init=auto

This commit is contained in:
Yunfan Li
2023-10-05 00:59:08 +08:00
parent 4672b3edcf
commit ac6f7a1e98
7 changed files with 122 additions and 21 deletions

View File

@@ -3514,7 +3514,91 @@ uint32 PlayerbotAI::GetEquipGearScore(Player* player, bool withBags, bool withBa
return 0;
}
void PlayerbotAI::_fillGearScoreData(Player* player, Item* item, std::vector<uint32>* gearScore, uint32& twoHandScore)
uint32 PlayerbotAI::GetMixedGearScore(Player* player, bool withBags, bool withBank)
{
std::vector<uint32> gearScore(EQUIPMENT_SLOT_END);
uint32 twoHandScore = 0;
for (uint8 i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; ++i)
{
if (Item* item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, i))
_fillGearScoreData(player, item, &gearScore, twoHandScore, true);
}
if (withBags)
{
// check inventory
for (uint8 i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; ++i)
{
if (Item* item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, i))
_fillGearScoreData(player, item, &gearScore, twoHandScore, true);
}
// check bags
for (uint8 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i)
{
if (Bag* pBag = (Bag*)player->GetItemByPos(INVENTORY_SLOT_BAG_0, i))
{
for (uint32 j = 0; j < pBag->GetBagSize(); ++j)
{
if (Item* item2 = pBag->GetItemByPos(j))
_fillGearScoreData(player, item2, &gearScore, twoHandScore, true);
}
}
}
}
if (withBank)
{
for (uint8 i = BANK_SLOT_ITEM_START; i < BANK_SLOT_ITEM_END; ++i)
{
if (Item* item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, i))
_fillGearScoreData(player, item, &gearScore, twoHandScore, true);
}
for (uint8 i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i)
{
if (Item* item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, i))
{
if (item->IsBag())
{
Bag* bag = (Bag*)item;
for (uint8 j = 0; j < bag->GetBagSize(); ++j)
{
if (Item* item2 = bag->GetItemByPos(j))
_fillGearScoreData(player, item2, &gearScore, twoHandScore, true);
}
}
}
}
}
uint8 count = EQUIPMENT_SLOT_END - 2; // ignore body and tabard slots
uint32 sum = 0;
// check if 2h hand is higher level than main hand + off hand
if (gearScore[EQUIPMENT_SLOT_MAINHAND] + gearScore[EQUIPMENT_SLOT_OFFHAND] < twoHandScore * 2)
{
gearScore[EQUIPMENT_SLOT_OFFHAND] = 0; // off hand is ignored in calculations if 2h weapon has higher score
--count;
gearScore[EQUIPMENT_SLOT_MAINHAND] = twoHandScore;
}
for (uint8 i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; ++i)
{
sum += gearScore[i];
}
if (count)
{
uint32 res = uint32(sum / count);
return res;
}
return 0;
}
void PlayerbotAI::_fillGearScoreData(Player* player, Item* item, std::vector<uint32>* gearScore, uint32& twoHandScore, bool mixed)
{
if (!item)
return;
@@ -3524,7 +3608,7 @@ void PlayerbotAI::_fillGearScoreData(Player* player, Item* item, std::vector<uin
return;
uint8 type = proto->InventoryType;
uint32 level = proto->ItemLevel;
uint32 level = mixed ? proto->ItemLevel * (1 + proto->Quality) : proto->ItemLevel;
switch (type)
{