aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorccrs <ccrs@users.noreply.github.com>2017-04-27 15:34:01 +0200
committerccrs <ccrs@users.noreply.github.com>2017-04-27 15:34:01 +0200
commit229444b74a7e2176db142e0446d4268995c5aad6 (patch)
treef5b767f57bf22894af6f471b8626da2a6848ff5f /src
parentc7a57e2a093ada2ece7a01eac2f627aeb26b08d5 (diff)
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)
Diffstat (limited to 'src')
-rw-r--r--src/server/game/AI/CoreAI/TotemAI.cpp3
-rw-r--r--src/server/game/Entities/Creature/Creature.h2
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp8
-rw-r--r--src/server/game/Entities/Unit/Unit.h1
-rw-r--r--src/server/game/Handlers/PetHandler.cpp6
-rw-r--r--src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_nefarian.cpp2
-rw-r--r--src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp4
-rw-r--r--src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp1
-rw-r--r--src/server/scripts/EasternKingdoms/ZulAman/boss_zuljin.cpp2
-rw-r--r--src/server/scripts/Kalimdor/zone_azuremyst_isle.cpp4
-rw-r--r--src/server/scripts/Kalimdor/zone_stonetalon_mountains.cpp2
-rw-r--r--src/server/scripts/Northrend/zone_zuldrak.cpp4
-rw-r--r--src/server/scripts/Outland/zone_terokkar_forest.cpp2
-rw-r--r--src/server/scripts/World/npcs_special.cpp2
14 files changed, 23 insertions, 20 deletions
diff --git a/src/server/game/AI/CoreAI/TotemAI.cpp b/src/server/game/AI/CoreAI/TotemAI.cpp
index d59df12022d..7de63cb6371 100644
--- a/src/server/game/AI/CoreAI/TotemAI.cpp
+++ b/src/server/game/AI/CoreAI/TotemAI.cpp
@@ -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();
diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h
index c70b6bb40b7..cb02c437d2f 100644
--- a/src/server/game/Entities/Creature/Creature.h
+++ b/src/server/game/Entities/Creature/Creature.h
@@ -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;
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 9f8b3900144..fc1aed52609 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -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;
}
diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h
index 9267c18d4d2..3312e88d3ba 100644
--- a/src/server/game/Entities/Unit/Unit.h
+++ b/src/server/game/Entities/Unit/Unit.h
@@ -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; }
diff --git a/src/server/game/Handlers/PetHandler.cpp b/src/server/game/Handlers/PetHandler.cpp
index 98d15158abb..c618978dff0 100644
--- a/src/server/game/Handlers/PetHandler.cpp
+++ b/src/server/game/Handlers/PetHandler.cpp
@@ -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);
}
diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_nefarian.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_nefarian.cpp
index 7320a6796ee..3a46d63fe5d 100644
--- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_nefarian.cpp
+++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_nefarian.cpp
@@ -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);
diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp
index bde2a220398..79fcb2634b1 100644
--- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp
+++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp
@@ -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;
diff --git a/src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp b/src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp
index 203d1266e6a..3a28a2569d1 100644
--- a/src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp
+++ b/src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp
@@ -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);*/
diff --git a/src/server/scripts/EasternKingdoms/ZulAman/boss_zuljin.cpp b/src/server/scripts/EasternKingdoms/ZulAman/boss_zuljin.cpp
index d766f3445ec..10d0772932c 100644
--- a/src/server/scripts/EasternKingdoms/ZulAman/boss_zuljin.cpp
+++ b/src/server/scripts/EasternKingdoms/ZulAman/boss_zuljin.cpp
@@ -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;
}
diff --git a/src/server/scripts/Kalimdor/zone_azuremyst_isle.cpp b/src/server/scripts/Kalimdor/zone_azuremyst_isle.cpp
index 1e823cd6714..c141b9ed608 100644
--- a/src/server/scripts/Kalimdor/zone_azuremyst_isle.cpp
+++ b/src/server/scripts/Kalimdor/zone_azuremyst_isle.cpp
@@ -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);
diff --git a/src/server/scripts/Kalimdor/zone_stonetalon_mountains.cpp b/src/server/scripts/Kalimdor/zone_stonetalon_mountains.cpp
index 8d8a24fcb10..ba41c523afb 100644
--- a/src/server/scripts/Kalimdor/zone_stonetalon_mountains.cpp
+++ b/src/server/scripts/Kalimdor/zone_stonetalon_mountains.cpp
@@ -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;
diff --git a/src/server/scripts/Northrend/zone_zuldrak.cpp b/src/server/scripts/Northrend/zone_zuldrak.cpp
index 0199340d0b9..5fec3f058fe 100644
--- a/src/server/scripts/Northrend/zone_zuldrak.cpp
+++ b/src/server/scripts/Northrend/zone_zuldrak.cpp
@@ -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);
diff --git a/src/server/scripts/Outland/zone_terokkar_forest.cpp b/src/server/scripts/Outland/zone_terokkar_forest.cpp
index d2a7a29e01a..834de219ea4 100644
--- a/src/server/scripts/Outland/zone_terokkar_forest.cpp
+++ b/src/server/scripts/Outland/zone_terokkar_forest.cpp
@@ -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);
diff --git a/src/server/scripts/World/npcs_special.cpp b/src/server/scripts/World/npcs_special.cpp
index 0edde6cd571..54a654527ba 100644
--- a/src/server/scripts/World/npcs_special.cpp
+++ b/src/server/scripts/World/npcs_special.cpp
@@ -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;