mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-13 23:43:44 +00:00
refactor(Core/Combat): Code style and improvement of ThreatMgr (#12992)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -236,7 +236,7 @@ public:
|
||||
|
||||
void EnterEvadeMode(EvadeReason why) override
|
||||
{
|
||||
if (!me->GetThreatMgr().getThreatList().empty())
|
||||
if (!me->GetThreatMgr().GetThreatList().empty())
|
||||
{
|
||||
if (!_processingMagmaBurst)
|
||||
{
|
||||
|
||||
@@ -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.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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()))
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user