Fix action validation checks: isUseful -> isPossible + codestyle fixes and corrections (#2125)

# Pull Request

Fix the incorrect logic flaw when processing actions from different
sources. It should be: `isUseful` -> `isPossible`. The original logic is
based on the Mangosbot code and the impl presented inside
`Engine::DoNextAction`. This should fix all wrong validation orders for
triggers and direct/specific actions.

Code style is based on the AzerothCore style guide + clang-format.

---

## 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?
- - [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?
- - [x] 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?
- - [x] 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

- - [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.
This commit is contained in:
privatecore 2026-02-13 18:24:11 +01:00 committed by GitHub
parent 80b3823f12
commit a0a50204ec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
19 changed files with 272 additions and 247 deletions

View File

@ -55,63 +55,6 @@ MountData CollectMountData(const Player* bot)
return data; return data;
} }
bool CheckMountStateAction::isUseful()
{
// Not useful when:
if (botAI->IsInVehicle() || bot->isDead() || bot->HasUnitState(UNIT_STATE_IN_FLIGHT) ||
!bot->IsOutdoors() || bot->InArena())
return false;
master = GetMaster();
// Get shapeshift states, only applicable when there's a master
if (master)
{
botInShapeshiftForm = bot->GetShapeshiftForm();
masterInShapeshiftForm = master->GetShapeshiftForm();
}
// Not useful when in combat and not currently mounted / travel formed
if ((bot->IsInCombat() || botAI->GetState() == BOT_STATE_COMBAT) &&
!bot->IsMounted() && botInShapeshiftForm != FORM_TRAVEL && botInShapeshiftForm != FORM_FLIGHT && botInShapeshiftForm != FORM_FLIGHT_EPIC)
return false;
// In addition to checking IsOutdoors, also check whether bot is clipping below floor slightly because that will
// cause bot to falsly indicate they are outdoors. This fixes bug where bot tries to mount indoors (which seems
// to mostly be an issue in tunnels of WSG and AV)
float posZ = bot->GetPositionZ();
float groundLevel = bot->GetMapWaterOrGroundLevel(bot->GetPositionX(), bot->GetPositionY(), posZ);
if (!bot->IsMounted() && !bot->HasWaterWalkAura() && posZ < groundLevel)
return false;
// Not useful when bot does not have mount strat and is not currently mounted
if (!GET_PLAYERBOT_AI(bot)->HasStrategy("mount", BOT_STATE_NON_COMBAT) && !bot->IsMounted())
return false;
// Not useful when level lower than minimum required
if (bot->GetLevel() < sPlayerbotAIConfig.useGroundMountAtMinLevel)
return false;
// Allow mounting while transformed only if the form allows it
if (bot->HasAuraType(SPELL_AURA_TRANSFORM) && bot->IsInDisallowedMountForm())
return false;
// BG Logic
if (bot->InBattleground())
{
// Do not use when carrying BG Flags
if (bot->HasAura(BG_WS_SPELL_WARSONG_FLAG) || bot->HasAura(BG_WS_SPELL_SILVERWING_FLAG) || bot->HasAura(BG_EY_NETHERSTORM_FLAG_SPELL))
return false;
// Only mount if BG starts in less than 30 sec
if (Battleground* bg = bot->GetBattleground())
if (bg->GetStatus() == STATUS_WAIT_JOIN && bg->GetStartDelayTime() > BG_START_DELAY_30S)
return false;
}
return true;
}
bool CheckMountStateAction::Execute(Event /*event*/) bool CheckMountStateAction::Execute(Event /*event*/)
{ {
// Determine if there are no attackers // Determine if there are no attackers
@ -182,6 +125,63 @@ bool CheckMountStateAction::Execute(Event /*event*/)
return false; return false;
} }
bool CheckMountStateAction::isUseful()
{
// Not useful when:
if (botAI->IsInVehicle() || bot->isDead() || bot->HasUnitState(UNIT_STATE_IN_FLIGHT) ||
!bot->IsOutdoors() || bot->InArena())
return false;
master = GetMaster();
// Get shapeshift states, only applicable when there's a master
if (master)
{
botInShapeshiftForm = bot->GetShapeshiftForm();
masterInShapeshiftForm = master->GetShapeshiftForm();
}
// Not useful when in combat and not currently mounted / travel formed
if ((bot->IsInCombat() || botAI->GetState() == BOT_STATE_COMBAT) &&
!bot->IsMounted() && botInShapeshiftForm != FORM_TRAVEL && botInShapeshiftForm != FORM_FLIGHT && botInShapeshiftForm != FORM_FLIGHT_EPIC)
return false;
// In addition to checking IsOutdoors, also check whether bot is clipping below floor slightly because that will
// cause bot to falsly indicate they are outdoors. This fixes bug where bot tries to mount indoors (which seems
// to mostly be an issue in tunnels of WSG and AV)
float posZ = bot->GetPositionZ();
float groundLevel = bot->GetMapWaterOrGroundLevel(bot->GetPositionX(), bot->GetPositionY(), posZ);
if (!bot->IsMounted() && !bot->HasWaterWalkAura() && posZ < groundLevel)
return false;
// Not useful when bot does not have mount strat and is not currently mounted
if (!GET_PLAYERBOT_AI(bot)->HasStrategy("mount", BOT_STATE_NON_COMBAT) && !bot->IsMounted())
return false;
// Not useful when level lower than minimum required
if (bot->GetLevel() < sPlayerbotAIConfig.useGroundMountAtMinLevel)
return false;
// Allow mounting while transformed only if the form allows it
if (bot->HasAuraType(SPELL_AURA_TRANSFORM) && bot->IsInDisallowedMountForm())
return false;
// BG Logic
if (bot->InBattleground())
{
// Do not use when carrying BG Flags
if (bot->HasAura(BG_WS_SPELL_WARSONG_FLAG) || bot->HasAura(BG_WS_SPELL_SILVERWING_FLAG) || bot->HasAura(BG_EY_NETHERSTORM_FLAG_SPELL))
return false;
// Only mount if BG starts in less than 30 sec
if (Battleground* bg = bot->GetBattleground())
if (bg->GetStatus() == STATUS_WAIT_JOIN && bg->GetStartDelayTime() > BG_START_DELAY_30S)
return false;
}
return true;
}
bool CheckMountStateAction::Mount() bool CheckMountStateAction::Mount()
{ {
// Remove current Shapeshift if need be // Remove current Shapeshift if need be

View File

@ -30,37 +30,6 @@ bool AttackEnemyFlagCarrierAction::isUseful()
PlayerHasFlag::IsCapturingFlag(bot); PlayerHasFlag::IsCapturingFlag(bot);
} }
bool AttackAnythingAction::isUseful()
{
if (!bot || !botAI) // Prevents invalid accesses
return false;
if (!botAI->AllowActivity(GRIND_ACTIVITY)) // Bot cannot be active
return false;
if (botAI->HasStrategy("stay", BOT_STATE_NON_COMBAT))
return false;
if (bot->IsInCombat())
return false;
Unit* target = GetTarget();
if (!target || !target->IsInWorld()) // Checks if the target is valid and in the world
return false;
std::string const name = std::string(target->GetName());
if (!name.empty() &&
(name.find("Dummy") != std::string::npos ||
name.find("Charge Target") != std::string::npos ||
name.find("Melee Target") != std::string::npos ||
name.find("Ranged Target") != std::string::npos))
{
return false;
}
return true;
}
bool DropTargetAction::Execute(Event event) bool DropTargetAction::Execute(Event event)
{ {
Unit* target = context->GetValue<Unit*>("current target")->Get(); Unit* target = context->GetValue<Unit*>("current target")->Get();
@ -127,7 +96,38 @@ bool AttackAnythingAction::Execute(Event event)
return result; return result;
} }
bool AttackAnythingAction::isPossible() { return AttackAction::isPossible() && GetTarget(); } bool AttackAnythingAction::isUseful()
{
if (!bot || !botAI) // Prevents invalid accesses
return false;
if (!botAI->AllowActivity(GRIND_ACTIVITY)) // Bot cannot be active
return false;
if (botAI->HasStrategy("stay", BOT_STATE_NON_COMBAT))
return false;
if (bot->IsInCombat())
return false;
Unit* target = GetTarget();
if (!target || !target->IsInWorld()) // Checks if the target is valid and in the world
return false;
std::string const name = std::string(target->GetName());
if (!name.empty() &&
(name.find("Dummy") != std::string::npos ||
name.find("Charge Target") != std::string::npos ||
name.find("Melee Target") != std::string::npos ||
name.find("Ranged Target") != std::string::npos))
{
return false;
}
return true;
}
bool AttackAnythingAction::isPossible() { return GetTarget() && AttackAction::isPossible(); }
bool DpsAssistAction::isUseful() bool DpsAssistAction::isUseful()
{ {

View File

@ -7,22 +7,24 @@
#define _PLAYERBOT_FISHINGACTION_H #define _PLAYERBOT_FISHINGACTION_H
#include "Action.h" #include "Action.h"
#include "MovementActions.h"
#include "Event.h" #include "Event.h"
#include "MovementActions.h"
#include "Playerbots.h" #include "Playerbots.h"
extern const uint32 FISHING_SPELL; extern const uint32 FISHING_SPELL;
extern const uint32 FISHING_POLE; extern const uint32 FISHING_POLE;
extern const uint32 FISHING_BOBBER; extern const uint32 FISHING_BOBBER;
WorldPosition FindWaterRadial(Player* bot, float x, float y, float z, Map* map, uint32 phaseMask, float minDistance, float maxDistance, float increment, bool checkLOS=false, int numDirections = 16); WorldPosition FindWaterRadial(Player* bot, float x, float y, float z, Map* map, uint32 phaseMask, float minDistance,
float maxDistance, float increment, bool checkLOS = false, int numDirections = 16);
class PlayerbotAI; class PlayerbotAI;
class FishingAction : public Action class FishingAction : public Action
{ {
public: public:
FishingAction(PlayerbotAI* botAI) : Action(botAI, "go fishing"){} FishingAction(PlayerbotAI* botAI) : Action(botAI, "go fishing") {}
bool Execute(Event event) override; bool Execute(Event event) override;
bool isUseful() override; bool isUseful() override;
}; };
@ -31,8 +33,10 @@ class EquipFishingPoleAction : public Action
{ {
public: public:
EquipFishingPoleAction(PlayerbotAI* botAI) : Action(botAI, "equip fishing pole") {} EquipFishingPoleAction(PlayerbotAI* botAI) : Action(botAI, "equip fishing pole") {}
bool Execute(Event event) override; bool Execute(Event event) override;
bool isUseful() override; bool isUseful() override;
private: private:
Item* _pole = nullptr; Item* _pole = nullptr;
}; };
@ -40,7 +44,8 @@ private:
class MoveNearWaterAction : public MovementAction class MoveNearWaterAction : public MovementAction
{ {
public: public:
MoveNearWaterAction(PlayerbotAI* botAI): MovementAction(botAI, "move near water") {} MoveNearWaterAction(PlayerbotAI* botAI) : MovementAction(botAI, "move near water") {}
bool Execute(Event event) override; bool Execute(Event event) override;
bool isUseful() override; bool isUseful() override;
bool isPossible() override; bool isPossible() override;
@ -50,6 +55,7 @@ class UseBobberAction : public Action
{ {
public: public:
UseBobberAction(PlayerbotAI* botAI) : Action(botAI, "use fishing bobber") {} UseBobberAction(PlayerbotAI* botAI) : Action(botAI, "use fishing bobber") {}
bool Execute(Event event) override; bool Execute(Event event) override;
bool isUseful() override; bool isUseful() override;
}; };
@ -58,6 +64,7 @@ class EndMasterFishingAction : public Action
{ {
public: public:
EndMasterFishingAction(PlayerbotAI* botAI) : Action(botAI, "end master fishing") {} EndMasterFishingAction(PlayerbotAI* botAI) : Action(botAI, "end master fishing") {}
bool Execute(Event event) override; bool Execute(Event event) override;
bool isUseful() override; bool isUseful() override;
}; };
@ -66,6 +73,8 @@ class RemoveBobberStrategyAction : public Action
{ {
public: public:
RemoveBobberStrategyAction(PlayerbotAI* botAI) : Action(botAI, "remove bobber strategy") {} RemoveBobberStrategyAction(PlayerbotAI* botAI) : Action(botAI, "remove bobber strategy") {}
bool Execute(Event event) override; bool Execute(Event event) override;
}; };
#endif #endif

View File

@ -78,6 +78,35 @@ bool CastSpellAction::Execute(Event event)
return botAI->CastSpell(spell, GetTarget()); return botAI->CastSpell(spell, GetTarget());
} }
bool CastSpellAction::isUseful()
{
if (botAI->IsInVehicle() && !botAI->IsInVehicle(false, false, true))
return false;
if (spell == "mount" && !bot->IsMounted() && !bot->IsInCombat())
return true;
if (spell == "mount" && bot->IsInCombat())
{
bot->Dismount();
return false;
}
Unit* spellTarget = GetTarget();
if (!spellTarget)
return false;
if (!spellTarget->IsInWorld() || spellTarget->GetMapId() != bot->GetMapId())
return false;
// float combatReach = bot->GetCombatReach() + target->GetCombatReach();
// if (!botAI->IsRanged(bot))
// combatReach += 4.0f / 3.0f;
return AI_VALUE2(bool, "spell cast useful", spell);
// && ServerFacade::instance().GetDistance2d(bot, target) <= (range + combatReach);
}
bool CastSpellAction::isPossible() bool CastSpellAction::isPossible()
{ {
if (botAI->IsInVehicle() && !botAI->IsInVehicle(false, false, true)) if (botAI->IsInVehicle() && !botAI->IsInVehicle(false, false, true))
@ -106,36 +135,6 @@ bool CastSpellAction::isPossible()
return botAI->CanCastSpell(spell, GetTarget()); return botAI->CanCastSpell(spell, GetTarget());
} }
bool CastSpellAction::isUseful()
{
if (botAI->IsInVehicle() && !botAI->IsInVehicle(false, false, true))
return false;
if (spell == "mount" && !bot->IsMounted() && !bot->IsInCombat())
return true;
if (spell == "mount" && bot->IsInCombat())
{
bot->Dismount();
return false;
}
Unit* spellTarget = GetTarget();
if (!spellTarget)
return false;
if (!spellTarget->IsInWorld() || spellTarget->GetMapId() != bot->GetMapId())
return false;
// float combatReach = bot->GetCombatReach() + spellTarget->GetCombatReach();
// if (!botAI->IsRanged(bot))
// combatReach += 4.0f / 3.0f;
return spellTarget &&
AI_VALUE2(bool, "spell cast useful",
spell); // && ServerFacade::instance().GetDistance2d(bot, spellTarget) <= (range + combatReach);
}
CastMeleeSpellAction::CastMeleeSpellAction(PlayerbotAI* botAI, std::string const spell) : CastSpellAction(botAI, spell) CastMeleeSpellAction::CastMeleeSpellAction(PlayerbotAI* botAI, std::string const spell) : CastSpellAction(botAI, spell)
{ {
range = ATTACK_DISTANCE; range = ATTACK_DISTANCE;

View File

@ -23,8 +23,8 @@ public:
std::string const GetTargetName() override { return "current target"; }; std::string const GetTargetName() override { return "current target"; };
bool Execute(Event event) override; bool Execute(Event event) override;
bool isPossible() override;
bool isUseful() override; bool isUseful() override;
bool isPossible() override;
ActionThreatType getThreatType() override { return ActionThreatType::Single; } ActionThreatType getThreatType() override { return ActionThreatType::Single; }
std::vector<NextAction> getPrerequisites() override std::vector<NextAction> getPrerequisites() override

View File

@ -49,17 +49,15 @@ bool DrinkAction::Execute(Event event)
bool DrinkAction::isUseful() bool DrinkAction::isUseful()
{ {
return UseItemAction::isUseful() && return UseItemAction::isUseful() && AI_VALUE2(bool, "has mana", "self target") &&
AI_VALUE2(bool, "has mana", "self target") &&
AI_VALUE2(uint8, "mana", "self target") < 100; AI_VALUE2(uint8, "mana", "self target") < 100;
} }
bool DrinkAction::isPossible() bool DrinkAction::isPossible()
{ {
return !bot->IsInCombat() && return !bot->IsInCombat() && !bot->IsMounted() &&
!bot->IsMounted() && !botAI->HasAnyAuraOf(GetTarget(), "dire bear form", "bear form", "cat form", "travel form", "aquatic form",
!botAI->HasAnyAuraOf(GetTarget(), "dire bear form", "bear form", "cat form", "travel form", "flight form", "swift flight form", nullptr) &&
"aquatic form","flight form", "swift flight form", nullptr) &&
(botAI->HasCheat(BotCheatMask::food) || UseItemAction::isPossible()); (botAI->HasCheat(BotCheatMask::food) || UseItemAction::isPossible());
} }
@ -102,17 +100,12 @@ bool EatAction::Execute(Event event)
return UseItemAction::Execute(event); return UseItemAction::Execute(event);
} }
bool EatAction::isUseful() bool EatAction::isUseful() { return UseItemAction::isUseful() && AI_VALUE2(uint8, "health", "self target") < 100; }
{
return UseItemAction::isUseful() &&
AI_VALUE2(uint8, "health", "self target") < 100;
}
bool EatAction::isPossible() bool EatAction::isPossible()
{ {
return !bot->IsInCombat() && return !bot->IsInCombat() && !bot->IsMounted() &&
!bot->IsMounted() && !botAI->HasAnyAuraOf(GetTarget(), "dire bear form", "bear form", "cat form", "travel form", "aquatic form",
!botAI->HasAnyAuraOf(GetTarget(), "dire bear form", "bear form", "cat form", "travel form", "flight form", "swift flight form", nullptr) &&
"aquatic form","flight form", "swift flight form", nullptr) &&
(botAI->HasCheat(BotCheatMask::food) || UseItemAction::isPossible()); (botAI->HasCheat(BotCheatMask::food) || UseItemAction::isPossible());
} }

View File

@ -85,7 +85,7 @@ bool RpgAction::SetNextRpgAction()
isChecked = true; isChecked = true;
Action* action = botAI->GetAiObjectContext()->GetAction(nextAction.getName()); Action* action = botAI->GetAiObjectContext()->GetAction(nextAction.getName());
if (!dynamic_cast<RpgEnabled*>(action) || !action->isPossible() || !action->isUseful()) if (!dynamic_cast<RpgEnabled*>(action) || !action->isUseful() || !action->isPossible())
continue; continue;
actions.push_back(action); actions.push_back(action);

View File

@ -7,9 +7,9 @@
#include "ChatHelper.h" #include "ChatHelper.h"
#include "Event.h" #include "Event.h"
#include "ItemPackets.h"
#include "ItemUsageValue.h" #include "ItemUsageValue.h"
#include "Playerbots.h" #include "Playerbots.h"
#include "ItemPackets.h"
bool UseItemAction::Execute(Event event) bool UseItemAction::Execute(Event event)
{ {
@ -416,13 +416,6 @@ bool UseHearthStone::Execute(Event event)
bool UseHearthStone::isUseful() { return !bot->InBattleground(); } bool UseHearthStone::isUseful() { return !bot->InBattleground(); }
bool UseRandomRecipe::isUseful()
{
return !bot->IsInCombat() && !botAI->HasActivePlayerMaster() && !bot->InBattleground();
}
bool UseRandomRecipe::isPossible() { return AI_VALUE2(uint32, "item count", "recipe") > 0; }
bool UseRandomRecipe::Execute(Event event) bool UseRandomRecipe::Execute(Event event)
{ {
std::vector<Item*> recipes = AI_VALUE2(std::vector<Item*>, "inventory items", "recipe"); std::vector<Item*> recipes = AI_VALUE2(std::vector<Item*>, "inventory items", "recipe");
@ -445,12 +438,12 @@ bool UseRandomRecipe::Execute(Event event)
return used; return used;
} }
bool UseRandomQuestItem::isUseful() bool UseRandomRecipe::isUseful()
{ {
return !botAI->HasActivePlayerMaster() && !bot->InBattleground() && !bot->HasUnitState(UNIT_STATE_IN_FLIGHT); return !bot->IsInCombat() && !botAI->HasActivePlayerMaster() && !bot->InBattleground();
} }
bool UseRandomQuestItem::isPossible() { return AI_VALUE2(uint32, "item count", "quest") > 0; } bool UseRandomRecipe::isPossible() { return AI_VALUE2(uint32, "item count", "recipe") > 0; }
bool UseRandomQuestItem::Execute(Event event) bool UseRandomQuestItem::Execute(Event event)
{ {
@ -478,7 +471,6 @@ bool UseRandomQuestItem::Execute(Event event)
break; break;
} }
} }
} }
if (!item) if (!item)
@ -490,3 +482,10 @@ bool UseRandomQuestItem::Execute(Event event)
return used; return used;
} }
bool UseRandomQuestItem::isUseful()
{
return !botAI->HasActivePlayerMaster() && !bot->InBattleground() && !bot->HasUnitState(UNIT_STATE_IN_FLIGHT);
}
bool UseRandomQuestItem::isPossible() { return AI_VALUE2(uint32, "item count", "quest") > 0; }

