diff options
author | megamage <none@none> | 2009-03-13 17:48:57 -0600 |
---|---|---|
committer | megamage <none@none> | 2009-03-13 17:48:57 -0600 |
commit | ce4c9cb2aeca0000e6ec7cccf5ae0951ad1e1266 (patch) | |
tree | 67b9a31ea40fce6f8c6b2193a584697b018211ae | |
parent | 5f2edfc7e899d7c6997e679f1b9737fb5e7e8d4d (diff) |
*Allow not to switch to charmed AI for some scripts.
--HG--
branch : trunk
-rw-r--r-- | src/game/Creature.cpp | 7 | ||||
-rw-r--r-- | src/game/CreatureAI.cpp | 7 | ||||
-rw-r--r-- | src/game/Unit.cpp | 2 | ||||
-rw-r--r-- | src/game/Unit.h | 2 |
4 files changed, 14 insertions, 4 deletions
diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index df56a3ac27f..8a5e6e52018 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -484,7 +484,12 @@ void Creature::Update(uint32 diff) break; // if creature is charmed, switch to charmed AI - UpdateCharmAI(); + if(NeedChangeAI) + { + UpdateCharmAI(); + NeedChangeAI = false; + IsAIEnabled = true; + } if(!IsInEvadeMode() && IsAIEnabled) { diff --git a/src/game/CreatureAI.cpp b/src/game/CreatureAI.cpp index 2d7eeeb18ff..9d9a3fc3a63 100644 --- a/src/game/CreatureAI.cpp +++ b/src/game/CreatureAI.cpp @@ -63,7 +63,12 @@ void UnitAI::DoMeleeAttackIfReady() void PlayerAI::OnCharmed(bool apply) { me->IsAIEnabled = apply; } //Disable CreatureAI when charmed -void CreatureAI::OnCharmed(bool apply) { /*me->IsAIEnabled = !apply;*/ } +void CreatureAI::OnCharmed(bool apply) +{ + //me->IsAIEnabled = !apply;*/ + me->NeedChangeAI = true; + me->IsAIEnabled = false; +} void CreatureAI::MoveInLineOfSight(Unit *who) { diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 886020459b1..76a2cb264d4 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -151,7 +151,7 @@ bool IsPassiveStackableSpell( uint32 spellId ) Unit::Unit() : WorldObject(), i_motionMaster(this), m_ThreatManager(this), m_HostilRefManager(this) -, m_IsInNotifyList(false), m_Notified(false), IsAIEnabled(false) +, m_IsInNotifyList(false), m_Notified(false), IsAIEnabled(false), NeedChangeAI(false) , i_AI(NULL), i_disabledAI(NULL) { m_objectType |= TYPEMASK_UNIT; diff --git a/src/game/Unit.h b/src/game/Unit.h index d3455d83baa..f980692ef7b 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -1422,7 +1422,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject uint32 GetReducedThreatPercent() { return m_reducedThreatPercent; } Unit *GetMisdirectionTarget() { return m_misdirectionTargetGUID ? GetUnit(*this, m_misdirectionTargetGUID) : NULL; } - bool IsAIEnabled; + bool IsAIEnabled, NeedChangeAI; protected: explicit Unit (); |