Merge pull request #618 from avirar/armor_token_usage

Armor token usage
This commit is contained in:
Yunfan Li
2024-10-21 11:11:09 +08:00
committed by GitHub
2 changed files with 51 additions and 18 deletions

View File

@@ -36,23 +36,39 @@ 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);
switch (proto->Class)
// Armor Tokens are classed as MISC JUNK (Class 15, Subclass 0), luckily no other items I found have class bits and epic quality.
if (proto->Class == ITEM_CLASS_MISC && proto->SubClass == ITEM_SUBCLASS_JUNK && proto->Quality == ITEM_QUALITY_EPIC)
{ {
case ITEM_CLASS_WEAPON: if (CanBotUseToken(proto, bot))
case ITEM_CLASS_ARMOR: {
if (usage == ITEM_USAGE_EQUIP || usage == ITEM_USAGE_REPLACE || usage == ITEM_USAGE_BAD_EQUIP) vote = NEED; // Eligible for "Need"
{ }
vote = NEED; else
} {
else if (usage != ITEM_USAGE_NONE) vote = GREED; // Not eligible, so "Greed"
{ }
vote = GREED; }
} else
break; {
default: switch (proto->Class)
if (StoreLootAction::IsLootAllowed(itemId, botAI)) {
vote = NEED; case ITEM_CLASS_WEAPON:
break; case ITEM_CLASS_ARMOR:
if (usage == ITEM_USAGE_EQUIP || usage == ITEM_USAGE_REPLACE || usage == ITEM_USAGE_BAD_EQUIP)
{
vote = NEED;
}
else if (usage != ITEM_USAGE_NONE)
{
vote = GREED;
}
break;
default:
if (StoreLootAction::IsLootAllowed(itemId, botAI))
vote = NEED;
break;
}
} }
if (sPlayerbotAIConfig->lootRollLevel == 0) if (sPlayerbotAIConfig->lootRollLevel == 0)
{ {
@@ -80,6 +96,7 @@ bool LootRollAction::Execute(Event event)
break; break;
} }
} }
// WorldPacket p(event.getPacket()); //WorldPacket packet for CMSG_LOOT_ROLL, (8+4+1) // WorldPacket p(event.getPacket()); //WorldPacket packet for CMSG_LOOT_ROLL, (8+4+1)
// p.rpos(0); //reset packet pointer // p.rpos(0); //reset packet pointer
// p >> guid; //guid of the item rolled // p >> guid; //guid of the item rolled
@@ -132,10 +149,10 @@ bool LootRollAction::Execute(Event event)
// break; // break;
// } // }
// } // }
return true; return true;
} }
RollVote LootRollAction::CalculateRollVote(ItemTemplate const* proto) RollVote LootRollAction::CalculateRollVote(ItemTemplate const* proto)
{ {
std::ostringstream out; std::ostringstream out;
@@ -165,7 +182,7 @@ RollVote LootRollAction::CalculateRollVote(ItemTemplate const* proto)
return StoreLootAction::IsLootAllowed(proto->ItemId, GET_PLAYERBOT_AI(bot)) ? needVote : PASS; return StoreLootAction::IsLootAllowed(proto->ItemId, GET_PLAYERBOT_AI(bot)) ? needVote : PASS;
} }
bool MasterLootRollAction::isUseful() { return !botAI->HasActivePlayerMaster(); }; bool MasterLootRollAction::isUseful() { return !botAI->HasActivePlayerMaster(); }
bool MasterLootRollAction::Execute(Event event) bool MasterLootRollAction::Execute(Event event)
{ {
@@ -204,3 +221,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
}

View File

@@ -25,6 +25,8 @@ protected:
RollVote CalculateRollVote(ItemTemplate const* proto); RollVote CalculateRollVote(ItemTemplate const* proto);
}; };
bool CanBotUseToken(ItemTemplate const* proto, Player* bot);
class MasterLootRollAction : public LootRollAction class MasterLootRollAction : public LootRollAction
{ {
public: public: