From 38a5ff778ab09a1966ed3c6347de95dcbdae4a1a Mon Sep 17 00:00:00 2001 From: avirar Date: Fri, 18 Oct 2024 10:06:41 +1100 Subject: [PATCH] Update LootRollAction.cpp Added logic for class/armour token usage. --- src/strategy/actions/LootRollAction.cpp | 28 +++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/strategy/actions/LootRollAction.cpp b/src/strategy/actions/LootRollAction.cpp index 4febe6ef..d9a7b86d 100644 --- a/src/strategy/actions/LootRollAction.cpp +++ b/src/strategy/actions/LootRollAction.cpp @@ -36,6 +36,20 @@ bool LootRollAction::Execute(Event event) if (!proto) continue; ItemUsage usage = AI_VALUE2(ItemUsage, "item usage", itemId); + // New token handling logic + if (proto->Class == ITEM_CLASS_TOKENS) + { + if (CanBotUseToken(proto, bot)) + { + vote = NEED; // Eligible for "Need" + } + else + { + vote = GREED; // Not eligible, so "Greed" + } + } + else + { switch (proto->Class) { case ITEM_CLASS_WEAPON: @@ -204,3 +218,17 @@ bool MasterLootRollAction::Execute(Event event) return true; } +bool CanBotUseToken(ItemTemplate const* proto, Player* bot) +{ + // Get the bitmask for the bot's class + uint32 botClassMask = (1 << (bot->getClass() - 1)); + + // Check if the bot's class is allowed to use the token + if (proto->AllowableClass & botClassMask) + { + return true; // Bot's class is eligible to use this token + } + + return false; // Bot's class cannot use this token +} +