View File

@ -69,8 +69,8 @@ class UseHearthStone : public UseItemAction
public: public:
UseHearthStone(PlayerbotAI* botAI) : UseItemAction(botAI, "hearthstone", true) {} UseHearthStone(PlayerbotAI* botAI) : UseItemAction(botAI, "hearthstone", true) {}
bool isUseful() override;
bool Execute(Event event) override; bool Execute(Event event) override;
bool isUseful() override;
}; };
class UseRandomRecipe : public UseItemAction class UseRandomRecipe : public UseItemAction
@ -78,9 +78,9 @@ class UseRandomRecipe : public UseItemAction
public: public:
UseRandomRecipe(PlayerbotAI* botAI) : UseItemAction(botAI, "random recipe", true) {} UseRandomRecipe(PlayerbotAI* botAI) : UseItemAction(botAI, "random recipe", true) {}
bool Execute(Event event) override;
bool isUseful() override; bool isUseful() override;
bool isPossible() override; bool isPossible() override;
bool Execute(Event event) override;
}; };
class UseRandomQuestItem : public UseItemAction class UseRandomQuestItem : public UseItemAction
@ -88,9 +88,9 @@ class UseRandomQuestItem : public UseItemAction
public: public:
UseRandomQuestItem(PlayerbotAI* botAI) : UseItemAction(botAI, "random quest item", true) {} UseRandomQuestItem(PlayerbotAI* botAI) : UseItemAction(botAI, "random quest item", true) {}
bool Execute(Event event) override;
bool isUseful() override; bool isUseful() override;
bool isPossible() override; bool isPossible() override;
bool Execute(Event event) override;
}; };
#endif #endif

