From d71dbd17510b3473952538b1d18c7987ef158e77 Mon Sep 17 00:00:00 2001 From: Uleat Date: Thu, 1 Feb 2018 05:38:10 -0500 Subject: [PATCH] Relocated 'stop movement' code into class Mob from class Bot --- zone/bot.cpp | 24 ++++++------------------ zone/bot.h | 4 +--- zone/mob.cpp | 15 +++++++++++++++ zone/mob.h | 2 ++ 4 files changed, 24 insertions(+), 21 deletions(-) diff --git a/zone/bot.cpp b/zone/bot.cpp index 844381336..12de9b936 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -2041,18 +2041,6 @@ void Bot::SetTarget(Mob* mob) { } } -void Bot::ForceMovementEnd() { - FixZ(); - SetCurrentSpeed(0); - if (moved) - moved = false; -} - -void Bot::ForceMovementEnd(float new_heading) { - SetHeading(new_heading); - ForceMovementEnd(); -} - // AI Processing for the Bot object void Bot::AI_Process() { @@ -2135,7 +2123,7 @@ void Bot::AI_Process() { // Can't move if rooted... if (IsRooted() && IsMoving()) { - ForceMovementEnd(); + StopMoving(); return; } @@ -2263,7 +2251,7 @@ void Bot::AI_Process() { SetTarget(nullptr); if (IsMoving()) - ForceMovementEnd(); + StopMoving(); return; } @@ -2418,7 +2406,7 @@ void Bot::AI_Process() { // We can fight if (atCombatRange) { if (IsMoving()) { - ForceMovementEnd(CalculateHeadingToTarget(tar->GetX(), tar->GetY())); + StopMoving(CalculateHeadingToTarget(tar->GetX(), tar->GetY())); return; } @@ -2644,7 +2632,7 @@ void Bot::AI_Process() { } else { if (IsMoving()) - ForceMovementEnd(); + StopMoving(); else SendPosition(); @@ -2698,7 +2686,7 @@ void Bot::AI_Process() { // Leash the bot if (lo_distance > BOT_LEASH_DISTANCE) { if (IsMoving()) - ForceMovementEnd(); + StopMoving(); Warp(glm::vec3(leash_owner->GetPosition())); @@ -2754,7 +2742,7 @@ void Bot::AI_Process() { } else { if (IsMoving()) { - ForceMovementEnd(); + StopMoving(); return; } } diff --git a/zone/bot.h b/zone/bot.h index baee2f0b4..d945c13be 100644 --- a/zone/bot.h +++ b/zone/bot.h @@ -405,9 +405,7 @@ public: bool AIHealRotation(Mob* tar, bool useFastHeals); bool GetPauseAI() { return _pauseAI; } void SetPauseAI(bool pause_flag) { _pauseAI = pause_flag; } - void ForceMovementEnd(); - void ForceMovementEnd(float new_heading); - + // Mob AI Virtual Override Methods virtual void AI_Process(); virtual void AI_Stop(); diff --git a/zone/mob.cpp b/zone/mob.cpp index 9239e5a14..9efdda70c 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -1437,6 +1437,21 @@ void Mob::SendHPUpdate(bool skip_self /*= false*/, bool force_update_all /*= fal } } +void Mob::StopMoving() { + FixZ(); + SetCurrentSpeed(0); + if (moved) + moved = false; +} + +void Mob::StopMoving(float new_heading) { + SetHeading(new_heading); + FixZ(); + SetCurrentSpeed(0); + if (moved) + moved = false; +} + /* Used for mobs standing still - this does not send a delta */ void Mob::SendPosition() { auto app = new EQApplicationPacket(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct)); diff --git a/zone/mob.h b/zone/mob.h index a06485659..6266aa029 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -569,6 +569,8 @@ public: void MakeSpawnUpdateNoDelta(PlayerPositionUpdateServer_Struct* spu); void MakeSpawnUpdate(PlayerPositionUpdateServer_Struct* spu); void SendPosition(); + void StopMoving(); + void StopMoving(float new_heading); void SetSpawned() { spawned = true; }; bool Spawned() { return spawned; }; virtual bool ShouldISpawnFor(Client *c) { return true; }