fix: Optimize DrinkAction to check mana in isUseful instead of Execute (#1666)

* fix: Optimize DrinkAction to check mana in isUseful instead of Execute

- Move HasManaValue check from Execute to isUseful for better performance
- Prevents non-mana classes from executing drink actions unnecessarily
- Improves AI efficiency by early filtering in isUseful method

Addresses reviewer feedback about HasManaValue usage optimization

* Update NonCombatActions.cpp

---------

Co-authored-by: bash <31279994+hermensbas@users.noreply.github.com>
This commit is contained in:
Gonzalo
2025-09-27 08:06:16 -03:00
committed by GitHub
parent fc69dd5ddd
commit f23b2ea2f6

View File

@@ -13,10 +13,6 @@ bool DrinkAction::Execute(Event event)
if (bot->IsInCombat())
return false;
bool hasMana = AI_VALUE2(bool, "has mana", "self target");
if (!hasMana)
return false;
if (botAI->HasCheat(BotCheatMask::food))
{
// if (bot->IsNonMeleeSpellCast(true))
@@ -54,7 +50,14 @@ bool DrinkAction::Execute(Event event)
return UseItemAction::Execute(event);
}
bool DrinkAction::isUseful() { return UseItemAction::isUseful() && AI_VALUE2(uint8, "mana", "self target") < 100; }
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;
}
bool DrinkAction::isPossible()
{