From 38a5ff778ab09a1966ed3c6347de95dcbdae4a1a Mon Sep 17 00:00:00 2001 From: avirar Date: Fri, 18 Oct 2024 10:06:41 +1100 Subject: [PATCH 1/5] 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 4febe6ef5..d9a7b86d1 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 +} + From efd204bbbe96779b1e722d96c90de59941db96b8 Mon Sep 17 00:00:00 2001 From: avirar Date: Fri, 18 Oct 2024 10:08:00 +1100 Subject: [PATCH 2/5] Update LootRollAction.h Declared CanBotUseToken --- src/strategy/actions/LootRollAction.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/strategy/actions/LootRollAction.h b/src/strategy/actions/LootRollAction.h index cc202c44e..a278f593d 100644 --- a/src/strategy/actions/LootRollAction.h +++ b/src/strategy/actions/LootRollAction.h @@ -25,6 +25,8 @@ class LootRollAction : public QueryItemUsageAction RollVote CalculateRollVote(ItemTemplate const* proto); }; +bool CanBotUseToken(ItemTemplate const* proto, Player* bot); + class MasterLootRollAction : public LootRollAction { public: From 4981f46aeed8467bf9cfdf3dc0ddac8d9c03ab8e Mon Sep 17 00:00:00 2001 From: avirar Date: Fri, 18 Oct 2024 12:24:23 +1100 Subject: [PATCH 3/5] Update LootRollAction.cpp Added logic so bots will only roll need on usable class armor tokens. The tokens/items are classed as MISC > JUNK oddly, code simply checks if the bots class is part of the bitmask of classes for the item, and the item is EPIC. This catches all the tokens I've tested so far. --- src/strategy/actions/LootRollAction.cpp | 75 +++++++++++++------------ 1 file changed, 40 insertions(+), 35 deletions(-) diff --git a/src/strategy/actions/LootRollAction.cpp b/src/strategy/actions/LootRollAction.cpp index d9a7b86d1..ef3737916 100644 --- a/src/strategy/actions/LootRollAction.cpp +++ b/src/strategy/actions/LootRollAction.cpp @@ -12,6 +12,20 @@ #include "PlayerbotAIConfig.h" #include "Playerbots.h" +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 +} + bool LootRollAction::Execute(Event event) { Player* bot = QueryItemUsageAction::botAI->GetBot(); @@ -36,8 +50,9 @@ 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) + + // New token handling logic + if (proto->Class == ITEM_CLASS_MISC && proto->SubClass == ITEM_SUBCLASS_JUNK && proto->Quality == ITEM_QUALITY_EPIC) { if (CanBotUseToken(proto, bot)) { @@ -50,23 +65,24 @@ bool LootRollAction::Execute(Event event) } else { - switch (proto->Class) - { - case ITEM_CLASS_WEAPON: - 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; + switch (proto->Class) + { + case ITEM_CLASS_WEAPON: + 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) { @@ -94,6 +110,7 @@ bool LootRollAction::Execute(Event event) break; } } + // WorldPacket p(event.getPacket()); //WorldPacket packet for CMSG_LOOT_ROLL, (8+4+1) // p.rpos(0); //reset packet pointer // p >> guid; //guid of the item rolled @@ -146,10 +163,12 @@ bool LootRollAction::Execute(Event event) // break; // } // } - + return true; } +// Remove the extra closing brace that was here + RollVote LootRollAction::CalculateRollVote(ItemTemplate const* proto) { std::ostringstream out; @@ -179,7 +198,7 @@ RollVote LootRollAction::CalculateRollVote(ItemTemplate const* proto) 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) { @@ -218,17 +237,3 @@ 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 -} - From 472050abd97304c9ed7f282b933a4ff9840982e3 Mon Sep 17 00:00:00 2001 From: avirar Date: Sat, 19 Oct 2024 11:43:51 +1100 Subject: [PATCH 4/5] Update LootRollAction.cpp Added logic for bots to roll need/greed on armor tokens based on class. --- src/strategy/actions/LootRollAction.cpp | 31 ++++++++++++------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/strategy/actions/LootRollAction.cpp b/src/strategy/actions/LootRollAction.cpp index ef3737916..8527b46f6 100644 --- a/src/strategy/actions/LootRollAction.cpp +++ b/src/strategy/actions/LootRollAction.cpp @@ -12,20 +12,6 @@ #include "PlayerbotAIConfig.h" #include "Playerbots.h" -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 -} - bool LootRollAction::Execute(Event event) { Player* bot = QueryItemUsageAction::botAI->GetBot(); @@ -51,7 +37,7 @@ bool LootRollAction::Execute(Event event) continue; ItemUsage usage = AI_VALUE2(ItemUsage, "item usage", itemId); - // New token handling logic + // 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)) @@ -167,7 +153,6 @@ bool LootRollAction::Execute(Event event) return true; } -// Remove the extra closing brace that was here RollVote LootRollAction::CalculateRollVote(ItemTemplate const* proto) { @@ -237,3 +222,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 +} From 30c36ccbf270ce5c3d790668dc4c7683045af339 Mon Sep 17 00:00:00 2001 From: avirar Date: Sun, 20 Oct 2024 09:38:05 +1100 Subject: [PATCH 5/5] Update LootRollAction.cpp Removed spaces --- src/strategy/actions/LootRollAction.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/strategy/actions/LootRollAction.cpp b/src/strategy/actions/LootRollAction.cpp index 8527b46f6..17f4ccb01 100644 --- a/src/strategy/actions/LootRollAction.cpp +++ b/src/strategy/actions/LootRollAction.cpp @@ -149,7 +149,6 @@ bool LootRollAction::Execute(Event event) // break; // } // } - return true; }