From 595c72bdf389359fa9c8a7f3e85dcdb03307ace0 Mon Sep 17 00:00:00 2001 From: Ozzatron Date: Sat, 9 Apr 2022 16:43:31 -0400 Subject: [PATCH] Sanity checked Anahita and Leviathan --- NPCs/Leviathan/Leviathan.cs | 45 +++++++++++++++++++++---------------- NPCs/Leviathan/Siren.cs | 39 +------------------------------- 2 files changed, 27 insertions(+), 57 deletions(-) diff --git a/NPCs/Leviathan/Leviathan.cs b/NPCs/Leviathan/Leviathan.cs index f3a09df734..dc8d38d0f5 100644 --- a/NPCs/Leviathan/Leviathan.cs +++ b/NPCs/Leviathan/Leviathan.cs @@ -712,8 +712,9 @@ namespace CalamityMod.NPCs.Leviathan CalamityNetcode.SyncWorld(); } - public static bool ReadyToDropLoot(NPC npc) + public static bool LastAnLStanding(DropAttemptInfo info) { + NPC npc = info.npc; if (npc.type == ModContent.NPCType() && !NPC.AnyNPCs(ModContent.NPCType())) return true; if (npc.type == ModContent.NPCType() && !NPC.AnyNPCs(ModContent.NPCType())) @@ -721,24 +722,16 @@ namespace CalamityMod.NPCs.Leviathan return false; } - // This loot code is shared with Anahita. - // The Leviathan runs the same loot code as Anahita, but only if she dies last. - public override void ModifyNPCLoot(NPCLoot npcLoot) + public static void DefineAnahitaLeviathanLoot(NPCLoot npcLoot) { - npcLoot.Add(ItemDropRule.BossBagByCondition(DropHelper.If(() => ReadyToDropLoot(NPC)), ModContent.ItemType())); + var lastStanding = npcLoot.DefineConditionalDropSet(LastAnLStanding); + lastStanding.Add(ItemDropRule.BossBag(ModContent.ItemType())); - // Trophy (always directly from boss, never in bag) - npcLoot.Add(ModContent.ItemType(), 10); - - // Lore - bool shouldDropLore(DropAttemptInfo info) => !DownedBossSystem.downedLeviathan && ReadyToDropLoot(info.npc); - npcLoot.AddConditionalPerPlayer(shouldDropLore , ModContent.ItemType()); - npcLoot.AddConditionalPerPlayer(shouldDropLore, ModContent.ItemType()); - - // Weapons. - var normalOnly = npcLoot.DefineConditionalDropSet(DropHelper.If(() => Main.expertMode && ReadyToDropLoot(NPC))); + LeadingConditionRule normalOnly = new LeadingConditionRule(new Conditions.NotExpert()); + lastStanding.Add(normalOnly); { - int[] weapons = new int[] + // Weapons and such + int[] items = new int[] { ModContent.ItemType(), ModContent.ItemType(), @@ -749,23 +742,37 @@ namespace CalamityMod.NPCs.Leviathan ModContent.ItemType(), ModContent.ItemType() }; - npcLoot.Add(ItemDropRule.OneFromOptions(DropHelper.NormalWeaponDropRateInt, weapons)); + npcLoot.Add(DropHelper.CalamityStyle(DropHelper.NormalWeaponDropRateFraction, items)); // Vanity normalOnly.Add(ModContent.ItemType(), 7); normalOnly.Add(ModContent.ItemType(), 7); // Equipment + normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); + normalOnly.Add(ModContent.ItemType(), 10); + + // Fishing normalOnly.Add(ItemID.HotlineFishingHook, 10); normalOnly.Add(ItemID.BottomlessBucket, 10); normalOnly.Add(ItemID.SuperAbsorbantSponge, 10); normalOnly.Add(ItemID.FishingPotion, 5, 5, 8); normalOnly.Add(ItemID.SonarPotion, 5, 5, 8); normalOnly.Add(ItemID.CratePotion, 5, 5, 8); - normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); } - npcLoot.AddIf(() => !DownedBossSystem.downedLeviathan && ReadyToDropLoot(NPC), ModContent.ItemType(), 10); + // Lore + bool shouldDropLore(DropAttemptInfo info) => !DownedBossSystem.downedLeviathan && LastAnLStanding(info); + npcLoot.AddConditionalPerPlayer(shouldDropLore, ModContent.ItemType()); + npcLoot.AddConditionalPerPlayer(shouldDropLore, ModContent.ItemType()); + } + + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + DefineAnahitaLeviathanLoot(npcLoot); + + // Trophy (always directly from boss, never in bag) + npcLoot.Add(ModContent.ItemType(), 10); } public override void OnHitPlayer(Player target, int damage, bool crit) diff --git a/NPCs/Leviathan/Siren.cs b/NPCs/Leviathan/Siren.cs index 33aab567af..0ae2cc355e 100644 --- a/NPCs/Leviathan/Siren.cs +++ b/NPCs/Leviathan/Siren.cs @@ -825,49 +825,12 @@ namespace CalamityMod.NPCs.Leviathan potionType = ItemID.GreaterHealingPotion; } - // Anahita runs the same loot code as the Leviathan, but only if she dies last. public override void ModifyNPCLoot(NPCLoot npcLoot) { - npcLoot.Add(ItemDropRule.BossBagByCondition(DropHelper.If(() => Leviathan.ReadyToDropLoot(NPC)), ModContent.ItemType())); + Leviathan.DefineAnahitaLeviathanLoot(npcLoot); // Trophy (always directly from boss, never in bag) npcLoot.Add(ModContent.ItemType(), 10); - - // Lore - npcLoot.AddIf(() => !DownedBossSystem.downedLeviathan && Leviathan.ReadyToDropLoot(NPC), ModContent.ItemType()); - npcLoot.AddIf(() => !DownedBossSystem.downedLeviathan && Leviathan.ReadyToDropLoot(NPC), ModContent.ItemType()); - - // Weapons. - var normalOnly = npcLoot.DefineConditionalDropSet(DropHelper.If(() => Main.expertMode && Leviathan.ReadyToDropLoot(NPC))); - { - int[] weapons = new int[] - { - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType() - }; - npcLoot.Add(ItemDropRule.OneFromOptions(DropHelper.NormalWeaponDropRateInt, weapons)); - - // Vanity - normalOnly.Add(ModContent.ItemType(), 7); - normalOnly.Add(ModContent.ItemType(), 7); - - // Equipment - normalOnly.Add(ItemID.HotlineFishingHook, 10); - normalOnly.Add(ItemID.BottomlessBucket, 10); - normalOnly.Add(ItemID.SuperAbsorbantSponge, 10); - normalOnly.Add(ItemID.FishingPotion, 5, 5, 8); - normalOnly.Add(ItemID.SonarPotion, 5, 5, 8); - normalOnly.Add(ItemID.CratePotion, 5, 5, 8); - normalOnly.Add(ModContent.ItemType()); - } - - npcLoot.AddIf(() => !DownedBossSystem.downedLeviathan && Leviathan.ReadyToDropLoot(NPC), ModContent.ItemType(), 10); } public override bool CheckActive()