Update PlayerbotAI.cpp

This commit is contained in:
Alex Dcnh
2025-07-04 19:19:29 +02:00
committed by GitHub
parent 326783ed4f
commit 8fd188ff3b

View File

@@ -4434,35 +4434,39 @@ void PlayerbotAI::RemoveShapeshift()
// https://wowpedia.fandom.com/wiki/API_GetAverageItemLevel // https://wowpedia.fandom.com/wiki/API_GetAverageItemLevel
uint32 PlayerbotAI::GetEquipGearScore(Player* player) uint32 PlayerbotAI::GetEquipGearScore(Player* player)
{ {
constexpr uint8 BASE_SLOTS = 17; // everything except Body & Tabard constexpr uint8 TOTAL_SLOTS = 17; // every slot except Body & Tabard
uint32 sumLevel = 0; uint32 sumLevel = 0;
uint8 divisor = BASE_SLOTS;
/* ---------- 0. Detect “ignore off-hand” situations --------- */
Item* main = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND); Item* main = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND);
Item* off = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); Item* off = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND);
bool twoHandMain = false; bool ignoreOffhand = false; // true → divisor = 16
if (main) if (main)
twoHandMain = (main->GetTemplate()->InventoryType == INVTYPE_2HWEAPON); {
bool twoHand = (main->GetTemplate()->InventoryType == INVTYPE_2HWEAPON);
if (twoHand && !player->HasAura(SPELL_TITAN_GRIP))
ignoreOffhand = true; // classic 2-hander
}
else if (!off) // both hands empty
ignoreOffhand = true;
/* ---------- 1. Add up item-levels ---------- */ /* ---------- 1. Sum up item-levels -------------------------- */
for (uint8 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot) for (uint8 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot)
{ {
if (slot == EQUIPMENT_SLOT_BODY || slot == EQUIPMENT_SLOT_TABARD) if (slot == EQUIPMENT_SLOT_BODY || slot == EQUIPMENT_SLOT_TABARD)
continue; continue; // Blizzard never counts these
if (ignoreOffhand && slot == EQUIPMENT_SLOT_OFFHAND)
continue; // skip off-hand in 2-H case
if (Item* it = player->GetItemByPos(INVENTORY_SLOT_BAG_0, slot)) if (Item* it = player->GetItemByPos(INVENTORY_SLOT_BAG_0, slot))
sumLevel += it->GetTemplate()->ItemLevel; sumLevel += it->GetTemplate()->ItemLevel; // missing items add 0
} }
/* ---------- 2. Adjust divisor -------------- */ /* ---------- 2. Divide by 17 or 16 -------------------------- */
if ((twoHandMain && !player->HasAura(SPELL_TITAN_GRIP)) || // real 2-H weapon const uint8 divisor = ignoreOffhand ? TOTAL_SLOTS - 1 : TOTAL_SLOTS; // 16 or 17
(!main && !off)) // both hands empty return sumLevel / divisor;
{
divisor = BASE_SLOTS - 1; // use 16
}
return divisor ? sumLevel / divisor : 0;
} }
// NOTE : function rewritten as flags "withBags" and "withBank" not used, and _fillGearScoreData sometimes attribute // NOTE : function rewritten as flags "withBags" and "withBank" not used, and _fillGearScoreData sometimes attribute