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:
ccrs
2017-04-27 15:34:01 +02:00
committed by funjoker
parent 2d4549023a
commit 104e745edf
10 changed files with 20 additions and 16 deletions

View File

@@ -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();

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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; }

View File

@@ -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);
}

View File

@@ -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;

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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)