mirror of
https://github.com/araxiaonline/TrinityCore.git
synced 2026-06-24 23:49:29 -04:00
*Add script function DoGetThreat and DoModifyThreatPercent and check if !pUnit to prevent crash.
*Note: it is always possible that getVictim() becomes NULL during updateAI! --HG-- branch : trunk
This commit is contained in:
@@ -711,11 +711,23 @@ void ScriptedAI::DoResetThreat()
|
||||
{
|
||||
Unit* pUnit = NULL;
|
||||
pUnit = Unit::GetUnit((*m_creature), (*itr)->getUnitGuid());
|
||||
if(pUnit && m_creature->getThreatManager().getThreat(pUnit))
|
||||
m_creature->getThreatManager().modifyThreatPercent(pUnit, -100);
|
||||
if(pUnit && DoGetThreat(pUnit))
|
||||
DoModifyThreatPercent(pUnit, -100);
|
||||
}
|
||||
}
|
||||
|
||||
float ScriptedAI::DoGetThreat(Unit* pUnit)
|
||||
{
|
||||
if(!pUnit) return 0.0f;
|
||||
return m_creature->getThreatManager().getThreat(pUnit);
|
||||
}
|
||||
|
||||
void ScriptedAI::DoModifyThreatPercent(Unit *pUnit, int32 pct)
|
||||
{
|
||||
if(!pUnit) return;
|
||||
m_creature->getThreatManager().modifyThreatPercent(pUnit, pct);
|
||||
}
|
||||
|
||||
void ScriptedAI::DoTeleportPlayer(Unit* pUnit, float x, float y, float z, float o)
|
||||
{
|
||||
if(!pUnit || pUnit->GetTypeId() != TYPEID_PLAYER)
|
||||
|
||||
Reference in New Issue
Block a user