From 1f472bddd395073bf2a2d146ecb66489b36015fb Mon Sep 17 00:00:00 2001 From: Maelthyr <100411212+Maelthyrr@users.noreply.github.com> Date: Sun, 25 Sep 2022 20:20:34 +0200 Subject: [PATCH] refactor(Core/Combat): Code style and improvement of ThreatMgr (#12992) --- src/server/game/AI/CoreAI/UnitAI.cpp | 4 +- src/server/game/AI/CoreAI/UnitAI.h | 4 +- .../game/AI/ScriptedAI/ScriptedCreature.cpp | 6 +- .../game/AI/SmartScripts/SmartScript.cpp | 8 +- src/server/game/Combat/HostileRefMgr.cpp | 4 +- src/server/game/Combat/ThreatMgr.cpp | 63 ++++++++-------- src/server/game/Combat/ThreatMgr.h | 75 +++++++++++-------- .../game/Entities/Creature/Creature.cpp | 12 +-- src/server/game/Entities/Unit/Unit.cpp | 22 +++--- src/server/game/Spells/SpellEffects.cpp | 12 +-- src/server/scripts/Commands/cs_debug.cpp | 18 ++--- .../BlackrockSpire/boss_drakkisath.cpp | 6 +- .../BlackrockSpire/boss_mor_grayhoof.cpp | 6 +- .../BlackwingLair/boss_nefarian.cpp | 2 +- .../MoltenCore/boss_ragnaros.cpp | 2 +- .../MoltenCore/boss_shazzrah.cpp | 2 +- .../Karazhan/boss_netherspite.cpp | 2 +- .../Karazhan/boss_prince_malchezaar.cpp | 2 +- .../Karazhan/boss_shade_of_aran.cpp | 2 +- .../boss_priestess_delrissa.cpp | 12 +-- .../Scholomance/instance_scholomance.cpp | 2 +- .../ZulGurub/boss_gahzranka.cpp | 4 +- .../EasternKingdoms/ZulGurub/boss_grilek.cpp | 4 +- .../EasternKingdoms/ZulGurub/boss_hakkar.cpp | 6 +- .../ZulGurub/boss_hazzarah.cpp | 2 +- .../EasternKingdoms/ZulGurub/boss_jindo.cpp | 6 +- .../ZulGurub/boss_mandokir.cpp | 6 +- .../EasternKingdoms/ZulGurub/boss_marli.cpp | 2 +- .../ZulGurub/boss_renataki.cpp | 4 +- .../BattleForMountHyjal/boss_archimonde.cpp | 4 +- .../TempleOfAhnQiraj/boss_bug_trio.cpp | 2 +- .../Kalimdor/TempleOfAhnQiraj/boss_ouro.cpp | 2 +- .../TempleOfAhnQiraj/boss_sartura.cpp | 12 +-- src/server/scripts/Kalimdor/boss_azuregos.cpp | 2 +- .../ahnkahet/boss_prince_taldaram.cpp | 2 +- .../boss_faction_champions.cpp | 16 ++-- .../boss_lady_deathwhisper.cpp | 2 +- .../boss_valithria_dreamwalker.cpp | 2 +- .../IcecrownCitadel/icecrown_citadel.cpp | 8 +- .../Northrend/Naxxramas/boss_gothik.cpp | 2 +- .../Northrend/Naxxramas/boss_kelthuzad.cpp | 2 +- .../Northrend/Naxxramas/boss_patchwerk.cpp | 4 +- .../Northrend/Naxxramas/boss_sapphiron.cpp | 4 +- .../Northrend/Naxxramas/boss_thaddius.cpp | 8 +- .../Northrend/Ulduar/Ulduar/boss_kologarn.cpp | 2 +- .../boss_blackheart_the_inciter.cpp | 2 +- .../ShadowLabyrinth/boss_murmur.cpp | 2 +- .../Outland/BlackTemple/boss_bloodboil.cpp | 2 +- .../Outland/BlackTemple/boss_supremus.cpp | 2 +- .../SerpentShrine/boss_lurker_below.cpp | 2 +- .../boss_morogrim_tidewalker.cpp | 2 +- .../Outland/TempestKeep/Eye/boss_alar.cpp | 2 +- .../Outland/TempestKeep/Eye/boss_kaelthas.cpp | 2 +- .../scripts/Outland/zone_netherstorm.cpp | 2 +- .../Outland/zone_shadowmoon_valley.cpp | 2 +- src/server/scripts/Pet/pet_mage.cpp | 2 +- src/server/scripts/Spells/spell_generic.cpp | 4 +- src/server/scripts/Spells/spell_warlock.cpp | 2 +- .../scripts/World/boss_emerald_dragons.cpp | 2 +- .../scripts/World/npc_stave_of_ancients.cpp | 2 +- .../scripts/World/npc_stave_of_ancients.h | 2 +- 61 files changed, 212 insertions(+), 196 deletions(-) diff --git a/src/server/game/AI/CoreAI/UnitAI.cpp b/src/server/game/AI/CoreAI/UnitAI.cpp index 1304a6cfe..c6ffa1462 100644 --- a/src/server/game/AI/CoreAI/UnitAI.cpp +++ b/src/server/game/AI/CoreAI/UnitAI.cpp @@ -136,7 +136,7 @@ SpellCastResult UnitAI::DoAddAuraToAllHostilePlayers(uint32 spellid) { if (me->IsInCombat()) { - ThreatContainer::StorageType threatlist = me->GetThreatMgr().getThreatList(); + ThreatContainer::StorageType threatlist = me->GetThreatMgr().GetThreatList(); for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) { if (Unit* unit = ObjectAccessor::GetUnit(*me, (*itr)->getUnitGuid())) @@ -159,7 +159,7 @@ SpellCastResult UnitAI::DoCastToAllHostilePlayers(uint32 spellid, bool triggered { if (me->IsInCombat()) { - ThreatContainer::StorageType threatlist = me->GetThreatMgr().getThreatList(); + ThreatContainer::StorageType threatlist = me->GetThreatMgr().GetThreatList(); for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) { if (Unit* unit = ObjectAccessor::GetUnit(*me, (*itr)->getUnitGuid())) diff --git a/src/server/game/AI/CoreAI/UnitAI.h b/src/server/game/AI/CoreAI/UnitAI.h index a423997b9..1070a2ba5 100644 --- a/src/server/game/AI/CoreAI/UnitAI.h +++ b/src/server/game/AI/CoreAI/UnitAI.h @@ -216,7 +216,7 @@ public: template Unit* SelectTarget(SelectTargetMethod targetType, uint32 position, PREDICATE const& predicate) { - ThreatContainer::StorageType const& threatlist = me->GetThreatMgr().getThreatList(); + ThreatContainer::StorageType const& threatlist = me->GetThreatMgr().GetThreatList(); if (position >= threatlist.size()) return nullptr; @@ -278,7 +278,7 @@ public: template void SelectTargetList(std::list& targetList, PREDICATE const& predicate, uint32 maxTargets, SelectTargetMethod targetType) { - ThreatContainer::StorageType const& threatlist = me->GetThreatMgr().getThreatList(); + ThreatContainer::StorageType const& threatlist = me->GetThreatMgr().GetThreatList(); if (threatlist.empty()) return; diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp index e1c6eedca..c131a8fd6 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp @@ -399,14 +399,14 @@ float ScriptedAI::DoGetThreat(Unit* unit) { if (!unit) return 0.0f; - return me->GetThreatMgr().getThreat(unit); + return me->GetThreatMgr().GetThreat(unit); } void ScriptedAI::DoModifyThreatPercent(Unit* unit, int32 pct) { if (!unit) return; - me->GetThreatMgr().modifyThreatPercent(unit, pct); + me->GetThreatMgr().ModifyThreatByPercent(unit, pct); } void ScriptedAI::DoTeleportPlayer(Unit* unit, float x, float y, float z, float o) @@ -580,7 +580,7 @@ void BossAI::TeleportCheaters() float x, y, z; me->GetPosition(x, y, z); - ThreatContainer::StorageType threatList = me->GetThreatMgr().getThreatList(); + ThreatContainer::StorageType threatList = me->GetThreatMgr().GetThreatList(); for (ThreatContainer::StorageType::const_iterator itr = threatList.begin(); itr != threatList.end(); ++itr) if (Unit* target = (*itr)->getTarget()) if (target->GetTypeId() == TYPEID_PLAYER && !IsInBoundary(target)) diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 4fe9984c7..b93254fed 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -522,12 +522,12 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u if (!me) break; - ThreatContainer::StorageType threatList = me->GetThreatMgr().getThreatList(); + ThreatContainer::StorageType threatList = me->GetThreatMgr().GetThreatList(); for (ThreatContainer::StorageType::const_iterator i = threatList.begin(); i != threatList.end(); ++i) { if (Unit* target = ObjectAccessor::GetUnit(*me, (*i)->getUnitGuid())) { - me->GetThreatMgr().modifyThreatPercent(target, e.action.threatPCT.threatINC ? (int32)e.action.threatPCT.threatINC : -(int32)e.action.threatPCT.threatDEC); + me->GetThreatMgr().ModifyThreatByPercent(target, e.action.threatPCT.threatINC ? (int32)e.action.threatPCT.threatINC : -(int32)e.action.threatPCT.threatDEC); LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_THREAT_ALL_PCT: Creature {} modify threat for unit {}, value {}", me->GetGUID().ToString(), target->GetGUID().ToString(), e.action.threatPCT.threatINC ? (int32)e.action.threatPCT.threatINC : -(int32)e.action.threatPCT.threatDEC); } @@ -543,7 +543,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { if (IsUnit(target)) { - me->GetThreatMgr().modifyThreatPercent(target->ToUnit(), e.action.threatPCT.threatINC ? (int32)e.action.threatPCT.threatINC : -(int32)e.action.threatPCT.threatDEC); + me->GetThreatMgr().ModifyThreatByPercent(target->ToUnit(), e.action.threatPCT.threatINC ? (int32)e.action.threatPCT.threatINC : -(int32)e.action.threatPCT.threatDEC); LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_THREAT_SINGLE_PCT: Creature guidLow {} modify threat for unit {}, value %i", me->GetGUID().ToString(), target->GetGUID().ToString(), e.action.threatPCT.threatINC ? (int32)e.action.threatPCT.threatINC : -(int32)e.action.threatPCT.threatDEC); } @@ -3219,7 +3219,7 @@ void SmartScript::GetTargets(ObjectVector& targets, SmartScriptHolder const& e, { if (me) { - ThreatContainer::StorageType threatList = me->GetThreatMgr().getThreatList(); + ThreatContainer::StorageType threatList = me->GetThreatMgr().GetThreatList(); for (ThreatContainer::StorageType::const_iterator i = threatList.begin(); i != threatList.end(); ++i) if (Unit* temp = ObjectAccessor::GetUnit(*me, (*i)->getUnitGuid())) // Xinef: added distance check diff --git a/src/server/game/Combat/HostileRefMgr.cpp b/src/server/game/Combat/HostileRefMgr.cpp index f44638080..16fc944a5 100644 --- a/src/server/game/Combat/HostileRefMgr.cpp +++ b/src/server/game/Combat/HostileRefMgr.cpp @@ -53,7 +53,7 @@ void HostileRefMgr::threatAssist(Unit* victim, float baseThreat, SpellInfo const } } - ref->GetSource()->doAddThreat(victim, threat); + ref->GetSource()->DoAddThreat(victim, threat); } ref = ref->next(); @@ -239,7 +239,7 @@ void HostileRefMgr::UpdateVisibility(bool checkThreat) while (ref) { HostileReference* nextRef = ref->next(); - if ((!checkThreat || ref->GetSource()->getThreatList().size() <= 1)) + if ((!checkThreat || ref->GetSource()->GetThreatListSize() <= 1)) { nextRef = ref->next(); ref->removeReference(); diff --git a/src/server/game/Combat/ThreatMgr.cpp b/src/server/game/Combat/ThreatMgr.cpp index 7cbbcd94d..91751f22a 100644 --- a/src/server/game/Combat/ThreatMgr.cpp +++ b/src/server/game/Combat/ThreatMgr.cpp @@ -131,14 +131,17 @@ void HostileReference::fireStatusChanged(ThreatRefStatusChangeEvent& threatRefSt GetSource()->processThreatEvent(&threatRefStatusChangeEvent); } +// -- compatibility layer for combat rewrite +Unit* HostileReference::GetOwner() const { return GetSource()->GetOwner(); } + //============================================================ -void HostileReference::addThreat(float modThreat) +void HostileReference::AddThreat(float modThreat) { iThreat += modThreat; // the threat is changed. Source and target unit have to be available // if the link was cut before relink it again - if (!isOnline()) + if (!IsOnline()) updateOnlineStatus(); if (modThreat != 0.0f) { @@ -154,7 +157,7 @@ void HostileReference::addThreat(float modThreat) Unit* victimOwner = target->GetCharmerOrOwner(); if (victimOwner && victimOwner->IsAlive()) { - GetSource()->addThreat(victimOwner, 0.0f); // create a threat to the owner of a pet, if the pet attacks + GetSource()->AddThreat(victimOwner, 0.0f); // create a threat to the owner of a pet, if the pet attacks } } } @@ -169,7 +172,7 @@ void HostileReference::addThreatPercent(int32 percent) float tmpThreat = iThreat; AddPct(tmpThreat, percent); - addThreat(tmpThreat - iThreat); + AddThreat(tmpThreat - iThreat); } //============================================================ @@ -256,7 +259,7 @@ void ThreatContainer::clearReferences() //============================================================ // Return the HostileReference of nullptr, if not found -HostileReference* ThreatContainer::getReferenceByTarget(Unit* victim) const +HostileReference* ThreatContainer::getReferenceByTarget(Unit const* victim) const { if (!victim) return nullptr; @@ -281,17 +284,17 @@ HostileReference* ThreatContainer::getReferenceByTarget(ObjectGuid const& guid) //============================================================ // Add the threat, if we find the reference -HostileReference* ThreatContainer::addThreat(Unit* victim, float threat) +HostileReference* ThreatContainer::AddThreat(Unit* victim, float threat) { HostileReference* ref = getReferenceByTarget(victim); if (ref) - ref->addThreat(threat); + ref->AddThreat(threat); return ref; } //============================================================ -void ThreatContainer::modifyThreatPercent(Unit* victim, int32 percent) +void ThreatContainer::ModifyThreatByPercent(Unit* victim, int32 percent) { if (HostileReference* ref = getReferenceByTarget(victim)) ref->addThreatPercent(percent); @@ -312,7 +315,7 @@ void ThreatContainer::update() // return the next best victim // could be the current victim -HostileReference* ThreatContainer::selectNextVictim(Creature* attacker, HostileReference* currentVictim) const +HostileReference* ThreatContainer::SelectNextVictim(Creature* attacker, HostileReference* currentVictim) const { // pussywizard: pretty much remade this whole function @@ -370,12 +373,12 @@ HostileReference* ThreatContainer::selectNextVictim(Creature* attacker, HostileR } // pussywizard: implement 110% threat rule for targets in melee range and 130% rule for targets in ranged distances - if (currentRef->getThreat() > 1.3f * currentVictim->getThreat()) // pussywizard: enough in all cases, end + if (currentRef->GetThreat() > 1.3f * currentVictim->GetThreat()) // pussywizard: enough in all cases, end { found = true; break; } - else if (currentRef->getThreat() > 1.1f * currentVictim->getThreat()) // pussywizard: enought only if target in melee range + else if (currentRef->GetThreat() > 1.1f * currentVictim->GetThreat()) // pussywizard: enought only if target in melee range { if (attacker->IsWithinMeleeRange(target)) { @@ -431,7 +434,7 @@ void ThreatMgr::clearReferences() //============================================================ -void ThreatMgr::addThreat(Unit* victim, float threat, SpellSchoolMask schoolMask, SpellInfo const* threatSpell) +void ThreatMgr::AddThreat(Unit* victim, float threat, SpellSchoolMask schoolMask, SpellInfo const* threatSpell) { if (!ThreatCalcHelper::isValidProcess(victim, iOwner, threatSpell)) return; @@ -445,10 +448,10 @@ void ThreatMgr::addThreat(Unit* victim, float threat, SpellSchoolMask schoolMask } } - doAddThreat(victim, threat); + DoAddThreat(victim, threat); } -void ThreatMgr::doAddThreat(Unit* victim, float threat) +void ThreatMgr::DoAddThreat(Unit* victim, float threat) { uint32 redirectThreadPct = victim->GetRedirectThreatPercent(); @@ -469,17 +472,17 @@ void ThreatMgr::doAddThreat(Unit* victim, float threat) void ThreatMgr::_addThreat(Unit* victim, float threat) { - HostileReference* ref = iThreatContainer.addThreat(victim, threat); + HostileReference* ref = iThreatContainer.AddThreat(victim, threat); // Ref is not in the online refs, search the offline refs next if (!ref) - ref = iThreatOfflineContainer.addThreat(victim, threat); + ref = iThreatOfflineContainer.AddThreat(victim, threat); if (!ref) // there was no ref => create a new one { // threat has to be 0 here HostileReference* hostileRef = new HostileReference(victim, this, 0); iThreatContainer.addReference(hostileRef); - hostileRef->addThreat(threat); // now we add the real threat + hostileRef->AddThreat(threat); // now we add the real threat if (victim->GetTypeId() == TYPEID_PLAYER && victim->ToPlayer()->IsGameMaster()) hostileRef->setOnlineOfflineState(false); // GM is always offline } @@ -487,9 +490,9 @@ void ThreatMgr::_addThreat(Unit* victim, float threat) //============================================================ -void ThreatMgr::modifyThreatPercent(Unit* victim, int32 percent) +void ThreatMgr::ModifyThreatByPercent(Unit* victim, int32 percent) { - iThreatContainer.modifyThreatPercent(victim, percent); + iThreatContainer.ModifyThreatByPercent(victim, percent); } //============================================================ @@ -497,21 +500,21 @@ void ThreatMgr::modifyThreatPercent(Unit* victim, int32 percent) Unit* ThreatMgr::getHostileTarget() { iThreatContainer.update(); - HostileReference* nextVictim = iThreatContainer.selectNextVictim(GetOwner()->ToCreature(), getCurrentVictim()); + HostileReference* nextVictim = iThreatContainer.SelectNextVictim(GetOwner()->ToCreature(), getCurrentVictim()); setCurrentVictim(nextVictim); return getCurrentVictim() != nullptr ? getCurrentVictim()->getTarget() : nullptr; } //============================================================ -float ThreatMgr::getThreat(Unit* victim, bool alsoSearchOfflineList) +float ThreatMgr::GetThreat(Unit* victim, bool alsoSearchOfflineList) { float threat = 0.0f; HostileReference* ref = iThreatContainer.getReferenceByTarget(victim); if (!ref && alsoSearchOfflineList) ref = iThreatOfflineContainer.getReferenceByTarget(victim); if (ref) - threat = ref->getThreat(); + threat = ref->GetThreat(); return threat; } @@ -524,7 +527,7 @@ float ThreatMgr::getThreatWithoutTemp(Unit* victim, bool alsoSearchOfflineList) if (!ref && alsoSearchOfflineList) ref = iThreatOfflineContainer.getReferenceByTarget(victim); if (ref) - threat = ref->getThreat() - ref->getTempThreatModifier(); + threat = ref->GetThreat() - ref->getTempThreatModifier(); return threat; } @@ -533,10 +536,10 @@ float ThreatMgr::getThreatWithoutTemp(Unit* victim, bool alsoSearchOfflineList) void ThreatMgr::tauntApply(Unit* taunter) { HostileReference* ref = iThreatContainer.getReferenceByTarget(taunter); - if (getCurrentVictim() && ref && (ref->getThreat() < getCurrentVictim()->getThreat())) + if (getCurrentVictim() && ref && (ref->GetThreat() < getCurrentVictim()->GetThreat())) { if (ref->getTempThreatModifier() == 0.0f) // Ok, temp threat is unused - ref->setTempThreat(getCurrentVictim()->getThreat()); + ref->setTempThreat(getCurrentVictim()->GetThreat()); } } @@ -578,7 +581,7 @@ void ThreatMgr::processThreatEvent(ThreatRefStatusChangeEvent* threatRefStatusCh setDirty(true); // the order in the threat list might have changed break; case UEV_THREAT_REF_ONLINE_STATUS: - if (!hostileRef->isOnline()) + if (!hostileRef->IsOnline()) { if (hostileRef == getCurrentVictim()) { @@ -594,7 +597,7 @@ void ThreatMgr::processThreatEvent(ThreatRefStatusChangeEvent* threatRefStatusCh } else { - if (getCurrentVictim() && hostileRef->getThreat() > (1.1f * getCurrentVictim()->getThreat())) + if (getCurrentVictim() && hostileRef->GetThreat() > (1.1f * getCurrentVictim()->GetThreat())) setDirty(true); iThreatContainer.addReference(hostileRef); iThreatOfflineContainer.remove(hostileRef); @@ -607,7 +610,7 @@ void ThreatMgr::processThreatEvent(ThreatRefStatusChangeEvent* threatRefStatusCh setDirty(true); } iOwner->SendRemoveFromThreatListOpcode(hostileRef); - if (hostileRef->isOnline()) + if (hostileRef->IsOnline()) iThreatContainer.remove(hostileRef); else iThreatOfflineContainer.remove(hostileRef); @@ -630,14 +633,14 @@ bool ThreatMgr::isNeedUpdateToClient(uint32 time) } // Reset all aggro without modifying the threatlist. -void ThreatMgr::resetAllAggro() +void ThreatMgr::ResetAllThreat() { ThreatContainer::StorageType& threatList = iThreatContainer.iThreatList; if (threatList.empty()) return; for (ThreatContainer::StorageType::iterator itr = threatList.begin(); itr != threatList.end(); ++itr) - (*itr)->setThreat(0); + (*itr)->SetThreat(0); setDirty(true); } diff --git a/src/server/game/Combat/ThreatMgr.h b/src/server/game/Combat/ThreatMgr.h index 6844b08d1..7196e5638 100644 --- a/src/server/game/Combat/ThreatMgr.h +++ b/src/server/game/Combat/ThreatMgr.h @@ -19,6 +19,7 @@ #define _THREATMANAGER #include "Common.h" +#include "IteratorPair.h" #include "ObjectGuid.h" #include "Reference.h" #include "SharedDefines.h" @@ -49,36 +50,43 @@ class HostileReference : public Reference public: HostileReference(Unit* refUnit, ThreatMgr* threatMgr, float threat); - //================================================= - void addThreat(float modThreat); + Unit* GetOwner() const; + Unit* GetVictim() const { return getTarget(); } - void setThreat(float threat) { addThreat(threat - getThreat()); } + //================================================= + void AddThreat(float modThreat); + + void SetThreat(float threat) { AddThreat(threat - GetThreat()); } void addThreatPercent(int32 percent); - [[nodiscard]] float getThreat() const { return iThreat; } + [[nodiscard]] float GetThreat() const { return iThreat; } - [[nodiscard]] bool isOnline() const { return iOnline; } + void ClearThreat() { removeReference(); } + + [[nodiscard]] bool IsOnline() const { return iOnline; } + [[nodiscard]] bool IsAvailable() const { return iOnline; } // unused for now + [[nodiscard]] bool IsOffline() const { return !iOnline; } // unused for now // used for temporary setting a threat and reducting it later again. // the threat modification is stored void setTempThreat(float threat) { - addTempThreat(threat - getThreat()); + addTempThreat(threat - GetThreat()); } void addTempThreat(float threat) { iTempThreatModifier = threat; if (iTempThreatModifier != 0.0f) - addThreat(iTempThreatModifier); + AddThreat(iTempThreatModifier); } void resetTempThreat() { if (iTempThreatModifier != 0.0f) { - addThreat(-iTempThreatModifier); + AddThreat(-iTempThreatModifier); iTempThreatModifier = 0.0f; } } @@ -143,11 +151,11 @@ public: ~ThreatContainer() { clearReferences(); } - HostileReference* addThreat(Unit* victim, float threat); + HostileReference* AddThreat(Unit* victim, float threat); - void modifyThreatPercent(Unit* victim, int32 percent); + void ModifyThreatByPercent(Unit* victim, int32 percent); - HostileReference* selectNextVictim(Creature* attacker, HostileReference* currentVictim) const; + HostileReference* SelectNextVictim(Creature* attacker, HostileReference* currentVictim) const; void setDirty(bool isDirty) { iDirty = isDirty; } @@ -163,10 +171,10 @@ public: return iThreatList.empty() ? nullptr : iThreatList.front(); } - HostileReference* getReferenceByTarget(Unit* victim) const; + HostileReference* getReferenceByTarget(Unit const* victim) const; HostileReference* getReferenceByTarget(ObjectGuid const& guid) const; - [[nodiscard]] StorageType const& getThreatList() const { return iThreatList; } + [[nodiscard]] StorageType const& GetThreatList() const { return iThreatList; } private: void remove(HostileReference* hostileRef) @@ -190,6 +198,8 @@ private: //================================================= +typedef HostileReference ThreatReference; + class ThreatMgr { public: @@ -199,16 +209,17 @@ public: ~ThreatMgr() { clearReferences(); } + Unit* SelectVictim() { return getHostileTarget(); } + Unit* GetCurrentVictim() const { if (ThreatReference* ref = getCurrentVictim()) return ref->GetVictim(); else return nullptr; } + Unit* GetAnyTarget() const { auto const& list = GetThreatList(); if (!list.empty()) return list.front()->getTarget(); return nullptr; } + void clearReferences(); - void addThreat(Unit* victim, float threat, SpellSchoolMask schoolMask = SPELL_SCHOOL_MASK_NORMAL, SpellInfo const* threatSpell = nullptr); - - void doAddThreat(Unit* victim, float threat); - - void modifyThreatPercent(Unit* victim, int32 percent); - - float getThreat(Unit* victim, bool alsoSearchOfflineList = false); - + void AddThreat(Unit* victim, float threat, SpellSchoolMask schoolMask = SPELL_SCHOOL_MASK_NORMAL, SpellInfo const* threatSpell = nullptr); + void DoAddThreat(Unit* victim, float threat); + void ModifyThreatByPercent(Unit* victim, int32 percent); + float GetThreat(Unit* victim, bool alsoSearchOfflineList = false); + float GetThreatListSize() const { return GetThreatList().size(); } float getThreatWithoutTemp(Unit* victim, bool alsoSearchOfflineList = false); [[nodiscard]] bool isThreatListEmpty() const { return iThreatContainer.empty(); } @@ -232,11 +243,10 @@ public: void setDirty(bool isDirty) { iThreatContainer.setDirty(isDirty); } // Reset all aggro without modifying the threadlist. - void resetAllAggro(); - - // -- compatibility layer for combat rewrite - void ResetAllThreat() { resetAllAggro(); } + void ResetThreat(Unit const* who) { if (auto* ref = FindReference(who, true)) ref->SetThreat(0.0f); } + void ResetAllThreat(); + void ClearThreat(Unit const* who) { if (auto* ref = FindReference(who, true)) ref->removeReference(); } void ClearAllThreat(); // Reset all aggro of unit in threadlist satisfying the predicate. @@ -250,7 +260,7 @@ public: { if (predicate(ref->getTarget())) { - ref->setThreat(0); + ref->SetThreat(0); setDirty(true); } } @@ -258,11 +268,14 @@ public: // methods to access the lists from the outside to do some dirty manipulation (scriping and such) // I hope they are used as little as possible. - [[nodiscard]] ThreatContainer::StorageType const& getThreatList() const { return iThreatContainer.getThreatList(); } - [[nodiscard]] ThreatContainer::StorageType const& getOfflineThreatList() const { return iThreatOfflineContainer.getThreatList(); } - ThreatContainer& getOnlineContainer() { return iThreatContainer; } - ThreatContainer& getOfflineContainer() { return iThreatOfflineContainer; } + [[nodiscard]] ThreatContainer::StorageType const& GetThreatList() const { return iThreatContainer.GetThreatList(); } + [[nodiscard]] ThreatContainer::StorageType const& GetOfflineThreatList() const { return iThreatOfflineContainer.GetThreatList(); } + ThreatContainer& GetOnlineContainer() { return iThreatContainer; } + ThreatContainer& GetOfflineContainer() { return iThreatOfflineContainer; } + private: + HostileReference* FindReference(Unit const* who, bool includeOffline) const { if (auto* ref = iThreatContainer.getReferenceByTarget(who)) return ref; if (includeOffline) if (auto* ref = iThreatOfflineContainer.getReferenceByTarget(who)) return ref; return nullptr; } + void _addThreat(Unit* victim, float threat); HostileReference* iCurrentVictim; @@ -283,7 +296,7 @@ namespace Acore ThreatOrderPred(bool ascending = false) : m_ascending(ascending) {} bool operator() (HostileReference const* a, HostileReference const* b) const { - return m_ascending ? a->getThreat() < b->getThreat() : a->getThreat() > b->getThreat(); + return m_ascending ? a->GetThreat() < b->GetThreat() : a->GetThreat() > b->GetThreat(); } private: const bool m_ascending; diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 99fa625f8..512e7c39e 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -207,8 +207,8 @@ bool TemporaryThreatModifierEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) { if (m_owner.IsInCombatWith(victim)) { - m_owner.GetThreatMgr().modifyThreatPercent(victim, -100); // Reset threat to zero. - m_owner.GetThreatMgr().addThreat(victim, m_threatValue); // Set to the previous value it had, first before modification. + m_owner.GetThreatMgr().ModifyThreatByPercent(victim, -100); // Reset threat to zero. + m_owner.GetThreatMgr().AddThreat(victim, m_threatValue); // Set to the previous value it had, first before modification. } } @@ -839,13 +839,13 @@ void Creature::Update(uint32 diff) } }; - if (GetThreatMgr().getThreatList().size() <= 1) + if (GetThreatMgr().GetThreatListSize() <= 1) { EnterEvade(); } else { - if (HostileReference* ref = GetThreatMgr().getOnlineContainer().getReferenceByTarget(m_cannotReachTarget)) + if (HostileReference* ref = GetThreatMgr().GetOnlineContainer().getReferenceByTarget(m_cannotReachTarget)) { ref->removeReference(); SetCannotReachTarget(); @@ -3626,11 +3626,11 @@ void Creature::ModifyThreatPercentTemp(Unit* victim, int32 percent, Milliseconds { if (victim) { - float currentThreat = GetThreatMgr().getThreat(victim); + float currentThreat = GetThreatMgr().GetThreat(victim); if (percent != 0.0f) { - GetThreatMgr().modifyThreatPercent(victim, percent); + GetThreatMgr().ModifyThreatByPercent(victim, percent); } TemporaryThreatModifierEvent* pEvent = new TemporaryThreatModifierEvent(*this, victim->GetGUID(), currentThreat); diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index c2b03b3e4..d190cbdcd 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -8977,7 +8977,7 @@ bool Unit::HandleProcTriggerSpell(Unit* victim, uint32 damage, AuraEffect* trigg return false; if (victim && victim->IsAlive()) - victim->GetThreatMgr().modifyThreatPercent(this, -10); + victim->GetThreatMgr().ModifyThreatByPercent(this, -10); basepoints0 = int32(CountPctFromMaxHealth(triggerAmount)); trigger_spell_id = 31616; @@ -14104,7 +14104,7 @@ void Unit::AddThreat(Unit* victim, float fThreat, SpellSchoolMask schoolMask, Sp // Only mobs can manage threat lists if (CanHaveThreatList() && !HasUnitState(UNIT_STATE_EVADE)) { - m_ThreatMgr.addThreat(victim, fThreat, schoolMask, threatSpell); + m_ThreatMgr.AddThreat(victim, fThreat, schoolMask, threatSpell); } } @@ -18679,8 +18679,8 @@ void Unit::SetPhaseMask(uint32 newPhaseMask, bool update) // modify threat lists for new phasemask if (GetTypeId() != TYPEID_PLAYER) { - ThreatContainer::StorageType threatList = GetThreatMgr().getThreatList(); - ThreatContainer::StorageType offlineThreatList = GetThreatMgr().getOfflineThreatList(); + ThreatContainer::StorageType threatList = GetThreatMgr().GetThreatList(); + ThreatContainer::StorageType offlineThreatList = GetThreatMgr().GetOfflineThreatList(); // merge expects sorted lists threatList.sort(); @@ -19654,17 +19654,17 @@ void Unit::SendThreatListUpdate() { if (!GetThreatMgr().isThreatListEmpty()) { - uint32 count = GetThreatMgr().getThreatList().size(); + uint32 count = GetThreatMgr().GetThreatList().size(); //LOG_DEBUG("entities.unit", "WORLD: Send SMSG_THREAT_UPDATE Message"); WorldPacket data(SMSG_THREAT_UPDATE, 8 + count * 8); data << GetPackGUID(); data << uint32(count); - ThreatContainer::StorageType const& tlist = GetThreatMgr().getThreatList(); + ThreatContainer::StorageType const& tlist = GetThreatMgr().GetThreatList(); for (ThreatContainer::StorageType::const_iterator itr = tlist.begin(); itr != tlist.end(); ++itr) { data << (*itr)->getUnitGuid().WriteAsPacked(); - data << uint32((*itr)->getThreat() * 100); + data << uint32((*itr)->GetThreat() * 100); } SendMessageToSet(&data, false); } @@ -19674,18 +19674,18 @@ void Unit::SendChangeCurrentVictimOpcode(HostileReference* pHostileReference) { if (!GetThreatMgr().isThreatListEmpty()) { - uint32 count = GetThreatMgr().getThreatList().size(); + uint32 count = GetThreatMgr().GetThreatList().size(); LOG_DEBUG("entities.unit", "WORLD: Send SMSG_HIGHEST_THREAT_UPDATE Message"); WorldPacket data(SMSG_HIGHEST_THREAT_UPDATE, 8 + 8 + count * 8); data << GetPackGUID(); data << pHostileReference->getUnitGuid().WriteAsPacked(); data << uint32(count); - ThreatContainer::StorageType const& tlist = GetThreatMgr().getThreatList(); + ThreatContainer::StorageType const& tlist = GetThreatMgr().GetThreatList(); for (ThreatContainer::StorageType::const_iterator itr = tlist.begin(); itr != tlist.end(); ++itr) { data << (*itr)->getUnitGuid().WriteAsPacked(); - data << uint32((*itr)->getThreat() * 100); + data << uint32((*itr)->GetThreat() * 100); } SendMessageToSet(&data, false); } @@ -20615,7 +20615,7 @@ bool Unit::IsInCombatWith(Unit const* who) const return false; // Search in threat list ObjectGuid guid = who->GetGUID(); - for (ThreatContainer::StorageType::const_iterator i = m_ThreatMgr.getThreatList().begin(); i != m_ThreatMgr.getThreatList().end(); ++i) + for (ThreatContainer::StorageType::const_iterator i = m_ThreatMgr.GetThreatList().begin(); i != m_ThreatMgr.GetThreatList().end(); ++i) { HostileReference* ref = (*i); // Return true if the unit matches diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index cd5809cd0..6fa9b83a6 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -3299,16 +3299,16 @@ void Spell::EffectTaunt(SpellEffIndex /*effIndex*/) return; } - if (!unitTarget->GetThreatMgr().getOnlineContainer().empty()) + if (!unitTarget->GetThreatMgr().GetOnlineContainer().empty()) { // Also use this effect to set the taunter's threat to the taunted creature's highest value - float myThreat = unitTarget->GetThreatMgr().getThreat(m_caster); - float topThreat = unitTarget->GetThreatMgr().getOnlineContainer().getMostHated()->getThreat(); + float myThreat = unitTarget->GetThreatMgr().GetThreat(m_caster); + float topThreat = unitTarget->GetThreatMgr().GetOnlineContainer().getMostHated()->GetThreat(); if (topThreat > myThreat) - unitTarget->GetThreatMgr().doAddThreat(m_caster, topThreat - myThreat); + unitTarget->GetThreatMgr().DoAddThreat(m_caster, topThreat - myThreat); //Set aggro victim to caster - if (HostileReference* forcedVictim = unitTarget->GetThreatMgr().getOnlineContainer().getReferenceByTarget(m_caster)) + if (HostileReference* forcedVictim = unitTarget->GetThreatMgr().GetOnlineContainer().getReferenceByTarget(m_caster)) unitTarget->GetThreatMgr().setCurrentVictim(forcedVictim); } @@ -5386,7 +5386,7 @@ void Spell::EffectModifyThreatPercent(SpellEffIndex /*effIndex*/) if (!unitTarget) return; - unitTarget->GetThreatMgr().modifyThreatPercent(m_caster, damage); + unitTarget->GetThreatMgr().ModifyThreatByPercent(m_caster, damage); } void Spell::EffectTransmitted(SpellEffIndex effIndex) diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp index e0c12e927..f713503de 100644 --- a/src/server/scripts/Commands/cs_debug.cpp +++ b/src/server/scripts/Commands/cs_debug.cpp @@ -806,7 +806,7 @@ public: if (!target || target->IsTotem() || target->IsPet()) return false; - auto const& threatList = target->GetThreatMgr().getThreatList(); + auto const& threatList = target->GetThreatMgr().GetThreatList(); ThreatContainer::StorageType::const_iterator itr; uint32 count = 0; @@ -817,24 +817,24 @@ public: Unit* unit = (*itr)->getTarget(); if (!unit) { - handler->PSendSysMessage(" %u. No Unit - threat %f", ++count, (*itr)->getThreat()); + handler->PSendSysMessage(" %u. No Unit - threat %f", ++count, (*itr)->GetThreat()); continue; } - handler->PSendSysMessage(" %u. %s (%s) - threat %f", ++count, unit->GetName().c_str(), unit->GetGUID().ToString().c_str(), (*itr)->getThreat()); + handler->PSendSysMessage(" %u. %s (%s) - threat %f", ++count, unit->GetName().c_str(), unit->GetGUID().ToString().c_str(), (*itr)->GetThreat()); } - auto const& threatList2 = target->GetThreatMgr().getOfflineThreatList(); + auto const& threatList2 = target->GetThreatMgr().GetOfflineThreatList(); for (itr = threatList2.begin(); itr != threatList2.end(); ++itr) { Unit* unit = (*itr)->getTarget(); if (!unit) { - handler->PSendSysMessage(" %u. [offline] No Unit - threat %f", ++count, (*itr)->getThreat()); + handler->PSendSysMessage(" %u. [offline] No Unit - threat %f", ++count, (*itr)->GetThreat()); continue; } - handler->PSendSysMessage(" %u. [offline] %s (%s) - threat %f", ++count, unit->GetName().c_str(), unit->GetGUID().ToString().c_str(), (*itr)->getThreat()); + handler->PSendSysMessage(" %u. [offline] %s (%s) - threat %f", ++count, unit->GetName().c_str(), unit->GetGUID().ToString().c_str(), (*itr)->GetThreat()); } handler->SendSysMessage("End of threat list."); @@ -857,12 +857,12 @@ public: { if (Unit* unit = ref->GetSource()->GetOwner()) { - handler->PSendSysMessage(" %u. %s %s (%s) - threat %f", ++count, (ref->isOnline() ? "" : "[offline]"), - unit->GetName().c_str(), unit->GetGUID().ToString().c_str(), ref->getThreat()); + handler->PSendSysMessage(" %u. %s %s (%s) - threat %f", ++count, (ref->IsOnline() ? "" : "[offline]"), + unit->GetName().c_str(), unit->GetGUID().ToString().c_str(), ref->GetThreat()); } else { - handler->PSendSysMessage(" %u. No Owner - threat %f", ++count, ref->getThreat()); + handler->PSendSysMessage(" %u. No Owner - threat %f", ++count, ref->GetThreat()); } ref = ref->next(); diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_drakkisath.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_drakkisath.cpp index c81f6b395..e4c461bf9 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_drakkisath.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_drakkisath.cpp @@ -91,8 +91,8 @@ public: if (Unit* target = me->GetVictim()) { _conflagrateTarget = me->GetVictim()->GetGUID(); - _conflagrateThreat = me->GetThreatMgr().getThreat(me->GetVictim()); - me->GetThreatMgr().modifyThreatPercent(target, -100); + _conflagrateThreat = me->GetThreatMgr().GetThreat(me->GetVictim()); + me->GetThreatMgr().ModifyThreatByPercent(target, -100); } events.ScheduleEvent(EVENT_CONFLAGRATION, urand(10000, 13000)); events.ScheduleEvent(EVENT_CHECK_CONFLAGRATION_TARGET, 10000); @@ -112,7 +112,7 @@ public: case EVENT_CHECK_CONFLAGRATION_TARGET: if (Unit* target = ObjectAccessor::GetUnit(*me, _conflagrateTarget)) { - me->GetThreatMgr().addThreat(target, _conflagrateThreat); + me->GetThreatMgr().AddThreat(target, _conflagrateThreat); } break; } diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_mor_grayhoof.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_mor_grayhoof.cpp index 94e04a926..1415d7096 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_mor_grayhoof.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_mor_grayhoof.cpp @@ -122,13 +122,13 @@ struct boss_mor_grayhoof : public BossAI // Sleep can target tank, we need to drop threat temporarily on the target. _sleepTargetGUID = target->GetGUID(); - _sleepTargetThreat = me->GetThreatMgr().getThreat(target); - me->GetThreatMgr().modifyThreatPercent(target, -100); + _sleepTargetThreat = me->GetThreatMgr().GetThreat(target); + me->GetThreatMgr().ModifyThreatByPercent(target, -100); _scheduler.Schedule(10s, [this](TaskContext /*context*/) { if (Unit* sleepTarget = ObjectAccessor::GetUnit(*me, _sleepTargetGUID)) { - me->GetThreatMgr().addThreat(sleepTarget, _sleepTargetThreat); + me->GetThreatMgr().AddThreat(sleepTarget, _sleepTargetThreat); } }); } diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_nefarian.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_nefarian.cpp index 4a8fe95d7..213e1e107 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_nefarian.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_nefarian.cpp @@ -679,7 +679,7 @@ struct boss_nefarian : public BossAI case EVENT_CLASSCALL: if (classesPresent.empty()) { - for (auto& ref : me->GetThreatMgr().getThreatList()) + for (auto& ref : me->GetThreatMgr().GetThreatList()) { if (ref->getTarget() && ref->getTarget()->GetTypeId() == TYPEID_PLAYER) { diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_ragnaros.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_ragnaros.cpp index 889cb3cd1..733e1a6a3 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_ragnaros.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_ragnaros.cpp @@ -236,7 +236,7 @@ public: void EnterEvadeMode(EvadeReason why) override { - if (!me->GetThreatMgr().getThreatList().empty()) + if (!me->GetThreatMgr().GetThreatList().empty()) { if (!_processingMagmaBurst) { diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_shazzrah.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_shazzrah.cpp index 8121b75d1..e18944ee4 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_shazzrah.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_shazzrah.cpp @@ -171,7 +171,7 @@ public: if (Creature* creatureCaster = caster->ToCreature()) { creatureCaster->GetThreatMgr().ResetAllThreat(); - creatureCaster->GetThreatMgr().addThreat(target, 1); + creatureCaster->GetThreatMgr().AddThreat(target, 1); creatureCaster->AI()->AttackStart(target); // Attack the target which caster will teleport to. } } diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp index 454009dd0..4fb6956fb 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp @@ -212,7 +212,7 @@ public: } // aggro target if Red Beam if (j == RED_PORTAL && me->GetVictim() != target && target->GetTypeId() == TYPEID_PLAYER) - me->GetThreatMgr().addThreat(target, 100000.0f + DoGetThreat(me->GetVictim())); + me->GetThreatMgr().AddThreat(target, 100000.0f + DoGetThreat(me->GetVictim())); } } diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp index 702b70481..8ba3955a7 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp @@ -251,7 +251,7 @@ public: if (!info) return; - ThreatContainer::StorageType const& t_list = me->GetThreatMgr().getThreatList(); + ThreatContainer::StorageType const& t_list = me->GetThreatMgr().GetThreatList(); std::vector targets; if (t_list.empty()) diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp index 861626e40..1855dde57 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp @@ -162,7 +162,7 @@ public: void FlameWreathEffect() { std::vector targets; - ThreatContainer::StorageType const& t_list = me->GetThreatMgr().getThreatList(); + ThreatContainer::StorageType const& t_list = me->GetThreatMgr().GetThreatList(); if (t_list.empty()) return; diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp index 43796d624..8d8bde598 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp @@ -299,16 +299,16 @@ struct boss_priestess_lackey_commonAI : public ScriptedAI void RecalculateThreat() { - ThreatContainer::StorageType const& tList = me->GetThreatMgr().getThreatList(); + ThreatContainer::StorageType const& tList = me->GetThreatMgr().GetThreatList(); for( ThreatContainer::StorageType::const_iterator itr = tList.begin(); itr != tList.end(); ++itr ) { Unit* pUnit = ObjectAccessor::GetUnit(*me, (*itr)->getUnitGuid()); - if( pUnit && pUnit->GetTypeId() == TYPEID_PLAYER && me->GetThreatMgr().getThreat(pUnit) ) + if( pUnit && pUnit->GetTypeId() == TYPEID_PLAYER && me->GetThreatMgr().GetThreat(pUnit) ) { float threatMod = GetThreatMod(me->GetDistance2d(pUnit), (float)pUnit->GetArmor(), pUnit->GetHealth(), pUnit->GetMaxHealth(), pUnit); - me->GetThreatMgr().modifyThreatPercent(pUnit, -100); - if (HostileReference* ref = me->GetThreatMgr().getOnlineContainer().getReferenceByTarget(pUnit)) - ref->addThreat(10000000.0f * threatMod); + me->GetThreatMgr().ModifyThreatByPercent(pUnit, -100); + if (HostileReference* ref = me->GetThreatMgr().GetOnlineContainer().getReferenceByTarget(pUnit)) + ref->AddThreat(10000000.0f * threatMod); } } } @@ -741,7 +741,7 @@ public: case EVENT_SPELL_BLINK: { bool InMeleeRange = false; - ThreatContainer::StorageType const& t_list = me->GetThreatMgr().getThreatList(); + ThreatContainer::StorageType const& t_list = me->GetThreatMgr().GetThreatList(); for (ThreatContainer::StorageType::const_iterator itr = t_list.begin(); itr != t_list.end(); ++itr) if (Unit* target = ObjectAccessor::GetUnit(*me, (*itr)->getUnitGuid())) if (target->IsWithinMeleeRange(me)) diff --git a/src/server/scripts/EasternKingdoms/Scholomance/instance_scholomance.cpp b/src/server/scripts/EasternKingdoms/Scholomance/instance_scholomance.cpp index 19f51d319..3bea4a1e5 100644 --- a/src/server/scripts/EasternKingdoms/Scholomance/instance_scholomance.cpp +++ b/src/server/scripts/EasternKingdoms/Scholomance/instance_scholomance.cpp @@ -371,7 +371,7 @@ public: Unit* SelectUnitCasting() { - ThreatContainer::StorageType threatlist = me->GetThreatMgr().getThreatList(); + ThreatContainer::StorageType threatlist = me->GetThreatMgr().GetThreatList(); for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) { if (Unit* unit = ObjectAccessor::GetUnit(*me, (*itr)->getUnitGuid())) diff --git a/src/server/scripts/EasternKingdoms/ZulGurub/boss_gahzranka.cpp b/src/server/scripts/EasternKingdoms/ZulGurub/boss_gahzranka.cpp index d05d1696f..6b4a19674 100644 --- a/src/server/scripts/EasternKingdoms/ZulGurub/boss_gahzranka.cpp +++ b/src/server/scripts/EasternKingdoms/ZulGurub/boss_gahzranka.cpp @@ -130,7 +130,7 @@ class spell_gahzranka_slam : public SpellScript { if (Unit* caster = GetCaster()) { - _wipeThreat = targets.size() < caster->GetThreatMgr().getThreatList().size(); + _wipeThreat = targets.size() < caster->GetThreatMgr().GetThreatListSize();; } } @@ -142,7 +142,7 @@ class spell_gahzranka_slam : public SpellScript { if (Unit* target = GetHitUnit()) { - caster->GetThreatMgr().modifyThreatPercent(target, -100); + caster->GetThreatMgr().ModifyThreatByPercent(target, -100); } } } diff --git a/src/server/scripts/EasternKingdoms/ZulGurub/boss_grilek.cpp b/src/server/scripts/EasternKingdoms/ZulGurub/boss_grilek.cpp index a8b91ac68..c50f5a75b 100644 --- a/src/server/scripts/EasternKingdoms/ZulGurub/boss_grilek.cpp +++ b/src/server/scripts/EasternKingdoms/ZulGurub/boss_grilek.cpp @@ -104,14 +104,14 @@ public: me->SetReactState(REACT_AGGRESSIVE); if (Unit* pursuitTarget = ObjectAccessor::GetUnit(*me, _pursuitTargetGUID)) { - me->GetThreatMgr().addThreat(pursuitTarget, 1000000.f); + me->GetThreatMgr().AddThreat(pursuitTarget, 1000000.f); } break; case EVENT_STOP_PURSUIT: if (Unit* pursuitTarget = ObjectAccessor::GetUnit(*me, _pursuitTargetGUID)) { _pursuitTargetGUID.Clear(); - me->GetThreatMgr().addThreat(pursuitTarget, -1000000.f); + me->GetThreatMgr().AddThreat(pursuitTarget, -1000000.f); } break; case EVENT_ENTANGLING_ROOTS: diff --git a/src/server/scripts/EasternKingdoms/ZulGurub/boss_hakkar.cpp b/src/server/scripts/EasternKingdoms/ZulGurub/boss_hakkar.cpp index b63fb4780..84192aadb 100644 --- a/src/server/scripts/EasternKingdoms/ZulGurub/boss_hakkar.cpp +++ b/src/server/scripts/EasternKingdoms/ZulGurub/boss_hakkar.cpp @@ -160,7 +160,7 @@ public: events.ScheduleEvent(EVENT_CORRUPTED_BLOOD, urand(30000, 45000)); break; case EVENT_CAUSE_INSANITY: - if (me->GetThreatMgr().getThreatList().size() > 1) + if (me->GetThreatMgr().GetThreatListSize() > 1) { if (Unit* victim = SelectTarget(SelectTargetMethod::MaxThreat, 0, 30.f, true)) { @@ -186,7 +186,7 @@ public: if (Unit* victim = SelectTarget(SelectTargetMethod::MaxThreat, 0, 5.f, true)) { DoCast(victim, SPELL_ASPECT_OF_MARLI, true); - me->GetThreatMgr().modifyThreatPercent(victim, -100.f); + me->GetThreatMgr().ModifyThreatByPercent(victim, -100.f); } events.ScheduleEvent(EVENT_ASPECT_OF_MARLI, 45000); break; @@ -198,7 +198,7 @@ public: if (Unit* victim = SelectTarget(SelectTargetMethod::MaxThreat, 0, 5.f, true)) { DoCast(victim, SPELL_ASPECT_OF_ARLOKK, true); - me->GetThreatMgr().modifyThreatPercent(victim, -100.f); + me->GetThreatMgr().ModifyThreatByPercent(victim, -100.f); } events.ScheduleEvent(EVENT_ASPECT_OF_ARLOKK, urand(10000, 15000)); break; diff --git a/src/server/scripts/EasternKingdoms/ZulGurub/boss_hazzarah.cpp b/src/server/scripts/EasternKingdoms/ZulGurub/boss_hazzarah.cpp index be9b57e66..648057c56 100644 --- a/src/server/scripts/EasternKingdoms/ZulGurub/boss_hazzarah.cpp +++ b/src/server/scripts/EasternKingdoms/ZulGurub/boss_hazzarah.cpp @@ -80,7 +80,7 @@ struct boss_hazzarah : public BossAI bool CanAIAttack(Unit const* target) const override { - if (me->GetThreatMgr().getThreatList().size() > 1 && me->GetThreatMgr().getOnlineContainer().getMostHated()->getTarget() == target) + if (me->GetThreatMgr().GetThreatListSize() > 1 && me->GetThreatMgr().GetOnlineContainer().getMostHated()->getTarget() == target) return !target->HasAura(SPELL_SLEEP); return true; diff --git a/src/server/scripts/EasternKingdoms/ZulGurub/boss_jindo.cpp b/src/server/scripts/EasternKingdoms/ZulGurub/boss_jindo.cpp index 6d85c47d8..0c69b7a29 100644 --- a/src/server/scripts/EasternKingdoms/ZulGurub/boss_jindo.cpp +++ b/src/server/scripts/EasternKingdoms/ZulGurub/boss_jindo.cpp @@ -81,7 +81,7 @@ struct boss_jindo : public BossAI { case NPC_BRAIN_WASH_TOTEM: summon->SetReactState(REACT_PASSIVE); - if (Unit* target = SelectTarget(SelectTargetMethod::Random, me->GetThreatMgr().getThreatList().size() > 1 ? 1 : 0)) + if (Unit* target = SelectTarget(SelectTargetMethod::Random, me->GetThreatMgr().GetThreatListSize() > 1 ? 1 : 0)) { summon->CastSpell(target, summon->m_spells[0], true); } @@ -132,7 +132,7 @@ struct boss_jindo : public BossAI events.ScheduleEvent(EVENT_POWERFULL_HEALING_WARD, urand(14000, 20000)); break; case EVENT_HEX: - if (me->GetThreatMgr().getThreatList().size() > 1) + if (me->GetThreatMgr().GetThreatListSize() > 1) DoCastVictim(SPELL_HEX, true); events.ScheduleEvent(EVENT_HEX, urand(12000, 20000)); break; @@ -154,7 +154,7 @@ struct boss_jindo : public BossAI bool CanAIAttack(Unit const* target) const override { - if (me->GetThreatMgr().getThreatList().size() > 1 && me->GetThreatMgr().getOnlineContainer().getMostHated()->getTarget() == target) + if (me->GetThreatMgr().GetThreatListSize() > 1 && me->GetThreatMgr().GetOnlineContainer().getMostHated()->getTarget() == target) return !target->HasAura(SPELL_HEX); return true; diff --git a/src/server/scripts/EasternKingdoms/ZulGurub/boss_mandokir.cpp b/src/server/scripts/EasternKingdoms/ZulGurub/boss_mandokir.cpp index d0d82b76b..11f398ef4 100644 --- a/src/server/scripts/EasternKingdoms/ZulGurub/boss_mandokir.cpp +++ b/src/server/scripts/EasternKingdoms/ZulGurub/boss_mandokir.cpp @@ -457,7 +457,7 @@ public: events.DelayEvents(1500); if (Unit* mainTarget = SelectTarget(SelectTargetMethod::MaxThreat, 0, 100.0f)) { - me->GetThreatMgr().modifyThreatPercent(mainTarget, -100); + me->GetThreatMgr().ModifyThreatByPercent(mainTarget, -100); } } events.ScheduleEvent(EVENT_CHARGE_PLAYER, urand(30000, 40000)); @@ -469,8 +469,8 @@ public: case EVENT_CLEAVE: { std::list meleeRangeTargets; - auto i = me->GetThreatMgr().getThreatList().begin(); - for (; i != me->GetThreatMgr().getThreatList().end(); ++i) + auto i = me->GetThreatMgr().GetThreatList().begin(); + for (; i != me->GetThreatMgr().GetThreatList().end(); ++i) { Unit* target = (*i)->getTarget(); if (me->IsWithinMeleeRange(target)) diff --git a/src/server/scripts/EasternKingdoms/ZulGurub/boss_marli.cpp b/src/server/scripts/EasternKingdoms/ZulGurub/boss_marli.cpp index 6748979a8..806477ace 100644 --- a/src/server/scripts/EasternKingdoms/ZulGurub/boss_marli.cpp +++ b/src/server/scripts/EasternKingdoms/ZulGurub/boss_marli.cpp @@ -314,7 +314,7 @@ class spell_enveloping_webs : public SpellScript Unit* hitUnit = GetHitUnit(); if (caster && hitUnit && hitUnit->GetTypeId() == TYPEID_PLAYER) { - caster->GetThreatMgr().modifyThreatPercent(hitUnit, -100); + caster->GetThreatMgr().ModifyThreatByPercent(hitUnit, -100); } } diff --git a/src/server/scripts/EasternKingdoms/ZulGurub/boss_renataki.cpp b/src/server/scripts/EasternKingdoms/ZulGurub/boss_renataki.cpp index f2afa88ca..373f2a8f8 100644 --- a/src/server/scripts/EasternKingdoms/ZulGurub/boss_renataki.cpp +++ b/src/server/scripts/EasternKingdoms/ZulGurub/boss_renataki.cpp @@ -85,7 +85,7 @@ public: bool CanAIAttack(Unit const* target) const override { - if (me->GetThreatMgr().getThreatList().size() > 1 && me->GetThreatMgr().getOnlineContainer().getMostHated()->getTarget() == target) + if (me->GetThreatMgr().GetThreatListSize() > 1 && me->GetThreatMgr().GetOnlineContainer().getMostHated()->getTarget() == target) return !target->HasAura(SPELL_GOUGE); return true; @@ -158,7 +158,7 @@ public: if (_thousandBladesTargets.empty()) { std::vector targetList; - ThreatContainer::StorageType const& threatlist = me->GetThreatMgr().getThreatList(); + ThreatContainer::StorageType const& threatlist = me->GetThreatMgr().GetThreatList(); for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) { if (Unit* target = (*itr)->getTarget()) diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_archimonde.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_archimonde.cpp index c786f683b..8f616e1ef 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_archimonde.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_archimonde.cpp @@ -325,7 +325,7 @@ public: return; // Now lets get archimode threat list - ThreatContainer::StorageType const& t_list = me->GetThreatMgr().getThreatList(); + ThreatContainer::StorageType const& t_list = me->GetThreatMgr().GetThreatList(); if (t_list.empty()) return; @@ -435,7 +435,7 @@ public: if (victim && me->IsWithinMeleeRange(victim)) return false; - ThreatContainer::StorageType const& threatlist = me->GetThreatMgr().getThreatList(); + ThreatContainer::StorageType const& threatlist = me->GetThreatMgr().GetThreatList(); if (threatlist.empty()) return false; diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_bug_trio.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_bug_trio.cpp index c57a95144..d4fb57363 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_bug_trio.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_bug_trio.cpp @@ -423,7 +423,7 @@ class spell_vem_knockback : public SpellScript { if (Creature* cCaster = GetCaster()->ToCreature()) { - cCaster->GetThreatMgr().modifyThreatPercent(target, -80); + cCaster->GetThreatMgr().ModifyThreatByPercent(target, -80); } } } diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_ouro.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_ouro.cpp index 5d78ec10e..a19ea1eae 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_ouro.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_ouro.cpp @@ -180,7 +180,7 @@ struct boss_ouro : public BossAI void SpellHitTarget(Unit* target, SpellInfo const* spellInfo) override { if (spellInfo->Id == SPELL_SAND_BLAST && target) - me->GetThreatMgr().modifyThreatPercent(target, 100); + me->GetThreatMgr().ModifyThreatByPercent(target, 100); } void Emerge() diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_sartura.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_sartura.cpp index 221c30c73..6dabe7337 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_sartura.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_sartura.cpp @@ -169,8 +169,8 @@ struct boss_sartura : public BossAI if (Unit* originalTarget = SelectTarget(SelectTargetMethod::Random, 0)) { _savedTargetGUID = originalTarget->GetGUID(); - _savedTargetThreat = me->GetThreatMgr().getThreat(originalTarget); - me->GetThreatMgr().modifyThreatPercent(originalTarget, -100); + _savedTargetThreat = me->GetThreatMgr().GetThreat(originalTarget); + me->GetThreatMgr().ModifyThreatByPercent(originalTarget, -100); } aggroReset = true; events.ScheduleEvent(EVENT_SARTURA_AGGRO_RESET_END, 5000); @@ -190,7 +190,7 @@ struct boss_sartura : public BossAI events.CancelEvent(EVENT_SARTURA_AGGRO_RESET); if (Unit* originalTarget = ObjectAccessor::GetUnit(*me, _savedTargetGUID)) { - me->GetThreatMgr().addThreat(originalTarget, _savedTargetThreat); + me->GetThreatMgr().AddThreat(originalTarget, _savedTargetThreat); _savedTargetGUID.Clear(); } aggroReset = false; @@ -286,8 +286,8 @@ struct npc_sartura_royal_guard : public ScriptedAI if (Unit* originalTarget = SelectTarget(SelectTargetMethod::Random, 0)) { _savedTargetGUID = originalTarget->GetGUID(); - _savedTargetThreat = me->GetThreatMgr().getThreat(originalTarget); - me->GetThreatMgr().modifyThreatPercent(originalTarget, -100); + _savedTargetThreat = me->GetThreatMgr().GetThreat(originalTarget); + me->GetThreatMgr().ModifyThreatByPercent(originalTarget, -100); } aggroReset = true; events.ScheduleEvent(EVENT_GUARD_AGGRO_RESET_END, 5000); @@ -307,7 +307,7 @@ struct npc_sartura_royal_guard : public ScriptedAI events.CancelEvent(EVENT_GUARD_AGGRO_RESET); if (Unit* originalTarget = ObjectAccessor::GetUnit(*me, _savedTargetGUID)) { - me->GetThreatMgr().addThreat(originalTarget, _savedTargetThreat); + me->GetThreatMgr().AddThreat(originalTarget, _savedTargetThreat); _savedTargetGUID.Clear(); } aggroReset = false; diff --git a/src/server/scripts/Kalimdor/boss_azuregos.cpp b/src/server/scripts/Kalimdor/boss_azuregos.cpp index 13c6ee445..66d5f2129 100644 --- a/src/server/scripts/Kalimdor/boss_azuregos.cpp +++ b/src/server/scripts/Kalimdor/boss_azuregos.cpp @@ -189,7 +189,7 @@ class spell_arcane_vacuum : public SpellScript Unit* hitUnit = GetHitUnit(); if (caster && hitUnit && hitUnit->ToPlayer()) { - caster->GetThreatMgr().modifyThreatPercent(hitUnit, -100); + caster->GetThreatMgr().ModifyThreatByPercent(hitUnit, -100); caster->CastSpell(hitUnit, SPELL_ARCANE_VACUUM_TP, true); } } diff --git a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_prince_taldaram.cpp b/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_prince_taldaram.cpp index f4bf7e5b4..9b073985e 100644 --- a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_prince_taldaram.cpp +++ b/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_prince_taldaram.cpp @@ -411,7 +411,7 @@ struct boss_taldaram : public BossAI { //Count alive players uint8 count = 0; - std::list const t_list = me->GetThreatMgr().getThreatList(); + std::list const t_list = me->GetThreatMgr().GetThreatList(); if (!t_list.empty()) { for (HostileReference const* reference : t_list) diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_faction_champions.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_faction_champions.cpp index 3ccc2a9c4..c80a6107c 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_faction_champions.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_faction_champions.cpp @@ -102,17 +102,17 @@ struct boss_faction_championsAI : public ScriptedAI void RecalculateThreat() { - ThreatContainer::StorageType const& tList = me->GetThreatMgr().getThreatList(); + ThreatContainer::StorageType const& tList = me->GetThreatMgr().GetThreatList(); for( ThreatContainer::StorageType::const_iterator itr = tList.begin(); itr != tList.end(); ++itr ) { Unit* pUnit = ObjectAccessor::GetUnit(*me, (*itr)->getUnitGuid()); - if( pUnit && pUnit->GetTypeId() == TYPEID_PLAYER && me->GetThreatMgr().getThreat(pUnit) ) + if( pUnit && pUnit->GetTypeId() == TYPEID_PLAYER && me->GetThreatMgr().GetThreat(pUnit) ) { float threatMod = GetThreatMod(me->GetDistance2d(pUnit), (float)pUnit->GetArmor(), pUnit->GetHealth(), pUnit->GetMaxHealth(), pUnit); - me->GetThreatMgr().modifyThreatPercent(pUnit, -100); - //me->getThreatMgr().doAddThreat(pUnit, 10000000.0f * threatMod); - if (HostileReference* ref = me->GetThreatMgr().getOnlineContainer().getReferenceByTarget(pUnit)) - ref->addThreat(10000000.0f * threatMod); + me->GetThreatMgr().ModifyThreatByPercent(pUnit, -100); + //me->getThreatMgr().DoAddThreat(pUnit, 10000000.0f * threatMod); + if (HostileReference* ref = me->GetThreatMgr().GetOnlineContainer().getReferenceByTarget(pUnit)) + ref->AddThreat(10000000.0f * threatMod); } } } @@ -177,7 +177,7 @@ struct boss_faction_championsAI : public ScriptedAI uint32 EnemiesInRange(float distance) { - ThreatContainer::StorageType const& tList = me->GetThreatMgr().getThreatList(); + ThreatContainer::StorageType const& tList = me->GetThreatMgr().GetThreatList(); uint32 count = 0; Unit* target; for( ThreatContainer::StorageType::const_iterator iter = tList.begin(); iter != tList.end(); ++iter ) @@ -191,7 +191,7 @@ struct boss_faction_championsAI : public ScriptedAI Unit* SelectEnemyCaster(bool casting, float range) { - ThreatContainer::StorageType const& tList = me->GetThreatMgr().getThreatList(); + ThreatContainer::StorageType const& tList = me->GetThreatMgr().GetThreatList(); Unit* target; for( ThreatContainer::StorageType::const_iterator iter = tList.begin(); iter != tList.end(); ++iter ) { diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp index e2c600ba0..fdb3b37f4 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp @@ -299,7 +299,7 @@ public: if (events.GetPhaseMask() & PHASE_ONE_MASK && damage >= me->GetPower(POWER_MANA)) { // reset threat - ThreatContainer::StorageType const& threatlist = me->GetThreatMgr().getThreatList(); + ThreatContainer::StorageType const& threatlist = me->GetThreatMgr().GetThreatList(); for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) { Unit* unit = ObjectAccessor::GetUnit((*me), (*itr)->getUnitGuid()); diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp index 98d5adf71..1484e1aa7 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp @@ -592,7 +592,7 @@ public: { checkTimer = 3000; me->SetInCombatWithZone(); - ThreatContainer::StorageType const& threatList = me->GetThreatMgr().getThreatList(); + ThreatContainer::StorageType const& threatList = me->GetThreatMgr().GetThreatList(); if (!threatList.empty()) for (ThreatContainer::StorageType::const_iterator itr = threatList.begin(); itr != threatList.end(); ++itr) if (Unit* target = (*itr)->getTarget()) diff --git a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp index c3f478d12..b581decfc 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp @@ -1775,15 +1775,15 @@ public: Position myPos = me->GetPosition(); me->NearTeleportTo(c->GetPositionX(), c->GetPositionY(), c->GetPositionZ(), c->GetOrientation()); c->NearTeleportTo(myPos.GetPositionX(), myPos.GetPositionY(), myPos.GetPositionZ(), myPos.GetOrientation()); - const ThreatContainer::StorageType me_tl = me->GetThreatMgr().getThreatList(); - const ThreatContainer::StorageType target_tl = c->GetThreatMgr().getThreatList(); + const ThreatContainer::StorageType me_tl = me->GetThreatMgr().GetThreatList(); + const ThreatContainer::StorageType target_tl = c->GetThreatMgr().GetThreatList(); DoResetThreat(); for (ThreatContainer::StorageType::const_iterator iter = target_tl.begin(); iter != target_tl.end(); ++iter) - me->GetThreatMgr().addThreat((*iter)->getTarget(), (*iter)->getThreat()); + me->GetThreatMgr().AddThreat((*iter)->getTarget(), (*iter)->GetThreat()); c->GetThreatMgr().ResetAllThreat(); for (ThreatContainer::StorageType::const_iterator iter = me_tl.begin(); iter != me_tl.end(); ++iter) - c->GetThreatMgr().addThreat((*iter)->getTarget(), (*iter)->getThreat()); + c->GetThreatMgr().AddThreat((*iter)->getTarget(), (*iter)->GetThreat()); } } diff --git a/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp b/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp index 65d745f89..591cb95b5 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp @@ -456,7 +456,7 @@ public: me->GetThreatMgr().resetAggro(NotOnSameSide(me)); if (Unit* pTarget = SelectTarget(SelectTargetMethod::MaxDistance, 0)) { - me->GetThreatMgr().addThreat(pTarget, 100.0f); + me->GetThreatMgr().AddThreat(pTarget, 100.0f); AttackStart(pTarget); } events.RepeatEvent(20000); diff --git a/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp b/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp index 92d5ebff2..5617f54da 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp @@ -438,7 +438,7 @@ public: case EVENT_DETONATE_MANA: { std::vector unitList; - ThreatContainer::StorageType const& threatList = me->GetThreatMgr().getThreatList(); + ThreatContainer::StorageType const& threatList = me->GetThreatMgr().GetThreatList(); for (auto itr : threatList) { if (itr->getTarget()->GetTypeId() == TYPEID_PLAYER diff --git a/src/server/scripts/Northrend/Naxxramas/boss_patchwerk.cpp b/src/server/scripts/Northrend/Naxxramas/boss_patchwerk.cpp index 275569233..e3e88e92f 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_patchwerk.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_patchwerk.cpp @@ -128,8 +128,8 @@ public: std::list meleeRangeTargets; Unit* finalTarget = nullptr; uint8 counter = 0; - auto i = me->GetThreatMgr().getThreatList().begin(); - for (; i != me->GetThreatMgr().getThreatList().end(); ++i, ++counter) + auto i = me->GetThreatMgr().GetThreatList().begin(); + for (; i != me->GetThreatMgr().GetThreatList().end(); ++i, ++counter) { // Gather all units with melee range Unit* target = (*i)->getTarget(); diff --git a/src/server/scripts/Northrend/Naxxramas/boss_sapphiron.cpp b/src/server/scripts/Northrend/Naxxramas/boss_sapphiron.cpp index 9d5940163..6f31f8417 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_sapphiron.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_sapphiron.cpp @@ -321,8 +321,8 @@ public: } std::vector targets; - auto i = me->GetThreatMgr().getThreatList().begin(); - for (; i != me->GetThreatMgr().getThreatList().end(); ++i) + auto i = me->GetThreatMgr().GetThreatList().begin(); + for (; i != me->GetThreatMgr().GetThreatList().end(); ++i) { if ((*i)->getTarget()->GetTypeId() == TYPEID_PLAYER) { diff --git a/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp b/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp index aace56577..4b9d3fde4 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp @@ -553,17 +553,17 @@ public: if (!feugen->IsAlive() || !feugen->GetVictim() || !me->GetVictim()) return; - float threatFeugen = feugen->GetThreatMgr().getThreat(feugen->GetVictim()); - float threatStalagg = me->GetThreatMgr().getThreat(me->GetVictim()); + float threatFeugen = feugen->GetThreatMgr().GetThreat(feugen->GetVictim()); + float threatStalagg = me->GetThreatMgr().GetThreat(me->GetVictim()); Unit* tankFeugen = feugen->GetVictim(); Unit* tankStalagg = me->GetVictim(); - feugen->GetThreatMgr().modifyThreatPercent(tankFeugen, -100); + feugen->GetThreatMgr().ModifyThreatByPercent(tankFeugen, -100); feugen->AddThreat(tankStalagg, threatFeugen); feugen->CastSpell(tankStalagg, SPELL_MAGNETIC_PULL, true); feugen->AI()->DoAction(ACTION_MAGNETIC_PULL); - me->GetThreatMgr().modifyThreatPercent(tankStalagg, -100); + me->GetThreatMgr().ModifyThreatByPercent(tankStalagg, -100); me->AddThreat(tankFeugen, threatStalagg); me->CastSpell(tankFeugen, SPELL_MAGNETIC_PULL, true); DoAction(ACTION_MAGNETIC_PULL); diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp index fd4456b7c..1196e2c10 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp @@ -670,7 +670,7 @@ public: bool operator() (WorldObject* target) const { - if (target == _victim && _me->GetThreatMgr().getThreatList().size() > 1) + if (target == _victim && _me->GetThreatMgr().GetThreatListSize() > 1) return true; if (target->GetTypeId() != TYPEID_PLAYER) diff --git a/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_blackheart_the_inciter.cpp b/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_blackheart_the_inciter.cpp index d23c7ab42..8404dd047 100644 --- a/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_blackheart_the_inciter.cpp +++ b/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_blackheart_the_inciter.cpp @@ -116,7 +116,7 @@ public: { me->CastSpell(me, SPELL_INCITE_CHAOS, false); - std::list t_list = me->GetThreatMgr().getThreatList(); + std::list t_list = me->GetThreatMgr().GetThreatList(); for (std::list::const_iterator itr = t_list.begin(); itr != t_list.end(); ++itr) { Unit* target = ObjectAccessor::GetUnit(*me, (*itr)->getUnitGuid()); diff --git a/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_murmur.cpp b/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_murmur.cpp index bb3686d76..fba9f6f19 100644 --- a/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_murmur.cpp +++ b/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_murmur.cpp @@ -150,7 +150,7 @@ public: if (!me->IsWithinMeleeRange(me->GetVictim())) { - ThreatContainer::StorageType threatlist = me->GetThreatMgr().getThreatList(); + ThreatContainer::StorageType threatlist = me->GetThreatMgr().GetThreatList(); for (ThreatContainer::StorageType::const_iterator i = threatlist.begin(); i != threatlist.end(); ++i) if (Unit* target = ObjectAccessor::GetUnit(*me, (*i)->getUnitGuid())) if (target->IsAlive() && me->IsWithinMeleeRange(target)) diff --git a/src/server/scripts/Outland/BlackTemple/boss_bloodboil.cpp b/src/server/scripts/Outland/BlackTemple/boss_bloodboil.cpp index d8955c7d8..e7ddb967b 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_bloodboil.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_bloodboil.cpp @@ -245,7 +245,7 @@ public: { PreventHitEffect(effIndex); if (Unit* target = GetHitUnit()) - GetCaster()->GetThreatMgr().modifyThreatPercent(target, -20); + GetCaster()->GetThreatMgr().ModifyThreatByPercent(target, -20); } void Register() override diff --git a/src/server/scripts/Outland/BlackTemple/boss_supremus.cpp b/src/server/scripts/Outland/BlackTemple/boss_supremus.cpp index 16825cc56..722db4cce 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_supremus.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_supremus.cpp @@ -126,7 +126,7 @@ public: Unit* FindHatefulStrikeTarget() { Unit* target = nullptr; - ThreatContainer::StorageType const& threatlist = me->GetThreatMgr().getThreatList(); + ThreatContainer::StorageType const& threatlist = me->GetThreatMgr().GetThreatList(); for (ThreatContainer::StorageType::const_iterator i = threatlist.begin(); i != threatlist.end(); ++i) { Unit* unit = ObjectAccessor::GetUnit(*me, (*i)->getUnitGuid()); diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lurker_below.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lurker_below.cpp index d2036cb02..1ff3f3771 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lurker_below.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lurker_below.cpp @@ -187,7 +187,7 @@ public: target = me->GetVictim(); else { - ThreatContainer::StorageType const& t_list = me->GetThreatMgr().getThreatList(); + ThreatContainer::StorageType const& t_list = me->GetThreatMgr().GetThreatList(); for (ThreatContainer::StorageType::const_iterator itr = t_list.begin(); itr != t_list.end(); ++itr) if (Unit* threatTarget = ObjectAccessor::GetUnit(*me, (*itr)->getUnitGuid())) if (me->IsWithinMeleeRange(threatTarget)) diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_morogrim_tidewalker.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_morogrim_tidewalker.cpp index 5c70e0271..66c73cca7 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_morogrim_tidewalker.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_morogrim_tidewalker.cpp @@ -221,7 +221,7 @@ public: // Xinef: if we have target we currently follow, return if (Unit* target = GetCaster()->GetVictim()) - if (GetCaster()->GetThreatMgr().getThreat(target) >= 100000.0f) + if (GetCaster()->GetThreatMgr().GetThreat(target) >= 100000.0f) return; // Xinef: acquire new target diff --git a/src/server/scripts/Outland/TempestKeep/Eye/boss_alar.cpp b/src/server/scripts/Outland/TempestKeep/Eye/boss_alar.cpp index 076c96442..dfa312a1b 100644 --- a/src/server/scripts/Outland/TempestKeep/Eye/boss_alar.cpp +++ b/src/server/scripts/Outland/TempestKeep/Eye/boss_alar.cpp @@ -323,7 +323,7 @@ public: else { me->resetAttackTimer(); - ThreatContainer::StorageType const& threatList = me->GetThreatMgr().getThreatList(); + ThreatContainer::StorageType const& threatList = me->GetThreatMgr().GetThreatList(); for (ThreatContainer::StorageType::const_iterator itr = threatList.begin(); itr != threatList.end(); ++itr) if (Unit* unit = ObjectAccessor::GetUnit(*me, (*itr)->getUnitGuid())) if (me->IsWithinMeleeRange(unit)) diff --git a/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp b/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp index 7d6ab1d67..eea9cda11 100644 --- a/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp +++ b/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp @@ -994,7 +994,7 @@ public: { PreventHitEffect(effIndex); - ThreatContainer::StorageType const& ThreatList = GetCaster()-> GetThreatMgr().getThreatList(); + ThreatContainer::StorageType const& ThreatList = GetCaster()-> GetThreatMgr().GetThreatList(); std::list targetList; for (ThreatContainer::StorageType::const_iterator itr = ThreatList.begin(); itr != ThreatList.end(); ++itr) { diff --git a/src/server/scripts/Outland/zone_netherstorm.cpp b/src/server/scripts/Outland/zone_netherstorm.cpp index 3ed77d91e..980d00719 100644 --- a/src/server/scripts/Outland/zone_netherstorm.cpp +++ b/src/server/scripts/Outland/zone_netherstorm.cpp @@ -1741,7 +1741,7 @@ public: // some code to cast spell Mana Burn on random target which has mana if (ManaBurnTimer <= diff) { - std::list AggroList = me->GetThreatMgr().getThreatList(); + std::list AggroList = me->GetThreatMgr().GetThreatList(); std::list UnitsWithMana; for (std::list::const_iterator itr = AggroList.begin(); itr != AggroList.end(); ++itr) diff --git a/src/server/scripts/Outland/zone_shadowmoon_valley.cpp b/src/server/scripts/Outland/zone_shadowmoon_valley.cpp index 8859a7e36..6f21b92e8 100644 --- a/src/server/scripts/Outland/zone_shadowmoon_valley.cpp +++ b/src/server/scripts/Outland/zone_shadowmoon_valley.cpp @@ -489,7 +489,7 @@ public: AttackStart(Dragonmaw); } - HostileReference* ref = me->GetThreatMgr().getOnlineContainer().getReferenceByTarget(caster); + HostileReference* ref = me->GetThreatMgr().GetOnlineContainer().getReferenceByTarget(caster); if (ref) ref->removeReference(); } diff --git a/src/server/scripts/Pet/pet_mage.cpp b/src/server/scripts/Pet/pet_mage.cpp index dd7ce5745..d426b6b31 100644 --- a/src/server/scripts/Pet/pet_mage.cpp +++ b/src/server/scripts/Pet/pet_mage.cpp @@ -101,7 +101,7 @@ struct npc_pet_mage_mirror_image : CasterAI while (ref) { if (Unit* unit = ref->GetSource()->GetOwner()) - unit->AddThreat(me, ref->getThreat() - ref->getTempThreatModifier()); + unit->AddThreat(me, ref->GetThreat() - ref->getTempThreatModifier()); ref = ref->next(); } diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index ea4028627..7e16ae4f6 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -893,7 +893,7 @@ class spell_gen_knock_away : public SpellScript PreventHitDefaultEffect(effIndex); if (Unit* target = GetHitUnit()) if (Creature* caster = GetCaster()->ToCreature()) - caster->GetThreatMgr().modifyThreatPercent(target, -25); // Xinef: amount confirmed by onyxia and void reaver notes + caster->GetThreatMgr().ModifyThreatByPercent(target, -25); // Xinef: amount confirmed by onyxia and void reaver notes } void Register() override @@ -999,7 +999,7 @@ class spell_gen_hate_to_zero : public SpellScript PreventHitDefaultEffect(effIndex); if (Unit* target = GetHitUnit()) if (Creature* caster = GetCaster()->ToCreature()) - caster->GetThreatMgr().modifyThreatPercent(target, -100); + caster->GetThreatMgr().ModifyThreatByPercent(target, -100); } void Register() override diff --git a/src/server/scripts/Spells/spell_warlock.cpp b/src/server/scripts/Spells/spell_warlock.cpp index 82a3e5e99..f23d3a247 100644 --- a/src/server/scripts/Spells/spell_warlock.cpp +++ b/src/server/scripts/Spells/spell_warlock.cpp @@ -699,7 +699,7 @@ class spell_warl_soulshatter : public SpellScript Unit* caster = GetCaster(); if (Unit* target = GetHitUnit()) { - if (target->CanHaveThreatList() && target->GetThreatMgr().getThreat(caster) > 0.0f) + if (target->CanHaveThreatList() && target->GetThreatMgr().GetThreat(caster) > 0.0f) caster->CastSpell(target, SPELL_WARLOCK_SOULSHATTER, true); } } diff --git a/src/server/scripts/World/boss_emerald_dragons.cpp b/src/server/scripts/World/boss_emerald_dragons.cpp index a45f55d13..fb3046986 100644 --- a/src/server/scripts/World/boss_emerald_dragons.cpp +++ b/src/server/scripts/World/boss_emerald_dragons.cpp @@ -320,7 +320,7 @@ public: { Talk(SAY_YSONDRE_SUMMON_DRUIDS); - auto const& attackers = me->GetThreatMgr().getThreatList(); + auto const& attackers = me->GetThreatMgr().GetThreatList(); uint8 attackersCount = 0; for (const auto attacker : attackers) diff --git a/src/server/scripts/World/npc_stave_of_ancients.cpp b/src/server/scripts/World/npc_stave_of_ancients.cpp index 8ce88a0d5..24e6fa411 100644 --- a/src/server/scripts/World/npc_stave_of_ancients.cpp +++ b/src/server/scripts/World/npc_stave_of_ancients.cpp @@ -111,7 +111,7 @@ bool NPCStaveQuestAI::IsFairFight() { Unit* unit = ObjectAccessor::GetUnit(*me, (*itr)->getUnitGuid()); - if (!(*itr)->getThreat()) + if (!(*itr)->GetThreat()) { // if target threat is 0 its fair, this prevents despawn in the case when // there is a bystander since UpdateVictim adds nearby enemies to the threatlist diff --git a/src/server/scripts/World/npc_stave_of_ancients.h b/src/server/scripts/World/npc_stave_of_ancients.h index d0b6c96ad..719499c9e 100644 --- a/src/server/scripts/World/npc_stave_of_ancients.h +++ b/src/server/scripts/World/npc_stave_of_ancients.h @@ -138,7 +138,7 @@ struct NPCStaveQuestAI : public ScriptedAI ObjectGuid gossipPlayerGUID; ObjectGuid playerGUID; bool encounterStarted; - ThreatContainer::StorageType const& threatList = me->GetThreatMgr().getThreatList(); + ThreatContainer::StorageType const& threatList = me->GetThreatMgr().GetThreatList(); std::map entryKeys = { { ARTORIUS_NORMAL_ENTRY, 1 },