aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game/Creature.cpp7
-rw-r--r--src/game/CreatureAI.cpp7
-rw-r--r--src/game/Unit.cpp2
-rw-r--r--src/game/Unit.h2
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 ();