From 01bd3beec71107991f9fde9e3e28df356da852d2 Mon Sep 17 00:00:00 2001 From: Dominic Date: Thu, 7 Apr 2022 19:22:43 -0500 Subject: [PATCH] Shit up to Anahita/Levi --- .../EidolonWyrmBodyAltHuge.cs | 2 - NPCs/AdultEidolonWyrm/EidolonWyrmBodyHuge.cs | 2 - NPCs/AdultEidolonWyrm/EidolonWyrmTailHuge.cs | 2 - NPCs/AquaticScourge/AquaticParasite.cs | 12 -- NPCs/AquaticScourge/AquaticScourgeBody.cs | 5 - NPCs/AquaticScourge/AquaticScourgeBodyAlt.cs | 5 - NPCs/AquaticScourge/AquaticScourgeHead.cs | 76 ++++++------ NPCs/AquaticScourge/AquaticScourgeTail.cs | 5 - NPCs/AquaticScourge/AquaticSeekerBody.cs | 5 - NPCs/AquaticScourge/AquaticSeekerTail.cs | 5 - NPCs/Astral/Aries.cs | 13 +- NPCs/Astral/AstralProbe.cs | 6 +- NPCs/Astral/AstralSlime.cs | 16 +-- NPCs/Astral/AstralachneaGround.cs | 17 +-- NPCs/Astral/AstralachneaWall.cs | 14 +-- NPCs/Astral/Atlas.cs | 17 ++- NPCs/Astral/BigSightseer.cs | 21 ++-- NPCs/Astral/FusionFeeder.cs | 7 +- NPCs/Astral/Hadarian.cs | 17 +-- NPCs/Astral/Hive.cs | 13 +- NPCs/Astral/Hiveling.cs | 5 +- NPCs/Astral/Mantis.cs | 15 +-- NPCs/Astral/Nova.cs | 22 ++-- NPCs/Astral/SmallSightseer.cs | 11 +- NPCs/Astral/StellarCulex.cs | 15 +-- NPCs/AstrumAureus/AstrumAureus.cs | 85 ++++++------- NPCs/AstrumAureus/AureusSpawn.cs | 4 +- NPCs/AstrumDeus/AstrumDeusBodySpectral.cs | 9 +- NPCs/AstrumDeus/AstrumDeusHeadSpectral.cs | 109 ++++++++-------- NPCs/AstrumDeus/AstrumDeusTailSpectral.cs | 9 +- NPCs/BrimstoneElemental/Brimling.cs | 6 +- NPCs/BrimstoneElemental/BrimstoneElemental.cs | 80 ++++++------ NPCs/Bumblebirb/Bumblefuck.cs | 52 ++++---- NPCs/Bumblebirb/Bumblefuck2.cs | 5 +- NPCs/Calamitas/CalamitasRun.cs | 15 ++- NPCs/Calamitas/CalamitasRun2.cs | 13 +- NPCs/Calamitas/CalamitasRun3.cs | 83 +++++++------ NPCs/Calamitas/SoulSeeker.cs | 6 +- NPCs/CeaselessVoid/CeaselessVoid.cs | 72 ++++++----- NPCs/Crabulon/CrabulonIdle.cs | 47 ++++--- NPCs/Crags/CalamityEye.cs | 14 +-- NPCs/Crags/CharredSlime.cs | 12 +- NPCs/Crags/CultistAssassin.cs | 6 +- NPCs/Crags/DespairStone.cs | 6 +- NPCs/Crags/HeatSpirit.cs | 6 +- NPCs/Crags/Scryllar.cs | 16 +-- NPCs/Crags/ScryllarRage.cs | 16 +-- NPCs/Crags/SoulSlurper.cs | 9 +- NPCs/Cryogen/Cryogen.cs | 86 +++++++------ NPCs/Cryogen/CryogenIce.cs | 2 - NPCs/DesertScourge/DesertNuisanceBody.cs | 5 - NPCs/DesertScourge/DesertNuisanceHead.cs | 2 - NPCs/DesertScourge/DesertNuisanceTail.cs | 5 - NPCs/DesertScourge/DesertScourgeBody.cs | 5 - NPCs/DesertScourge/DesertScourgeHead.cs | 107 ++++++++-------- NPCs/DesertScourge/DesertScourgeTail.cs | 5 - NPCs/DevourerofGods/DevourerofGodsBody.cs | 7 +- NPCs/DevourerofGods/DevourerofGodsBody2.cs | 5 - NPCs/DevourerofGods/DevourerofGodsHead.cs | 117 ++++++++++-------- NPCs/DevourerofGods/DevourerofGodsHead2.cs | 4 +- NPCs/DevourerofGods/DevourerofGodsTail.cs | 7 +- NPCs/DevourerofGods/DevourerofGodsTail2.cs | 5 - NPCs/DraedonLabThings/RepairUnitCritter.cs | 4 +- NPCs/ExoMechs/Draedon.cs | 6 +- NPCs/GreatSandShark/GreatSandShark.cs | 11 +- NPCs/HiveMind/DankCreeper.cs | 6 +- NPCs/HiveMind/DarkHeart.cs | 4 +- NPCs/HiveMind/HiveBlob.cs | 6 +- NPCs/HiveMind/HiveBlob2.cs | 6 +- NPCs/HiveMind/HiveCyst.cs | 8 +- NPCs/Leviathan/AquaticAberration.cs | 4 +- NPCs/Leviathan/Leviathan.cs | 110 ++++++++-------- NPCs/Leviathan/LeviathanStart.cs | 8 +- NPCs/Leviathan/Siren.cs | 61 +++++++-- NPCs/Leviathan/SirenIce.cs | 4 +- 75 files changed, 791 insertions(+), 817 deletions(-) diff --git a/NPCs/AdultEidolonWyrm/EidolonWyrmBodyAltHuge.cs b/NPCs/AdultEidolonWyrm/EidolonWyrmBodyAltHuge.cs index 9d2d1963d3..762ad7660d 100644 --- a/NPCs/AdultEidolonWyrm/EidolonWyrmBodyAltHuge.cs +++ b/NPCs/AdultEidolonWyrm/EidolonWyrmBodyAltHuge.cs @@ -192,8 +192,6 @@ namespace CalamityMod.NPCs.AdultEidolonWyrm public override bool CheckActive() => false; - public override bool PreNPCLoot() => false; - public override void HitEffect(int hitDirection, double damage) { if (NPC.life <= 0) diff --git a/NPCs/AdultEidolonWyrm/EidolonWyrmBodyHuge.cs b/NPCs/AdultEidolonWyrm/EidolonWyrmBodyHuge.cs index 337eee3b73..fdf07b19b2 100644 --- a/NPCs/AdultEidolonWyrm/EidolonWyrmBodyHuge.cs +++ b/NPCs/AdultEidolonWyrm/EidolonWyrmBodyHuge.cs @@ -192,8 +192,6 @@ namespace CalamityMod.NPCs.AdultEidolonWyrm public override bool CheckActive() => false; - public override bool PreNPCLoot() => false; - public override void HitEffect(int hitDirection, double damage) { if (NPC.life <= 0) diff --git a/NPCs/AdultEidolonWyrm/EidolonWyrmTailHuge.cs b/NPCs/AdultEidolonWyrm/EidolonWyrmTailHuge.cs index e26ff339c3..c51890bde6 100644 --- a/NPCs/AdultEidolonWyrm/EidolonWyrmTailHuge.cs +++ b/NPCs/AdultEidolonWyrm/EidolonWyrmTailHuge.cs @@ -157,8 +157,6 @@ namespace CalamityMod.NPCs.AdultEidolonWyrm public override bool CheckActive() => false; - public override bool PreNPCLoot() => false; - public override void HitEffect(int hitDirection, double damage) { if (NPC.life <= 0) diff --git a/NPCs/AquaticScourge/AquaticParasite.cs b/NPCs/AquaticScourge/AquaticParasite.cs index e3593b5da0..72c990f020 100644 --- a/NPCs/AquaticScourge/AquaticParasite.cs +++ b/NPCs/AquaticScourge/AquaticParasite.cs @@ -141,18 +141,6 @@ namespace CalamityMod.NPCs.AquaticScourge } int num268 = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; int num269 = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; - if (Main.tile[num268, num269 - 1] == null) - { - Main.tile[num268, num269 - 1] = new Tile(); - } - if (Main.tile[num268, num269 + 1] == null) - { - Main.tile[num268, num269 + 1] = new Tile(); - } - if (Main.tile[num268, num269 + 2] == null) - { - Main.tile[num268, num269 + 2] = new Tile(); - } if (Main.tile[num268, num269 - 1].LiquidAmount > 128) { if (Main.tile[num268, num269 + 1].HasTile) diff --git a/NPCs/AquaticScourge/AquaticScourgeBody.cs b/NPCs/AquaticScourge/AquaticScourgeBody.cs index f9ec85aab6..11df2cb598 100644 --- a/NPCs/AquaticScourge/AquaticScourgeBody.cs +++ b/NPCs/AquaticScourge/AquaticScourgeBody.cs @@ -123,11 +123,6 @@ namespace CalamityMod.NPCs.AquaticScourge return false; } - public override bool PreNPCLoot() - { - return false; - } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * bossLifeScale); diff --git a/NPCs/AquaticScourge/AquaticScourgeBodyAlt.cs b/NPCs/AquaticScourge/AquaticScourgeBodyAlt.cs index 23e9100386..6122cdc880 100644 --- a/NPCs/AquaticScourge/AquaticScourgeBodyAlt.cs +++ b/NPCs/AquaticScourge/AquaticScourgeBodyAlt.cs @@ -122,11 +122,6 @@ namespace CalamityMod.NPCs.AquaticScourge return false; } - public override bool PreNPCLoot() - { - return false; - } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * bossLifeScale); diff --git a/NPCs/AquaticScourge/AquaticScourgeHead.cs b/NPCs/AquaticScourge/AquaticScourgeHead.cs index 982fe38445..b8f37d77a4 100644 --- a/NPCs/AquaticScourge/AquaticScourgeHead.cs +++ b/NPCs/AquaticScourge/AquaticScourgeHead.cs @@ -21,6 +21,8 @@ using Terraria.ID; using Terraria.ModLoader; using CalamityMod.Items.Armor.Vanity; using Terraria.Audio; +using Terraria.GameContent.ItemDropRules; +using System; namespace CalamityMod.NPCs.AquaticScourge { @@ -55,7 +57,6 @@ namespace CalamityMod.NPCs.AquaticScourge NPC.HitSound = SoundID.NPCHit1; NPC.DeathSound = SoundID.NPCDeath1; NPC.netAlways = true; - bossBag = ModContent.ItemType(); if (CalamityWorld.malice || BossRushEvent.BossRushActive) NPC.scale = 1.25f; @@ -177,7 +178,7 @@ namespace CalamityMod.NPCs.AquaticScourge potionType = ModContent.ItemType(); } - public override bool SpecialNPCLoot() + public override bool SpecialOnKill() { int closestSegmentID = DropHelper.FindClosestWormSegment(NPC, ModContent.NPCType(), @@ -185,49 +186,48 @@ namespace CalamityMod.NPCs.AquaticScourge ModContent.NPCType(), ModContent.NPCType()); NPC.position = Main.npc[closestSegmentID].position; - return false; + return true; } - public override void NPCLoot() + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + // Boss bag + npcLoot.Add(ItemDropRule.BossBag(ModContent.ItemType())); + + // Normal drops: Everything that would otherwise be in the bag + var normalOnly = npcLoot.DefineNormalOnlyDropSet(); + { + // Weapons + int[] weapons = new int[] + { + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType() + }; + normalOnly.Add(ItemDropRule.OneFromOptions(DropHelper.NormalWeaponDropRateInt, weapons)); + + // Vanity + normalOnly.Add(ModContent.ItemType(), 7); + + // Fishing + normalOnly.Add(ModContent.ItemType()); + } + + npcLoot.Add(ItemID.GreaterHealingPotion, 1, 8, 14); + npcLoot.Add(ModContent.ItemType(), 10); + npcLoot.AddIf(() => !Main.expertMode, ModContent.ItemType()); + npcLoot.AddIf(() => !Main.expertMode, ModContent.ItemType()); + } + + public override void OnKill() { CalamityGlobalNPC.SetNewBossJustDowned(NPC); - DropHelper.DropBags(NPC); - - DropHelper.DropItem(NPC, ItemID.GreaterHealingPotion, 8, 14); - DropHelper.DropItemChance(NPC, ModContent.ItemType(), 10); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), true, !DownedBossSystem.downedAquaticScourge); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), true, !DownedBossSystem.downedAquaticScourge); - CalamityGlobalNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, DownedBossSystem.downedAquaticScourge); - // All other drops are contained in the bag, so they only drop directly on Normal - if (!Main.expertMode) - { - // Weapons - float w = DropHelper.NormalWeaponDropRateFloat; - DropHelper.DropEntireWeightedSet(NPC, - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w) - ); - - // Equipment - DropHelper.DropItem(NPC, ModContent.ItemType(), true); - - // Vanity - DropHelper.DropItemChance(NPC, ModContent.ItemType(), 7); - - // Fishing - DropHelper.DropItem(NPC, ModContent.ItemType()); - } - - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), !Main.expertMode, 0.1f); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), !Main.expertMode, 0.1f); - // If Aquatic Scourge has not yet been killed, notify players of buffed Acid Rain if (!DownedBossSystem.downedAquaticScourge) { diff --git a/NPCs/AquaticScourge/AquaticScourgeTail.cs b/NPCs/AquaticScourge/AquaticScourgeTail.cs index 985625d048..e4cc661709 100644 --- a/NPCs/AquaticScourge/AquaticScourgeTail.cs +++ b/NPCs/AquaticScourge/AquaticScourgeTail.cs @@ -122,11 +122,6 @@ namespace CalamityMod.NPCs.AquaticScourge return false; } - public override bool PreNPCLoot() - { - return false; - } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * bossLifeScale); diff --git a/NPCs/AquaticScourge/AquaticSeekerBody.cs b/NPCs/AquaticScourge/AquaticSeekerBody.cs index 23f9c39ba7..d3af6246b8 100644 --- a/NPCs/AquaticScourge/AquaticSeekerBody.cs +++ b/NPCs/AquaticScourge/AquaticSeekerBody.cs @@ -129,11 +129,6 @@ namespace CalamityMod.NPCs.AquaticScourge return false; } - public override bool PreNPCLoot() - { - return false; - } - public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 3; k++) diff --git a/NPCs/AquaticScourge/AquaticSeekerTail.cs b/NPCs/AquaticScourge/AquaticSeekerTail.cs index 5921ede1d6..95683da86b 100644 --- a/NPCs/AquaticScourge/AquaticSeekerTail.cs +++ b/NPCs/AquaticScourge/AquaticSeekerTail.cs @@ -129,11 +129,6 @@ namespace CalamityMod.NPCs.AquaticScourge return false; } - public override bool PreNPCLoot() - { - return false; - } - public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 3; k++) diff --git a/NPCs/Astral/Aries.cs b/NPCs/Astral/Aries.cs index 9b48737151..ffb4313955 100644 --- a/NPCs/Astral/Aries.cs +++ b/NPCs/Astral/Aries.cs @@ -9,6 +9,7 @@ using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ModLoader; using Terraria.Audio; +using ReLogic.Content; namespace CalamityMod.NPCs.Astral { @@ -21,7 +22,7 @@ namespace CalamityMod.NPCs.Astral DisplayName.SetDefault("Aries"); Main.npcFrameCount[NPC.type] = 8; if (!Main.dedServ) - glowmask = ModContent.Request("CalamityMod/NPCs/Astral/AriesGlow").Value; + glowmask = ModContent.Request("CalamityMod/NPCs/Astral/AriesGlow", AssetRequestMode.ImmediateLoad).Value; } public override void SetDefaults() @@ -35,7 +36,7 @@ namespace CalamityMod.NPCs.Astral NPC.lifeMax = 300; NPC.knockBackResist = 0.6f; NPC.value = Item.buyPrice(0, 0, 10, 0); - NPC.DeathSound = Mod.GetLegacySoundSlot(SoundType.NPCKilled, "Sounds/NPCKilled/AstralEnemyDeath"); + NPC.DeathSound = SoundLoader.GetLegacySoundSlot(Mod, "Sounds/NPCKilled/AstralEnemyDeath"); Banner = NPC.type; BannerItem = ModContent.ItemType(); if (DownedBossSystem.downedAstrumAureus) @@ -120,11 +121,11 @@ namespace CalamityMod.NPCs.Astral player.AddBuff(ModContent.BuffType(), 120, true); } - public override void NPCLoot() + public override void ModifyNPCLoot(NPCLoot npcLoot) { - DropHelper.DropItemChance(NPC, ModContent.ItemType(), 0.5f, 1, 2); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), Main.expertMode); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), DownedBossSystem.downedAstrumAureus, 7, 1, 1); + npcLoot.AddIf(() => !Main.expertMode, ModContent.ItemType(), 2, 1, 2); + npcLoot.AddIf(() => Main.expertMode, ModContent.ItemType(), 1, 1, 3); + npcLoot.AddIf(() => DownedBossSystem.downedAstrumAureus, ModContent.ItemType(), 7); } } } diff --git a/NPCs/Astral/AstralProbe.cs b/NPCs/Astral/AstralProbe.cs index 0a4bfa6e7c..f3fca3d60a 100644 --- a/NPCs/Astral/AstralProbe.cs +++ b/NPCs/Astral/AstralProbe.cs @@ -282,10 +282,10 @@ namespace CalamityMod.NPCs.Astral } } - public override void NPCLoot() + public override void ModifyNPCLoot(NPCLoot npcLoot) { - DropHelper.DropItemChance(NPC, ModContent.ItemType(), 0.5f, 1, 2); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), Main.expertMode); + npcLoot.AddIf(() => !Main.expertMode, ModContent.ItemType(), 2, 1, 2); + npcLoot.AddIf(() => Main.expertMode, ModContent.ItemType(), 1, 1, 3); } public override float SpawnChance(NPCSpawnInfo spawnInfo) diff --git a/NPCs/Astral/AstralSlime.cs b/NPCs/Astral/AstralSlime.cs index 123c690fde..0c6dd3b64b 100644 --- a/NPCs/Astral/AstralSlime.cs +++ b/NPCs/Astral/AstralSlime.cs @@ -1,4 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Banners; @@ -33,7 +33,7 @@ namespace CalamityMod.NPCs.Astral NPC.alpha = 60; NPC.HitSound = SoundID.NPCHit1; NPC.DeathSound = SoundID.NPCDeath1; - animationType = NPCID.BlueSlime; + AnimationType = NPCID.BlueSlime; Banner = NPC.type; BannerItem = ModContent.ItemType(); if (DownedBossSystem.downedAstrumAureus) @@ -79,13 +79,13 @@ namespace CalamityMod.NPCs.Astral player.AddBuff(ModContent.BuffType(), 120, true); } - public override void NPCLoot() + public override void ModifyNPCLoot(NPCLoot npcLoot) { - DropHelper.DropItemChance(NPC, ModContent.ItemType(), Main.expertMode ? 1 : 2, 1, 3); - int oreMin = Main.expertMode ? 11 : 8; - int oreMax = Main.expertMode ? 16 : 12; - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), DownedBossSystem.downedAstrumDeus, oreMin, oreMax); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), DownedBossSystem.downedAstrumAureus, 0.05f, 1, 1); + npcLoot.AddIf(() => !Main.expertMode, ModContent.ItemType(), 2, 1, 3); + npcLoot.AddIf(() => Main.expertMode, ModContent.ItemType(), 1, 1, 3); + npcLoot.AddIf(() => DownedBossSystem.downedAstrumAureus, ModContent.ItemType(), 7); + npcLoot.AddIf(() => DownedBossSystem.downedAstrumDeus && !Main.expertMode, ModContent.ItemType(), 1, 8, 12); + npcLoot.AddIf(() => DownedBossSystem.downedAstrumDeus && Main.expertMode, ModContent.ItemType(), 1, 11, 16); } } } diff --git a/NPCs/Astral/AstralachneaGround.cs b/NPCs/Astral/AstralachneaGround.cs index 946df42c01..bdc7237571 100644 --- a/NPCs/Astral/AstralachneaGround.cs +++ b/NPCs/Astral/AstralachneaGround.cs @@ -11,6 +11,7 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; +using ReLogic.Content; namespace CalamityMod.NPCs.Astral { @@ -25,7 +26,7 @@ namespace CalamityMod.NPCs.Astral Main.npcFrameCount[NPC.type] = 5; if (!Main.dedServ) - glowmask = ModContent.Request("CalamityMod/NPCs/Astral/AstralachneaGroundGlow").Value; + glowmask = ModContent.Request("CalamityMod/NPCs/Astral/AstralachneaGroundGlow", AssetRequestMode.ImmediateLoad).Value; base.SetStaticDefaults(); } @@ -39,11 +40,11 @@ namespace CalamityMod.NPCs.Astral NPC.defense = 20; NPC.DR_NERD(0.15f); NPC.lifeMax = 500; - NPC.DeathSound = Mod.GetLegacySoundSlot(SoundType.NPCKilled, "Sounds/NPCKilled/AstralEnemyDeath"); + NPC.DeathSound = SoundLoader.GetLegacySoundSlot(Mod, "Sounds/NPCKilled/AstralEnemyDeath"); NPC.knockBackResist = 0.38f; NPC.value = Item.buyPrice(0, 0, 20, 0); NPC.timeLeft = NPC.activeTime * 2; - animationType = NPCID.WallCreeper; + AnimationType = NPCID.WallCreeper; Banner = NPC.type; BannerItem = ModContent.ItemType(); if (DownedBossSystem.downedAstrumAureus) @@ -167,11 +168,13 @@ namespace CalamityMod.NPCs.Astral player.AddBuff(ModContent.BuffType(), 120, true); } - public override void NPCLoot() + public static void ModifyAstralachneaLoot(NPCLoot npcLoot) { - DropHelper.DropItem(NPC, ModContent.ItemType(), 2, 3); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), Main.expertMode); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), DownedBossSystem.downedAstrumAureus, 7, 1, 1); + npcLoot.AddIf(() => !Main.expertMode, ModContent.ItemType(), 2, 2, 3); + npcLoot.AddIf(() => Main.expertMode, ModContent.ItemType(), 1, 1, 4); + npcLoot.AddIf(() => DownedBossSystem.downedAstrumAureus, ModContent.ItemType(), 7); } + + public override void ModifyNPCLoot(NPCLoot npcLoot) => ModifyAstralachneaLoot(npcLoot); } } diff --git a/NPCs/Astral/AstralachneaWall.cs b/NPCs/Astral/AstralachneaWall.cs index 184ff95752..9688e9bf00 100644 --- a/NPCs/Astral/AstralachneaWall.cs +++ b/NPCs/Astral/AstralachneaWall.cs @@ -11,6 +11,7 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; +using ReLogic.Content; namespace CalamityMod.NPCs.Astral { @@ -25,7 +26,7 @@ namespace CalamityMod.NPCs.Astral Main.npcFrameCount[NPC.type] = 4; if (!Main.dedServ) - glowmask = ModContent.Request("CalamityMod/NPCs/Astral/AstralachneaWallGlow").Value; + glowmask = ModContent.Request("CalamityMod/NPCs/Astral/AstralachneaWallGlow", AssetRequestMode.ImmediateLoad).Value; base.SetStaticDefaults(); } @@ -39,12 +40,12 @@ namespace CalamityMod.NPCs.Astral NPC.defense = 20; NPC.DR_NERD(0.15f); NPC.lifeMax = 500; - NPC.DeathSound = Mod.GetLegacySoundSlot(SoundType.NPCKilled, "Sounds/NPCKilled/AstralEnemyDeath"); + NPC.DeathSound = SoundLoader.GetLegacySoundSlot(Mod, "Sounds/NPCKilled/AstralEnemyDeath"); NPC.knockBackResist = 0f; NPC.noGravity = true; NPC.value = Item.buyPrice(0, 0, 20, 0); NPC.timeLeft = NPC.activeTime * 2; - animationType = NPCID.BlackRecluseWall; + AnimationType = NPCID.BlackRecluseWall; Banner = ModContent.NPCType(); BannerItem = ModContent.ItemType(); if (DownedBossSystem.downedAstrumAureus) @@ -140,11 +141,6 @@ namespace CalamityMod.NPCs.Astral player.AddBuff(ModContent.BuffType(), 120, true); } - public override void NPCLoot() - { - DropHelper.DropItem(NPC, ModContent.ItemType(), 2, 3); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), Main.expertMode); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), DownedBossSystem.downedAstrumAureus, 7, 1, 1); - } + public override void ModifyNPCLoot(NPCLoot npcLoot) => AstralachneaGround.ModifyAstralachneaLoot(npcLoot); } } diff --git a/NPCs/Astral/Atlas.cs b/NPCs/Astral/Atlas.cs index 404370558f..fed0508169 100644 --- a/NPCs/Astral/Atlas.cs +++ b/NPCs/Astral/Atlas.cs @@ -14,6 +14,7 @@ using Terraria.GameContent; using Terraria.DataStructures; using Terraria.ModLoader; using Terraria.Audio; +using ReLogic.Content; namespace CalamityMod.NPCs.Astral { @@ -99,7 +100,7 @@ namespace CalamityMod.NPCs.Astral //also it's visuals are messed up on npc spawners etc. because the sheet is 3 wide. //not much we can do. looks fine in-game so /shrug if (!Main.dedServ) - glowmask = ModContent.Request("CalamityMod/NPCs/Astral/AtlasGlow").Value; + glowmask = ModContent.Request("CalamityMod/NPCs/Astral/AtlasGlow", AssetRequestMode.ImmediateLoad).Value; } public override void SetDefaults() @@ -115,7 +116,7 @@ namespace CalamityMod.NPCs.Astral NPC.knockBackResist = 0.08f; NPC.value = Item.buyPrice(0, 1, 0, 0); NPC.aiStyle = -1; - NPC.DeathSound = Mod.GetLegacySoundSlot(SoundType.NPCKilled, "Sounds/NPCKilled/AtlasDeath"); + NPC.DeathSound = SoundLoader.GetLegacySoundSlot(Mod, "Sounds/NPCKilled/AtlasDeath"); Banner = NPC.type; BannerItem = ModContent.ItemType(); if (DownedBossSystem.downedAstrumAureus) @@ -638,14 +639,12 @@ namespace CalamityMod.NPCs.Astral player.AddBuff(ModContent.BuffType(), 300, true); } - public override void NPCLoot() + public override void ModifyNPCLoot(NPCLoot npcLoot) { - int minStardust = Main.expertMode ? 7 : 6; - int maxStardust = Main.expertMode ? 9 : 8; - DropHelper.DropItem(NPC, ModContent.ItemType(), minStardust, maxStardust); - - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), DownedBossSystem.downedAstrumAureus, 7, 1, 1); - DropHelper.DropItem(NPC, ModContent.ItemType()); + npcLoot.Add(ModContent.ItemType()); + npcLoot.AddIf(() => !Main.expertMode, ModContent.ItemType(), 1, 6, 8); + npcLoot.AddIf(() => Main.expertMode, ModContent.ItemType(), 1, 7, 9); + npcLoot.AddIf(() => DownedBossSystem.downedAstrumAureus, ModContent.ItemType(), 7); } } } diff --git a/NPCs/Astral/BigSightseer.cs b/NPCs/Astral/BigSightseer.cs index 54c813f19e..cfdfdb0e74 100644 --- a/NPCs/Astral/BigSightseer.cs +++ b/NPCs/Astral/BigSightseer.cs @@ -10,6 +10,7 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; +using ReLogic.Content; namespace CalamityMod.NPCs.Astral { @@ -22,7 +23,7 @@ namespace CalamityMod.NPCs.Astral DisplayName.SetDefault("Big Sightseer"); Main.npcFrameCount[NPC.type] = 4; if (!Main.dedServ) - glowmask = ModContent.Request("CalamityMod/NPCs/Astral/BigSightseerGlow").Value; + glowmask = ModContent.Request("CalamityMod/NPCs/Astral/BigSightseerGlow", AssetRequestMode.ImmediateLoad).Value; } public override void SetDefaults() @@ -33,7 +34,7 @@ namespace CalamityMod.NPCs.Astral NPC.defense = 20; NPC.DR_NERD(0.15f); NPC.lifeMax = 430; - NPC.DeathSound = Mod.GetLegacySoundSlot(SoundType.NPCKilled, "Sounds/NPCKilled/AstralEnemyDeath"); + NPC.DeathSound = SoundLoader.GetLegacySoundSlot(Mod, "Sounds/NPCKilled/AstralEnemyDeath"); NPC.noGravity = true; NPC.knockBackResist = 0.8f; NPC.value = Item.buyPrice(0, 0, 20, 0); @@ -168,10 +169,10 @@ namespace CalamityMod.NPCs.Astral player.AddBuff(ModContent.BuffType(), 120, true); } - public override void NPCLoot() + public override void ModifyNPCLoot(NPCLoot npcLoot) { - DropHelper.DropItem(NPC, ModContent.ItemType(), 2, 3); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), Main.expertMode); + npcLoot.AddIf(() => !Main.expertMode, ModContent.ItemType(), 2, 2, 3); + npcLoot.AddIf(() => Main.expertMode, ModContent.ItemType(), 1, 1, 4); } } @@ -211,8 +212,8 @@ namespace CalamityMod.NPCs.Astral float pulse = (float)Math.Sin(NPC.ai[0]); float radius = 5.8f; Vector2 offset = angle.ToRotationVector2() * pulse * radius; - Dust pink = Dust.NewDustPerfect(NPC.Center + offset, ModContent.DustType(), Vector2.Zero); - Dust blue = Dust.NewDustPerfect(NPC.Center - offset, ModContent.DustType(), Vector2.Zero); + Dust.NewDustPerfect(NPC.Center + offset, ModContent.DustType(), Vector2.Zero); + Dust.NewDustPerfect(NPC.Center - offset, ModContent.DustType(), Vector2.Zero); //kill on tile collide if (Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) @@ -237,11 +238,9 @@ namespace CalamityMod.NPCs.Astral } } - //On death - public override bool PreNPCLoot() + public override void HitEffect(int hitDirection, double damage) { DoKillDust(); - return false; } public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) @@ -264,7 +263,7 @@ namespace CalamityMod.NPCs.Astral Vector2 vel = (angle + Main.rand.NextFloat(-0.04f, 0.04f)).ToRotationVector2(); int dustType = Main.rand.NextBool(2) ? ModContent.DustType() : ModContent.DustType(); Dust d = Dust.NewDustPerfect(NPC.Center, dustType, vel * Main.rand.NextFloat(1.8f, 2.2f)); - d.customData = npc; + d.customData = NPC; angle += rotPerIter; } diff --git a/NPCs/Astral/FusionFeeder.cs b/NPCs/Astral/FusionFeeder.cs index c9159b7901..3eb6e23ad6 100644 --- a/NPCs/Astral/FusionFeeder.cs +++ b/NPCs/Astral/FusionFeeder.cs @@ -11,6 +11,7 @@ using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; +using ReLogic.Content; namespace CalamityMod.NPCs.Astral { @@ -22,7 +23,7 @@ namespace CalamityMod.NPCs.Astral { DisplayName.SetDefault("Fusion Feeder"); if (!Main.dedServ) - glowmask = ModContent.Request("CalamityMod/NPCs/Astral/FusionFeederGlow").Value; + glowmask = ModContent.Request("CalamityMod/NPCs/Astral/FusionFeederGlow", AssetRequestMode.ImmediateLoad).Value; Main.npcFrameCount[NPC.type] = 4; } @@ -39,8 +40,8 @@ namespace CalamityMod.NPCs.Astral NPC.value = Item.buyPrice(0, 0, 20, 0); NPC.knockBackResist = 0.8f; NPC.behindTiles = true; - NPC.DeathSound = Mod.GetLegacySoundSlot(SoundType.NPCKilled, "Sounds/NPCKilled/AstralEnemyDeath"); - animationType = NPCID.SandShark; + NPC.DeathSound = SoundLoader.GetLegacySoundSlot(Mod, "Sounds/NPCKilled/AstralEnemyDeath"); + AnimationType = NPCID.SandShark; Banner = NPC.type; BannerItem = ModContent.ItemType(); if (DownedBossSystem.downedAstrumAureus) diff --git a/NPCs/Astral/Hadarian.cs b/NPCs/Astral/Hadarian.cs index 4ddd87182b..2c14a9faa8 100644 --- a/NPCs/Astral/Hadarian.cs +++ b/NPCs/Astral/Hadarian.cs @@ -12,6 +12,7 @@ using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; +using ReLogic.Content; namespace CalamityMod.NPCs.Astral { @@ -23,7 +24,7 @@ namespace CalamityMod.NPCs.Astral { DisplayName.SetDefault("Hadarian"); if (!Main.dedServ) - glowmask = ModContent.Request("CalamityMod/NPCs/Astral/HadarianGlow").Value; + glowmask = ModContent.Request("CalamityMod/NPCs/Astral/HadarianGlow", AssetRequestMode.ImmediateLoad).Value; Main.npcFrameCount[NPC.type] = 7; } @@ -36,7 +37,7 @@ namespace CalamityMod.NPCs.Astral NPC.defense = 8; NPC.DR_NERD(0.15f); NPC.lifeMax = 330; - NPC.DeathSound = Mod.GetLegacySoundSlot(SoundType.NPCKilled, "Sounds/NPCKilled/AstralEnemyDeath"); + NPC.DeathSound = SoundLoader.GetLegacySoundSlot(Mod, "Sounds/NPCKilled/AstralEnemyDeath"); NPC.knockBackResist = 0.75f; NPC.value = Item.buyPrice(0, 0, 15, 0); Banner = NPC.type; @@ -188,12 +189,12 @@ namespace CalamityMod.NPCs.Astral public override float SpawnChance(NPCSpawnInfo spawnInfo) { - Tile tile = Main.tile[spawnInfo.spawnTileX, spawnInfo.spawnTileY]; + Tile tile = Main.tile[spawnInfo.SpawnTileX, spawnInfo.SpawnTileY]; if (CalamityGlobalNPC.AnyEvents(spawnInfo.Player)) { return 0f; } - else if (spawnInfo.Player.InAstral(3) && spawnInfo.spawnTileType == ModContent.TileType() && tile.WallType == WallID.None) + else if (spawnInfo.Player.InAstral(3) && spawnInfo.SpawnTileType == ModContent.TileType() && tile.WallType == WallID.None) { return 0.25f; } @@ -205,11 +206,11 @@ namespace CalamityMod.NPCs.Astral player.AddBuff(ModContent.BuffType(), 120, true); } - public override void NPCLoot() + public override void ModifyNPCLoot(NPCLoot npcLoot) { - DropHelper.DropItem(NPC, ModContent.ItemType(), 2, 3); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), Main.expertMode); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), DownedBossSystem.downedAstrumAureus, 2, 2, 3); + npcLoot.AddIf(() => !Main.expertMode, ModContent.ItemType(), 2, 1, 3); + npcLoot.AddIf(() => Main.expertMode, ModContent.ItemType(), 1, 1, 4); + npcLoot.AddIf(() => DownedBossSystem.downedAstrumAureus, ModContent.ItemType(), 2, 2, 3); } } } diff --git a/NPCs/Astral/Hive.cs b/NPCs/Astral/Hive.cs index d8956c8ad3..0565474315 100644 --- a/NPCs/Astral/Hive.cs +++ b/NPCs/Astral/Hive.cs @@ -10,6 +10,7 @@ using System; using Terraria; using Terraria.ModLoader; using Terraria.Audio; +using ReLogic.Content; namespace CalamityMod.NPCs.Astral { @@ -21,7 +22,7 @@ namespace CalamityMod.NPCs.Astral { DisplayName.SetDefault("Hive"); if (!Main.dedServ) - glowmask = ModContent.Request("CalamityMod/NPCs/Astral/HiveGlow").Value; + glowmask = ModContent.Request("CalamityMod/NPCs/Astral/HiveGlow", AssetRequestMode.ImmediateLoad).Value; Main.npcFrameCount[NPC.type] = 6; } @@ -34,7 +35,7 @@ namespace CalamityMod.NPCs.Astral NPC.defense = 15; NPC.DR_NERD(0.15f); NPC.lifeMax = 470; - NPC.DeathSound = Mod.GetLegacySoundSlot(SoundType.NPCKilled, "Sounds/NPCKilled/AstralEnemyDeath"); + NPC.DeathSound = SoundLoader.GetLegacySoundSlot(Mod, "Sounds/NPCKilled/AstralEnemyDeath"); NPC.knockBackResist = 0f; NPC.value = Item.buyPrice(0, 0, 15, 0); Banner = NPC.type; @@ -139,11 +140,11 @@ namespace CalamityMod.NPCs.Astral player.AddBuff(ModContent.BuffType(), 120, true); } - public override void NPCLoot() + public override void ModifyNPCLoot(NPCLoot npcLoot) { - DropHelper.DropItem(NPC, ModContent.ItemType(), 2, 3); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), Main.expertMode); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), DownedBossSystem.downedAstrumAureus, 7, 1, 1); + npcLoot.AddIf(() => !Main.expertMode, ModContent.ItemType(), 2, 1, 3); + npcLoot.AddIf(() => Main.expertMode, ModContent.ItemType(), 1, 1, 4); + npcLoot.AddIf(() => DownedBossSystem.downedAstrumAureus, ModContent.ItemType(), 7); } } } diff --git a/NPCs/Astral/Hiveling.cs b/NPCs/Astral/Hiveling.cs index 13af29b6a4..fd554bd50e 100644 --- a/NPCs/Astral/Hiveling.cs +++ b/NPCs/Astral/Hiveling.cs @@ -7,6 +7,7 @@ using System; using Terraria; using Terraria.ModLoader; using Terraria.Audio; +using ReLogic.Content; namespace CalamityMod.NPCs.Astral { @@ -18,7 +19,7 @@ namespace CalamityMod.NPCs.Astral { DisplayName.SetDefault("Hiveling"); if (!Main.dedServ) - glowmask = ModContent.Request("CalamityMod/NPCs/Astral/HivelingGlow").Value; + glowmask = ModContent.Request("CalamityMod/NPCs/Astral/HivelingGlow", AssetRequestMode.ImmediateLoad).Value; Main.npcFrameCount[NPC.type] = 4; } @@ -30,7 +31,7 @@ namespace CalamityMod.NPCs.Astral NPC.damage = 30; NPC.defense = 0; NPC.lifeMax = 150; - NPC.DeathSound = Mod.GetLegacySoundSlot(SoundType.NPCKilled, "Sounds/NPCKilled/AstralEnemyDeath"); + NPC.DeathSound = SoundLoader.GetLegacySoundSlot(Mod, "Sounds/NPCKilled/AstralEnemyDeath"); NPC.knockBackResist = 0.5f; NPC.noGravity = true; NPC.value = Item.buyPrice(0, 0, 5, 0); diff --git a/NPCs/Astral/Mantis.cs b/NPCs/Astral/Mantis.cs index d784cf719a..99abc1db59 100644 --- a/NPCs/Astral/Mantis.cs +++ b/NPCs/Astral/Mantis.cs @@ -12,6 +12,7 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; +using ReLogic.Content; namespace CalamityMod.NPCs.Astral { @@ -24,7 +25,7 @@ namespace CalamityMod.NPCs.Astral DisplayName.SetDefault("Mantis"); Main.npcFrameCount[NPC.type] = 14; if (!Main.dedServ) - glowmask = ModContent.Request("CalamityMod/NPCs/Astral/MantisGlow").Value; + glowmask = ModContent.Request("CalamityMod/NPCs/Astral/MantisGlow", AssetRequestMode.ImmediateLoad).Value; } public override void SetDefaults() @@ -39,7 +40,7 @@ namespace CalamityMod.NPCs.Astral NPC.lifeMax = 340; NPC.knockBackResist = 0.2f; NPC.value = Item.buyPrice(0, 0, 15, 0); - NPC.DeathSound = Mod.GetLegacySoundSlot(SoundType.NPCKilled, "Sounds/NPCKilled/AstralEnemyDeath"); + NPC.DeathSound = SoundLoader.GetLegacySoundSlot(Mod, "Sounds/NPCKilled/AstralEnemyDeath"); Banner = NPC.type; BannerItem = ModContent.ItemType(); if (DownedBossSystem.downedAstrumAureus) @@ -119,7 +120,7 @@ namespace CalamityMod.NPCs.Astral Vector2 vector = Main.player[NPC.target].Center - NPC.Center; vector.Normalize(); int damage = DownedBossSystem.downedAstrumAureus ? 55 : 45; - Projectile.NewProjectile(NPC.Center + (NPC.Center.X < target.Center.X ? -14f : 14f) * Vector2.UnitX, vector * 7f, ModContent.ProjectileType(), damage, 0f); + Projectile.NewProjectile(NPC.GetSpawnSource_ForProjectile(), NPC.Center + (NPC.Center.X < target.Center.X ? -14f : 14f) * Vector2.UnitX, vector * 7f, ModContent.ProjectileType(), damage, 0f); } } @@ -236,11 +237,11 @@ namespace CalamityMod.NPCs.Astral player.AddBuff(ModContent.BuffType(), 120, true); } - public override void NPCLoot() + public override void ModifyNPCLoot(NPCLoot npcLoot) { - DropHelper.DropItem(NPC, ModContent.ItemType(), 2, 3); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), Main.expertMode); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), DownedBossSystem.downedAstrumAureus, 7, 1, 1); + npcLoot.AddIf(() => !Main.expertMode, ModContent.ItemType(), 2, 1, 2); + npcLoot.AddIf(() => Main.expertMode, ModContent.ItemType(), 1, 1, 3); + npcLoot.AddIf(() => DownedBossSystem.downedAstrumAureus, ModContent.ItemType(), 7); } } } diff --git a/NPCs/Astral/Nova.cs b/NPCs/Astral/Nova.cs index 22054ce7b6..833a4754a9 100644 --- a/NPCs/Astral/Nova.cs +++ b/NPCs/Astral/Nova.cs @@ -13,6 +13,7 @@ using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; +using ReLogic.Content; namespace CalamityMod.NPCs.Astral { @@ -32,7 +33,7 @@ namespace CalamityMod.NPCs.Astral Main.npcFrameCount[NPC.type] = 8; if (!Main.dedServ) - glowmask = ModContent.Request("CalamityMod/NPCs/Astral/NovaGlow").Value; + glowmask = ModContent.Request("CalamityMod/NPCs/Astral/NovaGlow", AssetRequestMode.ImmediateLoad).Value; } public override void SetDefaults() @@ -43,7 +44,7 @@ namespace CalamityMod.NPCs.Astral NPC.defense = 15; NPC.DR_NERD(0.15f); NPC.lifeMax = 230; - NPC.DeathSound = Mod.GetLegacySoundSlot(SoundType.NPCKilled, "Sounds/NPCKilled/AstralEnemyDeath"); + NPC.DeathSound = SoundLoader.GetLegacySoundSlot(Mod, "Sounds/NPCKilled/AstralEnemyDeath"); NPC.noGravity = true; NPC.knockBackResist = 0.5f; NPC.value = Item.buyPrice(0, 0, 20, 0); @@ -196,7 +197,7 @@ namespace CalamityMod.NPCs.Astral //other things NPC.ai[3] = -20000f; NPC.value = 0f; - NPC.extraValue = 0f; + NPC.extraValue = 0; NPC.StrikeNPCNoInteraction(9999, 1f, 1); int size = 30; @@ -256,9 +257,12 @@ namespace CalamityMod.NPCs.Astral } } - public override bool PreNPCLoot() + public override void ModifyNPCLoot(NPCLoot npcLoot) { - return NPC.ai[3] > -10000; + npcLoot.AddIf(() => NPC.ai[3] <= -10000f && !Main.expertMode, ModContent.ItemType(), 1, 2, 3); + npcLoot.AddIf(() => NPC.ai[3] <= -10000f && Main.expertMode, ModContent.ItemType(), 1, 3, 4); + npcLoot.AddIf(() => NPC.ai[3] <= -10000f, ModContent.ItemType(), 7); + npcLoot.AddIf(() => NPC.ai[3] <= -10000f, ModContent.ItemType(), 7); } public override void PostDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) @@ -283,13 +287,5 @@ namespace CalamityMod.NPCs.Astral { player.AddBuff(ModContent.BuffType(), 120, true); } - - public override void NPCLoot() - { - DropHelper.DropItem(NPC, ModContent.ItemType(), 2, 3); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), Main.expertMode); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), DownedBossSystem.downedAstrumAureus, 7, 1, 1); - DropHelper.DropItemChance(NPC, ModContent.ItemType(), 7, 1, 1); - } } } diff --git a/NPCs/Astral/SmallSightseer.cs b/NPCs/Astral/SmallSightseer.cs index 10a38b89ff..60273f8db2 100644 --- a/NPCs/Astral/SmallSightseer.cs +++ b/NPCs/Astral/SmallSightseer.cs @@ -10,6 +10,7 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; +using ReLogic.Content; namespace CalamityMod.NPCs.Astral { @@ -23,7 +24,7 @@ namespace CalamityMod.NPCs.Astral Main.npcFrameCount[NPC.type] = 4; if (!Main.dedServ) - glowmask = ModContent.Request("CalamityMod/NPCs/Astral/SmallSightseerGlow").Value; + glowmask = ModContent.Request("CalamityMod/NPCs/Astral/SmallSightseerGlow", AssetRequestMode.ImmediateLoad).Value; } public override void SetDefaults() @@ -34,7 +35,7 @@ namespace CalamityMod.NPCs.Astral NPC.defense = 16; NPC.DR_NERD(0.15f); NPC.lifeMax = 310; - NPC.DeathSound = Mod.GetLegacySoundSlot(SoundType.NPCKilled, "Sounds/NPCKilled/AstralEnemyDeath"); + NPC.DeathSound = SoundLoader.GetLegacySoundSlot(Mod, "Sounds/NPCKilled/AstralEnemyDeath"); NPC.noGravity = true; NPC.knockBackResist = 0.58f; NPC.value = Item.buyPrice(0, 0, 10, 0); @@ -136,10 +137,10 @@ namespace CalamityMod.NPCs.Astral player.AddBuff(ModContent.BuffType(), 60, true); } - public override void NPCLoot() + public override void ModifyNPCLoot(NPCLoot npcLoot) { - DropHelper.DropItemChance(NPC, ModContent.ItemType(), 0.5f, 1, 2); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), Main.expertMode); + npcLoot.AddIf(() => !Main.expertMode, ModContent.ItemType(), 2, 1, 2); + npcLoot.AddIf(() => Main.expertMode, ModContent.ItemType(), 1, 1, 3); } } } diff --git a/NPCs/Astral/StellarCulex.cs b/NPCs/Astral/StellarCulex.cs index f827cf4f72..e60e69d333 100644 --- a/NPCs/Astral/StellarCulex.cs +++ b/NPCs/Astral/StellarCulex.cs @@ -11,6 +11,7 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; +using ReLogic.Content; namespace CalamityMod.NPCs.Astral { @@ -22,7 +23,7 @@ namespace CalamityMod.NPCs.Astral { DisplayName.SetDefault("Stellar Culex"); if (!Main.dedServ) - glowmask = ModContent.Request("CalamityMod/NPCs/Astral/StellarCulexGlow").Value; + glowmask = ModContent.Request("CalamityMod/NPCs/Astral/StellarCulexGlow", AssetRequestMode.ImmediateLoad).Value; Main.npcFrameCount[NPC.type] = 4; } @@ -38,8 +39,8 @@ namespace CalamityMod.NPCs.Astral NPC.knockBackResist = 0.65f; NPC.lifeMax = 210; NPC.value = Item.buyPrice(0, 0, 10, 0); - NPC.DeathSound = Mod.GetLegacySoundSlot(SoundType.NPCKilled, "Sounds/NPCKilled/AstralEnemyDeath"); - animationType = NPCID.GiantFlyingFox; + NPC.DeathSound = SoundLoader.GetLegacySoundSlot(Mod, "Sounds/NPCKilled/AstralEnemyDeath"); + AnimationType = NPCID.GiantFlyingFox; Banner = NPC.type; BannerItem = ModContent.ItemType(); if (DownedBossSystem.downedAstrumAureus) @@ -122,11 +123,11 @@ namespace CalamityMod.NPCs.Astral player.AddBuff(ModContent.BuffType(), 120, true); } - public override void NPCLoot() + public override void ModifyNPCLoot(NPCLoot npcLoot) { - DropHelper.DropItemChance(NPC, ModContent.ItemType(), 0.5f, 1, 2); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), Main.expertMode); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), DownedBossSystem.downedAstrumAureus, 7, 1, 1); + npcLoot.AddIf(() => !Main.expertMode, ModContent.ItemType(), 2, 1, 2); + npcLoot.AddIf(() => Main.expertMode, ModContent.ItemType(), 1, 1, 3); + npcLoot.AddIf(() => DownedBossSystem.downedAstrumAureus, ModContent.ItemType(), 7); } } } diff --git a/NPCs/AstrumAureus/AstrumAureus.cs b/NPCs/AstrumAureus/AstrumAureus.cs index f2fc6f694d..bd1570830d 100644 --- a/NPCs/AstrumAureus/AstrumAureus.cs +++ b/NPCs/AstrumAureus/AstrumAureus.cs @@ -24,6 +24,7 @@ using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; +using Terraria.GameContent.ItemDropRules; namespace CalamityMod.NPCs.AstrumAureus { @@ -57,8 +58,7 @@ namespace CalamityMod.NPCs.AstrumAureus NPC.value = Item.buyPrice(0, 60, 0, 0); NPC.boss = true; NPC.DeathSound = SoundID.NPCDeath14; - music = CalamityMod.Instance.GetMusicFromMusicMod("AstrumAureus") ?? MusicID.Boss3; - bossBag = ModContent.ItemType(); + Music = CalamityMod.Instance.GetMusicFromMusicMod("AstrumAureus") ?? MusicID.Boss3; double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; NPC.lifeMax += (int)(NPC.lifeMax * HPBoost); NPC.Calamity().VulnerableToHeat = true; @@ -311,53 +311,47 @@ namespace CalamityMod.NPCs.AstrumAureus potionType = ItemID.GreaterHealingPotion; } - public override void NPCLoot() + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + // Boss bag + npcLoot.Add(ItemDropRule.BossBag(ModContent.ItemType())); + + // Normal drops: Everything that would otherwise be in the bag + var normalOnly = npcLoot.DefineNormalOnlyDropSet(); + { + // Weapons + int[] weapons = new int[] + { + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + }; + normalOnly.Add(ItemDropRule.OneFromOptions(DropHelper.NormalWeaponDropRateInt, weapons)); + + // Equipment + normalOnly.Add(ModContent.ItemType(), 7); + + // Other + normalOnly.Add(ModContent.ItemType(), 1, 9, 12); + } + + npcLoot.AddIf(() => !Main.expertMode, ModContent.ItemType(), 10); + + npcLoot.Add(ModContent.ItemType(), 10); + npcLoot.AddIf(() => !DownedBossSystem.downedAstrumAureus, ModContent.ItemType()); + + // Other + npcLoot.Add(ItemID.HallowedKey, 3); + } + + public override void OnKill() { CalamityGlobalNPC.SetNewBossJustDowned(NPC); - DropHelper.DropBags(NPC); - - DropHelper.DropItemChance(NPC, ModContent.ItemType(), 10); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), true, !DownedBossSystem.downedAstrumAureus); - CalamityGlobalNPC.SetNewShopVariable(new int[] { NPCID.Wizard, ModContent.NPCType() }, DownedBossSystem.downedAstrumAureus); - // All other drops are contained in the bag, so they only drop directly on Normal - if (!Main.expertMode) - { - // Materials - DropHelper.DropItemSpray(NPC, ModContent.ItemType(), 20, 30, 2); - DropHelper.DropItemSpray(NPC, ItemID.FallenStar, 18, 24, 2); - - // Weapons - float w = DropHelper.NormalWeaponDropRateFloat; - DropHelper.DropEntireWeightedSet(NPC, - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w) - ); - - // Equipment - DropHelper.DropItem(NPC, ModContent.ItemType(), true); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), NPC.downedMoonlord); - - // Vanity - DropHelper.DropItemChance(NPC, ModContent.ItemType(), 7); - - // Other - DropHelper.DropItem(NPC, ModContent.ItemType(), 9, 12); - } - - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), !Main.expertMode, 0.1f); - - // Other - DropHelper.DropItemChance(NPC, ItemID.HallowedKey, 3); - - // Drop an Astral Meteor if applicable - ThreadPool.QueueUserWorkItem(_ => AstralBiome.PlaceAstralMeteor()); - // If Astrum Aureus has not yet been killed, notify players of new Astral enemy drops if (!DownedBossSystem.downedAstrumAureus) { @@ -369,6 +363,9 @@ namespace CalamityMod.NPCs.AstrumAureus CalamityUtils.DisplayLocalizedText(key2, messageColor); } + // Drop an Astral Meteor if applicable + ThreadPool.QueueUserWorkItem(_ => AstralBiome.PlaceAstralMeteor()); + // Mark Astrum Aureus as dead DownedBossSystem.downedAstrumAureus = true; CalamityNetcode.SyncWorld(); diff --git a/NPCs/AstrumAureus/AureusSpawn.cs b/NPCs/AstrumAureus/AureusSpawn.cs index 69cff1840b..bf4ea62fe4 100644 --- a/NPCs/AstrumAureus/AureusSpawn.cs +++ b/NPCs/AstrumAureus/AureusSpawn.cs @@ -173,7 +173,7 @@ namespace CalamityMod.NPCs.AstrumAureus num7 *= num8; int type = ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); - Projectile.NewProjectile(NPC.Center.X, NPC.Center.Y, num6, num7, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSpawnSource_ForProjectile(), NPC.Center.X, NPC.Center.Y, num6, num7, type, damage, 0f, Main.myPlayer); } } } @@ -360,8 +360,6 @@ namespace CalamityMod.NPCs.AstrumAureus player.AddBuff(ModContent.BuffType(), 120, true); } - public override bool PreNPCLoot() => false; - public override bool CheckDead() { SoundEngine.PlaySound(SoundID.Item, (int)NPC.position.X, (int)NPC.position.Y, 14); diff --git a/NPCs/AstrumDeus/AstrumDeusBodySpectral.cs b/NPCs/AstrumDeus/AstrumDeusBodySpectral.cs index 8182ea2992..175b74dadd 100644 --- a/NPCs/AstrumDeus/AstrumDeusBodySpectral.cs +++ b/NPCs/AstrumDeus/AstrumDeusBodySpectral.cs @@ -50,10 +50,10 @@ namespace CalamityMod.NPCs.AstrumDeus NPC.noTileCollide = true; NPC.canGhostHeal = false; NPC.HitSound = SoundID.NPCHit4; - NPC.DeathSound = Mod.GetLegacySoundSlot(SoundType.NPCKilled, "Sounds/NPCKilled/AstrumDeusDeath"); + NPC.DeathSound = SoundLoader.GetLegacySoundSlot(Mod, "Sounds/NPCKilled/AstrumDeusDeath"); NPC.netAlways = true; NPC.boss = true; - music = CalamityMod.Instance.GetMusicFromMusicMod("AstrumDeus") ?? MusicID.Boss3; + Music = CalamityMod.Instance.GetMusicFromMusicMod("AstrumDeus") ?? MusicID.Boss3; NPC.dontCountMe = true; NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; @@ -177,11 +177,6 @@ namespace CalamityMod.NPCs.AstrumDeus return false; } - public override bool PreNPCLoot() - { - return false; - } - public override void HitEffect(int hitDirection, double damage) { if (NPC.life <= 0) diff --git a/NPCs/AstrumDeus/AstrumDeusHeadSpectral.cs b/NPCs/AstrumDeus/AstrumDeusHeadSpectral.cs index c4b8331e2e..859302a3b7 100644 --- a/NPCs/AstrumDeus/AstrumDeusHeadSpectral.cs +++ b/NPCs/AstrumDeus/AstrumDeusHeadSpectral.cs @@ -21,6 +21,7 @@ using Terraria; using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; +using Terraria.GameContent.ItemDropRules; namespace CalamityMod.NPCs.AstrumDeus { @@ -65,10 +66,9 @@ namespace CalamityMod.NPCs.AstrumDeus NPC.noGravity = true; NPC.noTileCollide = true; NPC.HitSound = SoundID.NPCHit4; - NPC.DeathSound = Mod.GetLegacySoundSlot(SoundType.NPCKilled, "Sounds/NPCKilled/AstrumDeusDeath"); + NPC.DeathSound = SoundLoader.GetLegacySoundSlot(Mod, "Sounds/NPCKilled/AstrumDeusDeath"); NPC.netAlways = true; - music = CalamityMod.Instance.GetMusicFromMusicMod("AstrumDeus") ?? MusicID.Boss3; - bossBag = ModContent.ItemType(); + Music = CalamityMod.Instance.GetMusicFromMusicMod("AstrumDeus") ?? MusicID.Boss3; NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; } @@ -207,10 +207,12 @@ namespace CalamityMod.NPCs.AstrumDeus public override void BossLoot(ref string name, ref int potionType) => potionType = ModContent.ItemType(); - public override bool SpecialNPCLoot() + public bool ShouldNotDropThings() => NPC.Calamity().newAI[0] == 0f || ((CalamityWorld.death || BossRushEvent.BossRushActive) && NPC.Calamity().newAI[0] != 3f); + + public override bool SpecialOnKill() { - if (NPC.Calamity().newAI[0] == 0f || ((CalamityWorld.death || BossRushEvent.BossRushActive) && NPC.Calamity().newAI[0] != 3f)) - return false; + if (ShouldNotDropThings()) + return true; int closestSegmentID = DropHelper.FindClosestWormSegment(NPC, ModContent.NPCType(), @@ -218,14 +220,13 @@ namespace CalamityMod.NPCs.AstrumDeus ModContent.NPCType()); NPC.position = Main.npc[closestSegmentID].position; - return false; + return true; } - public override bool PreNPCLoot() + public override void OnKill() { - // Unsplit Deus does not drop anything when killed/despawned. - if (NPC.Calamity().newAI[0] == 0f || ((CalamityWorld.death || BossRushEvent.BossRushActive) && NPC.Calamity().newAI[0] != 3f)) - return false; + if (ShouldNotDropThings()) + return; // Killing ANY split Deus makes all other Deus heads die immediately. for (int i = 0; i < Main.maxNPCs; ++i) @@ -241,52 +242,8 @@ namespace CalamityMod.NPCs.AstrumDeus } } - return true; - } - - public override void NPCLoot() - { CalamityGlobalNPC.SetNewBossJustDowned(NPC); - DropHelper.DropBags(NPC); - - DropHelper.DropItem(NPC, ItemID.GreaterHealingPotion, 8, 14); - DropHelper.DropItemChance(NPC, ModContent.ItemType(), 10); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), !DownedBossSystem.downedAstrumDeus); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), !DownedBossSystem.downedAstrumDeus); - - // Drop a large spray of all 4 lunar fragments - int minFragments = Main.expertMode ? 20 : 16; - int maxFragments = Main.expertMode ? 32 : 24; - DropHelper.DropItemSpray(NPC, ItemID.FragmentSolar, minFragments, maxFragments, 4); - DropHelper.DropItemSpray(NPC, ItemID.FragmentVortex, minFragments, maxFragments, 4); - DropHelper.DropItemSpray(NPC, ItemID.FragmentNebula, minFragments, maxFragments, 4); - DropHelper.DropItemSpray(NPC, ItemID.FragmentStardust, minFragments, maxFragments, 4); - - // All other drops are contained in the bag, so they only drop directly on Normal - if (!Main.expertMode) - { - DropHelper.DropItemSpray(NPC, ModContent.ItemType(), 50, 80, 5); - DropHelper.DropItemSpray(NPC, ItemID.FallenStar, 25, 40, 5); - - // Weapons - float w = DropHelper.NormalWeaponDropRateFloat; - DropHelper.DropEntireWeightedSet(NPC, - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w) - ); - - // Equipment - DropHelper.DropItem(NPC, ModContent.ItemType(), true); - DropHelper.DropItemChance(NPC, ModContent.ItemType(), 5); - - // Vanity - DropHelper.DropItemChance(NPC, ModContent.ItemType(), 7); - } - // Notify players that Astral Ore can be mined if Deus has never been killed yet if (!DownedBossSystem.downedAstrumDeus) { @@ -300,6 +257,48 @@ namespace CalamityMod.NPCs.AstrumDeus CalamityNetcode.SyncWorld(); } + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + npcLoot.Add(ItemDropRule.BossBag(ModContent.ItemType())); + + // Normal drops: Everything that would otherwise be in the bag + var normalOnly = npcLoot.DefineNormalOnlyDropSet(); + { + // Weapons + int[] weapons = new int[] + { + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + }; + normalOnly.Add(ItemDropRule.OneFromOptions(DropHelper.NormalWeaponDropRateInt, weapons)); + + // Equipment + normalOnly.Add(ModContent.ItemType(), 7); + normalOnly.Add(ModContent.ItemType()); + normalOnly.Add(ModContent.ItemType(), 5); + + // Materials + normalOnly.Add(ItemID.FallenStar, 25, 40); + normalOnly.Add(ModContent.ItemType(), 50, 80); + } + + npcLoot.Add(ItemID.GreaterHealingPotion, 1, 8, 14); + npcLoot.Add(ModContent.ItemType(), 5); + npcLoot.AddIf(() => !DownedBossSystem.downedAstrumDeus, ModContent.ItemType()); + npcLoot.AddIf(() => !DownedBossSystem.downedAstrumDeus, ModContent.ItemType()); + npcLoot.AddIf(() => !Main.expertMode, ItemID.FragmentSolar, 16, 24); + npcLoot.AddIf(() => !Main.expertMode, ItemID.FragmentVortex, 16, 24); + npcLoot.AddIf(() => !Main.expertMode, ItemID.FragmentNebula, 16, 24); + npcLoot.AddIf(() => !Main.expertMode, ItemID.FragmentStardust, 16, 24); + npcLoot.AddIf(() => Main.expertMode, ItemID.FragmentSolar, 20, 32); + npcLoot.AddIf(() => Main.expertMode, ItemID.FragmentVortex, 20, 32); + npcLoot.AddIf(() => Main.expertMode, ItemID.FragmentNebula, 20, 32); + npcLoot.AddIf(() => Main.expertMode, ItemID.FragmentStardust, 20, 32); + } + public override void OnHitPlayer(Player player, int damage, bool crit) { player.AddBuff(ModContent.BuffType(), 240, true); diff --git a/NPCs/AstrumDeus/AstrumDeusTailSpectral.cs b/NPCs/AstrumDeus/AstrumDeusTailSpectral.cs index 094be920c2..c2c604ba1c 100644 --- a/NPCs/AstrumDeus/AstrumDeusTailSpectral.cs +++ b/NPCs/AstrumDeus/AstrumDeusTailSpectral.cs @@ -50,10 +50,10 @@ namespace CalamityMod.NPCs.AstrumDeus NPC.noTileCollide = true; NPC.canGhostHeal = false; NPC.HitSound = SoundID.NPCHit4; - NPC.DeathSound = Mod.GetLegacySoundSlot(SoundType.NPCKilled, "Sounds/NPCKilled/AstrumDeusDeath"); + NPC.DeathSound = SoundLoader.GetLegacySoundSlot(Mod, "Sounds/NPCKilled/AstrumDeusDeath"); NPC.netAlways = true; NPC.boss = true; - music = CalamityMod.Instance.GetMusicFromMusicMod("AstrumDeus") ?? MusicID.Boss3; + Music = CalamityMod.Instance.GetMusicFromMusicMod("AstrumDeus") ?? MusicID.Boss3; NPC.dontCountMe = true; NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; @@ -189,11 +189,6 @@ namespace CalamityMod.NPCs.AstrumDeus return false; } - public override bool PreNPCLoot() - { - return false; - } - public override void OnHitPlayer(Player player, int damage, bool crit) { player.AddBuff(ModContent.BuffType(), 120, true); diff --git a/NPCs/BrimstoneElemental/Brimling.cs b/NPCs/BrimstoneElemental/Brimling.cs index a2b7d4b6f7..4ff063ce69 100644 --- a/NPCs/BrimstoneElemental/Brimling.cs +++ b/NPCs/BrimstoneElemental/Brimling.cs @@ -121,7 +121,7 @@ namespace CalamityMod.NPCs.BrimstoneElemental num7 *= num8; int type = ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); - Projectile.NewProjectile(NPC.Center.X, NPC.Center.Y, num6, num7, type, damage + (provy ? 30 : 0), 0f, Main.myPlayer, Main.player[NPC.target].Center.X, Main.player[NPC.target].Center.Y); + Projectile.NewProjectile(NPC.GetSpawnSource_ForProjectile(), NPC.Center.X, NPC.Center.Y, num6, num7, type, damage + (provy ? 30 : 0), 0f, Main.myPlayer, Main.player[NPC.target].Center.X, Main.player[NPC.target].Center.Y); } if (vector251.Length() > 400f || !flag104) { @@ -246,13 +246,13 @@ namespace CalamityMod.NPCs.BrimstoneElemental } } - public override void NPCLoot() + public override void OnKill() { if (!CalamityWorld.revenge) { int closestPlayer = Player.FindClosest(NPC.Center, 1, 1); if (Main.rand.Next(4) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) - Item.NewItem((int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height, ItemID.Heart); + Item.NewItem(NPC.GetItemSource_Loot(), (int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height, ItemID.Heart); } } diff --git a/NPCs/BrimstoneElemental/BrimstoneElemental.cs b/NPCs/BrimstoneElemental/BrimstoneElemental.cs index cee9addf44..957546fb73 100644 --- a/NPCs/BrimstoneElemental/BrimstoneElemental.cs +++ b/NPCs/BrimstoneElemental/BrimstoneElemental.cs @@ -16,6 +16,7 @@ using CalamityMod.World; using Microsoft.Xna.Framework; using System.IO; using Terraria; +using Terraria.GameContent.ItemDropRules; using Terraria.ID; using Terraria.ModLoader; @@ -58,8 +59,7 @@ namespace CalamityMod.NPCs.BrimstoneElemental NPC.netAlways = true; NPC.HitSound = SoundID.NPCHit23; NPC.DeathSound = SoundID.NPCDeath39; - music = CalamityMod.Instance.GetMusicFromMusicMod("BrimstoneElemental") ?? MusicID.Boss4; - bossBag = ModContent.ItemType(); + Music = CalamityMod.Instance.GetMusicFromMusicMod("BrimstoneElemental") ?? MusicID.Boss4; NPC.Calamity().VulnerableToHeat = false; NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToWater = true; @@ -149,47 +149,51 @@ namespace CalamityMod.NPCs.BrimstoneElemental potionType = ItemID.GreaterHealingPotion; } - public override void NPCLoot() + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + npcLoot.Add(ItemDropRule.BossBag(ModContent.ItemType())); + + npcLoot.Add(ModContent.ItemType(), 10); + npcLoot.AddIf(() => DownedBossSystem.downedBrimstoneElemental, ModContent.ItemType()); + + // Normal drops: Everything that would otherwise be in the bag + var normalOnly = npcLoot.DefineNormalOnlyDropSet(); + { + // Weapons + int[] weapons = new int[] + { + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + }; + normalOnly.Add(ItemDropRule.OneFromOptions(DropHelper.NormalWeaponDropRateInt, weapons)); + + // Materials + normalOnly.Add(ModContent.ItemType(), 1, 4, 8); + + // Equipment + normalOnly.Add(ModContent.ItemType()); + normalOnly.Add(ModContent.ItemType()); + normalOnly.Add(ModContent.ItemType()); + + // Vanity + normalOnly.Add(ModContent.ItemType(), 7); + } + + npcLoot.AddIf(() => !Main.expertMode, ModContent.ItemType(), 10); + npcLoot.AddIf(() => !Main.expertMode, ModContent.ItemType(), 10); + npcLoot.AddIf(() => !Main.expertMode && DownedBossSystem.downedProvidence, ModContent.ItemType()); + npcLoot.AddIf(() => !Main.expertMode && DownedBossSystem.downedProvidence, ModContent.ItemType(), 1, 20, 30); + } + + public override void OnKill() { CalamityGlobalNPC.SetNewBossJustDowned(NPC); - DropHelper.DropBags(NPC); - - DropHelper.DropItemChance(NPC, ModContent.ItemType(), 10); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), true, !DownedBossSystem.downedBrimstoneElemental); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), true, !DownedBossSystem.downedBrimstoneElemental); - CalamityGlobalNPC.SetNewShopVariable(new int[] { NPCID.Wizard }, DownedBossSystem.downedBrimstoneElemental); - if (!Main.expertMode) - { - //Materials - DropHelper.DropItemSpray(NPC, ModContent.ItemType(), 4, 8); - if (DownedBossSystem.downedProvidence) - DropHelper.DropItemSpray(NPC, ModContent.ItemType(), 20, 30, 2); - - // Weapons - float w = DropHelper.NormalWeaponDropRateFloat; - DropHelper.DropEntireWeightedSet(NPC, - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w) - ); - - // Equipment - DropHelper.DropItem(NPC, ModContent.ItemType(), true); - DropHelper.DropItem(NPC, ModContent.ItemType(), true); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), DownedBossSystem.downedProvidence); - - // Vanity - DropHelper.DropItemChance(NPC, ModContent.ItemType(), 7); - } - - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), !Main.expertMode, 0.1f); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), !Main.expertMode, 0.1f); - - // mark brimmy as dead + // Mark brimmy as dead DownedBossSystem.downedBrimstoneElemental = true; CalamityNetcode.SyncWorld(); } diff --git a/NPCs/Bumblebirb/Bumblefuck.cs b/NPCs/Bumblebirb/Bumblefuck.cs index 3dd77029f1..d2cdce97eb 100644 --- a/NPCs/Bumblebirb/Bumblefuck.cs +++ b/NPCs/Bumblebirb/Bumblefuck.cs @@ -17,6 +17,7 @@ using System; using System.IO; using Terraria; using Terraria.GameContent; +using Terraria.GameContent.ItemDropRules; using Terraria.ID; using Terraria.ModLoader; @@ -52,13 +53,12 @@ namespace CalamityMod.NPCs.Bumblebirb NPC.knockBackResist = 0f; NPC.boss = true; NPC.noTileCollide = true; - music = CalamityMod.Instance.GetMusicFromMusicMod("Dragonfolly") ?? MusicID.Boss4; + Music = CalamityMod.Instance.GetMusicFromMusicMod("Dragonfolly") ?? MusicID.Boss4; NPC.lavaImmune = true; NPC.noGravity = true; NPC.value = Item.buyPrice(1, 25, 0, 0); NPC.HitSound = SoundID.NPCHit51; NPC.DeathSound = SoundID.NPCDeath46; - bossBag = ModContent.ItemType(); NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = true; @@ -391,42 +391,46 @@ namespace CalamityMod.NPCs.Bumblebirb potionType = ModContent.ItemType(); } - public override void NPCLoot() + public override void ModifyNPCLoot(NPCLoot npcLoot) { - CalamityGlobalNPC.SetNewBossJustDowned(NPC); + npcLoot.Add(ModContent.ItemType()); + npcLoot.Add(ModContent.ItemType(), 10); + npcLoot.AddIf(() => !DownedBossSystem.downedDragonfolly, ModContent.ItemType()); - DropHelper.DropBags(NPC); - - DropHelper.DropItemChance(NPC, ModContent.ItemType(), 10); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), true, !DownedBossSystem.downedDragonfolly); - - // All other drops are contained in the bag, so they only drop directly on Normal - if (!Main.expertMode) + // Normal drops: Everything that would otherwise be in the bag + var normalOnly = npcLoot.DefineNormalOnlyDropSet(); { - // Materials - DropHelper.DropItemSpray(NPC, ModContent.ItemType(), 11, 17); - // Weapons - float w = DropHelper.NormalWeaponDropRateFloat; - DropHelper.DropEntireWeightedSet(NPC, - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w) - ); + int[] weapons = new int[] + { + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + }; + normalOnly.Add(ItemDropRule.OneFromOptions(DropHelper.NormalWeaponDropRateInt, weapons)); + + // Materials + normalOnly.Add(ModContent.ItemType(), 1, 11, 17); // Equipment - DropHelper.DropItem(NPC, ModContent.ItemType(), true); + normalOnly.Add(ModContent.ItemType()); // Vanity - DropHelper.DropItemChance(NPC, ModContent.ItemType(), 7); + normalOnly.Add(ModContent.ItemType(), 7); } - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), !Main.expertMode, 0.1f); + npcLoot.AddIf(() => !Main.expertMode, ModContent.ItemType(), 10); + } + + public override void OnKill() + { + CalamityGlobalNPC.SetNewBossJustDowned(NPC); // Mark The Dragonfolly as dead DownedBossSystem.downedDragonfolly = true; CalamityNetcode.SyncWorld(); + } public override void ScaleExpertStats(int numPlayers, float bossLifeScale) diff --git a/NPCs/Bumblebirb/Bumblefuck2.cs b/NPCs/Bumblebirb/Bumblefuck2.cs index dc84f2a338..d3b2643753 100644 --- a/NPCs/Bumblebirb/Bumblefuck2.cs +++ b/NPCs/Bumblebirb/Bumblefuck2.cs @@ -56,15 +56,14 @@ namespace CalamityMod.NPCs.Bumblebirb CalamityAI.Bumblebirb2AI(NPC, Mod, true); } - public override bool PreNPCLoot() + public override void OnKill() { if (!CalamityWorld.revenge) { int closestPlayer = Player.FindClosest(NPC.Center, 1, 1); if (Main.rand.Next(4) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) - Item.NewItem((int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height, ItemID.Heart); + Item.NewItem(NPC.GetItemSource_Loot(), (int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height, ItemID.Heart); } - return false; } public override void FindFrame(int frameHeight) diff --git a/NPCs/Calamitas/CalamitasRun.cs b/NPCs/Calamitas/CalamitasRun.cs index 6bf1ad5094..590ab6be73 100644 --- a/NPCs/Calamitas/CalamitasRun.cs +++ b/NPCs/Calamitas/CalamitasRun.cs @@ -53,7 +53,7 @@ namespace CalamityMod.NPCs.Calamitas NPC.noTileCollide = true; NPC.HitSound = SoundID.NPCHit4; NPC.DeathSound = SoundID.NPCDeath14; - music = CalamityMod.Instance.GetMusicFromMusicMod("Calamitas") ?? MusicID.Boss2; + Music = CalamityMod.Instance.GetMusicFromMusicMod("Calamitas") ?? MusicID.Boss2; NPC.Calamity().VulnerableToHeat = false; NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToWater = true; @@ -143,18 +143,21 @@ namespace CalamityMod.NPCs.Calamitas return NPC.Calamity().newAI[0] == 1f; } - public override void NPCLoot() + public override void OnKill() { if (!CalamityWorld.revenge) { int heartAmt = Main.rand.Next(3) + 3; for (int i = 0; i < heartAmt; i++) - Item.NewItem((int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height, ItemID.Heart); + Item.NewItem(NPC.GetItemSource_Loot(), (int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height, ItemID.Heart); } + } - DropHelper.DropItemChance(NPC, ModContent.ItemType(), 10); - DropHelper.DropItemChance(NPC, ModContent.ItemType(), Main.expertMode ? 4 : 5); - DropHelper.DropItemChance(NPC, ModContent.ItemType(), Main.expertMode ? 4 : 5); + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + npcLoot.Add(ModContent.ItemType(), 10); + npcLoot.Add(ModContent.ItemType(), 4); + npcLoot.Add(ModContent.ItemType(), 4); } public override void HitEffect(int hitDirection, double damage) diff --git a/NPCs/Calamitas/CalamitasRun2.cs b/NPCs/Calamitas/CalamitasRun2.cs index e95ab33633..f8105787bd 100644 --- a/NPCs/Calamitas/CalamitasRun2.cs +++ b/NPCs/Calamitas/CalamitasRun2.cs @@ -53,7 +53,7 @@ namespace CalamityMod.NPCs.Calamitas NPC.noTileCollide = true; NPC.HitSound = SoundID.NPCHit4; NPC.DeathSound = SoundID.NPCDeath14; - music = CalamityMod.Instance.GetMusicFromMusicMod("Calamitas") ?? MusicID.Boss2; + Music = CalamityMod.Instance.GetMusicFromMusicMod("Calamitas") ?? MusicID.Boss2; NPC.Calamity().VulnerableToHeat = false; NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToWater = true; @@ -143,17 +143,20 @@ namespace CalamityMod.NPCs.Calamitas return NPC.Calamity().newAI[0] == 1f; } - public override void NPCLoot() + public override void OnKill() { if (!CalamityWorld.revenge) { int heartAmt = Main.rand.Next(3) + 3; for (int i = 0; i < heartAmt; i++) - Item.NewItem((int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height, ItemID.Heart); + Item.NewItem(NPC.GetItemSource_Loot(), (int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height, ItemID.Heart); } + } - DropHelper.DropItemChance(NPC, ModContent.ItemType(), 10); - DropHelper.DropItemChance(NPC, ModContent.ItemType(), Main.expertMode ? 4 : 5); + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + npcLoot.Add(ModContent.ItemType(), 10); + npcLoot.Add(ModContent.ItemType(), 4); } public override void HitEffect(int hitDirection, double damage) diff --git a/NPCs/Calamitas/CalamitasRun3.cs b/NPCs/Calamitas/CalamitasRun3.cs index 3b7503fe93..2f71c8d8ba 100644 --- a/NPCs/Calamitas/CalamitasRun3.cs +++ b/NPCs/Calamitas/CalamitasRun3.cs @@ -21,6 +21,7 @@ using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; +using Terraria.GameContent.ItemDropRules; namespace CalamityMod.NPCs.Calamitas { @@ -66,8 +67,7 @@ namespace CalamityMod.NPCs.Calamitas NPC.noTileCollide = true; NPC.HitSound = SoundID.NPCHit4; NPC.DeathSound = SoundID.NPCDeath14; - music = CalamityMod.Instance.GetMusicFromMusicMod("Calamitas") ?? MusicID.Boss2; - bossBag = ModContent.ItemType(); + Music = CalamityMod.Instance.GetMusicFromMusicMod("Calamitas") ?? MusicID.Boss2; NPC.Calamity().VulnerableToHeat = false; NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToWater = true; @@ -162,50 +162,51 @@ namespace CalamityMod.NPCs.Calamitas return false; } - public override void NPCLoot() + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + npcLoot.Add(ItemDropRule.BossBag(ModContent.ItemType())); + + npcLoot.Add(ItemID.BrokenHeroSword); + npcLoot.Add(ModContent.ItemType(), 10); + npcLoot.AddIf(() => DownedBossSystem.downedCalamitas, ModContent.ItemType()); + + // Normal drops: Everything that would otherwise be in the bag + var normalOnly = npcLoot.DefineNormalOnlyDropSet(); + { + // Weapons + int[] weapons = new int[] + { + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + }; + normalOnly.Add(ItemDropRule.OneFromOptions(DropHelper.NormalWeaponDropRateInt, weapons)); + + // Equipment + normalOnly.Add(ModContent.ItemType()); + + // Materials + normalOnly.Add(ModContent.ItemType(), 1, 4, 8); + normalOnly.Add(ModContent.ItemType(), 1, 9, 14); + normalOnly.Add(ModContent.ItemType(), 1, 1, 2); + + // Vanity + normalOnly.Add(ModContent.ItemType(), 7); + normalOnly.Add(ItemDropRule.Common(ModContent.ItemType(), 10).OnSuccess(ItemDropRule.Common(ModContent.ItemType()))); + } + + npcLoot.AddIf(() => !Main.expertMode, ModContent.ItemType(), 10); + npcLoot.AddIf(() => !Main.expertMode && DownedBossSystem.downedProvidence, ModContent.ItemType(), 1, 30, 40); + } + + public override void OnKill() { CalamityGlobalNPC.SetNewBossJustDowned(NPC); - DropHelper.DropBags(NPC); - - DropHelper.DropItem(NPC, ItemID.BrokenHeroSword, true); - DropHelper.DropItemChance(NPC, ModContent.ItemType(), 10); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), !DownedBossSystem.downedCalamitas); - CalamityGlobalNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, DownedBossSystem.downedCalamitas); - if (!Main.expertMode) - { - //Materials - DropHelper.DropItemSpray(NPC, ModContent.ItemType(), 4, 8); - DropHelper.DropItem(NPC, ModContent.ItemType(), 9, 14); - DropHelper.DropItem(NPC, ModContent.ItemType(), 1, 2); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), DownedBossSystem.downedProvidence, 1f, 30, 40); - - // Weapons - float w = DropHelper.NormalWeaponDropRateFloat; - DropHelper.DropEntireWeightedSet(NPC, - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w) - ); - - // Equipment - DropHelper.DropItem(NPC, ModContent.ItemType(), true); - - // Vanity - DropHelper.DropItemChance(NPC, ModContent.ItemType(), 7); - if (Main.rand.NextBool(10)) - { - DropHelper.DropItem(NPC, ModContent.ItemType()); - DropHelper.DropItem(NPC, ModContent.ItemType()); - } - } - - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), !Main.expertMode, 0.1f); - // Abyss awakens after killing Calamitas string key = "Mods.CalamityMod.PlantBossText"; Color messageColor = Color.RoyalBlue; diff --git a/NPCs/Calamitas/SoulSeeker.cs b/NPCs/Calamitas/SoulSeeker.cs index 80f0b92c3e..534bdbe76c 100644 --- a/NPCs/Calamitas/SoulSeeker.cs +++ b/NPCs/Calamitas/SoulSeeker.cs @@ -98,7 +98,7 @@ namespace CalamityMod.NPCs.Calamitas int type = ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); - Projectile.NewProjectile(NPC.Center, velocity, type, damage, 1f, NPC.target, 1f, 0f); + Projectile.NewProjectile(NPC.GetSpawnSource_ForProjectile(), NPC.Center, velocity, type, damage, 1f, NPC.target, 1f, 0f); } timer = 0; } @@ -150,13 +150,13 @@ namespace CalamityMod.NPCs.Calamitas } } - public override void NPCLoot() + public override void OnKill() { if (!CalamityWorld.revenge) { int closestPlayer = Player.FindClosest(NPC.Center, 1, 1); if (Main.rand.Next(4) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) - Item.NewItem((int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height, ItemID.Heart); + Item.NewItem(NPC.GetItemSource_Loot(), (int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height, ItemID.Heart); } } diff --git a/NPCs/CeaselessVoid/CeaselessVoid.cs b/NPCs/CeaselessVoid/CeaselessVoid.cs index c400353a85..803da9a930 100644 --- a/NPCs/CeaselessVoid/CeaselessVoid.cs +++ b/NPCs/CeaselessVoid/CeaselessVoid.cs @@ -17,6 +17,7 @@ using Terraria.ID; using Terraria.ModLoader; using System.IO; using Terraria.Audio; +using Terraria.GameContent.ItemDropRules; namespace CalamityMod.NPCs.CeaselessVoid { @@ -63,7 +64,6 @@ namespace CalamityMod.NPCs.CeaselessVoid NPC.noTileCollide = true; NPC.boss = true; NPC.DeathSound = SoundID.NPCDeath14; - bossBag = ModContent.ItemType(); NPC.Calamity().VulnerableToSickness = false; } @@ -178,42 +178,17 @@ namespace CalamityMod.NPCs.CeaselessVoid return false; } - public override void NPCLoot() + public static bool AtFullStrength() => !DownedBossSystem.downedCeaselessVoid || CalamityWorld.DoGSecondStageCountdown <= 0; + + public static bool LastSentinelKilled() => !DownedBossSystem.downedCeaselessVoid && DownedBossSystem.downedStormWeaver && DownedBossSystem.downedSignus; + + public override void OnKill() { - // Only drop items if fought at full strength - bool fullStrength = !DownedBossSystem.downedCeaselessVoid || CalamityWorld.DoGSecondStageCountdown <= 0; + bool fullStrength = AtFullStrength(); + if (fullStrength) { CalamityGlobalNPC.SetNewBossJustDowned(NPC); - - DropHelper.DropBags(NPC); - - DropHelper.DropItemChance(NPC, ModContent.ItemType(), 10); - bool lastSentinelKilled = !DownedBossSystem.downedCeaselessVoid && DownedBossSystem.downedStormWeaver && DownedBossSystem.downedSignus; - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), true, lastSentinelKilled); - - if (!Main.expertMode) - { - // Materials - DropHelper.DropItem(NPC, ModContent.ItemType(), true, 2, 3); - - // Weapons - float dropChance = DropHelper.NormalWeaponDropRateFloat; - DropHelper.DropItemChance(NPC, ModContent.ItemType(), dropChance); - DropHelper.DropItemChance(NPC, ModContent.ItemType(), dropChance); - - // Equipment - DropHelper.DropItem(NPC, ModContent.ItemType(), true); - - // Vanity - DropHelper.DropItemChance(NPC, ModContent.ItemType(), 7); - if (Main.rand.NextBool(20)) - { - DropHelper.DropItem(NPC, ModContent.ItemType()); - DropHelper.DropItem(NPC, ModContent.ItemType()); - DropHelper.DropItem(NPC, ModContent.ItemType()); - } - } } // If DoG's fight is active, set the timer for the remaining two sentinels @@ -237,6 +212,37 @@ namespace CalamityMod.NPCs.CeaselessVoid } } + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + npcLoot.Add(ItemDropRule.BossBagByCondition(DropHelper.If(AtFullStrength), ModContent.ItemType())); + npcLoot.AddIf(AtFullStrength, ModContent.ItemType(), 10); + npcLoot.AddIf(LastSentinelKilled, ModContent.ItemType()); + + // Normal drops: Everything that would otherwise be in the bag + var normalOnly = npcLoot.DefineNormalOnlyDropSet(); + { + // Weapons + int[] weapons = new int[] + { + ModContent.ItemType(), + ModContent.ItemType(), + }; + normalOnly.Add(ItemDropRule.OneFromOptions(DropHelper.NormalWeaponDropRateInt, weapons)); + + // Materials + normalOnly.Add(ModContent.ItemType(), 1, 2, 3); + + // Equipment + normalOnly.Add(ModContent.ItemType()); + + // Vanity + normalOnly.Add(ModContent.ItemType(), 7); + normalOnly.Add(ItemDropRule.Common(ModContent.ItemType(), 20). + OnSuccess(ItemDropRule.Common(ModContent.ItemType())). + OnSuccess(ItemDropRule.Common(ModContent.ItemType()))); + } + } + public override void ScaleExpertStats(int numPlayers, float bossLifeScale) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * bossLifeScale); diff --git a/NPCs/Crabulon/CrabulonIdle.cs b/NPCs/Crabulon/CrabulonIdle.cs index d441d70e3b..bd3a3901be 100644 --- a/NPCs/Crabulon/CrabulonIdle.cs +++ b/NPCs/Crabulon/CrabulonIdle.cs @@ -20,6 +20,8 @@ using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; +using Terraria.GameContent.ItemDropRules; + namespace CalamityMod.NPCs.Crabulon { [AutoloadBossHead] @@ -55,7 +57,6 @@ namespace CalamityMod.NPCs.Crabulon NPC.value = Item.buyPrice(0, 10, 0, 0); NPC.HitSound = SoundID.NPCHit45; NPC.DeathSound = SoundID.NPCDeath1; - bossBag = ModContent.ItemType(); NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = true; @@ -717,38 +718,36 @@ namespace CalamityMod.NPCs.Crabulon return false; } - public override void NPCLoot() + public override void ModifyNPCLoot(NPCLoot npcLoot) { - CalamityGlobalNPC.SetNewBossJustDowned(NPC); + npcLoot.Add(ItemDropRule.BossBag(ModContent.ItemType())); + npcLoot.AddIf(() => !DownedBossSystem.downedCrabulon, ModContent.ItemType()); - DropHelper.DropBags(NPC); - - DropHelper.DropItemChance(NPC, ModContent.ItemType(), 10); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), true, !DownedBossSystem.downedCrabulon); - - // All other drops are contained in the bag, so they only drop directly on Normal - if (!Main.expertMode) + // Normal drops: Everything that would otherwise be in the bag + var normalOnly = npcLoot.DefineNormalOnlyDropSet(); { - // Materials - DropHelper.DropItem(NPC, ItemID.GlowingMushroom, 20, 30); - DropHelper.DropItem(NPC, ItemID.MushroomGrassSeeds, 3, 6); - // Weapons - float w = DropHelper.NormalWeaponDropRateFloat; - DropHelper.DropEntireWeightedSet(NPC, - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w) - ); + int[] weapons = new int[] + { + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + }; + normalOnly.Add(ItemDropRule.OneFromOptions(DropHelper.NormalWeaponDropRateInt, weapons)); // Equipment - DropHelper.DropItem(NPC, ModContent.ItemType(), true); + normalOnly.Add(ModContent.ItemType()); // Vanity - DropHelper.DropItemChance(NPC, ModContent.ItemType(), 7); + normalOnly.Add(ModContent.ItemType(), 7); } + } + + public override void OnKill() + { + CalamityGlobalNPC.SetNewBossJustDowned(NPC); // Mark Crabulon as dead DownedBossSystem.downedCrabulon = true; diff --git a/NPCs/Crags/CalamityEye.cs b/NPCs/Crags/CalamityEye.cs index 63e3de2c73..030b73555e 100644 --- a/NPCs/Crags/CalamityEye.cs +++ b/NPCs/Crags/CalamityEye.cs @@ -1,4 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Banners; using CalamityMod.World; @@ -26,7 +26,7 @@ namespace CalamityMod.NPCs.Crags NPC.defense = 12; NPC.lifeMax = 140; NPC.knockBackResist = 0f; - animationType = NPCID.DemonEye; + AnimationType = NPCID.DemonEye; NPC.value = Item.buyPrice(0, 0, 5, 0); NPC.HitSound = SoundID.NPCHit1; NPC.DeathSound = SoundID.NPCDeath1; @@ -121,12 +121,12 @@ namespace CalamityMod.NPCs.Crags player.AddBuff(ModContent.BuffType(), 120, true); } - public override void NPCLoot() + public override void ModifyNPCLoot(NPCLoot npcLoot) { - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), DownedBossSystem.downedProvidence, 2, 1, 1); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), Main.hardMode, 3, 1, 1); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), Main.hardMode, 2, 1, 1); - DropHelper.DropItemChance(NPC, ItemID.Lens, 2); + npcLoot.Add(ItemID.Lens, 2); + npcLoot.AddIf(() => Main.hardMode, ModContent.ItemType(), 2); + npcLoot.AddIf(() => Main.hardMode, ModContent.ItemType(), 3); + npcLoot.AddIf(() => DownedBossSystem.downedProvidence, ModContent.ItemType(), 2); } } } diff --git a/NPCs/Crags/CharredSlime.cs b/NPCs/Crags/CharredSlime.cs index 05259d4670..ca3a231f6c 100644 --- a/NPCs/Crags/CharredSlime.cs +++ b/NPCs/Crags/CharredSlime.cs @@ -1,4 +1,4 @@ -using CalamityMod.World; +using CalamityMod.World; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using CalamityMod.Items.Placeables.Banners; @@ -27,7 +27,7 @@ namespace CalamityMod.NPCs.Crags NPC.defense = 10; NPC.lifeMax = 250; NPC.knockBackResist = 0f; - animationType = NPCID.CorruptSlime; + AnimationType = NPCID.CorruptSlime; NPC.value = Item.buyPrice(0, 0, 5, 0); NPC.alpha = 50; NPC.lavaImmune = true; @@ -77,11 +77,11 @@ namespace CalamityMod.NPCs.Crags } } - public override void NPCLoot() + public override void ModifyNPCLoot(NPCLoot npcLoot) { - DropHelper.DropItem(NPC, ModContent.ItemType(), 10, 26); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), DownedBossSystem.downedProvidence, 2, 1, 1); - DropHelper.DropItemChance(NPC, ModContent.ItemType(), 3, 1, 1); + npcLoot.Add(ModContent.ItemType(), 1, 10, 26); + npcLoot.AddIf(() => Main.hardMode, ModContent.ItemType(), 3); + npcLoot.AddIf(() => DownedBossSystem.downedProvidence, ModContent.ItemType(), 2); } } } diff --git a/NPCs/Crags/CultistAssassin.cs b/NPCs/Crags/CultistAssassin.cs index deec66a15e..544c3f4833 100644 --- a/NPCs/Crags/CultistAssassin.cs +++ b/NPCs/Crags/CultistAssassin.cs @@ -75,10 +75,10 @@ namespace CalamityMod.NPCs.Crags } } - public override void NPCLoot() + public override void ModifyNPCLoot(NPCLoot npcLoot) { - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), DownedBossSystem.downedProvidence, 2, 1, 1); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), Main.hardMode, 3, 1, 1); + npcLoot.AddIf(() => Main.hardMode, ModContent.ItemType(), 3); + npcLoot.AddIf(() => DownedBossSystem.downedProvidence, ModContent.ItemType(), 2); } } } diff --git a/NPCs/Crags/DespairStone.cs b/NPCs/Crags/DespairStone.cs index ba422cc769..ff1006f00b 100644 --- a/NPCs/Crags/DespairStone.cs +++ b/NPCs/Crags/DespairStone.cs @@ -54,10 +54,10 @@ namespace CalamityMod.NPCs.Crags return spawnInfo.Player.Calamity().ZoneCalamity ? 0.25f : 0f; } - public override void NPCLoot() + public override void ModifyNPCLoot(NPCLoot npcLoot) { - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), DownedBossSystem.downedProvidence, 2, 1, 1); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), Main.hardMode, 3, 1, 1); + npcLoot.AddIf(() => Main.hardMode, ModContent.ItemType(), 3); + npcLoot.AddIf(() => DownedBossSystem.downedProvidence, ModContent.ItemType(), 2); } public override void OnHitPlayer(Player player, int damage, bool crit) diff --git a/NPCs/Crags/HeatSpirit.cs b/NPCs/Crags/HeatSpirit.cs index bb3d62d731..ea33182573 100644 --- a/NPCs/Crags/HeatSpirit.cs +++ b/NPCs/Crags/HeatSpirit.cs @@ -1,4 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Banners; @@ -90,9 +90,9 @@ namespace CalamityMod.NPCs.Crags } } - public override void NPCLoot() + public override void ModifyNPCLoot(NPCLoot npcLoot) { - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), Main.hardMode, 4, 1, 1); + npcLoot.AddIf(() => Main.hardMode, ModContent.ItemType(), 4); } } } diff --git a/NPCs/Crags/Scryllar.cs b/NPCs/Crags/Scryllar.cs index cf822ae28d..414e819aff 100644 --- a/NPCs/Crags/Scryllar.cs +++ b/NPCs/Crags/Scryllar.cs @@ -108,10 +108,6 @@ namespace CalamityMod.NPCs.Crags int num285 = 3; for (int num308 = num284; num308 < num284 + num285; num308++) { - if (Main.tile[num283, num308] == null) - { - Main.tile[num283, num308] = new Tile(); - } if ((Main.tile[num283, num308].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num283, num308].TileType]) || Main.tile[num283, num308].LiquidAmount > 0) { flag23 = false; @@ -123,10 +119,6 @@ namespace CalamityMod.NPCs.Crags bool flag25 = false; for (int num309 = num284; num309 < num284 + num285 - 2; num309++) { - if (Main.tile[num283, num309] == null) - { - Main.tile[num283, num309] = new Tile(); - } if ((Main.tile[num283, num309].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num283, num309].TileType]) || Main.tile[num283, num309].LiquidAmount > 0) { flag25 = true; @@ -255,11 +247,11 @@ namespace CalamityMod.NPCs.Crags return spawnInfo.Player.Calamity().ZoneCalamity ? 0.25f : 0f; } - public override void NPCLoot() + public override void ModifyNPCLoot(NPCLoot npcLoot) { - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), DownedBossSystem.downedProvidence, 20, 1, 1); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), DownedBossSystem.downedProvidence, 2, 1, 1); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), Main.hardMode, 3, 1, 1); + npcLoot.AddIf(() => Main.hardMode, ModContent.ItemType(), 3); + npcLoot.AddIf(() => DownedBossSystem.downedProvidence, ModContent.ItemType(), 2); + npcLoot.AddIf(() => DownedBossSystem.downedProvidence, ModContent.ItemType(), 20); } public override void OnHitPlayer(Player player, int damage, bool crit) diff --git a/NPCs/Crags/ScryllarRage.cs b/NPCs/Crags/ScryllarRage.cs index acb95b85e4..83b81bf20b 100644 --- a/NPCs/Crags/ScryllarRage.cs +++ b/NPCs/Crags/ScryllarRage.cs @@ -108,10 +108,6 @@ namespace CalamityMod.NPCs.Crags int num285 = 3; for (int num308 = num284; num308 < num284 + num285; num308++) { - if (Main.tile[num283, num308] == null) - { - Main.tile[num283, num308] = new Tile(); - } if ((Main.tile[num283, num308].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num283, num308].TileType]) || Main.tile[num283, num308].LiquidAmount > 0) { flag23 = false; @@ -123,10 +119,6 @@ namespace CalamityMod.NPCs.Crags bool flag25 = false; for (int num309 = num284; num309 < num284 + num285 - 2; num309++) { - if (Main.tile[num283, num309] == null) - { - Main.tile[num283, num309] = new Tile(); - } if ((Main.tile[num283, num309].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num283, num309].TileType]) || Main.tile[num283, num309].LiquidAmount > 0) { flag25 = true; @@ -255,11 +247,11 @@ namespace CalamityMod.NPCs.Crags return spawnInfo.Player.Calamity().ZoneCalamity ? 0.125f : 0f; } - public override void NPCLoot() + public override void ModifyNPCLoot(NPCLoot npcLoot) { - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), DownedBossSystem.downedProvidence, 20, 1, 1); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), DownedBossSystem.downedProvidence, 2, 1, 1); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), Main.hardMode, 3, 1, 1); + npcLoot.AddIf(() => Main.hardMode, ModContent.ItemType(), 3); + npcLoot.AddIf(() => DownedBossSystem.downedProvidence, ModContent.ItemType(), 2); + npcLoot.AddIf(() => DownedBossSystem.downedProvidence, ModContent.ItemType(), 20); } public override void OnHitPlayer(Player player, int damage, bool crit) diff --git a/NPCs/Crags/SoulSlurper.cs b/NPCs/Crags/SoulSlurper.cs index fa94351d3a..dfd4afc044 100644 --- a/NPCs/Crags/SoulSlurper.cs +++ b/NPCs/Crags/SoulSlurper.cs @@ -277,11 +277,12 @@ namespace CalamityMod.NPCs.Crags return false; } - public override void NPCLoot() + public override void ModifyNPCLoot(NPCLoot npcLoot) { - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), DownedBossSystem.downedProvidence, 2, 1, 1); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), Main.hardMode, 3, 1, 1); - DropHelper.DropItemChance(NPC, ModContent.ItemType(), (Main.hardMode ? 30 : 10)); + npcLoot.AddIf(() => !Main.hardMode, ModContent.ItemType(), 10); + npcLoot.AddIf(() => Main.hardMode, ModContent.ItemType(), 30); + npcLoot.AddIf(() => Main.hardMode, ModContent.ItemType(), 3); + npcLoot.AddIf(() => DownedBossSystem.downedProvidence, ModContent.ItemType(), 2); } public override void OnHitPlayer(Player player, int damage, bool crit) diff --git a/NPCs/Cryogen/Cryogen.cs b/NPCs/Cryogen/Cryogen.cs index a4b658d9a7..091a6ccd65 100644 --- a/NPCs/Cryogen/Cryogen.cs +++ b/NPCs/Cryogen/Cryogen.cs @@ -25,6 +25,7 @@ using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; +using Terraria.GameContent.ItemDropRules; namespace CalamityMod.NPCs.Cryogen { @@ -66,7 +67,6 @@ namespace CalamityMod.NPCs.Cryogen NPC.HitSound = SoundID.NPCHit5; NPC.DeathSound = SoundID.NPCDeath15; Music = CalamityMod.Instance.GetMusicFromMusicMod("Cryogen") ?? MusicID.FrostMoon; - bossBag = ModContent.ItemType(); NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToCold = false; NPC.Calamity().VulnerableToSickness = false; @@ -1050,50 +1050,56 @@ namespace CalamityMod.NPCs.Cryogen potionType = ItemID.GreaterHealingPotion; } - public override void NPCLoot() + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + // Boss bag + npcLoot.Add(ItemDropRule.BossBag(ModContent.ItemType())); + + // Trophy (always directly from boss, never in bag) + npcLoot.Add(ModContent.ItemType(), 10); + + // Lore + npcLoot.AddIf(() => !DownedBossSystem.downedCryogen, ModContent.ItemType()); + + // Normal drops: Everything that would otherwise be in the bag + var normalOnly = npcLoot.DefineNormalOnlyDropSet(); + { + // Weapons + int[] weapons = new int[] + { + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType() + }; + normalOnly.Add(ItemDropRule.OneFromOptions(DropHelper.NormalWeaponDropRateInt, weapons)); + + // Vanity + normalOnly.Add(ModContent.ItemType(), 7); + + // Materials + normalOnly.Add(ModContent.ItemType(), 1, 4, 8); + + // Equipment + normalOnly.Add(ModContent.ItemType()); + } + + npcLoot.Add(ItemID.FrozenKey, 3); + + npcLoot.AddIf(() => !Main.expertMode, ModContent.ItemType(), 10); + } + + public override void OnKill() { CalamityGlobalNPC.SetNewBossJustDowned(NPC); - DropHelper.DropBags(NPC); - - DropHelper.DropItemChance(NPC, ModContent.ItemType(), 10); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), true, !DownedBossSystem.downedCryogen); - - if (!Main.expertMode) - { - // Materials - DropHelper.DropItemSpray(NPC, ModContent.ItemType(), 4, 8); - - // Weapons - float w = DropHelper.NormalWeaponDropRateFloat; - DropHelper.DropEntireWeightedSet(NPC, - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w) - ); - - // Equipment - DropHelper.DropItem(NPC, ModContent.ItemType(), true); - - // Vanity - DropHelper.DropItemChance(NPC, ModContent.ItemType(), 7); - } - - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), !Main.expertMode, 0.1f); - - // Other - DropHelper.DropItemChance(NPC, ItemID.FrozenKey, 3); - // Spawn Permafrost if he isn't in the world int permafrostNPC = NPC.FindFirstNPC(ModContent.NPCType()); - if (permafrostNPC == -1 && Main.netMode != NetmodeID.MultiplayerClient) - { - NPC.NewNPC((int)NPC.Center.X, (int)NPC.Center.Y, ModContent.NPCType(), 0, 0f, 0f, 0f, 0f, 255); - } + if (permafrostNPC == -1) + NPC.NewNPC(NPC.GetSpawnSource_NPCHurt(), (int)NPC.Center.X, (int)NPC.Center.Y, ModContent.NPCType(), 0, 0f, 0f, 0f, 0f, 255); // If Cryogen has not been killed, notify players about Cryonic Ore if (!DownedBossSystem.downedCryogen) diff --git a/NPCs/Cryogen/CryogenIce.cs b/NPCs/Cryogen/CryogenIce.cs index 76aff53970..2db7136dad 100644 --- a/NPCs/Cryogen/CryogenIce.cs +++ b/NPCs/Cryogen/CryogenIce.cs @@ -98,8 +98,6 @@ namespace CalamityMod.NPCs.Cryogen NPC.lifeMax = (int)(NPC.lifeMax * 0.5f * bossLifeScale); } - public override bool PreNPCLoot() => false; - public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 3; k++) diff --git a/NPCs/DesertScourge/DesertNuisanceBody.cs b/NPCs/DesertScourge/DesertNuisanceBody.cs index 91f0e90605..32bb75d0e3 100644 --- a/NPCs/DesertScourge/DesertNuisanceBody.cs +++ b/NPCs/DesertScourge/DesertNuisanceBody.cs @@ -124,11 +124,6 @@ namespace CalamityMod.NPCs.DesertScourge return false; } - public override bool PreNPCLoot() - { - return false; - } - public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 3; k++) diff --git a/NPCs/DesertScourge/DesertNuisanceHead.cs b/NPCs/DesertScourge/DesertNuisanceHead.cs index cfb27476c5..5f6dbe583e 100644 --- a/NPCs/DesertScourge/DesertNuisanceHead.cs +++ b/NPCs/DesertScourge/DesertNuisanceHead.cs @@ -376,8 +376,6 @@ namespace CalamityMod.NPCs.DesertScourge } } - public override bool PreNPCLoot() => false; - public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 3; k++) diff --git a/NPCs/DesertScourge/DesertNuisanceTail.cs b/NPCs/DesertScourge/DesertNuisanceTail.cs index fc212cfc17..ccd0768228 100644 --- a/NPCs/DesertScourge/DesertNuisanceTail.cs +++ b/NPCs/DesertScourge/DesertNuisanceTail.cs @@ -143,11 +143,6 @@ namespace CalamityMod.NPCs.DesertScourge return false; } - public override bool PreNPCLoot() - { - return false; - } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) { NPC.lifeMax = (int)(NPC.lifeMax * 0.7f * bossLifeScale); diff --git a/NPCs/DesertScourge/DesertScourgeBody.cs b/NPCs/DesertScourge/DesertScourgeBody.cs index a68372994d..690dd9064e 100644 --- a/NPCs/DesertScourge/DesertScourgeBody.cs +++ b/NPCs/DesertScourge/DesertScourgeBody.cs @@ -180,11 +180,6 @@ namespace CalamityMod.NPCs.DesertScourge return false; } - public override bool PreNPCLoot() - { - return false; - } - public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 3; k++) diff --git a/NPCs/DesertScourge/DesertScourgeHead.cs b/NPCs/DesertScourge/DesertScourgeHead.cs index e46f84508a..8cebffc0b9 100644 --- a/NPCs/DesertScourge/DesertScourgeHead.cs +++ b/NPCs/DesertScourge/DesertScourgeHead.cs @@ -19,6 +19,7 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; +using Terraria.GameContent.ItemDropRules; namespace CalamityMod.NPCs.DesertScourge { @@ -57,7 +58,6 @@ namespace CalamityMod.NPCs.DesertScourge NPC.HitSound = SoundID.NPCHit1; NPC.DeathSound = SoundID.NPCDeath1; NPC.netAlways = true; - bossBag = ModContent.ItemType(); Music = CalamityMod.Instance.GetMusicFromMusicMod("DesertScourge") ?? MusicID.Boss1; if (CalamityWorld.malice || BossRushEvent.BossRushActive) @@ -546,58 +546,10 @@ namespace CalamityMod.NPCs.DesertScourge potionType = ItemID.SandBlock; } - public override bool SpecialNPCLoot() - { - int closestSegmentID = DropHelper.FindClosestWormSegment(NPC, - ModContent.NPCType(), - ModContent.NPCType(), - ModContent.NPCType()); - NPC.position = Main.npc[closestSegmentID].position; - return false; - } - - public override void NPCLoot() + public override void OnKill() { CalamityGlobalNPC.SetNewBossJustDowned(NPC); - DropHelper.DropBags(NPC); - - DropHelper.DropItem(NPC, ItemID.LesserHealingPotion, 8, 14); - DropHelper.DropItemChance(NPC, ModContent.ItemType(), 10); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), true, !DownedBossSystem.downedDesertScourge); - - // All other drops are contained in the bag, so they only drop directly on Normal - if (!Main.expertMode) - { - // Materials - DropHelper.DropItem(NPC, ModContent.ItemType(), 7, 14); - DropHelper.DropItem(NPC, ItemID.Coral, 5, 9); - DropHelper.DropItem(NPC, ItemID.Seashell, 5, 9); - DropHelper.DropItem(NPC, ItemID.Starfish, 5, 9); - - // Weapons - // Set up the base drop set, which includes Scourge of the Desert at its normal drop chance. - float w = DropHelper.NormalWeaponDropRateFloat; - DropHelper.DropEntireWeightedSet(NPC, - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w) - ); - - // Equipment - DropHelper.DropItem(NPC, ModContent.ItemType(), true); - - // Vanity - DropHelper.DropItemChance(NPC, ModContent.ItemType(), 7); - - // Fishing - DropHelper.DropItem(NPC, ModContent.ItemType()); - } - // If Desert Scourge has not been killed yet, notify players that the Sunken Sea is open and Sandstorms can happen if (!DownedBossSystem.downedDesertScourge) { @@ -617,6 +569,61 @@ namespace CalamityMod.NPCs.DesertScourge DownedBossSystem.downedDesertScourge = true; CalamityNetcode.SyncWorld(); } + + public override bool SpecialOnKill() + { + int closestSegmentID = DropHelper.FindClosestWormSegment(NPC, + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType()); + NPC.position = Main.npc[closestSegmentID].position; + return true; + } + + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + // Boss bag + npcLoot.Add(ItemDropRule.BossBag(ModContent.ItemType())); + + // Extraneous potions + npcLoot.Add(ItemID.LesserHealingPotion, 1, 8, 14); + + // Trophy (always directly from boss, never in bag) + npcLoot.Add(ModContent.ItemType(), 10); + + // Lore + npcLoot.AddIf(() => !DownedBossSystem.downedDesertScourge, ModContent.ItemType()); + + // Normal drops: Everything that would otherwise be in the bag + var normalOnly = npcLoot.DefineNormalOnlyDropSet(); + { + // Weapons + int[] weapons = new int[] + { + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType() + }; + normalOnly.Add(ItemDropRule.OneFromOptions(DropHelper.NormalWeaponDropRateInt, weapons)); + + // Vanity + normalOnly.Add(ModContent.ItemType(), 7); + + // Materials + normalOnly.Add(ItemID.Coral, 1, 5, 9); + normalOnly.Add(ItemID.Seashell, 1, 5, 9); + normalOnly.Add(ItemID.Starfish, 1, 5, 9); + normalOnly.Add(ModContent.ItemType(), 1, 7, 14); + + // Equipment + normalOnly.Add(ModContent.ItemType()); + normalOnly.Add(ModContent.ItemType()); + } + } #endregion public override void HitEffect(int hitDirection, double damage) diff --git a/NPCs/DesertScourge/DesertScourgeTail.cs b/NPCs/DesertScourge/DesertScourgeTail.cs index 0d3091d909..dc6ce11a34 100644 --- a/NPCs/DesertScourge/DesertScourgeTail.cs +++ b/NPCs/DesertScourge/DesertScourgeTail.cs @@ -162,11 +162,6 @@ namespace CalamityMod.NPCs.DesertScourge return false; } - public override bool PreNPCLoot() - { - return false; - } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * bossLifeScale); diff --git a/NPCs/DevourerofGods/DevourerofGodsBody.cs b/NPCs/DevourerofGods/DevourerofGodsBody.cs index 7355b224ff..733fdab84f 100644 --- a/NPCs/DevourerofGods/DevourerofGodsBody.cs +++ b/NPCs/DevourerofGods/DevourerofGodsBody.cs @@ -283,7 +283,7 @@ namespace CalamityMod.NPCs.DevourerofGods spriteBatch.EnterShaderRegion(); GameShaders.Misc["CalamityMod:DoGDisintegration"].UseOpacity(disintegrationFactor); GameShaders.Misc["CalamityMod:DoGDisintegration"].UseSaturation(NPC.whoAmI); - GameShaders.Misc["CalamityMod:DoGDisintegration"].UseImage("Images/Misc/Perlin"); + GameShaders.Misc["CalamityMod:DoGDisintegration"].UseImage0("Images/Misc/Perlin"); GameShaders.Misc["CalamityMod:DoGDisintegration"].Apply(); } @@ -380,11 +380,6 @@ namespace CalamityMod.NPCs.DevourerofGods return false; } - public override bool PreNPCLoot() - { - return false; - } - public override void HitEffect(int hitDirection, double damage) { if (NPC.life <= 0) diff --git a/NPCs/DevourerofGods/DevourerofGodsBody2.cs b/NPCs/DevourerofGods/DevourerofGodsBody2.cs index 1aad76a45a..b6c4608ce8 100644 --- a/NPCs/DevourerofGods/DevourerofGodsBody2.cs +++ b/NPCs/DevourerofGods/DevourerofGodsBody2.cs @@ -183,11 +183,6 @@ namespace CalamityMod.NPCs.DevourerofGods return false; } - public override bool PreNPCLoot() - { - return false; - } - public override void HitEffect(int hitDirection, double damage) { if (NPC.life <= 0) diff --git a/NPCs/DevourerofGods/DevourerofGodsHead.cs b/NPCs/DevourerofGods/DevourerofGodsHead.cs index e0a36f754c..a0a10f4fcd 100644 --- a/NPCs/DevourerofGods/DevourerofGodsHead.cs +++ b/NPCs/DevourerofGods/DevourerofGodsHead.cs @@ -33,6 +33,7 @@ using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; using Terraria.Audio; +using Terraria.GameContent.ItemDropRules; namespace CalamityMod.NPCs.DevourerofGods { @@ -163,7 +164,6 @@ namespace CalamityMod.NPCs.DevourerofGods NPC.DeathSound = SoundID.NPCDeath14; NPC.netAlways = true; Music = CalamityMod.Instance.GetMusicFromMusicMod("DevourerOfGodsP1") ?? MusicID.Boss3; - bossBag = ModContent.ItemType(); } public override void BossHeadSlot(ref int index) @@ -2046,7 +2046,7 @@ namespace CalamityMod.NPCs.DevourerofGods Main.npc[i].position = newPosition; if (Main.npc[i].type == ModContent.NPCType()) - ((DevourerofGodsTail)Main.npc[i].modNPC).setInvulTime(720); + ((DevourerofGodsTail)Main.npc[i].ModNPC).setInvulTime(720); Main.npc[i].netUpdate = true; } @@ -2186,7 +2186,7 @@ namespace CalamityMod.NPCs.DevourerofGods spriteBatch.EnterShaderRegion(); GameShaders.Misc["CalamityMod:DoGDisintegration"].UseOpacity(disintegrationFactor); GameShaders.Misc["CalamityMod:DoGDisintegration"].UseSaturation(NPC.whoAmI); - GameShaders.Misc["CalamityMod:DoGDisintegration"].UseImage("Images/Misc/Perlin"); + GameShaders.Misc["CalamityMod:DoGDisintegration"].UseImage0("Images/Misc/Perlin"); GameShaders.Misc["CalamityMod:DoGDisintegration"].Apply(); } @@ -2227,63 +2227,15 @@ namespace CalamityMod.NPCs.DevourerofGods potionType = ModContent.ItemType(); } - public override bool SpecialNPCLoot() - { - int closestSegmentID = DropHelper.FindClosestWormSegment(NPC, - ModContent.NPCType(), - ModContent.NPCType(), - ModContent.NPCType()); - NPC.position = Main.npc[closestSegmentID].position; - return false; - } - - public override void NPCLoot() + public override void OnKill() { // Stop the countdown -- if you kill DoG in less than 60 frames, this will stop another one from spawning. CalamityWorld.DoGSecondStageCountdown = 0; CalamityGlobalNPC.SetNewBossJustDowned(NPC); - DropHelper.DropBags(NPC); - - DropHelper.DropItem(NPC, ModContent.ItemType(), 5, 15); - DropHelper.DropItemChance(NPC, ModContent.ItemType(), 10); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), true, !DownedBossSystem.downedDoG); - CalamityGlobalNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, DownedBossSystem.downedDoG); - // Mount - CalamityPlayer mp = Main.player[Player.FindClosest(NPC.position, NPC.width, NPC.height)].Calamity(); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), true, mp.fabsolVodka); - - // All other drops are contained in the bag, so they only drop directly on Normal - if (!Main.expertMode) - { - // Materials - DropHelper.DropItem(NPC, ModContent.ItemType(), 25, 35); - DropHelper.DropItem(NPC, ModContent.ItemType(), 150, 250); - - // Weapons - float w = DropHelper.NormalWeaponDropRateFloat; - DropHelper.DropEntireWeightedSet(NPC, - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w) - ); - - // Equipment - DropHelper.DropItem(NPC, ModContent.ItemType(), true); - - // Vanity - DropHelper.DropItemChance(NPC, ModContent.ItemType(), 7); - } - - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), !Main.expertMode, 0.1f); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), !Main.expertMode, 0.1f); - // If DoG has not been killed yet, notify players that the holiday moons are buffed if (!DownedBossSystem.downedDoG) { @@ -2303,6 +2255,67 @@ namespace CalamityMod.NPCs.DevourerofGods CalamityNetcode.SyncWorld(); } + public override bool SpecialOnKill() + { + int closestSegmentID = DropHelper.FindClosestWormSegment(NPC, + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType()); + NPC.position = Main.npc[closestSegmentID].position; + return true; + } + + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + // Boss bag + npcLoot.Add(ItemDropRule.BossBag(ModContent.ItemType())); + + // Extraneous potions + npcLoot.Add(ModContent.ItemType(), 1, 5, 15); + + // Trophy (always directly from boss, never in bag) + npcLoot.Add(ModContent.ItemType(), 10); + + // Lore + npcLoot.AddIf(() => !DownedBossSystem.downedDoG, ModContent.ItemType()); + + // Fabsol Mount + npcLoot.AddIf(() => + { + CalamityPlayer mp = Main.player[Player.FindClosest(NPC.position, NPC.width, NPC.height)].Calamity(); + return mp.vodka; + }, ModContent.ItemType()); + + // Normal drops: Everything that would otherwise be in the bag + var normalOnly = npcLoot.DefineNormalOnlyDropSet(); + { + // Weapons + int[] weapons = new int[] + { + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType() + }; + normalOnly.Add(ItemDropRule.OneFromOptions(DropHelper.NormalWeaponDropRateInt, weapons)); + + // Vanity + normalOnly.Add(ModContent.ItemType(), 7); + + // Materials + normalOnly.Add(ModContent.ItemType(), 1, 25, 35); + normalOnly.Add(ModContent.ItemType(), 1, 150, 250); + + // Equipment + normalOnly.Add(ModContent.ItemType()); + } + + npcLoot.AddIf(() => !Main.expertMode, ModContent.ItemType(), 10); + npcLoot.AddIf(() => !Main.expertMode, ModContent.ItemType(), 10); + } + // Can only hit the target if within certain distance public override bool CanHitPlayer(Player target, ref int cooldownSlot) { diff --git a/NPCs/DevourerofGods/DevourerofGodsHead2.cs b/NPCs/DevourerofGods/DevourerofGodsHead2.cs index fd7f4e0959..74265e97b6 100644 --- a/NPCs/DevourerofGods/DevourerofGodsHead2.cs +++ b/NPCs/DevourerofGods/DevourerofGodsHead2.cs @@ -328,13 +328,13 @@ namespace CalamityMod.NPCs.DevourerofGods return false; } - public override void NPCLoot() + public override void OnKill() { if (!CalamityWorld.revenge) { int heartAmt = Main.rand.Next(3) + 3; for (int i = 0; i < heartAmt; i++) - Item.NewItem((int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height, ItemID.Heart); + Item.NewItem(NPC.GetItemSource_Loot(), (int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height, ItemID.Heart); } } diff --git a/NPCs/DevourerofGods/DevourerofGodsTail.cs b/NPCs/DevourerofGods/DevourerofGodsTail.cs index 8d1a7e4d39..a7edf61f5f 100644 --- a/NPCs/DevourerofGods/DevourerofGodsTail.cs +++ b/NPCs/DevourerofGods/DevourerofGodsTail.cs @@ -303,7 +303,7 @@ namespace CalamityMod.NPCs.DevourerofGods spriteBatch.EnterShaderRegion(); GameShaders.Misc["CalamityMod:DoGDisintegration"].UseOpacity(disintegrationFactor); GameShaders.Misc["CalamityMod:DoGDisintegration"].UseSaturation(NPC.whoAmI); - GameShaders.Misc["CalamityMod:DoGDisintegration"].UseImage("Images/Misc/Perlin"); + GameShaders.Misc["CalamityMod:DoGDisintegration"].UseImage0("Images/Misc/Perlin"); GameShaders.Misc["CalamityMod:DoGDisintegration"].Apply(); } @@ -437,11 +437,6 @@ namespace CalamityMod.NPCs.DevourerofGods return false; } - public override bool PreNPCLoot() - { - return false; - } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * bossLifeScale); diff --git a/NPCs/DevourerofGods/DevourerofGodsTail2.cs b/NPCs/DevourerofGods/DevourerofGodsTail2.cs index 3f574939cb..7b8025cd99 100644 --- a/NPCs/DevourerofGods/DevourerofGodsTail2.cs +++ b/NPCs/DevourerofGods/DevourerofGodsTail2.cs @@ -219,11 +219,6 @@ namespace CalamityMod.NPCs.DevourerofGods return false; } - public override bool PreNPCLoot() - { - return false; - } - public override void OnHitPlayer(Player player, int damage, bool crit) { player.AddBuff(ModContent.BuffType(), 90, true); diff --git a/NPCs/DraedonLabThings/RepairUnitCritter.cs b/NPCs/DraedonLabThings/RepairUnitCritter.cs index 1b65f67ee8..4402fef93d 100644 --- a/NPCs/DraedonLabThings/RepairUnitCritter.cs +++ b/NPCs/DraedonLabThings/RepairUnitCritter.cs @@ -305,9 +305,9 @@ namespace CalamityMod.NPCs.DraedonLabThings } } - public override void NPCLoot() + public override void ModifyNPCLoot(NPCLoot npcLoot) { - DropHelper.DropItemChance(NPC, ModContent.ItemType(), 2, 2, 4); + npcLoot.Add(ModContent.ItemType(), 2, 2, 4); } public override void FindFrame(int frameHeight) diff --git a/NPCs/ExoMechs/Draedon.cs b/NPCs/ExoMechs/Draedon.cs index 37943925ed..4fa4f19b7e 100644 --- a/NPCs/ExoMechs/Draedon.cs +++ b/NPCs/ExoMechs/Draedon.cs @@ -23,7 +23,7 @@ namespace CalamityMod.NPCs.ExoMechs public bool ShouldStartStandingUp; public Vector2 HoverDestinationOffset { - get => new Vector2(NPC.ai[1], NPC.ai[2]); + get => new(NPC.ai[1], NPC.ai[2]); set { NPC.ai[1] = value.X; @@ -57,8 +57,8 @@ namespace CalamityMod.NPCs.ExoMechs return false; } } - public static readonly Color TextColor = new Color(155, 255, 255); - public static readonly Color TextColorEdgy = new Color(213, 4, 11); + public static readonly Color TextColor = new(155, 255, 255); + public static readonly Color TextColorEdgy = new(213, 4, 11); public const int HologramFadeinTime = 45; public const int TalkDelay = 150; public const int DelayPerDialogLine = 130; diff --git a/NPCs/GreatSandShark/GreatSandShark.cs b/NPCs/GreatSandShark/GreatSandShark.cs index 2e4a2d1eee..71f425b41d 100644 --- a/NPCs/GreatSandShark/GreatSandShark.cs +++ b/NPCs/GreatSandShark/GreatSandShark.cs @@ -597,12 +597,15 @@ namespace CalamityMod.NPCs.GreatSandShark } } - public override void NPCLoot() + public override void ModifyNPCLoot(NPCLoot npcLoot) { - DropHelper.DropItem(NPC, ItemID.AncientBattleArmorMaterial, 1, 1); - DropHelper.DropItem(NPC, ModContent.ItemType(), 1, 1); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), Main.expertMode, 3, 1, 1); + npcLoot.Add(ItemID.AncientBattleArmorMaterial); + npcLoot.Add(ModContent.ItemType()); + npcLoot.AddIf(() => Main.expertMode, ModContent.ItemType(), 3); + } + public override void OnKill() + { // Mark Great Sand Shark as dead DownedBossSystem.downedGSS = true; CalamityNetcode.SyncWorld(); diff --git a/NPCs/HiveMind/DankCreeper.cs b/NPCs/HiveMind/DankCreeper.cs index 0d70d6ef80..f60fd29d80 100644 --- a/NPCs/HiveMind/DankCreeper.cs +++ b/NPCs/HiveMind/DankCreeper.cs @@ -112,13 +112,13 @@ namespace CalamityMod.NPCs.HiveMind } } - public override bool PreNPCLoot() + public override void OnKill() { if (!CalamityWorld.revenge) { int closestPlayer = Player.FindClosest(NPC.Center, 1, 1); if (Main.rand.Next(4) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) - Item.NewItem((int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height, ItemID.Heart); + Item.NewItem(NPC.GetItemSource_Loot(), (int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height, ItemID.Heart); } if ((Main.expertMode || BossRushEvent.BossRushActive) && Main.netMode != NetmodeID.MultiplayerClient) @@ -127,8 +127,6 @@ namespace CalamityMod.NPCs.HiveMind int damage = NPC.GetProjectileDamage(type); Projectile.NewProjectile(NPC.GetSpawnSource_ForProjectile(), NPC.Center, Vector2.Zero, type, damage, 0f, Main.myPlayer); } - - return false; } } } diff --git a/NPCs/HiveMind/DarkHeart.cs b/NPCs/HiveMind/DarkHeart.cs index e2ad90e3f1..12bf6df56a 100644 --- a/NPCs/HiveMind/DarkHeart.cs +++ b/NPCs/HiveMind/DarkHeart.cs @@ -123,13 +123,13 @@ namespace CalamityMod.NPCs.HiveMind } } - public override void NPCLoot() + public override void OnKill() { if (!CalamityWorld.revenge) { int closestPlayer = Player.FindClosest(NPC.Center, 1, 1); if (Main.rand.Next(4) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) - Item.NewItem((int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height, ItemID.Heart); + Item.NewItem(NPC.GetItemSource_Loot(), (int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height, ItemID.Heart); } } diff --git a/NPCs/HiveMind/HiveBlob.cs b/NPCs/HiveMind/HiveBlob.cs index 0200ec1a44..be9339c5eb 100644 --- a/NPCs/HiveMind/HiveBlob.cs +++ b/NPCs/HiveMind/HiveBlob.cs @@ -153,13 +153,13 @@ namespace CalamityMod.NPCs.HiveMind } } - public override void NPCLoot() + public override void OnKill() { if (!CalamityWorld.revenge) { int closestPlayer = Player.FindClosest(NPC.Center, 1, 1); - if (Main.rand.Next(8) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) - Item.NewItem((int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height, ItemID.Heart); + if (Main.rand.Next(4) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) + Item.NewItem(NPC.GetItemSource_Loot(), (int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height, ItemID.Heart); } } diff --git a/NPCs/HiveMind/HiveBlob2.cs b/NPCs/HiveMind/HiveBlob2.cs index c7aa3545e7..34611b650a 100644 --- a/NPCs/HiveMind/HiveBlob2.cs +++ b/NPCs/HiveMind/HiveBlob2.cs @@ -153,13 +153,13 @@ namespace CalamityMod.NPCs.HiveMind } } - public override void NPCLoot() + public override void OnKill() { if (!CalamityWorld.revenge) { int closestPlayer = Player.FindClosest(NPC.Center, 1, 1); - if (Main.rand.Next(8) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) - Item.NewItem((int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height, ItemID.Heart); + if (Main.rand.Next(4) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) + Item.NewItem(NPC.GetItemSource_Loot(), (int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height, ItemID.Heart); } } diff --git a/NPCs/HiveMind/HiveCyst.cs b/NPCs/HiveMind/HiveCyst.cs index 5256d31ab1..3b78b62bf3 100644 --- a/NPCs/HiveMind/HiveCyst.cs +++ b/NPCs/HiveMind/HiveCyst.cs @@ -1,4 +1,4 @@ -using CalamityMod.World; +using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -49,7 +49,7 @@ namespace CalamityMod.NPCs.HiveMind return 0f; bool anyBossElements = NPC.AnyNPCs(ModContent.NPCType()) || NPC.AnyNPCs(ModContent.NPCType()); - bool corrupt = TileID.Sets.Corrupt[spawnInfo.spawnTileType] || spawnInfo.spawnTileType == TileID.Demonite && spawnInfo.Player.ZoneCorrupt; + bool corrupt = TileID.Sets.Corrupt[spawnInfo.SpawnTileType] || spawnInfo.SpawnTileType == TileID.Demonite && spawnInfo.Player.ZoneCorrupt; if (anyBossElements || spawnInfo.PlayerSafe || !corrupt) return 0f; @@ -79,8 +79,8 @@ namespace CalamityMod.NPCs.HiveMind } if (Main.netMode != NetmodeID.MultiplayerClient && NPC.CountNPCS(ModContent.NPCType()) < 1) { - Vector2 spawnAt = NPC.Center + new Vector2(0f, (float)NPC.height / 2f); - NPC.NewNPC((int)spawnAt.X, (int)spawnAt.Y, ModContent.NPCType()); + Vector2 spawnAt = NPC.Bottom; + NPC.NewNPC(NPC.GetSpawnSource_NPCHurt(), (int)spawnAt.X, (int)spawnAt.Y, ModContent.NPCType()); } } } diff --git a/NPCs/Leviathan/AquaticAberration.cs b/NPCs/Leviathan/AquaticAberration.cs index f3c9bb6563..abad737887 100644 --- a/NPCs/Leviathan/AquaticAberration.cs +++ b/NPCs/Leviathan/AquaticAberration.cs @@ -228,7 +228,7 @@ namespace CalamityMod.NPCs.Leviathan } } - public override bool PreNPCLoot() + public override void OnKill() { if (!CalamityWorld.revenge) { @@ -236,8 +236,6 @@ namespace CalamityMod.NPCs.Leviathan if (Main.rand.Next(4) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) Item.NewItem((int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height, ItemID.Heart); } - - return false; } public override float SpawnChance(NPCSpawnInfo spawnInfo) diff --git a/NPCs/Leviathan/Leviathan.cs b/NPCs/Leviathan/Leviathan.cs index f99b8e226c..b569d00f7f 100644 --- a/NPCs/Leviathan/Leviathan.cs +++ b/NPCs/Leviathan/Leviathan.cs @@ -22,6 +22,7 @@ using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; +using Terraria.GameContent.ItemDropRules; namespace CalamityMod.NPCs.Leviathan { @@ -702,65 +703,70 @@ namespace CalamityMod.NPCs.Leviathan potionType = ItemID.GreaterHealingPotion; } - // The Leviathan runs the same loot code as Anahita, but only if she dies last. - public override void NPCLoot() + public override void OnKill() { - //Trophy dropped regardless of Anahita, precedent of Twins - DropHelper.DropItemChance(NPC, ModContent.ItemType(), 10); - - if (!NPC.AnyNPCs(ModContent.NPCType())) - DropSirenLeviLoot(NPC); - } - - // This loot code is shared with Anahita. - public static void DropSirenLeviLoot(NPC npc) - { - CalamityGlobalNPC.SetNewBossJustDowned(npc); - - DropHelper.DropBags(npc); - - DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !DownedBossSystem.downedLeviathan); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !DownedBossSystem.downedLeviathan); - - // All other drops are contained in the bag, so they only drop directly on Normal - if (!Main.expertMode) - { - // Weapons - float w = DropHelper.NormalWeaponDropRateFloat; - DropHelper.DropEntireWeightedSet(npc, - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w) - ); - - // Equipment - DropHelper.DropItem(npc, ModContent.ItemType(), true); - - // Vanity - DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); - DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); - - // Fishing - DropHelper.DropItemChance(npc, ItemID.HotlineFishingHook, 10); - DropHelper.DropItemChance(npc, ItemID.BottomlessBucket, 10); - DropHelper.DropItemChance(npc, ItemID.SuperAbsorbantSponge, 10); - DropHelper.DropItemChance(npc, ItemID.FishingPotion, 5, 5, 8); - DropHelper.DropItemChance(npc, ItemID.SonarPotion, 5, 5, 8); - DropHelper.DropItemChance(npc, ItemID.CratePotion, 5, 5, 8); - } - - DropHelper.DropItemCondition(npc, ModContent.ItemType(), !Main.expertMode, 0.1f); + CalamityGlobalNPC.SetNewBossJustDowned(NPC); // Mark Siren & Levi as dead DownedBossSystem.downedLeviathan = true; CalamityNetcode.SyncWorld(); } + public static bool ReadyToDropLoot(NPC npc) + { + if (npc.type == ModContent.NPCType() && !NPC.AnyNPCs(ModContent.NPCType())) + return true; + if (npc.type == ModContent.NPCType() && !NPC.AnyNPCs(ModContent.NPCType())) + return true; + 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) + { + npcLoot.Add(ItemDropRule.BossBagByCondition(DropHelper.If(() => ReadyToDropLoot(NPC)), ModContent.ItemType())); + + // Trophy (always directly from boss, never in bag) + npcLoot.Add(ModContent.ItemType(), 10); + + // Lore + npcLoot.AddIf(() => !DownedBossSystem.downedLeviathan && ReadyToDropLoot(NPC), ModContent.ItemType()); + npcLoot.AddIf(() => !DownedBossSystem.downedLeviathan && ReadyToDropLoot(NPC), ModContent.ItemType()); + + // Weapons. + var normalOnly = npcLoot.DefineConditionalDropSet(DropHelper.If(() => Main.expertMode && 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 && ReadyToDropLoot(NPC), ModContent.ItemType(), 10); + } + public override void OnHitPlayer(Player target, int damage, bool crit) { target.AddBuff(BuffID.Bleeding, 240, true); diff --git a/NPCs/Leviathan/LeviathanStart.cs b/NPCs/Leviathan/LeviathanStart.cs index b2be2b5282..f35f453d70 100644 --- a/NPCs/Leviathan/LeviathanStart.cs +++ b/NPCs/Leviathan/LeviathanStart.cs @@ -132,10 +132,10 @@ namespace CalamityMod.NPCs.Leviathan return SpawnCondition.OceanMonster.Chance * 0.4f; } - - public override void NPCLoot() + + public override void ModifyNPCLoot(NPCLoot npcLoot) { - DropHelper.DropItemChance(NPC, ModContent.ItemType(), 0.25f); + npcLoot.Add(ModContent.ItemType(), 4); } public override void HitEffect(int hitDirection, double damage) @@ -149,7 +149,7 @@ namespace CalamityMod.NPCs.Leviathan } else if (Main.netMode != NetmodeID.MultiplayerClient) { - int siren = NPC.NewNPC((int)NPC.Center.X, (int)NPC.position.Y + NPC.height, ModContent.NPCType(), NPC.whoAmI); + int siren = NPC.NewNPC(NPC.GetSpawnSource_NPCHurt(), (int)NPC.Center.X, (int)NPC.position.Y + NPC.height, ModContent.NPCType(), NPC.whoAmI); CalamityUtils.BossAwakenMessage(siren); } } diff --git a/NPCs/Leviathan/Siren.cs b/NPCs/Leviathan/Siren.cs index 8bed6ebde2..33aab567af 100644 --- a/NPCs/Leviathan/Siren.cs +++ b/NPCs/Leviathan/Siren.cs @@ -12,6 +12,15 @@ using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; +using Terraria.GameContent.ItemDropRules; +using CalamityMod.Items.Accessories; +using CalamityMod.Items.Armor.Vanity; +using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Items.Weapons.Summon; +using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Items.LoreItems; namespace CalamityMod.NPCs.Leviathan { @@ -62,8 +71,7 @@ namespace CalamityMod.NPCs.Leviathan NPC.noTileCollide = true; NPC.HitSound = SoundID.NPCHit1; NPC.DeathSound = SoundID.NPCDeath1; - music = CalamityMod.Instance.GetMusicFromMusicMod("Anahita") ?? MusicID.Boss3; - bossBag = ModContent.ItemType(); + Music = CalamityMod.Instance.GetMusicFromMusicMod("Anahita") ?? MusicID.Boss3; NPC.Calamity().VulnerableToHeat = false; NPC.Calamity().VulnerableToSickness = true; NPC.Calamity().VulnerableToElectricity = true; @@ -215,7 +223,7 @@ namespace CalamityMod.NPCs.Leviathan // Change music. if (leviAlive) - music = CalamityMod.Instance.GetMusicFromMusicMod("LeviathanAndAnahita") ?? MusicID.Boss3; + Music = CalamityMod.Instance.GetMusicFromMusicMod("LeviathanAndAnahita") ?? MusicID.Boss3; // Ice Shield if (NPC.localAI[2] < 3f) @@ -599,7 +607,7 @@ namespace CalamityMod.NPCs.Leviathan totalProjectiles = 6; type = ModContent.ProjectileType(); float soundPitch = (Main.rand.NextFloat() - 0.5f) * 0.5f; - Main.harpNote = soundPitch; + Main.musicPitch = soundPitch; SoundEngine.PlaySound(SoundID.Item26, player.position); break; } @@ -818,13 +826,48 @@ namespace CalamityMod.NPCs.Leviathan } // Anahita runs the same loot code as the Leviathan, but only if she dies last. - public override void NPCLoot() + public override void ModifyNPCLoot(NPCLoot npcLoot) { - //Trophy dropped regardless of Levi, precedent of Twins - DropHelper.DropItemChance(NPC, ModContent.ItemType(), 10); + npcLoot.Add(ItemDropRule.BossBagByCondition(DropHelper.If(() => Leviathan.ReadyToDropLoot(NPC)), ModContent.ItemType())); - if (!NPC.AnyNPCs(ModContent.NPCType())) - Leviathan.DropSirenLeviLoot(NPC); + // 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() diff --git a/NPCs/Leviathan/SirenIce.cs b/NPCs/Leviathan/SirenIce.cs index dd170998ee..c5a4e7ab6d 100644 --- a/NPCs/Leviathan/SirenIce.cs +++ b/NPCs/Leviathan/SirenIce.cs @@ -1,4 +1,4 @@ -using CalamityMod.Events; +using CalamityMod.Events; using Microsoft.Xna.Framework; using System.IO; using Terraria; @@ -115,8 +115,6 @@ namespace CalamityMod.NPCs.Leviathan player.AddBuff(BuffID.Frostburn, 240, true); } - public override bool PreNPCLoot() => false; - public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 5; k++)