aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/game/AI/CreatureAI.cpp1
-rw-r--r--src/server/game/Entities/Creature/Creature.cpp15
-rw-r--r--src/server/game/Entities/Creature/Creature.h2
-rw-r--r--src/server/game/Spells/Spell.cpp8
4 files changed, 17 insertions, 9 deletions
diff --git a/src/server/game/AI/CreatureAI.cpp b/src/server/game/AI/CreatureAI.cpp
index 5f1d13e047c..791c53dba39 100644
--- a/src/server/game/AI/CreatureAI.cpp
+++ b/src/server/game/AI/CreatureAI.cpp
@@ -310,6 +310,7 @@ bool CreatureAI::_EnterEvadeMode(EvadeReason /*why*/)
me->SetLastDamagedTime(0);
me->SetCannotReachTarget(false);
me->DoNotReacquireSpellFocusTarget();
+ me->SetTarget(ObjectGuid::Empty);
me->GetSpellHistory()->ResetAllCooldowns();
EngagementOver();
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp
index 5274a37d7fd..691dd1e6144 100644
--- a/src/server/game/Entities/Creature/Creature.cpp
+++ b/src/server/game/Entities/Creature/Creature.cpp
@@ -3032,11 +3032,11 @@ void Creature::SetTarget(ObjectGuid guid)
void Creature::SetSpellFocus(Spell const* focusSpell, WorldObject const* target)
{
- // already focused
- if (_spellFocusInfo.Spell)
+ // Pointer validation and checking for a already existing focus
+ if (_spellFocusInfo.Spell || !focusSpell)
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() || HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH) || HasAuraType(SPELL_AURA_FEIGN_DEATH))
return;
@@ -3054,7 +3054,8 @@ void Creature::SetSpellFocus(Spell const* focusSpell, WorldObject const* target)
if (spellInfo->HasAura(SPELL_AURA_CONTROL_VEHICLE))
return;
- if ((!target || target == this) && !focusSpell->GetCastTime()) // 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 && (!focusSpell->GetCastTime() && !spellInfo->IsChanneled()))
return;
// store pre-cast values for target and orientation (used to later restore)
@@ -3174,6 +3175,12 @@ void Creature::ReacquireSpellFocusTarget()
_spellFocusInfo.Delay = 0;
}
+void Creature::DoNotReacquireSpellFocusTarget()
+{
+ _spellFocusInfo.Delay = 0;
+ _spellFocusInfo.Spell = nullptr;
+}
+
bool Creature::IsMovementPreventedByCasting() const
{
// first check if currently a movement allowed channel is active and we're not casting
diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h
index e8530446388..fe594332f7e 100644
--- a/src/server/game/Entities/Creature/Creature.h
+++ b/src/server/game/Entities/Creature/Creature.h
@@ -341,7 +341,7 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
// Handling caster facing during spellcast
void SetTarget(ObjectGuid guid) override;
- void DoNotReacquireSpellFocusTarget() { _spellFocusInfo.Delay = 0; }
+ void DoNotReacquireSpellFocusTarget();
void SetSpellFocus(Spell const* focusSpell, WorldObject const* target);
bool HasSpellFocus(Spell const* focusSpell = nullptr) const override;
void ReleaseSpellFocus(Spell const* focusSpell = nullptr, bool withDelay = true);
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index ec83602fa36..733c7d5eb89 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -4552,10 +4552,10 @@ void Spell::SendChannelStart(uint32 duration)
{
unitCaster->SetChannelObjectGuid(channelTarget);
- if (channelTarget != unitCaster->GetGUID())
- if (Creature* creatureCaster = unitCaster->ToCreature())
- if (!creatureCaster->HasSpellFocus(this))
- creatureCaster->SetSpellFocus(this, ObjectAccessor::GetWorldObject(*creatureCaster, channelTarget));
+ if (Creature* creatureCaster = m_caster->ToCreature())
+ if (!creatureCaster->HasSpellFocus(this))
+ creatureCaster->SetSpellFocus(this,
+ ObjectAccessor::GetWorldObject(*creatureCaster, channelTarget));
}
unitCaster->SetUInt32Value(UNIT_CHANNEL_SPELL, m_spellInfo->Id);