mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-19 12:48:20 +00:00
Remove Bot_AICheckCloseBeneficialSpells and use AttemptCloseBeneficialSpells for better performance
This commit is contained in:
+42
-62
@@ -7205,72 +7205,47 @@ bool Bot::CheckLoreConflict(const EQ::ItemData* item) {
|
|||||||
return (m_inv.HasItemByLoreGroup(item->LoreGroup, invWhereWorn) != INVALID_INDEX);
|
return (m_inv.HasItemByLoreGroup(item->LoreGroup, invWhereWorn) != INVALID_INDEX);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EntityList::Bot_AICheckCloseBeneficialSpells(Bot* caster, uint8 iChance, uint16 spellType) {
|
bool Bot::AttemptCloseBeneficialSpells(uint16 spellType, Raid* raid, std::vector<Mob*> targetList) {
|
||||||
|
bool result = false;
|
||||||
if (IsBotSpellTypeDetrimental(spellType, caster->GetClass())) {
|
|
||||||
LogError("[EntityList::Bot_AICheckCloseBeneficialSpells] detrimental spells requested");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<Mob*> v;
|
|
||||||
|
|
||||||
if (IsGroupTargetOnlyBotSpellType(spellType)) {
|
|
||||||
v = caster->GatherGroupSpellTargets();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (RuleB(Bots, CrossRaidBuffingAndHealing)) {
|
|
||||||
v = caster->GatherSpellTargets(true);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
v = caster->GatherGroupSpellTargets();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Mob* tar = nullptr;
|
Mob* tar = nullptr;
|
||||||
|
|
||||||
for (Mob* m : v) {
|
for (Mob* m : targetList) {
|
||||||
tar = m;
|
tar = m;
|
||||||
|
|
||||||
if (!tar) {
|
if (!tar) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (caster == tar) {
|
if (IsGroupTargetOnlyBotSpellType(spellType)) {
|
||||||
continue;
|
if (raid && (raid->GetGroup(GetName()) == raid->GetGroup(tar->GetName()))) {
|
||||||
}
|
|
||||||
|
|
||||||
uint8 chanceToCast = caster->IsEngaged() ? caster->GetChanceToCastBySpellType(spellType) : 100;
|
|
||||||
|
|
||||||
if (!caster->PrecastChecks(tar, spellType)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (caster->AICastSpell(tar, chanceToCast, spellType)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tar->HasPet() && (!m->GetPet()->IsFamiliar() || RuleB(Bots, AllowBuffingHealingFamiliars))) {
|
|
||||||
tar = m->GetPet();
|
|
||||||
|
|
||||||
if (!tar) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!tar->IsOfClientBot() && !(tar->IsPet() && tar->GetOwner() && tar->GetOwner()->IsOfClientBot())) {
|
result = AttemptAICastSpell(spellType, tar);
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!caster->PrecastChecks(tar, spellType)) {
|
if (!result) {
|
||||||
continue;
|
if (tar->HasPet() && (!m->GetPet()->IsFamiliar() || RuleB(Bots, AllowBuffingHealingFamiliars))) {
|
||||||
}
|
tar = m->GetPet();
|
||||||
|
|
||||||
if (caster->AICastSpell(tar, chanceToCast, spellType)) {
|
if (!tar) {
|
||||||
return true;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!tar->IsOfClientBot() && !(tar->IsPet() && tar->GetOwner() && tar->GetOwner()->IsOfClientBot())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = AttemptAICastSpell(spellType, tar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (result) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Mob* EntityList::GetMobByBotID(uint32 botID) {
|
Mob* EntityList::GetMobByBotID(uint32 botID) {
|
||||||
@@ -10835,31 +10810,36 @@ std::list<BotSpellTypeOrder> Bot::GetSpellTypesPrioritized(uint8 priorityType) {
|
|||||||
return castOrder;
|
return castOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Bot::AttemptAICastSpell(uint16 spellType) {
|
bool Bot::AttemptAICastSpell(uint16 spellType, Mob* tar) {
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
Mob* tar = GetTarget();
|
if (!tar) {
|
||||||
|
if (GetTarget()) {
|
||||||
|
tar = GetTarget();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (!IsBotSpellTypeBeneficial(spellType)) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!IsTaunting() && !IsCommandedSpell() && GetSpellTypeAggroCheck(spellType) && HasOrMayGetAggro(IsSitting())) {
|
if (!IsTaunting() && !IsCommandedSpell() && GetSpellTypeAggroCheck(spellType) && HasOrMayGetAggro(IsSitting())) {
|
||||||
LogBotPreChecksDetail("{} says, 'Cancelling cast of [{}] due to GetSpellTypeAggroCheck and HasOrMayGetAggro.'", GetCleanName(), GetSpellTypeNameByID(spellType)); //deleteme
|
LogBotPreChecksDetail("{} says, 'Cancelling cast of [{}] due to GetSpellTypeAggroCheck and HasOrMayGetAggro.'", GetCleanName(), GetSpellTypeNameByID(spellType)); //deleteme
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsBotSpellTypeBeneficial(spellType, GetClass())) {
|
if (IsBotSpellTypeBeneficial(spellType)) {
|
||||||
if (!PrecastChecks(this, spellType) || !AICastSpell(this, GetChanceToCastBySpellType(spellType), spellType)) {
|
if (GetClass() == Class::Bard) {
|
||||||
if (GetClass() == Class::Bard) {
|
tar = this;
|
||||||
return result;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!tar || !PrecastChecks(tar, spellType) || !AICastSpell(tar, GetChanceToCastBySpellType(spellType), spellType)) {
|
if (!PrecastChecks(tar, spellType) || !AICastSpell(tar, GetChanceToCastBySpellType(spellType), spellType)) {
|
||||||
if (!entity_list.Bot_AICheckCloseBeneficialSpells(this, GetChanceToCastBySpellType(spellType), spellType)) {
|
return result;
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!tar || !PrecastChecks(tar, spellType) || !AICastSpell(tar, GetChanceToCastBySpellType(spellType), spellType)) {
|
if (!PrecastChecks(tar, spellType) || !AICastSpell(tar, GetChanceToCastBySpellType(spellType), spellType)) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -398,9 +398,10 @@ public:
|
|||||||
|
|
||||||
// AI Methods
|
// AI Methods
|
||||||
bool AICastSpell(Mob* tar, uint8 iChance, uint16 spellType, uint16 subTargetType = UINT16_MAX, uint16 subType = UINT16_MAX);
|
bool AICastSpell(Mob* tar, uint8 iChance, uint16 spellType, uint16 subTargetType = UINT16_MAX, uint16 subType = UINT16_MAX);
|
||||||
bool AttemptAICastSpell(uint16 spellType);
|
bool AttemptAICastSpell(uint16 spellType, Mob* tar = nullptr);
|
||||||
bool AttemptAACastSpell(Mob* tar, uint16 spell_id, AA::Rank* rank);
|
bool AttemptAACastSpell(Mob* tar, uint16 spell_id, AA::Rank* rank);
|
||||||
bool AttemptForcedCastSpell(Mob* tar, uint16 spell_id);
|
bool AttemptForcedCastSpell(Mob* tar, uint16 spell_id);
|
||||||
|
bool AttemptCloseBeneficialSpells(uint16 spellType, Raid* raid, std::vector<Mob*> targetList);
|
||||||
bool AI_EngagedCastCheck() override;
|
bool AI_EngagedCastCheck() override;
|
||||||
bool AI_PursueCastCheck() override;
|
bool AI_PursueCastCheck() override;
|
||||||
bool AI_IdleCastCheck() override;
|
bool AI_IdleCastCheck() override;
|
||||||
|
|||||||
@@ -633,6 +633,9 @@ bool Bot::AI_PursueCastCheck() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto castOrder = GetSpellTypesPrioritized(BotPriorityCategories::Pursue);
|
auto castOrder = GetSpellTypesPrioritized(BotPriorityCategories::Pursue);
|
||||||
|
Mob* tar = nullptr;
|
||||||
|
Raid* raid = GetRaid();
|
||||||
|
std::vector<Mob*> v = GatherSpellTargets(RuleB(Bots, CrossRaidBuffingAndHealing));
|
||||||
|
|
||||||
for (auto& currentCast : castOrder) {
|
for (auto& currentCast : castOrder) {
|
||||||
if (currentCast.priority == 0) {
|
if (currentCast.priority == 0) {
|
||||||
@@ -650,6 +653,10 @@ bool Bot::AI_PursueCastCheck() {
|
|||||||
|
|
||||||
result = AttemptAICastSpell(currentCast.spellType);
|
result = AttemptAICastSpell(currentCast.spellType);
|
||||||
|
|
||||||
|
if (!result && IsBotSpellTypeBeneficial(currentCast.spellType)) {
|
||||||
|
result = AttemptCloseBeneficialSpells(currentCast.spellType, raid, v);
|
||||||
|
}
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -692,6 +699,9 @@ bool Bot::AI_IdleCastCheck() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto castOrder = GetSpellTypesPrioritized(BotPriorityCategories::Idle);
|
auto castOrder = GetSpellTypesPrioritized(BotPriorityCategories::Idle);
|
||||||
|
Mob* tar = nullptr;
|
||||||
|
Raid* raid = GetRaid();
|
||||||
|
std::vector<Mob*> v = GatherSpellTargets(RuleB(Bots, CrossRaidBuffingAndHealing));
|
||||||
|
|
||||||
for (auto& currentCast : castOrder) {
|
for (auto& currentCast : castOrder) {
|
||||||
if (currentCast.priority == 0) {
|
if (currentCast.priority == 0) {
|
||||||
@@ -711,11 +721,21 @@ bool Bot::AI_IdleCastCheck() {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!IsBotSpellTypeBeneficial(currentCast.spellType)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
result = AttemptAICastSpell(currentCast.spellType);
|
result = AttemptAICastSpell(currentCast.spellType);
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result = AttemptCloseBeneficialSpells(currentCast.spellType, raid, v);
|
||||||
|
|
||||||
|
if (result) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!AIautocastspell_timer->Enabled()) {
|
if (!AIautocastspell_timer->Enabled()) {
|
||||||
@@ -746,6 +766,9 @@ bool Bot::AI_EngagedCastCheck() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto castOrder = GetSpellTypesPrioritized(BotPriorityCategories::Engaged);
|
auto castOrder = GetSpellTypesPrioritized(BotPriorityCategories::Engaged);
|
||||||
|
Mob* tar = nullptr;
|
||||||
|
Raid* raid = GetRaid();
|
||||||
|
std::vector<Mob*> v = GatherSpellTargets(RuleB(Bots, CrossRaidBuffingAndHealing));
|
||||||
|
|
||||||
for (auto& currentCast : castOrder) {
|
for (auto& currentCast : castOrder) {
|
||||||
if (currentCast.priority == 0) {
|
if (currentCast.priority == 0) {
|
||||||
@@ -763,6 +786,10 @@ bool Bot::AI_EngagedCastCheck() {
|
|||||||
|
|
||||||
result = AttemptAICastSpell(currentCast.spellType);
|
result = AttemptAICastSpell(currentCast.spellType);
|
||||||
|
|
||||||
|
if (!result && IsBotSpellTypeBeneficial(currentCast.spellType)) {
|
||||||
|
result = AttemptCloseBeneficialSpells(currentCast.spellType, raid, v);
|
||||||
|
}
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -628,7 +628,6 @@ private:
|
|||||||
Client* GetBotOwnerByBotID(const uint32 bot_id);
|
Client* GetBotOwnerByBotID(const uint32 bot_id);
|
||||||
std::list<Bot*> GetBotsByBotOwnerCharacterID(uint32 botOwnerCharacterID);
|
std::list<Bot*> GetBotsByBotOwnerCharacterID(uint32 botOwnerCharacterID);
|
||||||
|
|
||||||
bool Bot_AICheckCloseBeneficialSpells(Bot* caster, uint8 iChance, uint16 spellType); // TODO: Evaluate this closesly in hopes to eliminate
|
|
||||||
void ShowSpawnWindow(Client* client, int Distance, bool NamedOnly); // TODO: Implement ShowSpawnWindow in the bot class but it needs entity list stuff
|
void ShowSpawnWindow(Client* client, int Distance, bool NamedOnly); // TODO: Implement ShowSpawnWindow in the bot class but it needs entity list stuff
|
||||||
|
|
||||||
void ScanCloseClientMobs(std::unordered_map<uint16, Mob*>& close_mobs, Mob* scanning_mob);
|
void ScanCloseClientMobs(std::unordered_map<uint16, Mob*>& close_mobs, Mob* scanning_mob);
|
||||||
|
|||||||
Reference in New Issue
Block a user