refactor(Core/Combat): Code style and improvement of ThreatMgr (#12992)

This commit is contained in:
Maelthyr
2022-09-25 20:20:34 +02:00
committed by GitHub
parent ddcf0e79b6
commit 1f472bddd3
61 changed files with 212 additions and 196 deletions

View File

@@ -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();

View File

@@ -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;
}

View File

@@ -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);
}
});
}

View File

@@ -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)
{

View File

@@ -236,7 +236,7 @@ public:
void EnterEvadeMode(EvadeReason why) override
{
if (!me->GetThreatMgr().getThreatList().empty())
if (!me->GetThreatMgr().GetThreatList().empty())
{
if (!_processingMagmaBurst)
{

View File

@@ -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.
}
}

View File

@@ -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()));
}
}

View File

@@ -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<Unit*> targets;
if (t_list.empty())

View File

@@ -162,7 +162,7 @@ public:
void FlameWreathEffect()
{
std::vector<Unit*> targets;
ThreatContainer::StorageType const& t_list = me->GetThreatMgr().getThreatList();
ThreatContainer::StorageType const& t_list = me->GetThreatMgr().GetThreatList();
if (t_list.empty())
return;

View File

@@ -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))

View File

@@ -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()))

View File

@@ -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);
}
}
}

View File

@@ -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:

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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<Unit*> 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))

View File

@@ -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);
}
}

View File

@@ -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<Unit*> 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())

View File

@@ -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;

View File

@@ -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);
}
}
}

View File

@@ -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()

View File

@@ -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;

View File

@@ -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);
}
}

View File

@@ -411,7 +411,7 @@ struct boss_taldaram : public BossAI
{
//Count alive players
uint8 count = 0;
std::list<HostileReference*> const t_list = me->GetThreatMgr().getThreatList();
std::list<HostileReference*> const t_list = me->GetThreatMgr().GetThreatList();
if (!t_list.empty())
{
for (HostileReference const* reference : t_list)

View File

@@ -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 )
{

View File

@@ -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());

View File

@@ -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())

View File

@@ -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());
}
}

View File

@@ -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);

View File

@@ -438,7 +438,7 @@ public:
case EVENT_DETONATE_MANA:
{
std::vector<Unit*> 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

View File

@@ -128,8 +128,8 @@ public:
std::list<Unit*> 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();

View File

@@ -321,8 +321,8 @@ public:
}
std::vector<Unit*> 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)
{

View File

@@ -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);

View File

@@ -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)

View File

@@ -116,7 +116,7 @@ public:
{
me->CastSpell(me, SPELL_INCITE_CHAOS, false);
std::list<HostileReference*> t_list = me->GetThreatMgr().getThreatList();
std::list<HostileReference*> t_list = me->GetThreatMgr().GetThreatList();
for (std::list<HostileReference*>::const_iterator itr = t_list.begin(); itr != t_list.end(); ++itr)
{
Unit* target = ObjectAccessor::GetUnit(*me, (*itr)->getUnitGuid());

View File

@@ -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))

View File

@@ -245,7 +245,7 @@ public:
{
PreventHitEffect(effIndex);
if (Unit* target = GetHitUnit())
GetCaster()->GetThreatMgr().modifyThreatPercent(target, -20);
GetCaster()->GetThreatMgr().ModifyThreatByPercent(target, -20);
}
void Register() override

View File

@@ -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());

View File

@@ -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))

View File

@@ -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

View File

@@ -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))

View File

@@ -994,7 +994,7 @@ public:
{
PreventHitEffect(effIndex);
ThreatContainer::StorageType const& ThreatList = GetCaster()-> GetThreatMgr().getThreatList();
ThreatContainer::StorageType const& ThreatList = GetCaster()-> GetThreatMgr().GetThreatList();
std::list<Unit*> targetList;
for (ThreatContainer::StorageType::const_iterator itr = ThreatList.begin(); itr != ThreatList.end(); ++itr)
{

View File

@@ -1741,7 +1741,7 @@ public:
// some code to cast spell Mana Burn on random target which has mana
if (ManaBurnTimer <= diff)
{
std::list<HostileReference*> AggroList = me->GetThreatMgr().getThreatList();
std::list<HostileReference*> AggroList = me->GetThreatMgr().GetThreatList();
std::list<Unit*> UnitsWithMana;
for (std::list<HostileReference*>::const_iterator itr = AggroList.begin(); itr != AggroList.end(); ++itr)

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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

View File

@@ -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);
}
}

View File

@@ -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)

View File

@@ -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

View File

@@ -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<int, int> entryKeys = {
{ ARTORIUS_NORMAL_ENTRY, 1 },