Core: Combat/threat system rewrite
Port From (https://github.com/TrinityCore/TrinityCore/commit/34c7810fe507eca1b8b9389630db5d5d26d92e77)
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -53,15 +53,14 @@ namespace Game.Entities
|
||||
protected List<Unit> attackerList = new();
|
||||
Dictionary<ReactiveType, uint> m_reactiveTimer = new();
|
||||
protected float[][] m_weaponDamage = new float[(int)WeaponAttackType.Max][];
|
||||
public float[] m_threatModifier = new float[(int)SpellSchools.Max];
|
||||
|
||||
uint[] m_baseAttackSpeed = new uint[(int)WeaponAttackType.Max];
|
||||
float[] m_modAttackSpeedPct = new float[(int)WeaponAttackType.Max];
|
||||
protected uint[] m_attackTimer = new uint[(int)WeaponAttackType.Max];
|
||||
|
||||
ThreatManager threatManager;
|
||||
HostileRefManager hostileRefManager;
|
||||
RedirectThreatInfo _redirectThreatInfo;
|
||||
CombatManager m_combatManager;
|
||||
ThreatManager m_threatManager;
|
||||
|
||||
protected Unit attacking;
|
||||
|
||||
public float ModMeleeHitChance { get; set; }
|
||||
@@ -520,27 +519,6 @@ namespace Game.Entities
|
||||
byte _chargesRemoved;
|
||||
}
|
||||
|
||||
public struct RedirectThreatInfo
|
||||
{
|
||||
ObjectGuid _targetGUID;
|
||||
uint _threatPct;
|
||||
|
||||
public ObjectGuid GetTargetGUID() { return _targetGUID; }
|
||||
public uint GetThreatPct() { return _threatPct; }
|
||||
|
||||
public void Set(ObjectGuid guid, uint pct)
|
||||
{
|
||||
_targetGUID = guid;
|
||||
_threatPct = pct;
|
||||
}
|
||||
|
||||
public void ModifyThreatPct(int amount)
|
||||
{
|
||||
amount += (int)_threatPct;
|
||||
_threatPct = (uint)(Math.Max(0, amount));
|
||||
}
|
||||
}
|
||||
|
||||
public class SpellPeriodicAuraLogInfo
|
||||
{
|
||||
public SpellPeriodicAuraLogInfo(AuraEffect _auraEff, uint _damage, uint _originalDamage, uint _overDamage, uint _absorb, uint _resist, float _multiplier, bool _critical)
|
||||
|
||||
@@ -58,7 +58,10 @@ namespace Game.Entities
|
||||
return true;
|
||||
if (HasUnitFlag2((UnitFlags2)0x1000000))
|
||||
return false;
|
||||
return HasUnitFlag(UnitFlags.PetInCombat | UnitFlags.Rename | UnitFlags.Unk15);
|
||||
if (IsPet() && HasUnitFlag(UnitFlags.PetInCombat))
|
||||
return true;
|
||||
|
||||
return HasUnitFlag(UnitFlags.Rename | UnitFlags.Unk15);
|
||||
}
|
||||
public virtual bool IsInWater()
|
||||
{
|
||||
|
||||
@@ -274,6 +274,8 @@ namespace Game.Entities
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UpdatePetCombatState();
|
||||
}
|
||||
|
||||
public bool SetCharmedBy(Unit charmer, CharmType type, AuraApplication aurApp = null)
|
||||
@@ -314,7 +316,6 @@ namespace Game.Entities
|
||||
|
||||
CastStop();
|
||||
CombatStop(); // @todo CombatStop(true) may cause crash (interrupt spells)
|
||||
GetThreatManager().ClearAllThreat();
|
||||
|
||||
Player playerCharmer = charmer.ToPlayer();
|
||||
|
||||
@@ -463,8 +464,6 @@ namespace Game.Entities
|
||||
|
||||
CastStop();
|
||||
CombatStop(); // @todo CombatStop(true) may cause crash (interrupt spells)
|
||||
GetHostileRefManager().DeleteReferences();
|
||||
GetThreatManager().ClearAllThreat();
|
||||
|
||||
if (_oldFactionId != 0)
|
||||
{
|
||||
@@ -545,6 +544,8 @@ namespace Game.Entities
|
||||
player.SetClientControl(this, true);
|
||||
}
|
||||
|
||||
EngageWithTarget(charmer);
|
||||
|
||||
// a guardian should always have charminfo
|
||||
if (playerCharmer && this != charmer.GetFirstControlled())
|
||||
playerCharmer.SendRemoveControlBar();
|
||||
@@ -651,6 +652,8 @@ namespace Game.Entities
|
||||
m_Controlled.Remove(charm);
|
||||
}
|
||||
}
|
||||
|
||||
UpdatePetCombatState();
|
||||
}
|
||||
|
||||
public Unit GetFirstControlled()
|
||||
@@ -698,6 +701,8 @@ namespace Game.Entities
|
||||
Log.outFatal(LogFilter.Unit, "Unit {0} is not able to release its minion {1}", GetEntry(), GetMinionGUID());
|
||||
if (!GetCharmGUID().IsEmpty())
|
||||
Log.outFatal(LogFilter.Unit, "Unit {0} is not able to release its charm {1}", GetEntry(), GetCharmGUID());
|
||||
if (!IsPet()) // pets don't use the flag for this
|
||||
RemoveUnitFlag(UnitFlags.PetInCombat); // m_controlled is now empty, so we know none of our minions are in combat
|
||||
}
|
||||
|
||||
public void SendPetActionFeedback(PetActionFeedback msg, uint spellId)
|
||||
@@ -794,5 +799,25 @@ namespace Game.Entities
|
||||
pet.SetFullHealth();
|
||||
return true;
|
||||
}
|
||||
|
||||
public void UpdatePetCombatState()
|
||||
{
|
||||
Cypher.Assert(!IsPet()); // player pets do not use UNIT_FLAG_PET_IN_COMBAT for this purpose - but player pets should also never have minions of their own to call this
|
||||
|
||||
bool state = false;
|
||||
foreach (Unit minion in m_Controlled)
|
||||
{
|
||||
if (minion.IsInCombat())
|
||||
{
|
||||
state = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (state)
|
||||
AddUnitFlag(UnitFlags.PetInCombat);
|
||||
else
|
||||
RemoveUnitFlag(UnitFlags.PetInCombat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1514,14 +1514,7 @@ namespace Game.Entities
|
||||
SendCombatLogMessage(data);
|
||||
}
|
||||
|
||||
public void EnergizeBySpell(Unit victim, uint spellId, int damage, PowerType powerType)
|
||||
{
|
||||
SpellInfo info = Global.SpellMgr.GetSpellInfo(spellId, GetMap().GetDifficultyID());
|
||||
if (info != null)
|
||||
EnergizeBySpell(victim, info, damage, powerType);
|
||||
}
|
||||
|
||||
void EnergizeBySpell(Unit victim, SpellInfo spellInfo, int damage, PowerType powerType)
|
||||
public void EnergizeBySpell(Unit victim, SpellInfo spellInfo, int damage, PowerType powerType)
|
||||
{
|
||||
int gain = victim.ModifyPower(powerType, damage, false);
|
||||
int overEnergize = damage - gain;
|
||||
|
||||
+1567
-66
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user