mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +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)
This commit is contained in:
@@ -84,8 +84,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();
|
||||
|
||||
@@ -714,7 +714,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;
|
||||
|
||||
@@ -9524,7 +9524,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);
|
||||
|
||||
@@ -9563,7 +9564,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);
|
||||
}
|
||||
@@ -9645,7 +9647,7 @@ Unit* Creature::SelectVictim()
|
||||
|
||||
if (target && _IsTargetAcceptable(target) && CanCreatureAttack(target))
|
||||
{
|
||||
if (!IsFocusing())
|
||||
if (!IsFocusing(nullptr, true))
|
||||
SetInFront(target);
|
||||
return target;
|
||||
}
|
||||
|
||||
@@ -1902,6 +1902,7 @@ class TC_GAME_API Unit : public WorldObject
|
||||
Spell* FindCurrentSpellBySpellId(uint32 spell_id) const;
|
||||
int32 GetCurrentSpellCastTime(uint32 spell_id) const;
|
||||
|
||||
virtual bool IsFocusing(Spell const* /*focusSpell*/ = nullptr, bool /*withDelay*/ = false) { return false; }
|
||||
virtual bool IsMovementPreventedByCasting() const;
|
||||
|
||||
SpellHistory* GetSpellHistory() { return m_spellHistory; }
|
||||
|
||||
@@ -325,13 +325,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);
|
||||
}
|
||||
|
||||
@@ -271,7 +271,7 @@ public:
|
||||
case EVENT_SUCCESS_1:
|
||||
if (Unit* player = me->SelectNearestPlayer(60.0f))
|
||||
{
|
||||
me->SetInFront(player);
|
||||
me->SetFacingToObject(player);
|
||||
Talk(SAY_SUCCESS);
|
||||
if (GameObject* portcullis1 = me->FindNearestGameObject(GO_PORTCULLIS_ACTIVE, 65.0f))
|
||||
portcullis1->SetGoState(GO_STATE_ACTIVE);
|
||||
|
||||
@@ -194,8 +194,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;
|
||||
|
||||
@@ -242,7 +242,6 @@ class boss_akilzon : public CreatureScript
|
||||
{
|
||||
TargetGUID = target->GetGUID();
|
||||
DoCast(target, SPELL_STATIC_DISRUPTION, false);
|
||||
me->SetInFront(me->GetVictim());
|
||||
}
|
||||
/*if (float dist = me->IsWithinDist3d(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 5.0f) dist = 5.0f;
|
||||
SDisruptAOEVisual_Timer = 1000 + floor(dist / 30 * 1000.0f);*/
|
||||
|
||||
@@ -545,7 +545,7 @@ class boss_zuljin : public CreatureScript
|
||||
if (Flame_Breath_Timer <= diff)
|
||||
{
|
||||
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
|
||||
me->SetInFront(target);
|
||||
me->SetFacingToObject(target);
|
||||
DoCast(me, SPELL_FLAME_BREATH);
|
||||
Flame_Breath_Timer = 10000;
|
||||
}
|
||||
|
||||
@@ -533,8 +533,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);
|
||||
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
me->SummonCreature(NPC_GRIMTOTEM_SORCERER, -36.37f, -496.23f, -45.71f, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000);
|
||||
break;
|
||||
case 18:
|
||||
me->SetInFront(player);
|
||||
me->SetFacingToObject(player);
|
||||
Talk(SAY_END);
|
||||
player->GroupEventHappens(QUEST_PROTECT_KAYA, me);
|
||||
break;
|
||||
|
||||
@@ -67,8 +67,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);
|
||||
|
||||
@@ -470,7 +470,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);
|
||||
|
||||
@@ -421,7 +421,7 @@ public:
|
||||
{
|
||||
if (me->IsWithinLOS(player->GetPositionX(), player->GetPositionY(), player->GetPositionZ()) && me->IsWithinDistInMap(player, 30.0f))
|
||||
{
|
||||
me->SetInFront(player);
|
||||
me->SetFacingToObject(player);
|
||||
Active = false;
|
||||
|
||||
WorldPacket data;
|
||||
|
||||
Reference in New Issue
Block a user