mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
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:
@@ -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()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user