mirror of
https://github.com/liyunfan1223/mod-playerbots.git
synced 2026-06-20 23:49: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 -->
Pull strategy migration from cmangos for tank specializations
## 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.
-->
1. Invite bot tank
2. Use `reset boAI` or `nc +pull,+pull back` + `co +pull,+pull back`
3. Order bot to pull using command `pull my target` or `pull rti target`
4. Bot should run to mob, use ranged skill and back to point where he
started pull
Without `pull back` strategy bot run to mob, use ranged skill and wait
on mob until he come to bot
## 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?
- - [x] No
- - [ ] Yes (**explain why**)
- 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.
-->
Help with migration and solving some problems
<!--
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.
- - [ ] Documentation updated if needed (Conf comments, WiKi commands).
## Notes for Reviewers
<!-- Anything else that's helpful to review or test your pull request.
-->
Stability test after randomize new bots
<img width="465" height="172" alt="obraz"
src="https://github.com/user-attachments/assets/6e39a8c0-f23b-47cc-852a-71fa98044a31"
/>
---------
Co-authored-by: Keleborn <22352763+Celandriel@users.noreply.github.com>
259 lines
14 KiB
C++
259 lines
14 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_STRATEGYCONTEXT_H
|
|
#define _PLAYERBOT_STRATEGYCONTEXT_H
|
|
|
|
#include "AggressiveStrategy.h"
|
|
#include "AttackEnemyPlayersStrategy.h"
|
|
#include "BattlegroundStrategy.h"
|
|
#include "CastTimeStrategy.h"
|
|
#include "ChatCommandHandlerStrategy.h"
|
|
#include "ConserveManaStrategy.h"
|
|
#include "CustomStrategy.h"
|
|
#include "DeadStrategy.h"
|
|
#include "DebugStrategy.h"
|
|
#include "DpsAssistStrategy.h"
|
|
#include "DuelStrategy.h"
|
|
#include "EmoteStrategy.h"
|
|
#include "FleeStrategy.h"
|
|
#include "FocusTargetStrategy.h"
|
|
#include "FollowMasterStrategy.h"
|
|
#include "GrindingStrategy.h"
|
|
#include "GroupStrategy.h"
|
|
#include "GuardStrategy.h"
|
|
#include "GuildStrategy.h"
|
|
#include "KiteStrategy.h"
|
|
#include "LfgStrategy.h"
|
|
#include "LootNonCombatStrategy.h"
|
|
#include "MaintenanceStrategy.h"
|
|
#include "MarkRtiStrategy.h"
|
|
#include "MeleeCombatStrategy.h"
|
|
#include "MoveFromGroupStrategy.h"
|
|
#include "NamedObjectContext.h"
|
|
#include "NewRpgStrategy.h"
|
|
#include "NonCombatStrategy.h"
|
|
#include "PassiveStrategy.h"
|
|
#include "PullStrategy.h"
|
|
#include "QuestStrategies.h"
|
|
#include "RTSCStrategy.h"
|
|
#include "RacialsStrategy.h"
|
|
#include "RangedCombatStrategy.h"
|
|
#include "ReturnStrategy.h"
|
|
#include "RpgStrategy.h"
|
|
#include "RunawayStrategy.h"
|
|
#include "StayStrategy.h"
|
|
#include "TankAssistStrategy.h"
|
|
#include "TellTargetStrategy.h"
|
|
#include "ThreatStrategy.h"
|
|
#include "TravelStrategy.h"
|
|
#include "UseFoodStrategy.h"
|
|
#include "UsePotionsStrategy.h"
|
|
#include "WaitForAttackStrategy.h"
|
|
#include "WorldPacketHandlerStrategy.h"
|
|
|
|
class StrategyContext : public NamedObjectContext<Strategy>
|
|
{
|
|
public:
|
|
StrategyContext()
|
|
{
|
|
creators["racials"] = &StrategyContext::racials;
|
|
creators["loot"] = &StrategyContext::loot;
|
|
creators["gather"] = &StrategyContext::gather;
|
|
creators["emote"] = &StrategyContext::emote;
|
|
creators["passive"] = &StrategyContext::passive;
|
|
creators["aggressive"] = &StrategyContext::aggressive;
|
|
creators["save mana"] = &StrategyContext::auto_save_mana;
|
|
creators["food"] = &StrategyContext::food;
|
|
creators["chat"] = &StrategyContext::chat;
|
|
creators["default"] = &StrategyContext::world_packet;
|
|
creators["ready check"] = &StrategyContext::ready_check;
|
|
creators["dead"] = &StrategyContext::dead;
|
|
creators["flee"] = &StrategyContext::flee;
|
|
creators["duel"] = &StrategyContext::duel;
|
|
creators["start duel"] = &StrategyContext::start_duel;
|
|
creators["kite"] = &StrategyContext::kite;
|
|
creators["potions"] = &StrategyContext::potions;
|
|
creators["cast time"] = &StrategyContext::cast_time;
|
|
creators["threat"] = &StrategyContext::threat;
|
|
creators["focus"] = &StrategyContext::focus;
|
|
creators["tell target"] = &StrategyContext::tell_target;
|
|
creators["pvp"] = &StrategyContext::pvp;
|
|
creators["return"] = &StrategyContext::_return;
|
|
creators["lfg"] = &StrategyContext::lfg;
|
|
creators["custom"] = &StrategyContext::custom;
|
|
creators["reveal"] = &StrategyContext::reveal;
|
|
creators["collision"] = &StrategyContext::collision;
|
|
creators["rpg"] = &StrategyContext::rpg;
|
|
creators["new rpg"] = &StrategyContext::new_rpg;
|
|
creators["travel"] = &StrategyContext::travel;
|
|
creators["explore"] = &StrategyContext::explore;
|
|
creators["map"] = &StrategyContext::map;
|
|
creators["map full"] = &StrategyContext::map_full;
|
|
creators["sit"] = &StrategyContext::sit;
|
|
creators["mark rti"] = &StrategyContext::mark_rti;
|
|
creators["adds"] = &StrategyContext::possible_adds;
|
|
creators["pull back"] = &StrategyContext::pull_back;
|
|
creators["close"] = &StrategyContext::close;
|
|
creators["ranged"] = &StrategyContext::ranged;
|
|
creators["behind"] = &StrategyContext::behind;
|
|
creators["bg"] = &StrategyContext::bg;
|
|
creators["battleground"] = &StrategyContext::battleground;
|
|
creators["warsong"] = &StrategyContext::warsong;
|
|
creators["alterac"] = &StrategyContext::alterac;
|
|
creators["arathi"] = &StrategyContext::arathi;
|
|
creators["eye"] = &StrategyContext::eye;
|
|
creators["isle"] = &StrategyContext::isle;
|
|
creators["arena"] = &StrategyContext::arena;
|
|
creators["mount"] = &StrategyContext::mount;
|
|
creators["rtsc"] = &StrategyContext::rtsc;
|
|
creators["attack tagged"] = &StrategyContext::attack_tagged;
|
|
creators["debug"] = &StrategyContext::debug;
|
|
creators["debug move"] = &StrategyContext::debug_move;
|
|
creators["debug rpg"] = &StrategyContext::debug_rpg;
|
|
creators["debug spell"] = &StrategyContext::debug_spell;
|
|
creators["debug quest"] = &StrategyContext::debug_quest;
|
|
creators["maintenance"] = &StrategyContext::maintenance;
|
|
creators["group"] = &StrategyContext::group;
|
|
creators["guild"] = &StrategyContext::guild;
|
|
creators["grind"] = &StrategyContext::grind;
|
|
creators["avoid aoe"] = &StrategyContext::avoid_aoe;
|
|
creators["tank face"] = &StrategyContext::tank_face;
|
|
creators["move random"] = &StrategyContext::move_random;
|
|
creators["formation"] = &StrategyContext::combat_formation;
|
|
creators["move from group"] = &StrategyContext::move_from_group;
|
|
creators["worldbuff"] = &StrategyContext::world_buff;
|
|
creators["use bobber"] = &StrategyContext::bobber_strategy;
|
|
creators["master fishing"] = &StrategyContext::master_fishing;
|
|
creators["wait for attack"] = &StrategyContext::wait_for_attack;
|
|
creators["focus heal targets"] = &StrategyContext::focus_heal_targets;
|
|
}
|
|
|
|
private:
|
|
static Strategy* behind(PlayerbotAI* botAI) { return new SetBehindCombatStrategy(botAI); }
|
|
static Strategy* ranged(PlayerbotAI* botAI) { return new RangedCombatStrategy(botAI); }
|
|
static Strategy* close(PlayerbotAI* botAI) { return new MeleeCombatStrategy(botAI); }
|
|
static Strategy* mark_rti(PlayerbotAI* botAI) { return new MarkRtiStrategy(botAI); }
|
|
static Strategy* tell_target(PlayerbotAI* botAI) { return new TellTargetStrategy(botAI); }
|
|
static Strategy* threat(PlayerbotAI* botAI) { return new ThreatStrategy(botAI); }
|
|
static Strategy* focus(PlayerbotAI* botAI) { return new FocusStrategy(botAI); }
|
|
static Strategy* cast_time(PlayerbotAI* botAI) { return new CastTimeStrategy(botAI); }
|
|
static Strategy* potions(PlayerbotAI* botAI) { return new UsePotionsStrategy(botAI); }
|
|
static Strategy* kite(PlayerbotAI* botAI) { return new KiteStrategy(botAI); }
|
|
static Strategy* duel(PlayerbotAI* botAI) { return new DuelStrategy(botAI); }
|
|
static Strategy* start_duel(PlayerbotAI* botAI) { return new StartDuelStrategy(botAI); }
|
|
static Strategy* flee(PlayerbotAI* botAI) { return new FleeStrategy(botAI); }
|
|
static Strategy* dead(PlayerbotAI* botAI) { return new DeadStrategy(botAI); }
|
|
static Strategy* racials(PlayerbotAI* botAI) { return new RacialsStrategy(botAI); }
|
|
static Strategy* loot(PlayerbotAI* botAI) { return new LootNonCombatStrategy(botAI); }
|
|
static Strategy* gather(PlayerbotAI* botAI) { return new GatherStrategy(botAI); }
|
|
static Strategy* emote(PlayerbotAI* botAI) { return new EmoteStrategy(botAI); }
|
|
static Strategy* passive(PlayerbotAI* botAI) { return new PassiveStrategy(botAI); }
|
|
static Strategy* aggressive(PlayerbotAI* botAI) { return new AggressiveStrategy(botAI); }
|
|
// static Strategy* conserve_mana(PlayerbotAI* botAI) { return new ConserveManaStrategy(botAI); }
|
|
static Strategy* auto_save_mana(PlayerbotAI* botAI) { return new HealerAutoSaveManaStrategy(botAI); }
|
|
static Strategy* food(PlayerbotAI* botAI) { return new UseFoodStrategy(botAI); }
|
|
static Strategy* chat(PlayerbotAI* botAI) { return new ChatCommandHandlerStrategy(botAI); }
|
|
static Strategy* world_packet(PlayerbotAI* botAI) { return new WorldPacketHandlerStrategy(botAI); }
|
|
static Strategy* ready_check(PlayerbotAI* botAI) { return new ReadyCheckStrategy(botAI); }
|
|
static Strategy* pvp(PlayerbotAI* botAI) { return new AttackEnemyPlayersStrategy(botAI); }
|
|
static Strategy* _return(PlayerbotAI* botAI) { return new ReturnStrategy(botAI); }
|
|
static Strategy* lfg(PlayerbotAI* botAI) { return new LfgStrategy(botAI); }
|
|
static Strategy* custom(PlayerbotAI* botAI) { return new CustomStrategy(botAI); }
|
|
static Strategy* reveal(PlayerbotAI* botAI) { return new RevealStrategy(botAI); }
|
|
static Strategy* collision(PlayerbotAI* botAI) { return new CollisionStrategy(botAI); }
|
|
static Strategy* rpg(PlayerbotAI* botAI) { return new RpgStrategy(botAI); }
|
|
static Strategy* new_rpg(PlayerbotAI* botAI) { return new NewRpgStrategy(botAI); }
|
|
static Strategy* travel(PlayerbotAI* botAI) { return new TravelStrategy(botAI); }
|
|
static Strategy* explore(PlayerbotAI* botAI) { return new ExploreStrategy(botAI); }
|
|
static Strategy* map(PlayerbotAI* botAI) { return new MapStrategy(botAI); }
|
|
static Strategy* map_full(PlayerbotAI* botAI) { return new MapFullStrategy(botAI); }
|
|
static Strategy* sit(PlayerbotAI* botAI) { return new SitStrategy(botAI); }
|
|
static Strategy* possible_adds(PlayerbotAI* botAI) { return new PossibleAddsStrategy(botAI); }
|
|
static Strategy* pull_back(PlayerbotAI* botAI) { return new PullBackStrategy(botAI); }
|
|
static Strategy* mount(PlayerbotAI* botAI) { return new MountStrategy(botAI); }
|
|
static Strategy* bg(PlayerbotAI* botAI) { return new BGStrategy(botAI); }
|
|
static Strategy* battleground(PlayerbotAI* botAI) { return new BattlegroundStrategy(botAI); }
|
|
static Strategy* warsong(PlayerbotAI* botAI) { return new WarsongStrategy(botAI); }
|
|
static Strategy* alterac(PlayerbotAI* botAI) { return new AlteracStrategy(botAI); }
|
|
static Strategy* arathi(PlayerbotAI* botAI) { return new ArathiStrategy(botAI); }
|
|
static Strategy* eye(PlayerbotAI* botAI) { return new EyeStrategy(botAI); }
|
|
static Strategy* isle(PlayerbotAI* botAI) { return new IsleStrategy(botAI); }
|
|
static Strategy* arena(PlayerbotAI* botAI) { return new ArenaStrategy(botAI); }
|
|
static Strategy* rtsc(PlayerbotAI* botAI) { return new RTSCStrategy(botAI); }
|
|
static Strategy* attack_tagged(PlayerbotAI* botAI) { return new AttackTaggedStrategy(botAI); }
|
|
static Strategy* debug(PlayerbotAI* botAI) { return new DebugStrategy(botAI); }
|
|
static Strategy* debug_move(PlayerbotAI* botAI) { return new DebugMoveStrategy(botAI); }
|
|
static Strategy* debug_rpg(PlayerbotAI* botAI) { return new DebugRpgStrategy(botAI); }
|
|
static Strategy* debug_spell(PlayerbotAI* botAI) { return new DebugSpellStrategy(botAI); }
|
|
static Strategy* debug_quest(PlayerbotAI* botAI) { return new DebugQuestStrategy(botAI); }
|
|
static Strategy* maintenance(PlayerbotAI* botAI) { return new MaintenanceStrategy(botAI); }
|
|
static Strategy* group(PlayerbotAI* botAI) { return new GroupStrategy(botAI); }
|
|
static Strategy* guild (PlayerbotAI* botAI) { return new GuildStrategy(botAI); }
|
|
static Strategy* grind(PlayerbotAI* botAI) { return new GrindingStrategy(botAI); }
|
|
static Strategy* avoid_aoe(PlayerbotAI* botAI) { return new AvoidAoeStrategy(botAI); }
|
|
static Strategy* tank_face(PlayerbotAI* botAI) { return new TankFaceStrategy(botAI); }
|
|
static Strategy* move_random(PlayerbotAI* botAI) { return new MoveRandomStrategy(botAI); }
|
|
static Strategy* combat_formation(PlayerbotAI* botAI) { return new CombatFormationStrategy(botAI); }
|
|
static Strategy* move_from_group(PlayerbotAI* botAI) { return new MoveFromGroupStrategy(botAI); }
|
|
static Strategy* world_buff(PlayerbotAI* botAI) { return new WorldBuffStrategy(botAI); }
|
|
static Strategy* bobber_strategy(PlayerbotAI* botAI) { return new UseBobberStrategy(botAI); }
|
|
static Strategy* master_fishing(PlayerbotAI* botAI) { return new MasterFishingStrategy(botAI); }
|
|
static Strategy* wait_for_attack(PlayerbotAI* botAI) { return new WaitForAttackStrategy(botAI); }
|
|
static Strategy* focus_heal_targets(PlayerbotAI* botAI) { return new FocusHealTargetsStrategy(botAI); }
|
|
};
|
|
|
|
class MovementStrategyContext : public NamedObjectContext<Strategy>
|
|
{
|
|
public:
|
|
MovementStrategyContext() : NamedObjectContext<Strategy>(false, true)
|
|
{
|
|
creators["follow"] = &MovementStrategyContext::follow_master;
|
|
creators["stay"] = &MovementStrategyContext::stay;
|
|
creators["runaway"] = &MovementStrategyContext::runaway;
|
|
creators["flee from adds"] = &MovementStrategyContext::flee_from_adds;
|
|
creators["guard"] = &MovementStrategyContext::guard;
|
|
}
|
|
|
|
private:
|
|
static Strategy* guard(PlayerbotAI* botAI) { return new GuardStrategy(botAI); }
|
|
static Strategy* follow_master(PlayerbotAI* botAI) { return new FollowMasterStrategy(botAI); }
|
|
static Strategy* stay(PlayerbotAI* botAI) { return new StayStrategy(botAI); }
|
|
static Strategy* runaway(PlayerbotAI* botAI) { return new RunawayStrategy(botAI); }
|
|
static Strategy* flee_from_adds(PlayerbotAI* botAI) { return new FleeFromAddsStrategy(botAI); }
|
|
};
|
|
|
|
class AssistStrategyContext : public NamedObjectContext<Strategy>
|
|
{
|
|
public:
|
|
AssistStrategyContext() : NamedObjectContext<Strategy>(false, true)
|
|
{
|
|
creators["dps assist"] = &AssistStrategyContext::dps_assist;
|
|
creators["dps aoe"] = &AssistStrategyContext::dps_aoe;
|
|
creators["tank assist"] = &AssistStrategyContext::tank_assist;
|
|
}
|
|
|
|
private:
|
|
static Strategy* dps_assist(PlayerbotAI* botAI) { return new DpsAssistStrategy(botAI); }
|
|
static Strategy* dps_aoe(PlayerbotAI* botAI) { return new DpsAoeStrategy(botAI); }
|
|
static Strategy* tank_assist(PlayerbotAI* botAI) { return new TankAssistStrategy(botAI); }
|
|
};
|
|
|
|
class QuestStrategyContext : public NamedObjectContext<Strategy>
|
|
{
|
|
public:
|
|
QuestStrategyContext() : NamedObjectContext<Strategy>(false, true)
|
|
{
|
|
creators["quest"] = &QuestStrategyContext::quest;
|
|
creators["accept all quests"] = &QuestStrategyContext::accept_all_quests;
|
|
}
|
|
|
|
private:
|
|
static Strategy* quest(PlayerbotAI* botAI) { return new DefaultQuestStrategy(botAI); }
|
|
static Strategy* accept_all_quests(PlayerbotAI* botAI) { return new AcceptAllQuestsStrategy(botAI); }
|
|
};
|
|
|
|
#endif
|