mirror of
https://github.com/liyunfan1223/mod-playerbots.git
synced 2026-06-20 15:39:25 +02:00
# Pull Request Note: When I reference Aspect of the Hawk below, it also means Aspect of the Dragonhawk (the code will use Dragonhawk if the Hunter has it, Hawk if not, they share actions, triggers, and strategies). Hunter Aspects are currently bugged. All Hunters, regardless of spec or strategy, are hardcoded to use Aspect of the Hawk when mana is at 70%+ and Aspect of the Viper when mana drops to "lowMana" from the config (default is 15%), divided by 2. This means the following: - Hawk (bdps) and Viper (bmana) strategies are useless - Pack (bspeed) and Wild (rnature) strategies are applied, but bots will rapidly switch back and forth between Pack/Wild and Hawk/Viper, depending on strategy and mana level. This PR addresses the issues by doing the following: - Global Hawk strategy is removed. Now you need to set bdps for Hunters to use Hawk, but bdps remains the default Aspect strategy for all Hunters. - Dedicated Viper strategy is removed, leaving the global strategy. However, Viper will be used (when lowMana/2) ONLY if the bot is set to bdps. If the bot has the Wild or Pack strategy, they will not switch to Viper at all. I did this because I am assuming if you are using Wild or Pack, you need them for reasons other than to pump DPS. - The threshold to switch back to Hawk is lowered from 70% to 60%. The gap between lowMana/2 and 60% is now filled--if bdps is on, Hunters will switch to Hawk whenever above the Viper threshold, _except_ for when they have the Viper aura, in which case they will not switch to Hawk until 60% mana. This lets the Hunter build back mana before swapping back to Hawk (more like general player behavior) while still letting them swap from other Aspects to Hawk without needing to be all the way at 60% mana. - Gets rid of a weird condition in the Hawk trigger that would make it so that Hunters would switch to Hawk when at exactly 0 mana. I'm not sure what the point of that is. Also, I refactored the triggers a bit because I noticed there was some dead code in there. I didn't do a comprehensive refactor, but there was a lot of stuff that clearly didn't make sense even to my eyes, like back-to-back returns. I think there's more unnecessary code even just in the triggers, but I didn't want to get too into the weeds with this PR. --- ## 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 don't expect there to be any impact on costs, and if anything this PR removes some unneeded checks from triggers. --- ## 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 The easiest way is to go shoot a dummy with Volley until low on mana and then toggle on selfbot. You can do this with various Aspects active to test. ## Complexity & Impact Does this change add new decision branches? - - [X] No - - [ ] Yes (**explain below**) Does this change increase per-bot or per-tick processing? - - [X] No - - [ ] Yes (**describe and justify impact**) Could this logic scale poorly under load? - - [X] No - - [ ] Yes (**explain why**) --- ## Defaults & Configuration Does this change modify default bot behavior? - - [ ] No - - [X] Yes (**explain why**) Described above. Default behavior is broken. If this introduces more advanced or AI-heavy logic: - - [X] 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 - - [X] Yes (**explain below**) I asked Claude some questions about the triggers to make sure I didn't screw anything up. 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 - - [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>
189 lines
5.3 KiB
C++
189 lines
5.3 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 "HunterTriggers.h"
|
|
#include "GenericSpellActions.h"
|
|
#include "GenericTriggers.h"
|
|
#include "HunterActions.h"
|
|
#include "PlayerbotAI.h"
|
|
#include "PlayerbotAIConfig.h"
|
|
#include "Playerbots.h"
|
|
#include "ServerFacade.h"
|
|
#include "SharedDefines.h"
|
|
#include "Player.h"
|
|
|
|
bool KillCommandTrigger::IsActive()
|
|
{
|
|
return !botAI->HasAura("kill command", GetTarget());
|
|
}
|
|
|
|
bool BlackArrowTrigger::IsActive()
|
|
{
|
|
if (botAI->HasStrategy("trap weave", BOT_STATE_COMBAT))
|
|
return false;
|
|
|
|
return DebuffTrigger::IsActive();
|
|
}
|
|
|
|
bool HunterAspectOfTheDragonhawkTrigger::IsActive()
|
|
{
|
|
Unit* target = GetTarget();
|
|
if (!target)
|
|
return false;
|
|
|
|
if (!SpellTrigger::IsActive())
|
|
return false;
|
|
|
|
if (botAI->HasAura("aspect of the hawk", target) ||
|
|
botAI->HasAura("aspect of the dragonhawk", target))
|
|
return false;
|
|
|
|
if (botAI->HasAura("aspect of the viper", target))
|
|
return AI_VALUE2(uint8, "mana", "self target") >= 60;
|
|
|
|
return true;
|
|
}
|
|
|
|
bool HunterNoStingsActiveTrigger::IsActive()
|
|
{
|
|
Unit* target = AI_VALUE(Unit*, "current target");
|
|
return DebuffTrigger::IsActive() && target &&
|
|
!botAI->HasAura("serpent sting", target, false, true) &&
|
|
!botAI->HasAura("scorpid sting", target, false, true) &&
|
|
!botAI->HasAura("viper sting", target, false, true);
|
|
}
|
|
|
|
bool HuntersPetDeadTrigger::IsActive()
|
|
{
|
|
return AI_VALUE(bool, "pet dead") && !AI_VALUE2(bool, "mounted", "self target");
|
|
}
|
|
|
|
bool HuntersPetLowHealthTrigger::IsActive()
|
|
{
|
|
Unit* pet = AI_VALUE(Unit*, "pet target");
|
|
return pet && AI_VALUE2(uint8, "health", "pet target") < 40 &&
|
|
!AI_VALUE2(bool, "dead", "pet target") &&
|
|
!AI_VALUE2(bool, "mounted", "self target");
|
|
}
|
|
|
|
bool HuntersPetMediumHealthTrigger::IsActive()
|
|
{
|
|
Unit* pet = AI_VALUE(Unit*, "pet target");
|
|
return pet && AI_VALUE2(uint8, "health", "pet target") < sPlayerbotAIConfig.mediumHealth &&
|
|
!AI_VALUE2(bool, "dead", "pet target") && !AI_VALUE2(bool, "mounted", "self target");
|
|
}
|
|
|
|
bool HunterPetNotHappy::IsActive()
|
|
{
|
|
return !AI_VALUE(bool, "pet happy") && !AI_VALUE2(bool, "mounted", "self target");
|
|
}
|
|
|
|
bool HunterAspectOfTheViperTrigger::IsActive()
|
|
{
|
|
if (botAI->HasStrategy("rnature", BotState::BOT_STATE_COMBAT) ||
|
|
botAI->HasStrategy("rnature", BotState::BOT_STATE_NON_COMBAT) ||
|
|
botAI->HasStrategy("bspeed", BotState::BOT_STATE_COMBAT) ||
|
|
botAI->HasStrategy("bspeed", BotState::BOT_STATE_NON_COMBAT))
|
|
return false;
|
|
|
|
return BuffTrigger::IsActive() &&
|
|
AI_VALUE2(uint8, "mana", "self target") < (sPlayerbotAIConfig.lowMana / 2);
|
|
}
|
|
|
|
bool HunterAspectOfThePackTrigger::IsActive()
|
|
{
|
|
return BuffTrigger::IsActive() && !botAI->HasAura("aspect of the cheetah", GetTarget());
|
|
};
|
|
|
|
bool HunterLowAmmoTrigger::IsActive()
|
|
{
|
|
uint32 ammoCount = AI_VALUE2(uint32, "item count", "ammo");
|
|
return bot->GetGroup() && ammoCount > 0 && ammoCount < 100;
|
|
}
|
|
|
|
bool HunterHasAmmoTrigger::IsActive()
|
|
{
|
|
return !AmmoCountTrigger::IsActive();
|
|
}
|
|
|
|
bool SwitchToRangedTrigger::IsActive()
|
|
{
|
|
Unit* target = AI_VALUE(Unit*, "current target");
|
|
return botAI->HasStrategy("close", BOT_STATE_COMBAT) && target &&
|
|
(target->GetVictim() != bot &&
|
|
ServerFacade::instance().IsDistanceGreaterThan(AI_VALUE2(float, "distance", "current target"), 8.0f));
|
|
}
|
|
|
|
bool SwitchToMeleeTrigger::IsActive()
|
|
{
|
|
Unit* target = AI_VALUE(Unit*, "current target");
|
|
return botAI->HasStrategy("ranged", BOT_STATE_COMBAT) && target &&
|
|
(target->GetVictim() == bot &&
|
|
ServerFacade::instance().IsDistanceLessOrEqualThan(AI_VALUE2(float, "distance", "current target"), 8.0f));
|
|
}
|
|
|
|
// Valid targets for "Improved Tracking".
|
|
// Optional/Utility targets (uncomment for selfbot).
|
|
bool NoTrackTrigger::IsActive()
|
|
{
|
|
std::vector<std::string> track_list = {
|
|
"track beasts",
|
|
"track demons",
|
|
"track dragonkin",
|
|
"track elementals",
|
|
"track giants",
|
|
"track humanoids",
|
|
"track undead",
|
|
// "track hidden",
|
|
// "find herbs",
|
|
// "find minerals",
|
|
// "find fish",
|
|
// "find treasure",
|
|
};
|
|
|
|
for (auto &track: track_list)
|
|
{
|
|
if (botAI->HasAura(track, bot))
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
bool SerpentStingOnAttackerTrigger::IsActive()
|
|
{
|
|
if (!DebuffOnAttackerTrigger::IsActive())
|
|
return false;
|
|
|
|
Unit* target = GetTarget();
|
|
if (!target)
|
|
return false;
|
|
|
|
return !botAI->HasAura("scorpid sting", target, false, true) &&
|
|
!botAI->HasAura("viper sting", target, false, true);
|
|
}
|
|
|
|
const std::set<uint32> VolleyChannelCheckTrigger::VOLLEY_SPELL_IDS =
|
|
{
|
|
1510, // Volley Rank 1
|
|
14294, // Volley Rank 2
|
|
14295, // Volley Rank 3
|
|
27022, // Volley Rank 4
|
|
58431, // Volley Rank 5
|
|
58434 // Volley Rank 6
|
|
};
|
|
|
|
bool VolleyChannelCheckTrigger::IsActive()
|
|
{
|
|
if (Spell* spell = bot->GetCurrentSpell(CURRENT_CHANNELED_SPELL);
|
|
spell && VOLLEY_SPELL_IDS.count(spell->m_spellInfo->Id))
|
|
{
|
|
uint8 attackerCount = AI_VALUE(uint8, "attacker count");
|
|
return attackerCount < minEnemies;
|
|
}
|
|
|
|
return false;
|
|
}
|