View File

@ -7,20 +7,19 @@
#include "Playerbots.h" #include "Playerbots.h"
bool CastBearFormAction::isPossible()
{
return CastBuffSpellAction::isPossible() && !botAI->HasAura("dire bear form", GetTarget());
}
bool CastBearFormAction::isUseful() bool CastBearFormAction::isUseful()
{ {
return CastBuffSpellAction::isUseful() && !botAI->HasAura("dire bear form", GetTarget()); return CastBuffSpellAction::isUseful() && !botAI->HasAura("dire bear form", GetTarget());
} }
bool CastBearFormAction::isPossible()
{
return CastBuffSpellAction::isPossible() && !botAI->HasAura("dire bear form", GetTarget());
}
std::vector<NextAction> CastDireBearFormAction::getAlternatives() std::vector<NextAction> CastDireBearFormAction::getAlternatives()
{ {
return NextAction::merge({ NextAction("bear form") }, return NextAction::merge({NextAction("bear form")}, CastSpellAction::getAlternatives());
CastSpellAction::getAlternatives());
} }
bool CastTravelFormAction::isUseful() bool CastTravelFormAction::isUseful()
@ -32,22 +31,17 @@ bool CastTravelFormAction::isUseful()
!botAI->HasAura("dash", bot); !botAI->HasAura("dash", bot);
} }
bool CastCasterFormAction::isUseful()
{
return botAI->HasAnyAuraOf(GetTarget(), "dire bear form", "bear form", "cat form", "travel form", "aquatic form",
"flight form", "swift flight form", "moonkin form", nullptr) &&
AI_VALUE2(uint8, "mana", "self target") > sPlayerbotAIConfig.mediumHealth;
}
bool CastCasterFormAction::Execute(Event event) bool CastCasterFormAction::Execute(Event event)
{ {
botAI->RemoveShapeshift(); botAI->RemoveShapeshift();
return true; return true;
} }
bool CastCancelTreeFormAction::isUseful() bool CastCasterFormAction::isUseful()
{ {
return botAI->HasAura(33891, bot); return botAI->HasAnyAuraOf(GetTarget(), "dire bear form", "bear form", "cat form", "travel form", "aquatic form",
"flight form", "swift flight form", "moonkin form", nullptr) &&
AI_VALUE2(uint8, "mana", "self target") > sPlayerbotAIConfig.mediumHealth;
} }
bool CastCancelTreeFormAction::Execute(Event event) bool CastCancelTreeFormAction::Execute(Event event)
@ -56,6 +50,8 @@ bool CastCancelTreeFormAction::Execute(Event event)
return true; return true;
} }
bool CastCancelTreeFormAction::isUseful() { return botAI->HasAura(33891, bot); }
bool CastTreeFormAction::isUseful() bool CastTreeFormAction::isUseful()
{ {
return GetTarget() && CastSpellAction::isUseful() && !botAI->HasAura(33891, bot); return GetTarget() && CastSpellAction::isUseful() && !botAI->HasAura(33891, bot);

View File

@ -15,8 +15,8 @@ class CastBearFormAction : public CastBuffSpellAction
public: public:
CastBearFormAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "bear form") {} CastBearFormAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "bear form") {}
bool isPossible() override;
bool isUseful() override; bool isUseful() override;
bool isPossible() override;
}; };
class CastDireBearFormAction : public CastBuffSpellAction class CastDireBearFormAction : public CastBuffSpellAction
@ -37,6 +37,7 @@ class CastTreeFormAction : public CastBuffSpellAction
{ {
public: public:
CastTreeFormAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "tree of life") {} CastTreeFormAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "tree of life") {}
bool isUseful() override; bool isUseful() override;
}; };
@ -65,9 +66,9 @@ class CastCasterFormAction : public CastBuffSpellAction
public: public:
CastCasterFormAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "caster form") {} CastCasterFormAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "caster form") {}
bool Execute(Event event) override;
bool isUseful() override; bool isUseful() override;
bool isPossible() override { return true; } bool isPossible() override { return true; }
bool Execute(Event event) override;
}; };
class CastCancelTreeFormAction : public CastBuffSpellAction class CastCancelTreeFormAction : public CastBuffSpellAction
@ -75,9 +76,9 @@ class CastCancelTreeFormAction : public CastBuffSpellAction
public: public:
CastCancelTreeFormAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "cancel tree form") {} CastCancelTreeFormAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "cancel tree form") {}
bool Execute(Event event) override;
bool isUseful() override; bool isUseful() override;
bool isPossible() override { return true; } bool isPossible() override { return true; }
bool Execute(Event event) override;
}; };
#endif #endif

