From 2873a32c5f1209d2380815b93ef1ee7a5d69b363 Mon Sep 17 00:00:00 2001 From: celguar Date: Sun, 5 Nov 2023 04:32:55 +0300 Subject: [PATCH] Random gear max reqLevel diff is now set directly with config without wierd formulas --- playerbot/PlayerbotAIConfig.cpp | 2 +- playerbot/PlayerbotFactory.cpp | 22 +++++++++++----------- playerbot/aiplayerbot.conf.dist.in | 4 ++++ playerbot/aiplayerbot.conf.dist.in.tbc | 4 ++++ playerbot/aiplayerbot.conf.dist.in.wotlk | 4 ++++ 5 files changed, 24 insertions(+), 12 deletions(-) diff --git a/playerbot/PlayerbotAIConfig.cpp b/playerbot/PlayerbotAIConfig.cpp index b0e31ab36..ee813f9d8 100644 --- a/playerbot/PlayerbotAIConfig.cpp +++ b/playerbot/PlayerbotAIConfig.cpp @@ -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 >(config.GetStringDefault("AiPlayerbot.RandomGearBlacklist", ""), randomGearBlacklist); LoadList >(config.GetStringDefault("AiPlayerbot.RandomGearWhitelist", ""), randomGearWhitelist); randomGearProgression = config.GetBoolDefault("AiPlayerbot.RandomGearProgression", true); diff --git a/playerbot/PlayerbotFactory.cpp b/playerbot/PlayerbotFactory.cpp index 45beb3d01..ed65fd36d 100644 --- a/playerbot/PlayerbotFactory.cpp +++ b/playerbot/PlayerbotFactory.cpp @@ -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; @@ -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; @@ -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)) @@ -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 || diff --git a/playerbot/aiplayerbot.conf.dist.in b/playerbot/aiplayerbot.conf.dist.in index b722a3a8d..590b5e7b0 100644 --- a/playerbot/aiplayerbot.conf.dist.in +++ b/playerbot/aiplayerbot.conf.dist.in @@ -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 diff --git a/playerbot/aiplayerbot.conf.dist.in.tbc b/playerbot/aiplayerbot.conf.dist.in.tbc index 439af37ae..2502c4fe3 100644 --- a/playerbot/aiplayerbot.conf.dist.in.tbc +++ b/playerbot/aiplayerbot.conf.dist.in.tbc @@ -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 diff --git a/playerbot/aiplayerbot.conf.dist.in.wotlk b/playerbot/aiplayerbot.conf.dist.in.wotlk index 10815f740..17c423194 100644 --- a/playerbot/aiplayerbot.conf.dist.in.wotlk +++ b/playerbot/aiplayerbot.conf.dist.in.wotlk @@ -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