From cf5a686136a79be6684de61c16949600dc20ba26 Mon Sep 17 00:00:00 2001 From: celguar Date: Tue, 17 Oct 2023 23:53:21 +0300 Subject: [PATCH] Randomiser: skip offhand that is better than mainhand to make sure mainhand weapon is better only applies to fury warriors, rogues, enhance shamans (tbc+) and DKs --- playerbot/PlayerbotFactory.cpp | 53 ++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/playerbot/PlayerbotFactory.cpp b/playerbot/PlayerbotFactory.cpp index 8e1162a61..02c2ef61f 100644 --- a/playerbot/PlayerbotFactory.cpp +++ b/playerbot/PlayerbotFactory.cpp @@ -1727,6 +1727,59 @@ void PlayerbotFactory::InitEquipment(bool incremental, bool syncWithMaster) if (newStatValue <= 0) continue; + // skip off hand if main hand is worse +#ifdef MANGOSBOT_ZERO + if (proto->IsWeapon() && slot == EQUIPMENT_SLOT_OFFHAND && (bot->getClass() == CLASS_ROGUE || specId == 2)) +#endif +#ifdef MANGOSBOT_ONE + if (proto->IsWeapon() && slot == EQUIPMENT_SLOT_OFFHAND && (bot->getClass() == CLASS_ROGUE || specId == 2 || specId == 21)) +#endif +#ifdef MANGOSBOT_TWO + if (proto->IsWeapon() && slot == EQUIPMENT_SLOT_OFFHAND && (bot->getClass() == CLASS_ROGUE || specId == 2 || specId == 21 || bot->getClass == CLASS_DEATH_KNIGHT)) +#endif + { + bool betterValue = false; + bool betterDamage = false; + bool betterDps = false; + Item* mhItem = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND); + if (mhItem && mhItem->GetProto()) + { + ItemPrototype const* mhProto = mhItem->GetProto(); + uint32 mhStatValue = sRandomItemMgr.GetLiveStatWeight(bot, mhProto->ItemId, specId); + if (newStatValue > mhStatValue) + betterValue = true; + + uint32 mhDps = 0; + uint32 ohDps = 0; + uint32 mhDamage = 0; + uint32 ohDamage = 0; + for (int i = 0; i < MAX_ITEM_PROTO_DAMAGES; i++) + { + if (mhProto->Damage[i].DamageMax == 0) + break; + + mhDamage = mhProto->Damage[i].DamageMax; + + mhDps = (mhProto->Damage[i].DamageMin + mhProto->Damage[i].DamageMax) / (float)(mhProto->Delay / 1000.0f) / 2; + } + for (int i = 0; i < MAX_ITEM_PROTO_DAMAGES; i++) + { + if (proto->Damage[i].DamageMax == 0) + break; + + ohDamage = proto->Damage[i].DamageMax; + + ohDps = (proto->Damage[i].DamageMin + proto->Damage[i].DamageMax) / (float)(proto->Delay / 1000.0f) / 2; + } + if (ohDps > mhDps) + betterDps = true; + if (ohDamage > mhDamage) + betterDamage = true; + } + if (betterDps || (betterDamage && betterValue)) + continue; + } + if (incremental && oldItem && oldStatValue >= newStatValue && oldStatValue > 1) continue;