aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKillyana <morphone1@gmail.com>2020-01-01 17:19:37 +0100
committerShauren <shauren.trinity@gmail.com>2021-12-19 17:44:00 +0100
commita7cf209428fae5b025a0dcdc6b00bcef12175ed6 (patch)
tree8713a0f972136fcc85b45ec01d2239ff573789a0 /src
parentd095d4afe95125bba64312025528a2c4aab157e0 (diff)
Core/Creature: Clear creature focus after an evade
(cherry picked from commit a32aeceb0da5d691eb655e80eb9ea7b32fc44839)
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.h3
-rw-r--r--src/server/game/Spells/Spell.cpp7
4 files changed, 16 insertions, 10 deletions
diff --git a/src/server/game/AI/CreatureAI.cpp b/src/server/game/AI/CreatureAI.cpp
index 71d01702f5b..53020cf8e21 100644
--- a/src/server/game/AI/CreatureAI.cpp
+++ b/src/server/game/AI/CreatureAI.cpp
@@ -316,6 +316,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 1383f86712c..c459a6e0fc2 100644
--- a/src/server/game/Entities/Creature/Creature.cpp
+++ b/src/server/game/Entities/Creature/Creature.cpp
@@ -3175,11 +3175,11 @@ void Creature::SetTarget(ObjectGuid const& 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() || HasUnitFlag2(UNIT_FLAG2_FEIGN_DEATH) || HasAuraType(SPELL_AURA_FEIGN_DEATH))
return;
@@ -3197,7 +3197,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)
@@ -3316,6 +3317,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 a0d42f8cdf6..a3fc0223bb4 100644
--- a/src/server/game/Entities/Creature/Creature.h
+++ b/src/server/game/Entities/Creature/Creature.h
@@ -25,7 +25,6 @@
#include "Duration.h"
#include "Loot.h"
#include "MapObject.h"
-
#include <list>
class CreatureAI;
@@ -348,7 +347,7 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
// Handling caster facing during spellcast
void SetTarget(ObjectGuid const& 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 63c83148d53..38b81819ffc 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -4777,10 +4777,9 @@ void Spell::SendChannelStart(uint32 duration)
unitCaster->AddChannelObject(target.TargetGUID);
if (m_UniqueTargetInfo.size() == 1 && m_UniqueGOTargetInfo.empty())
- if(target.TargetGUID != unitCaster->GetGUID())
- if (Creature* creatureCaster = unitCaster->ToCreature())
- if (!creatureCaster->HasSpellFocus(this))
- creatureCaster->SetSpellFocus(this, ObjectAccessor::GetWorldObject(*creatureCaster, target.TargetGUID));
+ if (Creature* creatureCaster = unitCaster->ToCreature())
+ if (!creatureCaster->HasSpellFocus(this))
+ creatureCaster->SetSpellFocus(this, ObjectAccessor::GetWorldObject(*creatureCaster, target.TargetGUID));
}
for (GOTargetInfo const& target : m_UniqueGOTargetInfo)