*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:
megamage
2009-01-09 12:06:08 -06:00
parent 0f0f38c6d7
commit 9b8c50bb3b
27 changed files with 73 additions and 58 deletions
+14 -2
View File
@@ -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)