mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Misc: cleanup SetInFront uses
Set in front modifies only the serverside orientation, use with care.
Also check for current focus to prevent things like incorrect damage on casting creatures (ie dragon breath direction change in your face because of some taunt missclick)
(cherry picked from commit 229444b74a)
This commit is contained in:
@@ -83,8 +83,7 @@ void TotemAI::UpdateAI(uint32 /*diff*/)
|
||||
i_victimGuid = victim->GetGUID();
|
||||
|
||||
// attack
|
||||
me->SetInFront(victim); // client change orientation by self
|
||||
me->CastSpell(victim, me->ToTotem()->GetSpell(), false);
|
||||
me->CastSpell(victim, me->ToTotem()->GetSpell());
|
||||
}
|
||||
else
|
||||
i_victimGuid.Clear();
|
||||
|
||||
@@ -328,7 +328,7 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
|
||||
void MustReacquireTarget() { m_shouldReacquireTarget = true; } // flags the Creature for forced (client displayed) target reacquisition in the next ::Update call
|
||||
void DoNotReacquireTarget() { m_shouldReacquireTarget = false; m_suppressedTarget = ObjectGuid::Empty; m_suppressedOrientation = 0.0f; }
|
||||
void FocusTarget(Spell const* focusSpell, WorldObject const* target);
|
||||
bool IsFocusing(Spell const* focusSpell = nullptr, bool withDelay = false);
|
||||
bool IsFocusing(Spell const* focusSpell = nullptr, bool withDelay = false) override;
|
||||
void ReleaseFocus(Spell const* focusSpell = nullptr, bool withDelay = true);
|
||||
|
||||
bool IsMovementPreventedByCasting() const override;
|
||||
|
||||
@@ -8839,7 +8839,8 @@ void Unit::TauntApply(Unit* taunter)
|
||||
if (target && target == taunter)
|
||||
return;
|
||||
|
||||
SetInFront(taunter);
|
||||
if (!IsFocusing(nullptr, true))
|
||||
SetInFront(taunter);
|
||||
if (creature->IsAIEnabled)
|
||||
creature->AI()->AttackStart(taunter);
|
||||
|
||||
@@ -8878,7 +8879,8 @@ void Unit::TauntFadeOut(Unit* taunter)
|
||||
|
||||
if (target && target != taunter)
|
||||
{
|
||||
SetInFront(target);
|
||||
if (!IsFocusing(nullptr, true))
|
||||
SetInFront(target);
|
||||
if (creature->IsAIEnabled)
|
||||
creature->AI()->AttackStart(target);
|
||||
}
|
||||
@@ -8960,7 +8962,7 @@ Unit* Creature::SelectVictim()
|
||||
|
||||
if (target && _IsTargetAcceptable(target) && CanCreatureAttack(target))
|
||||
{
|
||||
if (!IsFocusing())
|
||||
if (!IsFocusing(nullptr, true))
|
||||
SetInFront(target);
|
||||
return target;
|
||||
}
|
||||
|
||||
@@ -1659,6 +1659,7 @@ class TC_GAME_API Unit : public WorldObject
|
||||
virtual SpellInfo const* GetCastSpellInfo(SpellInfo const* spellInfo) const;
|
||||
uint32 GetCastSpellXSpellVisualId(SpellInfo const* spellInfo) const;
|
||||
|
||||
virtual bool IsFocusing(Spell const* /*focusSpell*/ = nullptr, bool /*withDelay*/ = false) { return false; }
|
||||
virtual bool IsMovementPreventedByCasting() const;
|
||||
|
||||
SpellHistory* GetSpellHistory() { return _spellHistory; }
|
||||
|
||||
@@ -331,13 +331,15 @@ void WorldSession::HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint32 spe
|
||||
{
|
||||
if (unit_target)
|
||||
{
|
||||
pet->SetInFront(unit_target);
|
||||
if (!pet->IsFocusing())
|
||||
pet->SetInFront(unit_target);
|
||||
if (Player* player = unit_target->ToPlayer())
|
||||
pet->SendUpdateToPlayer(player);
|
||||
}
|
||||
else if (Unit* unit_target2 = spell->m_targets.GetUnitTarget())
|
||||
{
|
||||
pet->SetInFront(unit_target2);
|
||||
if (!pet->IsFocusing())
|
||||
pet->SetInFront(unit_target2);
|
||||
if (Player* player = unit_target2->ToPlayer())
|
||||
pet->SendUpdateToPlayer(player);
|
||||
}
|
||||
|
||||
@@ -196,8 +196,8 @@ public:
|
||||
++IntroPhase;
|
||||
break;
|
||||
case 1:
|
||||
me->SetInFront(Madrigosa);
|
||||
Madrigosa->SetInFront(me);
|
||||
me->SetFacingToObject(Madrigosa);
|
||||
Madrigosa->SetFacingToObject(me);
|
||||
Madrigosa->AI()->Talk(YELL_MADR_INTRO, me);
|
||||
IntroPhaseTimer = 9000;
|
||||
++IntroPhase;
|
||||
|
||||
@@ -532,8 +532,8 @@ public:
|
||||
return 1000;
|
||||
case 2:
|
||||
Talk(GEEZLE_SAY_1, Spark);
|
||||
Spark->SetInFront(me);
|
||||
me->SetInFront(Spark);
|
||||
Spark->SetFacingToObject(me);
|
||||
me->SetFacingToObject(Spark);
|
||||
return 5000;
|
||||
case 3:
|
||||
Spark->AI()->Talk(SPARK_SAY_2);
|
||||
|
||||
@@ -70,8 +70,8 @@ public:
|
||||
void LockRageclaw(Creature* rageclaw)
|
||||
{
|
||||
// pointer check not needed
|
||||
me->SetInFront(rageclaw);
|
||||
rageclaw->SetInFront(me);
|
||||
me->SetFacingToObject(rageclaw);
|
||||
rageclaw->SetFacingToObject(me);
|
||||
|
||||
DoCast(rageclaw, SPELL_LEFT_CHAIN, true);
|
||||
DoCast(rageclaw, SPELL_RIGHT_CHAIN, true);
|
||||
|
||||
@@ -469,7 +469,7 @@ public:
|
||||
player->GroupEventHappens(ESCAPE_FROM_FIREWING_POINT_A, me);
|
||||
else if (player->GetTeam() == HORDE)
|
||||
player->GroupEventHappens(ESCAPE_FROM_FIREWING_POINT_H, me);
|
||||
me->SetInFront(player);
|
||||
me->SetFacingToObject(player);
|
||||
break;
|
||||
case 30:
|
||||
me->HandleEmoteCommand(EMOTE_ONESHOT_WAVE);
|
||||
|
||||
@@ -420,7 +420,7 @@ public:
|
||||
{
|
||||
if (me->IsWithinLOS(player->GetPositionX(), player->GetPositionY(), player->GetPositionZ()) && me->IsWithinDistInMap(player, 30.0f))
|
||||
{
|
||||
me->SetInFront(player);
|
||||
me->SetFacingToObject(player);
|
||||
Active = false;
|
||||
|
||||
switch (emote)
|
||||
|
||||
Reference in New Issue
Block a user