View File

@ -8,16 +8,14 @@
#include "Event.h" #include "Event.h"
#include "Playerbots.h" #include "Playerbots.h"
bool CastRemoveShadowformAction::isUseful() { return botAI->HasAura("shadowform", AI_VALUE(Unit*, "self target")); }
bool CastRemoveShadowformAction::isPossible() { return true; }
bool CastRemoveShadowformAction::Execute(Event event) bool CastRemoveShadowformAction::Execute(Event event)
{ {
botAI->RemoveAura("shadowform"); botAI->RemoveAura("shadowform");
return true; return true;
} }
bool CastRemoveShadowformAction::isUseful() { return botAI->HasAura("shadowform", AI_VALUE(Unit*, "self target")); }
Unit* CastPowerWordShieldOnAlmostFullHealthBelowAction::GetTarget() Unit* CastPowerWordShieldOnAlmostFullHealthBelowAction::GetTarget()
{ {
Group* group = bot->GetGroup(); Group* group = bot->GetGroup();

View File

@ -56,7 +56,10 @@ HEAL_PARTY_ACTION(CastRenewOnPartyAction, "renew", 15.0f, HealingManaEfficiency:
class CastPrayerOfMendingAction : public HealPartyMemberAction class CastPrayerOfMendingAction : public HealPartyMemberAction
{ {
public: public:
CastPrayerOfMendingAction(PlayerbotAI* botAI) : HealPartyMemberAction(botAI, "prayer of mending", 10.0f, HealingManaEfficiency::HIGH, false) {} CastPrayerOfMendingAction(PlayerbotAI* botAI)
: HealPartyMemberAction(botAI, "prayer of mending", 10.0f, HealingManaEfficiency::HIGH, false)
{
}
}; };
HEAL_PARTY_ACTION(CastBindingHealAction, "binding heal", 15.0f, HealingManaEfficiency::MEDIUM); HEAL_PARTY_ACTION(CastBindingHealAction, "binding heal", 15.0f, HealingManaEfficiency::MEDIUM);
@ -65,7 +68,8 @@ HEAL_PARTY_ACTION(CastPrayerOfHealingAction, "prayer of healing", 15.0f, Healing
class CastCircleOfHealingAction : public HealPartyMemberAction class CastCircleOfHealingAction : public HealPartyMemberAction
{ {
public: public:
CastCircleOfHealingAction(PlayerbotAI* ai) : HealPartyMemberAction(ai, "circle of healing", 15.0f, HealingManaEfficiency::HIGH) CastCircleOfHealingAction(PlayerbotAI* ai)
: HealPartyMemberAction(ai, "circle of healing", 15.0f, HealingManaEfficiency::HIGH)
{ {
} }
}; };
@ -134,15 +138,15 @@ class CastRemoveShadowformAction : public Action
public: public:
CastRemoveShadowformAction(PlayerbotAI* botAI) : Action(botAI, "remove shadowform") {} CastRemoveShadowformAction(PlayerbotAI* botAI) : Action(botAI, "remove shadowform") {}
bool isUseful() override;
bool isPossible() override;
bool Execute(Event event) override; bool Execute(Event event) override;
bool isUseful() override;
}; };
class CastDispersionAction : public CastSpellAction class CastDispersionAction : public CastSpellAction
{ {
public: public:
CastDispersionAction(PlayerbotAI* ai) : CastSpellAction(ai, "dispersion") {} CastDispersionAction(PlayerbotAI* ai) : CastSpellAction(ai, "dispersion") {}
virtual std::string const GetTargetName() { return "self target"; } virtual std::string const GetTargetName() { return "self target"; }
}; };
@ -158,6 +162,7 @@ class CastHymnOfHopeAction : public CastSpellAction
{ {
public: public:
CastHymnOfHopeAction(PlayerbotAI* ai) : CastSpellAction(ai, "hymn of hope") {} CastHymnOfHopeAction(PlayerbotAI* ai) : CastSpellAction(ai, "hymn of hope") {}
virtual std::string const GetTargetName() { return "self target"; } virtual std::string const GetTargetName() { return "self target"; }
}; };
@ -165,6 +170,7 @@ class CastDivineHymnAction : public CastSpellAction
{ {
public: public:
CastDivineHymnAction(PlayerbotAI* ai) : CastSpellAction(ai, "divine hymn") {} CastDivineHymnAction(PlayerbotAI* ai) : CastSpellAction(ai, "divine hymn") {}
virtual std::string const GetTargetName() { return "self target"; } virtual std::string const GetTargetName() { return "self target"; }
}; };
@ -172,6 +178,7 @@ class CastShadowfiendAction : public CastSpellAction
{ {
public: public:
CastShadowfiendAction(PlayerbotAI* ai) : CastSpellAction(ai, "shadowfiend") {} CastShadowfiendAction(PlayerbotAI* ai) : CastSpellAction(ai, "shadowfiend") {}
virtual std::string const GetTargetName() { return "current target"; } virtual std::string const GetTargetName() { return "current target"; }
}; };
@ -182,6 +189,7 @@ public:
: HealPartyMemberAction(ai, "power word: shield", 15.0f, HealingManaEfficiency::HIGH) : HealPartyMemberAction(ai, "power word: shield", 15.0f, HealingManaEfficiency::HIGH)
{ {
} }
bool isUseful() override; bool isUseful() override;
Unit* GetTarget() override; Unit* GetTarget() override;
}; };
@ -193,6 +201,7 @@ public:
: HealPartyMemberAction(ai, "power word: shield", 5.0f, HealingManaEfficiency::HIGH) : HealPartyMemberAction(ai, "power word: shield", 5.0f, HealingManaEfficiency::HIGH)
{ {
} }
bool isUseful() override; bool isUseful() override;
Unit* GetTarget() override; Unit* GetTarget() override;
}; };
@ -201,13 +210,17 @@ class CastMindSearAction : public CastSpellAction
{ {
public: public:
CastMindSearAction(PlayerbotAI* ai) : CastSpellAction(ai, "mind sear") {} CastMindSearAction(PlayerbotAI* ai) : CastSpellAction(ai, "mind sear") {}
ActionThreatType getThreatType() override { return ActionThreatType::Aoe; } ActionThreatType getThreatType() override { return ActionThreatType::Aoe; }
}; };
class CastGuardianSpiritOnPartyAction : public HealPartyMemberAction class CastGuardianSpiritOnPartyAction : public HealPartyMemberAction
{ {
public: public:
CastGuardianSpiritOnPartyAction(PlayerbotAI* ai) : HealPartyMemberAction(ai, "guardian spirit", 40.0f, HealingManaEfficiency::MEDIUM) {} CastGuardianSpiritOnPartyAction(PlayerbotAI* ai)
: HealPartyMemberAction(ai, "guardian spirit", 40.0f, HealingManaEfficiency::MEDIUM)
{
}
}; };
#endif #endif

