mod-playerbots/src/Bot/Factory/AiFactory.cpp
Crow 3a7e3e2719
Fix Mages' Armor Strategies & Light Refactor (#2390)
<!--
Thank you for contributing to mod-playerbots, please make sure that
you...
1. Submit your PR to the test-staging branch, not master.
2. Read the guidelines below before submitting.
3. Don't delete parts of this template.

DESIGN PHILOSOPHY: We prioritize STABILITY, PERFORMANCE, AND
PREDICTABILITY over behavioral realism.

Every action and decision executes PER BOT AND PER TRIGGER. Small
increases in logic complexity scale
poorly across thousands of bots and negatively affect all. We prioritize
a stable system over a smarter
one. Bots don't need to behave perfectly; believable behavior is the
goal, not human simulation.
Default behavior must be cheap in processing; expensive behavior must be
opt-in.

Before submitting, make sure your changes aligns with these principles.
-->

## Pull Request Description
<!-- Describe what this change does and why it is needed -->
Mages have a "bdps" strategy to use Molten Armor (default for Fire and
Arcane) and "bmana" strategy to use Mage Armor (default for Frost). The
existing code uses a series of alternatives for armor
(Molten->Mage->Ice->Frost), which is needed for Mages that have not
learned Molten or Mage. However, I was noticing that sometimes my Fire
and Arcane Mages would end up with Mage Armor, presumably because there
could be a situation in which the casting of Molten Armor failed and the
fallback to Mage Armor kicked in (for example, due to there being not
enough mana to cast Molten Armor). This PR makes bdps always mean Molten
Armor, if it is learned, and bmana always mean Mage Armor, if it is
learned, by gating through triggers.

Other changes:

- Added bdps and bmana to default Mage combat strategies (still bdps for
Fire and Arcane and bmana for Frost) so that Mages will reapply armor if
it expires in combat.
- Deleted Arcane Explosion strategy--it was not fully implemented
because there was no associated action (such as through a
CastArcaneExplosionAction class). I debated implementing it, but there
isn't a suitable targeting mechanism that exists in the code from what I
can tell. Arcane Mages generally just use Blizzard for AoE (and
Flamestrike with PoM); Arcane Explosion is useful to use if (1) a player
is moving or (2) mobs are almost dead in an AoE situation. Scenario (1)
is irrelevant for bots since they cannot cast while moving. With respect
to scenario (2), the existing AoE triggers in fact look for highest HP
mobs so to implement Arcane Explosion in a useful manner would probably
require a new Value, and that is not worth it for what would be
miniscule benefit anyway.
- General cleanups of Mage code (e.g., deleted empty ActionNodes). These
were based on a quick review; I did not do any sort of detailed or
comprehensive review and have no desire to with this PR. Note: I know
that FrostMageStrategy.cpp had a Fireball alternative for Frostfire
Bolt, but I deleted it anyway because the same ActionNode is already in
GenericMageStrategy.cpp.
- General cleanups of AiFactory default combat/noncombat strategies
(e.g., removal of deprecated bdps and bmana strategies for Shamans).


## Feature Evaluation
<!--
If your PR is very minimal (comment typo, wrong ID reference, etc), and
it is very obvious it will not have
any impact on performance, you may skip these question. If necessary, a
maintainer may ask you for them later.
-->

<!-- Please answer the following: -->
- Describe the **minimum logic** required to achieve the intended
behavior.
- Describe the **processing cost** when this logic executes across many
bots.

Added getAlternatives for the armor strategies; this approach already
exists for Druids. Added one new trigger for Molten Armor that is
throttled by 10s like the existing Mage Armor trigger.

## How to Test the Changes
<!--
- Step-by-step instructions to test the change.
- Any required setup (e.g. multiple players, number of bots, specific
configuration).
- Expected behavior and how to verify it.
-->
Give a Mage the "bdps" strategy. They should cast Molten Armor. Make
them cast a different armor. After the trigger throttle period (10s),
they should reapply Molten Armor. Same goes for bmana and Mage Armor.
Try this in combat, and it should work too.


## Impact Assessment
<!-- As a generic test, before and after measure of pmon (playerbot pmon
tick) can help you here. -->
- Does this change increase per-bot/per-tick processing or risk scaling
poorly with thousands of bots?
    - - [x] No, not at all
    - - [ ] Minimal impact (**explain below**)
    - - [ ] Moderate impact (**explain below**)



