From c66d71006e9cd100b2f9a475029db20aa91ec1d0 Mon Sep 17 00:00:00 2001 From: Doze-Zoze Date: Mon, 22 Sep 2025 22:16:44 -0500 Subject: [PATCH] Sand & Sandgun changes & fixes Fixed our sandball collision logic to work like Vanilla sand. Adjusted damages of prehardmode falling sands to match Vanilla sand at 10. Astral stays 15, and Eutrophic is 5 due to sandgun balancing. (This is OK since most of the sand damage to a player comes from suffocation) All our sands can now be fired by Sandgun and have unique effects depending on the sand. (For context, Vanilla Evil/Hallow sand does +5 damage and pierces infinitely) - Sulphur Sand hits 2 targets and inflicts Irradiated - Dunesand has lower velocity, infinte piercing, +5 damage, and longer time without gravity - Eutrophic Sand has -5 damage and inflicts Eutrophication - Polyp Sand has minor homing and ignores platforms - Volcanic Sand does much less damage, but fires an additional short range shotgun blast - Astral Sand splits into 5 homing sandballs on hit --- Items/Placeables/Abyss/SulphurousSand.cs | 3 +- Items/Placeables/Astral/AstralSand.cs | 3 +- Items/Placeables/SunkenSea/Dunesand.cs | 13 +- Items/Placeables/SunkenSea/EutrophicSand.cs | 4 +- Items/Placeables/SunkenSea/PolypSand.cs | 12 +- Items/Placeables/SunkenSea/VolcanicSand.cs | 11 +- ...ods.CalamityMod.Projectiles.Typeless.hjson | 3 + Projectiles/Typeless/SandBall.cs | 200 +++++++++++++++++- Tiles/SunkenSea/Dunesand.cs | 2 +- Tiles/SunkenSea/EutrophicSand.cs | 2 +- Tiles/SunkenSea/PolypSand.cs | 2 +- Tiles/SunkenSea/VolcanicSand.cs | 2 +- 12 files changed, 231 insertions(+), 26 deletions(-) diff --git a/Items/Placeables/Abyss/SulphurousSand.cs b/Items/Placeables/Abyss/SulphurousSand.cs index e2b44467ba..59087ec75f 100644 --- a/Items/Placeables/Abyss/SulphurousSand.cs +++ b/Items/Placeables/Abyss/SulphurousSand.cs @@ -12,8 +12,7 @@ namespace CalamityMod.Items.Placeables.Abyss Item.ResearchUnlockCount = 100; ItemID.Sets.ShimmerTransformToItem[Type] = ModContent.ItemType(); - // +5 flat damage, equal to other sand variants - ItemID.Sets.SandgunAmmoProjectileData[Type] = new(ModContent.ProjectileType(), 5); + ItemID.Sets.SandgunAmmoProjectileData[Type] = new(ModContent.ProjectileType(), 0); } public override void SetDefaults() diff --git a/Items/Placeables/Astral/AstralSand.cs b/Items/Placeables/Astral/AstralSand.cs index 1ddc465fb5..a7e732363b 100644 --- a/Items/Placeables/Astral/AstralSand.cs +++ b/Items/Placeables/Astral/AstralSand.cs @@ -13,8 +13,7 @@ namespace CalamityMod.Items.Placeables.Astral Item.ResearchUnlockCount = 100; ItemTrader.ChlorophyteExtractinator.AddOption_OneWay(Type, 1, ItemID.SandBlock, 1); - // +5 flat damage, equal to other sand variants - ItemID.Sets.SandgunAmmoProjectileData[Type] = new(ModContent.ProjectileType(), 5); + ItemID.Sets.SandgunAmmoProjectileData[Type] = new(ModContent.ProjectileType(), 0); } public override void SetDefaults() diff --git a/Items/Placeables/SunkenSea/Dunesand.cs b/Items/Placeables/SunkenSea/Dunesand.cs index af03dbc96c..495107affc 100644 --- a/Items/Placeables/SunkenSea/Dunesand.cs +++ b/Items/Placeables/SunkenSea/Dunesand.cs @@ -1,4 +1,5 @@ -using Terraria.ID; +using CalamityMod.Projectiles.Typeless; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.SunkenSea @@ -11,8 +12,16 @@ namespace CalamityMod.Items.Placeables.SunkenSea { Item.ResearchUnlockCount = 100; ItemID.Sets.ShimmerTransformToItem[Type] = ModContent.ItemType(); + + //+5 flat damage + ItemID.Sets.SandgunAmmoProjectileData[Type] = new(ModContent.ProjectileType(), 5); } - public override void SetDefaults() => Item.DefaultToPlaceableTile(ModContent.TileType()); + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.ammo = AmmoID.Sand; + Item.notAmmo = true; + } } } diff --git a/Items/Placeables/SunkenSea/EutrophicSand.cs b/Items/Placeables/SunkenSea/EutrophicSand.cs index 4ee6775d12..a198e8970c 100644 --- a/Items/Placeables/SunkenSea/EutrophicSand.cs +++ b/Items/Placeables/SunkenSea/EutrophicSand.cs @@ -14,8 +14,8 @@ namespace CalamityMod.Items.Placeables.SunkenSea Item.ResearchUnlockCount = 100; ItemID.Sets.ShimmerTransformToItem[Type] = ModContent.ItemType(); - // +5 flat damage, equal to other sand variants - ItemID.Sets.SandgunAmmoProjectileData[Type] = new(ModContent.ProjectileType(), 5); + // -5 flat damage + ItemID.Sets.SandgunAmmoProjectileData[Type] = new(ModContent.ProjectileType(),-5); } public override void SetDefaults() diff --git a/Items/Placeables/SunkenSea/PolypSand.cs b/Items/Placeables/SunkenSea/PolypSand.cs index 50c699626f..cc20b3828f 100644 --- a/Items/Placeables/SunkenSea/PolypSand.cs +++ b/Items/Placeables/SunkenSea/PolypSand.cs @@ -1,4 +1,5 @@ -using Terraria.ID; +using CalamityMod.Projectiles.Typeless; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.SunkenSea @@ -9,8 +10,15 @@ namespace CalamityMod.Items.Placeables.SunkenSea public override void SetStaticDefaults() { Item.ResearchUnlockCount = 100; + + ItemID.Sets.SandgunAmmoProjectileData[Type] = new(ModContent.ProjectileType(), 0); } - public override void SetDefaults() => Item.DefaultToPlaceableTile(ModContent.TileType()); + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.ammo = AmmoID.Sand; + Item.notAmmo = true; + } } } diff --git a/Items/Placeables/SunkenSea/VolcanicSand.cs b/Items/Placeables/SunkenSea/VolcanicSand.cs index 277f746966..c7003f7cb6 100644 --- a/Items/Placeables/SunkenSea/VolcanicSand.cs +++ b/Items/Placeables/SunkenSea/VolcanicSand.cs @@ -1,4 +1,5 @@ -using Terraria.ID; +using CalamityMod.Projectiles.Typeless; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.SunkenSea @@ -9,8 +10,14 @@ namespace CalamityMod.Items.Placeables.SunkenSea public override void SetStaticDefaults() { Item.ResearchUnlockCount = 100; + ItemID.Sets.SandgunAmmoProjectileData[Type] = new(ModContent.ProjectileType(), 0); } - public override void SetDefaults() => Item.DefaultToPlaceableTile(ModContent.TileType()); + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.ammo = AmmoID.Sand; + Item.notAmmo = true; + } } } diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson index 6e35eee88a..b9c79438a1 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson @@ -170,3 +170,6 @@ PinkPearlFalling.DisplayName: Pink Pearl Falling PolypSandBallFalling.DisplayName: Polyp Sand Ball Falling VolcanicSandBallFalling.DisplayName: Volcanic Sand Ball Falling WhitePearlFalling.DisplayName: White Pearl Falling +DuneSandBallGun.DisplayName: Dunesandball +PolypSandBallGun.DisplayName: Polyp Sandball +VolcanicSandBallGun.DisplayName: Volcanic Sandball diff --git a/Projectiles/Typeless/SandBall.cs b/Projectiles/Typeless/SandBall.cs index a92bd56297..4e9072fa7d 100644 --- a/Projectiles/Typeless/SandBall.cs +++ b/Projectiles/Typeless/SandBall.cs @@ -1,4 +1,5 @@ using System; +using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Items.Placeables.Abyss; using CalamityMod.Items.Placeables.Astral; using CalamityMod.Items.Placeables.SunkenSea; @@ -90,6 +91,52 @@ namespace CalamityMod.Projectiles.Typeless public override int TileType => ModContent.TileType(); public override int ItemType => ModContent.ItemType(); public override int DustType => 108; + + //Doze: I'm giving our sandgun sands actual special effects because it's more interesting + //This one hits only one target but splits on impact into seeking mini sands + + public override void SetDefaults() + { + base.SetDefaults(); + Projectile.penetrate = 1; + Projectile.localNPCHitCooldown = 10; + Projectile.usesLocalNPCImmunity = true; + Projectile.usesIDStaticNPCImmunity = false; + } + public override bool PreAI() + { + if (Projectile.ai[2] == 1) + { + Projectile.scale = 0.75f; + if (Projectile.ai[1] == 0) + { + Projectile.originalDamage = Projectile.damage; + Projectile.damage = 0; + } + if (Projectile.ai[1] == 30) + { + Projectile.Calamity().conditionalHomingRange = 600; + Projectile.damage = Projectile.originalDamage; + } + } + return base.PreAI(); + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + if (Projectile.ai[2] != 1) + { + for (var i = 0; i < 4; i++) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity.RotatedByRandom(0.75f) * Main.rand.NextFloat(0.5f,0.75f), ModContent.ProjectileType(), (int)(Projectile.damage * 0.5f), Projectile.knockBack, Projectile.owner, ai2: 1); + } + } + + public override bool PreKill(int timeLeft) + { + if (Projectile.penetrate == 0) + Projectile.active = false; + return Projectile.active; + } + } public class EutrophicSandBallGun : SandBall @@ -98,6 +145,19 @@ namespace CalamityMod.Projectiles.Typeless public override int TileType => ModContent.TileType(); public override int ItemType => ModContent.ItemType(); public override int DustType => 108; // Weirdly same dusts as Astral + + //Doze: I'm giving our sandgun sands actual special effects because it's more interesting + //This one hits only one target and does 5 less damage, but inflicts a relatively long stun debuff + public override void SetDefaults() + { + base.SetDefaults(); + Projectile.penetrate = 1; + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 300); + } } public class SulphurousSandBallGun : SandBall @@ -106,6 +166,128 @@ namespace CalamityMod.Projectiles.Typeless public override int TileType => ModContent.TileType(); public override int ItemType => ModContent.ItemType(); // Uses normal sand dust + + //Doze: I'm giving our sandgun sands actual special effects because it's more interesting + //This one hits only two targets but inflicts Irradiated + public override void SetDefaults() + { + base.SetDefaults(); + Projectile.penetrate = 2; + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 150); + } + } + public class DuneSandBallGun : SandBall + { + public override string Texture => "CalamityMod/Projectiles/Typeless/SandBallDune"; + public override int TileType => ModContent.TileType(); + public override int ItemType => ModContent.ItemType(); + public override int DustType => DustID.Sand; + + + //Doze: I'm giving our sandgun sands actual special effects because it's more interesting + //This one has much less velocity and no gravity for the first 3 seconds, pierces infinitely, and does 5 extra damage + public override void AI() + { + if (Projectile.ai[1] == 0 ) + { + Projectile.velocity *= 0.5f; + } + if (Main.rand.NextBool()) + { + int i = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustType); + Main.dust[i].velocity.X *= 0.4f; + Main.dust[i].velocity.Y += Fired ? 0f : Projectile.velocity.Y * 0.5f; + } + + Projectile.ai[1]++; + Projectile.rotation += 0.1f; + if (Projectile.ai[1] >= 180f) + { + Projectile.ai[1] = 180f; + Projectile.velocity.Y += 0.2f; + } + if (Projectile.velocity.Y > 10f) + Projectile.velocity.Y = 10f; + + Point p = Projectile.Center.ToTileCoordinates(); + // Don't check out of bounds + if (p.X < 0 || p.X >= Main.maxTilesX || p.Y < 0 || p.Y >= Main.maxTilesY) + return; + Tile placer = Main.tile[p.X, p.Y + 1]; + if (placer.HasTile && TileID.Sets.Platforms[placer.TileType] && Projectile.ai[1] >= 60f) + Projectile.Kill(); + + } + } + public class PolypSandBallGun : SandBall + { + public override string Texture => "CalamityMod/Projectiles/Typeless/SandBallPolyp"; + public override int TileType => ModContent.TileType(); + public override int ItemType => ModContent.ItemType(); + public override int DustType => DustID.Sand; + + //Doze: I'm giving our sandgun sands actual special effects because it's more interesting + //This one has a small homing range and can go through platforms + public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough, ref Vector2 hitboxCenterFrac) + { + fallThrough = true; + return true; + } + public override void SetDefaults() + { + base.SetDefaults(); + Projectile.penetrate = 1; + Projectile.Calamity().conditionalHomingRange = 160; + } + } + public class VolcanicSandBallGun : SandBall + { + public override string Texture => "CalamityMod/Projectiles/Typeless/SandBallVolcanic"; + public override int TileType => ModContent.TileType(); + public override int ItemType => ModContent.ItemType(); + public override int DustType => -1; + + //Doze: I'm giving our sandgun sands actual special effects because it's more interesting + //This one fires a shotgun of mini sands, but every sand deals less damage + + public override void SetDefaults() + { + base.SetDefaults(); + Projectile.localNPCHitCooldown = -1; + Projectile.usesLocalNPCImmunity = true; + Projectile.usesIDStaticNPCImmunity = false; + } + public override bool PreAI() + { + if (Projectile.ai[2] == 1) + { + if (Projectile.ai[1] == 0) + { + Projectile.scale = 0.75f; + Projectile.penetrate = 1; + Projectile.timeLeft = 30; + } + } else + { + if (Projectile.ai[1] == 0) + { + for (var i = 0; i < 5; i++) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity.RotatedByRandom(0.5f) * 0.75f, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5f), Projectile.knockBack, Projectile.owner, ai2: 1); + Projectile.damage = (int)(Projectile.damage * 0.5f); + + } + } + return base.PreAI(); + } + public override bool PreKill(int timeLeft) + { + if (Projectile.ai[2] == 1) //Baby sands should always vanish without placing blocks + Projectile.active = false; + return Projectile.active; + } } // All the setups go here to prevent mass blocks of copypasting @@ -143,7 +325,7 @@ namespace CalamityMod.Projectiles.Typeless // Using clones will not allow for custom dust types sadly public override void AI() { - if (Main.rand.NextBool()) + if (Main.rand.NextBool() && DustType >= 0) { int i = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustType); Main.dust[i].velocity.X *= 0.4f; @@ -159,21 +341,19 @@ namespace CalamityMod.Projectiles.Typeless } if (Projectile.velocity.Y > 10f) Projectile.velocity.Y = 10f; + } - Point p = Projectile.Center.ToTileCoordinates(); - // Don't check out of bounds - if (p.X < 0 || p.X >= Main.maxTilesX || p.Y < 0 || p.Y >= Main.maxTilesY) - return; - Tile placer = Main.tile[p.X, p.Y + 1]; - if (placer.HasTile && TileID.Sets.Platforms[placer.TileType] && Projectile.ai[1] >= 60f) - Projectile.Kill(); + public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough, ref Vector2 hitboxCenterFrac) + { + fallThrough = false; + return base.TileCollideStyle(ref width, ref height, ref fallThrough, ref hitboxCenterFrac); } public override void OnKill(int timeLeft) { Point p = Projectile.Center.ToTileCoordinates(); - // If the sand is dying outside the world border, cancel placing sand. - if (p.X < 0 || p.X >= Main.maxTilesX || p.Y < 0 || p.Y >= Main.maxTilesY) + // If the sand is dying outside the world border, or having used all of it's pierce, cancel placing sand. + if ( p.X < 0 || p.X >= Main.maxTilesX || p.Y < 0 || p.Y >= Main.maxTilesY) return; Tile placer = Main.tile[p.X, p.Y]; diff --git a/Tiles/SunkenSea/Dunesand.cs b/Tiles/SunkenSea/Dunesand.cs index 0533ca9bb1..9493a12f8f 100644 --- a/Tiles/SunkenSea/Dunesand.cs +++ b/Tiles/SunkenSea/Dunesand.cs @@ -36,7 +36,7 @@ namespace CalamityMod.Tiles.SunkenSea TileID.Sets.Conversion.Sand[Type] = true; TileID.Sets.ForAdvancedCollision.ForSandshark[Type] = true; TileID.Sets.Falling[Type] = true; - TileID.Sets.FallingBlockProjectile[Type] = new TileID.Sets.FallingBlockProjectileInfo(ModContent.ProjectileType(), 15); + TileID.Sets.FallingBlockProjectile[Type] = new TileID.Sets.FallingBlockProjectileInfo(ModContent.ProjectileType(), 10); this.RegisterUniversalMerge(TileID.Sandstone, "CalamityMod/Tiles/Merges/SandstoneMerge"); this.RegisterUniversalMerge(TileID.Sand, "CalamityMod/Tiles/Merges/SandMerge"); diff --git a/Tiles/SunkenSea/EutrophicSand.cs b/Tiles/SunkenSea/EutrophicSand.cs index 3ebff8a24e..a695859acc 100644 --- a/Tiles/SunkenSea/EutrophicSand.cs +++ b/Tiles/SunkenSea/EutrophicSand.cs @@ -43,7 +43,7 @@ namespace CalamityMod.Tiles.SunkenSea TileID.Sets.Conversion.Sand[Type] = true; TileID.Sets.ForAdvancedCollision.ForSandshark[Type] = true; TileID.Sets.Falling[Type] = true; - TileID.Sets.FallingBlockProjectile[Type] = new TileID.Sets.FallingBlockProjectileInfo(ModContent.ProjectileType(), 15); + TileID.Sets.FallingBlockProjectile[Type] = new TileID.Sets.FallingBlockProjectileInfo(ModContent.ProjectileType(), 5); this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/EutrophicSandMerge"); this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/NavystoneMerge"); diff --git a/Tiles/SunkenSea/PolypSand.cs b/Tiles/SunkenSea/PolypSand.cs index dcd33acde1..a92a145606 100644 --- a/Tiles/SunkenSea/PolypSand.cs +++ b/Tiles/SunkenSea/PolypSand.cs @@ -40,7 +40,7 @@ namespace CalamityMod.Tiles.SunkenSea TileID.Sets.Conversion.Sand[Type] = true; TileID.Sets.ForAdvancedCollision.ForSandshark[Type] = true; TileID.Sets.Falling[Type] = true; - TileID.Sets.FallingBlockProjectile[Type] = new TileID.Sets.FallingBlockProjectileInfo(ModContent.ProjectileType(), 15); + TileID.Sets.FallingBlockProjectile[Type] = new TileID.Sets.FallingBlockProjectileInfo(ModContent.ProjectileType(), 10); this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/ShellstoneMerge"); this.RegisterUniversalMerge(TileID.Sandstone, "CalamityMod/Tiles/Merges/SandstoneMerge"); diff --git a/Tiles/SunkenSea/VolcanicSand.cs b/Tiles/SunkenSea/VolcanicSand.cs index 83d3e0e28d..e0c17c2c33 100644 --- a/Tiles/SunkenSea/VolcanicSand.cs +++ b/Tiles/SunkenSea/VolcanicSand.cs @@ -35,7 +35,7 @@ namespace CalamityMod.Tiles.SunkenSea TileID.Sets.Conversion.Sand[Type] = true; TileID.Sets.ForAdvancedCollision.ForSandshark[Type] = true; TileID.Sets.Falling[Type] = true; - TileID.Sets.FallingBlockProjectile[Type] = new TileID.Sets.FallingBlockProjectileInfo(ModContent.ProjectileType(), 15); + TileID.Sets.FallingBlockProjectile[Type] = new TileID.Sets.FallingBlockProjectileInfo(ModContent.ProjectileType(), 10); //Stone merges this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/ShellstoneMerge");