diff options
| author | megamage <none@none> | 2009-01-09 12:06:08 -0600 |
|---|---|---|
| committer | megamage <none@none> | 2009-01-09 12:06:08 -0600 |
| commit | 9b8c50bb3b628f28db6eec01f7186916bff75f00 (patch) | |
| tree | 7603503893219d8c9e9e7c1d0b693839aadd98bd /src/bindings/scripts/include | |
| parent | 0f0f38c6d767845ba33d4d5cf533237fe1e575dd (diff) | |
*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
Diffstat (limited to 'src/bindings/scripts/include')
| -rw-r--r-- | src/bindings/scripts/include/sc_creature.cpp | 16 | ||||
| -rw-r--r-- | src/bindings/scripts/include/sc_creature.h | 3 |
2 files changed, 17 insertions, 2 deletions
diff --git a/src/bindings/scripts/include/sc_creature.cpp b/src/bindings/scripts/include/sc_creature.cpp index 20c5600dc02..12992eedc52 100644 --- a/src/bindings/scripts/include/sc_creature.cpp +++ b/src/bindings/scripts/include/sc_creature.cpp @@ -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) diff --git a/src/bindings/scripts/include/sc_creature.h b/src/bindings/scripts/include/sc_creature.h index 9c7ffc022eb..12ec3f0cbf5 100644 --- a/src/bindings/scripts/include/sc_creature.h +++ b/src/bindings/scripts/include/sc_creature.h @@ -144,6 +144,9 @@ struct TRINITY_DLL_DECL ScriptedAI : public CreatureAI //Drops all threat to 0%. Does not remove players from the threat list void DoResetThreat(); + float DoGetThreat(Unit *u); + void DoModifyThreatPercent(Unit *pUnit, int32 pct); + //Teleports a player without dropping threat (only teleports to same map) void DoTeleportPlayer(Unit* pUnit, float x, float y, float z, float o); void DoTeleportAll(float x, float y, float z, float o); |
