diff options
author | Treeston <treeston.mmoc@gmail.com> | 2017-07-01 20:18:02 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2020-08-13 22:46:44 +0200 |
commit | 8be23fcbbdf26e8169defd761e61765f301bebe0 (patch) | |
tree | 6309b79f7dd617a8ddc801624dbbd4ed7ac22174 /src/server/scripts/Pet | |
parent | 2c99678118798279372f17d4bb5f5a88ac95c413 (diff) |
[3.3.5] Combat/Threat rewrite - prep & refactor (#19966)
* Combat/Threat rewrite (PR #19930) prep work. Mostly refactors, and a compatibility layer on ThreatManager/HostileReference that allows scripts to be changed already.
(cherry picked from commit e2a1ccd118d129b96e09ff1a15ed0adb1d4a3897)
Diffstat (limited to 'src/server/scripts/Pet')
-rw-r--r-- | src/server/scripts/Pet/pet_mage.cpp | 45 | ||||
-rw-r--r-- | src/server/scripts/Pet/pet_priest.cpp | 2 |
2 files changed, 8 insertions, 39 deletions
diff --git a/src/server/scripts/Pet/pet_mage.cpp b/src/server/scripts/Pet/pet_mage.cpp index 5c1b8e735d5..04536ec32f3 100644 --- a/src/server/scripts/Pet/pet_mage.cpp +++ b/src/server/scripts/Pet/pet_mage.cpp @@ -83,21 +83,13 @@ class npc_pet_mage_mirror_image : public CreatureScript continue; } // else compare best fit unit with current unit - ThreatContainer::StorageType triggers = (*iter)->getThreatManager().getThreatList(); - for (ThreatContainer::StorageType::const_iterator trig_citr = triggers.begin(); trig_citr != triggers.end(); ++trig_citr) + float threat = (*iter)->GetThreatManager().GetThreat(owner); + // Check if best fit hostile unit hs lower threat than this current unit + if (highestThreat < threat) { - // Try to find threat referenced to owner - if ((*trig_citr)->getTarget() == owner) - { - // Check if best fit hostile unit hs lower threat than this current unit - if (highestThreat < (*trig_citr)->getThreat()) - { - // If so, update best fit unit - highestThreat = (*trig_citr)->getThreat(); - highestThreatUnit = (*iter); - break; - } - } + // If so, update best fit unit + highestThreat = threat; + highestThreatUnit = (*iter); } // In case no unit with threat was found so far, always check for nearest unit (only for players) if ((*iter)->GetTypeId() == TYPEID_PLAYER) @@ -119,30 +111,7 @@ class npc_pet_mage_mirror_image : public CreatureScript bool IsInThreatList(Unit* target) { Unit* owner = me->GetCharmerOrOwner(); - - std::list<Unit*> targets; - Trinity::AnyUnfriendlyUnitInObjectRangeCheck u_check(me, me, 30.0f); - Trinity::UnitListSearcher<Trinity::AnyUnfriendlyUnitInObjectRangeCheck> searcher(me, targets, u_check); - Cell::VisitAllObjects(me, searcher, 40.0f); - - for (std::list<Unit*>::const_iterator iter = targets.begin(); iter != targets.end(); ++iter) - { - if ((*iter) == target) - { - // Consider only units without CC - if (!(*iter)->HasBreakableByDamageCrowdControlAura((*iter))) - { - ThreatContainer::StorageType triggers = (*iter)->getThreatManager().getThreatList(); - for (ThreatContainer::StorageType::const_iterator trig_citr = triggers.begin(); trig_citr != triggers.end(); ++trig_citr) - { - // Try to find threat referenced to owner - if ((*trig_citr)->getTarget() == owner) - return true; - } - } - } - } - return false; + return owner && target->IsThreatenedBy(owner); } void InitializeAI() override diff --git a/src/server/scripts/Pet/pet_priest.cpp b/src/server/scripts/Pet/pet_priest.cpp index 13885355398..381baa15387 100644 --- a/src/server/scripts/Pet/pet_priest.cpp +++ b/src/server/scripts/Pet/pet_priest.cpp @@ -49,7 +49,7 @@ class npc_pet_pri_lightwell : public CreatureScript if (!me->IsAlive()) return; - me->DeleteThreatList(); + me->GetThreatManager().ClearAllThreat(); me->CombatStop(true); me->ResetPlayerDamageReq(); } |