View File

@ -27,6 +27,7 @@ class CastHungerForBloodAction : public CastBuffSpellAction
{ {
public: public:
CastHungerForBloodAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "hunger for blood") {} CastHungerForBloodAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "hunger for blood") {}
std::string const GetTargetName() override { return "current target"; } std::string const GetTargetName() override { return "current target"; }
}; };
@ -43,9 +44,9 @@ class CastStealthAction : public CastBuffSpellAction
public: public:
CastStealthAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "stealth") {} CastStealthAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "stealth") {}
std::string const GetTargetName() override { return "self target"; }
bool isUseful() override; bool isUseful() override;
bool isPossible() override; bool isPossible() override;
std::string const GetTargetName() override { return "self target"; }
}; };
class UnstealthAction : public Action class UnstealthAction : public Action
@ -61,8 +62,8 @@ class CheckStealthAction : public Action
public: public:
CheckStealthAction(PlayerbotAI* botAI) : Action(botAI, "check stealth") {} CheckStealthAction(PlayerbotAI* botAI) : Action(botAI, "check stealth") {}
bool isPossible() override { return true; }
bool Execute(Event event) override; bool Execute(Event event) override;
bool isPossible() override { return true; }
}; };
class CastKickAction : public CastSpellAction class CastKickAction : public CastSpellAction
@ -131,6 +132,7 @@ class CastEnvenomAction : public CastMeleeSpellAction
{ {
public: public:
CastEnvenomAction(PlayerbotAI* ai) : CastMeleeSpellAction(ai, "envenom") {} CastEnvenomAction(PlayerbotAI* ai) : CastMeleeSpellAction(ai, "envenom") {}
bool isUseful() override; bool isUseful() override;
bool isPossible() override; bool isPossible() override;
}; };
@ -139,37 +141,42 @@ class CastTricksOfTheTradeOnMainTankAction : public BuffOnMainTankAction
{ {
public: public:
CastTricksOfTheTradeOnMainTankAction(PlayerbotAI* ai) : BuffOnMainTankAction(ai, "tricks of the trade", true) {} CastTricksOfTheTradeOnMainTankAction(PlayerbotAI* ai) : BuffOnMainTankAction(ai, "tricks of the trade", true) {}
virtual bool isUseful() override;
bool isUseful() override;
}; };
class UseDeadlyPoisonAction : public UseItemAction class UseDeadlyPoisonAction : public UseItemAction
{ {
public: public:
UseDeadlyPoisonAction(PlayerbotAI* ai) : UseItemAction(ai, "Deadly Poison") {} UseDeadlyPoisonAction(PlayerbotAI* ai) : UseItemAction(ai, "Deadly Poison") {}
virtual bool Execute(Event event) override;
virtual bool isPossible() override; bool Execute(Event event) override;
bool isPossible() override;
}; };
class UseInstantPoisonAction : public UseItemAction class UseInstantPoisonAction : public UseItemAction
{ {
public: public:
UseInstantPoisonAction(PlayerbotAI* ai) : UseItemAction(ai, "Instant Poison") {} UseInstantPoisonAction(PlayerbotAI* ai) : UseItemAction(ai, "Instant Poison") {}
virtual bool Execute(Event event) override;
virtual bool isPossible() override; bool Execute(Event event) override;
bool isPossible() override;
}; };
class UseInstantPoisonOffHandAction : public UseItemAction class UseInstantPoisonOffHandAction : public UseItemAction
{ {
public: public:
UseInstantPoisonOffHandAction(PlayerbotAI* ai) : UseItemAction(ai, "Instant Poison Off Hand") {} UseInstantPoisonOffHandAction(PlayerbotAI* ai) : UseItemAction(ai, "Instant Poison Off Hand") {}
virtual bool Execute(Event event) override;
virtual bool isPossible() override; bool Execute(Event event) override;
bool isPossible() override;
}; };
class FanOfKnivesAction : public CastMeleeSpellAction class FanOfKnivesAction : public CastMeleeSpellAction
{ {
public: public:
FanOfKnivesAction(PlayerbotAI* ai) : CastMeleeSpellAction(ai, "fan of knives") {} FanOfKnivesAction(PlayerbotAI* ai) : CastMeleeSpellAction(ai, "fan of knives") {}
ActionThreatType getThreatType() override { return ActionThreatType::Aoe; } ActionThreatType getThreatType() override { return ActionThreatType::Aoe; }
}; };

