From b95795d30d668273cb50edfe16ee2a8754dc1a4a Mon Sep 17 00:00:00 2001 From: Ozzatron Date: Sun, 14 Aug 2022 20:08:23 -0400 Subject: [PATCH] treat loot rule edits like IL edits, similar complexity --- Items/CalamityGlobalItemLoot.cs | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/Items/CalamityGlobalItemLoot.cs b/Items/CalamityGlobalItemLoot.cs index a8f370db33..1293dc2de5 100644 --- a/Items/CalamityGlobalItemLoot.cs +++ b/Items/CalamityGlobalItemLoot.cs @@ -324,22 +324,29 @@ namespace CalamityMod.Items #region Miscellaneous // Bat Hook is now acquired from Vampires. case ItemID.GoodieBag: - SequentialRulesNotScalingWithLuckRule spaghettiBag = null; - foreach (IItemDropRule rule in rules) - if (rule is SequentialRulesNotScalingWithLuckRule s) - spaghettiBag = s; - if (spaghettiBag is null) - break; - foreach (IItemDropRule rule in spaghettiBag.rules) - if (rule is CommonDropNotScalingWithLuck WHY && WHY.itemId == ItemID.BatHook) - { - WHY.chanceNumerator = 0; - WHY.chanceDenominator = 1; - } + RemoveBatHookFromGoodieBag(rules); break; #endregion } } #endregion + + #region Goodie Bag Bat Hook + private static void RemoveBatHookFromGoodieBag(IList rules) + { + SequentialRulesNotScalingWithLuckRule rule1 = null; + foreach (IItemDropRule rule in rules) + if (rule is SequentialRulesNotScalingWithLuckRule s) + rule1 = s; + if (rule1 is null) + return; + foreach (IItemDropRule rule in rule1.rules) + if (rule is CommonDropNotScalingWithLuck rule2 && rule2.itemId == ItemID.BatHook) + { + rule2.chanceNumerator = 0; + rule2.chanceDenominator = 1; + } + } + #endregion } }