mod-playerbots/src/Ai/Raid/ZulAman/Multiplier/RaidZulAmanMultipliers.cpp
Crow 91eac70ca2
Implement Zul'Aman Strategies (#2186)
# Pull Request

_Implement strategies for all bosses in Zul'Aman. See next post for
overview of implemented strategies._

---

## Design Philosophy

We prioritize **stability, performance, and predictability** over
behavioral realism.
Complex player-mimicking logic is intentionally limited due to its
negative impact on scalability, maintainability, and
long-term robustness.

Excessive processing overhead can lead to server hiccups, increased CPU
usage, and degraded performance for all
participants. Because every action and
decision tree is executed **per bot and per trigger**, even small
increases in logic complexity can scale poorly and
negatively affect both players and
world (random) bots. Bots are not expected to behave perfectly, and
perfect simulation of human decision-making is not a
project goal. Increased behavioral
realism often introduces disproportionate cost, reduced predictability,
and significantly higher maintenance overhead.

Every additional branch of logic increases long-term responsibility. All
decision paths must be tested, validated, and
maintained continuously as the system evolves.
If advanced or AI-intensive behavior is introduced, the **default
configuration must remain the lightweight decision
model**. More complex behavior should only be
available as an **explicit opt-in option**, clearly documented as having
a measurable performance cost.

Principles:

- **Stability before intelligence**  
  A stable system is always preferred over a smarter one.

- **Performance is a shared resource**  
  Any increase in bot cost affects all players and all bots.

- **Simple logic scales better than smart logic**  
Predictable behavior under load is more valuable than perfect decisions.

- **Complexity must justify itself**  
  If a feature cannot clearly explain its cost, it should not exist.

- **Defaults must be cheap**  
  Expensive behavior must always be optional and clearly communicated.

- **Bots should look reasonable, not perfect**  
  The goal is believable behavior, not human simulation.

Before submitting, confirm that this change aligns with those
principles.

---

## Feature Evaluation

Please answer the following:

- Describe the **minimum logic** required to achieve the intended
behavior?
- Describe the **cheapest implementation** that produces an acceptable
result?
- Describe the **runtime cost** when this logic executes across many
bots?

_I have attempted to order checks while taking into account cost and
likelihood and have opted to find lower-cost methods where possible. I
have also not gone as in depth as I have with other strategies,
partially because it is not necessary to complete encounters but also to
try to limit the performance impact. From my observation, including with
pmon, none of the methods should be overly taxing._

---

## How to Test the Changes

- Step-by-step instructions to test the change
- Any required setup (e.g. multiple players, bots, specific
configuration)
- Expected behavior and how to verify it

_Run Zul'Aman. See next post for strategies to test._

## Complexity & Impact

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

_Only in the context of raid strategies, with new methods to consider
and new multipliers to evaluate when bots perform actions with the
instance strategy active._

Does this change increase per-bot or per-tick processing?
- - [ ] No
- - [x] Yes (**describe and justify impact**)

_The impact is only with the "zulaman" strategy active, which will be
applied only in the instance. There is currently a PR open to also
remove instance strategies when leaving the map to get rid of the
residual performance impact._

Could this logic scale poorly under load?
- - [ ] No
- - [x] Yes (**explain why**)

_Technically yes, but I think it is unlikely to have an appreciable
difference unless there are many groups running the instance at the same
time on a large server._

## Defaults & Configuration

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

_Only in the instance. It is a necessary trade-off to consider with raid
strategies that I always keep in mind (degree of automation vs. player
choice)._

If this introduces more advanced or AI-heavy logic:
- - [x] Lightweight mode remains the default
- - [ ] More complex behavior is optional and thereby configurable

_Not exactly sure how to address this question in the context of this
PR, but there aren't any techniques or methods for this strategy that I
have not tried before (or something very similar)._

## AI Assistance

Was AI assistance (e.g. ChatGPT or similar tools) used while working on
this change?
- - [ ] No
- - [x] Yes (**explain below**)

If yes, please specify:

- AI tool or model used (e.g. ChatGPT, GPT-4, Claude, etc.)
- Purpose of usage (e.g. brainstorming, refactoring, documentation, code
generation)
- Which parts of the change were influenced or generated
- Whether the result was manually reviewed and adapted

_Gemini and GPT for some questions about the codebase and C++ and
assistance with drafting a few things like containers that I find more
tedious to do myself._

AI assistance is allowed, but all submitted code must be fully
understood, reviewed, and owned by the contributor.
Any AI-influenced changes must be verified against existing CORE and PB
logic. We expect contributors to be honest
about what they do and do not understand.