View File

@ -176,20 +176,19 @@ Unit* CastShatteringThrowAction::GetTarget()
return nullptr; // No valid target return nullptr; // No valid target
} }
bool CastShatteringThrowAction::Execute(Event event)
{
Unit* target = GetTarget();
if (!target)
return false;
return botAI->CastSpell("shattering throw", target);
}
bool CastShatteringThrowAction::isUseful() bool CastShatteringThrowAction::isUseful()
{ {
if (!bot->HasSpell(64382) || bot->HasSpellCooldown(64382))
// Spell cooldown check
if (!bot->HasSpell(64382))
{
return false; return false;
}
// Spell cooldown check
if (bot->HasSpellCooldown(64382))
{
return false;
}
GuidVector enemies = AI_VALUE(GuidVector, "possible targets"); GuidVector enemies = AI_VALUE(GuidVector, "possible targets");
@ -220,25 +219,12 @@ bool CastShatteringThrowAction::isPossible()
// Range check: Shattering Throw is 30 yards // Range check: Shattering Throw is 30 yards
if (!bot->IsWithinDistInMap(target, 30.0f)) if (!bot->IsWithinDistInMap(target, 30.0f))
{
return false; return false;
}
// Check line of sight // Check line of sight
if (!bot->IsWithinLOSInMap(target)) if (!bot->IsWithinLOSInMap(target))
{
return false; return false;
}
// If the minimal checks above pass, simply return true. // If the minimal checks above pass, simply return true.
return true; return true;
} }
bool CastShatteringThrowAction::Execute(Event event)
{
Unit* target = GetTarget();
if (!target)
return false;
return botAI->CastSpell("shattering throw", target);
}

