From 46a1b26529377e9117b9096eb01a2d5f7e76c8ea Mon Sep 17 00:00:00 2001 From: nytmyr <53322305+nytmyr@users.noreply.github.com> Date: Sat, 1 Feb 2025 09:11:50 -0600 Subject: [PATCH] Move GetSpellTargetList to only get called when necessary to reduce overhead --- zone/bot.cpp | 25 +++++++++++++++---------- zone/bot.h | 12 ++++++------ 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/zone/bot.cpp b/zone/bot.cpp index f5726965d..0996ee247 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -114,8 +114,8 @@ Bot::Bot(NPCType *npcTypeData, Client* botOwner) : NPC(npcTypeData, nullptr, glm GenerateBaseStats(); bot_timers.clear(); bot_blocked_buffs.clear(); - _spellTargetList.clear(); - _groupSpellTargetList.clear(); + _spell_target_list.clear(); + _group_spell_target_list.clear(); SetStoredRaid(nullptr); SetVerifiedRaid(false); p_raid_instance = nullptr; @@ -269,8 +269,8 @@ Bot::Bot( database.botdb.LoadBotBlockedBuffs(this); } - _spellTargetList.clear(); - _groupSpellTargetList.clear(); + _spell_target_list.clear(); + _group_spell_target_list.clear(); SetStoredRaid(nullptr); SetVerifiedRaid(false); p_raid_instance = nullptr; @@ -2197,10 +2197,8 @@ void Bot::AI_Process() return; } - std::vector spell_target_list = GatherSpellTargets(RuleB(Bots, CrossRaidBuffingAndHealing)); - SetSpellTargetList(spell_target_list); - std::vector group_spell_target_list = GatherSpellTargets(); - SetGroupSpellTargetList(group_spell_target_list); + _spell_target_list.clear(); + _group_spell_target_list.clear(); SetTempSpellType(UINT16_MAX); // HEAL ROTATION CASTING CHECKS @@ -2216,8 +2214,6 @@ void Bot::AI_Process() //ALT COMBAT (ACQUIRE HATE) glm::vec3 Goal(0, 0, 0); - - // We have aggro to choose from if (IsEngaged()) { if (rest_timer.Enabled()) { @@ -13312,3 +13308,12 @@ bool Bot::IsImmuneToBotSpell(uint16 spell_id, Mob* caster) { return false; } + +std::vector Bot::GetSpellTargetList() { + if (_spell_target_list.empty()) { + std::vector spell_target_list = GatherSpellTargets(RuleB(Bots, CrossRaidBuffingAndHealing)); + SetSpellTargetList(spell_target_list); + } + + return _spell_target_list; +} diff --git a/zone/bot.h b/zone/bot.h index dd84509c8..757818bde 100644 --- a/zone/bot.h +++ b/zone/bot.h @@ -560,10 +560,10 @@ public: // Movement checks bool PlotBotPositionAroundTarget(Mob* target, float& x_dest, float& y_dest, float& z_dest, float min_distance, float max_distance, bool behind_only = false, bool front_only = false, bool bypass_los = false); - std::vector GetSpellTargetList() { return _spellTargetList; } - void SetSpellTargetList(std::vector spell_target_list) { _spellTargetList = spell_target_list; } - std::vector GetGroupSpellTargetList() { return _groupSpellTargetList; } - void SetGroupSpellTargetList(std::vector spell_target_list) { _groupSpellTargetList = spell_target_list; } + std::vector GetSpellTargetList(); + void SetSpellTargetList(std::vector spell_target_list) { _spell_target_list = spell_target_list; } + std::vector GetGroupSpellTargetList() { return _group_spell_target_list; } + void SetGroupSpellTargetList(std::vector spell_target_list) { _group_spell_target_list = spell_target_list; } std::vector GetBuffTargets(Mob* spellTarget); // Bot settings @@ -1215,8 +1215,8 @@ private: bool _illusionBlock; std::vector m_bot_spell_settings; - std::vector _spellTargetList; - std::vector _groupSpellTargetList; + std::vector _spell_target_list; + std::vector _group_spell_target_list; Raid* _storedRaid; bool _verifiedRaid; uint16 _tempSpellType;