From cc52e63fbbd35d2ccf3bc5f78c6f60ff7be60b3d Mon Sep 17 00:00:00 2001 From: Dominic Date: Thu, 7 Apr 2022 23:53:19 -0500 Subject: [PATCH] Handful of missed cases --- NPCs/Astral/FusionFeeder.cs | 6 +- NPCs/Crabulon/CrabShroom.cs | 6 +- NPCs/HiveMind/HiveMind.cs | 111 ++++++++++++------------ NPCs/NormalNPCs/Sunskater.cs | 5 -- NPCs/Perforator/PerforatorTailLarge.cs | 5 -- NPCs/Perforator/PerforatorTailMedium.cs | 6 +- NPCs/Perforator/PerforatorTailSmall.cs | 5 -- NPCs/Signus/CosmicLantern.cs | 2 - NPCs/Signus/SignusBomb.cs | 2 - NPCs/SlimeGod/SlimeSpawnCorrupt.cs | 8 +- NPCs/SlimeGod/SlimeSpawnCorrupt2.cs | 15 ++-- NPCs/SlimeGod/SlimeSpawnCrimson.cs | 15 ++-- NPCs/SlimeGod/SlimeSpawnCrimson2.cs | 13 +-- 13 files changed, 87 insertions(+), 112 deletions(-) diff --git a/NPCs/Astral/FusionFeeder.cs b/NPCs/Astral/FusionFeeder.cs index 3eb6e23ad6..835f0ef311 100644 --- a/NPCs/Astral/FusionFeeder.cs +++ b/NPCs/Astral/FusionFeeder.cs @@ -132,10 +132,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, 3, 4); } } } diff --git a/NPCs/Crabulon/CrabShroom.cs b/NPCs/Crabulon/CrabShroom.cs index 148e68fee5..b99d2baa4f 100644 --- a/NPCs/Crabulon/CrabShroom.cs +++ b/NPCs/Crabulon/CrabShroom.cs @@ -106,16 +106,14 @@ namespace CalamityMod.NPCs.Crabulon return false; } - public override bool PreNPCLoot() + 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); + Item.NewItem(NPC.GetItemSource_Loot(), (int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height, ItemID.Heart); } - - return false; } public override void HitEffect(int hitDirection, double damage) diff --git a/NPCs/HiveMind/HiveMind.cs b/NPCs/HiveMind/HiveMind.cs index 27a82c1270..9b0b80d540 100644 --- a/NPCs/HiveMind/HiveMind.cs +++ b/NPCs/HiveMind/HiveMind.cs @@ -21,15 +21,16 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; +using Terraria.GameContent.ItemDropRules; /* states: - * 0 = slow drift - * 1 = reelback and teleport after spawn enemy - * 2 = reelback for spin lunge + death legacy - * 3 = spin lunge - * 4 = semicircle spawn arc - * 5 = raindash - * 6 = deceleration - */ +* 0 = slow drift +* 1 = reelback and teleport after spawn enemy +* 2 = reelback for spin lunge + death legacy +* 3 = spin lunge +* 4 = semicircle spawn arc +* 5 = raindash +* 6 = deceleration +*/ namespace CalamityMod.NPCs.HiveMind { @@ -107,7 +108,6 @@ namespace CalamityMod.NPCs.HiveMind NPC.HitSound = SoundID.NPCHit1; NPC.DeathSound = SoundID.NPCDeath1; Music = CalamityMod.Instance.GetMusicFromMusicMod("HiveMind") ?? MusicID.Boss2; - bossBag = ModContent.ItemType(); if (Main.expertMode) { @@ -549,15 +549,10 @@ namespace CalamityMod.NPCs.HiveMind int tilePosX = (int)NPC.Center.X / 16; int tilePosY = (int)(NPC.position.Y + NPC.height) / 16 + 1; - if (Main.tile[tilePosX, tilePosY] == null) - Main.tile[tilePosX, tilePosY] = new Tile(); - while (!(Main.tile[tilePosX, tilePosY].HasUnactuatedTile && Main.tileSolid[Main.tile[tilePosX, tilePosY].TileType])) { tilePosY++; NPC.position.Y += 16; - if (Main.tile[tilePosX, tilePosY] == null) - Main.tile[tilePosX, tilePosY] = new Tile(); } } NPC.netUpdate = true; @@ -1010,7 +1005,7 @@ namespace CalamityMod.NPCs.HiveMind if (Main.netMode != NetmodeID.MultiplayerClient && Main.rand.NextBool(15) && NPC.CountNPCS(ModContent.NPCType()) < 2) { Vector2 spawnAt = NPC.Center + new Vector2(0f, NPC.height / 2f); - NPC.NewNPC((int)spawnAt.X, (int)spawnAt.Y, ModContent.NPCType()); + NPC.NewNPC(NPC.GetSpawnSource_NPCHurt(), (int)spawnAt.X, (int)spawnAt.Y, ModContent.NPCType()); } } else @@ -1020,13 +1015,13 @@ namespace CalamityMod.NPCs.HiveMind if (Main.rand.NextBool(60) && Main.netMode != NetmodeID.MultiplayerClient) { Vector2 spawnAt = NPC.Center + new Vector2(0f, NPC.height / 2f); - NPC.NewNPC((int)spawnAt.X, (int)spawnAt.Y, NPCID.EaterofSouls); + NPC.NewNPC(NPC.GetSpawnSource_NPCHurt(), (int)spawnAt.X, (int)spawnAt.Y, NPCID.EaterofSouls); } if (Main.rand.NextBool(150) && Main.netMode != NetmodeID.MultiplayerClient) { Vector2 spawnAt = NPC.Center + new Vector2(0f, NPC.height / 2f); - NPC.NewNPC((int)spawnAt.X, (int)spawnAt.Y, NPCID.DevourerHead); + NPC.NewNPC(NPC.GetSpawnSource_NPCHurt(), (int)spawnAt.X, (int)spawnAt.Y, NPCID.DevourerHead); } } } @@ -1072,49 +1067,10 @@ namespace CalamityMod.NPCs.HiveMind potionType = ItemID.HealingPotion; } - public override void NPCLoot() + public override void OnKill() { CalamityGlobalNPC.SetNewBossJustDowned(NPC); - DropHelper.DropBags(NPC); - - DropHelper.DropItemChance(NPC, ModContent.ItemType(), 10); - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), true, !DownedBossSystem.downedHiveMind); - - CalamityGlobalNPC.SetNewShopVariable(new int[] { NPCID.Dryad }, DownedBossSystem.downedHiveMind); - - // All other drops are contained in the bag, so they only drop directly on Normal - if (!Main.expertMode) - { - // Materials - DropHelper.DropItemSpray(NPC, ModContent.ItemType(), 25, 30, 5); - DropHelper.DropItemSpray(NPC, ItemID.DemoniteBar, 8, 12, 2); - DropHelper.DropItemSpray(NPC, ItemID.RottenChunk, 9, 15, 3); - if (Main.hardMode) - DropHelper.DropItemSpray(NPC, ItemID.CursedFlame, 10, 20, 2); - DropHelper.DropItem(NPC, ItemID.CorruptSeeds, 10, 15); - - // 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, 30, 50), - DropHelper.WeightStack(w) - ); - - // Equipment - DropHelper.DropItem(NPC, ModContent.ItemType(), true); - - // Vanity - DropHelper.DropItemChance(NPC, ModContent.ItemType(), 7); - DropHelper.DropItemChance(NPC, ModContent.ItemType(), 10); - } - // If neither The Hive Mind nor The Perforator Hive have been killed yet, notify players of Aerialite Ore if (!DownedBossSystem.downedHiveMind && !DownedBossSystem.downedPerforator) { @@ -1129,5 +1085,46 @@ namespace CalamityMod.NPCs.HiveMind DownedBossSystem.downedHiveMind = true; CalamityNetcode.SyncWorld(); } + + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + npcLoot.Add(ItemDropRule.BossBag(ModContent.ItemType())); + + npcLoot.Add(ModContent.ItemType(), 10); + npcLoot.AddIf(() => !DownedBossSystem.downedHiveMind, 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(), + ModContent.ItemType(), + }; + normalOnly.Add(ItemDropRule.OneFromOptions(DropHelper.NormalWeaponDropRateInt, weapons)); + normalOnly.Add(ModContent.ItemType(), 1, 30, 50); + + // Materials + normalOnly.Add(ItemID.DemoniteBar, 1, 12, 15); + normalOnly.Add(ItemID.RottenChunk, 1, 12, 15); + normalOnly.Add(ItemID.CorruptSeeds, 1, 12, 15); + normalOnly.Add(ModContent.ItemType(), 1, 25, 30); + normalOnly.Add(ItemDropRule.ByCondition(new Conditions.IsHardmode(), ItemID.CursedFlame, 1, 10, 20)); + + // Equipment + normalOnly.Add(ModContent.ItemType()); + + // Vanity + normalOnly.Add(ModContent.ItemType(), 7); + normalOnly.Add(ModContent.ItemType(), 10); + } + } } } diff --git a/NPCs/NormalNPCs/Sunskater.cs b/NPCs/NormalNPCs/Sunskater.cs index de8fb094b2..e4ff9841f4 100644 --- a/NPCs/NormalNPCs/Sunskater.cs +++ b/NPCs/NormalNPCs/Sunskater.cs @@ -211,11 +211,6 @@ namespace CalamityMod.NPCs.NormalNPCs player.AddBuff(ModContent.BuffType(), 120, true); } - public override void NPCLoot() - { - DropHelper.DropItemCondition(NPC, ModContent.ItemType(), Main.hardMode, 3, 1, 1); - } - public override void ModifyNPCLoot(NPCLoot npcLoot) { npcLoot.AddIf(() => Main.hardMode, ModContent.ItemType(), 3); diff --git a/NPCs/Perforator/PerforatorTailLarge.cs b/NPCs/Perforator/PerforatorTailLarge.cs index 5af34d8350..03e0af204f 100644 --- a/NPCs/Perforator/PerforatorTailLarge.cs +++ b/NPCs/Perforator/PerforatorTailLarge.cs @@ -185,11 +185,6 @@ namespace CalamityMod.NPCs.Perforator 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/Perforator/PerforatorTailMedium.cs b/NPCs/Perforator/PerforatorTailMedium.cs index a3c07f6248..975ddb794b 100644 --- a/NPCs/Perforator/PerforatorTailMedium.cs +++ b/NPCs/Perforator/PerforatorTailMedium.cs @@ -183,16 +183,14 @@ namespace CalamityMod.NPCs.Perforator return false; } - 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 OnHitPlayer(Player player, int damage, bool crit) diff --git a/NPCs/Perforator/PerforatorTailSmall.cs b/NPCs/Perforator/PerforatorTailSmall.cs index 0effc6bae0..4542d08557 100644 --- a/NPCs/Perforator/PerforatorTailSmall.cs +++ b/NPCs/Perforator/PerforatorTailSmall.cs @@ -184,11 +184,6 @@ namespace CalamityMod.NPCs.Perforator return false; } - public override bool PreNPCLoot() - { - return false; - } - public override void OnHitPlayer(Player player, int damage, bool crit) { player.AddBuff(ModContent.BuffType(), 60, true); diff --git a/NPCs/Signus/CosmicLantern.cs b/NPCs/Signus/CosmicLantern.cs index c3079248f8..45f3d5cd7a 100644 --- a/NPCs/Signus/CosmicLantern.cs +++ b/NPCs/Signus/CosmicLantern.cs @@ -139,8 +139,6 @@ namespace CalamityMod.NPCs.Signus return false; } - public override bool PreNPCLoot() => false; - public override bool CanHitPlayer(Player target, ref int cooldownSlot) { cooldownSlot = 1; diff --git a/NPCs/Signus/SignusBomb.cs b/NPCs/Signus/SignusBomb.cs index c284ca8fc4..b8a8908c0e 100644 --- a/NPCs/Signus/SignusBomb.cs +++ b/NPCs/Signus/SignusBomb.cs @@ -199,8 +199,6 @@ namespace CalamityMod.NPCs.Signus return false; } - 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/SlimeGod/SlimeSpawnCorrupt.cs b/NPCs/SlimeGod/SlimeSpawnCorrupt.cs index 9ed456e874..3939122bfa 100644 --- a/NPCs/SlimeGod/SlimeSpawnCorrupt.cs +++ b/NPCs/SlimeGod/SlimeSpawnCorrupt.cs @@ -1,4 +1,4 @@ -using CalamityMod.Events; +using CalamityMod.Events; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -27,7 +27,7 @@ namespace CalamityMod.NPCs.SlimeGod NPC.lifeMax = 10000; } NPC.knockBackResist = 0f; - animationType = 121; + AnimationType = 121; NPC.alpha = 55; NPC.lavaImmune = false; NPC.noGravity = false; @@ -39,14 +39,12 @@ namespace CalamityMod.NPCs.SlimeGod NPC.Calamity().VulnerableToSickness = false; } - public override bool PreNPCLoot() => false; - public override void HitEffect(int hitDirection, double damage) { if (Main.netMode != NetmodeID.MultiplayerClient && NPC.life <= 0) { Vector2 spawnAt = NPC.Center + new Vector2(0f, (float)NPC.height / 2f); - NPC.NewNPC((int)spawnAt.X, (int)spawnAt.Y, ModContent.NPCType()); + NPC.NewNPC(NPC.GetItemSource_Loot(), (int)spawnAt.X, (int)spawnAt.Y, ModContent.NPCType()); } for (int k = 0; k < 5; k++) { diff --git a/NPCs/SlimeGod/SlimeSpawnCorrupt2.cs b/NPCs/SlimeGod/SlimeSpawnCorrupt2.cs index 95370915d1..f79005e90a 100644 --- a/NPCs/SlimeGod/SlimeSpawnCorrupt2.cs +++ b/NPCs/SlimeGod/SlimeSpawnCorrupt2.cs @@ -1,4 +1,4 @@ -using CalamityMod.Events; +using CalamityMod.Events; using CalamityMod.World; using Terraria; using Terraria.ID; @@ -27,7 +27,7 @@ namespace CalamityMod.NPCs.SlimeGod NPC.lifeMax = 5000; } NPC.knockBackResist = 0f; - animationType = NPCID.CorruptSlime; + AnimationType = NPCID.CorruptSlime; NPC.alpha = 55; NPC.lavaImmune = false; NPC.noGravity = false; @@ -54,18 +54,19 @@ namespace CalamityMod.NPCs.SlimeGod } } - public override bool PreNPCLoot() + 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); + Item.NewItem(NPC.GetItemSource_Loot(), (int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height, ItemID.Heart); } + } - DropHelper.DropItemChance(NPC, ItemID.Vitamins, Main.expertMode ? 50 : 100); - - return false; + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + npcLoot.Add(ItemID.Vitamins, 50); } public override void OnHitPlayer(Player player, int damage, bool crit) diff --git a/NPCs/SlimeGod/SlimeSpawnCrimson.cs b/NPCs/SlimeGod/SlimeSpawnCrimson.cs index 64f3be968d..6cd68b4a16 100644 --- a/NPCs/SlimeGod/SlimeSpawnCrimson.cs +++ b/NPCs/SlimeGod/SlimeSpawnCrimson.cs @@ -1,4 +1,4 @@ -using CalamityMod.Events; +using CalamityMod.Events; using CalamityMod.World; using Terraria; using Terraria.ID; @@ -27,7 +27,7 @@ namespace CalamityMod.NPCs.SlimeGod NPC.lifeMax = 10000; } NPC.knockBackResist = 0f; - animationType = NPCID.CorruptSlime; + AnimationType = NPCID.CorruptSlime; NPC.alpha = 55; NPC.lavaImmune = false; NPC.noGravity = false; @@ -54,18 +54,19 @@ namespace CalamityMod.NPCs.SlimeGod } } - public override bool PreNPCLoot() + 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); + Item.NewItem(NPC.GetItemSource_Loot(), (int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height, ItemID.Heart); } + } - DropHelper.DropItemChance(NPC, ItemID.Blindfold, Main.expertMode ? 50 : 100); - - return false; + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + npcLoot.Add(ItemID.Blindfold, 50); } public override void OnHitPlayer(Player player, int damage, bool crit) diff --git a/NPCs/SlimeGod/SlimeSpawnCrimson2.cs b/NPCs/SlimeGod/SlimeSpawnCrimson2.cs index c8ea426fb9..e09fea2dcc 100644 --- a/NPCs/SlimeGod/SlimeSpawnCrimson2.cs +++ b/NPCs/SlimeGod/SlimeSpawnCrimson2.cs @@ -49,7 +49,7 @@ namespace CalamityMod.NPCs.SlimeGod int frameY = 1; if (!Main.dedServ) { - if (!Main.NPCLoaded[NPC.type] || TextureAssets.Npc[NPC.type].Value is null) + if (TextureAssets.Npc[NPC.type].Value is null) return; frameY = TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type]; } @@ -143,18 +143,19 @@ namespace CalamityMod.NPCs.SlimeGod } } - public override bool PreNPCLoot() + 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); + Item.NewItem(NPC.GetItemSource_Loot(), (int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height, ItemID.Heart); } + } - DropHelper.DropItemChance(NPC, ItemID.Blindfold, Main.expertMode ? 50 : 100); - - return false; + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + npcLoot.Add(ItemID.Blindfold, 50); } public override void OnHitPlayer(Player player, int damage, bool crit)