- Does this change modify default bot behavior?
    - - [ ] No
    - - [x] Yes (**explain why**)

The point of this PR is to fix the default Mage armor buffing behavior.


- Does this change add new decision branches or increase maintenance
complexity?
    - - [x] No
    - - [ ] Yes (**explain below**)



## AI Assistance
<!--
AI assistance is allowed, but all submitted code must be fully
understood, reviewed, and owned by the contributor.
We expect contributors to be honest about what they do and do not
understand.
-->
Was AI assistance used while working on this change?
- - [ ] No
- - [x] Yes (**explain below**)
<!--
If yes, please specify:
- Purpose of usage (e.g. brainstorming, refactoring, documentation, code
generation).
- Which parts of the change were influenced or generated, and whether it
was thoroughly reviewed.
-->
I had GPT-5.4 present a couple of possibilities to fix the issue of Mage
Armor being cast with bdps, and from there I settled on the
getAlternatives approach. I did everything else.


<!--
TRANSLATIONS:
Anything new that the bots say in chat must be in a translatable format.
This is done using GetBotTextOrDefault,
which you can search for in the codebase to find examples. Your code
needs to have English as the default fallback,
while the full translations need to be in an SQL update file. The
languages in the file are the nine language
options supported by AzerothCore: English, Korean, French, German,
Chinese, Taiwanese, Spanish, Spanish Mexico, and
Russian. See
data/sql/playerbots/updates/2025_12_27_ai_playerbot_fishing_text.sql as
an example of a translation SQL
update, whose content are called within the codebase at
src/strategy/actions/FishingAction.cpp
-->

## Final Checklist

- - [x] Stability is not compromised.
- - [x] Performance impact is understood, tested, and acceptable.
- - [x] Added logic complexity is justified and explained.
- - [x] Any new bot dialogue lines are translated.
- - [x] Documentation updated if needed (Conf comments, WiKi commands).

## Notes for Reviewers
<!-- Anything else that's helpful to review or test your pull request.
-->
@Dreathean Perhaps the wiki can be updated to document the bdps and
bmana strategies for Mages?
2026-05-22 19:25:48 -07:00

729 lines
27 KiB
C++

