mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 23:01:30 +00:00
Fix for bots disappearing while idle
This commit is contained in:
parent
5b371ad054
commit
036e4739ae
24
zone/bot.cpp
24
zone/bot.cpp
@ -29,7 +29,7 @@
|
|||||||
extern volatile bool is_zone_loaded;
|
extern volatile bool is_zone_loaded;
|
||||||
|
|
||||||
// This constructor is used during the bot create command
|
// This constructor is used during the bot create command
|
||||||
Bot::Bot(NPCType *npcTypeData, Client* botOwner) : NPC(npcTypeData, nullptr, glm::vec4(), Ground, false), rest_timer(1) {
|
Bot::Bot(NPCType *npcTypeData, Client* botOwner) : NPC(npcTypeData, nullptr, glm::vec4(), Ground, false), rest_timer(1), ping_timer(1) {
|
||||||
if(botOwner) {
|
if(botOwner) {
|
||||||
this->SetBotOwner(botOwner);
|
this->SetBotOwner(botOwner);
|
||||||
this->_botOwnerCharacterID = botOwner->CharacterID();
|
this->_botOwnerCharacterID = botOwner->CharacterID();
|
||||||
@ -80,6 +80,7 @@ Bot::Bot(NPCType *npcTypeData, Client* botOwner) : NPC(npcTypeData, nullptr, glm
|
|||||||
SetShowHelm(true);
|
SetShowHelm(true);
|
||||||
SetPauseAI(false);
|
SetPauseAI(false);
|
||||||
rest_timer.Disable();
|
rest_timer.Disable();
|
||||||
|
ping_timer.Disable();
|
||||||
SetFollowDistance(BOT_FOLLOW_DISTANCE_DEFAULT);
|
SetFollowDistance(BOT_FOLLOW_DISTANCE_DEFAULT);
|
||||||
if (IsCasterClass(GetClass()))
|
if (IsCasterClass(GetClass()))
|
||||||
SetStopMeleeLevel((uint8)RuleI(Bots, CasterStopMeleeLevel));
|
SetStopMeleeLevel((uint8)RuleI(Bots, CasterStopMeleeLevel));
|
||||||
@ -105,7 +106,7 @@ Bot::Bot(NPCType *npcTypeData, Client* botOwner) : NPC(npcTypeData, nullptr, glm
|
|||||||
|
|
||||||
// This constructor is used when the bot is loaded out of the database
|
// This constructor is used when the bot is loaded out of the database
|
||||||
Bot::Bot(uint32 botID, uint32 botOwnerCharacterID, uint32 botSpellsID, double totalPlayTime, uint32 lastZoneId, NPCType *npcTypeData)
|
Bot::Bot(uint32 botID, uint32 botOwnerCharacterID, uint32 botSpellsID, double totalPlayTime, uint32 lastZoneId, NPCType *npcTypeData)
|
||||||
: NPC(npcTypeData, nullptr, glm::vec4(), Ground, false), rest_timer(1)
|
: NPC(npcTypeData, nullptr, glm::vec4(), Ground, false), rest_timer(1), ping_timer(1)
|
||||||
{
|
{
|
||||||
this->_botOwnerCharacterID = botOwnerCharacterID;
|
this->_botOwnerCharacterID = botOwnerCharacterID;
|
||||||
if(this->_botOwnerCharacterID > 0)
|
if(this->_botOwnerCharacterID > 0)
|
||||||
@ -162,6 +163,7 @@ Bot::Bot(uint32 botID, uint32 botOwnerCharacterID, uint32 botSpellsID, double to
|
|||||||
SetPauseAI(false);
|
SetPauseAI(false);
|
||||||
|
|
||||||
rest_timer.Disable();
|
rest_timer.Disable();
|
||||||
|
ping_timer.Disable();
|
||||||
SetFollowDistance(BOT_FOLLOW_DISTANCE_DEFAULT);
|
SetFollowDistance(BOT_FOLLOW_DISTANCE_DEFAULT);
|
||||||
if (IsCasterClass(GetClass()))
|
if (IsCasterClass(GetClass()))
|
||||||
SetStopMeleeLevel((uint8)RuleI(Bots, CasterStopMeleeLevel));
|
SetStopMeleeLevel((uint8)RuleI(Bots, CasterStopMeleeLevel));
|
||||||
@ -2010,6 +2012,9 @@ bool Bot::Process() {
|
|||||||
if (IsStunned() || IsMezzed())
|
if (IsStunned() || IsMezzed())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
if (!IsMoving() && ping_timer.Check())
|
||||||
|
SentPositionPacket(0.0f, 0.0f, 0.0f, 0.0f, 0);
|
||||||
|
|
||||||
// Bot AI
|
// Bot AI
|
||||||
AI_Process();
|
AI_Process();
|
||||||
return true;
|
return true;
|
||||||
@ -3251,6 +3256,7 @@ bool Bot::Spawn(Client* botCharacterOwner) {
|
|||||||
// Load pet
|
// Load pet
|
||||||
LoadPet();
|
LoadPet();
|
||||||
SentPositionPacket(0.0f, 0.0f, 0.0f, 0.0f, 0);
|
SentPositionPacket(0.0f, 0.0f, 0.0f, 0.0f, 0);
|
||||||
|
ping_timer.Start(8000);
|
||||||
// there is something askew with spawn struct appearance fields...
|
// there is something askew with spawn struct appearance fields...
|
||||||
// I re-enabled this until I can sort it out
|
// I re-enabled this until I can sort it out
|
||||||
uint32 itemID = 0;
|
uint32 itemID = 0;
|
||||||
@ -9072,4 +9078,18 @@ std::string Bot::CreateSayLink(Client* c, const char* message, const char* name)
|
|||||||
return saylink;
|
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
|
#endif
|
||||||
|
|||||||
@ -341,6 +341,8 @@ public:
|
|||||||
virtual int GetRunspeed() const { return (int)((float)_GetRunSpeed() * 1.785714f); }
|
virtual int GetRunspeed() const { return (int)((float)_GetRunSpeed() * 1.785714f); }
|
||||||
virtual void WalkTo(float x, float y, float z);
|
virtual void WalkTo(float x, float y, float z);
|
||||||
virtual void RunTo(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);
|
bool UseDiscipline(uint32 spell_id, uint32 target);
|
||||||
uint8 GetNumberNeedingHealedInGroup(uint8 hpr, bool includePets);
|
uint8 GetNumberNeedingHealedInGroup(uint8 hpr, bool includePets);
|
||||||
bool GetNeedsCured(Mob *tar);
|
bool GetNeedsCured(Mob *tar);
|
||||||
@ -731,6 +733,7 @@ private:
|
|||||||
unsigned int RestRegenMana;
|
unsigned int RestRegenMana;
|
||||||
unsigned int RestRegenEndurance;
|
unsigned int RestRegenEndurance;
|
||||||
Timer rest_timer;
|
Timer rest_timer;
|
||||||
|
Timer ping_timer;
|
||||||
int32 base_end;
|
int32 base_end;
|
||||||
int32 cur_end;
|
int32 cur_end;
|
||||||
int32 max_end;
|
int32 max_end;
|
||||||
|
|||||||
@ -589,8 +589,8 @@ public:
|
|||||||
void MakeSpawnUpdateNoDelta(PlayerPositionUpdateServer_Struct* spu);
|
void MakeSpawnUpdateNoDelta(PlayerPositionUpdateServer_Struct* spu);
|
||||||
void MakeSpawnUpdate(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);
|
void SentPositionPacket(float dx, float dy, float dz, float dh, int anim, bool send_to_self = false);
|
||||||
void StopMoving();
|
virtual void StopMoving();
|
||||||
void StopMoving(float new_heading);
|
virtual void StopMoving(float new_heading);
|
||||||
void SetSpawned() { spawned = true; };
|
void SetSpawned() { spawned = true; };
|
||||||
bool Spawned() { return spawned; };
|
bool Spawned() { return spawned; };
|
||||||
virtual bool ShouldISpawnFor(Client *c) { return true; }
|
virtual bool ShouldISpawnFor(Client *c) { return true; }
|
||||||
|
|||||||
@ -1075,6 +1075,9 @@ void Bot::WalkTo(float x, float y, float z)
|
|||||||
if (IsSitting())
|
if (IsSitting())
|
||||||
Stand();
|
Stand();
|
||||||
|
|
||||||
|
if (ping_timer.Enabled())
|
||||||
|
ping_timer.Disable();
|
||||||
|
|
||||||
Mob::WalkTo(x, y, z);
|
Mob::WalkTo(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1083,6 +1086,9 @@ void Bot::RunTo(float x, float y, float z)
|
|||||||
if (IsSitting())
|
if (IsSitting())
|
||||||
Stand();
|
Stand();
|
||||||
|
|
||||||
|
if (ping_timer.Enabled())
|
||||||
|
ping_timer.Disable();
|
||||||
|
|
||||||
Mob::RunTo(x, y, z);
|
Mob::RunTo(x, y, z);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user