Implement AIBot_spells_by_type to reduce looping when searching for spells

This commit is contained in:
nytmyr
2024-12-22 22:38:52 -06:00
parent 998f34842b
commit 83d41f00d2
4 changed files with 103 additions and 37 deletions
+44 -2
View File
@@ -6061,7 +6061,6 @@ bool Bot::DoFinishedSpellSingleTarget(uint16 spell_id, Mob* spellTarget, EQ::spe
bool Bot::DoFinishedSpellGroupTarget(uint16 spell_id, Mob* spellTarget, EQ::spells::CastingSlot slot, bool& stopLogic) {
bool isMainGroupMGB = false;
Raid* raid = GetStoredRaid();
if (isMainGroupMGB && (GetClass() != Class::Bard)) {
BotGroupSay(
@@ -9718,7 +9717,7 @@ bool Bot::BotHasEnoughMana(uint16 spell_id) {
return true;
}
bool Bot::IsTargetAlreadyReceivingSpell(Mob* tar, uint16 spell_id) { //TODO bot rewrite - add raid and spell targets
bool Bot::IsTargetAlreadyReceivingSpell(Mob* tar, uint16 spell_id) {
if (!tar || !spell_id) {
return true;
}
@@ -11971,3 +11970,46 @@ void Bot::CleanBotBlockedBuffs()
}
}
}
std::vector<BotSpells_Struct_wIndex> Bot::BotGetSpellsByType(uint16 spellType) {
if (!AIBot_spells_by_type[spellType].empty()) {
return AIBot_spells_by_type[spellType];
}
else {
spellType = GetParentSpellType(spellType);
return AIBot_spells_by_type[spellType];
}
}
void Bot::AssignBotSpellsToTypes(std::vector<BotSpells_Struct>& AIBot_spells, std::unordered_map<uint16, std::vector<BotSpells_Struct_wIndex>>& AIBot_spells_by_type) {
AIBot_spells_by_type.clear();
for (size_t i = 0; i < AIBot_spells.size(); ++i) {
const auto& spell = AIBot_spells[i];
if (spell.spellid <= 0) {
continue;
}
BotSpells_Struct_wIndex spellWithIndex{
static_cast<uint32>(i),
spell.type,
spell.spellid,
spell.manacost,
spell.time_cancast,
spell.recast_delay,
spell.priority,
spell.resist_adjust,
spell.minlevel,
spell.maxlevel,
spell.min_hp,
spell.max_hp,
spell.bucket_name,
spell.bucket_value,
spell.bucket_comparison
};
AIBot_spells_by_type[spell.type].emplace_back(spellWithIndex);
}
}