Skip to content

Conversation

@kadeshar
Copy link
Owner

Pull Request

Describe what this change does and why it is needed...


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?

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

Complexity & Impact

Does this change add new decision branches?

    • No
    • Yes (explain below)

Does this change increase per-bot or per-tick processing?

    • No
    • Yes (describe and justify impact)

Could this logic scale poorly under load?

    • No
    • Yes (explain why)

Defaults & Configuration

Does this change modify default bot behavior?

    • No
    • Yes (explain why)

If this introduces more advanced or AI-heavy logic:

    • Lightweight mode remains the default
    • More complex behavior is optional and thereby configurable

AI Assistance

Was AI assistance (e.g. ChatGPT or similar tools) used while working on this change?

    • No
    • 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

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

    • Stability is not compromised
    • Performance impact is understood, tested, and acceptable
    • Added logic complexity is justified and explained
    • 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.

Copilot AI review requested due to automatic review settings February 10, 2026 19:15
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors “trainer” behavior/configuration for playerbots by simplifying the train trigger logic, adding a reusable “can train” value, and reworking the trainer action to support explicit target selection (master vs bot) and trainer validation.

Changes:

  • Replaced AiPlayerbot.AutoTrainSpells (string) with AiPlayerbot.AllowLearnTrainerSpells (bool) and updated config initialization + conf template.
  • Added CanTrainValue and wired it into ValueContext, then simplified RpgTrainTrigger to rely on that value.
  • Refactored TrainerAction and RpgTrainAction to centralize validation/affordability checks and streamline spell iteration/learning.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/PlayerbotAIConfig.h Replaces autoTrainSpells string with allowLearnTrainerSpells bool.
src/PlayerbotAIConfig.cpp Loads the new AiPlayerbot.AllowLearnTrainerSpells config option.
src/Ai/World/Rpg/Action/NewRpgBaseAction.cpp Simplifies questgiver interaction checks (removes trainer-related logic from this path).
src/Ai/Base/ValueContext.h Registers new "can train" value creator.
src/Ai/Base/Value/MaintenanceValues.h Adds CanTrainValue declaration.
src/Ai/Base/Value/MaintenanceValues.cpp Implements CanTrainValue based on free money for spells.
src/Ai/Base/Value/LogLevelValue.h Adds missing include for logging common definitions.
src/Ai/Base/Value/BudgetValues.cpp Refactors train/repair cost calculations; changes trainer scan logic.
src/Ai/Base/Trigger/RpgTriggers.h Removes RpgTrainTrigger::IsTrainerOf declaration.
src/Ai/Base/Trigger/RpgTriggers.cpp Simplifies train trigger to use "can train" and basic trainer flag check.
src/Ai/Base/Actions/TrainerAction.h Refactors trainer action interface and private helpers.
src/Ai/Base/Actions/TrainerAction.cpp Refactors execution/validation/learning flow and target selection logic.
src/Ai/Base/Actions/RpgSubActions.h Adds isPossible/isUseful overrides for RpgTrainAction.
src/Ai/Base/Actions/RpgSubActions.cpp Implements trainer affordability/teachability checks for RPG train action.
conf/playerbots.conf.dist Updates documentation and default for AiPlayerbot.AllowLearnTrainerSpells.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 18 to 20
Creature* target = GetTarget()->ToCreature();
if (!target)
return false;
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetTarget() can return nullptr (no selection by bot/master), but GetTarget()->ToCreature() dereferences it unconditionally. This can crash in Execute() (and the same pattern is used in isUseful() / isPossible()). Store the Unit* returned by GetTarget() and null-check it before calling ToCreature()/accessing it.

Copilot uses AI. Check for mistakes.
Comment on lines 63 to 67
if (trainer->GetSpells().empty())
{
if (spellInfo->Effects[j].Effect == SPELL_EFFECT_LEARN_SPELL)
{
uint32 learnedSpell = spellInfo->Effects[j].TriggerSpell;
if (!bot->HasSpell(learnedSpell))
{
bot->learnSpell(learnedSpell);
learned = true;
}
}
// Not sure why we need to say anything, especially w/o master
botAI->TellError("No spells can be learned from this trainer");
return false;
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isPossible() should ideally be side-effect free, but it calls botAI->TellError(...). Since isPossible() is used during regular action selection (not just on explicit command execution), this can generate repeated error notifications. Consider moving this message to Execute() (only when the trainer action is actually run), or gate it behind an explicit player command / debug mode.

Copilot uses AI. Check for mistakes.
Comment on lines +106 to 108
if (!(itr->second.npcflag & UNIT_NPC_FLAG_TRAINER))
continue;

Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TrainCostValue::Calculate() now skips creature templates unless npcflag contains UNIT_NPC_FLAG_TRAINER. Other parts of the codebase iterate all templates and rely on sObjectMgr->GetTrainer(entry) (e.g., PlayerbotFactory::InitAvailableSpells()), so this filter can cause train cost to be undercounted for trainers that exist but don't have this specific flag set (or use other trainer-related flags). Consider removing the npcflag filter, or expanding it to include all trainer-related flags you expect (class/profession/etc).

Suggested change
if (!(itr->second.npcflag & UNIT_NPC_FLAG_TRAINER))
continue;

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants