Skip to content

Commit

Permalink
Random gear max reqLevel diff is now set directly with config without…
Browse files Browse the repository at this point in the history
… wierd formulas
  • Loading branch information
celguar committed Nov 5, 2023
1 parent d9c48b3 commit 2873a32
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 12 deletions.
2 changes: 1 addition & 1 deletion playerbot/PlayerbotAIConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ bool PlayerbotAIConfig::Initialize()
mediumMana = config.GetIntDefault("AiPlayerbot.MediumMana", 40);

randomGearMaxLevel = config.GetIntDefault("AiPlayerbot.RandomGearMaxLevel", 500);
randomGearMaxDiff = config.GetIntDefault("AiPlayerbot.RandomGearMaxDiff", 5);
randomGearMaxDiff = config.GetIntDefault("AiPlayerbot.RandomGearMaxDiff", 11);
LoadList<list<uint32> >(config.GetStringDefault("AiPlayerbot.RandomGearBlacklist", ""), randomGearBlacklist);
LoadList<list<uint32> >(config.GetStringDefault("AiPlayerbot.RandomGearWhitelist", ""), randomGearWhitelist);
randomGearProgression = config.GetBoolDefault("AiPlayerbot.RandomGearProgression", true);
Expand Down
22 changes: 11 additions & 11 deletions playerbot/PlayerbotFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1650,6 +1650,11 @@ void PlayerbotFactory::InitEquipment(bool incremental, bool syncWithMaster)
if (proto->ItemLevel > maxItemLevel)
continue;

// do not use items that required level is too low compared to bot's level
uint32 reqLevel = sRandomItemMgr.GetMinLevelFromCache(newItemId);
if (reqLevel && proto->Quality < ITEM_QUALITY_LEGENDARY && abs((int)bot->GetLevel() - (int)reqLevel) > sPlayerbotAIConfig.randomGearMaxDiff)
continue;

// filter tank weapons
if (slot == EQUIPMENT_SLOT_OFFHAND && (specId == 3 || specId == 5) && !(proto->Class == ITEM_CLASS_ARMOR && proto->SubClass == ITEM_SUBCLASS_ARMOR_SHIELD))
continue;
Expand Down Expand Up @@ -1703,11 +1708,6 @@ void PlayerbotFactory::InitEquipment(bool incremental, bool syncWithMaster)
}
}

// check req level difference from config
int delta = sPlayerbotAIConfig.randomGearMaxDiff + (80 - bot->GetLevel()) / 10;
if (proto->Quality < ITEM_QUALITY_LEGENDARY && ((int)bot->GetLevel() - (int)sRandomItemMgr.GetMinLevelFromCache(newItemId) > delta))
continue;

Item* oldItem = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, slot);
ItemPrototype const* oldProto = oldItem ? oldItem->GetProto() : nullptr;
//uint32 oldStatValue = oldItem ? sRandomItemMgr.GetStatWeight(oldProto->ItemId, specId) : 0;
Expand Down Expand Up @@ -1911,9 +1911,9 @@ void PlayerbotFactory::InitSecondEquipmentSet()
if (proto->ItemLevel > sPlayerbotAIConfig.randomGearMaxLevel)
continue;

// check req level difference from config
int delta = sPlayerbotAIConfig.randomGearMaxDiff + (80 - bot->GetLevel()) / 10;
if ((int)bot->GetLevel() - (int)sRandomItemMgr.GetMinLevelFromCache(itemId) > delta)
// do not use items that required level is too low compared to bot's level
uint32 reqLevel = sRandomItemMgr.GetMinLevelFromCache(itemId);
if (reqLevel && proto->Quality < ITEM_QUALITY_LEGENDARY && abs((int)bot->GetLevel() - (int)reqLevel) > sPlayerbotAIConfig.randomGearMaxDiff)
continue;

if (!CanEquipItem(proto, desiredQuality))
Expand Down Expand Up @@ -3263,9 +3263,9 @@ void PlayerbotFactory::InitInventoryEquip()
if (proto->ItemLevel > sPlayerbotAIConfig.randomGearMaxLevel)
continue;

// check req level difference from config
int delta = sPlayerbotAIConfig.randomGearMaxDiff + (80 - bot->GetLevel()) / 10;
if ((int)bot->GetLevel() - (int)sRandomItemMgr.GetMinLevelFromCache(itemId) > delta)
// do not use items that required level is too low compared to bot's level
uint32 reqLevel = sRandomItemMgr.GetMinLevelFromCache(itemId);
if (reqLevel && proto->Quality < ITEM_QUALITY_LEGENDARY && abs((int)bot->GetLevel() - (int)reqLevel) > sPlayerbotAIConfig.randomGearMaxDiff)
continue;

if ((proto->Class != ITEM_CLASS_ARMOR && proto->Class != ITEM_CLASS_WEAPON) || (proto->Bonding == BIND_WHEN_PICKED_UP ||
Expand Down
4 changes: 4 additions & 0 deletions playerbot/aiplayerbot.conf.dist.in
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ AiPlayerbot.RandomGearLoweringChance = 0.15
# Max iLVL Phase 1 = 71(MC, ONY, ZG) | Phase 2(BWL) = 77 | Phase 2.5(AQ) = 88 | Phase 3(NAXX) = 100 (NOT RECOMMENDED SINCE ILVL OVERLAPS BETWEEN TIERS)
AiPlayerbot.RandomGearMaxLevel = 500

# Max difference between bot level and item's required level to be used in randomisation
# Default = 11, means bots level 60 can use items that require (themselves or via quests) level 49 and above
AiPlayerbot.RandomGearMaxDiff = 11

# List of item IDs to exclude from random gear, separated by comma
AiPlayerbot.RandomGearBlacklist = 0

Expand Down
4 changes: 4 additions & 0 deletions playerbot/aiplayerbot.conf.dist.in.tbc
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ AiPlayerbot.RandomGearLoweringChance = 0.15

AiPlayerbot.RandomGearMaxLevel = 500

# Max difference between bot level and item's required level to be used in randomisation
# Default = 11, means bots level 70 can use items that require (themselves or via quests) level 59 and above
AiPlayerbot.RandomGearMaxDiff = 11

# List of item IDs to exclude from random gear, separated by comma
AiPlayerbot.RandomGearBlacklist = 0

Expand Down
4 changes: 4 additions & 0 deletions playerbot/aiplayerbot.conf.dist.in.wotlk
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ AiPlayerbot.RandomGearLoweringChance = 0.15

AiPlayerbot.RandomGearMaxLevel = 500

# Max difference between bot level and item's required level to be used in randomisation
# Default = 11, means bots level 80 can use items that require (themselves or via quests) level 69 and above
AiPlayerbot.RandomGearMaxDiff = 11

# List of item IDs to exclude from random gear, separated by comma
AiPlayerbot.RandomGearBlacklist = 0

Expand Down

0 comments on commit 2873a32

Please sign in to comment.