View File

@ -25,8 +25,7 @@ MELEE_ACTION_U(CastBattleShoutTauntAction, "battle shout", CastSpellAction::isUs
class CastDemoralizingShoutAction : public CastMeleeDebuffSpellAction class CastDemoralizingShoutAction : public CastMeleeDebuffSpellAction
{ {
public: public:
CastDemoralizingShoutAction(PlayerbotAI* botAI) CastDemoralizingShoutAction(PlayerbotAI* botAI) : CastMeleeDebuffSpellAction(botAI, "demoralizing shout") {}
: CastMeleeDebuffSpellAction(botAI, "demoralizing shout") {}
}; };
class CastDemoralizingShoutWithoutLifeTimeCheckAction : public CastMeleeDebuffSpellAction class CastDemoralizingShoutWithoutLifeTimeCheckAction : public CastMeleeDebuffSpellAction
@ -140,8 +139,8 @@ class CastVigilanceAction : public BuffOnPartyAction
public: public:
CastVigilanceAction(PlayerbotAI* botAI) : BuffOnPartyAction(botAI, "vigilance") {} CastVigilanceAction(PlayerbotAI* botAI) : BuffOnPartyAction(botAI, "vigilance") {}
Unit* GetTarget() override;
bool Execute(Event event) override; bool Execute(Event event) override;
Unit* GetTarget() override;
}; };
class CastRetaliationAction : public CastBuffSpellAction class CastRetaliationAction : public CastBuffSpellAction
@ -157,10 +156,10 @@ class CastShatteringThrowAction : public CastSpellAction
public: public:
CastShatteringThrowAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "shattering throw") {} CastShatteringThrowAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "shattering throw") {}
Unit* GetTarget() override; bool Execute(Event event) override;
bool isUseful() override; bool isUseful() override;
bool isPossible() override; bool isPossible() override;
bool Execute(Event event) override; Unit* GetTarget() override;
}; };
#endif #endif

