From 80dbd22ba1f4122a1fbfda18d47ef7c6a5a6b3a0 Mon Sep 17 00:00:00 2001 From: avirar Date: Wed, 5 Nov 2025 09:27:50 +1100 Subject: [PATCH] Fixes equip bug with random suffix rings (#1757) * Check item score of rings/trinkets to determine the correct slot to equip * Early return, removed unecessary if statements, single line statements Simplify logic for equipping items by reducing nested conditions. --- src/strategy/actions/EquipAction.cpp | 31 ++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/src/strategy/actions/EquipAction.cpp b/src/strategy/actions/EquipAction.cpp index 946af5b2..f24d89f7 100644 --- a/src/strategy/actions/EquipAction.cpp +++ b/src/strategy/actions/EquipAction.cpp @@ -271,19 +271,38 @@ void EquipAction::EquipItem(Item* item) { if (equippedItems[1]) { - // Both slots are full - pick the worst item to replace + // Both slots are full - pick the worst item to replace, but only if new item is better StatsWeightCalculator calc(bot); calc.SetItemSetBonus(false); calc.SetOverflowPenalty(false); - float firstItemScore = calc.CalculateItem(equippedItems[0]->GetTemplate()->ItemId); - float secondItemScore = calc.CalculateItem(equippedItems[1]->GetTemplate()->ItemId); + // Calculate new item score with random properties + int32 newItemRandomProp = item->GetItemRandomPropertyId(); + float newItemScore = calc.CalculateItem(itemId, newItemRandomProp); - // If the second slot is worse, place the new item there - if (firstItemScore > secondItemScore) + // Calculate equipped items scores with random properties + int32 firstRandomProp = equippedItems[0]->GetItemRandomPropertyId(); + int32 secondRandomProp = equippedItems[1]->GetItemRandomPropertyId(); + float firstItemScore = calc.CalculateItem(equippedItems[0]->GetTemplate()->ItemId, firstRandomProp); + float secondItemScore = calc.CalculateItem(equippedItems[1]->GetTemplate()->ItemId, secondRandomProp); + + // Determine which slot (if any) should be replaced + bool betterThanFirst = newItemScore > firstItemScore; + bool betterThanSecond = newItemScore > secondItemScore; + + // Early return if new item is not better than either equipped item + if (!betterThanFirst && !betterThanSecond) + return; + + if (betterThanFirst && betterThanSecond) { - dstSlot++; + // New item is better than both - replace the worse of the two equipped items + if (firstItemScore > secondItemScore) + dstSlot++; // Replace second slot (worse) + // else: keep dstSlot as-is (replace first slot) } + else if (betterThanSecond) + dstSlot++; // Only better than second slot - replace it } else {