Loot roll config

This commit is contained in:
Yunfan Li
2024-02-12 13:59:24 +08:00
parent 187989ddd1
commit 0b105e70d7
4 changed files with 63 additions and 20 deletions

View File

@@ -162,6 +162,10 @@ AiPlayerbot.AddClassCommand = 1
# Default: 0 (disabled)
AiPlayerbot.FreeMethodLoot = 0
# Bots loot roll level (0 = pass, 1 = greed, 2 = need)
# Default: 1 (greed)
AiPlayerbot.LootRollLevel = 1
# Bots pick their quest reward (yes = picks first useful item, no = list all rewards, ask = pick useful item and lists if multiple)
AiPlayerbot.AutoPickReward = no

View File

@@ -273,6 +273,7 @@ bool PlayerbotAIConfig::Initialize()
// SPP automation
freeMethodLoot = sConfigMgr->GetOption<bool>("AiPlayerbot.FreeMethodLoot", false);
lootRollLevel = sConfigMgr->GetOption<int32>("AiPlayerbot.LootRollLevel", 1);
autoPickReward = sConfigMgr->GetOption<std::string>("AiPlayerbot.AutoPickReward", "yes");
autoEquipUpgradeLoot = sConfigMgr->GetOption<bool>("AiPlayerbot.AutoEquipUpgradeLoot", true);
equipUpgradeThreshold = sConfigMgr->GetOption<float>("AiPlayerbot.EquipUpgradeThreshold", 1.1f);

View File

@@ -161,6 +161,7 @@ class PlayerbotAIConfig
uint32 botActiveAlone;
bool freeMethodLoot;
int32 lootRollLevel;
std::string autoPickReward;
bool autoEquipUpgradeLoot;
float equipUpgradeThreshold;

View File

@@ -4,7 +4,9 @@
#include "LootRollAction.h"
#include "Event.h"
#include "Group.h"
#include "ItemUsageValue.h"
#include "PlayerbotAIConfig.h"
#include "Playerbots.h"
#include "LootAction.h"
@@ -16,16 +18,62 @@ bool LootRollAction::Execute(Event event)
if (!group)
return false;
WorldPacket p(event.getPacket()); //WorldPacket packet for CMSG_LOOT_ROLL, (8+4+1)
ObjectGuid guid;
uint32 slot;
uint8 rollType;
p.rpos(0); //reset packet pointer
p >> guid; //guid of the item rolled
p >> slot; //number of players invited to roll
p >> rollType; //need,greed or pass on roll
std::vector<Roll*> rolls = group->GetRolls();
for (Roll* &roll : rolls) {
if (roll->playerVote.find(bot->GetGUID())->second != NOT_EMITED_YET) {
continue;
}
ObjectGuid guid = roll->itemGUID;
uint32 slot = roll->itemSlot;
uint32 itemId = roll->itemid;
RollVote vote = PASS;
ItemTemplate const *proto = sObjectMgr->GetItemTemplate(itemId);
if (!proto)
continue;
ItemUsage usage = AI_VALUE2(ItemUsage, "item usage", itemId);
switch (proto->Class)
{
case ITEM_CLASS_WEAPON:
case ITEM_CLASS_ARMOR:
if (usage == ITEM_USAGE_EQUIP || usage == ITEM_USAGE_REPLACE) {
vote = NEED;
}
else if (usage != ITEM_USAGE_NONE) {
vote = GREED;
}
break;
default:
if (StoreLootAction::IsLootAllowed(itemId, botAI))
vote = NEED;
break;
}
if (sPlayerbotAIConfig->lootRollLevel == 0) {
vote = PASS;
} else if (sPlayerbotAIConfig->lootRollLevel == 1) {
if (vote == NEED) {
vote = GREED;
} else if (vote == GREED) {
vote = PASS;
}
}
switch (group->GetLootMethod())
{
case MASTER_LOOT:
case FREE_FOR_ALL:
group->CountRollVote(bot->GetGUID(), guid, PASS);
break;
default:
group->CountRollVote(bot->GetGUID(), guid, vote);
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
// p >> slot; //number of players invited to roll
// p >> rollType; //need,greed or pass on roll
// std::vector<Roll*> rolls = group->GetRolls();
// bot->Say("guid:" + std::to_string(guid.GetCounter()) +
@@ -74,17 +122,6 @@ bool LootRollAction::Execute(Event event)
// }
// }
switch (group->GetLootMethod())
{
case MASTER_LOOT:
case FREE_FOR_ALL:
group->CountRollVote(bot->GetGUID(), guid, PASS);
break;
default:
group->CountRollVote(bot->GetGUID(), guid, vote);
break;
}
return true;
}