Combat/Threat: Split ThreatManager::NotifyDisengaged off from ThreatManager::ClearAllThreat. NotifyDisengaged signifies intent to clear the engagement flag, and should only be called from AI. Fixes #23490.

# Conflicts:
#	src/server/game/AI/CreatureAI.cpp
#	src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp
#	src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp
#	src/server/scripts/Kalimdor/zone_desolace.cpp
#	src/server/scripts/Northrend/zone_borean_tundra.cpp
This commit is contained in:
Treeston authored and Ovahlord committed 2020-07-22 18:38:35 +02:00
1 parent de6a514ec5
commit db3282e65a
22 files changed
+33 -31

No files matched your search

+2 -2
View File
@@ -57,15 +57,15 @@ void GuardAI::EnterEvadeMode(EvadeReason /*why*/)
{
me->GetMotionMaster()->MoveIdle();
me->CombatStop(true);
me->GetThreatManager().ClearAllThreat();
me->GetThreatManager().NotifyDisengaged();
return;
}
TC_LOG_DEBUG("entities.unit", "Guard entry: %u enters evade mode.", me->GetEntry());
me->RemoveAllAuras();
me->GetThreatManager().ClearAllThreat();
me->CombatStop(true);
me->GetThreatManager().NotifyDisengaged();
// Remove ChaseMovementGenerator from MotionMaster stack list, and add HomeMovementGenerator instead
if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE)
+3 -6
View File
@@ -254,9 +254,9 @@ 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();
me->SetLastDamagedTime(0);
@@ -265,10 +265,7 @@ bool CreatureAI::_EnterEvadeMode(EvadeReason /*why*/)
me->GetSpellHistory()->ResetAllCooldowns();
me->SetTarget(ObjectGuid::Empty);
if (me->IsInEvadeMode())
return false;
return true;
return !me->IsInEvadeMode();
}
const uint32 BOUNDARY_VISUALIZE_CREATURE = 15425;
@@ -131,8 +131,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))
+4
View File
@@ -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())
+3
View File
@@ -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)
-1
View File
@@ -9194,7 +9194,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))
@@ -249,7 +249,6 @@ void ObjectGridStoper::Visit(CreatureMapType &m)
if (iter->GetSource()->IsInCombat())
{
iter->GetSource()->CombatStop();
iter->GetSource()->GetThreatManager().ClearAllThreat();
iter->GetSource()->AI()->EnterEvadeMode();
}
}
@@ -375,8 +375,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);
@@ -1253,7 +1253,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);
}
@@ -422,8 +422,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())
@@ -219,8 +219,8 @@ public:
void DoFriend()
{
me->RemoveAllAuras();
me->GetThreatManager().ClearAllThreat();
me->CombatStop(true);
me->GetThreatManager().NotifyDisengaged();
me->StopMoving();
me->GetMotionMaster()->MoveIdle();
@@ -1151,7 +1151,7 @@ class npc_dark_nucleus : public CreatureScript
if (attacker == me)
return;
me->GetThreatManager().ClearAllThreat();
me->GetThreatManager().ResetAllThreat();
AddThreat(attacker, 500000000.0f);
}
@@ -578,8 +578,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();
}
@@ -723,8 +723,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;
@@ -882,8 +882,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();
@@ -1146,8 +1146,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();
@@ -927,7 +927,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
}
@@ -1766,8 +1766,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
@@ -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
@@ -631,7 +631,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);
}
}
@@ -1297,7 +1297,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);
}
}
@@ -720,7 +720,7 @@ public:
Creature* owner = GetOwner()->ToCreature();
owner->RemoveAllAurasExceptType(SPELL_AURA_DUMMY);
owner->CombatStop(true);
owner->GetThreatManager().ClearAllThreat();
owner->GetThreatManager().NotifyDisengaged();
owner->GetMotionMaster()->Clear(false);
owner->GetMotionMaster()->MoveFollow(GetCaster(), 4.0f, 0.0f);
owner->CastSpell(owner, SPELL_SUBDUED, true);
@@ -100,8 +100,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;
}
@@ -980,8 +980,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);
@@ -96,8 +96,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;
}
+1 -1
View File
@@ -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();
}
};