From 59037fc4170d888e6469082fdc7d99450d702dbd Mon Sep 17 00:00:00 2001 From: ben-tk <45545085+ben-tk@users.noreply.github.com> Date: Wed, 24 Aug 2022 18:16:28 -0400 Subject: [PATCH] Fixed Mimics dropping multiple of the same item. Nerfed the drop rate of the items. Made the Toy Sled less likely to eat your one guaranteed Ice Mimic drop --- NPCs/CalamityGlobalNPCLoot.cs | 50 ++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/NPCs/CalamityGlobalNPCLoot.cs b/NPCs/CalamityGlobalNPCLoot.cs index 7ec579780f..06632504c3 100644 --- a/NPCs/CalamityGlobalNPCLoot.cs +++ b/NPCs/CalamityGlobalNPCLoot.cs @@ -126,16 +126,19 @@ namespace CalamityMod.NPCs break; // Mimic - // Drops all of its items Calamity Style @ 33.33% each + // Drops all of its items Calamity Style @ 25% each // This requires erasing its vanilla behavior. case NPCID.Mimic: try { - // Remove the vanilla loot rule which controls all Mimic drops. - var mimicLootRules = npcLoot.Get(false); - mimicLootRules.RemoveAll((rule) => rule is OneFromOptionsDropRule mimicItems && mimicItems.dropIds[0] == ItemID.DualHook); + npcLoot.RemoveWhere((rule) => + { + if (rule is OneFromOptionsDropRule vanillaItems) + return vanillaItems.dropIds[0] == ItemID.DualHook; + return false; + }); - var mimicItems = new int[] + int[] mimicItems = new int[] { ItemID.MagicDagger, ItemID.CrossNecklace, @@ -147,7 +150,7 @@ namespace CalamityMod.NPCs // Mimics will not drop any items if spawned from statues. var notStatue = npcLoot.DefineConditionalDropSet(new Conditions.NotFromStatue()); - notStatue.Add(DropHelper.CalamityStyle(DropHelper.BagWeaponDropRateFraction, mimicItems)); + notStatue.Add(DropHelper.CalamityStyle(DropHelper.NormalWeaponDropRateFraction, mimicItems)); } catch (ArgumentNullException) { } break; @@ -185,26 +188,35 @@ namespace CalamityMod.NPCs break; // Ice Mimic - // Drops all of its items Calamity Style @ 33.33% each - // This requires erasing its bizarre vanilla behavior involving the Toy Sled. + // Drops all of its items Calamity Style @ 25% each, Toy Sled is weighted much lower because it's a pet + // This requires erasing its vanilla behavior involving the Toy Sled. case NPCID.IceMimic: try { - // Remove the vanilla loot rule which controls all Ice Mimic drops. - var iceMimicRootRules = npcLoot.Get(false); - iceMimicRootRules.RemoveAll((rule) => rule is CommonDrop sledDrop && sledDrop.itemId == ItemID.ToySled); + npcLoot.RemoveWhere((rule) => + { + if (rule is OneFromOptionsDropRule vanillaItems) + return vanillaItems.dropIds[0] == ItemID.Frostbrand; + return false; + }); + npcLoot.RemoveWhere((rule) => + { + if (rule is CommonDrop sledDrop) + return sledDrop.itemId == ItemID.ToySled; + return false; + }); - var iceMimicItems = new int[] - { - ItemID.Frostbrand, - ItemID.IceBow, - ItemID.FlowerofFrost, - ItemID.ToySled, - }; + WeightedItemStack[] iceMimicItems = new WeightedItemStack[] + { + ItemID.Frostbrand, + ItemID.IceBow, + ItemID.FlowerofFrost, + new WeightedItemStack(ItemID.ToySled, 0.25f, 1, 1), + }; // Ice Mimics will not drop any items if spawned from statues. var notStatue = npcLoot.DefineConditionalDropSet(new Conditions.NotFromStatue()); - notStatue.Add(DropHelper.CalamityStyle(DropHelper.BagWeaponDropRateFraction, iceMimicItems)); + notStatue.Add(DropHelper.CalamityStyle(DropHelper.NormalWeaponDropRateFraction, iceMimicItems)); } catch (ArgumentNullException) { } break;