diff --git a/zone/bot.cpp b/zone/bot.cpp index f7575c030..4b493d9bd 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -2013,12 +2013,20 @@ bool Bot::Process() { if(GetAppearance() == eaDead && GetHP() > 0) SetAppearance(eaStanding); + if (IsMoving()) { + ping_timer.Disable(); + } + else { + if (!ping_timer.Enabled()) + ping_timer.Start(BOT_KEEP_ALIVE_INTERVAL); + + if (ping_timer.Check()) + SentPositionPacket(0.0f, 0.0f, 0.0f, 0.0f, 0); + } + if (IsStunned() || IsMezzed()) return true; - if (!IsMoving() && ping_timer.Check()) - SentPositionPacket(0.0f, 0.0f, 0.0f, 0.0f, 0); - // Bot AI AI_Process(); return true; @@ -9082,18 +9090,4 @@ std::string Bot::CreateSayLink(Client* c, const char* message, const char* name) return saylink; } -void Bot::StopMoving() { - if (!ping_timer.Enabled()) - ping_timer.Start(8000); - - Mob::StopMoving(); -} - -void Bot::StopMoving(float new_heading) { - if (!ping_timer.Enabled()) - ping_timer.Start(8000); - - Mob::StopMoving(new_heading); -} - #endif diff --git a/zone/bot.h b/zone/bot.h index ed3cf8d92..55a8cba97 100644 --- a/zone/bot.h +++ b/zone/bot.h @@ -44,6 +44,8 @@ #define BOT_LEASH_DISTANCE 250000 // as DSq value (500 units) +#define BOT_KEEP_ALIVE_INTERVAL 5000 // 5 seconds + extern WorldServer worldserver; const int BotAISpellRange = 100; // TODO: Write a method that calcs what the bot's spell range is based on spell, equipment, AA, whatever and replace this @@ -341,8 +343,6 @@ public: virtual int GetRunspeed() const { return (int)((float)_GetRunSpeed() * 1.785714f); } virtual void WalkTo(float x, float y, float z); virtual void RunTo(float x, float y, float z); - virtual void StopMoving(); - virtual void StopMoving(float new_heading); bool UseDiscipline(uint32 spell_id, uint32 target); uint8 GetNumberNeedingHealedInGroup(uint8 hpr, bool includePets); bool GetNeedsCured(Mob *tar); diff --git a/zone/mob.h b/zone/mob.h index 809e7841c..423dbb63e 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -589,8 +589,8 @@ public: void MakeSpawnUpdateNoDelta(PlayerPositionUpdateServer_Struct* spu); void MakeSpawnUpdate(PlayerPositionUpdateServer_Struct* spu); void SentPositionPacket(float dx, float dy, float dz, float dh, int anim, bool send_to_self = false); - virtual void StopMoving(); - virtual void StopMoving(float new_heading); + void StopMoving(); + void StopMoving(float new_heading); void SetSpawned() { spawned = true; }; bool Spawned() { return spawned; }; virtual bool ShouldISpawnFor(Client *c) { return true; } diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index 968300e56..cf79aae08 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -1075,9 +1075,6 @@ void Bot::WalkTo(float x, float y, float z) if (IsSitting()) Stand(); - if (ping_timer.Enabled()) - ping_timer.Disable(); - Mob::WalkTo(x, y, z); } @@ -1086,9 +1083,6 @@ void Bot::RunTo(float x, float y, float z) if (IsSitting()) Stand(); - if (ping_timer.Enabled()) - ping_timer.Disable(); - Mob::RunTo(x, y, z); } #endif