Core/Creature: Clear creature focus after an evade

Port From (https://github.com/TrinityCore/TrinityCore/commit/a7cf209428fae5b025a0dcdc6b00bcef12175ed6)
This commit is contained in:
hondacrx
2022-01-05 23:55:47 -05:00
parent 654c9743e3
commit 72fa0cd450
3 changed files with 16 additions and 13 deletions
+1
View File
@@ -314,6 +314,7 @@ namespace Game.AI
me.SetLastDamagedTime(0); me.SetLastDamagedTime(0);
me.SetCannotReachTarget(false); me.SetCannotReachTarget(false);
me.DoNotReacquireSpellFocusTarget(); me.DoNotReacquireSpellFocusTarget();
me.SetTarget(ObjectGuid.Empty);
me.GetSpellHistory().ResetAllCooldowns(); me.GetSpellHistory().ResetAllCooldowns();
EngagementOver(); EngagementOver();
+10 -5
View File
@@ -2903,11 +2903,11 @@ namespace Game.Entities
public void SetSpellFocus(Spell focusSpell, WorldObject target) public void SetSpellFocus(Spell focusSpell, WorldObject target)
{ {
// already focused // Pointer validation and checking for a already existing focus
if (_spellFocusInfo.Spell != null) if (_spellFocusInfo.Spell != null || focusSpell == null)
return; return;
// Prevent dead/feigning death creatures from setting a focus target, so they won't turn // Prevent dead / feign death creatures from setting a focus target
if (!IsAlive() || HasUnitFlag2(UnitFlags2.FeignDeath) || HasAuraType(AuraType.FeignDeath)) if (!IsAlive() || HasUnitFlag2(UnitFlags2.FeignDeath) || HasAuraType(AuraType.FeignDeath))
return; return;
@@ -2925,7 +2925,8 @@ namespace Game.Entities
if (spellInfo.HasAura(AuraType.ControlVehicle)) if (spellInfo.HasAura(AuraType.ControlVehicle))
return; return;
if ((!target || target == this) && focusSpell.GetCastTime() == 0) // instant cast, untargeted (or self-targeted) spell doesn't need any facing updates // instant non-channeled casts and non-target spells don't need facing updates
if (target == null && (focusSpell.GetCastTime() == 0 && !spellInfo.IsChanneled()))
return; return;
// store pre-cast values for target and orientation (used to later restore) // store pre-cast values for target and orientation (used to later restore)
@@ -3042,7 +3043,11 @@ namespace Game.Entities
_spellFocusInfo.Delay = 0; _spellFocusInfo.Delay = 0;
} }
public void DoNotReacquireSpellFocusTarget() { _spellFocusInfo.Delay = 0; } public void DoNotReacquireSpellFocusTarget()
{
_spellFocusInfo.Delay = 0;
_spellFocusInfo.Spell = null;
}
public ulong GetSpawnId() { return m_spawnId; } public ulong GetSpawnId() { return m_spawnId; }
+1 -4
View File
@@ -3993,16 +3993,13 @@ namespace Game.Spells
unitCaster.AddChannelObject(target.TargetGUID); unitCaster.AddChannelObject(target.TargetGUID);
if (m_UniqueTargetInfo.Count == 1 && m_UniqueGOTargetInfo.Empty()) if (m_UniqueTargetInfo.Count == 1 && m_UniqueGOTargetInfo.Empty())
{
if (target.TargetGUID != unitCaster.GetGUID())
{ {
Creature creatureCaster = unitCaster.ToCreature(); Creature creatureCaster = unitCaster.ToCreature();
if (creatureCaster != null) if (creatureCaster != null)
if (!creatureCaster.HasSpellFocus()) if (!creatureCaster.HasSpellFocus(this))
creatureCaster.SetSpellFocus(this, Global.ObjAccessor.GetWorldObject(creatureCaster, target.TargetGUID)); creatureCaster.SetSpellFocus(this, Global.ObjAccessor.GetWorldObject(creatureCaster, target.TargetGUID));
} }
} }
}
foreach (GOTargetInfo target in m_UniqueGOTargetInfo) foreach (GOTargetInfo target in m_UniqueGOTargetInfo)
if ((target.EffectMask & channelAuraMask) != 0) if ((target.EffectMask & channelAuraMask) != 0)