From 2d89b0d9d4228932a1ad8a3d2b4cb69a7176c19c Mon Sep 17 00:00:00 2001 From: Dominic Date: Fri, 7 Oct 2022 17:03:26 -0500 Subject: [PATCH] Geyser updates --- NPCs/AquaticScourge/AquaticUrchin.cs | 101 ---------- NPCs/SulphurousSea/AquaticUrchin.cs | 173 ++++++++++++++++++ .../AquaticUrchin.png | Bin Projectiles/Environment/HotSteam.cs | 56 ++++-- Tiles/Abyss/SteamGeyser.cs | 22 +-- Tiles/Abyss/SteamGeyser.png | Bin 512 -> 547 bytes World/SulphurousSea.cs | 58 +++++- 7 files changed, 277 insertions(+), 133 deletions(-) delete mode 100644 NPCs/AquaticScourge/AquaticUrchin.cs create mode 100644 NPCs/SulphurousSea/AquaticUrchin.cs rename NPCs/{AquaticScourge => SulphurousSea}/AquaticUrchin.png (100%) diff --git a/NPCs/AquaticScourge/AquaticUrchin.cs b/NPCs/AquaticScourge/AquaticUrchin.cs deleted file mode 100644 index 290e1c9f32..0000000000 --- a/NPCs/AquaticScourge/AquaticUrchin.cs +++ /dev/null @@ -1,101 +0,0 @@ -using CalamityMod.BiomeManagers; -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.Items.Placeables.Banners; -using CalamityMod.Items.Weapons.Rogue; -using Terraria; -using Terraria.GameContent.Bestiary; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.NPCs.AquaticScourge -{ - public class AquaticUrchin : ModNPC - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Aquatic Urchin"); - } - - public override void SetDefaults() - { - NPC.aiStyle = -1; - AIType = -1; - NPC.damage = Main.hardMode ? 50 : 25; - NPC.width = 40; - NPC.height = 40; - NPC.defense = 10; - NPC.lifeMax = Main.hardMode ? 300 : 50; - NPC.knockBackResist = 0.8f; - NPC.value = Item.buyPrice(0, 0, 0, 80); - NPC.HitSound = SoundID.NPCHit1; - NPC.DeathSound = SoundID.NPCDeath15; - NPC.behindTiles = true; - Banner = NPC.type; - BannerItem = ModContent.ItemType(); - NPC.Calamity().VulnerableToHeat = false; - NPC.Calamity().VulnerableToSickness = false; - NPC.Calamity().VulnerableToElectricity = true; - NPC.Calamity().VulnerableToWater = false; - SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - } - - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - - // Will move to localization whenever that is cleaned up. - new FlavorTextBestiaryInfoElement("A relative of its brethren in the far ocean, this one’s spines have been hardened by the sulphuric waters. They drip with the venom they inhabit, so it’s better to not be struck by them.") - }); - } - - public override void AI() - { - CalamityAI.UnicornAI(NPC, Mod, true, NPC.wet ? 12f : 4f, NPC.wet ? 7f : 3f, NPC.wet ? 0.12f : 0.05f, NPC.wet ? -16f : -7.5f, NPC.wet ? -14f : -6.5f, NPC.wet ? -13f : -6f, NPC.wet ? -12f : -5f, NPC.wet ? -15f : -7f); - } - - public override void OnHitPlayer(Player player, int damage, bool crit) - { - if (damage > 0) - player.AddBuff(ModContent.BuffType(), 120, true); - } - - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - if (spawnInfo.PlayerSafe) - { - return 0f; - } - if (spawnInfo.Player.Calamity().ZoneSulphur && spawnInfo.Water && NPC.CountNPCS(ModContent.NPCType()) < 2) - { - return 0.2f; - } - return 0f; - } - - public override void ModifyNPCLoot(NPCLoot npcLoot) - { - npcLoot.Add(ModContent.ItemType(), 1, 15, 25); - } - - public override void HitEffect(int hitDirection, double damage) - { - for (int k = 0; k < 5; k++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, hitDirection, -1f, 0, default, 1f); - } - if (NPC.life <= 0) - { - for (int k = 0; k < 20; k++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, hitDirection, -1f, 0, default, 1f); - } - if (Main.netMode != NetmodeID.Server) - { - Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find("AquaticUrchin").Type, 1f); - Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find("AquaticUrchin2").Type, 1f); - Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find("AquaticUrchin3").Type, 1f); - } - } - } - } -} diff --git a/NPCs/SulphurousSea/AquaticUrchin.cs b/NPCs/SulphurousSea/AquaticUrchin.cs new file mode 100644 index 0000000000..b7c1909dac --- /dev/null +++ b/NPCs/SulphurousSea/AquaticUrchin.cs @@ -0,0 +1,173 @@ +using CalamityMod.BiomeManagers; +using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Items.Placeables.Banners; +using CalamityMod.Items.Weapons.Rogue; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.GameContent.Bestiary; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.WorldBuilding; + +namespace CalamityMod.NPCs.SulphurousSea +{ + public class AquaticUrchin : ModNPC + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Aquatic Urchin"); + } + + public override void SetDefaults() + { + NPC.aiStyle = -1; + AIType = -1; + NPC.damage = Main.hardMode ? 50 : 25; + NPC.width = 20; + NPC.height = 20; + NPC.defense = 10; + NPC.lifeMax = Main.hardMode ? 300 : 50; + NPC.knockBackResist = 0.8f; + NPC.value = Item.buyPrice(0, 0, 0, 80); + NPC.HitSound = SoundID.NPCHit1; + NPC.DeathSound = SoundID.NPCDeath15; + NPC.behindTiles = true; + NPC.npcSlots = 0.3333f; + Banner = NPC.type; + BannerItem = ModContent.ItemType(); + NPC.noGravity = true; + NPC.noTileCollide = true; + NPC.RemoveWaterSlowness(); + NPC.Calamity().VulnerableToHeat = false; + NPC.Calamity().VulnerableToSickness = false; + NPC.Calamity().VulnerableToElectricity = true; + NPC.Calamity().VulnerableToWater = false; + SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; + } + + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + + // Will move to localization whenever that is cleaned up. + new FlavorTextBestiaryInfoElement("A relative of its brethren in the far ocean, this one’s spines have been hardened by the sulphuric waters. They drip with the venom they inhabit, so it’s better to not be struck by them.") + }); + } + + public static void DoUrchinAI(NPC npc) + { + // Simply stick to tiles. + if (Main.netMode != NetmodeID.MultiplayerClient && npc.localAI[0] == 0f) + { + GenSearch search = Main.rand.NextBool() ? new Searches.Down(300) : new Searches.Up(300); + if (WorldUtils.Find(npc.Center.ToTileCoordinates(), Searches.Chain(search, new Conditions.IsSolid()), out Point result)) + { + npc.Center = result.ToWorldCoordinates(); + npc.netUpdate = true; + } + npc.localAI[0] = 1f; + } + + // Drift slowly over tiles. + float speedFactor = 0.018f; + + npc.collideX = MathHelper.Distance(npc.position.X, npc.oldPosition.X) < 0.01f; + npc.collideY = MathHelper.Distance(npc.position.Y, npc.oldPosition.Y) < 0.01f; + npc.noGravity = Collision.SolidCollision(npc.TopLeft - Vector2.One * 12, npc.width + 6, npc.height + 6); + if (npc.ai[1] == 0f) + { + if (npc.direction == 0) + npc.direction = 1; + + npc.rotation += npc.direction * npc.directionY * speedFactor * 0.006f; + if (npc.collideY) + npc.ai[0] = 2f; + + if (!npc.collideY && npc.ai[0] == 2f) + { + npc.direction = -npc.direction; + npc.ai[1] = 1f; + npc.ai[0] = 1f; + } + if (npc.collideX) + { + npc.directionY = -npc.directionY; + npc.ai[1] = 1f; + } + } + else + { + npc.rotation -= npc.direction * npc.directionY * 0.006f; + if (npc.collideX) + npc.ai[0] = 2f; + + if (!npc.collideX && npc.ai[0] == 2f) + { + npc.directionY = -npc.directionY; + npc.ai[1] = 0f; + npc.ai[0] = 1f; + } + if (npc.collideY) + { + npc.direction = -npc.direction; + npc.ai[1] = 0f; + } + } + npc.velocity.X = npc.direction * speedFactor; + + if (npc.noGravity) + npc.velocity.Y = npc.directionY * speedFactor; + + // Use blazing wheel movement. + Vector2 position = npc.Center - Vector2.One * 6f; + npc.velocity = Collision.noSlopeCollision(position, npc.velocity, 12, 12, true, true); + } + + public override void AI() => DoUrchinAI(NPC); + + public override void OnHitPlayer(Player player, int damage, bool crit) + { + if (damage > 0) + player.AddBuff(ModContent.BuffType(), 120, true); + } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + if (spawnInfo.PlayerSafe) + { + return 0f; + } + if (spawnInfo.Player.Calamity().ZoneSulphur && spawnInfo.Water && NPC.CountNPCS(ModContent.NPCType()) < 12) + { + return 1.1f; + } + return 0f; + } + + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + npcLoot.Add(ModContent.ItemType(), 1, 15, 25); + } + + public override void HitEffect(int hitDirection, double damage) + { + for (int k = 0; k < 5; k++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, hitDirection, -1f, 0, default, 1f); + } + if (NPC.life <= 0) + { + for (int k = 0; k < 20; k++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, hitDirection, -1f, 0, default, 1f); + } + if (Main.netMode != NetmodeID.Server) + { + Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find("AquaticUrchin").Type, 1f); + Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find("AquaticUrchin2").Type, 1f); + Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find("AquaticUrchin3").Type, 1f); + } + } + } + } +} diff --git a/NPCs/AquaticScourge/AquaticUrchin.png b/NPCs/SulphurousSea/AquaticUrchin.png similarity index 100% rename from NPCs/AquaticScourge/AquaticUrchin.png rename to NPCs/SulphurousSea/AquaticUrchin.png diff --git a/Projectiles/Environment/HotSteam.cs b/Projectiles/Environment/HotSteam.cs index 4ede545e53..143dcbf76b 100644 --- a/Projectiles/Environment/HotSteam.cs +++ b/Projectiles/Environment/HotSteam.cs @@ -1,36 +1,45 @@ +using CalamityMod.DataStructures; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Environment { - public class HotSteam : ModProjectile + public class HotSteam : ModProjectile, IAdditiveDrawer { - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public const int Lifetime = 180; + + public override string Texture => "CalamityMod/Projectiles/Summon/SmallAresArms/MinionPlasmaGas"; public override void SetStaticDefaults() { DisplayName.SetDefault("Steam"); + + // This prevents the water from creating a universal distortion wherever it lands, thus making the geysers look weird. + ProjectileID.Sets.NoLiquidDistortion[Type] = true; } public override void SetDefaults() { - Projectile.width = 40; - Projectile.height = 40; + Projectile.width = Projectile.height = 184; + Projectile.penetrate = -1; Projectile.hostile = true; - Projectile.tileCollide = true; - Projectile.ignoreWater = false; - Projectile.timeLeft = 30; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.timeLeft = Lifetime; + Projectile.hide = true; + Projectile.localAI[0] = 1f; } + public override void AI() { - for (int i = 0; i < 6; i++) - { - Dust dust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, 4); - dust.velocity = Vector2.One.RotatedByRandom(MathHelper.TwoPi); - dust.alpha = 127; - } + Projectile.localAI[0] = 0f; + Projectile.scale = Utils.Remap(Projectile.timeLeft, Lifetime, 0.4f, 0.02f, 1.4f); + Projectile.Opacity = Utils.Remap(Projectile.timeLeft, 134f, 67f, 1f, 0.04f); + Projectile.velocity.Y *= 0.97f; } public override void OnHitPlayer(Player target, int damage, bool crit) @@ -40,5 +49,26 @@ namespace CalamityMod.Projectiles.Environment target.AddBuff(BuffID.Poisoned, 180); } + + public override bool? CanDamage() => Projectile.Opacity > 0.6f ? null : false; + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + return CalamityUtils.CircularHitboxCollision(Projectile.Center, Projectile.scale * 92f, targetHitbox); + } + + public void AdditiveDraw(SpriteBatch spriteBatch) + { + if (Projectile.localAI[0] == 1f) + return; + + Texture2D texture = TextureAssets.Projectile[Projectile.type].Value; + Vector2 origin = texture.Size() * 0.5f; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + float opacity = Projectile.Opacity * 0.4f; + Color drawColor = new Color(159, 137, 181) * opacity; + Vector2 scale = Projectile.Size / texture.Size() * Projectile.scale * 1.35f; + spriteBatch.Draw(texture, drawPosition, null, drawColor, Projectile.rotation, origin, scale, 0, 0f); + } } } diff --git a/Tiles/Abyss/SteamGeyser.cs b/Tiles/Abyss/SteamGeyser.cs index 3eac3337f8..e954255bc3 100644 --- a/Tiles/Abyss/SteamGeyser.cs +++ b/Tiles/Abyss/SteamGeyser.cs @@ -1,7 +1,7 @@ -using CalamityMod.Dusts; +using System; +using CalamityMod.Dusts; using CalamityMod.Projectiles.Environment; using Microsoft.Xna.Framework; -using System; using Terraria; using Terraria.DataStructures; using Terraria.ModLoader; @@ -16,7 +16,6 @@ namespace CalamityMod.Tiles.Abyss Main.tileFrameImportant[Type] = true; Main.tileNoAttach[Type] = true; TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); - TileObjectData.newTile.DrawYOffset = 4; TileObjectData.addTile(Type); ModTranslation name = CreateMapEntryName(); name.SetDefault("Geyser"); @@ -34,18 +33,15 @@ namespace CalamityMod.Tiles.Abyss } public override void NearbyEffects(int i, int j, bool closer) { - bool noTilesBetweenPlayer = Collision.CanHit(new Vector2(i, j) * 16, 1, 1, new Vector2(i * 16f, Main.LocalPlayer.Center.Y), 1, 1); + Tile t = CalamityUtils.ParanoidTileRetrieval(i, j); - if (WorldGen.genRand.NextBool(60) && !Main.gamePaused && noTilesBetweenPlayer) + Vector2 spawnPosition = new(i * 16f + 24f, j * 16f - 4f); + if (!Main.gamePaused && t.TileFrameX % 36 == 0 && t.TileFrameY % 36 == 0 && Collision.CanHitLine(spawnPosition, 1, 1, spawnPosition - Vector2.UnitY * 100f, 1, 1)) { - if (Math.Abs(Main.LocalPlayer.Center.X - i * 16) < 80 && - Main.LocalPlayer.Bottom.Y < j * 16 && - Main.LocalPlayer.Bottom.Y > j * 16 - 300) - { - float yeetSpeed = MathHelper.Clamp(10f - (10f * Math.Abs(Main.LocalPlayer.Bottom.Y - j * 16) / 300f), 0f, 10f); - Main.LocalPlayer.velocity.Y -= yeetSpeed; - Projectile.NewProjectile(new EntitySource_WorldEvent(), i * 16 + 8, j * 16 - 20, 0f, -10f, ModContent.ProjectileType(), Main.expertMode ? 12 : 15, 0f); - } + float positionInterpolant = (i + j) * 0.041f % 1f; + Vector2 smokeVelocity = -Vector2.UnitY.RotatedByRandom(0.11f) * MathHelper.Lerp(4.8f, 8.1f, positionInterpolant); + smokeVelocity.X += (float)Math.Cos(MathHelper.TwoPi * positionInterpolant) * 1.1f; + Projectile.NewProjectile(new EntitySource_WorldEvent(), spawnPosition, smokeVelocity, ModContent.ProjectileType(), Main.expertMode ? 12 : 15, 0f); } } } diff --git a/Tiles/Abyss/SteamGeyser.png b/Tiles/Abyss/SteamGeyser.png index a8da9ed61f779a524fe22fb7d18c16c948ba2599..6d656dbcf97e7c9f3175347f39767cbcaeeca09c 100644 GIT binary patch delta 459 zcmV;+0W|)A1fv8YiBL{Q4GJ0x0000DNk~Le0001N0000a2m=5B09&&!{*fVMf589% z4#5Gqk!$S$00DeSL_t(oN6nStl7k=&gfT$j{h#>!TvKdMuXFw&-I~fDL6ljo%L>e{$e&OO8l~j?J!UDHiP-yf z89o8C$D`KoGRqkv4RYTsrMls2e|?OZXtmNRpf$bu50o+uX2#PVej>_@;mjyAs6L3#kEPlO z4s!1adCE!_9UsfCHruQ<#6|RR#e(0>ucMC;5=b67!;IDF_*jlIV`G6fe-{#eIA-r= z8b%1fLE>1*QfM9&l!nXzT5)Dj03=4tAUH;ml#nnADHZ)l%M&`X=9;y}M-$?e%!s@; zHcccBKuFIdC84nytQAK^RRmUqnd~5A=5~_7N{1LJZz8zxxWbbTPrAZ!O(Icdg!H*G zlikq__;QUj#kiy3N(kr*AxC#ZYp$8(=3t^(??3ruS4{{!0CE5T002ovPDHLkV1h5! B%E$l! delta 423 zcmV;Y0a*T{1b_q~iBL{Q4GJ0x0000DNk~Le0001J0000W2m=5B0LjVCl93@~f5HF& z4#EKyC`y0;00CJ^L_t(YOU;#wZo?oD1bI35|G&7NOel7W8#R@1R*EcO?-sA`E@Ayf zc;K;o3+EZ;3&ogH-jLG!QZbsLl*h&nR|qXj+>kbmh_6u!8A{3d6NExYsnPx;bh|Cf zrwHW??fhfDMhMFt^FMlD^64UhE*iEiRt zA&Oc+LTFqLZN!W|w?bT(rpHFnm~(|@V6KqX@#+rMla{*|48~&bGo#tB^*;yNOrcsy zEe)_56}U}pILVHTE<`kC;efqDh{6OGXU_a(r1UK0fa!zxXkIBM=Zs6peRUvRBLo4& z$l&P54c!=@U~ir|{IzD4+gS62YV}nChJ?WSXbj~dL%8BPO{&{ZET`J&8rEzf520e6 zJ1q$eu0R^Y<=Nb_%);6yEP1T25Ms;ML`bQ<5a_{%8>Piw1{|L~( Main.maxTilesX / 76; + public static int GeyserCount => Main.maxTilesX / 137; + public static int YStart { get; @@ -193,7 +195,8 @@ namespace CalamityMod.World CreateBeachNearSea(); ClearAloneTiles(); PlaceScrapPiles(); - GeneratePillarsInCaverns(); + GenerateColumnsInCaverns(); + GenerateSteamGeysersInCaverns(); GenerateHardenedSandstone(); } #endregion @@ -772,7 +775,7 @@ namespace CalamityMod.World } } - public static void GeneratePillarsInCaverns() + public static void GenerateColumnsInCaverns() { int columnCount = ColumnCount; int width = BiomeWidth; @@ -814,7 +817,50 @@ namespace CalamityMod.World continue; } - GeneratePillar(x, top.Y, y); + GenerateColumn(x, top.Y, y); + } + } + + public static void GenerateSteamGeysersInCaverns() + { + int geyserCount = GeyserCount; + int width = BiomeWidth; + int depth = BlockDepth; + ushort geyserID = (ushort)ModContent.TileType(); + + for (int g = 0; g < geyserCount; g++) + { + int x = GetActualX(WorldGen.genRand.Next(20, width - 32)); + int y = WorldGen.genRand.Next(YStart + depth / 2, YStart + depth - 20); + + bool tryAgain = false; + + // Try again if inside a tile. + for (int dx = 0; dx < 2; dx++) + { + for (int dy = 0; dy < 2; dy++) + { + Tile tile = CalamityUtils.ParanoidTileRetrieval(x + dx, y - dy); + if (tile.HasTile) + tryAgain = true; + } + } + + // Try again if there is no ground. + for (int dx = 0; dx < 2; dx++) + { + Tile tile = CalamityUtils.ParanoidTileRetrieval(x + dx, y + 1); + if (!WorldGen.SolidTile(tile)) + tryAgain = true; + } + + if (tryAgain) + { + g--; + continue; + } + + WorldGen.PlacePot(x, y, geyserID); } } @@ -1059,10 +1105,10 @@ namespace CalamityMod.World return result; } - public static void GeneratePillar(int left, int top, int bottom) + public static void GenerateColumn(int left, int top, int bottom) { int depth = BlockDepth; - ushort pillarID = (ushort)ModContent.TileType(); + ushort ColumnID = (ushort)ModContent.TileType(); ushort hardenedSandstoneWallID = (ushort)ModContent.WallType(); ushort sandWallID = (ushort)ModContent.WallType(); short variantFrameOffset = (short)(WorldGen.genRand.Next(3) * 36); @@ -1080,7 +1126,7 @@ namespace CalamityMod.World else if (y == bottom) frameY = 36; - Main.tile[x, y].TileType = pillarID; + Main.tile[x, y].TileType = ColumnID; Main.tile[x, y].TileFrameX = frameX; Main.tile[x, y].TileFrameY = frameY; Main.tile[x, y].WallType = y >= YStart + depth * OpenCavernStartDepthPercentage ? hardenedSandstoneWallID : sandWallID;