diff options
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartAI.cpp | 31 | ||||
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartAI.h | 6 |
2 files changed, 20 insertions, 17 deletions
diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp index 296090a4378..c13fdb87de4 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.cpp +++ b/src/server/game/AI/SmartScripts/SmartAI.cpp @@ -68,6 +68,8 @@ SmartAI::SmartAI(Creature* c) : CreatureAI(c) mFollowArrivedEntry = 0; mFollowCreditType = 0; mInvincibilityHpLevel = 0; + + mJustReset = false; } void SmartAI::UpdateDespawn(const uint32 diff) @@ -88,13 +90,6 @@ void SmartAI::UpdateDespawn(const uint32 diff) } else mDespawnTime -= diff; } -void SmartAI::Reset() -{ - if (!HasEscortState(SMART_ESCORT_ESCORTING))//dont mess up escort movement after combat - SetRun(mRun); - GetScript()->OnReset(); -} - WayPoint* SmartAI::GetNextWayPoint() { if (!mWayPoints || mWayPoints->empty()) @@ -476,7 +471,8 @@ void SmartAI::EnterEvadeMode() else me->GetMotionMaster()->MoveTargetedHome(); - Reset(); + if (!HasEscortState(SMART_ESCORT_ESCORTING))//dont mess up escort movement after combat + SetRun(mRun); } void SmartAI::MoveInLineOfSight(Unit* who) @@ -567,7 +563,8 @@ void SmartAI::JustRespawned() if (me->getFaction() != me->GetCreatureTemplate()->faction_A) me->RestoreFaction(); GetScript()->ProcessEventsFor(SMART_EVENT_RESPAWN); - Reset(); + mJustReset = true; + JustReachedHome(); mFollowGuid = 0;//do not reset follower on Reset(), we need it after combat evade mFollowDist = 0; mFollowAngle = 0; @@ -586,10 +583,17 @@ int SmartAI::Permissible(const Creature* creature) void SmartAI::JustReachedHome() { - GetScript()->ProcessEventsFor(SMART_EVENT_REACHED_HOME); + GetScript()->OnReset(); + + if (!mJustReset) + { + GetScript()->ProcessEventsFor(SMART_EVENT_REACHED_HOME); + + if (!UpdateVictim() && me->GetMotionMaster()->GetCurrentMovementGeneratorType() == IDLE_MOTION_TYPE && me->GetWaypointPath()) + me->ToCreature()->GetMotionMaster()->MovePath(me->GetWaypointPath(), true); + } - if (!UpdateVictim() && me->GetMotionMaster()->GetCurrentMovementGeneratorType() == IDLE_MOTION_TYPE && me->GetWaypointPath()) - me->ToCreature()->GetMotionMaster()->MovePath(me->GetWaypointPath(), true); + mJustReset = false; } void SmartAI::EnterCombat(Unit* enemy) @@ -689,7 +693,8 @@ void SmartAI::InitializeAI() { GetScript()->OnInitialize(me); if (!me->isDead()) - Reset(); + mJustReset = true; + JustReachedHome(); GetScript()->ProcessEventsFor(SMART_EVENT_RESPAWN); } diff --git a/src/server/game/AI/SmartScripts/SmartAI.h b/src/server/game/AI/SmartScripts/SmartAI.h index 92637b17f25..085859a6d85 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.h +++ b/src/server/game/AI/SmartScripts/SmartAI.h @@ -71,10 +71,7 @@ class SmartAI : public CreatureAI // Called when creature is spawned or respawned void JustRespawned(); - // Called after InitializeAI(), EnterEvadeMode() for resetting variables - void Reset(); - - // Called at reaching home after evade + // Called at reaching home after evade, InitializeAI(), EnterEvadeMode() for resetting variables void JustReachedHome(); // Called for reaction at enter to combat if not in combat yet (enemy can be NULL) @@ -232,6 +229,7 @@ class SmartAI : public CreatureAI uint32 mDespawnState; void UpdateDespawn(const uint32 diff); uint32 mEscortInvokerCheckTimer; + bool mJustReset; }; class SmartGameObjectAI : public GameObjectAI |