From 6d009e3601fac74e2d8699466d70687120c99994 Mon Sep 17 00:00:00 2001 From: mountaindrew10 Date: Fri, 17 Feb 2023 17:00:14 -0600 Subject: [PATCH 1/2] More Giant Plantera Bulb stuff. --- Tiles/GiantPlanteraBulb.cs | 52 +++++++++++++++++++++++++++++++++-- Tiles/VernalSoil.cs | 55 +++++++++++++++++++++++++------------- 2 files changed, 86 insertions(+), 21 deletions(-) diff --git a/Tiles/GiantPlanteraBulb.cs b/Tiles/GiantPlanteraBulb.cs index 871f317b39..d13d0f047b 100644 --- a/Tiles/GiantPlanteraBulb.cs +++ b/Tiles/GiantPlanteraBulb.cs @@ -8,10 +8,10 @@ using Terraria.Enums; using Terraria.ModLoader; using Terraria.ObjectData; using System; +using CalamityMod.Projectiles.Melee; namespace CalamityMod.Tiles { - //TODO: this needs animation, will do that later today public class GiantPlanteraBulb : ModTile { public override void SetStaticDefaults() @@ -32,11 +32,17 @@ namespace CalamityMod.Tiles TileObjectData.addTile(Type); AnimationFrameHeight = 90; AddMapEntry(Main.hardMode ? new Color(243, 82, 171) : new Color(107, 125, 33)); - DustType = DustID.JungleGrass; + DustType = DustID.PlanteraBulb; base.SetStaticDefaults(); } + public override bool CreateDust(int i, int j, ref int type) + { + type = (!WorldGen.genRand.NextBool(3) && Main.hardMode) ? DustID.Plantera_Pink : DustID.Plantera_Green; + return true; + } + public override void NumDust(int i, int j, bool fail, ref int num) { num = fail ? 1 : 2; @@ -70,7 +76,49 @@ namespace CalamityMod.Tiles // Spawn Plantera if the bulb was broken within a distance of 50 tiles or less if (distanceFromPlayer / 16f < 50f) + { + float projectileVelocity = 6f; + int projType = ProjectileID.SporeCloud; + int npcType = NPCID.Spore; + Vector2 spawn = new Vector2(i * 16, j * 16); + Vector2 destination = new Vector2(i * 16, (j - 2) * 16) - spawn; + destination.Normalize(); + destination *= projectileVelocity; + int numProj = 30; + int numNPCs = 10; + float rotation = MathHelper.ToRadians(100); + + for (int projIndex = 0; projIndex < numProj; projIndex++) + { + Vector2 perturbedSpeed = destination.RotatedBy(MathHelper.Lerp(-rotation, rotation, projIndex / (float)(numProj - 1))) * (Main.rand.NextFloat() + 0.25f); + + if (Main.netMode != NetmodeID.MultiplayerClient) + Projectile.NewProjectile(new EntitySource_TileBreak(i, j), spawn, perturbedSpeed, projType, 0, 0f, Player.FindClosest(new Vector2(i * 16, j * 16), 16, 16)); + + Dust dust = Dust.NewDustDirect(spawn, 16, 16, DustID.JungleSpore, perturbedSpeed.X, perturbedSpeed.Y, 250, default, 0.8f); + dust.fadeIn = 0.7f; + Dust.NewDustDirect(spawn, 16, 16, (!WorldGen.genRand.NextBool(3) && Main.hardMode) ? DustID.Plantera_Pink : DustID.Plantera_Green, perturbedSpeed.X, perturbedSpeed.Y); + } + + for (int npcIndex = 0; npcIndex < numNPCs; npcIndex++) + { + Vector2 perturbedSpeed = destination.RotatedBy(MathHelper.Lerp(-rotation, rotation, npcIndex / (float)(numNPCs - 1))) * (Main.rand.NextFloat() + 0.5f) * 0.5f; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int spore = NPC.NewNPC(new EntitySource_TileBreak(i, j), (int)spawn.X, (int)spawn.Y, npcType, 0, -1f); + Main.npc[spore].velocity.X = perturbedSpeed.X; + Main.npc[spore].velocity.Y = perturbedSpeed.Y; + Main.npc[spore].netUpdate = true; + } + + Dust dust = Dust.NewDustDirect(spawn, 16, 16, DustID.JungleSpore, perturbedSpeed.X, perturbedSpeed.Y, 250, default, 0.8f); + dust.fadeIn = 0.7f; + Dust.NewDustDirect(spawn, 16, 16, DustID.Plantera_Pink, perturbedSpeed.X, perturbedSpeed.Y); + } + NPC.SpawnOnPlayer(player, NPCID.Plantera); + } } public override void AnimateTile(ref int frame, ref int frameCounter) diff --git a/Tiles/VernalSoil.cs b/Tiles/VernalSoil.cs index 2f093f3692..10c6ec4150 100644 --- a/Tiles/VernalSoil.cs +++ b/Tiles/VernalSoil.cs @@ -87,29 +87,46 @@ namespace CalamityMod.Tiles bool isPlayerNear = WorldGen.PlayerLOS(i, j2); if (isPlayerNear) { - if (Main.netMode != NetmodeID.MultiplayerClient) + float projectileVelocity = 6f; + int projType = ProjectileID.SporeCloud; + int npcType = NPCID.Spore; + Vector2 spawn = new Vector2(i * 16, j2 * 16); + Vector2 destination = new Vector2(i * 16, (j2 - 2) * 16) - spawn; + destination.Normalize(); + destination *= projectileVelocity; + int numProj = 15; + int numNPCs = 5; + float rotation = MathHelper.ToRadians(100); + + for (int projIndex = 0; projIndex < numProj; projIndex++) + { + Vector2 perturbedSpeed = destination.RotatedBy(MathHelper.Lerp(-rotation, rotation, projIndex / (float)(numProj - 1))) * (Main.rand.NextFloat() + 0.25f); + + if (Main.netMode != NetmodeID.MultiplayerClient) + Projectile.NewProjectile(new EntitySource_TileUpdate(i, j2), spawn, perturbedSpeed, projType, 0, 0f, Player.FindClosest(new Vector2(i * 16, j2 * 16), 16, 16)); + + Dust dust = Dust.NewDustDirect(spawn, 16, 16, DustID.JungleSpore, perturbedSpeed.X, perturbedSpeed.Y, 250, default, 0.8f); + dust.fadeIn = 0.7f; + Dust.NewDustDirect(spawn, 16, 16, (!WorldGen.genRand.NextBool(3) && Main.hardMode) ? DustID.Plantera_Pink : DustID.Plantera_Green, perturbedSpeed.X, perturbedSpeed.Y); + } + + if (Main.hardMode) { - float projectileVelocity = 6f; - int type = ProjectileID.SporeCloud; - Vector2 spawn = new Vector2(i * 16, j2 * 16); - Vector2 destination = new Vector2(i * 16, (j2 - 2) * 16) - spawn; - destination.Normalize(); - destination *= projectileVelocity; - int numProj = 20; - int numNPCs = 5; - float rotation = MathHelper.ToRadians(100); - for (int projIndex = 0; projIndex < numProj; projIndex++) - { - Vector2 perturbedSpeed = destination.RotatedBy(MathHelper.Lerp(-rotation, rotation, projIndex / (float)(numProj - 1))) * (Main.rand.NextFloat() + 0.25f); - Projectile.NewProjectile(new EntitySource_TileUpdate(i, j2), spawn, perturbedSpeed, type, 0, 0f, Player.FindClosest(new Vector2(i * 16, j2 * 16), 16, 16)); - } for (int npcIndex = 0; npcIndex < numNPCs; npcIndex++) { Vector2 perturbedSpeed = destination.RotatedBy(MathHelper.Lerp(-rotation, rotation, npcIndex / (float)(numNPCs - 1))) * (Main.rand.NextFloat() + 0.5f) * 0.5f; - int spore = NPC.NewNPC(new EntitySource_TileUpdate(i, j2), (int)spawn.X, (int)spawn.Y, NPCID.Spore, 0, -1f); - Main.npc[spore].velocity.X = perturbedSpeed.X; - Main.npc[spore].velocity.Y = perturbedSpeed.Y; - Main.npc[spore].netUpdate = true; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int spore = NPC.NewNPC(new EntitySource_TileUpdate(i, j2), (int)spawn.X, (int)spawn.Y, npcType, 0, -1f); + Main.npc[spore].velocity.X = perturbedSpeed.X; + Main.npc[spore].velocity.Y = perturbedSpeed.Y; + Main.npc[spore].netUpdate = true; + } + + Dust dust = Dust.NewDustDirect(spawn, 16, 16, DustID.JungleSpore, perturbedSpeed.X, perturbedSpeed.Y, 250, default, 0.8f); + dust.fadeIn = 0.7f; + Dust.NewDustDirect(spawn, 16, 16, DustID.Plantera_Pink, perturbedSpeed.X, perturbedSpeed.Y); } } } From ca019f1b0a291f7a5aaed601cc88a3aad14b1cb9 Mon Sep 17 00:00:00 2001 From: mountaindrew10 Date: Fri, 17 Feb 2023 19:04:53 -0600 Subject: [PATCH 2/2] Bulb grow and break sounds...Inferno Fork sounds lol --- Tiles/GiantPlanteraBulb.cs | 8 +++++--- Tiles/VernalSoil.cs | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Tiles/GiantPlanteraBulb.cs b/Tiles/GiantPlanteraBulb.cs index d13d0f047b..d17a14f9e6 100644 --- a/Tiles/GiantPlanteraBulb.cs +++ b/Tiles/GiantPlanteraBulb.cs @@ -1,14 +1,13 @@ -using CalamityMod.Dusts; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.DataStructures; using Terraria.Enums; using Terraria.ModLoader; using Terraria.ObjectData; using System; -using CalamityMod.Projectiles.Melee; namespace CalamityMod.Tiles { @@ -31,8 +30,10 @@ namespace CalamityMod.Tiles TileObjectData.newTile.DrawYOffset = 2; TileObjectData.addTile(Type); AnimationFrameHeight = 90; + MineResist = 3f; AddMapEntry(Main.hardMode ? new Color(243, 82, 171) : new Color(107, 125, 33)); DustType = DustID.PlanteraBulb; + HitSound = SoundID.Grass; base.SetStaticDefaults(); } @@ -81,6 +82,7 @@ namespace CalamityMod.Tiles int projType = ProjectileID.SporeCloud; int npcType = NPCID.Spore; Vector2 spawn = new Vector2(i * 16, j * 16); + SoundEngine.PlaySound(SoundID.Item74, spawn); Vector2 destination = new Vector2(i * 16, (j - 2) * 16) - spawn; destination.Normalize(); destination *= projectileVelocity; diff --git a/Tiles/VernalSoil.cs b/Tiles/VernalSoil.cs index 10c6ec4150..d3c6dc2a7b 100644 --- a/Tiles/VernalSoil.cs +++ b/Tiles/VernalSoil.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -91,6 +92,7 @@ namespace CalamityMod.Tiles int projType = ProjectileID.SporeCloud; int npcType = NPCID.Spore; Vector2 spawn = new Vector2(i * 16, j2 * 16); + SoundEngine.PlaySound(SoundID.Item73, spawn); Vector2 destination = new Vector2(i * 16, (j2 - 2) * 16) - spawn; destination.Normalize(); destination *= projectileVelocity;