/*
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license, you may redistribute it
* and/or modify it under version 3 of the License, or (at your option), any later version.
*/
#include "AiFactory.h"
#include "BattlegroundMgr.h"
#include "DKAiObjectContext.h"
#include "DruidAiObjectContext.h"
#include "Engine.h"
#include "Group.h"
#include "HunterAiObjectContext.h"
#include "Item.h"
#include "MageAiObjectContext.h"
#include "PaladinAiObjectContext.h"
#include "PlayerbotAI.h"
#include "PlayerbotAIConfig.h"
#include "Playerbots.h"
#include "PriestAiObjectContext.h"
#include "RogueAiObjectContext.h"
#include "ShamanAiObjectContext.h"
#include "SharedDefines.h"
#include "SpellInfo.h"
#include "SpellMgr.h"
#include "WarlockAiObjectContext.h"
#include "WarriorAiObjectContext.h"
AiObjectContext* AiFactory::createAiObjectContext(Player* player, PlayerbotAI* botAI)
{
switch (player->getClass())
{
case CLASS_PRIEST:
return new PriestAiObjectContext(botAI);
case CLASS_MAGE:
return new MageAiObjectContext(botAI);
case CLASS_WARLOCK:
return new WarlockAiObjectContext(botAI);
case CLASS_WARRIOR:
return new WarriorAiObjectContext(botAI);
case CLASS_SHAMAN:
return new ShamanAiObjectContext(botAI);
case CLASS_PALADIN:
return new PaladinAiObjectContext(botAI);
case CLASS_DRUID:
return new DruidAiObjectContext(botAI);
case CLASS_HUNTER:
return new HunterAiObjectContext(botAI);
case CLASS_ROGUE:
return new RogueAiObjectContext(botAI);
case CLASS_DEATH_KNIGHT:
return new DKAiObjectContext(botAI);
}
return new AiObjectContext(botAI);
}
uint8 AiFactory::GetPlayerSpecTab(Player* bot)
{
std::map<uint8, uint32> tabs = GetPlayerSpecTabs(bot);
if (bot->GetLevel() >= 10 && ((tabs[0] + tabs[1] + tabs[2]) > 0))
{
int8 tab = -1;
uint32 max = 0;
for (uint32 i = 0; i < uint32(3); i++)
{
if (tab == -1 || max < tabs[i])
{
tab = i;
max = tabs[i];
}
}
return tab;
}
else
{
uint8 tab = 0;
switch (bot->getClass())
{
case CLASS_MAGE:
tab = MAGE_TAB_FROST;
break;
case CLASS_PALADIN:
tab = PALADIN_TAB_RETRIBUTION;
break;
case CLASS_PRIEST:
tab = PRIEST_TAB_HOLY;
break;
case CLASS_WARLOCK:
tab = WARLOCK_TAB_DEMONOLOGY;
break;
}
return tab;
}
}
std::map<uint8, uint32> AiFactory::GetPlayerSpecTabs(Player* bot)
{
std::map<uint8, uint32> tabs = {{0, 0}, {0, 0}, {0, 0}};
const PlayerTalentMap& talentMap = bot->GetTalentMap();
for (PlayerTalentMap::const_iterator i = talentMap.begin(); i != talentMap.end(); ++i)
{
uint32 spellId = i->first;
if ((bot->GetActiveSpecMask() & i->second->specMask) == 0)
{
continue;
}
TalentSpellPos const* talentPos = GetTalentSpellPos(spellId);
if (!talentPos)
continue;
TalentEntry const* talentInfo = sTalentStore.LookupEntry(talentPos->talent_id);
if (!talentInfo)
continue;
uint32 const* talentTabIds = GetTalentTabPages(bot->getClass());
const SpellInfo* spellInfo = sSpellMgr->GetSpellInfo(spellId);
int rank = spellInfo ? spellInfo->GetRank() : 1;
if (talentInfo->TalentTab == talentTabIds[0])
tabs[0] += rank;
if (talentInfo->TalentTab == talentTabIds[1])
tabs[1] += rank;
if (talentInfo->TalentTab == talentTabIds[2])
tabs[2] += rank;
}
return tabs;
}
BotRoles AiFactory::GetPlayerRoles(Player* player)
{
BotRoles role = BOT_ROLE_NONE;
uint8 tab = GetPlayerSpecTab(player);
switch (player->getClass())
{
case CLASS_PRIEST:
if (tab == PRIEST_TAB_SHADOW)
role = BOT_ROLE_DPS;
else
role = BOT_ROLE_HEALER;
break;
case CLASS_SHAMAN:
if (tab == SHAMAN_TAB_RESTORATION)
role = BOT_ROLE_HEALER;
else
role = BOT_ROLE_DPS;
break;
case CLASS_WARRIOR:
if (tab == WARRIOR_TAB_PROTECTION)
role = BOT_ROLE_TANK;
else
role = BOT_ROLE_DPS;
break;
case CLASS_PALADIN:
if (tab == PALADIN_TAB_HOLY)
role = BOT_ROLE_HEALER;
else if (tab == PALADIN_TAB_PROTECTION)
role = BOT_ROLE_TANK;
else if (tab == PALADIN_TAB_RETRIBUTION)
role = BOT_ROLE_DPS;
break;
case CLASS_DRUID:
if (tab == DRUID_TAB_BALANCE)
role = BOT_ROLE_DPS;
else if (tab == DRUID_TAB_FERAL)
role = (BotRoles)(BOT_ROLE_TANK | BOT_ROLE_DPS);
else if (tab == DRUID_TAB_RESTORATION)
role = BOT_ROLE_HEALER;
break;
default:
role = BOT_ROLE_DPS;
break;
}
return role;
}
std::string AiFactory::GetPlayerSpecName(Player* player)
{
std::string specName;
int tab = GetPlayerSpecTab(player);
switch (player->getClass())
{
case CLASS_PRIEST:
if (tab == PRIEST_TAB_SHADOW)
specName = "shadow";
else if (tab == PRIEST_TAB_HOLY)
specName = "holy";
else
specName = "disc";
break;
case CLASS_SHAMAN:
if (tab == SHAMAN_TAB_RESTORATION)
specName = "resto";
else if (tab == SHAMAN_TAB_ENHANCEMENT)
specName = "enhance";
else
specName = "elem";
break;
case CLASS_WARRIOR:
if (tab == WARRIOR_TAB_PROTECTION)
specName = "prot";
else if (tab == WARRIOR_TAB_FURY)
specName = "fury";
else
specName = "arms";
break;
case CLASS_PALADIN:
if (tab == PALADIN_TAB_HOLY)
specName = "holy";
else if (tab == PALADIN_TAB_PROTECTION)
specName = "prot";
else if (tab == PALADIN_TAB_RETRIBUTION)
specName = "retrib";
break;
case CLASS_DRUID:
if (tab == DRUID_TAB_BALANCE)
specName = "balance";
else if (tab == DRUID_TAB_FERAL)
specName = "feraldps";
else if (tab == DRUID_TAB_RESTORATION)
specName = "resto";
break;
case CLASS_ROGUE:
if (tab == ROGUE_TAB_ASSASSINATION)
specName = "assas";
else if (tab == ROGUE_TAB_COMBAT)
specName = "combat";
else if (tab == ROGUE_TAB_SUBTLETY)
specName = "subtle";
break;
case CLASS_HUNTER:
if (tab == HUNTER_TAB_BEAST_MASTERY)
specName = "beast";
else if (tab == HUNTER_TAB_MARKSMANSHIP)
specName = "marks";
else if (tab == HUNTER_TAB_SURVIVAL)
specName = "surv";
break;
case CLASS_DEATH_KNIGHT:
if (tab == DEATH_KNIGHT_TAB_BLOOD)
specName = "blooddps";
else if (tab == DEATH_KNIGHT_TAB_FROST)
specName = "frostdps";
else if (tab == DEATH_KNIGHT_TAB_UNHOLY)
specName = "unholydps";
break;
case CLASS_MAGE:
if (tab == MAGE_TAB_ARCANE)
specName = "arcane";
else if (tab == MAGE_TAB_FIRE)
specName = "fire";
else if (tab == MAGE_TAB_FROST)
specName = "frost";
break;
case CLASS_WARLOCK:
if (tab == WARLOCK_TAB_AFFLICTION)
specName = "afflic";
else if (tab == WARLOCK_TAB_DEMONOLOGY)
specName = "demo";
else if (tab == WARLOCK_TAB_DESTRUCTION)
specName = "destro";
break;
default:
break;
}
return specName;
}
void AiFactory::AddDefaultCombatStrategies(Player* player, PlayerbotAI* const facade, Engine* engine)
{
uint8 tab = GetPlayerSpecTab(player);
if (!player->InBattleground())
engine->addStrategiesNoInit("racials", "chat", "default", "cast time", "potions", "duel", "boost", nullptr);
if (sPlayerbotAIConfig.autoAvoidAoe && facade->HasRealPlayerMaster())
engine->addStrategy("avoid aoe", false);
engine->addStrategy("formation", false);
switch (player->getClass())
{
case CLASS_PRIEST:
if (tab == PRIEST_TAB_SHADOW)
engine->addStrategiesNoInit("dps", "shadow debuff", "shadow aoe", nullptr);
else if (tab == PRIEST_TAB_DISCIPLINE)
engine->addStrategy("heal", false);
else // if (tab == PRIEST_TAB_HOLY)
engine->addStrategy("holy heal", false);
engine->addStrategiesNoInit("dps assist", "cure", nullptr);
break;
case CLASS_MAGE:
if (tab == MAGE_TAB_ARCANE)
engine->addStrategiesNoInit("arcane", "bdps", nullptr);
else if (tab == MAGE_TAB_FIRE)
{
if (player->HasSpell(44614) /*Frostfire Bolt*/ && player->HasAura(15047) /*Ice Shards*/)
engine->addStrategiesNoInit("frostfire", "bdps", nullptr);
else
engine->addStrategiesNoInit("fire", "bdps", nullptr);
}
else // if (tab == MAGE_TAB_FROST)
engine->addStrategiesNoInit("frost", "bmana", nullptr);
engine->addStrategiesNoInit("dps", "dps assist", "cure", "cc", "aoe", nullptr);
break;
case CLASS_WARRIOR:
if (tab == WARRIOR_TAB_PROTECTION)
engine->addStrategiesNoInit("tank", "tank assist", "pull", "pull back", "aoe", nullptr);
else if (tab == WARRIOR_TAB_ARMS || !player->HasSpell(1680)) // Whirlwind
engine->addStrategiesNoInit("arms", "aoe", "dps assist", nullptr);
else // if (tab == WARRIOR_TAB_FURY)
engine->addStrategiesNoInit("fury", "aoe", "dps assist", nullptr);
break;
case CLASS_SHAMAN:
if (tab == SHAMAN_TAB_ELEMENTAL)
engine->addStrategiesNoInit("ele", "stoneskin", "wrath", "mana spring", "wrath of air", nullptr);
else if (tab == SHAMAN_TAB_RESTORATION)
engine->addStrategiesNoInit("resto", "stoneskin", "flametongue", "mana spring", "wrath of air", nullptr);
else // if (tab == SHAMAN_TAB_ENHANCEMENT)
engine->addStrategiesNoInit("enh", "strength of earth", "magma", "healing stream", "windfury", nullptr);
engine->addStrategiesNoInit("dps assist", "cure", "aoe", nullptr);
break;
case CLASS_PALADIN:
if (tab == PALADIN_TAB_PROTECTION)
engine->addStrategiesNoInit("tank", "tank assist", "pull", "pull back", "bthreat", "barmor", "cure", nullptr);
else if (tab == PALADIN_TAB_HOLY)
engine->addStrategiesNoInit("heal", "dps assist", "cure", "bcast", nullptr);
else // if (tab == PALADIN_TAB_RETRIBUTION)
engine->addStrategiesNoInit("dps", "dps assist", "cure", "baoe", nullptr);
break;
case CLASS_DRUID:
if (tab == DRUID_TAB_BALANCE)
engine->addStrategiesNoInit("caster", "cure", "caster aoe", "caster debuff", "dps assist", nullptr);
else if (tab == DRUID_TAB_RESTORATION)
engine->addStrategiesNoInit("heal", "cure", "dps assist", nullptr);
else // if (tab == DRUID_TAB_FERAL)
{
if (player->HasSpell(768) /*cat form*/ && !player->HasAura(16931) /*thick hide*/)
engine->addStrategiesNoInit("cat", "dps assist", nullptr);
else
engine->addStrategiesNoInit("bear", "tank assist", "pull", "pull back", nullptr);
}
break;
case CLASS_HUNTER:
if (tab == HUNTER_TAB_BEAST_MASTERY)
engine->addStrategy("bm", false);
else if (tab == HUNTER_TAB_MARKSMANSHIP)
engine->addStrategy("mm", false);
else // if (tab == HUNTER_TAB_SURVIVAL)
engine->addStrategy("surv", false);
engine->addStrategiesNoInit("cc", "dps assist", "aoe", "bdps", nullptr);
break;
case CLASS_ROGUE:
if (tab == ROGUE_TAB_ASSASSINATION || tab == ROGUE_TAB_SUBTLETY)
engine->addStrategiesNoInit("melee", "dps assist", "aoe", nullptr);
else // if (tab == ROGUE_TAB_COMBAT)
engine->addStrategiesNoInit("dps", "dps assist", "aoe", nullptr);
break;
case CLASS_WARLOCK:
if (tab == WARLOCK_TAB_AFFLICTION)
engine->addStrategiesNoInit("affli", "curse of agony", nullptr);
else if (tab == WARLOCK_TAB_DEMONOLOGY)
engine->addStrategiesNoInit("demo", "curse of agony", "meta melee", nullptr);
else // if (tab == WARLOCK_TAB_DESTRUCTION)
engine->addStrategiesNoInit("destro", "curse of elements", nullptr);
engine->addStrategiesNoInit("cc", "dps assist", "aoe", nullptr);
break;
case CLASS_DEATH_KNIGHT:
if (tab == DEATH_KNIGHT_TAB_BLOOD)
engine->addStrategiesNoInit("blood", "tank assist", "pull", "pull back", nullptr);
else if (tab == DEATH_KNIGHT_TAB_FROST)
engine->addStrategiesNoInit("frost", "frost aoe", "dps assist", nullptr);
else // if (tab == DEATH_KNIGHT_TAB_UNHOLY)
engine->addStrategiesNoInit("unholy", "unholy aoe", "dps assist", nullptr);
break;
}
if (PlayerbotAI::IsTank(player, true))
engine->addStrategy("tank face", false);
if (PlayerbotAI::IsMelee(player, true) && PlayerbotAI::IsDps(player, true))
engine->addStrategy("behind", false);
if (PlayerbotAI::IsHeal(player, true))
{
if (sPlayerbotAIConfig.autoSaveMana)
engine->addStrategy("save mana", false);
if (!sPlayerbotAIConfig.IsRestrictedHealerDPSMap(player->GetMapId()))
engine->addStrategy("healer dps", false);
}
if (facade->IsRealPlayer() || sRandomPlayerbotMgr.IsRandomBot(player))
{
if (!player->GetGroup())
{
// change for heal spec
engine->addStrategy("boost", false);
engine->addStrategy("dps assist", false);
engine->removeStrategy("threat", false);
switch (player->getClass())
{
case CLASS_PRIEST:
{
if (tab != PRIEST_TAB_SHADOW)
engine->addStrategiesNoInit("holy dps", "shadow debuff", "shadow aoe", nullptr);
break;
}
case CLASS_DRUID:
{
if (tab == DRUID_TAB_RESTORATION)
{
engine->addStrategiesNoInit("caster", "caster aoe", nullptr);
engine->addStrategy("caster debuff", false);
}
break;
}
case CLASS_SHAMAN:
{
if (tab == SHAMAN_TAB_RESTORATION)
engine->addStrategiesNoInit("caster", "caster aoe", nullptr);
break;
}
case CLASS_PALADIN:
{
if (tab == PALADIN_TAB_HOLY)
engine->addStrategiesNoInit("dps", "dps assist", "baoe", nullptr);
break;
}
default:
break;
}
}
}
if (sRandomPlayerbotMgr.IsRandomBot(player))
engine->ChangeStrategy(sPlayerbotAIConfig.randomBotCombatStrategies);
else
engine->ChangeStrategy(sPlayerbotAIConfig.combatStrategies);
// Battleground switch
if (player->InBattleground() && player->GetBattleground())
{
BattlegroundTypeId bgType = player->GetBattlegroundTypeId();
if (bgType == BATTLEGROUND_RB)
bgType = player->GetBattleground()->GetBgTypeID(true);
if (bgType == BATTLEGROUND_WS)
engine->addStrategy("warsong", false);
if (bgType == BATTLEGROUND_AB)
engine->addStrategy("arathi", false);
if (bgType == BATTLEGROUND_AV)
engine->addStrategy("alterac", false);
if (bgType == BATTLEGROUND_EY)
engine->addStrategy("eye", false);
if (bgType == BATTLEGROUND_IC)
engine->addStrategy("isle", false);
if (player->InArena())
{
engine->addStrategy("arena", false);
engine->addStrategiesNoInit("boost", "racials", "chat", "default", "aoe", "cast time", "dps assist", nullptr);
}
else
engine->addStrategiesNoInit("boost", "racials", "chat", "default", "aoe", "potions", "cast time", "dps assist", nullptr);
engine->removeStrategy("custom::say", false);
engine->removeStrategy("flee", false);
engine->removeStrategy("threat", false);
engine->addStrategy("boost", false);
}
}
Engine* AiFactory::createCombatEngine(Player* player, PlayerbotAI* const facade, AiObjectContext* aiObjectContext)
{
Engine* engine = new Engine(facade, aiObjectContext);
AddDefaultCombatStrategies(player, facade, engine);
engine->Init();
return engine;
}
void AiFactory::AddDefaultNonCombatStrategies(Player* player, PlayerbotAI* const facade, Engine* nonCombatEngine)
{
uint8 tab = GetPlayerSpecTab(player);
switch (player->getClass())
{
case CLASS_PRIEST:
nonCombatEngine->addStrategiesNoInit("dps assist", "cure", nullptr);
break;
case CLASS_PALADIN:
if (tab == PALADIN_TAB_PROTECTION)
{
nonCombatEngine->addStrategiesNoInit("bthreat", "tank assist", "pull", "barmor", nullptr);
if (player->GetLevel() >= 20)
nonCombatEngine->addStrategy("bhealth", false);
else
nonCombatEngine->addStrategy("bdps", false);
}
else if (tab == PALADIN_TAB_HOLY)
nonCombatEngine->addStrategiesNoInit("dps assist", "bmana", "bcast", nullptr);
else
nonCombatEngine->addStrategiesNoInit("dps assist", "bdps", "baoe", nullptr);
nonCombatEngine->addStrategiesNoInit("cure", nullptr);
break;
case CLASS_HUNTER:
nonCombatEngine->addStrategiesNoInit("bdps", "dps assist", "pet", nullptr);
break;
case CLASS_SHAMAN:
nonCombatEngine->addStrategiesNoInit("dps assist", "cure", nullptr);
break;
case CLASS_MAGE:
if (tab == MAGE_TAB_ARCANE || tab == MAGE_TAB_FIRE)
nonCombatEngine->addStrategy("bdps", false);
else
nonCombatEngine->addStrategy("bmana", false);
nonCombatEngine->addStrategiesNoInit("dps assist", "cure", nullptr);
break;
case CLASS_DRUID:
if (tab == DRUID_TAB_FERAL)
{
if (player->GetLevel() >= 20 && !player->HasAura(16931) /*thick hide*/)
nonCombatEngine->addStrategy("dps assist", false);
else
nonCombatEngine->addStrategiesNoInit("tank assist", "pull", nullptr);
}
else
nonCombatEngine->addStrategiesNoInit("dps assist", "cure", nullptr);
break;
case CLASS_WARRIOR:
if (tab == WARRIOR_TAB_PROTECTION)
nonCombatEngine->addStrategiesNoInit("tank assist", "pull", nullptr);
else
nonCombatEngine->addStrategy("dps assist", false);
break;
case CLASS_WARLOCK:
if (tab == WARLOCK_TAB_AFFLICTION)
nonCombatEngine->addStrategiesNoInit("felhunter", "spellstone", nullptr);
else if (tab == WARLOCK_TAB_DEMONOLOGY)
nonCombatEngine->addStrategiesNoInit("felguard", "spellstone", nullptr);
else if (tab == WARLOCK_TAB_DESTRUCTION)
nonCombatEngine->addStrategiesNoInit("imp", "firestone", nullptr);
nonCombatEngine->addStrategiesNoInit("dps assist", "ss self", nullptr);
break;
case CLASS_DEATH_KNIGHT:
if (tab == DEATH_KNIGHT_TAB_BLOOD)
nonCombatEngine->addStrategiesNoInit("tank assist", "pull", nullptr);
else
nonCombatEngine->addStrategy("dps assist", false);
break;
default:
nonCombatEngine->addStrategy("dps assist", false);
break;
}
if (!player->InBattleground())
{
nonCombatEngine->addStrategiesNoInit("nc", "food", "chat", "follow", "default", "quest", "loot",
"gather", "duel", "pvp", "buff", "mount", "emote", nullptr);
}
if (sPlayerbotAIConfig.autoSaveMana && PlayerbotAI::IsHeal(player, true))
nonCombatEngine->addStrategy("save mana", false);
if ((sRandomPlayerbotMgr.IsRandomBot(player)) && !player->InBattleground())
{
Player* master = facade->GetMaster();
// let 25% of free bots start duels.
if (!urand(0, 3))
nonCombatEngine->addStrategy("start duel", false);
if (sPlayerbotAIConfig.randomBotJoinLfg)
nonCombatEngine->addStrategy("lfg", false);
if (!player->GetGroup() || player->GetGroup()->GetLeaderGUID() == player->GetGUID())
{
// let 25% of random not grouped (or grp leader) bots help other players
// if (!urand(0, 3))
// nonCombatEngine->addStrategy("attack tagged");
// nonCombatEngine->addStrategy("pvp", false);
// nonCombatEngine->addStrategy("collision");
// nonCombatEngine->addStrategy("group");
// nonCombatEngine->addStrategy("guild");
nonCombatEngine->addStrategy("grind", false);
if (sPlayerbotAIConfig.enableNewRpgStrategy)
nonCombatEngine->addStrategy("new rpg", false);
else if (sPlayerbotAIConfig.autoDoQuests)
{
// nonCombatEngine->addStrategy("travel");
nonCombatEngine->addStrategy("rpg", false);
}
else
nonCombatEngine->addStrategy("move random", false);
if (sPlayerbotAIConfig.randomBotJoinBG)
nonCombatEngine->addStrategy("bg", false);
// if (!master || GET_PLAYERBOT_AI(master))
// nonCombatEngine->addStrategy("maintenance");
nonCombatEngine->ChangeStrategy(sPlayerbotAIConfig.randomBotNonCombatStrategies);
}
else
{
if (facade)
{
if (master)
{
PlayerbotAI* masterBotAI = GET_PLAYERBOT_AI(master);
if (masterBotAI || sRandomPlayerbotMgr.IsRandomBot(player))
{
// nonCombatEngine->addStrategy("pvp", false);
// nonCombatEngine->addStrategy("collision");
// nonCombatEngine->addStrategy("group");
// nonCombatEngine->addStrategy("guild");
// if (sPlayerbotAIConfig.autoDoQuests)
// {
// // nonCombatEngine->addStrategy("travel");
// nonCombatEngine->addStrategy("rpg");
// }
// else
// {
// nonCombatEngine->addStrategy("move random");
// }
// if (masterBotAI)
// nonCombatEngine->addStrategy("maintenance");
nonCombatEngine->ChangeStrategy(sPlayerbotAIConfig.randomBotNonCombatStrategies);
}
else
{
// nonCombatEngine->addStrategy("pvp", false);
nonCombatEngine->ChangeStrategy(sPlayerbotAIConfig.nonCombatStrategies);
}
}
}
}
}
else
nonCombatEngine->ChangeStrategy(sPlayerbotAIConfig.nonCombatStrategies);
// Battleground switch
if (player->InBattleground() && player->GetBattleground())
{
nonCombatEngine->addStrategiesNoInit("nc", "chat", "default", "buff", "food", "mount", "pvp", "dps assist",
"attack tagged", "emote", nullptr);
nonCombatEngine->removeStrategy("custom::say", false);
nonCombatEngine->removeStrategy("travel", false);
nonCombatEngine->removeStrategy("rpg", false);
nonCombatEngine->removeStrategy("grind", false);
BattlegroundTypeId bgType = player->GetBattlegroundTypeId();
if (bgType == BATTLEGROUND_RB)
bgType = player->GetBattleground()->GetBgTypeID(true);
if ((bgType <= BATTLEGROUND_EY || bgType == BATTLEGROUND_IC) &&
!player->InArena()) // do not add for not supported bg or arena
nonCombatEngine->addStrategy("battleground", false);
if (bgType == BATTLEGROUND_WS)
nonCombatEngine->addStrategy("warsong", false);
if (bgType == BATTLEGROUND_AV)
nonCombatEngine->addStrategy("alterac", false);
if (bgType == BATTLEGROUND_AB)
nonCombatEngine->addStrategy("arathi", false);
if (bgType == BATTLEGROUND_EY)
nonCombatEngine->addStrategy("eye", false);
if (bgType == BATTLEGROUND_IC)
nonCombatEngine->addStrategy("isle", false);
if (player->InArena())
{
nonCombatEngine->addStrategy("arena", false);
nonCombatEngine->removeStrategy("mount", false);
}
}
}
Engine* AiFactory::createNonCombatEngine(Player* player, PlayerbotAI* const facade, AiObjectContext* aiObjectContext)
{
Engine* nonCombatEngine = new Engine(facade, aiObjectContext);
AddDefaultNonCombatStrategies(player, facade, nonCombatEngine);
nonCombatEngine->Init();
return nonCombatEngine;
}
void AiFactory::AddDefaultDeadStrategies(Player* player, PlayerbotAI* const facade, Engine* deadEngine)
{
(void)facade; // unused and remove warning
deadEngine->addStrategiesNoInit("dead", "stay", "chat", "default", "follow", nullptr);
if (sRandomPlayerbotMgr.IsRandomBot(player) && !player->GetGroup())
deadEngine->removeStrategy("follow", false);
}
Engine* AiFactory::createDeadEngine(Player* player, PlayerbotAI* const facade, AiObjectContext* AiObjectContext)
{
Engine* deadEngine = new Engine(facade, AiObjectContext);
AddDefaultDeadStrategies(player, facade, deadEngine);
deadEngine->Init();
return deadEngine;
}