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

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