mirror of
https://github.com/liyunfan1223/mod-playerbots.git
synced 2026-06-20 15:39:25 +02:00
<!--
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?
345 lines
9.1 KiB
C++
345 lines
9.1 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.
|
|
*/
|
|
|
|
#ifndef _PLAYERBOT_MAGETRIGGERS_H
|
|
#define _PLAYERBOT_MAGETRIGGERS_H
|
|
|
|
#include "CureTriggers.h"
|
|
#include "GenericTriggers.h"
|
|
#include "SharedDefines.h"
|
|
#include "Trigger.h"
|
|
#include "Playerbots.h"
|
|
#include <unordered_set>
|
|
|
|
// Buff and Out of Combat Triggers
|
|
|
|
class ArcaneIntellectOnPartyTrigger : public BuffOnPartyTrigger
|
|
{
|
|
public:
|
|
ArcaneIntellectOnPartyTrigger(PlayerbotAI* botAI)
|
|
: BuffOnPartyTrigger(botAI, "arcane intellect", 2 * 2000) {}
|
|
bool IsActive() override;
|
|
};
|
|
|
|
class ArcaneIntellectTrigger : public BuffTrigger
|
|
{
|
|
public:
|
|
ArcaneIntellectTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "arcane intellect", 2 * 2000) {}
|
|
bool IsActive() override;
|
|
};
|
|
|
|
class MageArmorTrigger : public BuffTrigger
|
|
{
|
|
public:
|
|
MageArmorTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "mage armor", 5 * 2000) {}
|
|
bool IsActive() override;
|
|
};
|
|
|
|
class MoltenArmorTrigger : public BuffTrigger
|
|
{
|
|
public:
|
|
MoltenArmorTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "molten armor", 5 * 2000) {}
|
|
bool IsActive() override;
|
|
};
|
|
|
|
class NoFocusMagicTrigger : public Trigger
|
|
{
|
|
public:
|
|
NoFocusMagicTrigger(PlayerbotAI* botAI) : Trigger(botAI, "no focus magic") {}
|
|
bool IsActive() override;
|
|
};
|
|
|
|
class IceBarrierTrigger : public BuffTrigger
|
|
{
|
|
public:
|
|
IceBarrierTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "ice barrier") {}
|
|
};
|
|
|
|
class NoManaGemTrigger : public Trigger
|
|
{
|
|
public:
|
|
NoManaGemTrigger(PlayerbotAI* botAI) : Trigger(botAI, "no mana gem") {}
|
|
bool IsActive() override;
|
|
};
|
|
|
|
class FireWardTrigger : public DeflectSpellTrigger
|
|
{
|
|
public:
|
|
FireWardTrigger(PlayerbotAI* botAI) : DeflectSpellTrigger(botAI, "fire ward") {}
|
|
};
|
|
|
|
class FrostWardTrigger : public DeflectSpellTrigger
|
|
{
|
|
public:
|
|
FrostWardTrigger(PlayerbotAI* botAI) : DeflectSpellTrigger(botAI, "frost ward") {}
|
|
};
|
|
|
|
// Proc and Boost Triggers
|
|
|
|
class HotStreakTrigger : public HasAuraTrigger
|
|
{
|
|
public:
|
|
HotStreakTrigger(PlayerbotAI* botAI) : HasAuraTrigger(botAI, "hot streak") {}
|
|
};
|
|
|
|
class FirestarterTrigger : public HasAuraTrigger
|
|
{
|
|
public:
|
|
FirestarterTrigger(PlayerbotAI* botAI) : HasAuraTrigger(botAI, "firestarter") {}
|
|
};
|
|
|
|
class MissileBarrageTrigger : public HasAuraTrigger
|
|
{
|
|
public:
|
|
MissileBarrageTrigger(PlayerbotAI* botAI) : HasAuraTrigger(botAI, "missile barrage") {}
|
|
};
|
|
|
|
class ArcaneBlastTrigger : public BuffTrigger
|
|
{
|
|
public:
|
|
ArcaneBlastTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "arcane blast") {}
|
|
};
|
|
|
|
class ArcaneBlastStackTrigger : public HasAuraStackTrigger
|
|
{
|
|
public:
|
|
ArcaneBlastStackTrigger(PlayerbotAI* botAI) : HasAuraStackTrigger(botAI, "arcane blast", 4, 1) {}
|
|
};
|
|
|
|
class ArcaneBlast4StacksAndMissileBarrageTrigger : public TwoTriggers
|
|
{
|
|
public:
|
|
ArcaneBlast4StacksAndMissileBarrageTrigger(PlayerbotAI* botAI)
|
|
: TwoTriggers(botAI, "arcane blast stack", "missile barrage") {}
|
|
};
|
|
|
|
class CombustionTrigger : public BoostTrigger
|
|
{
|
|
public:
|
|
CombustionTrigger(PlayerbotAI* botAI) : BoostTrigger(botAI, "combustion") {}
|
|
};
|
|
|
|
class IcyVeinsCooldownTrigger : public SpellCooldownTrigger
|
|
{
|
|
public:
|
|
IcyVeinsCooldownTrigger(PlayerbotAI* botAI) : SpellCooldownTrigger(botAI, "icy veins") {}
|
|
};
|
|
|
|
class DeepFreezeCooldownTrigger : public SpellCooldownTrigger
|
|
{
|
|
public:
|
|
DeepFreezeCooldownTrigger(PlayerbotAI* botAI) : SpellCooldownTrigger(botAI, "deep freeze") {}
|
|
|
|
bool IsActive() override;
|
|
};
|
|
|
|
class ColdSnapTrigger : public TwoTriggers
|
|
{
|
|
public:
|
|
ColdSnapTrigger(PlayerbotAI* botAI) : TwoTriggers(botAI, "icy veins on cd", "deep freeze on cd") {}
|
|
};
|
|
|
|
class MirrorImageTrigger : public BoostTrigger
|
|
{
|
|
public:
|
|
MirrorImageTrigger(PlayerbotAI* botAI) : BoostTrigger(botAI, "mirror image") {}
|
|
};
|
|
|
|
class IcyVeinsTrigger : public BoostTrigger
|
|
{
|
|
public:
|
|
IcyVeinsTrigger(PlayerbotAI* botAI) : BoostTrigger(botAI, "icy veins") {}
|
|
};
|
|
|
|
class ArcanePowerTrigger : public BoostTrigger
|
|
{
|
|
public:
|
|
ArcanePowerTrigger(PlayerbotAI* botAI) : BoostTrigger(botAI, "arcane power") {}
|
|
};
|
|
class PresenceOfMindTrigger : public BoostTrigger
|
|
{
|
|
public:
|
|
PresenceOfMindTrigger(PlayerbotAI* botAI) : BoostTrigger(botAI, "presence of mind") {}
|
|
};
|
|
|
|
// CC, Interrupt, and Dispel Triggers
|
|
|
|
class PolymorphTrigger : public HasCcTargetTrigger
|
|
{
|
|
public:
|
|
PolymorphTrigger(PlayerbotAI* botAI) : HasCcTargetTrigger(botAI, "polymorph") {}
|
|
};
|
|
|
|
class RemoveCurseTrigger : public NeedCureTrigger
|
|
{
|
|
public:
|
|
RemoveCurseTrigger(PlayerbotAI* botAI) : NeedCureTrigger(botAI, "remove curse", DISPEL_CURSE) {}
|
|
};
|
|
|
|
class PartyMemberRemoveCurseTrigger : public PartyMemberNeedCureTrigger
|
|
{
|
|
public:
|
|
PartyMemberRemoveCurseTrigger(PlayerbotAI* botAI)
|
|
: PartyMemberNeedCureTrigger(botAI, "remove curse", DISPEL_CURSE) {}
|
|
};
|
|
|
|
class SpellstealTrigger : public TargetAuraDispelTrigger
|
|
{
|
|
public:
|
|
SpellstealTrigger(PlayerbotAI* botAI) : TargetAuraDispelTrigger(botAI, "spellsteal", DISPEL_MAGIC) {}
|
|
};
|
|
|
|
class CounterspellEnemyHealerTrigger : public InterruptEnemyHealerTrigger
|
|
{
|
|
public:
|
|
CounterspellEnemyHealerTrigger(PlayerbotAI* botAI) : InterruptEnemyHealerTrigger(botAI, "counterspell") {}
|
|
};
|
|
|
|
class CounterspellInterruptSpellTrigger : public InterruptSpellTrigger
|
|
{
|
|
public:
|
|
CounterspellInterruptSpellTrigger(PlayerbotAI* botAI) : InterruptSpellTrigger(botAI, "counterspell") {}
|
|
};
|
|
|
|
// Damage and Debuff Triggers
|
|
|
|
class LivingBombTrigger : public DebuffTrigger
|
|
{
|
|
public:
|
|
LivingBombTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "living bomb", 1, true) {}
|
|
bool IsActive() override { return BuffTrigger::IsActive(); }
|
|
};
|
|
|
|
class LivingBombOnAttackersTrigger : public DebuffOnAttackerTrigger
|
|
{
|
|
public:
|
|
LivingBombOnAttackersTrigger(PlayerbotAI* botAI) : DebuffOnAttackerTrigger(botAI, "living bomb", true) {}
|
|
bool IsActive() override { return BuffTrigger::IsActive(); }
|
|
};
|
|
|
|
class FireballTrigger : public DebuffTrigger
|
|
{
|
|
public:
|
|
FireballTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "fireball", 1, true) {}
|
|
};
|
|
|
|
class ImprovedScorchTrigger : public DebuffTrigger
|
|
{
|
|
public:
|
|
ImprovedScorchTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "improved scorch", 1, true, 0.5f) {}
|
|
bool IsActive() override;
|
|
};
|
|
|
|
class PyroblastTrigger : public DebuffTrigger
|
|
{
|
|
public:
|
|
PyroblastTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "pyroblast", 1, true) {}
|
|
};
|
|
|
|
class FrostfireBoltTrigger : public DebuffTrigger
|
|
{
|
|
public:
|
|
FrostfireBoltTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "frostfire bolt", 1, true) {}
|
|
};
|
|
|
|
class FingersOfFrostTrigger : public HasAuraTrigger
|
|
{
|
|
public:
|
|
FingersOfFrostTrigger(PlayerbotAI* botAI) : HasAuraTrigger(botAI, "fingers of frost") {}
|
|
};
|
|
|
|
class BrainFreezeTrigger : public HasAuraTrigger
|
|
{
|
|
public:
|
|
BrainFreezeTrigger(PlayerbotAI* botAI) : HasAuraTrigger(botAI, "fireball!") {}
|
|
};
|
|
|
|
class FrostNovaOnTargetTrigger : public DebuffTrigger
|
|
{
|
|
public:
|
|
FrostNovaOnTargetTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "frost nova", 1, false) {}
|
|
bool IsActive() override;
|
|
};
|
|
|
|
class FrostbiteOnTargetTrigger : public DebuffTrigger
|
|
{
|
|
public:
|
|
FrostbiteOnTargetTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "frostbite", 1, false) {}
|
|
bool IsActive() override;
|
|
};
|
|
|
|
class FlamestrikeNearbyTrigger : public Trigger
|
|
{
|
|
public:
|
|
FlamestrikeNearbyTrigger(PlayerbotAI* botAI, float radius = 30.0f)
|
|
: Trigger(botAI, "flamestrike nearby"), radius(radius)
|
|
{
|
|
}
|
|
bool IsActive() override;
|
|
|
|
protected:
|
|
float radius;
|
|
static const std::unordered_set<uint32> FLAMESTRIKE_SPELL_IDS;
|
|
};
|
|
|
|
class FlamestrikeBlizzardTrigger : public TwoTriggers
|
|
{
|
|
public:
|
|
FlamestrikeBlizzardTrigger(PlayerbotAI* botAI) : TwoTriggers(botAI, "flamestrike nearby", "medium aoe") {}
|
|
};
|
|
|
|
class BlizzardChannelCheckTrigger : public Trigger
|
|
{
|
|
public:
|
|
BlizzardChannelCheckTrigger(PlayerbotAI* botAI, uint32 minEnemies = 2)
|
|
: Trigger(botAI, "blizzard channel check"), minEnemies(minEnemies) {}
|
|
|
|
bool IsActive() override;
|
|
|
|
protected:
|
|
uint32 minEnemies;
|
|
static const std::unordered_set<uint32> BLIZZARD_SPELL_IDS;
|
|
};
|
|
|
|
class BlastWaveOffCdTrigger : public SpellNoCooldownTrigger
|
|
{
|
|
public:
|
|
BlastWaveOffCdTrigger(PlayerbotAI* botAI) : SpellNoCooldownTrigger(botAI, "blast wave") {}
|
|
};
|
|
|
|
class BlastWaveOffCdTriggerAndMediumAoeTrigger : public TwoTriggers
|
|
{
|
|
public:
|
|
BlastWaveOffCdTriggerAndMediumAoeTrigger(PlayerbotAI* botAI)
|
|
: TwoTriggers(botAI, "blast wave off cd", "medium aoe") {}
|
|
};
|
|
|
|
class NoFirestarterStrategyTrigger : public Trigger
|
|
{
|
|
public:
|
|
NoFirestarterStrategyTrigger(PlayerbotAI* botAI) : Trigger(botAI, "no firestarter strategy") {}
|
|
|
|
bool IsActive() override
|
|
{
|
|
return !botAI->HasStrategy("firestarter", BOT_STATE_COMBAT);
|
|
}
|
|
};
|
|
|
|
class EnemyIsCloseAndNoFirestarterStrategyTrigger : public TwoTriggers
|
|
{
|
|
public:
|
|
EnemyIsCloseAndNoFirestarterStrategyTrigger(PlayerbotAI* botAI)
|
|
: TwoTriggers(botAI, "enemy is close", "no firestarter strategy") {}
|
|
};
|
|
|
|
class EnemyTooCloseForSpellAndNoFirestarterStrategyTrigger : public TwoTriggers
|
|
{
|
|
public:
|
|
EnemyTooCloseForSpellAndNoFirestarterStrategyTrigger(PlayerbotAI* botAI)
|
|
: TwoTriggers(botAI, "enemy too close for spell", "no firestarter strategy") {}
|
|
};
|
|
|
|
#endif
|