From 5d15472cb729fd4e1d9b216abda3fc2abe623d98 Mon Sep 17 00:00:00 2001 From: CongratsIsTrash <1q2w3e4dasd@gmail.com> Date: Wed, 26 Nov 2025 14:16:59 -0500 Subject: [PATCH] Sweeping changes to crate loot Including removal of most biome-specific material drops Includes the Hardmode ore crate bug fix at long last Also adds alternative Auric Ore obtainment method --- Enums/HardmodeCrateType.cs | 9 + Items/CalamityGlobalItemLoot.cs | 151 ++++---- Items/Fishing/AstralCatches/AstralCrate.cs | 69 +--- Items/Fishing/AstralCatches/MonolithCrate.cs | 37 +- .../BrimstoneCragCatches/BrimstoneCrate.cs | 27 +- .../Fishing/BrimstoneCragCatches/SlagCrate.cs | 35 +- .../SulphurCatches/HydrothermalCrate.cs | 83 +--- .../Fishing/SulphurCatches/SulphurousCrate.cs | 75 +--- .../SunkenSeaCatches/EutrophicCrate.cs | 45 +-- Items/Fishing/SunkenSeaCatches/PrismCrate.cs | 48 +-- Items/Placeables/Ores/AuricOre.cs | 11 +- Utilities/DropHelper.cs | 364 ++++++++++++++++-- 12 files changed, 507 insertions(+), 447 deletions(-) create mode 100644 Enums/HardmodeCrateType.cs diff --git a/Enums/HardmodeCrateType.cs b/Enums/HardmodeCrateType.cs new file mode 100644 index 0000000000..6febfd2600 --- /dev/null +++ b/Enums/HardmodeCrateType.cs @@ -0,0 +1,9 @@ +namespace CalamityMod.Enums +{ + public enum HardmodeCrateType + { + Biome, + Mythril, + Titanium + } +} diff --git a/Items/CalamityGlobalItemLoot.cs b/Items/CalamityGlobalItemLoot.cs index 12b004b8cd..e01900cf49 100644 --- a/Items/CalamityGlobalItemLoot.cs +++ b/Items/CalamityGlobalItemLoot.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using CalamityMod.Enums; using CalamityMod.Items.Accessories; using CalamityMod.Items.Materials; using CalamityMod.Items.PermanentBoosters; @@ -25,12 +26,6 @@ namespace CalamityMod.Items public override void ModifyItemLoot(Item item, ItemLoot loot) { Fraction fifteenPercent = new Fraction(15, 100); - static bool CryonicAvailable() - { - if (!DownedBossSystem.downedCryogen) - return false; - return (NPC.downedMechBoss1.ToInt() + NPC.downedMechBoss2.ToInt() + NPC.downedMechBoss3.ToInt()) >= 2; - } switch (item.type) { @@ -270,91 +265,47 @@ namespace CalamityMod.Items #endregion #region Fishing Crates - // TODO -- What is all this shit? case ItemID.WoodenCrate: case ItemID.WoodenCrateHard: - loot.Add(ModContent.ItemType(), 4, 3, 5); // 25% 3-5 Wulfrum Scrap + // We do not need to pop Hardmode ores out of Pearlwood Crates. They do not drop higher tier ores. break; - case ItemID.IronCrate: case ItemID.IronCrateHard: - loot.Add(ModContent.ItemType(), 4, 5, 8); // 25% 5-8 Wulfrum Scrap - loot.Add(ModContent.ItemType(), 4, 5, 8); // 25% 5-8 Ancient Bone Dust + RemoveHardmodeOresFromStandardCrates(loot); + loot.AddHardmodeOresToCrates(HardmodeCrateType.Mythril); break; - // these drops are not available in hardmode because this crate will stop dropping + // Non-crafted underground Gold Chest loot @ 20%; Individually 5% case ItemID.GoldenCrate: - loot.Add(ItemID.FlareGun, 10); // 10% Flare Gun - loot.Add(ItemID.ShoeSpikes, 10); // 10% Shoe Spikes (BUT NOT CLIMBING CLAWS?) - loot.Add(ItemID.BandofRegeneration, 10); // 10% Band of Regeneration + loot.Add(new OneFromOptionsNotScaledWithLuckDropRule(5, 1, + ItemID.FlareGun, + ItemID.Mace, + ItemID.BandofRegeneration, + ItemID.ShoeSpikes)); // Climbing Claws is in Wooden/Pearlwood (vanilla) in case you're curious break; case ItemID.GoldenCrateHard: - // Post-Yharon: 15% 30-40 Auric Ore - loot.AddIf(() => DownedBossSystem.downedYharon, ModContent.ItemType(), fifteenPercent, 30, 40); + RemoveHardmodeOresFromStandardCrates(loot); + loot.AddHardmodeOresToCrates(HardmodeCrateType.Titanium); + loot.Add(new OneFromOptionsNotScaledWithLuckDropRule(5, 1, + ItemID.FlareGun, + ItemID.Mace, + ItemID.BandofRegeneration, + ItemID.ShoeSpikes)); break; - case ItemID.CorruptFishingCrate: - case ItemID.CrimsonFishingCrate: case ItemID.CorruptFishingCrateHard: case ItemID.CrimsonFishingCrateHard: - loot.Add(ModContent.ItemType(), fifteenPercent, 5, 8); // 15% 5-8 Blighted Gel - break; - - case ItemID.HallowedFishingCrate: // WHY case ItemID.HallowedFishingCrateHard: - var postProv = loot.DefineConditionalDropSet(() => DownedBossSystem.downedProvidence); - postProv.Add(ModContent.ItemType(), fifteenPercent, 5, 10); // 15% 5-10 Unholy Essence - break; - - case ItemID.DungeonFishingCrate: case ItemID.DungeonFishingCrateHard: - loot.AddIf(() => NPC.downedPlantBoss, ItemID.Ectoplasm, 10, 1, 5); // 10% 1-5 Ectoplasm - loot.AddIf(() => DownedBossSystem.downedPolterghast, ModContent.ItemType(), 10, 1, 5); // 10% 1-5 Necroplasm - break; - - case ItemID.JungleFishingCrate: case ItemID.JungleFishingCrateHard: - loot.Add(ModContent.ItemType(), new Fraction(1, 5), 1, 3); // 20% 1-3 Murky Paste - var postPlant = loot.DefineConditionalDropSet(() => NPC.downedPlantBoss); - postPlant.Add(ModContent.ItemType(), 5, 16, 28); // 20% 16-28 Perennial Ore - postPlant.Add(ModContent.ItemType(), fifteenPercent, 4, 7); // 15% 4-7 Perennial Bar - loot.AddIf(() => NPC.downedGolemBoss, ModContent.ItemType(), 5, 3, 6); // 20% 3-6 Plague Cell Canister - var uelibloom = loot.DefineConditionalDropSet(() => DownedBossSystem.downedProvidence); - uelibloom.Add(ModContent.ItemType(), 5, 16, 28); // 20% 16-28 Uelibloom Ore - uelibloom.Add(ModContent.ItemType(), fifteenPercent, 4, 7); // 15% 4-7 Uelibloom Bar - break; - - case ItemID.FloatingIslandFishingCrate: case ItemID.FloatingIslandFishingCrateHard: - var evilBossTwo = loot.DefineConditionalDropSet(() => DownedBossSystem.downedHiveMind || DownedBossSystem.downedPerforator); - evilBossTwo.Add(ModContent.ItemType(), 5, 16, 28); // 20% 16-28 Aerialite Ore - evilBossTwo.Add(ModContent.ItemType(), fifteenPercent, 4, 7); // 15% 4-7 Aerialite Bar - loot.AddIf(() => Main.hardMode, ModContent.ItemType(), 5, 2, 4); // 20% 2-4 Essence of Sunlight - loot.AddIf(() => NPC.downedMoonlord, ModContent.ItemType(), 5, 16, 28); // 20% 16-28 Exodium Clusters - break; - - case ItemID.FrozenCrate: case ItemID.FrozenCrateHard: - var cryonic = loot.DefineConditionalDropSet(CryonicAvailable); - cryonic.Add(ModContent.ItemType(), 5, 16, 28); // 20% 16-28 Cryonic Ore - cryonic.Add(ModContent.ItemType(), fifteenPercent, 4, 7); // 15% 4-7 Cryonic Bar - loot.AddIf(() => Main.hardMode, ModContent.ItemType(), 5, 2, 4); // 20% 2-4 Essence of Eleum - break; - - case ItemID.LavaCrate: case ItemID.LavaCrateHard: - loot.AddIf(() => Main.hardMode, ModContent.ItemType(), 5, 2, 4); // 20% 2-4 Essence of Havoc - break; - - // Calamity does not touch Oasis Crates yet - case ItemID.OasisCrate: case ItemID.OasisCrateHard: - break; - - // Calamity does not touch Ocean Crates yet - case ItemID.OceanCrate: case ItemID.OceanCrateHard: + RemoveHardmodeOresFromBiomeCrates(loot); + loot.AddHardmodeOresToCrates(HardmodeCrateType.Biome); break; #endregion @@ -525,6 +476,70 @@ namespace CalamityMod.Items } #endregion + #region Fishing Crate Loot Rule Manipulation + private static void RemoveHardmodeOresFromStandardCrates(ItemLoot loot) + { + List rules = loot.Get(false); + + // This is the primary rule which contains every drop + AlwaysAtleastOneSuccessDropRule mainRule = null; + foreach (IItemDropRule rule in rules) + if (rule is AlwaysAtleastOneSuccessDropRule a) + mainRule = a; + if (mainRule is null) + return; + + // Find ones that are supposed to be for the ore and not the other loot + foreach (IItemDropRule rule in mainRule.rules) + { + // Hardmode ores/bars are both nested within *another* nested rule + if (rule is SequentialRulesNotScalingWithLuckRule oreRule) + { + // Confirm that this is for the ore/bar then pop the numerator for the big rule + foreach (IItemDropRule nestedRule in oreRule.rules) + { + if (nestedRule is SequentialRulesNotScalingWithLuckRule s) + { + oreRule.chanceNumerator = 0; + return; + } + } + } + } + } + + private static void RemoveHardmodeOresFromBiomeCrates(ItemLoot loot) + { + List rules = loot.Get(false); + + // This is the primary rule which contains every drop + AlwaysAtleastOneSuccessDropRule mainRule = null; + foreach (IItemDropRule rule in rules) + if (rule is AlwaysAtleastOneSuccessDropRule a) + mainRule = a; + if (mainRule is null) + return; + + // Find ones that are supposed to be for the ore and not the other loot + foreach (IItemDropRule rule in mainRule.rules) + { + // Hardmode ores/bars are both nested within *another* nested rule + if (rule is SequentialRulesNotScalingWithLuckRule oreRule) + { + // Confirm that this is for the ore/bar then pop the numerator for the big rule + foreach (IItemDropRule nestedRule in oreRule.rules) + { + if (nestedRule is OneFromRulesRule o) + { + oreRule.chanceNumerator = 0; + return; + } + } + } + } + } + #endregion + #region Goodie Bag Bat Hook private static void RemoveBatHookFromGoodieBag(ItemLoot loot) { diff --git a/Items/Fishing/AstralCatches/AstralCrate.cs b/Items/Fishing/AstralCatches/AstralCrate.cs index 690c4c8e8b..40ed274c6a 100644 --- a/Items/Fishing/AstralCatches/AstralCrate.cs +++ b/Items/Fishing/AstralCatches/AstralCrate.cs @@ -1,16 +1,6 @@ -using CalamityMod.Items.Accessories; -using CalamityMod.Items.Critters; -using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.Ores; -using CalamityMod.Items.Potions; -using CalamityMod.Items.Weapons.Magic; -using CalamityMod.Items.Weapons.Melee; -using CalamityMod.Items.Weapons.Ranged; -using CalamityMod.Items.Weapons.Rogue; -using CalamityMod.Items.Weapons.Summon; +using CalamityMod.Items.Materials; using CalamityMod.Tiles.Astral; using Terraria; -using Terraria.GameContent.ItemDropRules; using Terraria.ID; using Terraria.ModLoader; @@ -29,18 +19,11 @@ namespace CalamityMod.Items.Fishing.AstralCatches public override void SetDefaults() { + Item.DefaultToPlaceableTile(ModContent.TileType()); Item.width = 32; Item.height = 32; - Item.maxStack = 9999; - Item.consumable = true; - Item.rare = ItemRarityID.Green; Item.value = Item.sellPrice(gold: 1); - Item.createTile = ModContent.TileType(); - Item.useTurn = true; - Item.autoReuse = true; - Item.useAnimation = 15; - Item.useTime = 10; - Item.useStyle = ItemUseStyleID.Swing; + Item.rare = ItemRarityID.Green; } public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) @@ -51,48 +34,14 @@ namespace CalamityMod.Items.Fishing.AstralCatches public override bool CanRightClick() => true; public override void ModifyItemLoot(ItemLoot itemLoot) { - var postAstrumAureus = itemLoot.DefineConditionalDropSet(() => DownedBossSystem.downedAstrumAureus); - var postAstrumDeus = itemLoot.DefineConditionalDropSet(() => DownedBossSystem.downedAstrumDeus); + // 4-10 Starblight Soot @ 50% + // This is our equivalent to Crystal Shards/Ichor + itemLoot.Add(ModContent.ItemType(), 2, 4, 10); - // Materials - itemLoot.Add(ModContent.ItemType(), 1, 5, 10); - itemLoot.Add(ItemID.FallenStar, 1, 5, 10); - itemLoot.Add(ItemID.Meteorite, 5, 10, 20); - itemLoot.Add(ItemID.MeteoriteBar, 10, 1, 3); + // Astrophage @ 5% + itemLoot.Add(ModContent.ItemType(), 20); - postAstrumAureus.Add(ModContent.ItemType(), 5, 2, 5); - postAstrumDeus.Add(ModContent.ItemType(), 5, 10, 20); - postAstrumDeus.Add(ModContent.ItemType(), 10, 1, 3); - postAstrumDeus.Add(ModContent.ItemType(), 4, 5, 10); - - // Weapons (and Starburster Core) - postAstrumAureus.Add(new OneFromOptionsDropRule(10, 1, - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType() - )); - - // Pet - itemLoot.Add(ModContent.ItemType(), 10); - - // Bait - itemLoot.Add(ModContent.ItemType(), 5, 1, 3); - itemLoot.Add(ItemID.EnchantedNightcrawler, 5, 1, 3); - itemLoot.Add(ModContent.ItemType(), 5, 1, 3); - itemLoot.Add(ItemID.Firefly, 3, 1, 3); - - // Potions - postAstrumAureus.Add(ModContent.ItemType(), 10, 1, 3); - postAstrumAureus.Add(ModContent.ItemType(), 10, 1, 3); - itemLoot.AddCratePotionRules(); - - // Money - itemLoot.Add(ItemID.SilverCoin, 1, 10, 90); - itemLoot.Add(ItemID.GoldCoin, 2, 1, 5); + itemLoot.AddBiomeCrateLootRules(); } } } diff --git a/Items/Fishing/AstralCatches/MonolithCrate.cs b/Items/Fishing/AstralCatches/MonolithCrate.cs index 060d03675b..726d74743f 100644 --- a/Items/Fishing/AstralCatches/MonolithCrate.cs +++ b/Items/Fishing/AstralCatches/MonolithCrate.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Critters; -using CalamityMod.Tiles.Astral; +using CalamityMod.Tiles.Astral; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -17,18 +16,11 @@ namespace CalamityMod.Items.Fishing.AstralCatches public override void SetDefaults() { + Item.DefaultToPlaceableTile(ModContent.TileType()); Item.width = 32; Item.height = 32; - Item.maxStack = 9999; - Item.consumable = true; - Item.rare = ItemRarityID.Green; Item.value = Item.sellPrice(gold: 1); - Item.createTile = ModContent.TileType(); - Item.useTurn = true; - Item.autoReuse = true; - Item.useAnimation = 15; - Item.useTime = 10; - Item.useStyle = ItemUseStyleID.Swing; + Item.rare = ItemRarityID.Green; } public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) @@ -39,27 +31,10 @@ namespace CalamityMod.Items.Fishing.AstralCatches public override bool CanRightClick() => true; public override void ModifyItemLoot(ItemLoot itemLoot) { - // Materials - itemLoot.Add(ItemID.FallenStar, 1, 5, 10); - itemLoot.Add(ItemID.Meteorite, 5, 10, 20); - itemLoot.Add(ItemID.MeteoriteBar, 10, 1, 3); + // Astrophage @ 5% + itemLoot.Add(ModContent.ItemType(), 20); - // Pet - itemLoot.Add(ModContent.ItemType(), 10); - - // Bait - itemLoot.Add(ModContent.ItemType(), 5, 1, 3); - itemLoot.Add(ItemID.EnchantedNightcrawler, 5, 1, 3); - itemLoot.Add(ModContent.ItemType(), 5, 1, 3); - - itemLoot.Add(ItemID.Firefly, 3, 1, 3); - - // Potions - itemLoot.AddCratePotionRules(false); - - // Money - itemLoot.Add(ItemID.SilverCoin, 1, 10, 90); - itemLoot.Add(ItemID.GoldCoin, 2, 1, 5); + itemLoot.AddBiomeCrateLootRules(false); } } } diff --git a/Items/Fishing/BrimstoneCragCatches/BrimstoneCrate.cs b/Items/Fishing/BrimstoneCragCatches/BrimstoneCrate.cs index 6a0413d264..fb5785cf59 100644 --- a/Items/Fishing/BrimstoneCragCatches/BrimstoneCrate.cs +++ b/Items/Fishing/BrimstoneCragCatches/BrimstoneCrate.cs @@ -1,6 +1,4 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Items.Potions; -using CalamityMod.Tiles.Crags; +using CalamityMod.Tiles.Crags; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -42,28 +40,7 @@ namespace CalamityMod.Items.Fishing.BrimstoneCragCatches public override bool CanRightClick() => true; public override void ModifyItemLoot(ItemLoot itemLoot) { - // Materials - itemLoot.Add(ItemID.Obsidian, 1, 2, 5); - itemLoot.Add(ItemID.Hellstone, 4, 2, 5); - itemLoot.Add(ItemID.HellstoneBar, 10, 1, 3); - itemLoot.Add(ModContent.ItemType(), 1, 1, 4); - itemLoot.AddIf(() => DownedBossSystem.downedBrimstoneElemental, ModContent.ItemType(), 10, 1, 3); - itemLoot.AddIf(() => DownedBossSystem.downedProvidence, ModContent.ItemType(), 2, 1, 3); - - // Weapons (none) - - // Bait - itemLoot.Add(ItemID.MasterBait, 10, 1, 2); - itemLoot.Add(ItemID.JourneymanBait, 5, 1, 3); - itemLoot.Add(ItemID.ApprenticeBait, 3, 2, 3); - - // Potions - itemLoot.Add(ItemID.InfernoPotion, 10, 1, 3); - itemLoot.AddCratePotionRules(); - - // Money - itemLoot.Add(ItemID.SilverCoin, 1, 10, 90); - itemLoot.Add(ItemID.GoldCoin, 2, 1, 5); + itemLoot.AddBiomeCrateLootRules(); } } } diff --git a/Items/Fishing/BrimstoneCragCatches/SlagCrate.cs b/Items/Fishing/BrimstoneCragCatches/SlagCrate.cs index 55ff0e63e7..a6259f890c 100644 --- a/Items/Fishing/BrimstoneCragCatches/SlagCrate.cs +++ b/Items/Fishing/BrimstoneCragCatches/SlagCrate.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Tiles.Crags; +using CalamityMod.Tiles.Crags; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -17,18 +16,11 @@ namespace CalamityMod.Items.Fishing.BrimstoneCragCatches public override void SetDefaults() { + Item.DefaultToPlaceableTile(ModContent.TileType()); Item.width = 32; Item.height = 32; - Item.maxStack = 9999; - Item.consumable = true; - Item.rare = ItemRarityID.Green; Item.value = Item.sellPrice(gold: 1); - Item.createTile = ModContent.TileType(); - Item.useTurn = true; - Item.autoReuse = true; - Item.useAnimation = 15; - Item.useTime = 10; - Item.useStyle = ItemUseStyleID.Swing; + Item.rare = ItemRarityID.Green; } public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) @@ -39,26 +31,7 @@ namespace CalamityMod.Items.Fishing.BrimstoneCragCatches public override bool CanRightClick() => true; public override void ModifyItemLoot(ItemLoot itemLoot) { - // Materials - itemLoot.Add(ItemID.Obsidian, 1, 2, 5); - itemLoot.Add(ItemID.Hellstone, 4, 2, 5); - itemLoot.Add(ItemID.HellstoneBar, 10, 1, 3); - itemLoot.Add(ModContent.ItemType(), 1, 1, 4); - - // Weapons (none) - - // Bait - itemLoot.Add(ItemID.MasterBait, 10, 1, 2); - itemLoot.Add(ItemID.JourneymanBait, 5, 1, 3); - itemLoot.Add(ItemID.ApprenticeBait, 3, 2, 3); - - // Potions - itemLoot.Add(ItemID.InfernoPotion, 10, 1, 3); - itemLoot.AddCratePotionRules(false); - - // Money - itemLoot.Add(ItemID.SilverCoin, 1, 10, 90); - itemLoot.Add(ItemID.GoldCoin, 2, 1, 5); + itemLoot.AddBiomeCrateLootRules(false); } } } diff --git a/Items/Fishing/SulphurCatches/HydrothermalCrate.cs b/Items/Fishing/SulphurCatches/HydrothermalCrate.cs index 52dad8a28b..547da73a7a 100644 --- a/Items/Fishing/SulphurCatches/HydrothermalCrate.cs +++ b/Items/Fishing/SulphurCatches/HydrothermalCrate.cs @@ -1,9 +1,6 @@ using CalamityMod.Items.Accessories; -using CalamityMod.Items.Materials; using CalamityMod.Items.Pets; -using CalamityMod.Items.Placeables; -using CalamityMod.Items.Placeables.Ores; -using CalamityMod.Items.Potions; +using CalamityMod.Items.Placeables.Furniture; using CalamityMod.Items.Tools.ClimateChange; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; @@ -31,18 +28,11 @@ namespace CalamityMod.Items.Fishing.SulphurCatches public override void SetDefaults() { + Item.DefaultToPlaceableTile(ModContent.TileType()); Item.width = 32; Item.height = 32; - Item.maxStack = 9999; - Item.consumable = true; - Item.rare = ItemRarityID.Green; Item.value = Item.sellPrice(gold: 1); - Item.createTile = ModContent.TileType(); - Item.useTurn = true; - Item.autoReuse = true; - Item.useAnimation = 15; - Item.useTime = 10; - Item.useStyle = ItemUseStyleID.Swing; + Item.rare = ItemRarityID.Green; } public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) @@ -53,51 +43,29 @@ namespace CalamityMod.Items.Fishing.SulphurCatches public override bool CanRightClick() => true; public override void ModifyItemLoot(ItemLoot itemLoot) { - // The contents of this crate depend massively on progression, so it uses a large number of LeadingConditionRules. - var tier1AbyssAvailable = itemLoot.DefineConditionalDropSet(() => DownedBossSystem.downedSlimeGod || Main.hardMode); - var tier2AbyssAvailable = itemLoot.DefineConditionalDropSet(() => DownedBossSystem.downedLeviathan); - var scoriaAvailable = itemLoot.DefineConditionalDropSet(() => NPC.downedGolemBoss); - var tier1AcidRain = itemLoot.DefineConditionalDropSet(() => DownedBossSystem.downedEoCAcidRain); - var tier2AcidRain = itemLoot.DefineConditionalDropSet(() => DownedBossSystem.downedAquaticScourgeAcidRain); - var tier3AcidRain = itemLoot.DefineConditionalDropSet(() => DownedBossSystem.downedPolterghast && DownedBossSystem.downedBoomerDuke); + // 20-50 Blocks @ 100%; Individually 33.33% + itemLoot.Add(new OneFromRulesRule(1, new IItemDropRule[3] + { + ItemDropRule.NotScalingWithLuck(ModContent.ItemType(), 1, 20, 50), + ItemDropRule.NotScalingWithLuck(ModContent.ItemType(), 1, 20, 50), + ItemDropRule.NotScalingWithLuck(ModContent.ItemType(), 1, 20, 50) + })); - // Materials - itemLoot.Add(ModContent.ItemType(), 1, 5, 10); - itemLoot.Add(ModContent.ItemType(), 1, 5, 10); - itemLoot.Add(ModContent.ItemType(), 1, 5, 10); - itemLoot.Add(ModContent.ItemType(), 1, 5, 10); - - tier1AcidRain.Add(ModContent.ItemType(), 10, 1, 3); - tier2AcidRain.Add(ModContent.ItemType(), 10, 1, 3); - tier2AbyssAvailable.Add(ModContent.ItemType(), 5, 2, 5); - tier2AbyssAvailable.Add(ModContent.ItemType(), 5, 2, 5); - tier2AbyssAvailable.Add(ModContent.ItemType(), 5, 2, 5); - scoriaAvailable.Add(ModContent.ItemType(), 5, 16, 28); - scoriaAvailable.Add(ModContent.ItemType(), new Fraction(15, 100), 4, 7); - tier3AcidRain.Add(ModContent.ItemType(), 10, 1, 5); + // Rusty Chest Loot @ 100%; Individually 25% + itemLoot.Add(new OneFromOptionsNotScaledWithLuckDropRule(1, 1, + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType() + )); // Pre-HM Abyss Weapons - tier1AbyssAvailable.Add(new OneFromOptionsDropRule(10, 1, + itemLoot.Add(new OneFromOptionsDropRule(10, 1, ModContent.ItemType(), ModContent.ItemType(), ModContent.ItemType(), ModContent.ItemType(), - ModContent.ItemType() - )); - - // Post-AS Acid Rain Weapons (and Nuclear Rod) - tier2AcidRain.Add(new OneFromOptionsDropRule(10, 1, - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType() - )); - - // Pre-HM Abyss Equipment (and Torrential Tear) - tier1AbyssAvailable.Add(new OneFromOptionsDropRule(4, 1, + ModContent.ItemType(), ModContent.ItemType(), ModContent.ItemType(), ModContent.ItemType(), @@ -105,18 +73,7 @@ namespace CalamityMod.Items.Fishing.SulphurCatches ModContent.ItemType() )); - // Bait - itemLoot.Add(ItemID.MasterBait, 10, 1, 2); - itemLoot.Add(ItemID.JourneymanBait, 5, 1, 3); - itemLoot.Add(ItemID.ApprenticeBait, 3, 2, 3); - - // Potions - itemLoot.Add(ModContent.ItemType(), 10, 1, 3); - itemLoot.AddCratePotionRules(); - - // Money - itemLoot.Add(ItemID.SilverCoin, 1, 10, 90); - itemLoot.Add(ItemID.GoldCoin, 2, 1, 5); + itemLoot.AddBiomeCrateLootRules(); } } } diff --git a/Items/Fishing/SulphurCatches/SulphurousCrate.cs b/Items/Fishing/SulphurCatches/SulphurousCrate.cs index 98d8b825e3..499fdaa098 100644 --- a/Items/Fishing/SulphurCatches/SulphurousCrate.cs +++ b/Items/Fishing/SulphurCatches/SulphurousCrate.cs @@ -1,19 +1,11 @@ using CalamityMod.Items.Accessories; -using CalamityMod.Items.Materials; -using CalamityMod.Items.Pets; -using CalamityMod.Items.Placeables; -using CalamityMod.Items.Potions; -using CalamityMod.Items.Tools.ClimateChange; -using CalamityMod.Items.Weapons.Magic; -using CalamityMod.Items.Weapons.Melee; -using CalamityMod.Items.Weapons.Ranged; -using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Items.Placeables.Furniture; using CalamityMod.Items.Weapons.Summon; +using CalamityMod.Tiles.Abyss; using Terraria; using Terraria.GameContent.ItemDropRules; using Terraria.ID; using Terraria.ModLoader; -using CrateTile = CalamityMod.Tiles.Abyss.SulphurousCrateTile; namespace CalamityMod.Items.Fishing.SulphurCatches { @@ -29,18 +21,11 @@ namespace CalamityMod.Items.Fishing.SulphurCatches public override void SetDefaults() { + Item.DefaultToPlaceableTile(ModContent.TileType()); Item.width = 32; Item.height = 32; - Item.maxStack = 9999; - Item.consumable = true; - Item.rare = ItemRarityID.Green; Item.value = Item.sellPrice(gold: 1); - Item.createTile = ModContent.TileType(); - Item.useTurn = true; - Item.autoReuse = true; - Item.useAnimation = 15; - Item.useTime = 10; - Item.useStyle = ItemUseStyleID.Swing; + Item.rare = ItemRarityID.Green; } public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) @@ -51,47 +36,23 @@ namespace CalamityMod.Items.Fishing.SulphurCatches public override bool CanRightClick() => true; public override void ModifyItemLoot(ItemLoot itemLoot) { - var tier1AbyssAvailable = itemLoot.DefineConditionalDropSet(() => DownedBossSystem.downedSlimeGod || Main.hardMode); - var tier1AcidRain = itemLoot.DefineConditionalDropSet(() => DownedBossSystem.downedEoCAcidRain); + // 20-50 Blocks @ 100%; Individually 33.33% + itemLoot.Add(new OneFromRulesRule(1, new IItemDropRule[3] + { + ItemDropRule.NotScalingWithLuck(ModContent.ItemType(), 1, 20, 50), + ItemDropRule.NotScalingWithLuck(ModContent.ItemType(), 1, 20, 50), + ItemDropRule.NotScalingWithLuck(ModContent.ItemType(), 1, 20, 50) + })); - // Materials - itemLoot.Add(ModContent.ItemType(), 1, 5, 10); - itemLoot.Add(ModContent.ItemType(), 1, 5, 10); - itemLoot.Add(ModContent.ItemType(), 1, 5, 10); - itemLoot.Add(ModContent.ItemType(), 1, 5, 10); - - tier1AcidRain.Add(ModContent.ItemType(), 10, 1, 3); - - // Pre-HM Abyss Weapons - tier1AbyssAvailable.Add(new OneFromOptionsDropRule(10, 1, - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType() + // Rusty Chest Loot @ 100%; Individually 25% + itemLoot.Add(new OneFromOptionsNotScaledWithLuckDropRule(1, 1, + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType() )); - // Pre-HM Abyss Equipment (and Torrential Tear) - tier1AbyssAvailable.Add(new OneFromOptionsDropRule(4, 1, - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType() - )); - - // Bait - itemLoot.Add(ItemID.MasterBait, 10, 1, 2); - itemLoot.Add(ItemID.JourneymanBait, 5, 1, 3); - itemLoot.Add(ItemID.ApprenticeBait, 3, 2, 3); - - // Potions - itemLoot.Add(ModContent.ItemType(), 10, 1, 3); - itemLoot.AddCratePotionRules(false); - - // Money - itemLoot.Add(ItemID.SilverCoin, 1, 10, 90); - itemLoot.Add(ItemID.GoldCoin, 2, 1, 5); + itemLoot.AddBiomeCrateLootRules(false); } } } diff --git a/Items/Fishing/SunkenSeaCatches/EutrophicCrate.cs b/Items/Fishing/SunkenSeaCatches/EutrophicCrate.cs index c2c7f48aec..a0752f07ef 100644 --- a/Items/Fishing/SunkenSeaCatches/EutrophicCrate.cs +++ b/Items/Fishing/SunkenSeaCatches/EutrophicCrate.cs @@ -1,10 +1,4 @@ -using CalamityMod.Items.Critters; -using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables; -using CalamityMod.Items.Weapons.Magic; -using CalamityMod.Items.Weapons.Melee; -using CalamityMod.Items.Weapons.Ranged; -using CalamityMod.Items.Weapons.Summon; +using CalamityMod.Tiles.SunkenSea; using Terraria; using Terraria.GameContent.ItemDropRules; using Terraria.ID; @@ -24,18 +18,11 @@ namespace CalamityMod.Items.Fishing.SunkenSeaCatches public override void SetDefaults() { + Item.DefaultToPlaceableTile(ModContent.TileType()); Item.width = 32; Item.height = 32; - Item.maxStack = 9999; - Item.consumable = true; - Item.rare = ItemRarityID.Green; Item.value = Item.sellPrice(gold: 1); - Item.createTile = ModContent.TileType(); - Item.useTurn = true; - Item.autoReuse = true; - Item.useAnimation = 15; - Item.useTime = 10; - Item.useStyle = ItemUseStyleID.Swing; + Item.rare = ItemRarityID.Green; } public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) @@ -46,26 +33,14 @@ namespace CalamityMod.Items.Fishing.SunkenSeaCatches public override bool CanRightClick() => true; public override void ModifyItemLoot(ItemLoot itemLoot) { - var postDesertScourge = itemLoot.DefineConditionalDropSet(() => DownedBossSystem.downedDesertScourge); + // 20-50 Blocks @ 100%; Individually 50% + itemLoot.Add(new OneFromRulesRule(1, new IItemDropRule[2] + { + ItemDropRule.NotScalingWithLuck(ModContent.ItemType(), 1, 20, 50), + ItemDropRule.NotScalingWithLuck(ModContent.ItemType(), 1, 20, 50) + })); - // Materials - itemLoot.Add(ModContent.ItemType(), 1, 10, 30); - itemLoot.Add(ModContent.ItemType(), 1, 10, 30); - postDesertScourge.Add(ModContent.ItemType(), 1, 5, 10); - postDesertScourge.Add(ModContent.ItemType(), 5, 2, 5); - - // Bait - itemLoot.Add(ItemID.MasterBait, 10, 1, 2); - itemLoot.Add(ItemID.JourneymanBait, 5, 1, 3); - itemLoot.Add(ModContent.ItemType(), 5, 1, 3); - itemLoot.Add(ItemID.ApprenticeBait, 3, 2, 3); - - // Potions - itemLoot.AddCratePotionRules(false); - - // Money - itemLoot.Add(ItemID.SilverCoin, 1, 10, 90); - itemLoot.Add(ItemID.GoldCoin, 2, 1, 5); + itemLoot.AddBiomeCrateLootRules(false); } } } diff --git a/Items/Fishing/SunkenSeaCatches/PrismCrate.cs b/Items/Fishing/SunkenSeaCatches/PrismCrate.cs index ecf064395c..b467105250 100644 --- a/Items/Fishing/SunkenSeaCatches/PrismCrate.cs +++ b/Items/Fishing/SunkenSeaCatches/PrismCrate.cs @@ -6,6 +6,7 @@ using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Summon; +using CalamityMod.Tiles.SunkenSea; using Terraria; using Terraria.GameContent.ItemDropRules; using Terraria.ID; @@ -26,18 +27,11 @@ namespace CalamityMod.Items.Fishing.SunkenSeaCatches public override void SetDefaults() { + Item.DefaultToPlaceableTile(ModContent.TileType()); Item.width = 32; Item.height = 32; - Item.maxStack = 9999; - Item.consumable = true; - Item.rare = ItemRarityID.Green; Item.value = Item.sellPrice(gold: 1); - Item.createTile = ModContent.TileType(); - Item.useTurn = true; - Item.autoReuse = true; - Item.useAnimation = 15; - Item.useTime = 10; - Item.useStyle = ItemUseStyleID.Swing; + Item.rare = ItemRarityID.Green; } public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) @@ -48,36 +42,14 @@ namespace CalamityMod.Items.Fishing.SunkenSeaCatches public override bool CanRightClick() => true; public override void ModifyItemLoot(ItemLoot itemLoot) { - var postDesertScourge = itemLoot.DefineConditionalDropSet(() => DownedBossSystem.downedDesertScourge); - var postHardmodeClam = itemLoot.DefineConditionalDropSet(() => DownedBossSystem.downedCLAMHardMode); + // 20-50 Blocks @ 100%; Individually 50% + itemLoot.Add(new OneFromRulesRule(1, new IItemDropRule[2] + { + ItemDropRule.NotScalingWithLuck(ModContent.ItemType(), 1, 20, 50), + ItemDropRule.NotScalingWithLuck(ModContent.ItemType(), 1, 20, 50) + })); - // Materials - itemLoot.Add(ModContent.ItemType(), 1, 10, 30); - itemLoot.Add(ModContent.ItemType(), 1, 10, 30); - postDesertScourge.Add(ModContent.ItemType(), 1, 5, 10); - postDesertScourge.Add(ModContent.ItemType(), 5, 2, 5); - postHardmodeClam.Add(ModContent.ItemType(), new Fraction(12, 100), 2, 5); - - // Weapons - postHardmodeClam.Add(new OneFromOptionsNotScaledWithLuckDropRule(7, 100, - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType() - )); - - // Bait - itemLoot.Add(ItemID.MasterBait, 10, 1, 2); - itemLoot.Add(ItemID.JourneymanBait, 5, 1, 3); - itemLoot.Add(ModContent.ItemType(), 5, 1, 3); - itemLoot.Add(ItemID.ApprenticeBait, 3, 2, 3); - - // Potions - itemLoot.AddCratePotionRules(); - - // Money - itemLoot.Add(ItemID.SilverCoin, 1, 10, 90); - itemLoot.Add(ItemID.GoldCoin, 2, 1, 5); + itemLoot.AddBiomeCrateLootRules(); } } } diff --git a/Items/Placeables/Ores/AuricOre.cs b/Items/Placeables/Ores/AuricOre.cs index b1e3ec05c6..976cef7ade 100644 --- a/Items/Placeables/Ores/AuricOre.cs +++ b/Items/Placeables/Ores/AuricOre.cs @@ -1,4 +1,5 @@ -using CalamityMod.Rarities; +using CalamityMod.Items.Materials; +using CalamityMod.Rarities; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -29,5 +30,13 @@ namespace CalamityMod.Items.Placeables.Ores Item.value = Item.sellPrice(gold: 4); Item.rare = ModContent.RarityType(); } + + public override void AddRecipes() + { + CreateRecipe(10). + AddIngredient(). + AddCondition(Condition.NearShimmer). + Register(); + } } } diff --git a/Utilities/DropHelper.cs b/Utilities/DropHelper.cs index 0575ad5b0c..b971ec69a5 100644 --- a/Utilities/DropHelper.cs +++ b/Utilities/DropHelper.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using CalamityMod.Enums; using CalamityMod.Items.Accessories; using CalamityMod.Items.Potions; using CalamityMod.NPCs.SulphurousSea; @@ -281,52 +282,320 @@ namespace CalamityMod loot.Add(lcr); } + public static void AddBiomeCrateLootRules(this ILoot loot, bool hardMode = true) + { + if (hardMode) + loot.AddHardmodeOresToCrates(HardmodeCrateType.Biome); + else + { + // Pre-Hardmode Ore/Bar loot pools + // 20-35 Ores @ 14.29%; Individually 1.79% + IItemDropRule[] phmOres = new IItemDropRule[8] + { + ItemDropRule.NotScalingWithLuck(ItemID.CopperOre, 1, 20, 35), + ItemDropRule.NotScalingWithLuck(ItemID.TinOre, 1, 20, 35), + ItemDropRule.NotScalingWithLuck(ItemID.IronOre, 1, 20, 35), + ItemDropRule.NotScalingWithLuck(ItemID.LeadOre, 1, 20, 35), + ItemDropRule.NotScalingWithLuck(ItemID.SilverOre, 1, 20, 35), + ItemDropRule.NotScalingWithLuck(ItemID.TungstenOre, 1, 20, 35), + ItemDropRule.NotScalingWithLuck(ItemID.GoldOre, 1, 20, 35), + ItemDropRule.NotScalingWithLuck(ItemID.PlatinumOre, 1, 20, 35) + }; + loot.Add(new OneFromRulesRule(7, phmOres)); + + // 6-16 Bars @ 25%; Individually 4.17% + IItemDropRule[] phmBars = new IItemDropRule[6] + { + ItemDropRule.NotScalingWithLuck(ItemID.IronBar, 1, 6, 16), + ItemDropRule.NotScalingWithLuck(ItemID.LeadBar, 1, 6, 16), + ItemDropRule.NotScalingWithLuck(ItemID.SilverBar, 1, 6, 16), + ItemDropRule.NotScalingWithLuck(ItemID.TungstenBar, 1, 6, 16), + ItemDropRule.NotScalingWithLuck(ItemID.GoldBar, 1, 6, 16), + ItemDropRule.NotScalingWithLuck(ItemID.PlatinumBar, 1, 6, 16) + }; + loot.Add(new OneFromRulesRule(4, phmBars)); + } + + // 2-4 Buff Potions @ 25%; Individually 4.17% + loot.Add(new OneFromRulesRule(4, new IItemDropRule[6] + { + ItemDropRule.NotScalingWithLuck(ItemID.ObsidianSkinPotion, 1, 2, 4), + ItemDropRule.NotScalingWithLuck(ItemID.SpelunkerPotion, 1, 2, 4), + ItemDropRule.NotScalingWithLuck(ItemID.HunterPotion, 1, 2, 4), + ItemDropRule.NotScalingWithLuck(ItemID.GravitationPotion, 1, 2, 4), + ItemDropRule.NotScalingWithLuck(ItemID.MiningPotion, 1, 2, 4), + ItemDropRule.NotScalingWithLuck(ItemID.HeartreachPotion, 1, 2, 4) + })); + + // 5-17 (Regular) Recovery Potions @ 50%; 25% Healing 25% Mana + loot.Add(new OneFromRulesRule(2, new IItemDropRule[2] + { + ItemDropRule.NotScalingWithLuck(ItemID.HealingPotion, 1, 5, 17), + ItemDropRule.NotScalingWithLuck(ItemID.ManaPotion, 1, 5, 17) + })); + + // 2-6 Bait @ 50%; 25% Master 25% Apprentice + loot.Add(new OneFromRulesRule(2, new IItemDropRule[2] + { + ItemDropRule.NotScalingWithLuck(ItemID.MasterBait, 1, 2, 6), + ItemDropRule.NotScalingWithLuck(ItemID.ApprenticeBait, 1, 2, 6) + })); + + // 5-12 Gold Coin @ 25% + loot.Add(ItemID.GoldCoin, 4, 5, 12); + } + /// - /// Adds all the common potions for fishing crates, alongside scaling mana and regen potions + /// Adds (or re-adds) Hardmode Ores to crates with respect to Hardmode Progression rework
+ /// Drop rules replicate vanilla's rules. ///
/// The ILoot interface for the loot table. - /// Whether or not the crate is considered a hardmode crate. - public static void AddCratePotionRules(this ILoot loot, bool hardMode = true) + /// Type of crate: Mythril, Titanium, Biome + public static void AddHardmodeOresToCrates(this ILoot loot, HardmodeCrateType type) { - loot.Add(ItemID.ObsidianSkinPotion, 10, 1, 3); - loot.Add(ItemID.SwiftnessPotion, 10, 1, 3); - loot.Add(ItemID.IronskinPotion, 10, 1, 3); - loot.Add(ItemID.NightOwlPotion, 10, 1, 3); - loot.Add(ItemID.ShinePotion, 10, 1, 3); - loot.Add(ItemID.MiningPotion, 10, 1, 3); - loot.Add(ItemID.HeartreachPotion, 10, 1, 3); - loot.Add(ItemID.TrapsightPotion, 10, 1, 3); // Dangersense Potion + var adamantiteLCR = loot.DefineConditionalDropSet(AdamantiteCondition); + var mythrilLCR = new LeadingConditionRule(MythrilCondition); - // Define all the loot rules for the potion types - var supremePots = new OneFromOptionsNotScaledWithLuckDropRule(1, 1, ModContent.ItemType(), ModContent.ItemType()); - var superPots = new OneFromOptionsNotScaledWithLuckDropRule(1, 1, ItemID.SuperHealingPotion, ItemID.SuperManaPotion); - var greaterPots = new OneFromOptionsNotScaledWithLuckDropRule(1, 1, ItemID.GreaterHealingPotion, ItemID.GreaterManaPotion); - var regularPots = new OneFromOptionsNotScaledWithLuckDropRule(1, 1, ItemID.HealingPotion, ItemID.ManaPotion); - var lesserPots = new OneFromOptionsNotScaledWithLuckDropRule(1, 1, ItemID.LesserHealingPotion, ItemID.LesserManaPotion); - - // Chained LeadingConditionRules achieve the equivalent of "if killed X, else if killed Y, else if killed Z, else..." - var lcrSupremePotion = loot.DefineConditionalDropSet(() => DownedBossSystem.downedDoG); - var lcrSuperPotion = new LeadingConditionRule(If(() => DownedBossSystem.downedProvidence)); - var lcrGreaterPotion = new LeadingConditionRule(If(() => NPC.downedMechBossAny)); - var lcrRegularPotion = new LeadingConditionRule(If(() => NPC.downedBoss3)); - - // Actually chain all the LCRs together - // Greater potions upwards are only chained if the crate is marked as Hardmode - if (hardMode) + if (type == HardmodeCrateType.Biome) { - lcrSupremePotion.Add(supremePots); - lcrSupremePotion.OnFailedConditions(lcrSuperPotion); - lcrSuperPotion.Add(superPots); - lcrSuperPotion.OnFailedConditions(lcrGreaterPotion); - lcrGreaterPotion.Add(greaterPots); - lcrGreaterPotion.OnFailedConditions(lcrRegularPotion); + // Pre-Hardmode loot pools + // 20-35 Ores @ 7.14%; Individually 0.89% + IItemDropRule[] phmOres = new IItemDropRule[8] + { + ItemDropRule.NotScalingWithLuck(ItemID.CopperOre, 1, 20, 35), + ItemDropRule.NotScalingWithLuck(ItemID.TinOre, 1, 20, 35), + ItemDropRule.NotScalingWithLuck(ItemID.IronOre, 1, 20, 35), + ItemDropRule.NotScalingWithLuck(ItemID.LeadOre, 1, 20, 35), + ItemDropRule.NotScalingWithLuck(ItemID.SilverOre, 1, 20, 35), + ItemDropRule.NotScalingWithLuck(ItemID.TungstenOre, 1, 20, 35), + ItemDropRule.NotScalingWithLuck(ItemID.GoldOre, 1, 20, 35), + ItemDropRule.NotScalingWithLuck(ItemID.PlatinumOre, 1, 20, 35) + }; + // 6-16 Bars @ 8.33%; Individually 1.39% + IItemDropRule[] phmBars = new IItemDropRule[6] + { + ItemDropRule.NotScalingWithLuck(ItemID.IronBar, 1, 6, 16), + ItemDropRule.NotScalingWithLuck(ItemID.LeadBar, 1, 6, 16), + ItemDropRule.NotScalingWithLuck(ItemID.SilverBar, 1, 6, 16), + ItemDropRule.NotScalingWithLuck(ItemID.TungstenBar, 1, 6, 16), + ItemDropRule.NotScalingWithLuck(ItemID.GoldBar, 1, 6, 16), + ItemDropRule.NotScalingWithLuck(ItemID.PlatinumBar, 1, 6, 16) + }; + + // Tier 3 loot pools + // 20-35 Ores @ 7.14%; Individually 1.19% + IItemDropRule[] hmOresThree = new IItemDropRule[6] + { + ItemDropRule.NotScalingWithLuck(ItemID.CobaltOre, 1, 20, 35), + ItemDropRule.NotScalingWithLuck(ItemID.PalladiumOre, 1, 20, 35), + ItemDropRule.NotScalingWithLuck(ItemID.MythrilOre, 1, 20, 35), + ItemDropRule.NotScalingWithLuck(ItemID.OrichalcumOre, 1, 20, 35), + ItemDropRule.NotScalingWithLuck(ItemID.AdamantiteOre, 1, 20, 35), + ItemDropRule.NotScalingWithLuck(ItemID.TitaniumOre, 1, 20, 35) + }; + // 5-16 Bars @ 16.67%; Individually 2.78% + IItemDropRule[] hmBarsThree = new IItemDropRule[6] + { + ItemDropRule.NotScalingWithLuck(ItemID.CobaltBar, 1, 5, 16), + ItemDropRule.NotScalingWithLuck(ItemID.PalladiumBar, 1, 5, 16), + ItemDropRule.NotScalingWithLuck(ItemID.MythrilBar, 1, 5, 16), + ItemDropRule.NotScalingWithLuck(ItemID.OrichalcumBar, 1, 5, 16), + ItemDropRule.NotScalingWithLuck(ItemID.AdamantiteBar, 1, 5, 16), + ItemDropRule.NotScalingWithLuck(ItemID.TitaniumBar, 1, 5, 16) + }; + var adamantiteDropsOres = new SequentialRulesNotScalingWithLuckRule(7, new OneFromRulesRule(2, hmOresThree), new OneFromRulesRule(1, phmOres)); + var adamantiteDropsBars = new SequentialRulesNotScalingWithLuckRule(4, new OneFromRulesRule(3, 2, hmBarsThree), new OneFromRulesRule(1, phmBars)); + + // Tier 2 loot pools + // 20-35 Ores @ 7.14%; Individually 1.79% + IItemDropRule[] hmOresTwo = new IItemDropRule[4] + { + ItemDropRule.NotScalingWithLuck(ItemID.CobaltOre, 1, 20, 35), + ItemDropRule.NotScalingWithLuck(ItemID.PalladiumOre, 1, 20, 35), + ItemDropRule.NotScalingWithLuck(ItemID.MythrilOre, 1, 20, 35), + ItemDropRule.NotScalingWithLuck(ItemID.OrichalcumOre, 1, 20, 35) + }; + // 5-16 Bars @ 16.67%; Individually 4.17% + IItemDropRule[] hmBarsTwo = new IItemDropRule[4] + { + ItemDropRule.NotScalingWithLuck(ItemID.CobaltBar, 1, 5, 16), + ItemDropRule.NotScalingWithLuck(ItemID.PalladiumBar, 1, 5, 16), + ItemDropRule.NotScalingWithLuck(ItemID.MythrilBar, 1, 5, 16), + ItemDropRule.NotScalingWithLuck(ItemID.OrichalcumBar, 1, 5, 16) + }; + var mythrilDropsOres = new SequentialRulesNotScalingWithLuckRule(7, new OneFromRulesRule(2, hmOresTwo), new OneFromRulesRule(1, phmOres)); + var mythrilDropsBars = new SequentialRulesNotScalingWithLuckRule(4, new OneFromRulesRule(3, 2, hmBarsTwo), new OneFromRulesRule(1, phmBars)); + + // Tier 1 loot pools + // 20-35 Ores @ 7.14%; Individually 3.57% + IItemDropRule[] hmOresOne = new IItemDropRule[2] + { + ItemDropRule.NotScalingWithLuck(ItemID.CobaltOre, 1, 20, 35), + ItemDropRule.NotScalingWithLuck(ItemID.PalladiumOre, 1, 20, 35) + }; + // 5-16 Bars @ 16.67%; Individually 8.33% + IItemDropRule[] hmBarsOne = new IItemDropRule[2] + { + ItemDropRule.NotScalingWithLuck(ItemID.CobaltBar, 1, 5, 16), + ItemDropRule.NotScalingWithLuck(ItemID.PalladiumBar, 1, 5, 16) + }; + var cobaltDropsOres = new SequentialRulesNotScalingWithLuckRule(7, new OneFromRulesRule(2, hmOresOne), new OneFromRulesRule(1, phmOres)); + var cobaltDropsBars = new SequentialRulesNotScalingWithLuckRule(4, new OneFromRulesRule(3, 2, hmBarsOne), new OneFromRulesRule(1, phmBars)); + + adamantiteLCR.Add(adamantiteDropsOres); + adamantiteLCR.Add(adamantiteDropsBars); + adamantiteLCR.OnFailedConditions(mythrilLCR); + mythrilLCR.Add(mythrilDropsOres); + mythrilLCR.Add(mythrilDropsBars); + mythrilLCR.OnFailedConditions(cobaltDropsOres); + mythrilLCR.OnFailedConditions(cobaltDropsBars); } - lcrRegularPotion.Add(regularPots); - lcrRegularPotion.OnFailedConditions(lesserPots); - // Add the chain starting from regular potions if marked as a Pre-Hardmode crate - if (!hardMode) + else if (type == HardmodeCrateType.Mythril) { - loot.Add(lcrRegularPotion); + // Pre-Hardmode loot pools + // 12-21 Ores @ 8.33%; Individually 1.39% + IItemDropRule[] phmOres = new IItemDropRule[6] + { + ItemDropRule.NotScalingWithLuck(ItemID.CopperOre, 1, 12, 21), + ItemDropRule.NotScalingWithLuck(ItemID.TinOre, 1, 12, 21), + ItemDropRule.NotScalingWithLuck(ItemID.IronOre, 1, 12, 21), + ItemDropRule.NotScalingWithLuck(ItemID.LeadOre, 1, 12, 21), + ItemDropRule.NotScalingWithLuck(ItemID.SilverOre, 1, 12, 21), + ItemDropRule.NotScalingWithLuck(ItemID.TungstenOre, 1, 12, 21), + }; + // 4-7 Bars @ 6.94%; Individually 1.16% + IItemDropRule[] phmBars = new IItemDropRule[6] + { + ItemDropRule.NotScalingWithLuck(ItemID.CopperBar, 1, 4, 7), + ItemDropRule.NotScalingWithLuck(ItemID.TinBar, 1, 4, 7), + ItemDropRule.NotScalingWithLuck(ItemID.IronBar, 1, 4, 7), + ItemDropRule.NotScalingWithLuck(ItemID.LeadBar, 1, 4, 7), + ItemDropRule.NotScalingWithLuck(ItemID.SilverBar, 1, 4, 7), + ItemDropRule.NotScalingWithLuck(ItemID.TungstenBar, 1, 4, 7), + }; + + // Tier 2 loot pools + // 12-21 Ores @ 8.33%; Individually 2.08% + IItemDropRule[] hmOresTwo = new IItemDropRule[4] + { + ItemDropRule.NotScalingWithLuck(ItemID.CobaltOre, 1, 12, 21), + ItemDropRule.NotScalingWithLuck(ItemID.PalladiumOre, 1, 12, 21), + ItemDropRule.NotScalingWithLuck(ItemID.MythrilOre, 1, 12, 21), + ItemDropRule.NotScalingWithLuck(ItemID.OrichalcumOre, 1, 12, 21) + }; + // 3-7 Bars @ 13.89%; Individually 3.47% + IItemDropRule[] hmBarsTwo = new IItemDropRule[4] + { + ItemDropRule.NotScalingWithLuck(ItemID.CobaltBar, 1, 3, 7), + ItemDropRule.NotScalingWithLuck(ItemID.PalladiumBar, 1, 3, 7), + ItemDropRule.NotScalingWithLuck(ItemID.MythrilBar, 1, 3, 7), + ItemDropRule.NotScalingWithLuck(ItemID.OrichalcumBar, 1, 3, 7) + }; + var mythrilDropsOres = new SequentialRulesNotScalingWithLuckRule(6, new OneFromRulesRule(2, hmOresTwo), new OneFromRulesRule(1, phmOres)); + var mythrilDropsBars = new SequentialRulesNotScalingWithLuckRule(4, new OneFromRulesRule(3, 2, hmBarsTwo), new OneFromRulesRule(1, phmBars)); + var mythrilDrops = new SequentialRulesNotScalingWithLuckRule(1, mythrilDropsOres, mythrilDropsBars); + + // Tier 1 loot pools + // 12-21 Ores @ 8.33%; Individually 4.17% + IItemDropRule[] hmOresOne = new IItemDropRule[2] + { + ItemDropRule.NotScalingWithLuck(ItemID.CobaltOre, 1, 12, 21), + ItemDropRule.NotScalingWithLuck(ItemID.PalladiumOre, 1, 12, 21) + }; + // 3-7 Bars @ 13.89%; Individually 6.94% + IItemDropRule[] hmBarsOne = new IItemDropRule[2] + { + ItemDropRule.NotScalingWithLuck(ItemID.CobaltBar, 1, 3, 7), + ItemDropRule.NotScalingWithLuck(ItemID.PalladiumBar, 1, 3, 7) + }; + var cobaltDropsOres = new SequentialRulesNotScalingWithLuckRule(6, new OneFromRulesRule(2, hmOresOne), new OneFromRulesRule(1, phmOres)); + var cobaltDropsBars = new SequentialRulesNotScalingWithLuckRule(4, new OneFromRulesRule(3, 2, hmBarsOne), new OneFromRulesRule(1, phmBars)); + var cobaltDrops = new SequentialRulesNotScalingWithLuckRule(1, cobaltDropsOres, cobaltDropsBars); + + mythrilLCR.Add(mythrilDrops); + mythrilLCR.OnFailedConditions(cobaltDrops); + loot.Add(mythrilLCR); // No Adamantite LCR here so we need to add this in + } + else if (type == HardmodeCrateType.Titanium) + { + // Pre-Hardmode loot pools + // 25-34 Ores @ 10%; Individually 2.5% + IItemDropRule[] phmOres = new IItemDropRule[4] + { + ItemDropRule.NotScalingWithLuck(ItemID.SilverOre, 1, 25, 34), + ItemDropRule.NotScalingWithLuck(ItemID.TungstenOre, 1, 25, 34), + ItemDropRule.NotScalingWithLuck(ItemID.GoldOre, 1, 25, 34), + ItemDropRule.NotScalingWithLuck(ItemID.PlatinumOre, 1, 25, 34) + }; + // 8-11 Bars @ 8.89%; Individually 2.22% + IItemDropRule[] phmBars = new IItemDropRule[4] + { + ItemDropRule.NotScalingWithLuck(ItemID.SilverBar, 1, 8, 11), + ItemDropRule.NotScalingWithLuck(ItemID.TungstenBar, 1, 8, 11), + ItemDropRule.NotScalingWithLuck(ItemID.GoldBar, 1, 8, 11), + ItemDropRule.NotScalingWithLuck(ItemID.PlatinumBar, 1, 8, 11) + }; + + // Tier 3 loot pools + // 25-34 Ores @ 10%; Individually 2.5% + IItemDropRule[] hmOresThree = new IItemDropRule[4] + { + ItemDropRule.NotScalingWithLuck(ItemID.MythrilOre, 1, 25, 34), + ItemDropRule.NotScalingWithLuck(ItemID.OrichalcumOre, 1, 25, 34), + ItemDropRule.NotScalingWithLuck(ItemID.AdamantiteOre, 1, 25, 34), + ItemDropRule.NotScalingWithLuck(ItemID.TitaniumOre, 1, 25, 34) + }; + // 8-11 Bars @ 17.78%; Individually 4.44% + IItemDropRule[] hmBarsThree = new IItemDropRule[4] + { + ItemDropRule.NotScalingWithLuck(ItemID.MythrilBar, 1, 8, 11), + ItemDropRule.NotScalingWithLuck(ItemID.OrichalcumBar, 1, 8, 11), + ItemDropRule.NotScalingWithLuck(ItemID.AdamantiteBar, 1, 8, 11), + ItemDropRule.NotScalingWithLuck(ItemID.TitaniumBar, 1, 8, 11) + }; + var adamantiteDropsOres = new SequentialRulesNotScalingWithLuckRule(5, new OneFromRulesRule(2, hmOresThree), new OneFromRulesRule(1, phmOres)); + var adamantiteDropsBars = new SequentialRulesNotScalingWithLuckRule(3, new OneFromRulesRule(3, 2, hmBarsThree), new OneFromRulesRule(1, phmBars)); + var adamantiteDrops = new SequentialRulesNotScalingWithLuckRule(1, adamantiteDropsOres, adamantiteDropsBars); + + // Tier 2 loot pools + // 25-34 Ores @ 10%; Individually 5% + IItemDropRule[] hmOresTwo = new IItemDropRule[2] + { + ItemDropRule.NotScalingWithLuck(ItemID.MythrilOre, 1, 25, 34), + ItemDropRule.NotScalingWithLuck(ItemID.OrichalcumOre, 1, 25, 34) + }; + // 8-11 Bars @ 17.78%; Individually 8.89% + IItemDropRule[] hmBarsTwo = new IItemDropRule[2] + { + ItemDropRule.NotScalingWithLuck(ItemID.MythrilBar, 1, 8, 11), + ItemDropRule.NotScalingWithLuck(ItemID.OrichalcumBar, 1, 8, 11) + }; + var mythrilDropsOres = new SequentialRulesNotScalingWithLuckRule(5, new OneFromRulesRule(2, hmOresTwo), new OneFromRulesRule(1, phmOres)); + var mythrilDropsBars = new SequentialRulesNotScalingWithLuckRule(3, new OneFromRulesRule(3, 2, hmBarsTwo), new OneFromRulesRule(1, phmBars)); + var mythrilDrops = new SequentialRulesNotScalingWithLuckRule(1, mythrilDropsOres, mythrilDropsBars); + + // Tier 1 loot pools + // EXCEPTION: Titanium Crates do not drop Cobalt. This is added to make it not entirely useless to get early. + // 25-34 Ores @ 10%; Individually 5% + IItemDropRule[] hmOresOne = new IItemDropRule[2] + { + ItemDropRule.NotScalingWithLuck(ItemID.CobaltOre, 1, 25, 34), + ItemDropRule.NotScalingWithLuck(ItemID.PalladiumOre, 1, 25, 34) + }; + // 8-11 Bars @ 17.78%; Individually 8.89% + IItemDropRule[] hmBarsOne = new IItemDropRule[2] + { + ItemDropRule.NotScalingWithLuck(ItemID.CobaltBar, 1, 8, 11), + ItemDropRule.NotScalingWithLuck(ItemID.PalladiumBar, 1, 8, 11) + }; + var cobaltDropsOres = new SequentialRulesNotScalingWithLuckRule(5, new OneFromRulesRule(2, hmOresOne), new OneFromRulesRule(1, phmOres)); + var cobaltDropsBars = new SequentialRulesNotScalingWithLuckRule(3, new OneFromRulesRule(3, 2, hmBarsOne), new OneFromRulesRule(1, phmBars)); + var cobaltDrops = new SequentialRulesNotScalingWithLuckRule(1, cobaltDropsOres, cobaltDropsBars); + + adamantiteLCR.Add(adamantiteDrops); + adamantiteLCR.OnFailedConditions(mythrilLCR); + mythrilLCR.Add(mythrilDrops); + mythrilLCR.OnFailedConditions(cobaltDrops); } } #endregion @@ -484,6 +753,25 @@ namespace CalamityMod #endregion #region Drop Rule Conditions + public static IItemDropRuleCondition MythrilCondition = If((info) => + { + // If the Early Hardmode Progression Rework is not enabled, then Mythril/Orichalcum can always drop. + if (!CalamityServerConfig.Instance.EarlyHardmodeProgressionRework) + return true; + + // If the Early Hardmode Progression Rework is enabled, then any Mechanical Boss must be defeated for Mythril/Orichalcum to drop. + return NPC.downedMechBossAny; + }); + public static IItemDropRuleCondition AdamantiteCondition = If((info) => + { + // If the Early Hardmode Progression Rework is not enabled, then Adamantite/Titanium can always drop. + if (!CalamityServerConfig.Instance.EarlyHardmodeProgressionRework) + return true; + + // If the Early Hardmode Progression Rework is enabled, then 2 of the Mechanical Bosses must be defeated for Adamantite/Titanium to drop. + return (NPC.downedMechBoss1 && NPC.downedMechBoss2) || (NPC.downedMechBoss2 && NPC.downedMechBoss3) || (NPC.downedMechBoss1 && NPC.downedMechBoss3); + }); + public static IItemDropRuleCondition HallowedBarsCondition = If((info) => { // If the Early Hardmode Progression Rework is not enabled, then Hallowed Bars can always drop from Mechanical Bosses.