Move GetSpellTargetList to only get called when necessary to reduce overhead

This commit is contained in:
nytmyr
2025-02-01 09:11:50 -06:00
parent 498b64fea2
commit 46a1b26529
2 changed files with 21 additions and 16 deletions
+15 -10
View File
@@ -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<Mob*> spell_target_list = GatherSpellTargets(RuleB(Bots, CrossRaidBuffingAndHealing));
SetSpellTargetList(spell_target_list);
std::vector<Mob*> 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<Mob*> Bot::GetSpellTargetList() {
if (_spell_target_list.empty()) {
std::vector<Mob*> spell_target_list = GatherSpellTargets(RuleB(Bots, CrossRaidBuffingAndHealing));
SetSpellTargetList(spell_target_list);
}
return _spell_target_list;
}
+6 -6
View File
@@ -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<Mob*> GetSpellTargetList() { return _spellTargetList; }
void SetSpellTargetList(std::vector<Mob*> spell_target_list) { _spellTargetList = spell_target_list; }
std::vector<Mob*> GetGroupSpellTargetList() { return _groupSpellTargetList; }
void SetGroupSpellTargetList(std::vector<Mob*> spell_target_list) { _groupSpellTargetList = spell_target_list; }
std::vector<Mob*> GetSpellTargetList();
void SetSpellTargetList(std::vector<Mob*> spell_target_list) { _spell_target_list = spell_target_list; }
std::vector<Mob*> GetGroupSpellTargetList() { return _group_spell_target_list; }
void SetGroupSpellTargetList(std::vector<Mob*> spell_target_list) { _group_spell_target_list = spell_target_list; }
std::vector<Mob*> GetBuffTargets(Mob* spellTarget);
// Bot settings
@@ -1215,8 +1215,8 @@ private:
bool _illusionBlock;
std::vector<BotSpellSettings> m_bot_spell_settings;
std::vector<Mob*> _spellTargetList;
std::vector<Mob*> _groupSpellTargetList;
std::vector<Mob*> _spell_target_list;
std::vector<Mob*> _group_spell_target_list;
Raid* _storedRaid;
bool _verifiedRaid;
uint16 _tempSpellType;