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

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