diff options
author | Discover- <amort11@hotmail.com> | 2013-12-17 10:12:23 +0100 |
---|---|---|
committer | Discover- <amort11@hotmail.com> | 2013-12-17 10:12:23 +0100 |
commit | 20a22662df5442ba9b171f2cde22be50ed75bdc3 (patch) | |
tree | a77a2c4bdac99d23ce992e9805b3d4fb9f0c4ff7 /src | |
parent | 54b7162f1def59387ecf3c031705f56fa1b10b02 (diff) |
Core/SAI: Using SMART_ACTION_SET_FOLLOW with target_type 0 (SMART_TARGET_NONE) will now stop the following completely. Fixes 6 scripts in a clean TDB already using this functionality even though it wasn't implemented.
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartAI.cpp | 48 | ||||
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartAI.h | 1 | ||||
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartScript.cpp | 3 |
3 files changed, 33 insertions, 19 deletions
diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp index 1c78b97866f..1ced9e79672 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.cpp +++ b/src/server/game/AI/SmartScripts/SmartAI.cpp @@ -339,27 +339,10 @@ void SmartAI::UpdateAI(uint32 diff) { if (me->FindNearestCreature(mFollowArrivedEntry, INTERACTION_DISTANCE, true)) { - if (Player* player = ObjectAccessor::GetPlayer(*me, mFollowGuid)) - { - if (!mFollowCreditType) - player->RewardPlayerAndGroupAtEvent(mFollowCredit, me); - else - player->GroupEventHappens(mFollowCredit, me); - } - mFollowGuid = 0; - mFollowDist = 0; - mFollowAngle = 0; - mFollowCredit = 0; - mFollowArrivedTimer = 1000; - mFollowArrivedEntry = 0; - mFollowCreditType = 0; - SetDespawnTime(5000); - me->StopMoving(); - me->GetMotionMaster()->MoveIdle(); - StartDespawn(); - GetScript()->ProcessEventsFor(SMART_EVENT_FOLLOW_COMPLETED); + StopFollow(); return; } + mFollowArrivedTimer = 1000; } else @@ -803,7 +786,11 @@ void SmartAI::SetCombatMove(bool on) void SmartAI::SetFollow(Unit* target, float dist, float angle, uint32 credit, uint32 end, uint32 creditType) { if (!target) + { + StopFollow(); return; + } + SetRun(mRun); mFollowGuid = target->GetGUID(); mFollowDist = dist >= 0.0f ? dist : PET_FOLLOW_DIST; @@ -815,6 +802,29 @@ void SmartAI::SetFollow(Unit* target, float dist, float angle, uint32 credit, ui mFollowCreditType = creditType; } +void SmartAI::StopFollow() +{ + if (Player* player = ObjectAccessor::GetPlayer(*me, mFollowGuid)) + { + if (!mFollowCreditType) + player->RewardPlayerAndGroupAtEvent(mFollowCredit, me); + else + player->GroupEventHappens(mFollowCredit, me); + } + + mFollowGuid = 0; + mFollowDist = 0; + mFollowAngle = 0; + mFollowCredit = 0; + mFollowArrivedTimer = 1000; + mFollowArrivedEntry = 0; + mFollowCreditType = 0; + SetDespawnTime(5000); + me->StopMoving(); + me->GetMotionMaster()->MoveIdle(); + StartDespawn(); + GetScript()->ProcessEventsFor(SMART_EVENT_FOLLOW_COMPLETED); +} void SmartAI::SetScript9(SmartScriptHolder& e, uint32 entry, Unit* invoker) { if (invoker) diff --git a/src/server/game/AI/SmartScripts/SmartAI.h b/src/server/game/AI/SmartScripts/SmartAI.h index 085859a6d85..5c56736a673 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.h +++ b/src/server/game/AI/SmartScripts/SmartAI.h @@ -63,6 +63,7 @@ class SmartAI : public CreatureAI void SetCombatMove(bool on); bool CanCombatMove() { return mCanCombatMove; } void SetFollow(Unit* target, float dist = 0.0f, float angle = 0.0f, uint32 credit = 0, uint32 end = 0, uint32 creditType = 0); + void StopFollow(); void SetScript9(SmartScriptHolder& e, uint32 entry, Unit* invoker); SmartScript* GetScript() { return &mScript; } diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 164ace2eb44..50434649125 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -825,7 +825,10 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u ObjectList* targets = GetTargets(e, unit); if (!targets) + { + CAST_AI(SmartAI, me->AI())->StopFollow(); break; + } for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) { |