---

## Final Checklist

- - [x] Stability is not compromised
- - [x] Performance impact is understood, tested, and acceptable
- - [x] Added logic complexity is justified and explained
- - [x] Documentation updated if needed

---

## Notes for Reviewers

Anything that significantly improves realism at the cost of stability or
performance should be carefully discussed
before merging.

---------

Co-authored-by: Keleborn <22352763+Celandriel@users.noreply.github.com>
Co-authored-by: bash <hermensb@gmail.com>
Co-authored-by: Revision <tkn963@gmail.com>
Co-authored-by: kadeshar <kadeshar@gmail.com>
2026-03-27 10:38:12 -07:00

383 lines
10 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 "RaidZulAmanMultipliers.h"
#include "RaidZulAmanActions.h"
#include "RaidZulAmanHelpers.h"
#include "ChooseTargetActions.h"
#include "DKActions.h"
#include "DruidBearActions.h"
#include "FollowActions.h"
#include "GenericSpellActions.h"
#include "HunterActions.h"
#include "MageActions.h"
#include "PaladinActions.h"
#include "Playerbots.h"
#include "PriestActions.h"
#include "RaidBossHelpers.h"
#include "ReachTargetActions.h"
#include "RogueActions.h"
#include "ShamanActions.h"
#include "WarlockActions.h"
#include "WarriorActions.h"
using namespace ZulAmanHelpers;
// Akil'zon <Eagle Avatar>
float AkilzonDisableCombatFormationMoveMultiplier::GetValue(Action* action)
{
if (!AI_VALUE2(Unit*, "find target", "akil'zon"))
return 1.0f;
if (dynamic_cast<CombatFormationMoveAction*>(action) &&
!dynamic_cast<SetBehindTargetAction*>(action))
return 0.0f;
return 1.0f;
}
float AkilzonStayInEyeOfTheStormMultiplier::GetValue(Action* action)
{
if (!AI_VALUE2(Unit*, "find target", "akil'zon") /* ||
!GetElectricalStormTarget(bot)*/)
return 1.0f;
auto it = akilzonStormTimer.find(bot->GetMap()->GetInstanceId());
if (it == akilzonStormTimer.end() ||
!IsInStormWindow(it->second, std::time(nullptr)))
return 1.0f;
if (dynamic_cast<CastReachTargetSpellAction*>(action) ||
dynamic_cast<CastKillingSpreeAction*>(action) ||
dynamic_cast<CastBlinkBackAction*>(action) ||
dynamic_cast<CastDisengageAction*>(action) ||
dynamic_cast<SetBehindTargetAction*>(action) ||
dynamic_cast<FleeAction*>(action) ||
dynamic_cast<FollowAction*>(action) ||
dynamic_cast<ReachTargetAction*>(action))
return 0.0f;
return 1.0f;
}
// Nalorakk <Bear Avatar>
float NalorakkDisableTankActionsMultiplier::GetValue(Action* action)
{
if (!botAI->IsTank(bot))
return 1.0f;
Unit* nalorakk = AI_VALUE2(Unit*, "find target", "nalorakk");
if (!nalorakk)
return 1.0f;
if (dynamic_cast<TankFaceAction*>(action))
return 0.0f;
if (bot->GetVictim() == nullptr)
return 1.0f;
bool shouldTankBoss = false;
if (botAI->IsMainTank(bot) &&
!nalorakk->HasAura(static_cast<uint32>(ZulAmanSpells::SPELL_BEARFORM)))
shouldTankBoss = true;
if (botAI->IsAssistTankOfIndex(bot, 0, true) &&
nalorakk->HasAura(static_cast<uint32>(ZulAmanSpells::SPELL_BEARFORM)))
shouldTankBoss = true;
if (!shouldTankBoss &&
(dynamic_cast<TankAssistAction*>(action) ||
dynamic_cast<CastTauntAction*>(action) ||
dynamic_cast<CastGrowlAction*>(action) ||
dynamic_cast<CastHandOfReckoningAction*>(action) ||
dynamic_cast<CastDarkCommandAction*>(action)))
return 0.0f;
return 1.0f;
}
float NalorakkControlMisdirectionMultiplier::GetValue(Action* action)
{
if (bot->getClass() != CLASS_HUNTER ||
!AI_VALUE2(Unit*, "find target", "nalorakk"))
return 1.0f;
if (dynamic_cast<CastMisdirectionOnMainTankAction*>(action))
return 0.0f;
return 1.0f;
}
// Jan'alai <Dragonhawk Avatar>
float JanalaiDisableTankActionsMultiplier::GetValue(Action* action)
{
if (!botAI->IsTank(bot) ||
!AI_VALUE2(Unit*, "find target", "jan'alai"))
return 1.0f;
if (dynamic_cast<TankFaceAction*>(action))
return 0.0f;
if (bot->GetVictim() == nullptr)
return 1.0f;
if (botAI->IsMainTank(bot) &&
dynamic_cast<TankAssistAction*>(action))
return 0.0f;
if (botAI->IsAssistTank(bot) &&
!GetFirstAliveUnitByEntry(
botAI, static_cast<uint32>(ZulAmanNPCs::NPC_AMANI_DRAGONHAWK_HATCHLING)) &&
dynamic_cast<TankAssistAction*>(action))
return 0.0f;
return 1.0f;
}
float JanalaiDisableCombatFormationMoveMultiplier::GetValue(Action* action)
{
if (!AI_VALUE2(Unit*, "find target", "jan'alai"))
return 1.0f;
if (dynamic_cast<CombatFormationMoveAction*>(action) &&
!dynamic_cast<SetBehindTargetAction*>(action))
return 0.0f;
return 1.0f;
}
float JanalaiStayAwayFromFireBombsMultiplier::GetValue(Action* action)
{
if (!AI_VALUE2(Unit*, "find target", "jan'alai"))
return 1.0f;
if (!HasFireBombNearby(botAI, bot))
return 1.0f;
if (dynamic_cast<CastReachTargetSpellAction*>(action) ||
dynamic_cast<CastKillingSpreeAction*>(action) ||
dynamic_cast<CastBlinkBackAction*>(action) ||
dynamic_cast<CastDisengageAction*>(action) ||
dynamic_cast<FleeAction*>(action) ||
dynamic_cast<FollowAction*>(action) ||
dynamic_cast<ReachTargetAction*>(action))
return 0.0f;
return 1.0f;
}
float JanalaiDoNotCrowdControlHatchersMultiplier::GetValue(Action* action)
{
if (!AI_VALUE2(Unit*, "find target", "amani'shi hatcher"))
return 1.0f;
if (dynamic_cast<CastCrowdControlSpellAction*>(action) ||
dynamic_cast<CastPolymorphAction*>(action))
return 0.0f;
return 1.0f;
}
float JanalaiDelayBloodlustAndHeroismMultiplier::GetValue(Action* action)
{
if (bot->getClass() != CLASS_SHAMAN)
return 1.0f;
if (!AI_VALUE2(Unit*, "find target", "jan'alai"))
return 1.0f;
if (AI_VALUE2(Unit*, "find target", "amani dragonhawk hatchling"))
return 1.0f;
if (dynamic_cast<CastBloodlustAction*>(action) ||
dynamic_cast<CastHeroismAction*>(action))
return 0.0f;
return 1.0f;
}
// Halazzi <Lynx Avatar>
float HalazziDisableTankActionsMultiplier::GetValue(Action* action)
{
if (!botAI->IsTank(bot) ||
!AI_VALUE2(Unit*, "find target", "halazzi"))
return 1.0f;
if (dynamic_cast<TankFaceAction*>(action))
return 0.0f;
if (bot->GetVictim() != nullptr &&
dynamic_cast<TankAssistAction*>(action))
return 0.0f;
return 1.0f;
}
float HalazziControlMisdirectionMultiplier::GetValue(Action* action)
{
if (bot->getClass() != CLASS_HUNTER ||
!AI_VALUE2(Unit*, "find target", "halazzi"))
return 1.0f;
if (dynamic_cast<CastMisdirectionOnMainTankAction*>(action))
return 0.0f;
return 1.0f;
}
// Hex Lord Malacrass
float HexLordMalacrassAvoidWhirlwindMultiplier::GetValue(Action* action)
{
if (botAI->IsMainTank(bot))
return 1.0f;
Unit* malacrass = AI_VALUE2(Unit*, "find target", "hex lord malacrass");
if (!malacrass ||
!malacrass->HasAura(static_cast<uint32>(ZulAmanSpells::SPELL_HEX_LORD_WHIRLWIND)))
return 1.0f;
if (dynamic_cast<CastReachTargetSpellAction*>(action) ||
dynamic_cast<CastKillingSpreeAction*>(action) ||
dynamic_cast<ReachTargetAction*>(action))
return 0.0f;
return 1.0f;
}
float HexLordMalacrassStopAttackingDuringSpellReflectionMultiplier::GetValue(Action* action)
{
if (!botAI->IsCaster(bot))
return 1.0f;
Unit* malacrass = AI_VALUE2(Unit*, "find target", "hex lord malacrass");
if (!malacrass ||
!malacrass->HasAura(static_cast<uint32>(ZulAmanSpells::SPELL_HEX_LORD_SPELL_REFLECTION)))
return 1.0f;
auto castSpellAction = dynamic_cast<CastSpellAction*>(action);
if (!castSpellAction)
return 1.0f;
if (castSpellAction->getThreatType() == Action::ActionThreatType::Aoe ||
(bot->GetVictim() == malacrass &&
castSpellAction->getThreatType() == Action::ActionThreatType::Single))
return 0.0f;
return 1.0f;
}
float HexLordMalacrassDoNotDispelUnstableAfflictionMultiplier::GetValue(Action* action)
{
if (bot->getClass() != CLASS_PRIEST &&
bot->getClass() != CLASS_PALADIN &&
bot->getClass() != CLASS_WARLOCK)
return 1.0f;
if (!AI_VALUE2(Unit*, "find target", "hex lord malacrass"))
return 1.0f;
Group* group = bot->GetGroup();
if (!group)
return 1.0f;
bool hasUnstableAffliction = false;
for (GroupReference* ref = bot->GetGroup()->GetFirstMember(); ref != nullptr; ref = ref->next())
{
Player* member = ref->GetSource();
if (!member || !member->IsAlive())
continue;
if (member->HasAura(static_cast<uint32>(ZulAmanSpells::SPELL_UNSTABLE_AFFLICTION)))
{
hasUnstableAffliction = true;
break;
}
}
if (!hasUnstableAffliction)
return 1.0f;
if (dynamic_cast<CastDevourMagicCleanseAction*>(action) ||
dynamic_cast<CastDispelMagicAction*>(action) ||
dynamic_cast<CastDispelMagicOnPartyAction*>(action) ||
dynamic_cast<CastMassDispelAction*>(action) ||
dynamic_cast<CastPurgeAction*>(action))
return 0.0f;
return 1.0f;
}
// Zul'jin
float ZuljinDisableTankFaceMultiplier::GetValue(Action* action)
{
if (!botAI->IsTank(bot))
return 1.0f;
Unit* zuljin = AI_VALUE2(Unit*, "find target", "zul'jin");
if (!zuljin ||
zuljin->HasAura(static_cast<uint32>(ZulAmanSpells::SPELL_SHAPE_OF_THE_DRAGONHAWK)))
return 1.0f;
if (dynamic_cast<TankFaceAction*>(action))
return 0.0f;
return 1.0f;
}
float ZuljinAvoidWhirlwindMultiplier::GetValue(Action* action)
{
if (botAI->IsMainTank(bot))
return 1.0f;
Unit* zuljin = AI_VALUE2(Unit*, "find target", "zul'jin");
if (!zuljin ||
!zuljin->HasAura(static_cast<uint32>(ZulAmanSpells::SPELL_ZULJIN_WHIRLWIND)))
return 1.0f;
if (dynamic_cast<CastReachTargetSpellAction*>(action) ||
dynamic_cast<CastKillingSpreeAction*>(action) ||
dynamic_cast<ReachTargetAction*>(action))
return 0.0f;
return 1.0f;
}
float ZuljinDisableAvoidAoeMultiplier::GetValue(Action* action)
{
Unit* zuljin = AI_VALUE2(Unit*, "find target", "zul'jin");
if (!zuljin ||
!zuljin->HasAura(static_cast<uint32>(ZulAmanSpells::SPELL_SHAPE_OF_THE_EAGLE)))
return 1.0f;
if (dynamic_cast<AvoidAoeAction*>(action))
return 0.0f;
return 1.0f;
}
float ZuljinDelayBloodlustAndHeroismMultiplier::GetValue(Action* action)
{
if (bot->getClass() != CLASS_SHAMAN)
return 1.0f;
Unit* zuljin = AI_VALUE2(Unit*, "find target", "zul'jin");
if (!zuljin ||
zuljin->HasAura(static_cast<uint32>(ZulAmanSpells::SPELL_SHAPE_OF_THE_EAGLE)))
return 1.0f;
if (dynamic_cast<CastBloodlustAction*>(action) ||
dynamic_cast<CastHeroismAction*>(action))
return 0.0f;
return 1.0f;
}