From bd6e06aadb84623d1207900dee82549c965405dd Mon Sep 17 00:00:00 2001 From: Uleat Date: Fri, 13 Dec 2019 16:50:42 -0500 Subject: [PATCH] Few tweaks to bot ai --- zone/bot.cpp | 22 ++++++++++++++++------ zone/bot.h | 1 + zone/bot_command.cpp | 2 +- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/zone/bot.cpp b/zone/bot.cpp index f80f91c6f..4322f150f 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -83,6 +83,7 @@ Bot::Bot(NPCType *npcTypeData, Client* botOwner) : NPC(npcTypeData, nullptr, glm SetPauseAI(false); m_alt_combat_hate_timer.Start(250); + m_auto_defend_timer.Disable(); //m_combat_jitter_timer.Disable(); //SetCombatJitterFlag(false); SetGuardFlag(false); @@ -180,6 +181,7 @@ Bot::Bot(uint32 botID, uint32 botOwnerCharacterID, uint32 botSpellsID, double to SetPauseAI(false); m_alt_combat_hate_timer.Start(250); + m_auto_defend_timer.Disable(); //m_combat_jitter_timer.Disable(); //SetCombatJitterFlag(false); SetGuardFlag(false); @@ -2462,7 +2464,7 @@ constexpr float MAX_CASTER_DISTANCE[PLAYER_CLASS_COUNT] = { // W C P R S D M B R S N W M E B B // A L A N H R N R O H E I A N S E // R R L G D U K D G M C Z G C T R - }; +}; void Bot::AI_Process() { @@ -2861,14 +2863,14 @@ void Bot::AI_Process() if (find_target) { if (IsRooted()) { - SetTarget(hate_list.GetClosestEntOnHateList(this)); + SetTarget(hate_list.GetClosestEntOnHateList(this, true)); } else { // This will keep bots on target for now..but, future updates will allow for rooting/stunning SetTarget(hate_list.GetEscapingEntOnHateList(leash_owner, leash_distance)); if (!GetTarget()) { - SetTarget(hate_list.GetEntWithMostHateOnList(this)); + SetTarget(hate_list.GetEntWithMostHateOnList(this, nullptr, true)); } } } @@ -3550,9 +3552,15 @@ void Bot::AI_Process() // This is as close as I could get without modifying the aggro mechanics and making it an expensive process... // 'class Client' doesn't make use of hate_list... - if (bot_owner->GetAggroCount() && bot_owner->GetBotOption(Client::booAutoDefend)) { + if (RuleB(Bots, AllowOwnerOptionAutoDefend) && bot_owner->GetBotOption(Client::booAutoDefend)) { - if (RuleB(Bots, AllowOwnerOptionAutoDefend)) { + if (!m_auto_defend_timer.Enabled()) { + + m_auto_defend_timer.Start(zone->random.Int(250, 1250)); // random timer to simulate 'awareness' (cuts down on scanning overhead) + return; + } + + if (m_auto_defend_timer.Check() && bot_owner->GetAggroCount()) { if (NOT_HOLDING && NOT_PASSIVE) { @@ -3570,7 +3578,7 @@ void Bot::AI_Process() } auto hater = entity_list.GetMob(hater_iter.spawn_id); - if (hater && DistanceSquared(hater->GetPosition(), bot_owner->GetPosition()) <= leash_distance) { + if (hater && !hater->IsMezzed() && DistanceSquared(hater->GetPosition(), bot_owner->GetPosition()) <= leash_distance) { // This is roughly equivilent to npc attacking a client pet owner AddToHateList(hater, 1); @@ -3582,6 +3590,8 @@ void Bot::AI_Process() GetPet()->SetTarget(hater); } + m_auto_defend_timer.Disable(); + return; } } diff --git a/zone/bot.h b/zone/bot.h index 3ee85d57f..97bb6892c 100644 --- a/zone/bot.h +++ b/zone/bot.h @@ -693,6 +693,7 @@ private: Timer m_evade_timer; // can be moved to pTimers at some point Timer m_alt_combat_hate_timer; + Timer m_auto_defend_timer; //Timer m_combat_jitter_timer; //bool m_combat_jitter_flag; bool m_guard_flag; diff --git a/zone/bot_command.cpp b/zone/bot_command.cpp index c60aa7810..baa4818ac 100644 --- a/zone/bot_command.cpp +++ b/zone/bot_command.cpp @@ -5758,7 +5758,7 @@ void bot_subcommand_bot_list(Client *c, const Seperator *sep) } Bot * botCheckNotOnline = entity_list.GetBotByBotName(bots_iter.Name); std::string botspawn_saylink = StringFormat("^botspawn %s", bots_iter.Name); - c->Message(Chat::White, "%s is a level %u %s %s %s who is owned by %s", + c->Message(Chat::White, "[%s] is a level %u %s %s %s who is owned by %s", ((c->CharacterID() == bots_iter.Owner_ID) && (!botCheckNotOnline) ? (EQEmu::SayLinkEngine::GenerateQuestSaylink(botspawn_saylink, false, bots_iter.Name).c_str()) : (bots_iter.Name)), bots_iter.Level, Bot::RaceIdToString(bots_iter.Race).c_str(),