diff options
| author | Treeston <treeston.mmoc@gmail.com> | 2019-07-21 01:49:58 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2021-12-17 00:23:33 +0100 |
| commit | c13d83796f7b2111c5dcf8546bdd84eccd232ae3 (patch) | |
| tree | 03c4220a955113e46b3aa2f9cc270574ba3a79c4 /src/server/scripts | |
| parent | f9fe00bf8c4c913bcfedd8df7d8e1001129962a0 (diff) | |
Core/AI: Finally move the "is creature engaged" flag to be a property of the creature AI, where it honestly always belonged. Fixes #17981 and #23602 for real this time.
(cherry picked from commit 0e7c66cb4c7ff7d44e232d0b50703a48605ffd24)
Diffstat (limited to 'src/server/scripts')
18 files changed, 31 insertions, 38 deletions
diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp index 6e58a7ef96c..956400e1814 100644 --- a/src/server/scripts/Commands/cs_debug.cpp +++ b/src/server/scripts/Commands/cs_debug.cpp @@ -872,7 +872,7 @@ public: ThreatManager& mgr = target->GetThreatManager(); if (!target->IsAlive()) { - handler->PSendSysMessage("%s (%s) is not alive.", target->GetName().c_str(), target->GetGUID().ToString().c_str()); + handler->PSendSysMessage("%s (%s) is not alive.%s", target->GetName().c_str(), target->GetGUID().ToString().c_str(), target->IsEngaged() ? " (It is, however, engaged. Huh?)" : ""); return true; } 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 a326d9c2323..2057c55a29b 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/instance_blackrock_depths.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/instance_blackrock_depths.cpp @@ -372,16 +372,9 @@ public: if (Creature* boss = instance->GetCreature(TombBossGUIDs[i])) { if (!boss->IsAlive()) - {//do not call EnterEvadeMode(), it will create infinit loops boss->Respawn(); - boss->RemoveAllAuras(); - boss->CombatStop(true); - boss->GetThreatManager().NotifyDisengaged(); - boss->LoadCreaturesAddon(); - boss->GetMotionMaster()->MoveTargetedHome(); - boss->SetLootRecipient(nullptr); - } - boss->SetFaction(FACTION_FRIENDLY); + else + boss->SetFaction(FACTION_FRIENDLY); } } GhostKillCount = 0; diff --git a/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp b/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp index 68400643091..7c6fb0e4689 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp @@ -1257,7 +1257,6 @@ public: Julianne->GetMotionMaster()->Clear(); Julianne->setDeathState(JUST_DIED); Julianne->CombatStop(true); - Julianne->GetThreatManager().NotifyDisengaged(); Julianne->SetDynamicFlags(UNIT_DYNFLAG_LOOTABLE); } return; @@ -1527,7 +1526,6 @@ void boss_julianne::boss_julianneAI::DamageTaken(Unit* /*done_by*/, uint32 &dama Romulo->GetMotionMaster()->Clear(); Romulo->setDeathState(JUST_DIED); Romulo->CombatStop(true); - Romulo->GetThreatManager().NotifyDisengaged(); Romulo->SetDynamicFlags(UNIT_DYNFLAG_LOOTABLE); } diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp index 64c8497712c..f62c84c7dc0 100644 --- a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp @@ -1388,9 +1388,10 @@ public: me->RemoveAurasDueToSpell(SPELL_THE_MIGHT_OF_MOGRAINE); me->RemoveAllAuras(); me->CombatStop(true); - me->GetThreatManager().NotifyDisengaged(); me->InterruptNonMeleeSpells(false); me->SetWalk(false); + + EngagementOver(); for (uint8 i = 0; i < ENCOUNTER_DEFENDER_NUMBER; ++i) DespawnNPC(uiDefenderGUID[i]); @@ -1407,9 +1408,9 @@ public: if (Creature* temp = ObjectAccessor::GetCreature(*me, uiKorfaxGUID)) { + temp->AI()->EnterEvadeMode(); temp->RemoveAllAuras(); temp->CombatStop(true); - temp->GetThreatManager().NotifyDisengaged(); temp->AttackStop(); temp->SetFaction(me->GetFaction()); temp->SetWalk(false); @@ -1428,9 +1429,9 @@ public: if (Creature* temp = ObjectAccessor::GetCreature(*me, uiEligorGUID)) { + temp->AI()->EnterEvadeMode(); temp->RemoveAllAuras(); temp->CombatStop(true); - temp->GetThreatManager().NotifyDisengaged(); temp->AttackStop(); temp->SetFaction(me->GetFaction()); temp->SetWalk(false); @@ -1440,9 +1441,9 @@ public: if (Creature* temp = ObjectAccessor::GetCreature(*me, uiKoltiraGUID)) { + temp->AI()->EnterEvadeMode(); temp->RemoveAllAuras(); temp->CombatStop(true); - temp->GetThreatManager().NotifyDisengaged(); temp->AttackStop(); temp->SetFaction(me->GetFaction()); temp->SetWalk(false); @@ -1455,9 +1456,9 @@ public: if (Creature* temp = ObjectAccessor::GetCreature(*me, uiThassarianGUID)) { + temp->AI()->EnterEvadeMode(); temp->RemoveAllAuras(); 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 a8788d5da97..1ea1ccf835a 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp @@ -423,9 +423,10 @@ void hyjalAI::EnterEvadeMode(EvadeReason /*why*/) if (me->GetEntry() != JAINA) me->RemoveAllAuras(); me->CombatStop(true); - me->GetThreatManager().NotifyDisengaged(); + + EngagementOver(); + me->LoadCreaturesAddon(); - if (me->IsAlive()) me->GetMotionMaster()->MoveTargetedHome(); diff --git a/src/server/scripts/Kalimdor/zone_desolace.cpp b/src/server/scripts/Kalimdor/zone_desolace.cpp index 5a5e91e491c..46c6102e340 100644 --- a/src/server/scripts/Kalimdor/zone_desolace.cpp +++ b/src/server/scripts/Kalimdor/zone_desolace.cpp @@ -86,9 +86,11 @@ public: me->UpdateEntry(NPC_TAMED_KODO); me->CombatStop(); - me->GetThreatManager().NotifyDisengaged(); me->SetFaction(FACTION_FRIENDLY); me->SetSpeedRate(MOVE_RUN, 0.6f); + + EngagementOver(); + me->GetMotionMaster()->MoveFollow(caster, PET_FOLLOW_DIST, me->GetFollowAngle()); me->setActive(true); me->RemoveNpcFlag(UNIT_NPC_FLAG_GOSSIP); diff --git a/src/server/scripts/Kalimdor/zone_the_barrens.cpp b/src/server/scripts/Kalimdor/zone_the_barrens.cpp index 422be2b9b15..5b5add35f17 100644 --- a/src/server/scripts/Kalimdor/zone_the_barrens.cpp +++ b/src/server/scripts/Kalimdor/zone_the_barrens.cpp @@ -215,11 +215,11 @@ public: { me->RemoveAllAuras(); me->CombatStop(true); - me->GetThreatManager().NotifyDisengaged(); - me->StopMoving(); + + EngagementOver(); + me->GetMotionMaster()->MoveIdle(); - me->SetFaction(FACTION_FRIENDLY_F); me->HandleEmoteCommand(EMOTE_ONESHOT_SALUTE); } diff --git a/src/server/scripts/Maelstrom/Stonecore/stonecore.cpp b/src/server/scripts/Maelstrom/Stonecore/stonecore.cpp index 962ce4bda86..ed9ee7f953e 100644 --- a/src/server/scripts/Maelstrom/Stonecore/stonecore.cpp +++ b/src/server/scripts/Maelstrom/Stonecore/stonecore.cpp @@ -173,7 +173,7 @@ class npc_sc_millhouse_manastorm : public CreatureScript me->RemoveAllAuras(); me->CombatStop(true); - me->GetThreatManager().NotifyDisengaged(); + EngagementOver(); switch (pointId) { 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 84015ecb287..fc5fdbceb4d 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp @@ -580,7 +580,7 @@ struct gunship_npc_AI : public ScriptedAI return; me->CombatStop(true); - me->GetThreatManager().NotifyDisengaged(); + EngagementOver(); me->GetMotionMaster()->MoveTargetedHome(); } @@ -725,7 +725,6 @@ class npc_gunship : public CreatureScript Creature* stalker = *itr; stalker->RemoveAllAuras(); stalker->CombatStop(true); - stalker->GetThreatManager().NotifyDisengaged(); } uint32 explosionSpell = isVictory ? SPELL_EXPLOSION_VICTORY : SPELL_EXPLOSION_WIPE; @@ -878,7 +877,7 @@ class npc_high_overlord_saurfang_igb : public CreatureScript return; me->CombatStop(true); - me->GetThreatManager().NotifyDisengaged(); + EngagementOver(); me->GetMotionMaster()->MoveTargetedHome(); Reset(); @@ -1142,7 +1141,7 @@ class npc_muradin_bronzebeard_igb : public CreatureScript return; me->CombatStop(true); - me->GetThreatManager().NotifyDisengaged(); + EngagementOver(); me->GetMotionMaster()->MoveTargetedHome(); Reset(); 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 f7a1878b6e0..b4f61407615 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp @@ -1778,7 +1778,7 @@ class npc_terenas_menethil : public CreatureScript return; me->CombatStop(false); - me->GetThreatManager().NotifyDisengaged(); + EngagementOver(); } void DamageTaken(Unit* /*attacker*/, uint32& damage) override diff --git a/src/server/scripts/Northrend/Naxxramas/boss_patchwerk.cpp b/src/server/scripts/Northrend/Naxxramas/boss_patchwerk.cpp index bf58171cfb7..e16da9ab00f 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_patchwerk.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_patchwerk.cpp @@ -122,7 +122,7 @@ public: ThreatReference* secondThreat = nullptr; ThreatReference* thirdThreat = nullptr; - ThreatManager const& mgr = me->GetThreatManager(); + ThreatManager& mgr = me->GetThreatManager(); Unit* currentVictim = mgr.GetCurrentVictim(); auto list = mgr.GetModifiableThreatList(); auto it = list.begin(), end = list.end(); diff --git a/src/server/scripts/Northrend/Nexus/Oculus/boss_urom.cpp b/src/server/scripts/Northrend/Nexus/Oculus/boss_urom.cpp index c1e6a515863..4775540bd6b 100644 --- a/src/server/scripts/Northrend/Nexus/Oculus/boss_urom.cpp +++ b/src/server/scripts/Northrend/Nexus/Oculus/boss_urom.cpp @@ -293,7 +293,7 @@ class boss_urom : public CreatureScript { me->RemoveAllAuras(); me->CombatStop(false); - me->GetThreatManager().NotifyDisengaged(); + EngagementOver(); } 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 28c983e3ab6..700ab396c65 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().NotifyDisengaged(); + EngagementOver(); Elder->AI()->DoAction(ACTION_ELDER_FREYA_KILLED); } } diff --git a/src/server/scripts/Northrend/zone_borean_tundra.cpp b/src/server/scripts/Northrend/zone_borean_tundra.cpp index 6d488fd5112..2677be16d0b 100644 --- a/src/server/scripts/Northrend/zone_borean_tundra.cpp +++ b/src/server/scripts/Northrend/zone_borean_tundra.cpp @@ -751,7 +751,6 @@ public: Creature* owner = GetOwner()->ToCreature(); owner->RemoveAllAurasExceptType(SPELL_AURA_DUMMY); owner->CombatStop(true); - 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/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp index aea89d9ed17..a7d7b2cc303 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp @@ -524,7 +524,7 @@ public: { ThreatManager const& mgr = me->GetThreatManager(); std::list<Unit*> TargetList; - Unit* currentVictim = mgr.GetCurrentVictim(); + Unit* currentVictim = mgr.GetLastVictim(); for (ThreatReference const* ref : mgr.GetSortedThreatList()) { if (Player* tempTarget = ref->GetVictim()->ToPlayer()) diff --git a/src/server/scripts/Outland/zone_hellfire_peninsula.cpp b/src/server/scripts/Outland/zone_hellfire_peninsula.cpp index df90cedc591..9e9df90c9d6 100644 --- a/src/server/scripts/Outland/zone_hellfire_peninsula.cpp +++ b/src/server/scripts/Outland/zone_hellfire_peninsula.cpp @@ -100,7 +100,7 @@ public: me->AddNpcFlag(UNIT_NPC_FLAG_QUESTGIVER); me->RemoveAllAuras(); me->CombatStop(true); - me->GetThreatManager().NotifyDisengaged(); + EngagementOver(); Talk(SAY_FREE); return; } @@ -973,7 +973,7 @@ public: me->RestoreFaction(); me->RemoveAllAuras(); me->CombatStop(true); - me->GetThreatManager().NotifyDisengaged(); + EngagementOver(); me->AddNpcFlag(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 db507e8df63..e1cab1ce464 100644 --- a/src/server/scripts/Outland/zone_terokkar_forest.cpp +++ b/src/server/scripts/Outland/zone_terokkar_forest.cpp @@ -91,7 +91,7 @@ public: me->SetStandState(UNIT_STAND_STATE_SIT); me->RemoveAllAuras(); me->CombatStop(true); - me->GetThreatManager().NotifyDisengaged(); + EngagementOver(); UnkorUnfriendly_Timer = 60000; } diff --git a/src/server/scripts/Pet/pet_priest.cpp b/src/server/scripts/Pet/pet_priest.cpp index 83541959304..57a5e4ea979 100644 --- a/src/server/scripts/Pet/pet_priest.cpp +++ b/src/server/scripts/Pet/pet_priest.cpp @@ -50,7 +50,7 @@ class npc_pet_pri_lightwell : public CreatureScript return; me->CombatStop(true); - me->GetThreatManager().NotifyDisengaged(); + EngagementOver(); me->ResetPlayerDamageReq(); } }; |
