Compare commits

..

10 Commits

Author SHA1 Message Date
kadeshar
a19604024e
Merge pull request #1662 from gacuna89/patch-2
Fix: Prevent bots from eating and drinking while mounted
2025-09-29 21:46:07 +02:00
bash
972e2604ce
Update NonCombatActions.cpp
This is better, even though aura check is tiny more expensive then most. Placing them into isUseful() is kinda confusing.
2025-09-29 00:14:28 +02:00
bash
aaa9e1a42c
Placed cheap checks in isPossible() more expensive in isUseful()
combat en mounted are both HasUnitFlag checks, which are cheap calls to make.
2025-09-29 00:06:56 +02:00
bash
df77668b4b
Review 2025-09-28 20:37:01 +02:00
bash
ec4ab34f94
Update NonCombatActions.cpp
Expensive checks last.
2025-09-27 23:31:16 +02:00
bash
62e2ca247a
formatting 2025-09-27 23:28:48 +02:00
bash
d9b57fcfd4
Updated the locations of the checks, also added the checks as additional gatekeeper of the execute. 2025-09-27 23:26:29 +02:00
bash
e042e3b12b
Added shapeshift 2025-09-27 22:55:52 +02:00
bash
3228667121
Merge branch 'master' into patch-2 2025-09-27 22:40:39 +02:00
Gonzalo
f26c4e99f6
Fix: Prevent bots from eating and drinking while mounted
This change modifies the `DrinkAction::Execute()` and `EatAction::Execute()` functions in `src/strategy/actions/NonCombatActions.cpp`.

Previously, playerbots could attempt to eat food or drink water while mounted, which is not possible in the game and creates unrealistic behavior.

This fix adds mount state checks to both actions:
1. `DrinkAction::Execute()` now checks `bot->IsMounted()` and returns false if mounted
2. `EatAction::Execute()` now checks `bot->IsMounted()` and returns false if mounted

This prevents bots from attempting to consume food or drinks while mounted, improving bot behavior realism and preventing unnecessary action attempts that would fail anyway.
2025-09-25 18:26:28 -03:00

View File

@ -10,9 +10,6 @@
bool DrinkAction::Execute(Event event)
{
if (bot->IsInCombat())
return false;
if (botAI->HasCheat(BotCheatMask::food))
{
// if (bot->IsNonMeleeSpellCast(true))
@ -52,23 +49,22 @@ bool DrinkAction::Execute(Event event)
bool DrinkAction::isUseful()
{
// check class uses mana
if (!AI_VALUE2(bool, "has mana", "self target"))
return false;
return UseItemAction::isUseful() && AI_VALUE2(uint8, "mana", "self target") < 100;
return UseItemAction::isUseful() &&
AI_VALUE2(bool, "has mana", "self target") &&
AI_VALUE2(uint8, "mana", "self target") < 100;
}
bool DrinkAction::isPossible()
{
return !bot->IsInCombat() && (botAI->HasCheat(BotCheatMask::food) || UseItemAction::isPossible());
return !bot->IsInCombat() &&
!bot->IsMounted() &&
!botAI->HasAnyAuraOf(GetTarget(), "dire bear form", "bear form", "cat form", "travel form",
"aquatic form","flight form", "swift flight form", nullptr) &&
(botAI->HasCheat(BotCheatMask::food) || UseItemAction::isPossible());
}
bool EatAction::Execute(Event event)
{
if (bot->IsInCombat())
return false;
if (botAI->HasCheat(BotCheatMask::food))
{
// if (bot->IsNonMeleeSpellCast(true))
@ -106,9 +102,17 @@ bool EatAction::Execute(Event event)
return UseItemAction::Execute(event);
}
bool EatAction::isUseful() { return UseItemAction::isUseful() && AI_VALUE2(uint8, "health", "self target") < 85; }
bool EatAction::isUseful()
{
return UseItemAction::isUseful() &&
AI_VALUE2(uint8, "health", "self target") < 100;
}
bool EatAction::isPossible()
{
return !bot->IsInCombat() && (botAI->HasCheat(BotCheatMask::food) || UseItemAction::isPossible());
return !bot->IsInCombat() &&
!bot->IsMounted() &&
!botAI->HasAnyAuraOf(GetTarget(), "dire bear form", "bear form", "cat form", "travel form",
"aquatic form","flight form", "swift flight form", nullptr) &&
(botAI->HasCheat(BotCheatMask::food) || UseItemAction::isPossible());
}