Update LootRollAction.cpp

Added logic for class/armour token usage.
This commit is contained in:
avirar
2024-10-18 10:06:41 +11:00
committed by GitHub
parent 0dc7a844ea
commit 38a5ff778a

View File

@@ -36,6 +36,20 @@ bool LootRollAction::Execute(Event event)
if (!proto) if (!proto)
continue; continue;
ItemUsage usage = AI_VALUE2(ItemUsage, "item usage", itemId); 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) switch (proto->Class)
{ {
case ITEM_CLASS_WEAPON: case ITEM_CLASS_WEAPON:
@@ -204,3 +218,17 @@ bool MasterLootRollAction::Execute(Event event)
return true; 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
}