View File

@ -1,9 +1,9 @@
#ifndef _PLAYERBOT_RAIDEOEACTIONS_H #ifndef _PLAYERBOT_RAIDEOEACTIONS_H
#define _PLAYERBOT_RAIDEOEACTIONS_H #define _PLAYERBOT_RAIDEOEACTIONS_H
#include "MovementActions.h"
#include "AttackAction.h" #include "AttackAction.h"
#include "GenericSpellActions.h" #include "GenericSpellActions.h"
#include "MovementActions.h"
#include "PlayerbotAI.h" #include "PlayerbotAI.h"
#include "Playerbots.h" #include "Playerbots.h"
@ -13,34 +13,38 @@ const std::pair<float, float> MALYGOS_STACK_POSITION = {755.0f, 1301.0f};
class MalygosPositionAction : public MovementAction class MalygosPositionAction : public MovementAction
{ {
public: public:
MalygosPositionAction(PlayerbotAI* botAI, std::string const name = "malygos position") MalygosPositionAction(PlayerbotAI* botAI, std::string const name = "malygos position") : MovementAction(botAI, name)
: MovementAction(botAI, name) {} {
}
bool Execute(Event event) override; bool Execute(Event event) override;
}; };
class MalygosTargetAction : public AttackAction class MalygosTargetAction : public AttackAction
{ {
public: public:
MalygosTargetAction(PlayerbotAI* botAI, std::string const name = "malygos target") MalygosTargetAction(PlayerbotAI* botAI, std::string const name = "malygos target") : AttackAction(botAI, name) {}
: AttackAction(botAI, name) {}
bool Execute(Event event) override; bool Execute(Event event) override;
}; };
class PullPowerSparkAction : public CastSpellAction //class PullPowerSparkAction : public CastSpellAction
{ //{
public: //public:
PullPowerSparkAction(PlayerbotAI* botAI, std::string const name = "pull power spark") // PullPowerSparkAction(PlayerbotAI* botAI, std::string const name = "pull power spark") : CastSpellAction(botAI, name)
: CastSpellAction(botAI, name) {} // {
bool Execute(Event event) override; // }
bool isPossible() override;
bool isUseful() override; // bool Execute(Event event) override;
}; // bool isUseful() override;
// bool isPossible() override;
//};
class KillPowerSparkAction : public AttackAction class KillPowerSparkAction : public AttackAction
{ {
public: public:
KillPowerSparkAction(PlayerbotAI* botAI, std::string const name = "kill power spark") KillPowerSparkAction(PlayerbotAI* botAI, std::string const name = "kill power spark") : AttackAction(botAI, name) {}
: AttackAction(botAI, name) {}
bool Execute(Event event) override; bool Execute(Event event) override;
}; };
@ -48,6 +52,7 @@ class EoEFlyDrakeAction : public MovementAction
{ {
public: public:
EoEFlyDrakeAction(PlayerbotAI* ai) : MovementAction(ai, "eoe fly drake") {} EoEFlyDrakeAction(PlayerbotAI* ai) : MovementAction(ai, "eoe fly drake") {}
bool Execute(Event event) override; bool Execute(Event event) override;
bool isPossible() override; bool isPossible() override;
}; };
@ -56,6 +61,7 @@ class EoEDrakeAttackAction : public Action
{ {
public: public:
EoEDrakeAttackAction(PlayerbotAI* botAI) : Action(botAI, "eoe drake attack") {} EoEDrakeAttackAction(PlayerbotAI* botAI) : Action(botAI, "eoe drake attack") {}
bool Execute(Event event) override; bool Execute(Event event) override;
bool isPossible() override; bool isPossible() override;

View File

@ -60,8 +60,27 @@ public:
virtual ~Action(void) {} virtual ~Action(void) {}
virtual bool Execute([[maybe_unused]] Event event) { return true; } virtual bool Execute([[maybe_unused]] Event event) { return true; }
virtual bool isPossible() { return true; }
/**
* @brief First validation check - determines if this action is contextually useful
*
* Performs lightweight checks to evaluate whether the action makes sense
* in the current situation. Called before isPossible() during action selection.
*
* @return true if the action is useful, false otherwise
*/
virtual bool isUseful() { return true; } virtual bool isUseful() { return true; }
/**
* @brief Second validation check - determines if this action can be executed
*
* Performs hard pre-execution validation against the event and game state.
* Called after isUseful() passes, before Execute().
*
* @return true if the action is possible, false otherwise
*/
virtual bool isPossible() { return true; }
virtual std::vector<NextAction> getPrerequisites() { return {}; } virtual std::vector<NextAction> getPrerequisites() { return {}; }
virtual std::vector<NextAction> getAlternatives() { return {}; } virtual std::vector<NextAction> getAlternatives() { return {}; }
virtual std::vector<NextAction> getContinuers() { return {}; } virtual std::vector<NextAction> getContinuers() { return {}; }

View File

@ -323,18 +323,18 @@ ActionResult Engine::ExecuteAction(std::string const name, Event event, std::str
q->Qualify(qualifier); q->Qualify(qualifier);
} }
if (!action->isPossible())
{
delete actionNode;
return ACTION_RESULT_IMPOSSIBLE;
}
if (!action->isUseful()) if (!action->isUseful())
{ {
delete actionNode; delete actionNode;
return ACTION_RESULT_USELESS; return ACTION_RESULT_USELESS;
} }
if (!action->isPossible())
{
delete actionNode;
return ACTION_RESULT_IMPOSSIBLE;
}
action->MakeVerbose(); action->MakeVerbose();
result = ListenAndExecute(action, event); result = ListenAndExecute(action, event);