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,6 +36,21 @@ 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);
// 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)
{
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:
@@ -54,6 +69,7 @@ bool LootRollAction::Execute(Event event)
vote = NEED; vote = NEED;
break; break;
} }
}
if (sPlayerbotAIConfig->lootRollLevel == 0) if (sPlayerbotAIConfig->lootRollLevel == 0)
{ {
vote = PASS; vote = PASS;
@@ -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: