diff options
25 files changed, 39 insertions, 39 deletions
diff --git a/src/server/game/AI/CoreAI/GuardAI.cpp b/src/server/game/AI/CoreAI/GuardAI.cpp index 3e541ccfd84..547d074e7d6 100644 --- a/src/server/game/AI/CoreAI/GuardAI.cpp +++ b/src/server/game/AI/CoreAI/GuardAI.cpp @@ -57,15 +57,15 @@ void GuardAI::EnterEvadeMode(EvadeReason /*why*/) { me->GetMotionMaster()->MoveIdle(); me->CombatStop(true); - me->GetThreatManager().ClearAllThreat(); + me->GetThreatManager().NotifyDisengaged(); return; } TC_LOG_TRACE("scritps.ai", "GuardAI::EnterEvadeMode: %s enters evade mode.", me->GetGUID().ToString().c_str()); me->RemoveAllAuras(); - me->GetThreatManager().ClearAllThreat(); me->CombatStop(true); + me->GetThreatManager().NotifyDisengaged(); me->GetMotionMaster()->MoveTargetedHome(); } diff --git a/src/server/game/AI/CreatureAI.cpp b/src/server/game/AI/CreatureAI.cpp index a7d2888fc0b..cfb58a99826 100644 --- a/src/server/game/AI/CreatureAI.cpp +++ b/src/server/game/AI/CreatureAI.cpp @@ -220,9 +220,8 @@ bool CreatureAI::_EnterEvadeMode(EvadeReason /*why*/) me->RemoveAurasOnEvade(); - // sometimes bosses stuck in combat? - me->GetThreatManager().ClearAllThreat(); me->CombatStop(true); + me->GetThreatManager().NotifyDisengaged(); me->LoadCreaturesAddon(); me->SetLootRecipient(nullptr); me->ResetPlayerDamageReq(); @@ -230,10 +229,7 @@ bool CreatureAI::_EnterEvadeMode(EvadeReason /*why*/) me->SetCannotReachTarget(false); me->DoNotReacquireTarget(); - if (me->IsInEvadeMode()) - return false; - - return true; + return !me->IsInEvadeMode(); } static const uint32 BOUNDARY_VISUALIZE_CREATURE = 15425; diff --git a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp index 3f5ff9a74ea..37dec1a6fe8 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp @@ -96,8 +96,8 @@ void EscortAI::ReturnToLastPoint() void EscortAI::EnterEvadeMode(EvadeReason /*why*/) { me->RemoveAllAuras(); - me->GetThreatManager().ClearAllThreat(); me->CombatStop(true); + me->GetThreatManager().NotifyDisengaged(); me->SetLootRecipient(nullptr); if (HasEscortState(STATE_ESCORT_ESCORTING)) diff --git a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp index 40ebf4ee44d..04c6f0a3376 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp @@ -107,8 +107,8 @@ void FollowerAI::EnterEvadeMode(EvadeReason /*why*/) return; me->RemoveAllAuras(); - me->GetThreatManager().ClearAllThreat(); me->CombatStop(true); + me->GetThreatManager().NotifyDisengaged(); me->SetLootRecipient(nullptr); me->SetCannotReachTarget(false); me->DoNotReacquireTarget(); diff --git a/src/server/game/Combat/ThreatManager.cpp b/src/server/game/Combat/ThreatManager.cpp index 83c86f59e1a..626d42042b5 100644 --- a/src/server/game/Combat/ThreatManager.cpp +++ b/src/server/game/Combat/ThreatManager.cpp @@ -478,6 +478,10 @@ void ThreatManager::ClearAllThreat() _myThreatListEntries.begin()->second->UnregisterAndFree(); while (!_myThreatListEntries.empty()); } +} + +void ThreatManager::NotifyDisengaged() +{ // note: i don't really like having this here // (maybe engage flag should be in creature ai? it's inherently an AI property...) if (_owner->IsEngaged()) diff --git a/src/server/game/Combat/ThreatManager.h b/src/server/game/Combat/ThreatManager.h index 12beb54c486..1eda7d01e15 100644 --- a/src/server/game/Combat/ThreatManager.h +++ b/src/server/game/Combat/ThreatManager.h @@ -154,6 +154,9 @@ class TC_GAME_API ThreatManager void ClearThreat(ThreatReference* ref); // Removes all targets from the threat list (will cause evade in UpdateVictim if called) void ClearAllThreat(); + // THIS SHOULD ONLY BE CALLED FROM A CREATURE'S AI (typically in EnterEvadeMode) + // notify the unit that the AI has disengaged + void NotifyDisengaged(); // Fixate on the passed target; this target will always be selected until the fixate is cleared // (if the target is not in the threat list, does nothing) diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 5422bee3a8e..9f288407813 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -8613,7 +8613,6 @@ void Unit::setDeathState(DeathState s) if (s != ALIVE && s != JUST_RESPAWNED) { CombatStop(); - GetThreatManager().ClearAllThreat(); ClearComboPointHolders(); // any combo points pointed to unit lost at it death if (IsNonMeleeSpellCast(false)) diff --git a/src/server/game/Grids/ObjectGridLoader.cpp b/src/server/game/Grids/ObjectGridLoader.cpp index ada845e0234..2c17aaa4b1a 100644 --- a/src/server/game/Grids/ObjectGridLoader.cpp +++ b/src/server/game/Grids/ObjectGridLoader.cpp @@ -255,7 +255,6 @@ void ObjectGridStoper::Visit(CreatureMapType &m) if (iter->GetSource()->IsInCombat()) { iter->GetSource()->CombatStop(); - iter->GetSource()->GetThreatManager().ClearAllThreat(); iter->GetSource()->AI()->EnterEvadeMode(); } } diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/instance_blackrock_depths.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/instance_blackrock_depths.cpp index 5ca04ace1f8..70f8f69379f 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/instance_blackrock_depths.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/instance_blackrock_depths.cpp @@ -398,8 +398,8 @@ public: {//do not call EnterEvadeMode(), it will create infinit loops boss->Respawn(); boss->RemoveAllAuras(); - boss->GetThreatManager().ClearAllThreat(); boss->CombatStop(true); + boss->GetThreatManager().NotifyDisengaged(); boss->LoadCreaturesAddon(); boss->GetMotionMaster()->MoveTargetedHome(); boss->SetLootRecipient(nullptr); diff --git a/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp b/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp index 9db2c7e2042..c46ac193ab6 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp @@ -1258,7 +1258,7 @@ public: Julianne->GetMotionMaster()->Clear(); Julianne->setDeathState(JUST_DIED); Julianne->CombatStop(true); - Julianne->GetThreatManager().ClearAllThreat(); + Julianne->GetThreatManager().NotifyDisengaged(); Julianne->SetUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE); } return; @@ -1528,7 +1528,7 @@ void boss_julianne::boss_julianneAI::DamageTaken(Unit* /*done_by*/, uint32 &dama Romulo->GetMotionMaster()->Clear(); Romulo->setDeathState(JUST_DIED); Romulo->CombatStop(true); - Romulo->GetThreatManager().ClearAllThreat(); + Romulo->GetThreatManager().NotifyDisengaged(); Romulo->SetUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE); } diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp index 3f9b7f814c7..931df7115d0 100644 --- a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp @@ -1386,8 +1386,8 @@ public: if (me->HasAura(SPELL_THE_MIGHT_OF_MOGRAINE)) me->RemoveAurasDueToSpell(SPELL_THE_MIGHT_OF_MOGRAINE); me->RemoveAllAuras(); - me->GetThreatManager().ClearAllThreat(); me->CombatStop(true); + me->GetThreatManager().NotifyDisengaged(); me->InterruptNonMeleeSpells(false); me->SetWalk(false); @@ -1407,8 +1407,8 @@ public: if (Creature* temp = ObjectAccessor::GetCreature(*me, uiKorfaxGUID)) { temp->RemoveAllAuras(); - temp->GetThreatManager().ClearAllThreat(); temp->CombatStop(true); + temp->GetThreatManager().NotifyDisengaged(); temp->AttackStop(); temp->SetFaction(me->GetFaction()); temp->SetWalk(false); @@ -1418,7 +1418,6 @@ public: if (Creature* temp = ObjectAccessor::GetCreature(*me, uiMaxwellGUID)) { temp->RemoveAllAuras(); - temp->GetThreatManager().ClearAllThreat(); temp->CombatStop(true); temp->AttackStop(); temp->SetFaction(me->GetFaction()); @@ -1429,8 +1428,8 @@ public: if (Creature* temp = ObjectAccessor::GetCreature(*me, uiEligorGUID)) { temp->RemoveAllAuras(); - temp->GetThreatManager().ClearAllThreat(); temp->CombatStop(true); + temp->GetThreatManager().NotifyDisengaged(); temp->AttackStop(); temp->SetFaction(me->GetFaction()); temp->SetWalk(false); @@ -1441,8 +1440,8 @@ public: if (Creature* temp = ObjectAccessor::GetCreature(*me, uiKoltiraGUID)) { temp->RemoveAllAuras(); - temp->GetThreatManager().ClearAllThreat(); temp->CombatStop(true); + temp->GetThreatManager().NotifyDisengaged(); temp->AttackStop(); temp->SetFaction(me->GetFaction()); temp->SetWalk(false); @@ -1456,8 +1455,8 @@ public: if (Creature* temp = ObjectAccessor::GetCreature(*me, uiThassarianGUID)) { temp->RemoveAllAuras(); - temp->GetThreatManager().ClearAllThreat(); temp->CombatStop(true); + temp->GetThreatManager().NotifyDisengaged(); temp->AttackStop(); temp->SetFaction(me->GetFaction()); temp->SetWalk(false); diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp index a2f18999d41..9abbf1269c5 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp @@ -423,8 +423,8 @@ void hyjalAI::EnterEvadeMode(EvadeReason /*why*/) { if (me->GetEntry() != JAINA) me->RemoveAllAuras(); - me->GetThreatManager().ClearAllThreat(); me->CombatStop(true); + me->GetThreatManager().NotifyDisengaged(); me->LoadCreaturesAddon(); if (me->IsAlive()) diff --git a/src/server/scripts/Kalimdor/zone_desolace.cpp b/src/server/scripts/Kalimdor/zone_desolace.cpp index f9a76edc77b..e57fb68463c 100644 --- a/src/server/scripts/Kalimdor/zone_desolace.cpp +++ b/src/server/scripts/Kalimdor/zone_desolace.cpp @@ -90,7 +90,7 @@ public: me->UpdateEntry(NPC_TAMED_KODO); me->CombatStop(); - me->GetThreatManager().ClearAllThreat(); + me->GetThreatManager().NotifyDisengaged(); me->SetFaction(FACTION_FRIENDLY); me->SetSpeedRate(MOVE_RUN, 0.6f); me->GetMotionMaster()->MoveFollow(caster, PET_FOLLOW_DIST, me->GetFollowAngle()); diff --git a/src/server/scripts/Kalimdor/zone_the_barrens.cpp b/src/server/scripts/Kalimdor/zone_the_barrens.cpp index f0072b7617e..90ce8c130f6 100644 --- a/src/server/scripts/Kalimdor/zone_the_barrens.cpp +++ b/src/server/scripts/Kalimdor/zone_the_barrens.cpp @@ -220,8 +220,8 @@ public: void DoFriend() { me->RemoveAllAuras(); - me->GetThreatManager().ClearAllThreat(); me->CombatStop(true); + me->GetThreatManager().NotifyDisengaged(); me->StopMoving(); me->GetMotionMaster()->MoveIdle(); diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp index c998659c27b..9baa007d72c 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp @@ -1156,7 +1156,7 @@ class npc_dark_nucleus : public CreatureScript if (attacker == me) return; - me->GetThreatManager().ClearAllThreat(); + me->GetThreatManager().ResetAllThreat(); AddThreat(attacker, 500000000.0f); } diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp index 18d5135ae66..45b64917dc4 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp @@ -579,8 +579,8 @@ struct gunship_npc_AI : public ScriptedAI if (!me->IsAlive() || !me->IsInCombat()) return; - me->GetThreatManager().ClearAllThreat(); me->CombatStop(true); + me->GetThreatManager().NotifyDisengaged(); me->GetMotionMaster()->MoveTargetedHome(); } @@ -724,8 +724,8 @@ class npc_gunship : public CreatureScript { Creature* stalker = *itr; stalker->RemoveAllAuras(); - stalker->GetThreatManager().ClearAllThreat(); stalker->CombatStop(true); + stalker->GetThreatManager().NotifyDisengaged(); } uint32 explosionSpell = isVictory ? SPELL_EXPLOSION_VICTORY : SPELL_EXPLOSION_WIPE; @@ -883,8 +883,8 @@ class npc_high_overlord_saurfang_igb : public CreatureScript if (!me->IsAlive()) return; - me->GetThreatManager().ClearAllThreat(); me->CombatStop(true); + me->GetThreatManager().NotifyDisengaged(); me->GetMotionMaster()->MoveTargetedHome(); Reset(); @@ -1147,8 +1147,8 @@ class npc_muradin_bronzebeard_igb : public CreatureScript if (!me->IsAlive()) return; - me->GetThreatManager().ClearAllThreat(); me->CombatStop(true); + me->GetThreatManager().NotifyDisengaged(); me->GetMotionMaster()->MoveTargetedHome(); Reset(); diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp index a6432aa156f..99340630b99 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp @@ -933,7 +933,7 @@ class spell_putricide_ooze_channel : public SpellScriptLoader void StartAttack() { GetCaster()->ClearUnitState(UNIT_STATE_CASTING); - GetCaster()->GetThreatManager().ClearAllThreat(); + GetCaster()->GetThreatManager().ResetAllThreat(); GetCaster()->ToCreature()->AI()->AttackStart(GetHitUnit()); GetCaster()->GetThreatManager().AddThreat(GetHitUnit(), 500000000.0f, nullptr, true, true); // value seen in sniff } diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp index eefbefeac53..086b0eeeca2 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp @@ -1800,8 +1800,8 @@ class npc_terenas_menethil : public CreatureScript if (!me->IsAlive()) return; - me->GetThreatManager().ClearAllThreat(); me->CombatStop(false); + me->GetThreatManager().NotifyDisengaged(); } void DamageTaken(Unit* /*attacker*/, uint32& damage) override diff --git a/src/server/scripts/Northrend/Nexus/Oculus/boss_urom.cpp b/src/server/scripts/Northrend/Nexus/Oculus/boss_urom.cpp index 224ee49e769..4187b86cfe8 100644 --- a/src/server/scripts/Northrend/Nexus/Oculus/boss_urom.cpp +++ b/src/server/scripts/Northrend/Nexus/Oculus/boss_urom.cpp @@ -290,7 +290,7 @@ class boss_urom : public CreatureScript { me->RemoveAllAuras(); me->CombatStop(false); - me->GetThreatManager().ClearAllThreat(); + me->GetThreatManager().NotifyDisengaged(); } void SpellHit(Unit* /*caster*/, SpellInfo const* spellInfo) override diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp index baae21d8268..b41f7639b90 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp @@ -634,7 +634,7 @@ class boss_freya : public CreatureScript Elder->RemoveAllAuras(); Elder->AttackStop(); Elder->CombatStop(true); - Elder->GetThreatManager().ClearAllThreat(); + Elder->GetThreatManager().NotifyDisengaged(); Elder->AI()->DoAction(ACTION_ELDER_FREYA_KILLED); } } diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp index 7cd71a8a5b7..6a37225b65f 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp @@ -1310,7 +1310,7 @@ class npc_mimiron_assault_bot : public CreatureScript { if (Unit* newTarget = SelectTarget(SELECT_TARGET_MINDISTANCE, 0, 30.0f, true)) { - me->GetThreatManager().ClearAllThreat(); + me->GetThreatManager().ResetAllThreat(); AttackStart(newTarget); } } diff --git a/src/server/scripts/Northrend/zone_borean_tundra.cpp b/src/server/scripts/Northrend/zone_borean_tundra.cpp index 6f9f5eac349..7033fa74310 100644 --- a/src/server/scripts/Northrend/zone_borean_tundra.cpp +++ b/src/server/scripts/Northrend/zone_borean_tundra.cpp @@ -735,7 +735,7 @@ public: Creature* owner = GetOwner()->ToCreature(); owner->RemoveAllAurasExceptType(SPELL_AURA_DUMMY); owner->CombatStop(true); - owner->GetThreatManager().ClearAllThreat(); + owner->GetThreatManager().NotifyDisengaged(); owner->GetMotionMaster()->Clear(); owner->GetMotionMaster()->MoveFollow(GetCaster(), 4.0f, 0.0f); owner->CastSpell(owner, SPELL_SUBDUED, true); diff --git a/src/server/scripts/Outland/zone_hellfire_peninsula.cpp b/src/server/scripts/Outland/zone_hellfire_peninsula.cpp index 887d2c2788a..e9b7a907b05 100644 --- a/src/server/scripts/Outland/zone_hellfire_peninsula.cpp +++ b/src/server/scripts/Outland/zone_hellfire_peninsula.cpp @@ -101,8 +101,8 @@ public: me->SetFaction(FACTION_FRIENDLY); me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); me->RemoveAllAuras(); - me->GetThreatManager().ClearAllThreat(); me->CombatStop(true); + me->GetThreatManager().NotifyDisengaged(); Talk(SAY_FREE); return; } @@ -973,8 +973,8 @@ public: _events.Reset(); me->RestoreFaction(); me->RemoveAllAuras(); - me->GetThreatManager().ClearAllThreat(); me->CombatStop(true); + me->GetThreatManager().NotifyDisengaged(); me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); me->SetImmuneToPC(true); Talk(SAY_DEFEATED); diff --git a/src/server/scripts/Outland/zone_terokkar_forest.cpp b/src/server/scripts/Outland/zone_terokkar_forest.cpp index feeaf352589..9a000906d7c 100644 --- a/src/server/scripts/Outland/zone_terokkar_forest.cpp +++ b/src/server/scripts/Outland/zone_terokkar_forest.cpp @@ -91,8 +91,8 @@ public: me->SetFaction(FACTION_FRIENDLY); me->SetStandState(UNIT_STAND_STATE_SIT); me->RemoveAllAuras(); - me->GetThreatManager().ClearAllThreat(); me->CombatStop(true); + me->GetThreatManager().NotifyDisengaged(); UnkorUnfriendly_Timer = 60000; } diff --git a/src/server/scripts/Pet/pet_priest.cpp b/src/server/scripts/Pet/pet_priest.cpp index 0198c4bc542..573dd9750ea 100644 --- a/src/server/scripts/Pet/pet_priest.cpp +++ b/src/server/scripts/Pet/pet_priest.cpp @@ -49,8 +49,8 @@ class npc_pet_pri_lightwell : public CreatureScript if (!me->IsAlive()) return; - me->GetThreatManager().ClearAllThreat(); me->CombatStop(true); + me->GetThreatManager().NotifyDisengaged(); me->ResetPlayerDamageReq(); } }; |