From ce75de9a842e73f3003b4dfac991c13247067ae8 Mon Sep 17 00:00:00 2001 From: Dominic Date: Thu, 6 Oct 2022 15:08:56 -0500 Subject: [PATCH 01/21] Base for reworked sulph sea worldgen --- Utilities/MathematicalUtils.cs | 1 - Utilities/WorldgenUtils.cs | 54 ++ World/SulphurousSea.cs | 1264 +++++++++++--------------------- 3 files changed, 497 insertions(+), 822 deletions(-) diff --git a/Utilities/MathematicalUtils.cs b/Utilities/MathematicalUtils.cs index 8e3e17d123..d920f3e259 100644 --- a/Utilities/MathematicalUtils.cs +++ b/Utilities/MathematicalUtils.cs @@ -27,7 +27,6 @@ namespace CalamityMod /// The Y position on the map. /// A metric of "instability" of the noise. The higher this is, the more unstable. Lower of bounds of 2-3 are preferable. /// The seed for the noise. - /// public static float PerlinNoise2D(float x, float y, int octaves, int seed) { float SmoothFunction(float n) => 3f * n * n - 2f * n * n * n; diff --git a/Utilities/WorldgenUtils.cs b/Utilities/WorldgenUtils.cs index 55017eec6b..41d5d84caa 100644 --- a/Utilities/WorldgenUtils.cs +++ b/Utilities/WorldgenUtils.cs @@ -1,4 +1,5 @@ using System.Linq; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -31,5 +32,58 @@ namespace CalamityMod } } } + + /// + /// Generates caves via celluar automata in terms of active/inactive states. May also be used to smoothen out areas. + /// + /// The area to perform the algorithm on. + /// The number of times to iterate. The higher this value is, the more smooth the result is. + public static void GenerateCellularAutomataCave(Rectangle area, int gameIterations) + { + bool[,] cellStates = new bool[area.Width, area.Height]; + int width = cellStates.GetLength(0); + int height = cellStates.GetLength(1); + + // Initialize the cell states. + for (int i = area.Left; i < area.Right; i++) + { + for (int j = area.Top; j < area.Bottom; j++) + cellStates[i - area.Left, j - area.Top] = ParanoidTileRetrieval(i, j).HasTile; + } + + for (int i = 0; i < gameIterations; i++) + { + bool[,] newState = cellStates.Clone() as bool[,]; + for (int x = 0; x < width; x++) + { + for (int y = 0; y < height; y++) + { + int nearbyActiveCells = 0; + for (int dx = -1; dx <= 1; dx++) + { + for (int dy = -1; dy <= 1; dy++) + { + if (x + dx < 0 || x + dx >= width || y + dy < 0 || y + dy >= height) + { + nearbyActiveCells++; + continue; + } + + nearbyActiveCells += cellStates[x + dx, y + dy].ToInt(); + } + } + + newState[x, y] = nearbyActiveCells >= 5; + } + } + cellStates = newState; + } + + for (int i = area.Left; i < area.Right; i++) + { + for (int j = area.Top; j < area.Bottom; j++) + Main.tile[i, j].Get().HasTile = cellStates[i - area.Left, j - area.Top]; + } + } } } diff --git a/World/SulphurousSea.cs b/World/SulphurousSea.cs index e2a6f0fa48..6be657f96f 100644 --- a/World/SulphurousSea.cs +++ b/World/SulphurousSea.cs @@ -9,6 +9,7 @@ using System; using System.Collections.Generic; using System.Linq; using Terraria; +using Terraria.GameContent.RGB; using Terraria.ID; using Terraria.ModLoader; using Terraria.WorldBuilding; @@ -18,25 +19,78 @@ namespace CalamityMod.World public class SulphurousSea { #region Fields and Properties + + // Loop variables that are accessed via getter methods should be stored externally in local variables for performance reasons. + public static readonly List SulphSeaTiles = new() + { + ModContent.TileType(), + ModContent.TileType(), + ModContent.TileType() + }; + + public const float SandBlockEdgeDescentSmoothness = 0.24f; + + // What percentage it takes for dither effects to start appearing at the edges. + // As an example, if this value is 0.7 that would mean that tiles that are below 70% of the way down from the top of the ocean would + // start randomly dithering. + public const float DitherStartFactor = 0.9f; + + public const int DepthForWater = 18; + + public const float TopWaterDepthPercentage = 0.125f; + + public const float TopWaterDescentSmoothnessMin = 0.26f; + + public const float TopWaterDescentSmoothnessMax = 0.39f; + + public const int TotalSandTilesBeforeWaterMin = 32; + + public const int TotalSandTilesBeforeWaterMax = 45; + + // 0-1 value of how jagged the small caves should be. The higher this value is, the more variance you can expect for each step when carving out caves. + public const float SmallCavesJaggedness = 0.51f; + + // How much of a tendency the small caves have to be cramped instead of large and open, with values between 0-1 emphasizing larger caves while values greater than 1 + // emphasizing more cramped caves. + public const float SmallCavesBiasTowardsTightness = 2.21f; + + // How much of a magnification is performed when calculating perlin noise for spaghetti caves. The closer to 0 this value is, the more same-y the caves will seem in + // terms of direction, size, etc. + public const float SpaghettiCaveMagnification = 0.00193f; + + // 0-1 value that determines the threshold for spaghetti caves being carved out. At 0, no caves are carved out, at 1, all tiles are carved out. + // This is used in the formula 'abs(noise(x, y)) < r' to determine whether the cave should remove tiles. + public static readonly float[] SpaghettiCaveCarveOutThresholds = new float[] + { + 0.033f, + 0.089f + }; + + public const float CheeseCaveMagnification = 0.00237f; + + public static readonly float[] CheeseCaveCarveOutThresholds = new float[] + { + 0.4f + }; + + // Percentage of how far down a tile has to be for open caverns to appear. + public const float OpenCavernStartDepthPercentage = 0.5f; + public static int BiomeWidth { get { - // Small world - if (Main.maxTilesX == 4200) + return Main.maxTilesX switch { - return 370; - } - // Medium world - else if (Main.maxTilesX == 6400) - { - return 445; - } - // Large world - else - { - return 500; - } + // Small worlds. + 4200 => 370, + + // Medium worlds. + 6400 => 445, + + // Large worlds. This also accounts for worlds of an unknown size, such as extra large worlds. + _ => (int)(Main.maxTilesX / 16.8f), + }; } } @@ -44,31 +98,38 @@ namespace CalamityMod.World { get { - // Small world - if (Main.maxTilesX == 4200) + float depthFactor = Main.maxTilesX switch { - return (int)((Main.rockLayer + 20 - YStart) * 0.8); - } - // Medium world - else if (Main.maxTilesX == 6400) - { - return (int)((Main.rockLayer + 20 - YStart) * 0.85); - } - // Large world - else - { - return (int)((Main.rockLayer + 20 - YStart) * 0.925); - } + // Small worlds. + 4200 => 0.8f, + + // Medium worlds. + 6400 => 0.85f, + + // Large worlds. + _ => 0.925f + }; + return (int)((Main.rockLayer + 112 - YStart) * depthFactor); } } - public static int YStart = 0; - public static readonly List SulphSeaTiles = new() + public static int TotalCavesInShallowWater => (int)Math.Ceiling(Main.maxTilesX / 1300f); + + public static int MaxTopWaterDepth => (int)(BlockDepth * TopWaterDepthPercentage); + + public static int MinCaveWidth => (int)(Main.maxTilesX / 2500f); + + public static int MaxCaveWidth => (int)Math.Ceiling(Main.maxTilesX / 376f); + + public static int MinCaveMovementSteps => (int)Math.Ceiling(Main.maxTilesX / 70f); + + public static int MaxCaveMovementSteps => (int)Math.Ceiling(Main.maxTilesX / 40f); + + public static int YStart { - ModContent.TileType(), - ModContent.TileType(), - ModContent.TileType() - }; + get; + set; + } #endregion #region Placement Methods @@ -76,846 +137,323 @@ namespace CalamityMod.World { Abyss.AtLeftSideOfWorld = Main.dungeonX < Main.maxTilesX / 2; DetermineYStart(); - CreateStartingBlock(); - CreateWater(); - GenerateHardenedSandstone(); + GenerateSandBlock(); RemoveStupidTilesAboveSea(); - GenerateLake(); - SettleWater(); // The island Y spawn position calculations are relative to water. Settling the water before doing these calculations is ideal. - GenerateIslands(); - GenerateVentsAndFossils(); - SmoothenTheEntireSea(); + GenerateShallowTopWater(); + + // Cave generation. Some of these borrow concepts and tricks used by Minecraft's new generation. + GenerateSmallWaterCaverns(); + GenerateSpaghettiWaterCaves(); + GenerateCheeseWaterCaves(); + ClearOutStrayTiles(); + + // Lay down decorations after the caves are generated. + DecideHardSandstoneLine(); } public static void FinishGeneratingSulphurSea() { - PlaceStalactites(); - PlaceColumns(); - CreateBeachNearSea(); - PlaceScrapPiles(); - PlaceRustyChests(); + } #endregion - #region Perlin Noise - public static float NoiseFunction(int seed) + #region Generation Functions + public static void GenerateSandBlock() { - seed = (seed << 13) ^ seed; - return 1.0f - ((seed * (seed * seed * 15731) + 1376312589) & 0x7fffffff) / 1073741824.0f; - } - public static float PerlinNoise2D(float x, float y, int octave, int seed) - { - float frequency = (float)Math.Pow(2, octave); - float xFrequency = x * frequency; - float yFrequency = y * frequency; - int flooredXFrequency = (int)xFrequency; - int flooredYFrequency = (int)yFrequency; - float fractionXFrequency = xFrequency - flooredXFrequency; - float fractionYFrequency = yFrequency - flooredYFrequency; - - float noise1 = NoiseFunction(flooredXFrequency + flooredYFrequency * 54 + seed); - float noise2 = NoiseFunction(flooredXFrequency + 1 + flooredYFrequency * 54 + seed); - float noise3 = NoiseFunction(flooredXFrequency + (1 + flooredYFrequency) * 54 + seed); - float noise4 = NoiseFunction(flooredXFrequency + 1 + (1 + flooredYFrequency) * 54 + seed); - - float lerpStart = MathHelper.Lerp(noise1, noise2, fractionXFrequency); - float lerpEnd = MathHelper.Lerp(noise3, noise4, fractionXFrequency); - return MathHelper.Lerp(lerpStart, lerpEnd, fractionYFrequency); - } - #endregion - - #region Generating Initial Block - public static void CreateStartingBlock() - { - // Set above for general performance. - ushort sandTileType = (ushort)ModContent.TileType(); - ushort sandstoneTileType = (ushort)ModContent.TileType(); - - ushort sandWallType = (ushort)ModContent.WallType(); - ushort sandstoneWallType = (ushort)ModContent.WallType(); - - - float randomValue1 = WorldGen.genRand.NextFloat(-0.4f, 0.4f); - while (Math.Abs(randomValue1) < 0.22f) + int width = BiomeWidth + 1; + int maxDepth = BlockDepth; + ushort blockTileType = (ushort)ModContent.TileType(); + for (int i = 1; i < width; i++) { - randomValue1 = WorldGen.genRand.NextFloat(-0.4f, 0.4f); - } - float randomValue2 = WorldGen.genRand.NextFloat(-0.2f, 0.2f); - while (Math.Abs(randomValue2) < 0.07f) - { - randomValue2 = WorldGen.genRand.NextFloat(-0.2f, 0.2f); - } + int x = GetActualX(i); - float randomValue3 = WorldGen.genRand.NextFloat(0.42f, 0.96f) * WorldGen.genRand.NextBool(2).ToDirectionInt(); - float wallBoundAtPosition(float xRatio) => (float)(Math.Sin(randomValue3 * MathHelper.Pi * xRatio) + Math.Cos(randomValue3 * Math.E / 2f * xRatio)) * 0.5f * 28f; + // Calculate the 0-1 factor that determines how far down a vertical strip of the sea should descend. + float depthFactor = (float)Math.Pow(Math.Sin((1f - i / (float)width) * MathHelper.PiOver2), SandBlockEdgeDescentSmoothness); - for (int x = 1; x < BiomeWidth; x++) - { - float xRatio = x / (float)BiomeWidth; - for (int y = YStart; y <= YStart + BlockDepth; y++) + // Determine the top and botton of the strip. + int top = YStart; + int bottom = top + (int)(maxDepth * depthFactor); + for (int y = top; y < bottom; y++) { - int trueX = Abyss.AtLeftSideOfWorld ? x : Main.maxTilesX - x; - float yRatio = (y - YStart) / (float)BlockDepth; - float xAngleWrap = x / (float)BiomeWidth * MathHelper.TwoPi - MathHelper.Pi; - bool generateSand = yRatio < SandstoneYMinimum(xAngleWrap, randomValue1, randomValue2); - if (WorldGen.InWorld(trueX, y)) - { - if (y - YStart < BlockDepth - (int)(BlockDepth * 0.35f) + (int)(Math.Sin(xRatio * MathHelper.Pi) * (int)(BlockDepth * 0.35f))) - { - Main.tile[trueX, y].ClearEverything(); - Main.tile[trueX, y].WallType = generateSand ? sandWallType : sandstoneWallType; - Main.tile[trueX, y].TileType = generateSand ? sandTileType : sandstoneTileType; - if (y - YStart - 6 < wallBoundAtPosition(xRatio * MathHelper.TwoPi * 4f)) - Main.tile[trueX, y].WallType = WallID.None; + float ditherChance = CalculateDitherChance(width, top, bottom, i, y); + if (WorldGen.genRand.NextFloat() >= ditherChance) + Main.tile[x, y].TileType = blockTileType; - Main.tile[trueX, y].Get().HasTile = true; - } + // Ensure that the sand pops into existence if there is no chance that dithering will occur. + // This doesn't happen if there is dithering to ensure that there aren't stray sand tiles in the middle of open + // caves that have nothing to connect to. + if (ditherChance <= 0f) + { + Main.tile[x, y].Get().Slope = SlopeType.Solid; + Main.tile[x, y].Get().IsHalfBlock = false; + Main.tile[x, y].Get().HasTile = true; } } } } - public static float SandstoneYMinimum(float xAsAngle, float randomValue1, float randomValue2) - { - float sineSquaredRandom1 = randomValue1 * (float)Math.Cos(xAsAngle * randomValue1) * (float)Math.Cos(xAsAngle * randomValue1); - float sineSquaredRandom2 = randomValue1 * (float)Math.Sin(xAsAngle * randomValue1) * (float)Math.Sin(xAsAngle * randomValue1); - float sineSquaredRandom3 = randomValue2 * (float)Math.Sin(xAsAngle * randomValue2); - float sineSquaredRandom4 = (float)Math.Sin(randomValue1 / randomValue2 * xAsAngle) * (float)Math.Cos(randomValue1 * MathHelper.Pi); - return 0.25f * Math.Abs(sineSquaredRandom1 + 0.5f * sineSquaredRandom2 + sineSquaredRandom3 - sineSquaredRandom4) + 0.25f; - } - #endregion - #region Generating Water - public const int PerlinIterations = 1; - public const int PerlinOctaves = 4; - public const int PerlinXEdgeClamp = 20; - public const float PerlinYDelta = 40; - public const float PerlinNoiseMax = 0.05f; - public const float PerlinThreshold = 0.1f; // Be careful with this number - - public static void GenerateLake() - { - int lakeDepthMax = WorldGen.genRand.Next(36, 52 + 1); - float lakeSteepness = WorldGen.genRand.NextFloat(1.2f, 1.5f); - for (int x = 1; x < BiomeWidth; x++) - { - int trueX = Abyss.AtLeftSideOfWorld ? x : Main.maxTilesX - x; - float xRatio = x / (float)BiomeWidth; - int lakeDepth = (int)(Math.Sin(MathHelper.Min((1f - xRatio) * MathHelper.PiOver2 * lakeSteepness * 1.2f, MathHelper.PiOver2)) * lakeDepthMax); - for (int y = YStart; y <= YStart + lakeDepth; y++) - { - ushort oldWall = Main.tile[trueX, y].WallType; - Main.tile[trueX, y].ClearEverything(); - Main.tile[trueX, y].WallType = oldWall; - Main.tile[trueX, y].LiquidAmount = 255; - } - } - } - - public static void CreateWater() - { - int[] seeds = new int[PerlinIterations]; - for (int i = 0; i < seeds.Length; i++) - { - seeds[i] = WorldGen.genRand.Next(); - } - for (int x = 1; x < BiomeWidth; x++) - { - float xRatio = x / (float)BiomeWidth; - for (int y = YStart; y <= YStart + BlockDepth; y++) - { - float yRatio = (y - YStart) / (float)BlockDepth; - int trueX = Abyss.AtLeftSideOfWorld ? x : Main.maxTilesX - x; - if (y - YStart < BlockDepth - (int)(BlockDepth * 0.35f) + (int)(Math.Sin(xRatio * MathHelper.Pi) * (int)(BlockDepth * 0.35f)) - PerlinYDelta) - { - if (x < PerlinXEdgeClamp || x > BiomeWidth - PerlinXEdgeClamp) - continue; - float perlinAverage = 0f; - for (int k = 0; k < seeds.Length; k++) - { - perlinAverage += PerlinNoise2D(xRatio, yRatio, PerlinOctaves, seeds[k]) / PerlinIterations; - } - if (perlinAverage > PerlinThreshold * WorldGen.genRand.NextFloat(1f - PerlinNoiseMax, 1f + PerlinNoiseMax)) - { - ushort oldWall = Main.tile[trueX, y].WallType; - Main.tile[trueX, y].ClearEverything(); - Main.tile[trueX, y].WallType = oldWall; - Main.tile[trueX, y].LiquidAmount = 255; - } - } - } - } - } - #endregion - - #region Generating Edge Sandstone - public const int EdgeCheckMinX = 6; - public const int EdgeCheckMaxX = 8; - public const int EdgeCheckMinY = 4; - public const int EdgeCheckMaxY = 6; - public const int MinimumEdgeScore = 4; - public const int SpotWidth = 4; - public static void GenerateHardenedSandstone() - { - for (int x = 1; x < BiomeWidth; x++) - { - for (int y = YStart; y <= YStart + BlockDepth; y++) - { - int trueX = Abyss.AtLeftSideOfWorld ? x : Main.maxTilesX - x; - int edgeScore = GetEdgeScore(trueX, y); - - if (edgeScore >= MinimumEdgeScore) - { - for (int dx = -SpotWidth / 2; dx <= SpotWidth; dx++) - { - for (int dy = -SpotWidth / 2; dy <= SpotWidth / 2; dy++) - { - if (WorldGen.InWorld(trueX + dx, y + dy)) - { - if (CalamityUtils.ParanoidTileRetrieval(trueX + dx, y + dy).TileType != (ushort)ModContent.TileType() && - SulphSeaTiles.Contains(CalamityUtils.ParanoidTileRetrieval(trueX + dx, y + dy).TileType)) - { - Main.tile[trueX + dx, y + dy].TileType = (ushort)ModContent.TileType(); - } - } - } - } - } - } - } - } - public static int GetEdgeScore(int x, int y) - { - int edgeScore = 0; - for (int dx = x - WorldGen.genRand.Next(EdgeCheckMinX, EdgeCheckMaxX + 1); dx <= x + WorldGen.genRand.Next(EdgeCheckMinX, EdgeCheckMaxX + 1); dx++) - { - if (dx == x) - continue; - if (CalamityUtils.ParanoidTileRetrieval(dx, y).LiquidAmount == 255) - edgeScore++; - } - for (int dy = y - WorldGen.genRand.Next(EdgeCheckMinY, EdgeCheckMaxY + 1); dy <= y + WorldGen.genRand.Next(EdgeCheckMinY, EdgeCheckMaxY + 1); dy++) - { - if (dy == y) - continue; - if (CalamityUtils.ParanoidTileRetrieval(x, dy).LiquidAmount == 255) - edgeScore++; - } - return edgeScore; - } - #endregion - - #region Generating Islands - public const int IslandCount = 4; - public const int IslandXPadding = 20; - - public const int IslandMinWidth = 15; - public const int IslandMaxWidth = 22; - - public const int IslandMinDepth = 5; - public const int IslandMaxDepth = 10; - public static void SettleWater() - { - Liquid.QuickWater(3, -1, -1); - WorldGen.WaterCheck(); - int counter = 0; - Liquid.quickSettle = true; - while (counter < 10) - { - counter++; - while (Liquid.numLiquid > 0) - { - Liquid.UpdateLiquid(); - } - WorldGen.WaterCheck(); - } - Liquid.quickSettle = false; - - // Remove liquid above the biome line, to prevent flooding. - for (int x = 2; x < BiomeWidth - 2; x++) - { - int trueX = x; - if (!Abyss.AtLeftSideOfWorld) - trueX = Main.maxTilesX - x; - for (int y = YStart - 300; y <= YStart; y++) - { - if (CalamityUtils.ParanoidTileRetrieval(trueX, y).LiquidAmount > 0) - Main.tile[trueX, y].LiquidAmount = 0; - } - } - } - public static void GenerateIslands() - { - for (int i = 0; i < IslandCount; i++) - { - int y = YStart - 240; - int x = WorldGen.genRand.Next(IslandMaxWidth + IslandXPadding, BiomeWidth - IslandMaxWidth - IslandXPadding); - if (!Abyss.AtLeftSideOfWorld) - x = Main.maxTilesX - x; - while (CalamityUtils.ParanoidTileRetrieval(x, y).LiquidAmount == 0) - { - y++; - if (y > Main.rockLayer - 35) - { - break; - } - } - if (y > Main.rockLayer - 35) - { - i--; - continue; // Try again - } - int height = 2 * WorldGen.genRand.Next(IslandMinDepth, IslandMaxDepth + 1); - int width = WorldGen.genRand.Next(IslandMinWidth, IslandMaxWidth + 1); - int treePosition = WorldGen.genRand.Next(-width + 4, width - 4); - - for (float theta = 0f; theta <= MathHelper.TwoPi; theta += 0.05f) - { - for (int dx = 0; dx != (int)(height * Math.Cos(theta)); dx += (height * Math.Cos(theta) > 0).ToDirectionInt()) - { - for (int dy = 0; dy != (int)(width * Math.Sin(theta)); dy += (width * Math.Sin(theta) > 0).ToDirectionInt()) - { - if (WorldGen.InWorld(x + dx, y + dy)) - { - if (dy >= -2 - WorldGen.genRand.Next(-2, 3)) - { - int extraHeight = WorldGen.genRand.Next(0, 1 + 1); - for (int y2 = 0; y2 <= extraHeight; y2++) - { - Main.tile[x + dx, y + dy - y2].TileType = (ushort)ModContent.TileType(); - Main.tile[x + dx, y + dy - y2].Get().Slope = SlopeType.Solid; - Main.tile[x + dx, y + dy - y2].Get().IsHalfBlock = false; - Main.tile[x + dx, y + dy - y2].Get().HasTile = true; - } - if (dy == -2 && dx == treePosition) - WorldGen.PlaceTile(x + dx, y + dy - extraHeight - 1, ModContent.TileType()); - } - else - { - Main.tile[x + dx, y + dy].LiquidAmount = 0; - } - } - } - } - } - } - } - #endregion - - #region Smoothening Everything - public static void SmoothenTheEntireSea() - { - for (int x = 2; x < BiomeWidth - 2; x++) - { - int trueX = x; - if (!Abyss.AtLeftSideOfWorld) - trueX = Main.maxTilesX - x; - for (int y = YStart; y <= YStart + BlockDepth; y++) - { - Tile.SmoothSlope(trueX, y); - } - } - } - #endregion - - #region Generating Scenery - public const int ColumnMinDistanceX = 8; - public const int ColumnMinHeight = 10; - public const int ColumnMaxHeight = 27; - public const int StalactitePairMinDistance = 6; - public const int StalactitePairMaxDistance = 44; - public static void GenerateVentsAndFossils() - { - for (int x = 1; x < BiomeWidth; x++) - { - int trueX = Abyss.AtLeftSideOfWorld ? x : Main.maxTilesX - x; - for (int y = YStart; y <= YStart + BlockDepth; y++) - { - // Generate vents in the top 45% - if (y - YStart < BlockDepth * 0.45f) - { - if (WorldGen.SolidTile(trueX, y + 1) && WorldGen.genRand.NextBool(20)) - { - PlaceMiscTile(trueX, y, 1, 2, (ushort)ModContent.TileType()); - } - } - // And fossils in the bottom 55% - else - { - if (WorldGen.SolidTile(trueX, y + 1)) - { - // Generate ribs such that they're all nearby - if (WorldGen.genRand.NextBool(25)) - { - ushort type = (ushort)Utils.SelectRandom(WorldGen.genRand, - ModContent.TileType(), - ModContent.TileType(), - ModContent.TileType(), - ModContent.TileType(), - ModContent.TileType()); - int height; - if (type == ModContent.TileType() || type == ModContent.TileType()) - { - height = 3; - } - else if (type == ModContent.TileType()) - { - height = 2; - } - else if (type == ModContent.TileType()) - { - height = 4; - } - else - { - height = 1; - } - PlaceMiscTile(trueX, y, 1, height, type); - } - else if (WorldGen.genRand.NextBool(16)) - { - PlaceMiscTile(trueX, y, 3, 2, (ushort)Utils.SelectRandom(WorldGen.genRand, ModContent.TileType(), ModContent.TileType(), ModContent.TileType())); - } - } - } - } - } - } - public static void PlaceColumns() - { - int previousX = 0; - int style; - for (int x = 1; x < BiomeWidth; x++) - { - int trueX = Abyss.AtLeftSideOfWorld ? x : Main.maxTilesX - x; - for (int y = YStart; y <= YStart + BlockDepth; y++) - { - if (y - YStart > BlockDepth * 0.5f) - { - if (WorldGen.SolidTile(trueX, y + 1) && - WorldGen.SolidTile(trueX + 1, y + 1) && - SulphSeaTiles.Contains(CalamityUtils.ParanoidTileRetrieval(trueX, y + 1).TileType) && - WorldGen.genRand.NextBool(3) && - Math.Abs(trueX - previousX) >= ColumnMinDistanceX) - { - int top = y; - int height = 0; - while (!(WorldGen.SolidTile(trueX - 1, top) && WorldGen.SolidTile(trueX, top) && WorldGen.SolidTile(trueX + 1, top))) - { - top--; - height++; - if (height > ColumnMaxHeight + 1) - break; - } - if (height <= ColumnMaxHeight && height >= ColumnMinHeight) - { - for (int dy = 0; dy < height; dy++) - { - style = WorldGen.genRand.Next(3); - short yFrame = 18; - if (dy == 0) - yFrame = 36; - if (dy == height - 1) - yFrame = 0; - ushort oldWall = Main.tile[trueX, y - dy].WallType; - Main.tile[trueX, y - dy].ResetToType((ushort)ModContent.TileType()); - Main.tile[trueX, y - dy].TileFrameX = (short)(style * 36); - Main.tile[trueX, y - dy].TileFrameY = yFrame; - Main.tile[trueX, y - dy].LiquidAmount = 255; - Main.tile[trueX, y - dy].WallType = oldWall; - Main.tile[trueX, y - dy].Get().HasTile = true; - - oldWall = Main.tile[trueX + 1, y - dy].WallType; - - Main.tile[trueX + 1, y - dy].ResetToType((ushort)ModContent.TileType()); - Main.tile[trueX + 1, y - dy].TileFrameX = (short)(style * 36 + 18); - Main.tile[trueX + 1, y - dy].TileFrameY = yFrame; - Main.tile[trueX + 1, y - dy].LiquidAmount = 255; - Main.tile[trueX + 1, y - dy].WallType = oldWall; - Main.tile[trueX + 1, y - dy].Get().HasTile = true; - } - previousX = trueX; - } - } - } - } - } - } - public static void PlaceStalactites() - { - int heightFromType(int type) - { - if (type <= 2) - return 2; - else if (type <= 4) - return 3; - else - return 4; - }; - for (int x = 1; x < BiomeWidth; x++) - { - int trueX = Abyss.AtLeftSideOfWorld ? x : Main.maxTilesX - x; - for (int y = YStart; y <= YStart + BlockDepth; y++) - { - if (y - YStart > BlockDepth * 0.25f) - { - if (WorldGen.SolidTile(trueX, y - 1) && WorldGen.genRand.NextBool(10)) - { - int dy = 1; - while (!CalamityUtils.ParanoidTileRetrieval(trueX, y + dy).HasTile) - { - dy++; - if (dy > StalactitePairMaxDistance) - break; - } - if (dy <= StalactitePairMaxDistance && dy >= StalactitePairMinDistance) - { - int type = WorldGen.genRand.Next(6); - type++; - int height = heightFromType(type); - - PlaceStalactite(trueX, y, height, (ushort)CalamityMod.Instance.Find($"SulphurousStalactite{type}").Type); - if (WorldGen.SolidTile(trueX, y + dy + 1)) - PlaceStalacmite(trueX, y + dy, height, (ushort)CalamityMod.Instance.Find($"SulphurousStalacmite{type}").Type); - } - } - } - } - } - } - public static void PlaceMiscTile(int x, int y, int width, int height, ushort type, int style = 0) - { - try - { - bool canGenerate = true; - for (int i = x; i < x + width; i++) - { - for (int j = y - (int)Math.Ceiling(height / 2.0); j < y + (int)Math.Ceiling(height / 2.0); j++) - { - if (Main.tile[i, j].HasTile) - { - canGenerate = false; - } - } - if (!Main.tile[i, y + 1].HasUnactuatedTile || Main.tile[i, y + 1].IsHalfBlock || Main.tile[i, y + 1].Slope != 0 || !Main.tileSolid[Main.tile[i, y + 1].TileType]) - { - canGenerate = false; - } - } - if (canGenerate) - { - WorldGen.PlaceTile(x, y, type, style: style); - } - } - catch - { - return; // This should only ever happen from an index error, and there's really no point in continuing if that happens - } - } - public static void PlaceStalactite(int x, int y, int height, ushort type) - { - for (int dy = 0; dy < height; dy++) - { - ushort oldWall = Main.tile[x, y + dy].WallType; - Main.tile[x, y + dy].ClearEverything(); - Main.tile[x, y + dy].WallType = oldWall; - Main.tile[x, y + dy].TileType = type; - Main.tile[x, y + dy].TileFrameY = (short)(dy * 18); - Main.tile[x, y + dy].Get().HasTile = true; - } - } - public static void PlaceStalacmite(int x, int y, int height, ushort type) - { - for (int dy = height - 1; dy > 0; dy--) - { - ushort oldWall = Main.tile[x, y + dy].WallType; - Main.tile[x, y - dy].ClearEverything(); - Main.tile[x, y - dy].WallType = oldWall; - Main.tile[x, y - dy].TileType = type; - Main.tile[x, y - dy].TileFrameY = (short)(height * 18 - dy * 18); - Main.tile[x, y - dy].Get().HasTile = true; - } - } - #endregion - - #region Generating Chests - public const int CheckCutoffDistance = 15; - public static void PlaceRustyChests() - { - // Ambiguity bullshit. - int[] ItemTypes = { ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType() }; - - for (int i = 0; i < ItemTypes.Length; ++i) - { - Chest chest = null; - int attempts = 0; - - while (chest is null) - { - attempts++; - int x = WorldGen.genRand.Next(CheckCutoffDistance, BiomeWidth - CheckCutoffDistance); - if (!Abyss.AtLeftSideOfWorld) - { - x = Main.maxTilesX - x; - } - int y = WorldGen.genRand.Next(YStart + CheckCutoffDistance, YStart + BlockDepth - CheckCutoffDistance); - if (WorldGen.InWorld(x, y)) - { - if (!CalamityUtils.ParanoidTileRetrieval(x, y).HasTile && - SulphSeaTiles.Contains(CalamityUtils.ParanoidTileRetrieval(x, y + 1).TileType) && - CalamityUtils.ParanoidTileRetrieval(x, y + 1).HasTile) - { - chest = MiscWorldgenRoutines.AddChestWithLoot(x, y, (ushort)ModContent.TileType()); - } - } - - if (attempts >= 5000) - break; - } - - if (attempts >= 5000) - continue; - - // If a chest was placed, force its first item to be the unique item. - if (chest != null) - { - chest.item[0].SetDefaults(ItemTypes[i]); - chest.item[0].Prefix(-1); - } - } - } - #endregion - - #region Removal of stupid Tiles above the Sea - - public static List OtherTilesForSulphSeaToDestroy = new() - { - TileID.PalmTree, - TileID.Sunflower, - TileID.CorruptThorns, - TileID.CrimsonThorns, - TileID.CorruptGrass, - TileID.CorruptPlants, - TileID.Stalactite, - TileID.ImmatureHerbs, - TileID.MatureHerbs, - TileID.Pots, - TileID.Pumpkins, // Happens during Halloween - TileID.FallenLog, - TileID.LilyPad, - TileID.VanityTreeSakura, - TileID.VanityTreeYellowWillow - }; - - public static List WallsForSulphSeaToDestroy = new() - { - WallID.Dirt, - WallID.DirtUnsafe, - WallID.DirtUnsafe1, - WallID.DirtUnsafe2, - WallID.DirtUnsafe3, - WallID.DirtUnsafe4, - WallID.Cave6Unsafe, // Rocky dirt wall - WallID.Grass, - WallID.GrassUnsafe, - WallID.Flower, - WallID.FlowerUnsafe, - WallID.CorruptGrassUnsafe, - WallID.EbonstoneUnsafe, - WallID.CrimstoneUnsafe, - }; public static void RemoveStupidTilesAboveSea() { - for (int x = 0; x < BiomeWidth; x++) + for (int i = 0; i < BiomeWidth; i++) { - int trueX = Abyss.AtLeftSideOfWorld ? x : Main.maxTilesX - x; + int x = GetActualX(i); for (int y = YStart - 140; y < YStart + 80; y++) { - int type = CalamityUtils.ParanoidTileRetrieval(trueX, y).TileType; + int type = CalamityUtils.ParanoidTileRetrieval(x, y).TileType; if (YStartWhitelist.Contains(type) || OtherTilesForSulphSeaToDestroy.Contains(type)) + CalamityUtils.ParanoidTileRetrieval(x, y).Get().HasTile = false; + if (WallsForSulphSeaToDestroy.Contains(CalamityUtils.ParanoidTileRetrieval(x, y).WallType)) + CalamityUtils.ParanoidTileRetrieval(x, y).WallType = 0; + } + } + } + + public static void GenerateShallowTopWater() + { + int maxDepth = MaxTopWaterDepth; + int totalSandTilesBeforeWater = WorldGen.genRand.Next(TotalSandTilesBeforeWaterMin, TotalSandTilesBeforeWaterMax); + int width = (int)((BiomeWidth - totalSandTilesBeforeWater) * 0.42f); + float descentSmoothness = WorldGen.genRand.NextFloat(TopWaterDescentSmoothnessMin, TopWaterDescentSmoothnessMax); + for (int i = 1; i < width; i++) + { + int x = GetActualX(i); + + // Calculate the 0-1 factor that determines how far down a vertical strip of water should descend. + float depthFactor = (float)Math.Pow(Math.Sin((1f - i / (float)width) * MathHelper.PiOver2), descentSmoothness); + + // Determine the top and botton of the water strip. + int top = YStart; + int bottom = top + (int)(maxDepth * depthFactor); + for (int y = top; y < bottom; y++) + { + if (y >= top + DepthForWater) + Main.tile[x, y].LiquidAmount = byte.MaxValue; + Main.tile[x, y].Get().HasTile = false; + } + + // Clear water that's above the level for some reason. + for (int y = top - 150; y < top + DepthForWater; y++) + Main.tile[x, y].LiquidAmount = 0; + } + } + + public static void GenerateSmallWaterCaverns() + { + int width = BiomeWidth; + int depth = BlockDepth; + int shallowWaterCaveCount = TotalCavesInShallowWater; + int minCaveWidth = MinCaveWidth; + int maxCaveWidth = MaxCaveWidth; + ushort wallID = (ushort)ModContent.WallType(); + + for (int i = 0; i < shallowWaterCaveCount; i++) + { + // Initialize variables for the cave. + int caveHorizontalOffset = WorldGen.genRand.Next((int)(width * 0.1f)); + int x = GetActualX((int)MathHelper.Lerp(width * 0.8f, width * 0.24f, i / (float)(shallowWaterCaveCount - 1f)) + caveHorizontalOffset); + int caveWidth = (minCaveWidth + maxCaveWidth) / 3 + WorldGen.genRand.Next(8); + int caveSteps = WorldGen.genRand.Next(MinCaveMovementSteps, MaxCaveMovementSteps); + int caveSeed = WorldGen.genRand.Next(); + Vector2 baseCaveDirection = Vector2.UnitY.RotatedBy(WorldGen.genRand.NextFloatDirection() * 0.54f); + Vector2 cavePosition = new(x, YStart + MaxTopWaterDepth + DepthForWater / 2); + + for (int j = 0; j < caveSteps; j++) + { + // Make the cave direction turn based on perlin noise. + float caveOffsetAngleAtStep = CalamityUtils.PerlinNoise2D(i / 50f, j / 50f, 4, caveSeed) * MathHelper.Pi * 1.9f; + Vector2 caveDirection = baseCaveDirection.RotatedBy(caveOffsetAngleAtStep); + + // Carve out at the current position. + if (cavePosition.X < Main.maxTilesX - 15 && cavePosition.X >= 15) { - CalamityUtils.ParanoidTileRetrieval(trueX, y).Get().HasTile = false; + WorldGen.digTunnel(cavePosition.X, cavePosition.Y, caveDirection.X, caveDirection.Y, 1, (int)(caveWidth * 1.18f), true); + WorldUtils.Gen(cavePosition.ToPoint(), new Shapes.Circle(caveWidth), Actions.Chain(new GenAction[] + { + new Actions.ClearTile(true), + new Actions.PlaceWall(wallID, true), + new Actions.SetLiquid() + })); } - if (WallsForSulphSeaToDestroy.Contains(CalamityUtils.ParanoidTileRetrieval(trueX, y).WallType)) + + // Update the cave position. + cavePosition += caveDirection * caveWidth; + + // Turn back if the cave position is close to leaving the sea. + if (GetActualX((int)cavePosition.X) > width * 0.8f || cavePosition.Y > YStart + depth * 0.7f) { - CalamityUtils.ParanoidTileRetrieval(trueX, y).WallType = 0; + cavePosition.X -= Abyss.AtLeftSideOfWorld.ToDirectionInt() * caveWidth; + cavePosition.Y -= caveWidth; + } + + // Update the cave width for the next update step. + float caveWidthFactorInterpolant = (float)Math.Pow(WorldGen.genRand.NextFloat(), SmallCavesBiasTowardsTightness); + caveWidth = (int)Math.Round(caveWidth * MathHelper.Lerp(1f - SmallCavesJaggedness, 1f + SmallCavesJaggedness, caveWidthFactorInterpolant)); + if (WorldGen.genRand.NextBool(12)) + caveWidth = (int)(caveWidth * 1.4f); + + caveWidth = Utils.Clamp(caveWidth, minCaveWidth, maxCaveWidth); + } + } + } + + public static void GenerateSpaghettiWaterCaves() + { + int width = (int)(BiomeWidth * 0.96f); + int depth = (int)(BlockDepth * 0.9f); + ushort wallID = (ushort)ModContent.WallType(); + + for (int c = 0; c < SpaghettiCaveCarveOutThresholds.Length; c++) + { + int caveSeed = WorldGen.genRand.Next(10000000); + for (int i = 1; i < width; i++) + { + // Initialize variables for the cave. + int x = GetActualX(i); + for (int y = YStart; y < YStart + depth; y++) + { + float noise = FractalBrownianMotion(i * SpaghettiCaveMagnification, y * SpaghettiCaveMagnification, caveSeed, 5); + + // Bias noise away from 0, effectively making caves less likely to appear, based on how close it is to the bottom/horizontal edge. + // This causes caves to naturally stop as the reach ends instead of abruptly stopping like in the old Sulphurous Sea worldgen. + float biasAwayFrom0Interpolant = Utils.GetLerpValue(0.92f, 0.96f, i / (float)width, true) + Utils.GetLerpValue(0.86f, 0.9f, (y - YStart) / (float)depth, true); + + // If the noise is less than 0, bias to -1, if it's greater than 0, bias away to 1. + // This is done instead of biasing to -1 or 1 without exception to ensure that in doing so the noise does not cross into the + // cutout threshold near 0 as it interpolates. + noise = MathHelper.Lerp(noise, Math.Sign(noise), biasAwayFrom0Interpolant); + + if (Math.Abs(noise) < SpaghettiCaveCarveOutThresholds[c]) + { + WorldUtils.Gen(new(x, y), new Shapes.Rectangle(1, 1), Actions.Chain(new GenAction[] + { + new Actions.ClearTile(true), + new Actions.PlaceWall(wallID, true), + new Actions.SetLiquid() + })); + } } } } } - #endregion - #region Nearby Beach - public static readonly List ValidBeachCovertTiles = new() + public static void GenerateCheeseWaterCaves() { - TileID.Dirt, - TileID.Stone, - TileID.Crimstone, - TileID.Ebonstone, - TileID.Sand, - TileID.Ebonsand, - TileID.Crimsand, - TileID.Grass, - TileID.CorruptGrass, - TileID.CrimsonGrass, - TileID.ClayBlock, - TileID.Mud, - }; - public static readonly List ValidBeachDestroyTiles = new() - { - TileID.Coral, - TileID.BeachPiles, - TileID.Plants, - TileID.Plants2, - TileID.SmallPiles, - TileID.LargePiles, - TileID.LargePiles2, - TileID.CorruptThorns, - TileID.CrimsonThorns, - TileID.DyePlants, - TileID.Trees, - TileID.Sunflower, - }; - public static void CreateBeachNearSea() - { - int beachWidth = WorldGen.genRand.Next(150, 190 + 1); + int width = (int)(BiomeWidth * 0.9f); + int depth = (int)(BlockDepth * 0.9f); + ushort wallID = (ushort)ModContent.WallType(); - var searchCondition = Searches.Chain(new Searches.Down(3000), new Conditions.IsSolid()); - WorldUtils.Find(new Point(BiomeWidth + 4, (int)WorldGen.worldSurfaceLow - 20), searchCondition, out Point determinedPoint); - Tile tileAtEdge = CalamityUtils.ParanoidTileRetrieval(determinedPoint.X, determinedPoint.Y); - - // Extend outward to encompass some of the desert, if there is one. - if (tileAtEdge.TileType == TileID.Sand || - tileAtEdge.TileType == TileID.Ebonsand || - tileAtEdge.TileType == TileID.Crimsand) + for (int c = 0; c < CheeseCaveCarveOutThresholds.Length; c++) { - beachWidth += 85; - } - - for (int x = BiomeWidth - 10; x <= BiomeWidth + beachWidth; x++) - { - float xRatio = Utils.GetLerpValue(BiomeWidth - 10, BiomeWidth + beachWidth, x, true); - int trueX = Abyss.AtLeftSideOfWorld ? x : Main.maxTilesX - x; - int depth = (int)(Math.Sin((1f - xRatio) * MathHelper.PiOver2) * 45 + 1); - for (int y = YStart - 40; y < YStart + depth; y++) + int caveSeed = WorldGen.genRand.Next(10000000); + for (int i = 1; i < width; i++) { - Tile tileAtPosition = CalamityUtils.ParanoidTileRetrieval(trueX, y); - if (tileAtPosition.HasTile && ValidBeachDestroyTiles.Contains(tileAtPosition.TileType)) + // Initialize variables for the cave. + int x = GetActualX(i); + for (int y = YStart; y < YStart + depth; y++) { - // Kill trees manually so that no leftover tiles are present. - if (Main.tile[trueX, y].TileType == TileID.Trees) - WorldGen.KillTile(trueX, y); - else - Main.tile[trueX, y].Get().HasTile = false; - } - - else if (tileAtPosition.HasTile && ValidBeachCovertTiles.Contains(tileAtPosition.TileType)) - { - Main.tile[trueX, y].TileType = (ushort)ModContent.TileType(); + float noise = FractalBrownianMotion(i * CheeseCaveMagnification, y * CheeseCaveMagnification, caveSeed, 6); + float biasToNegativeOneInterpolant = Utils.GetLerpValue(0.86f, 0.9f, i / (float)width, true) + Utils.GetLerpValue(0.86f, 0.9f, (y - YStart) / (float)depth, true); + biasToNegativeOneInterpolant += Utils.GetLerpValue(YStart + OpenCavernStartDepthPercentage * depth, YStart + OpenCavernStartDepthPercentage * depth - 25f, y, true); + if (noise - biasToNegativeOneInterpolant * 6f > CheeseCaveCarveOutThresholds[c]) + { + WorldUtils.Gen(new(x, y), new Shapes.Rectangle(1, 1), Actions.Chain(new GenAction[] + { + new Actions.ClearTile(true), + new Actions.PlaceWall(wallID, true), + new Actions.SetLiquid() + })); + } } } } - - // Plant new trees. - for (int x = BiomeWidth - 10; x <= BiomeWidth + beachWidth; x++) - { - int trueX = Abyss.AtLeftSideOfWorld ? x : Main.maxTilesX - x; - if (!WorldGen.genRand.NextBool(10)) - continue; - - int y = YStart - 30; - if (!WorldUtils.Find(new Point(trueX, y), Searches.Chain(new Searches.Down(100), new Conditions.IsTile((ushort)ModContent.TileType())), out Point treePlantPosition)) - continue; - - WorldGen.PlaceTile(treePlantPosition.X, treePlantPosition.Y - 1, ModContent.TileType()); - } } - #endregion - #region Scrap Piles - public static void PlaceScrapPiles() + public static void ClearOutStrayTiles() { - int tries = 0; - List pastPlacementPostiion = new List(); - for (int i = 0; i < 3; i++) + int width = BiomeWidth; + int depth = BlockDepth; + ushort blockTileType = (ushort)ModContent.TileType(); + ushort wallID = (ushort)ModContent.WallType(); + + void recursivelyGetAttachedPoints(int x, int y, List points) { - tries++; - if (tries > 20000) - continue; + Tile t = CalamityUtils.ParanoidTileRetrieval(x, y); + Point p = new(x, y); + if (t.TileType != blockTileType || !t.HasTile || points.Count > 512 || points.Contains(p)) + return; - int x = WorldGen.genRand.Next(75, BiomeWidth - 85); - if (!Abyss.AtLeftSideOfWorld) - x = Main.maxTilesX - x; - int y = WorldGen.genRand.Next(YStart + (int)(BlockDepth * 0.3f), YStart + (int)(BlockDepth * 0.8f)); + points.Add(p); - Point pilePlacementPosition = new Point(x, y); + recursivelyGetAttachedPoints(x + 1, y, points); + recursivelyGetAttachedPoints(x - 1, y, points); + recursivelyGetAttachedPoints(x, y + 1, points); + recursivelyGetAttachedPoints(x, y - 1, points); + } - // If the selected position is sitting inside of a tile, try again. - if (WorldGen.SolidTile(pilePlacementPosition.X, pilePlacementPosition.Y)) + + // Clear out stray chunks created by caverns. + for (int i = 1; i < width; i++) + { + int x = GetActualX(i); + for (int y = YStart; y < YStart + depth; y++) { - i--; - continue; + List chunkPoints = new(); + recursivelyGetAttachedPoints(x, y, chunkPoints); + + int cutoffLimit = y >= YStart + depth * OpenCavernStartDepthPercentage ? 512 : 50; + if (chunkPoints.Count >= 2 && chunkPoints.Count < cutoffLimit) + { + foreach (Point p in chunkPoints) + { + WorldUtils.Gen(p, new Shapes.Rectangle(1, 1), Actions.Chain(new GenAction[] + { + new Actions.ClearTile(true), + new Actions.PlaceWall(wallID, true), + new Actions.SetLiquid() + })); + } + } } - - // If the selected position is close to other piles, try again. - if (pastPlacementPostiion.Any(p => Vector2.Distance(p, pilePlacementPosition.ToVector2()) < 85f)) - { - i--; - continue; - } - - // Otherwise, decide which pile should be created. - int pileVariant = WorldGen.genRand.Next(7); - string schematicName = $"Sulphurous Scrap {pileVariant + 1}"; - Vector2? wrappedSchematicArea = SchematicManager.GetSchematicArea(schematicName); - - // Create a log message if for some reason the schematic in question doesn't exist. - if (!wrappedSchematicArea.HasValue) - { - CalamityMod.Instance.Logger.Warn($"Tried to place a schematic with name \"{schematicName}\". No matching schematic file found."); - continue; - } - - Vector2 schematicArea = wrappedSchematicArea.Value; - - // Decide the placement position by searching downward and looking for the lowest point. - // If the position is quite steep, try again. - Vector2 left = pilePlacementPosition.ToVector2() - Vector2.UnitX * schematicArea.X * 0.5f; - Vector2 right = pilePlacementPosition.ToVector2() + Vector2.UnitX * schematicArea.X * 0.5f; - while (!WorldGen.SolidTile(CalamityUtils.ParanoidTileRetrieval((int)left.X, (int)left.Y))) - left.Y++; - while (!WorldGen.SolidTile(CalamityUtils.ParanoidTileRetrieval((int)right.X, (int)right.Y))) - right.Y++; - - if (Math.Abs(left.Y - right.Y) >= 20f) - { - i--; - continue; - } - - // If the placement position ended up in the abyss, try again. - if (left.Y >= YStart + BlockDepth + 5 || right.Y >= YStart + BlockDepth + 5) - { - i--; - continue; - } - - // Pick the lowest point vertically. - Point bottomCenter = new Point(pilePlacementPosition.X, (int)Math.Max(left.Y, right.Y) + 6); - bool _ = false; - SchematicManager.PlaceSchematic>(schematicName, bottomCenter, SchematicAnchor.BottomCenter, ref _); - - pastPlacementPostiion.Add(bottomCenter.ToVector2()); - tries = 0; } } - #endregion Scrap Piles + + public static void DecideHardSandstoneLine() + { + int width = BiomeWidth; + int depth = BlockDepth; + + int sandstoneSeed = WorldGen.genRand.Next(); + ushort blockTypeToReplace = (ushort)ModContent.TileType(); + ushort blockTypeToPlace = (ushort)ModContent.TileType(); + ushort wallID = (ushort)ModContent.WallType(); + for (int i = 0; i < width; i++) + { + for (int y = YStart; y < YStart + depth; y++) + { + int sandstoneLineOffset = (int)(FractalBrownianMotion(i * 0.004f, y * 0.004f, sandstoneSeed, 7) * 30) + depth / 2; + + // Make the sandstone line descent a little bit the closer it is to the world edge, to make it look like it "warps" towards the abyss. + sandstoneLineOffset -= (int)(Math.Pow(Utils.GetLerpValue(width * 0.1f, width * 0.8f, i, true), 1.72f) * 45f); + + Point p = new(GetActualX(i), y); + Tile t = CalamityUtils.ParanoidTileRetrieval(p.X, p.Y); + if (y >= YStart + sandstoneLineOffset && t.HasTile && t.TileType == blockTypeToReplace) + { + WorldUtils.Gen(p, new Shapes.Rectangle(1, 1), Actions.Chain(new GenAction[] + { + new Actions.SetTile(blockTypeToPlace, true), + new Actions.PlaceWall(wallID, true), + new Actions.SetLiquid() + })); + } + } + } + } + #endregion Generation Functions #region Misc Functions - public static List YStartWhitelist = new() + public static readonly List YStartWhitelist = new() { TileID.Stone, TileID.Dirt, @@ -952,11 +490,60 @@ namespace CalamityMod.World TileID.CrimsonVines, TileID.Containers, TileID.DyePlants, - TileID.JungleGrass // Yes, this can happen on rare occasion + TileID.JungleGrass, // Yes, this can happen on rare occasion. + TileID.SeaOats }; + + public static readonly List OtherTilesForSulphSeaToDestroy = new() + { + TileID.PalmTree, + TileID.Sunflower, + TileID.CorruptThorns, + TileID.CrimsonThorns, + TileID.CorruptGrass, + TileID.CorruptPlants, + TileID.Stalactite, + TileID.ImmatureHerbs, + TileID.MatureHerbs, + TileID.Pots, + TileID.Pumpkins, // Happens during Halloween + TileID.FallenLog, + TileID.LilyPad, + TileID.VanityTreeSakura, + TileID.VanityTreeYellowWillow, + TileID.ShellPile + }; + + public static readonly List WallsForSulphSeaToDestroy = new() + { + WallID.Dirt, + WallID.DirtUnsafe, + WallID.DirtUnsafe1, + WallID.DirtUnsafe2, + WallID.DirtUnsafe3, + WallID.DirtUnsafe4, + WallID.Cave6Unsafe, // Rocky dirt wall + WallID.Grass, + WallID.GrassUnsafe, + WallID.Flower, + WallID.FlowerUnsafe, + WallID.CorruptGrassUnsafe, + WallID.EbonstoneUnsafe, + WallID.CrimstoneUnsafe, + }; + + // This method is an involutory function, meaning that applying it to the same number twice always yields the original number. + public static int GetActualX(int x) + { + if (Abyss.AtLeftSideOfWorld) + return x; + + return Main.maxTilesX - x; + } + public static void DetermineYStart() { - int xCheckPosition = Abyss.AtLeftSideOfWorld ? BiomeWidth + 1 : Main.maxTilesX - BiomeWidth - 1; + int xCheckPosition = GetActualX(BiomeWidth + 1); var searchCondition = Searches.Chain(new Searches.Down(3000), new Conditions.IsSolid()); Point determinedPoint; @@ -968,6 +555,41 @@ namespace CalamityMod.World while (CalamityUtils.ParanoidTileRetrieval(determinedPoint.X, determinedPoint.Y).TileType == TileID.Ebonstone); YStart = determinedPoint.Y; } + + public static float CalculateDitherChance(int width, int top, int bottom, int x, int y) + { + float verticalCompletion = Utils.GetLerpValue(top, bottom, y, true); + float horizontalDitherChance = Utils.GetLerpValue(DitherStartFactor, 1f, x / (float)width, true); + float verticalDitherChance = Utils.GetLerpValue(DitherStartFactor, 1f, verticalCompletion, true); + float ditherChance = horizontalDitherChance + verticalDitherChance; + if (ditherChance > 1f) + ditherChance = 1f; + + // Make the dither chance fizzle out at low vertical completion values. + // This is done so that there isn't dithering on the surface of the sea. + ditherChance -= Utils.GetLerpValue(0.56f, 0.5f, verticalCompletion, true); + if (ditherChance < 0f) + ditherChance = 0f; + return ditherChance; + } + + public static float FractalBrownianMotion(float x, float y, int seed, int octaves, float gain = 0.5f, float lacunarity = 2f) + { + float result = 0f; + float frequency = 1f; + float amplitude = 0.5f; + x += seed * 0.00489937f % 10f; + + for (int i = 0; i < octaves; i++) + { + float noise = NoiseHelper.GetStaticNoise(new Vector2(x, y) * frequency) * 2f - 1f; + result += noise * amplitude; + amplitude *= gain; + frequency *= lacunarity; + } + + return result; + } #endregion } } From 6d7df47760b04d5a99289ec545ea72b84c1c1f10 Mon Sep 17 00:00:00 2001 From: Dominic Date: Thu, 6 Oct 2022 16:13:14 -0500 Subject: [PATCH 02/21] Better ground smoothing for the top of the sea --- Items/Placeables/SulphurousSand.cs | 2 +- Systems/BiomeTileCounterSystem.cs | 2 +- Systems/MiscWorldStateSystem.cs | 3 + Systems/WorldSyncingSystem.cs | 2 + Tiles/Abyss/AcidWoodTree.cs | 2 +- Tiles/Abyss/AcidWoodTreeSapling.cs | 2 +- Tiles/Abyss/HardenedSulphurousSandstone.cs | 5 +- Tiles/Abyss/SulphurousCactus.cs | 2 +- Tiles/Abyss/SulphurousSand.cs | 87 +----------------- Tiles/Abyss/SulphurousSandNoWater.cs | 38 -------- Tiles/Abyss/SulphurousSandNoWater.png | Bin 19561 -> 0 bytes Tiles/Abyss/SulphurousSandstone.cs | 5 +- World/SulphurousSea.cs | 98 ++++++++++++++++++--- World/WorldEvilIsland.cs | 4 +- 14 files changed, 109 insertions(+), 143 deletions(-) delete mode 100644 Tiles/Abyss/SulphurousSandNoWater.cs delete mode 100644 Tiles/Abyss/SulphurousSandNoWater.png diff --git a/Items/Placeables/SulphurousSand.cs b/Items/Placeables/SulphurousSand.cs index 310fbdcefb..543e412329 100644 --- a/Items/Placeables/SulphurousSand.cs +++ b/Items/Placeables/SulphurousSand.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Placeables public override void SetDefaults() { - Item.createTile = ModContent.TileType(); + Item.createTile = ModContent.TileType(); Item.useStyle = ItemUseStyleID.Swing; Item.useTurn = true; Item.useAnimation = 15; diff --git a/Systems/BiomeTileCounterSystem.cs b/Systems/BiomeTileCounterSystem.cs index b5a75c904a..2014276dcf 100644 --- a/Systems/BiomeTileCounterSystem.cs +++ b/Systems/BiomeTileCounterSystem.cs @@ -33,7 +33,7 @@ namespace CalamityMod.Systems BrimstoneCragTiles = tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()]; SunkenSeaTiles = tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()]; AbyssTiles = tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()]; - SulphurTiles = tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()]; + SulphurTiles = tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()]; int astralDesertTiles = tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()]; int astralSnowTiles = tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()]; diff --git a/Systems/MiscWorldStateSystem.cs b/Systems/MiscWorldStateSystem.cs index 3024723608..84e7cadfb3 100644 --- a/Systems/MiscWorldStateSystem.cs +++ b/Systems/MiscWorldStateSystem.cs @@ -51,6 +51,7 @@ namespace CalamityMod BossRushEvent.HostileProjectileKillCounter = 0; CustomTemple.NewAlterPosition = Point.Zero; Abyss.AbyssChasmBottom = 0; + SulphurousSea.YStart = 0; Abyss.AtLeftSideOfWorld = false; spawnedBandit = false; @@ -130,6 +131,7 @@ namespace CalamityMod tag["downed"] = downed; tag["abyssChasmBottom"] = Abyss.AbyssChasmBottom; + tag["SulphSeaYStart"] = SulphurousSea.YStart; tag["acidRainPoints"] = AcidRainEvent.AccumulatedKillPoints; tag["Reforges"] = Reforges; tag["MoneyStolenByBandit"] = MoneyStolenByBandit; @@ -176,6 +178,7 @@ namespace CalamityMod RecipeUnlockHandler.Load(downed); Abyss.AbyssChasmBottom = tag.GetInt("abyssChasmBottom"); + SulphurousSea.YStart = tag.GetInt("SulphSeaYStart"); AcidRainEvent.AccumulatedKillPoints = tag.GetInt("acidRainPoints"); Reforges = tag.GetInt("Reforges"); MoneyStolenByBandit = tag.GetInt("MoneyStolenByBandit"); diff --git a/Systems/WorldSyncingSystem.cs b/Systems/WorldSyncingSystem.cs index 93716eeea5..19ab8a6f40 100644 --- a/Systems/WorldSyncingSystem.cs +++ b/Systems/WorldSyncingSystem.cs @@ -140,6 +140,7 @@ namespace CalamityMod.Systems RecipeUnlockHandler.SendData(writer); writer.Write(Abyss.AbyssChasmBottom); + writer.Write(SulphurousSea.YStart); writer.Write(AcidRainEvent.AccumulatedKillPoints); writer.Write(Reforges); writer.Write(MoneyStolenByBandit); @@ -271,6 +272,7 @@ namespace CalamityMod.Systems RecipeUnlockHandler.ReceiveData(reader); Abyss.AbyssChasmBottom = reader.ReadInt32(); + SulphurousSea.YStart = reader.ReadInt32(); AcidRainEvent.AccumulatedKillPoints = reader.ReadInt32(); Reforges = reader.ReadInt32(); MoneyStolenByBandit = reader.ReadInt32(); diff --git a/Tiles/Abyss/AcidWoodTree.cs b/Tiles/Abyss/AcidWoodTree.cs index 8d962c32f2..33a3c0da10 100644 --- a/Tiles/Abyss/AcidWoodTree.cs +++ b/Tiles/Abyss/AcidWoodTree.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Tiles.Abyss public override void SetStaticDefaults() { // Grows on sulphurous sand - GrowsOnTileId = new int[2] { ModContent.TileType() , ModContent.TileType()}; + GrowsOnTileId = new int[] { ModContent.TileType() }; } //Copypasted from vanilla, just as ExampleMod did, due to the lack of proper explanation diff --git a/Tiles/Abyss/AcidWoodTreeSapling.cs b/Tiles/Abyss/AcidWoodTreeSapling.cs index f663acb9af..9b918234c4 100644 --- a/Tiles/Abyss/AcidWoodTreeSapling.cs +++ b/Tiles/Abyss/AcidWoodTreeSapling.cs @@ -34,7 +34,7 @@ namespace CalamityMod.Tiles.Abyss TileObjectData.newTile.CoordinateHeights = new[] { 16, 18 }; TileObjectData.newTile.CoordinateWidth = 16; TileObjectData.newTile.CoordinatePadding = 2; - TileObjectData.newTile.AnchorValidTiles = new[] { ModContent.TileType(), ModContent.TileType(), ModContent.TileType(), ModContent.TileType() }; + TileObjectData.newTile.AnchorValidTiles = new[] { ModContent.TileType(), ModContent.TileType(), ModContent.TileType() }; TileObjectData.newTile.StyleHorizontal = true; TileObjectData.newTile.DrawFlipHorizontal = true; TileObjectData.newTile.WaterPlacement = LiquidPlacement.NotAllowed; diff --git a/Tiles/Abyss/HardenedSulphurousSandstone.cs b/Tiles/Abyss/HardenedSulphurousSandstone.cs index e934eabebf..fb6a4cd909 100644 --- a/Tiles/Abyss/HardenedSulphurousSandstone.cs +++ b/Tiles/Abyss/HardenedSulphurousSandstone.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using CalamityMod.World; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -57,7 +58,7 @@ namespace CalamityMod.Tiles.Abyss } } } - if (Main.tile[i, j + 1] != null && nearbyVineCount < 5) + if (Main.tile[i, j + 1] != null && nearbyVineCount < 5 && j >= SulphurousSea.VineGrowTopLimit) { if (!Main.tile[i, j + 1].HasTile && Main.tile[i, j + 1].TileType != (ushort)ModContent.TileType()) { diff --git a/Tiles/Abyss/SulphurousCactus.cs b/Tiles/Abyss/SulphurousCactus.cs index 37ae76e5c4..98ad27e66f 100644 --- a/Tiles/Abyss/SulphurousCactus.cs +++ b/Tiles/Abyss/SulphurousCactus.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.Abyss public override void SetStaticDefaults() { // Grows on sulphurous sand - GrowsOnTileId = new int[2] { ModContent.TileType(), ModContent.TileType() }; + GrowsOnTileId = new int[] { ModContent.TileType() }; } public override Asset GetTexture() => ModContent.Request("CalamityMod/Tiles/Abyss/SulphurousCactus"); diff --git a/Tiles/Abyss/SulphurousSand.cs b/Tiles/Abyss/SulphurousSand.cs index 72836b8cfa..7b2993cc2b 100644 --- a/Tiles/Abyss/SulphurousSand.cs +++ b/Tiles/Abyss/SulphurousSand.cs @@ -1,6 +1,7 @@  using CalamityMod.CalPlayer; using CalamityMod.Projectiles.Enemy; +using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -32,89 +33,7 @@ namespace CalamityMod.Tiles.Abyss { num = fail ? 1 : 3; } - - public override void NearbyEffects(int i, int j, bool closer) - { - if (i < 250 && i > 150) - { - if (!closer) - { - if (Main.tile[i - 1, j] != null) - { - if (!Main.tile[i - 1, j].HasTile) - { - if (Main.tile[i - 1, j].LiquidAmount <= 128) - { - Main.tile[i - 1, j].LiquidAmount = 255; - Main.tile[i - 1, j].Get().LiquidType = LiquidID.Water; - } - } - } - if (Main.tile[i - 2, j] != null) - { - if (!Main.tile[i - 2, j].HasTile) - { - if (Main.tile[i - 2, j].LiquidAmount <= 128) - { - Main.tile[i - 2, j].LiquidAmount = 255; - Main.tile[i - 2, j].Get().LiquidType = LiquidID.Water; - } - } - } - if (Main.tile[i - 3, j] != null) - { - if (!Main.tile[i - 3, j].HasTile) - { - if (Main.tile[i - 3, j].LiquidAmount <= 128) - { - Main.tile[i - 3, j].LiquidAmount = 255; - Main.tile[i - 3, j].Get().LiquidType = LiquidID.Water; - } - } - } - } - } - else if (i > Main.maxTilesX - 250 && i < Main.maxTilesX - 150) - { - if (!closer) - { - if (Main.tile[i + 1, j] != null) - { - if (!Main.tile[i + 1, j].HasTile) - { - if (Main.tile[i + 1, j].LiquidAmount <= 128) - { - Main.tile[i + 1, j].LiquidAmount = 255; - Main.tile[i + 1, j].Get().LiquidType = LiquidID.Water; - } - } - } - if (Main.tile[i + 2, j] != null) - { - if (!Main.tile[i + 2, j].HasTile) - { - if (Main.tile[i + 2, j].LiquidAmount <= 128) - { - Main.tile[i + 2, j].LiquidAmount = 255; - Main.tile[i + 2, j].Get().LiquidType = LiquidID.Water; - } - } - } - if (Main.tile[i + 3, j] != null) - { - if (!Main.tile[i + 3, j].HasTile) - { - if (Main.tile[i + 3, j].LiquidAmount <= 128) - { - Main.tile[i + 3, j].LiquidAmount = 255; - Main.tile[i + 3, j].Get().LiquidType = LiquidID.Water; - } - } - } - } - } - } - + public override void KillTile(int i, int j, ref bool fail, ref bool effectOnly, ref bool noItem) { if (CalamityUtils.ParanoidTileRetrieval(i, j + 1).HasTile && @@ -210,7 +129,7 @@ namespace CalamityMod.Tiles.Abyss } } } - if (Main.tile[i, j + 1] != null && nearbyVineCount < 5) + if (Main.tile[i, j + 1] != null && nearbyVineCount < 5 && j >= SulphurousSea.VineGrowTopLimit) { if (!Main.tile[i, j + 1].HasTile && Main.tile[i, j + 1].TileType != (ushort)ModContent.TileType()) { diff --git a/Tiles/Abyss/SulphurousSandNoWater.cs b/Tiles/Abyss/SulphurousSandNoWater.cs deleted file mode 100644 index 76edcb0598..0000000000 --- a/Tiles/Abyss/SulphurousSandNoWater.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ModLoader; -using Terraria.ID; - -namespace CalamityMod.Tiles.Abyss -{ - public class SulphurousSandNoWater : ModTile - { - public override void SetStaticDefaults() - { - Main.tileSolid[Type] = true; - Main.tileBlockLight[Type] = true; - - CalamityUtils.MergeWithGeneral(Type); - CalamityUtils.MergeWithAbyss(Type); - - TileID.Sets.CanBeDugByShovel[Type] = true; - - DustType = 32; - ItemDrop = ModContent.ItemType(); - AddMapEntry(new Color(150, 100, 50)); - MineResist = 1f; - HitSound = SoundID.Dig; - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 3; - } - - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - TileFraming.CustomMergeFrame(i, j, Type, ModContent.TileType(), false, false, false, false, resetFrame); - return false; - } - } -} diff --git a/Tiles/Abyss/SulphurousSandNoWater.png b/Tiles/Abyss/SulphurousSandNoWater.png deleted file mode 100644 index 180882767cacd730710c589003ecbd91d0dddd10..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 19561 zcmYIwcQ}>*|9_Iqa6(3oaU`LLlI@6Nmc6&^%&cRdgUBJ-$`%>n*ddOQY}wgc#<7ld zGLOUW^r`pv_lL`Mxwy`K?sGpM&&PU+)KpixLBT?C<;s;CD#{S;D_4j(2w&7>*9kx2 z5m*?lrUmDQ!Xc_cu ziHrsqEqw;n1A`?y;6eeBV*j&)s_Ux(A1K*BSGdnFmjcj)iOlJ7S+7 zSz(kb(UbiFEhpGjeq#y{h*BcWu`2Q4^83ChDR%RcaVJ1$(NaMxiBkRTq+5X!jXhJE4*Y1 zuL5*O2CH&akSr`tn6*G45ZLcebZdFyST*SHZm-Jo#w=M#uv@3(j^Wbe)J3-^2_Sw~ zDlkCk$Nn}W6LTsr0^#Ld>W=ejOBx2cIV`D^W`-#PmFZF&M+k!6$yi+yQ*Svf8;Y9@AyDogQ3nwMb2t1LAV;y~|f{u;~=N00dlV zcHh5oJo0T=_x1TqY72QeYCf=eYyVRW-tFSlWxVaQ*e#t@$B!X02R>f=)Nm0S}2K_x5_sGnJ&hfw1Cq(cK5BT zd+&OaQ*(@7@3>-@12AKhQ6QBkKqKFCI}+2>sAC|;4$>58n_m5%)aFp>GmJFeLO6kw zQRr6&y$NNfx2zCc)35i!(xz{EkW}A$ zUf!9H3>~B%=n4|V-vpic_haF((cgn`ffoW#*B4h$!X8GMc00D_p6ieDZ{E87V?})y#z$#N2d}Wb$H-%jKY$R{J1!x z8*d{mavHJ?^JuX=w^ZC+ImQKIrMt2X!5Kg zGh(;W1K`NNLrlx!F5@%ULI;SiR}tNsYy1{yUvu9XDq~SK+6V>*%r~bAb{o+lx<|jB z2Ks-mnXp+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_c?@t^=e{=YX2?&oyjRv}9|@ z(YJ{C+J!1%r096VRjpg a0gA~u6`Hx!cNXvtld-WphklImj{6%NB%$8` diff --git a/Tiles/Abyss/SulphurousSandstone.cs b/Tiles/Abyss/SulphurousSandstone.cs index b8f1c46a5b..ef03d8eda5 100644 --- a/Tiles/Abyss/SulphurousSandstone.cs +++ b/Tiles/Abyss/SulphurousSandstone.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using CalamityMod.World; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -57,7 +58,7 @@ namespace CalamityMod.Tiles.Abyss } } } - if (Main.tile[i, j + 1] != null && nearbyVineCount < 5) + if (Main.tile[i, j + 1] != null && nearbyVineCount < 5 && j >= SulphurousSea.VineGrowTopLimit) { if (!Main.tile[i, j + 1].HasTile && Main.tile[i, j + 1].TileType != (ushort)ModContent.TileType()) { diff --git a/World/SulphurousSea.cs b/World/SulphurousSea.cs index 6be657f96f..547ff751c0 100644 --- a/World/SulphurousSea.cs +++ b/World/SulphurousSea.cs @@ -74,7 +74,15 @@ namespace CalamityMod.World }; // Percentage of how far down a tile has to be for open caverns to appear. - public const float OpenCavernStartDepthPercentage = 0.5f; + public const float OpenCavernStartDepthPercentage = 0.42f; + + public const float HardenedSandstoneLineMagnification = 0.004f; + + public const int MaxIslandHeight = 16; + + public const int MaxIslandDepth = 9; + + public const float IslandLineMagnification = 0.0079f; public static int BiomeWidth { @@ -113,13 +121,13 @@ namespace CalamityMod.World } } - public static int TotalCavesInShallowWater => (int)Math.Ceiling(Main.maxTilesX / 1300f); + public static int TotalCavesInShallowWater => (int)Math.Ceiling(Main.maxTilesX / 2000f); public static int MaxTopWaterDepth => (int)(BlockDepth * TopWaterDepthPercentage); public static int MinCaveWidth => (int)(Main.maxTilesX / 2500f); - public static int MaxCaveWidth => (int)Math.Ceiling(Main.maxTilesX / 376f); + public static int MaxCaveWidth => (int)Math.Ceiling(Main.maxTilesX / 566f); public static int MinCaveMovementSteps => (int)Math.Ceiling(Main.maxTilesX / 70f); @@ -130,6 +138,9 @@ namespace CalamityMod.World get; set; } + + // Vines cannot grow any higher than this. This is done to prevent vines from growing very close to the sea surface. + public static int VineGrowTopLimit => YStart + 100; #endregion #region Placement Methods @@ -148,7 +159,9 @@ namespace CalamityMod.World ClearOutStrayTiles(); // Lay down decorations after the caves are generated. + ClearAloneTiles(); DecideHardSandstoneLine(); + MakeSurfaceLessRigid(); } public static void FinishGeneratingSulphurSea() @@ -305,7 +318,7 @@ namespace CalamityMod.World for (int c = 0; c < SpaghettiCaveCarveOutThresholds.Length; c++) { - int caveSeed = WorldGen.genRand.Next(10000000); + int caveSeed = WorldGen.genRand.Next(); for (int i = 1; i < width; i++) { // Initialize variables for the cave. @@ -316,7 +329,7 @@ namespace CalamityMod.World // Bias noise away from 0, effectively making caves less likely to appear, based on how close it is to the bottom/horizontal edge. // This causes caves to naturally stop as the reach ends instead of abruptly stopping like in the old Sulphurous Sea worldgen. - float biasAwayFrom0Interpolant = Utils.GetLerpValue(0.92f, 0.96f, i / (float)width, true) + Utils.GetLerpValue(0.86f, 0.9f, (y - YStart) / (float)depth, true); + float biasAwayFrom0Interpolant = Utils.GetLerpValue(0.82f, 0.94f, i / (float)width, true) + Utils.GetLerpValue(0.77f, 0.88f, (y - YStart) / (float)depth, true); // If the noise is less than 0, bias to -1, if it's greater than 0, bias away to 1. // This is done instead of biasing to -1 or 1 without exception to ensure that in doing so the noise does not cross into the @@ -339,13 +352,13 @@ namespace CalamityMod.World public static void GenerateCheeseWaterCaves() { - int width = (int)(BiomeWidth * 0.9f); + int width = (int)(BiomeWidth * 0.96f); int depth = (int)(BlockDepth * 0.9f); ushort wallID = (ushort)ModContent.WallType(); for (int c = 0; c < CheeseCaveCarveOutThresholds.Length; c++) { - int caveSeed = WorldGen.genRand.Next(10000000); + int caveSeed = WorldGen.genRand.Next(); for (int i = 1; i < width; i++) { // Initialize variables for the cave. @@ -353,9 +366,9 @@ namespace CalamityMod.World for (int y = YStart; y < YStart + depth; y++) { float noise = FractalBrownianMotion(i * CheeseCaveMagnification, y * CheeseCaveMagnification, caveSeed, 6); - float biasToNegativeOneInterpolant = Utils.GetLerpValue(0.86f, 0.9f, i / (float)width, true) + Utils.GetLerpValue(0.86f, 0.9f, (y - YStart) / (float)depth, true); + float biasToNegativeOneInterpolant = Utils.GetLerpValue(0.82f, 0.94f, i / (float)width, true) + Utils.GetLerpValue(0.77f, 0.88f, (y - YStart) / (float)depth, true); biasToNegativeOneInterpolant += Utils.GetLerpValue(YStart + OpenCavernStartDepthPercentage * depth, YStart + OpenCavernStartDepthPercentage * depth - 25f, y, true); - if (noise - biasToNegativeOneInterpolant * 6f > CheeseCaveCarveOutThresholds[c]) + if (noise - biasToNegativeOneInterpolant > CheeseCaveCarveOutThresholds[c]) { WorldUtils.Gen(new(x, y), new Shapes.Rectangle(1, 1), Actions.Chain(new GenAction[] { @@ -418,6 +431,38 @@ namespace CalamityMod.World } } + public static void ClearAloneTiles() + { + int width = BiomeWidth; + int depth = BlockDepth; + ushort blockTileType = (ushort)ModContent.TileType(); + + for (int i = 0; i < width; i++) + { + int x = GetActualX(i); + for (int y = YStart; y < YStart + depth; y++) + { + Tile t = CalamityUtils.ParanoidTileRetrieval(x, y); + if (!t.HasTile || t.TileType != blockTileType) + continue; + + // Check to see if the tile has any cardinal neighbors. If it doesn't, destroy it. + if (!CalamityUtils.ParanoidTileRetrieval(x - 1, y).HasTile && + !CalamityUtils.ParanoidTileRetrieval(x + 1, y).HasTile && + !CalamityUtils.ParanoidTileRetrieval(x, y - 1).HasTile && + !CalamityUtils.ParanoidTileRetrieval(x, y + 1).HasTile) + { + WorldUtils.Gen(new(x, y), new Shapes.Rectangle(1, 1), Actions.Chain(new GenAction[] + { + new Actions.ClearTile(true), + new Actions.ClearWall(true), + new Actions.SetLiquid() + })); + } + } + } + } + public static void DecideHardSandstoneLine() { int width = BiomeWidth; @@ -427,11 +472,12 @@ namespace CalamityMod.World ushort blockTypeToReplace = (ushort)ModContent.TileType(); ushort blockTypeToPlace = (ushort)ModContent.TileType(); ushort wallID = (ushort)ModContent.WallType(); + for (int i = 0; i < width; i++) { for (int y = YStart; y < YStart + depth; y++) { - int sandstoneLineOffset = (int)(FractalBrownianMotion(i * 0.004f, y * 0.004f, sandstoneSeed, 7) * 30) + depth / 2; + int sandstoneLineOffset = (int)(FractalBrownianMotion(i * HardenedSandstoneLineMagnification, y * HardenedSandstoneLineMagnification, sandstoneSeed, 7) * 30) + (int)(depth * OpenCavernStartDepthPercentage); // Make the sandstone line descent a little bit the closer it is to the world edge, to make it look like it "warps" towards the abyss. sandstoneLineOffset -= (int)(Math.Pow(Utils.GetLerpValue(width * 0.1f, width * 0.8f, i, true), 1.72f) * 45f); @@ -450,6 +496,38 @@ namespace CalamityMod.World } } } + + public static void MakeSurfaceLessRigid() + { + int y = YStart; + int width = BiomeWidth; + int heightSeed = WorldGen.genRand.Next(); + ushort blockTileType = (ushort)ModContent.TileType(); + ushort wallID = (ushort)ModContent.WallType(); + + for (int i = 0; i < width; i++) + { + int x = GetActualX(i); + Tile t = CalamityUtils.ParanoidTileRetrieval(x, y); + + // If the tile below is solid, then determine how high it should rise upward. + // This is done to make the surface less unnaturally flat. + if (t.HasTile) + { + float noise = FractalBrownianMotion(i * IslandLineMagnification, y * IslandLineMagnification, heightSeed, 5) * 0.5f + 0.5f; + int heightOffset = -(int)Math.Round(MathHelper.Lerp(-MaxIslandDepth, MaxIslandHeight, noise)); + for (int dy = 0; dy != heightOffset; dy += Math.Sign(heightOffset)) + { + WorldUtils.Gen(new(x, y + dy), new Shapes.Rectangle(1, 1), Actions.Chain(new GenAction[] + { + heightOffset > 0 ? new Actions.ClearTile() : new Actions.SetTile(blockTileType, true), + new Actions.PlaceWall(y != heightOffset ? wallID : WallID.None, true), + new Actions.SetLiquid() + })); + } + } + } + } #endregion Generation Functions #region Misc Functions diff --git a/World/WorldEvilIsland.cs b/World/WorldEvilIsland.cs index bff00076c5..438d887083 100644 --- a/World/WorldEvilIsland.cs +++ b/World/WorldEvilIsland.cs @@ -65,8 +65,8 @@ namespace CalamityMod.World do { xIslandGen = WorldGen.crimson ? - WorldGen.genRand.Next((int)(x * 0.1), (int)(x * 0.2)) : - WorldGen.genRand.Next((int)(x * 0.8), (int)(x * 0.9)); + WorldGen.genRand.Next((int)(x * 0.1), (int)(x * 0.3)) : + WorldGen.genRand.Next((int)(x * 0.7), (int)(x * 0.9)); yIslandGen = WorldGen.genRand.Next(95, 126); yIslandGen = Math.Min(yIslandGen, (int)WorldGen.worldSurfaceLow - 50); From 5594ad8c02d9f764d6aa933eb02f77a368d6c11c Mon Sep 17 00:00:00 2001 From: Dominic Date: Thu, 6 Oct 2022 17:44:31 -0500 Subject: [PATCH 03/21] Fix rectangular caves --- Schematics/CalamitySchematicIO.cs | 5 +++++ World/SulphurousSea.cs | 19 +++++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Schematics/CalamitySchematicIO.cs b/Schematics/CalamitySchematicIO.cs index 4f206dab30..ec2dc150d7 100644 --- a/Schematics/CalamitySchematicIO.cs +++ b/Schematics/CalamitySchematicIO.cs @@ -556,6 +556,11 @@ namespace CalamityMod.Schematics { ModContent.SplitName(tileFullName, out string mod, out string tileName); Mod theMod = ModLoader.GetMod(mod); + + // TODO -- This is legacy code to avoid breaking old schematics. It would be ideal to revert this and update the schematics, but this will do for now. + if (tileName == "SulphurousSandNoWater") + tileName = "SulphurousSand"; + // If that mod isn't loaded, spawn in a TML default UnloadedTile instead. smt.TileType = (ushort)(theMod is null ? ModContent.TileType() : theMod.Find(tileName).Type); } diff --git a/World/SulphurousSea.cs b/World/SulphurousSea.cs index 547ff751c0..1232966557 100644 --- a/World/SulphurousSea.cs +++ b/World/SulphurousSea.cs @@ -162,6 +162,7 @@ namespace CalamityMod.World ClearAloneTiles(); DecideHardSandstoneLine(); MakeSurfaceLessRigid(); + //LayTreesOnSurface(); } public static void FinishGeneratingSulphurSea() @@ -312,8 +313,8 @@ namespace CalamityMod.World public static void GenerateSpaghettiWaterCaves() { - int width = (int)(BiomeWidth * 0.96f); - int depth = (int)(BlockDepth * 0.9f); + int width = BiomeWidth; + int depth = (int)(BlockDepth * 0.96f); ushort wallID = (ushort)ModContent.WallType(); for (int c = 0; c < SpaghettiCaveCarveOutThresholds.Length; c++) @@ -329,7 +330,8 @@ namespace CalamityMod.World // Bias noise away from 0, effectively making caves less likely to appear, based on how close it is to the bottom/horizontal edge. // This causes caves to naturally stop as the reach ends instead of abruptly stopping like in the old Sulphurous Sea worldgen. - float biasAwayFrom0Interpolant = Utils.GetLerpValue(0.82f, 0.94f, i / (float)width, true) + Utils.GetLerpValue(0.77f, 0.88f, (y - YStart) / (float)depth, true); + float distanceFromEdge = new Vector2(i / (float)width, (y - YStart) / (float)depth).Length(); + float biasAwayFrom0Interpolant = Utils.GetLerpValue(0.82f, 0.96f, distanceFromEdge * 0.8f, true); // If the noise is less than 0, bias to -1, if it's greater than 0, bias away to 1. // This is done instead of biasing to -1 or 1 without exception to ensure that in doing so the noise does not cross into the @@ -352,8 +354,8 @@ namespace CalamityMod.World public static void GenerateCheeseWaterCaves() { - int width = (int)(BiomeWidth * 0.96f); - int depth = (int)(BlockDepth * 0.9f); + int width = BiomeWidth; + int depth = (int)(BlockDepth * 0.96f); ushort wallID = (ushort)ModContent.WallType(); for (int c = 0; c < CheeseCaveCarveOutThresholds.Length; c++) @@ -366,7 +368,8 @@ namespace CalamityMod.World for (int y = YStart; y < YStart + depth; y++) { float noise = FractalBrownianMotion(i * CheeseCaveMagnification, y * CheeseCaveMagnification, caveSeed, 6); - float biasToNegativeOneInterpolant = Utils.GetLerpValue(0.82f, 0.94f, i / (float)width, true) + Utils.GetLerpValue(0.77f, 0.88f, (y - YStart) / (float)depth, true); + float distanceFromEdge = new Vector2(i / (float)width, (y - YStart) / (float)depth).Length(); + float biasToNegativeOneInterpolant = Utils.GetLerpValue(0.82f, 0.96f, distanceFromEdge * 0.8f, true); biasToNegativeOneInterpolant += Utils.GetLerpValue(YStart + OpenCavernStartDepthPercentage * depth, YStart + OpenCavernStartDepthPercentage * depth - 25f, y, true); if (noise - biasToNegativeOneInterpolant > CheeseCaveCarveOutThresholds[c]) { @@ -393,7 +396,7 @@ namespace CalamityMod.World { Tile t = CalamityUtils.ParanoidTileRetrieval(x, y); Point p = new(x, y); - if (t.TileType != blockTileType || !t.HasTile || points.Count > 512 || points.Contains(p)) + if (t.TileType != blockTileType || !t.HasTile || points.Count > 300 || points.Contains(p)) return; points.Add(p); @@ -414,7 +417,7 @@ namespace CalamityMod.World List chunkPoints = new(); recursivelyGetAttachedPoints(x, y, chunkPoints); - int cutoffLimit = y >= YStart + depth * OpenCavernStartDepthPercentage ? 512 : 50; + int cutoffLimit = y >= YStart + depth * OpenCavernStartDepthPercentage ? 300 : 50; if (chunkPoints.Count >= 2 && chunkPoints.Count < cutoffLimit) { foreach (Point p in chunkPoints) From 5b607f503970e342340f25bdaaf26548c994bbcb Mon Sep 17 00:00:00 2001 From: Dominic Date: Thu, 6 Oct 2022 21:07:14 -0500 Subject: [PATCH 04/21] TREE --- World/SulphurousSea.cs | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/World/SulphurousSea.cs b/World/SulphurousSea.cs index 1232966557..e6e4667696 100644 --- a/World/SulphurousSea.cs +++ b/World/SulphurousSea.cs @@ -84,6 +84,8 @@ namespace CalamityMod.World public const float IslandLineMagnification = 0.0079f; + public const int TreeGrowChance = 5; + public static int BiomeWidth { get @@ -162,7 +164,7 @@ namespace CalamityMod.World ClearAloneTiles(); DecideHardSandstoneLine(); MakeSurfaceLessRigid(); - //LayTreesOnSurface(); + LayTreesOnSurface(); } public static void FinishGeneratingSulphurSea() @@ -524,13 +526,38 @@ namespace CalamityMod.World WorldUtils.Gen(new(x, y + dy), new Shapes.Rectangle(1, 1), Actions.Chain(new GenAction[] { heightOffset > 0 ? new Actions.ClearTile() : new Actions.SetTile(blockTileType, true), - new Actions.PlaceWall(y != heightOffset ? wallID : WallID.None, true), + new Actions.PlaceWall(MathHelper.Distance(dy, heightOffset) >= 2f ? wallID : WallID.None, true), new Actions.SetLiquid() })); } } } } + + public static void LayTreesOnSurface() + { + int width = BiomeWidth; + for (int i = 0; i < width - 8; i++) + { + if (!WorldGen.genRand.NextBool(TreeGrowChance)) + continue; + + int x = GetActualX(i); + int y = YStart - 30; + if (!WorldUtils.Find(new(x, y), Searches.Chain(new Searches.Down(MaxIslandDepth + 31), new Conditions.IsSolid()), out Point growPoint)) + continue; + + x = growPoint.X; + y = growPoint.Y - 1; + + if (CalamityUtils.ParanoidTileRetrieval(x, y).LiquidAmount > 0) + continue; + + Main.tile[x, y].TileType = TileID.Saplings; + Main.tile[x, y].Get().HasTile = true; + WorldGen.GrowPalmTree(x, y); + } + } #endregion Generation Functions #region Misc Functions From bb54b462c152ff2cb8bddfac4c1231a4692ede35 Mon Sep 17 00:00:00 2001 From: Dominic Date: Thu, 6 Oct 2022 22:00:01 -0500 Subject: [PATCH 05/21] Transition to not sulph sea --- ILEditing/WorldgenILChanges.cs | 2 +- Tiles/Abyss/SulphurousSand.cs | 2 +- World/SulphurousSea.cs | 106 ++++++++++++++++++++++++++++++++- 3 files changed, 105 insertions(+), 5 deletions(-) diff --git a/ILEditing/WorldgenILChanges.cs b/ILEditing/WorldgenILChanges.cs index 78678e8139..9d5ca5219c 100644 --- a/ILEditing/WorldgenILChanges.cs +++ b/ILEditing/WorldgenILChanges.cs @@ -49,7 +49,7 @@ namespace CalamityMod.ILEditing cursor.EmitDelegate(() => { - WorldGen.dungeonX = Utils.Clamp(WorldGen.dungeonX, SulphurousSea.BiomeWidth + 100, Main.maxTilesX - SulphurousSea.BiomeWidth - 100); + WorldGen.dungeonX = Utils.Clamp(WorldGen.dungeonX, SulphurousSea.BiomeWidth + 167, Main.maxTilesX - SulphurousSea.BiomeWidth - 167); // Adjust the Y position of the dungeon to accomodate for the X shift. WorldUtils.Find(new Point(WorldGen.dungeonX, WorldGen.dungeonY), Searches.Chain(new Searches.Down(9001), new Conditions.IsSolid()), out Point result); diff --git a/Tiles/Abyss/SulphurousSand.cs b/Tiles/Abyss/SulphurousSand.cs index 7b2993cc2b..a19ae64783 100644 --- a/Tiles/Abyss/SulphurousSand.cs +++ b/Tiles/Abyss/SulphurousSand.cs @@ -50,7 +50,7 @@ namespace CalamityMod.Tiles.Abyss if (!Main.tile[i, tileLocationY].HasTile) { if (!CalamityPlayer.areThereAnyDamnBosses && Main.tile[i, tileLocationY].LiquidAmount == 255 && Main.tile[i, tileLocationY - 1].LiquidAmount == 255 && - Main.tile[i, tileLocationY - 2].LiquidAmount == 255 && Main.netMode != NetmodeID.MultiplayerClient) + Main.tile[i, tileLocationY - 2].LiquidAmount == 255 && !Main.tile[i, tileLocationY - 2].HasTile && Main.netMode != NetmodeID.MultiplayerClient) { Projectile.NewProjectile(new EntitySource_WorldEvent(), (float)(i * 16 + 16), (float)(tileLocationY * 16 + 16), 0f, -0.1f, ModContent.ProjectileType(), 0, 2f, Main.myPlayer, 0f, 0f); } diff --git a/World/SulphurousSea.cs b/World/SulphurousSea.cs index e6e4667696..48a374022f 100644 --- a/World/SulphurousSea.cs +++ b/World/SulphurousSea.cs @@ -169,7 +169,7 @@ namespace CalamityMod.World public static void FinishGeneratingSulphurSea() { - + CreateBeachNearSea(); } #endregion @@ -485,7 +485,7 @@ namespace CalamityMod.World int sandstoneLineOffset = (int)(FractalBrownianMotion(i * HardenedSandstoneLineMagnification, y * HardenedSandstoneLineMagnification, sandstoneSeed, 7) * 30) + (int)(depth * OpenCavernStartDepthPercentage); // Make the sandstone line descent a little bit the closer it is to the world edge, to make it look like it "warps" towards the abyss. - sandstoneLineOffset -= (int)(Math.Pow(Utils.GetLerpValue(width * 0.1f, width * 0.8f, i, true), 1.72f) * 45f); + sandstoneLineOffset -= (int)(Math.Pow(Utils.GetLerpValue(width * 0.1f, width * 0.8f, i, true), 1.72f) * 67f); Point p = new(GetActualX(i), y); Tile t = CalamityUtils.ParanoidTileRetrieval(p.X, p.Y); @@ -520,6 +520,8 @@ namespace CalamityMod.World if (t.HasTile) { float noise = FractalBrownianMotion(i * IslandLineMagnification, y * IslandLineMagnification, heightSeed, 5) * 0.5f + 0.5f; + noise = MathHelper.Lerp(noise, 0.5f, Utils.GetLerpValue(width - 13f, width - 1f, i, true)); + int heightOffset = -(int)Math.Round(MathHelper.Lerp(-MaxIslandDepth, MaxIslandHeight, noise)); for (int dy = 0; dy != heightOffset; dy += Math.Sign(heightOffset)) { @@ -555,7 +557,66 @@ namespace CalamityMod.World Main.tile[x, y].TileType = TileID.Saplings; Main.tile[x, y].Get().HasTile = true; - WorldGen.GrowPalmTree(x, y); + if (!WorldGen.GrowPalmTree(x, y)) + WorldGen.KillTile(x, y); + } + } + + public static void CreateBeachNearSea() + { + int beachWidth = WorldGen.genRand.Next(150, 190 + 1); + + var searchCondition = Searches.Chain(new Searches.Down(3000), new Conditions.IsSolid()); + WorldUtils.Find(new Point(BiomeWidth + 4, (int)WorldGen.worldSurfaceLow - 20), searchCondition, out Point determinedPoint); + Tile tileAtEdge = CalamityUtils.ParanoidTileRetrieval(determinedPoint.X, determinedPoint.Y); + + // Extend outward to encompass some of the desert, if there is one. + if (tileAtEdge.TileType is TileID.Sand or TileID.Ebonsand or TileID.Crimsand) + beachWidth += 85; + + // Transform the landscape. + for (int i = BiomeWidth - 10; i <= BiomeWidth + beachWidth; i++) + { + int x = GetActualX(i); + float xRatio = Utils.GetLerpValue(BiomeWidth - 10, BiomeWidth + beachWidth, i, true); + float ditherChance = Utils.GetLerpValue(0.92f, 0.99f, xRatio, true); + int depth = (int)(Math.Sin((1f - xRatio) * MathHelper.PiOver2) * 45f + 1f); + for (int y = YStart - 50; y < YStart + depth; y++) + { + Tile tileAtPosition = CalamityUtils.ParanoidTileRetrieval(x, y); + if (tileAtPosition.HasTile && ValidBeachDestroyTiles.Contains(tileAtPosition.TileType)) + { + // Kill trees manually so that no leftover tiles are present. + if (Main.tile[x, y].TileType == TileID.Trees) + WorldGen.KillTile(x, y); + else + Main.tile[x, y].Get().HasTile = false; + } + + else if (tileAtPosition.HasTile && ValidBeachCovertTiles.Contains(tileAtPosition.TileType) && WorldGen.genRand.NextFloat() >= ditherChance) + Main.tile[x, y].TileType = (ushort)ModContent.TileType(); + } + } + + // Plant new trees. + for (int x = BiomeWidth - 10; x <= BiomeWidth + beachWidth; x++) + { + int trueX = Abyss.AtLeftSideOfWorld ? x : Main.maxTilesX - x; + if (!WorldGen.genRand.NextBool(10)) + continue; + + int y = YStart - 30; + if (!WorldUtils.Find(new Point(trueX, y), Searches.Chain(new Searches.Down(100), new Conditions.IsTile((ushort)ModContent.TileType())), out Point treePlantPosition)) + continue; + + treePlantPosition.Y--; + + // Place the saplings and try to grow them. + WorldGen.PlaceTile(treePlantPosition.X, treePlantPosition.Y, ModContent.TileType()); + Main.tile[treePlantPosition].TileType = TileID.Saplings; + Main.tile[treePlantPosition].Get().HasTile = true; + if (!WorldGen.GrowPalmTree(treePlantPosition.X, treePlantPosition.Y)) + WorldGen.KillTile(treePlantPosition.X, treePlantPosition.Y); } } #endregion Generation Functions @@ -640,6 +701,45 @@ namespace CalamityMod.World WallID.CrimstoneUnsafe, }; + public static readonly List ValidBeachCovertTiles = new() + { + TileID.Dirt, + TileID.Stone, + TileID.Crimstone, + TileID.Ebonstone, + TileID.Sand, + TileID.Ebonsand, + TileID.Crimsand, + TileID.Grass, + TileID.CorruptGrass, + TileID.CrimsonGrass, + TileID.ClayBlock, + TileID.Mud, + }; + + public static readonly List ValidBeachDestroyTiles = new() + { + TileID.Coral, + TileID.BeachPiles, + TileID.Plants, + TileID.Plants2, + TileID.SmallPiles, + TileID.LargePiles, + TileID.LargePiles2, + TileID.CorruptThorns, + TileID.CrimsonThorns, + TileID.DyePlants, + TileID.Trees, + TileID.Sunflower, + TileID.LilyPad, + TileID.SeaOats, + TileID.ImmatureHerbs, + TileID.MatureHerbs, + TileID.BloomingHerbs, + TileID.VanityTreeSakura, + TileID.VanityTreeYellowWillow, + }; + // This method is an involutory function, meaning that applying it to the same number twice always yields the original number. public static int GetActualX(int x) { From 045f7db5b18e05012db6bd949226e5aad39ec31f Mon Sep 17 00:00:00 2001 From: Dominic Date: Fri, 7 Oct 2022 00:46:44 -0500 Subject: [PATCH 06/21] Columns + unfucked a bunch of sulph sea tile sheets --- BiomeManagers/AbyssLayer1Biome.cs | 2 +- ILEditing/ILChangesLoading.cs | 2 + ILEditing/MechanicILChanges.cs | 21 +++++++ Tiles/Abyss/SteamGeyser.png | Bin 949 -> 512 bytes Tiles/Abyss/SulphuricFossil1.png | Bin 915 -> 385 bytes Tiles/Abyss/SulphuricFossil2.png | Bin 1072 -> 408 bytes Tiles/Abyss/SulphuricFossil3.png | Bin 935 -> 378 bytes Tiles/Abyss/SulphurousColumn.cs | 3 +- Tiles/Abyss/SulphurousColumn.png | Bin 2181 -> 750 bytes Tiles/Abyss/SulphurousRib1.png | Bin 446 -> 293 bytes Tiles/Abyss/SulphurousRib3.png | Bin 358 -> 257 bytes Tiles/Abyss/SulphurousRib4.png | Bin 354 -> 264 bytes Tiles/Abyss/SulphurousRib5.png | Bin 232 -> 203 bytes World/SulphurousSea.cs | 99 ++++++++++++++++++++++++++++-- 14 files changed, 118 insertions(+), 9 deletions(-) diff --git a/BiomeManagers/AbyssLayer1Biome.cs b/BiomeManagers/AbyssLayer1Biome.cs index 9e299f96e9..80842c3696 100644 --- a/BiomeManagers/AbyssLayer1Biome.cs +++ b/BiomeManagers/AbyssLayer1Biome.cs @@ -36,7 +36,7 @@ namespace CalamityMod.BiomeManagers if (WeakReferenceSupport.InAnySubworld()) return false; - return point.Y > (Main.rockLayer - y * 0.05) && + return point.Y > SulphurousSea.YStart + SulphurousSea.BlockDepth - 78 && !player.lavaWet && !player.honeyWet && abyssPosY && diff --git a/ILEditing/ILChangesLoading.cs b/ILEditing/ILChangesLoading.cs index 66b3830167..fb379ad75d 100644 --- a/ILEditing/ILChangesLoading.cs +++ b/ILEditing/ILChangesLoading.cs @@ -57,6 +57,7 @@ namespace CalamityMod.ILEditing IL.Terraria.GameContent.Liquid.LiquidRenderer.InternalDraw += DrawCustomLava2; IL.Terraria.Main.oldDrawWater += DrawCustomLava3; IL.Terraria.Player.CollectTaxes += MakeTaxCollectorUseful; + On.Terraria.Graphics.Light.TileLightScanner.GetTileLight += MakeSulphSeaWaterBetter; On.Terraria.Main.DrawGore += DrawForegroundStuff; On.Terraria.GameContent.Drawing.TileDrawing.PreDrawTiles += ClearForegroundStuff; On.Terraria.GameContent.Drawing.TileDrawing.Draw += ClearTilePings; @@ -168,6 +169,7 @@ namespace CalamityMod.ILEditing IL.Terraria.GameContent.Liquid.LiquidRenderer.InternalDraw -= DrawCustomLava2; IL.Terraria.Main.oldDrawWater -= DrawCustomLava3; IL.Terraria.Player.CollectTaxes -= MakeTaxCollectorUseful; + On.Terraria.Graphics.Light.TileLightScanner.GetTileLight -= MakeSulphSeaWaterBetter; // IL.Terraria.WaterfallManager.DrawWaterfall -= DrawCustomLavafalls; On.Terraria.NPC.Collision_DecideFallThroughPlatforms -= EnableCalamityBossPlatformCollision; IL.Terraria.Wiring.HitWireSingle -= AddTwinklersToStatue; diff --git a/ILEditing/MechanicILChanges.cs b/ILEditing/MechanicILChanges.cs index f429cc5250..a58deb39f0 100644 --- a/ILEditing/MechanicILChanges.cs +++ b/ILEditing/MechanicILChanges.cs @@ -784,6 +784,14 @@ namespace CalamityMod.ILEditing initialColor.TopRightColor = SelectLavaColor(initialTexture, initialColor.TopRightColor, liquidType == 1); initialColor.BottomLeftColor = SelectLavaColor(initialTexture, initialColor.BottomLeftColor, liquidType == 1); initialColor.BottomRightColor = SelectLavaColor(initialTexture, initialColor.BottomRightColor, liquidType == 1); + if (liquidType == ModContent.Find("CalamityMod/SulphuricWater").Slot) + { + initialColor.TopLeftColor *= 0.4f; + initialColor.TopRightColor *= 0.4f; + initialColor.BottomLeftColor *= 0.4f; + initialColor.BottomRightColor *= 0.4f; + } + return initialColor; }); } @@ -877,6 +885,19 @@ namespace CalamityMod.ILEditing } #endregion Custom Lava Visuals + #region Sulph Sea Water Visuals + private static void MakeSulphSeaWaterBetter(On.Terraria.Graphics.Light.TileLightScanner.orig_GetTileLight orig, TileLightScanner self, int x, int y, out Vector3 outputColor) + { + orig(self, x, y, out outputColor); + + Tile tile = CalamityUtils.ParanoidTileRetrieval(x, y); + if (tile.LiquidAmount <= 0 || tile.HasTile || Main.waterStyle != ModContent.Find("CalamityMod/SulphuricWater").Slot) + return; + + outputColor = Vector3.Lerp(outputColor, Color.LightSeaGreen.ToVector3(), 0.41f); + } + #endregion Sulph Sea Water Visuals + #region Statue Additions /// /// Change the following code sequence in Wiring.HitWireSingle diff --git a/Tiles/Abyss/SteamGeyser.png b/Tiles/Abyss/SteamGeyser.png index ca6860255cf0a2cb035a08dce00dcedc49ad6973..a8da9ed61f779a524fe22fb7d18c16c948ba2599 100644 GIT binary patch delta 469 zcmV;`0V@8r2Y>{S83+Ra007C!&61HJAb%TBOjJcoIy+}UKyg|}jd@KuFjJ_KRL!}K zA{`(A0002^%NhUx010$bPE-H?|NsC0|Nj6}Pk0gl000SaNLh0L01mM?=E5eMtI<{e18k) z8RiScm{Q)5()&^|nxT}(#tv5qElb>xHjId`Q3@GK$@vq6LP)96{v&j|Ez73}e6w|0ht`NdDh`$LrVn!`piVctT2#IduTp@~DKtgC- z4sFDYKDR<#m!`)?(U^0EW?-(6)_?Kp4%L&EyB7?`V(&Af*{}6K2ii=bT1hPpuo@M( zO>H>Ij*KouG-cs{y+Vk>1Qut`{AHx{EaZUcgZF4&DJJKPOUQK~T_Xem#K_?2#|_;W zpI~pEIsCO|mD^bJglhFw0fvOY`e+R0B15?1I!&tEPb{a}=o;2+ArGNqokBY;2@I}4 z8pGw;+_KEV+9xb|tgjGa%hyCmsl5>B!G;^9#a;#+pFPtgp>_QNYF9*h@00000 LNkvXXu0mjf&$rQ~ delta 909 zcmV;819JR;1hof{83+ad0090MJ)n^x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(duzx)4q%6Ei}fy6ifjbjUn8;r~SR=EPS2-ln9K{G5sQe$HPl!^@iEK9D9y2Lk) zG5`;r&3F7l{v%|B2Q2ut`lu#`g~0IOl;;GI(6#|k-ilU z0QaB1cRW`zs<0`!JuxO8#lA+r)BwmV#@yA=Q@$g#SLKSOf(4G=3xKN^&UT!jSSlL; z@o2kjJs@XXqHgwqb+NQ8@d&zf%g2htdj{@8T z;t@HYR`Q!2J?3z5@&lP7M0vSx%U-lkyFiFk#Vzga&Vc}nh+h89k!H}j>LC_ z4DF_qajEaQ;lTF<}QcMkjNIEUPxacBHPW(#PMs+SuEKrqtdc@B-(UA{_tL|xyv zgo66slPh`;&`hheb5Pal(sPCF_ahyz)loD2)~-_O1tq2)3IqkTo6PC)m}9+<%ih09 zsC-9g&qMm=sOOPNJ)jwT_;LYgk*e$lq{rIKJG`fIcM$o~F~@y6B^lrPW*Gqe3B$3z z5^i%oCn9xIWp_6j_ta2)nszV05B^R p3tH7r<@SyeQ&LOWWdnRj=m$QXEdH^9BJ}_O002ovPDHLkV1jZKzGnac diff --git a/Tiles/Abyss/SulphuricFossil2.png b/Tiles/Abyss/SulphuricFossil2.png index 9d08d9f024c9da793972f94388cdf34ca5b924d1..bbd91f80f671a445c5eefedd634a8a50ed79bef0 100644 GIT binary patch literal 408 zcmeAS@N?(olHy`uVBq!ia0vp^WhY4l5>woZZ>0B&$#u<<7{)4^*;l!!`#X#Z?mI z7yKUv7&e{JIS&-&EbxddW?btQIEHw5@4bAH?~sCkOW>&>v48*D zpQhc}GHc(9F!hOBTAbAaPVe#1ynX8PQ={)2gI;w-?z|JUbNbA!-}JBD+V_9j*Qpgn z&jar8|EN>6y!LzB!5=@l)?7>2HOcsl!G(i4t*7?(2ZlY%>D_63#>ipAjbl6&Lp7689ZJ6T-G@yGywpet*~|g literal 1072 zcmV-01kd}4P)Px&>PbXFR9J=Wm`iUPRTRg6FLq+Dc`CC_)H60gJ9G zbxA)4EZB6xCn!QlAQnZ6sw!<3A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5<9XiR>Ur+7Wyz6jrX!yvxu+F8kutNicou+4wKnsj!w`Lj4#R4z z1i;43!EQ190!*nwv|P0l2h$9Dti;DN401 zu^)7Xp7CE=Qtc|6YXF>Im_PbehakEPjXSlsqic10qo3@0zTY1RLw{eCasNJg?f~So z^9H~ki~vZ?O&7aal|^(J@?+sx)&M+s`@w-R0}tMMBXgyE8i3l+24H#V764BwE3VQI zyMM0zG3y$qQWlY8XyUKcJ$#{f0)YL#^qtgP0)WpQQ3$z|D1<~ps$jb(In~@1YT~g0 z04K7d33KTr06kk6ty_|lniGEQ*B{9ESj@Qo`yP8gBFE67N@2bEB`}9nlWo+S2B2ZP%Ao@cnPdTgp_2w6Zn^-}dUl|LxVyLCe-fF! zQ2J}8h3LF7BQYL1qnZ3fpCQG@_Lc+Vz5*Wu?e@B&AXKwy&M5p^?*7wP0Gurr3_vpB zjp@6O4F_iLThV1m_i#Qd5w+Uhqi3Ui27o2^n4^(iJSpSm;^DFJpHOSf9nXC_Axr7n z1J84vr|2pd?O&4+U4|4^yXDKBaO`#@hvtt-XV;w3sy7JjrgQ_nmcRmJBYo&e>rq~F)#1^8lV3U^b^h002ov JPDHLkV1iXyuy_Cf diff --git a/Tiles/Abyss/SulphurousColumn.cs b/Tiles/Abyss/SulphurousColumn.cs index 08d49cac39..031a863e24 100644 --- a/Tiles/Abyss/SulphurousColumn.cs +++ b/Tiles/Abyss/SulphurousColumn.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Tiles.Abyss TileObjectData.newTile.Width = 2; TileObjectData.newTile.Height = 3; TileObjectData.newTile.Origin = new Point16(1, 2); - TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.Table | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile, TileObjectData.newTile.Width, 0); TileObjectData.newTile.UsesCustomCanPlace = true; TileObjectData.newTile.CoordinateHeights = new int[] { @@ -32,7 +32,6 @@ namespace CalamityMod.Tiles.Abyss TileObjectData.newTile.CoordinatePadding = 2; TileObjectData.newTile.WaterDeath = false; TileObjectData.newTile.LavaDeath = true; - TileObjectData.newTile.DrawYOffset = 2; TileObjectData.addTile(Type); ModTranslation name = CreateMapEntryName(); AddMapEntry(new Color(150, 100, 50), name); diff --git a/Tiles/Abyss/SulphurousColumn.png b/Tiles/Abyss/SulphurousColumn.png index 7ae5f91a238d056a6730e24c609751f1342699d9..836c0668bd021fb9acad4fd56940107ceeb59842 100644 GIT binary patch delta 739 zcmV<90v!E?5$*+$7k@Sg0{{R37_Px#1ZP1_K>z@;j|==^ z1poj56;Mo6MIs#_IWSXaK|oA8J8@b^jd@J~000Oe|BV0u00(qZPE-H?|NsC002)gJ zMgRZ+32;bRa{vGi!vFvd!vV){sAK>D0#8XqK~z{r#g;0>3Ti1PGme(LW+xE2_8aC@f(j zBx3O40CifwF_wc1N9H)HET#_?L3QHy5XPg$6~&JpQOGP%+x9s%2j#>KV#ygq8N%aw z_*=_KSHh4v>VLbr+EK`;w2UZSAV9@|;Ce(^k_%zZ=c8jD>iu>(v5l=slrf^J2ia;p zu`R;WixP$9Up>eU~xc+W3qq<51r=jBDrD+6-(({Ch1CcovJ%0n0FC7dB(-p-b2Ne!O6dpv1 z4IEv)C@m-F(0?e#V_O&@K0T46C)zv*!mlH8uB`Q)ZhX%57qMU9N%^`}L zHjt=_(nS%-2C5N-YLgN7=Ae*M=L3O($SaBnT2fJ?=VTocr7KGAMHvGKv7FJUdyFIZ z7*$)ShkwGN#oeeLb)%R#6Gbs`rhaV><1{V~1kHN(M3cF?tW_&2V8mcT_ZaR53g5LH z5q{b6ptH{ zTiIgpF;ZV%S&%Q}u^coDg@w-uwm8Cs)#l{J@m!T`2&x`(yc-`QKAx7`j}lZ-5p9q$ zTyvKgyuvIfQV@6b#8Pyl(!!A2B0xx!W6B2dFJltrG9Yr!$G<2%ohaJVqc+sO{{RcY VR0SeZ&3ym>002ovPDH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0}vTQSdyRn(bK8iZUay%Y2^x`XTrJN>L?2;VvX?pAef2z+=M*?pu@57Dqw7<9vf$ zm0qoKD}7W^6zwyVy&N*vr}-E&J&CohsE_B}ug$0$5z}>*qDq29QO#gG(8my(4#!_a88xjO+U`K9oPycS{y^J#FFc~sfupYSx$01<@e1N9>N8nw6KxgE z@ktcz%w5*9`}*`ZF|$!Asw8kKN@EV=&dgrgi&iW@6-D1Kil~tljUeCUNQH0s^t-gK zC|A#f+&?i6yA<8J-r04nIF+JGf~036Y?2bj(|jc`b68oIQ#;qkIX#!Mv>pYQJ(@4z z=d?CRNn0Z4r`f@o7gtx5tbhYO+aB|~*)CRAu%2IUt9mB>XGnaM_Lc(2^;*u){OO^q z9sv`*ycXB-`A(QrdUF}--l|DD^8`T zl3?WuFEeI3vl-*sAIL1RWX{{((_Dk4k4&=E=KR9A1ojO2yRzBf=P6tvHpUN&?^2Ab zqCZ!MEQ8;!=f4)f7=E;U87oWv9YOx=p22z!E4)%vN#LjV2gTs3U`pR1A$=9Y746Ar zODZikX>84x$#-OnzSY5S_4To`_`0oi-?FDDq{1sjl?49+!-rGe){J+q00000NkvXX Hu0mjfqYz2A diff --git a/Tiles/Abyss/SulphurousRib1.png b/Tiles/Abyss/SulphurousRib1.png index c504049e1e00600a984da22b3a58bdf56377ebeb..77872bb1f82d6a7eb593e2722a45e039faed43b0 100644 GIT binary patch delta 271 zcmdnTyp&0?Gr-TCmrII^fq{Y7)59eQNDBe62M05dJi{9LWul@&y=Z_>h^wVRaAB0Y zlB|M{m36wK10x$hP(_$t?iV1%UJ~RN{2vS$q`aBkfI^%F9+AZi41D`Rn9+hYSOqB9 z=IP=XV&Q-GtT*2Q1rC;gBj^A2$6VMJbtLK3vdxNnQW#FjF1Ql8eO4!f(*_R1W3pZ= z56;@LE!A05@!H%+3(M{(NzVOI(er4Um+Uo@Yc@wdxLZ9J=#4UbUc9`5bK_z+OXC|y z5`-^w+dlf$dVgiFp;ck1$lNQ1zI$$&*j@0nt5_WO^`f!x)FOsskHjPQIKG(-bP|K7 LtDnm{r-UW|c`#(Q delta 425 zcmV;a0apH{0=@$wiBL{Q4GJ0x0000DNk~Le0000G0000+2nGNE0L3H}i;*E9e+h6% zS#tmY4!{5a4!{9w)`)m1_o)00@CLLbys)5Fx1~V3VXcnc<$rddu#yvoWY2409_u`)1~`T6uEU9~I>%^YZ$@ z|84Lo0H*@nJjgbD9_N>w#S~Zze_VIdf+A^tC<+_#W~f2)F`{CSUX z1@q6fq5yb}eF;{e(I53&1=QL6Ah(5fa?4Q{IRz%zj>`}66!;Qc;PC9+g$WO`A)m+j zGiNx|=Ex)1g0q0jk?|DZMi=oE_`VOp3ijSPnERLtq=kT3g@YMLZZ@8Eb)uqzp=f|lh^wVRaAA~t zx}$@VtO6q&zmJtQPzCqPBnu$LUJ~RN{2vS$q`aBkCfZ4qCwaO!hG+yYJ#&$(!GNPR z(Y*ipUwO-=N{dSz{~w(pzhc58!_bQolG(F@zfNfKxcYMLkA9B_+A|qHzCW=?^l8?w zGVTD=VBR;HuQ&uc3w=LWadCJ(=iYVgUS@pv(!NJKzbh0mFR$gEx%9@`2A~TVJYD@< J);T3K0RS~~PgMW_ delta 337 zcmZoERLtqy>OjiGvMDhB-zapQxx%&spFRSl*=wzENf{e!~}-eFQbj(W{I`B*aEH!ZiXZ#L9(*vQQ$C*Z?=Pt7X9jwi>q znAPY1|F42;rav-Jc){da=x886h0Wo?t;fp~e*HWBJz-Xzo&)=qV#YIR+`8fh|DWF8 zoFJ8^e8x4Tn9-5h!R%npVK$(nUevWW3Sa-$koo1tf;ycAyBX4q)p-`Q+kO4Sq__X@ hBYD|?o2)!M3~>y}Yu=bX1cn0xgQu&X%Q~loCIEnXdZz#Y diff --git a/Tiles/Abyss/SulphurousRib4.png b/Tiles/Abyss/SulphurousRib4.png index 0a7697777cc0c27d347f69f34b7287dd78c2586d..9540391f01b0461ce058e8b5e040f40db91c8577 100644 GIT binary patch delta 221 zcmaFF)WM|K8Q|y6%O%Cdz`(%k>ERLtq=kUkjDs0S{?)Z~ov5f_C>r1s;%aFSTo~of z$i|=U=-^{ztt6`eRIzh2e;JTsFA4Gs{tpHWQr^sN6YV7GGCf@!LoEFFUTEZMP~dS5 ztbO+H|K!_;mE31bwu+0`7zhdrPxiNr{^G%+!D?|X%E$JX%bhL4;S-L|_?0wk_iJ9$ z827Dq!B^8d4ky3rUddZ@lx4{mb;sX+EJFL!eXh^&&+YM-6*Rxy>r!^#Md0YGxeKy^ P4q@bP0l+XkK!qQD! delta 333 zcmeBRdc>sI8Q|y6%O%Cdz`(%k>ERLtqy>Q3go6!8HlN$!I8jldp0mIsvY3H^Z$Ah# zTCfJI042YBx;Tb-cqeZ$;rMsHfu%1#;xtF95bKNuCN~-0F>$ZePiPdrUU9%=qu#_GlTZZNwMhG=XgwiWs-ej#;p12jkyMjCu~$%mqsw zBqZ1p8T>mpOlg<>@VD#QQ) delta 210 zcmX@j_<~WfGr-TCmrII^fq{Y7)59eQNDF{42OE%-|NK93qM|}QXMsm#F#`kNeh_A~ zU=3CQO4fS1IEGmGC;$2X-=3Mnz{sd6Qz9Ydal6L@hX3`oEZGT6pEVd*ViOiVWqLM$ z$2NAK#mrr?4qF(z9yKNO@Xc`Wb1%2kY{(G5Q~y)0=VGkWeuD$78fFa2UpS81pZUMw z0|Vo)O2%}nhD#|L%oP#~e#^4O?X%@hUC5->%E-*jz}BzaX1L!&3+NICPgg&ebxsLQ E00Rg_TmS$7 diff --git a/World/SulphurousSea.cs b/World/SulphurousSea.cs index 48a374022f..0f4d178ea4 100644 --- a/World/SulphurousSea.cs +++ b/World/SulphurousSea.cs @@ -86,6 +86,11 @@ namespace CalamityMod.World public const int TreeGrowChance = 5; + // The percentage of tiles on average that should be transformed into water. + // A value of 1 indicates that every tile should have water. + // This value should be close to 1, but not exactly, so that when water settles the top of caverns will be open. + public const float WaterSpreadPercentage = 0.95f; + public static int BiomeWidth { get @@ -127,7 +132,7 @@ namespace CalamityMod.World public static int MaxTopWaterDepth => (int)(BlockDepth * TopWaterDepthPercentage); - public static int MinCaveWidth => (int)(Main.maxTilesX / 2500f); + public static int MinCaveWidth => Main.maxTilesX / 2500; public static int MaxCaveWidth => (int)Math.Ceiling(Main.maxTilesX / 566f); @@ -135,6 +140,8 @@ namespace CalamityMod.World public static int MaxCaveMovementSteps => (int)Math.Ceiling(Main.maxTilesX / 40f); + public static int ColumnCount => Main.maxTilesX / 76; + public static int YStart { get; @@ -160,11 +167,12 @@ namespace CalamityMod.World GenerateCheeseWaterCaves(); ClearOutStrayTiles(); - // Lay down decorations after the caves are generated. + // Lay down decorations and post-processing effects after the caves are generated. ClearAloneTiles(); DecideHardSandstoneLine(); MakeSurfaceLessRigid(); LayTreesOnSurface(); + GeneratePillarsInCaverns(); } public static void FinishGeneratingSulphurSea() @@ -288,7 +296,7 @@ namespace CalamityMod.World { new Actions.ClearTile(true), new Actions.PlaceWall(wallID, true), - new Actions.SetLiquid() + new Actions.SetLiquid(LiquidID.Water, (byte)(WorldGen.genRand.NextFloat() > WaterSpreadPercentage ? 0 : byte.MaxValue)) })); } @@ -346,7 +354,7 @@ namespace CalamityMod.World { new Actions.ClearTile(true), new Actions.PlaceWall(wallID, true), - new Actions.SetLiquid() + new Actions.SetLiquid(LiquidID.Water, (byte)(WorldGen.genRand.NextFloat() > WaterSpreadPercentage ? 0 : byte.MaxValue)) })); } } @@ -379,7 +387,7 @@ namespace CalamityMod.World { new Actions.ClearTile(true), new Actions.PlaceWall(wallID, true), - new Actions.SetLiquid() + new Actions.SetLiquid(LiquidID.Water, (byte)(WorldGen.genRand.NextFloat() > WaterSpreadPercentage ? 0 : byte.MaxValue)) })); } } @@ -539,19 +547,25 @@ namespace CalamityMod.World public static void LayTreesOnSurface() { int width = BiomeWidth; + for (int i = 0; i < width - 8; i++) { + // Only sometimes generate trees. if (!WorldGen.genRand.NextBool(TreeGrowChance)) continue; int x = GetActualX(i); int y = YStart - 30; + + // Search downward in hopes of finding a position to generate and grow an acorn. + // If no such downward tile exists, skip this tile. if (!WorldUtils.Find(new(x, y), Searches.Chain(new Searches.Down(MaxIslandDepth + 31), new Conditions.IsSolid()), out Point growPoint)) continue; x = growPoint.X; y = growPoint.Y - 1; + // Ignore tiles if there's water above. if (CalamityUtils.ParanoidTileRetrieval(x, y).LiquidAmount > 0) continue; @@ -562,6 +576,49 @@ namespace CalamityMod.World } } + public static void GeneratePillarsInCaverns() + { + int columnCount = ColumnCount; + int width = BiomeWidth; + int depth = BlockDepth; + int maxColumnHeight = 45; + var searchCondition = Searches.Chain(new Searches.Up(maxColumnHeight), new Conditions.IsSolid()); + + for (int c = 0; c < columnCount; c++) + { + int x = GetActualX(WorldGen.genRand.Next(20, width - 32)); + int y = WorldGen.genRand.Next(YStart, YStart + depth - 30); + + bool tryAgain = false; + + // Try again if inside a tile. + Tile tile = CalamityUtils.ParanoidTileRetrieval(x, y); + Tile bottom = CalamityUtils.ParanoidTileRetrieval(x, y + 1); + Tile bottomRight = CalamityUtils.ParanoidTileRetrieval(x + 1, y + 1); + if (tile.HasTile) + tryAgain = true; + + // Try again if there is no bottom tile. + if (!bottom.HasTile || !bottomRight.HasTile) + tryAgain = true; + + // Try again if there is no tile above or the ceiling is not level. + if (!WorldUtils.Find(new(x, y), searchCondition, out Point top) || + !WorldUtils.Find(new(x + 1, y), searchCondition, out Point topRight) || top.Y != topRight.Y) + { + tryAgain = true; + } + + if (tryAgain) + { + c--; + continue; + } + + GeneratePillar(x, top.Y, y); + } + } + public static void CreateBeachNearSea() { int beachWidth = WorldGen.genRand.Next(150, 190 + 1); @@ -569,7 +626,7 @@ namespace CalamityMod.World var searchCondition = Searches.Chain(new Searches.Down(3000), new Conditions.IsSolid()); WorldUtils.Find(new Point(BiomeWidth + 4, (int)WorldGen.worldSurfaceLow - 20), searchCondition, out Point determinedPoint); Tile tileAtEdge = CalamityUtils.ParanoidTileRetrieval(determinedPoint.X, determinedPoint.Y); - + // Extend outward to encompass some of the desert, if there is one. if (tileAtEdge.TileType is TileID.Sand or TileID.Ebonsand or TileID.Crimsand) beachWidth += 85; @@ -798,6 +855,36 @@ namespace CalamityMod.World return result; } + + public static void GeneratePillar(int left, int top, int bottom) + { + int depth = BlockDepth; + ushort pillarID = (ushort)ModContent.TileType(); + ushort hardenedSandstoneWallID = (ushort)ModContent.WallType(); + ushort sandWallID = (ushort)ModContent.WallType(); + short variantFrameOffset = (short)(WorldGen.genRand.Next(3) * 36); + + for (int x = left; x < left + 2; x++) + { + for (int y = top; y <= bottom; y++) + { + short frameX = (short)((x - left) * 18 + variantFrameOffset); + + // Use the top frame if at the top, bottom frame if at the bottom, and the middle frame otherwise. + short frameY = 18; + if (y == top) + frameY = 0; + else if (y == bottom) + frameY = 36; + + Main.tile[x, y].TileType = pillarID; + Main.tile[x, y].TileFrameX = frameX; + Main.tile[x, y].TileFrameY = frameY; + Main.tile[x, y].WallType = y >= YStart + depth * OpenCavernStartDepthPercentage ? hardenedSandstoneWallID : sandWallID; + Main.tile[x, y].Get().HasTile = true; + } + } + } #endregion } } From 380b06a72bd80d8fcd92ad880c0d5f3b6c6c5059 Mon Sep 17 00:00:00 2001 From: Dominic Date: Fri, 7 Oct 2022 05:46:04 -0500 Subject: [PATCH 07/21] Island! --- Systems/WorldgenManagementSystem.cs | 2 +- Tiles/Abyss/SulphurousColumn.cs | 14 +- Walls/SulphurousSandWall.cs | 9 - Walls/SulphurousSandstoneWall.cs | 9 - World/SulphurousSea.cs | 261 ++++++++++++++++++++++++---- 5 files changed, 237 insertions(+), 58 deletions(-) diff --git a/Systems/WorldgenManagementSystem.cs b/Systems/WorldgenManagementSystem.cs index ab675b9354..ace6db60eb 100644 --- a/Systems/WorldgenManagementSystem.cs +++ b/Systems/WorldgenManagementSystem.cs @@ -193,7 +193,7 @@ namespace CalamityMod.Systems tasks.Insert(++currentFinalIndex, new PassLegacy("SulphurSea2", (progress, config) => { progress.Message = "Further polluting one of the oceans"; - SulphurousSea.FinishGeneratingSulphurSea(); + SulphurousSea.SulphurSeaGenerationAfterAbyss(); })); tasks.Insert(++currentFinalIndex, new PassLegacy("Roxcalibur", (progress, config) => diff --git a/Tiles/Abyss/SulphurousColumn.cs b/Tiles/Abyss/SulphurousColumn.cs index 031a863e24..d386f0c84e 100644 --- a/Tiles/Abyss/SulphurousColumn.cs +++ b/Tiles/Abyss/SulphurousColumn.cs @@ -42,14 +42,14 @@ namespace CalamityMod.Tiles.Abyss } public override void KillMultiTile(int i, int j, int frameX, int frameY) { - if (Main.netMode != NetmodeID.Server) + if (Main.netMode == NetmodeID.Server) + return; + + // Explode into a bunch of rocks when broken. + for (int k = 0; k < WorldGen.genRand.Next(3, 4 + 1); k++) { - for (int k = 0; k < WorldGen.genRand.Next(3, 4 + 1); k++) - { - Gore.NewGore(new EntitySource_TileBreak(i, j), new Vector2(i, j) * 16f, - Vector2.One.RotatedByRandom(MathHelper.TwoPi) * WorldGen.genRand.NextFloat(1.4f, 3.2f), - Mod.Find($"SulphurousRockGore{WorldGen.genRand.Next(3) + 1}").Type); - } + int goreID = Mod.Find($"SulphurousRockGore{WorldGen.genRand.Next(3) + 1}").Type; + Gore.NewGore(new EntitySource_TileBreak(i, j), new Vector2(i, j) * 16f, Main.rand.NextVector2Unit() * WorldGen.genRand.NextFloat(1.4f, 3.2f), goreID); } } public override void NumDust(int i, int j, bool fail, ref int num) diff --git a/Walls/SulphurousSandWall.cs b/Walls/SulphurousSandWall.cs index 4ba25cdf42..4ea9b6bf5e 100644 --- a/Walls/SulphurousSandWall.cs +++ b/Walls/SulphurousSandWall.cs @@ -13,15 +13,6 @@ namespace CalamityMod.Walls AddMapEntry(new Color(84, 71, 46)); } - public override void RandomUpdate(int i, int j) - { - if (Main.tile[i, j].LiquidAmount <= 0) - { - Main.tile[i, j].LiquidAmount = 255; - Main.tile[i, j].Get().LiquidType = LiquidID.Water; - } - } - public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; } } diff --git a/Walls/SulphurousSandstoneWall.cs b/Walls/SulphurousSandstoneWall.cs index c0b930621f..24b9f1da62 100644 --- a/Walls/SulphurousSandstoneWall.cs +++ b/Walls/SulphurousSandstoneWall.cs @@ -13,15 +13,6 @@ namespace CalamityMod.Walls AddMapEntry(new Color(57, 45, 38)); } - public override void RandomUpdate(int i, int j) - { - if (Main.tile[i, j].LiquidAmount <= 0) - { - Main.tile[i, j].LiquidAmount = 255; - Main.tile[i, j].Get().LiquidType = LiquidID.Water; - } - } - public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; } } diff --git a/World/SulphurousSea.cs b/World/SulphurousSea.cs index 0f4d178ea4..347f3a7aa1 100644 --- a/World/SulphurousSea.cs +++ b/World/SulphurousSea.cs @@ -1,7 +1,4 @@ -using CalamityMod.Items; -using CalamityMod.Items.Accessories; -using CalamityMod.Items.Weapons.Summon; -using CalamityMod.Schematics; +using CalamityMod.Schematics; using CalamityMod.Tiles.Abyss; using CalamityMod.Walls; using Microsoft.Xna.Framework; @@ -20,7 +17,6 @@ namespace CalamityMod.World { #region Fields and Properties - // Loop variables that are accessed via getter methods should be stored externally in local variables for performance reasons. public static readonly List SulphSeaTiles = new() { ModContent.TileType(), @@ -35,7 +31,7 @@ namespace CalamityMod.World // start randomly dithering. public const float DitherStartFactor = 0.9f; - public const int DepthForWater = 18; + public const int DepthForWater = 12; public const float TopWaterDepthPercentage = 0.125f; @@ -47,6 +43,10 @@ namespace CalamityMod.World public const int TotalSandTilesBeforeWaterMax = 45; + public const float OpenSeaWidthPercentage = 0.53f; + + public const float IslandCurvatureSharpness = 0.74f; + // 0-1 value of how jagged the small caves should be. The higher this value is, the more variance you can expect for each step when carving out caves. public const float SmallCavesJaggedness = 0.51f; @@ -76,6 +76,11 @@ namespace CalamityMod.World // Percentage of how far down a tile has to be for open caverns to appear. public const float OpenCavernStartDepthPercentage = 0.42f; + // The percentage of tiles on average that should be transformed into water. + // A value of 1 indicates that every tile should have water. + // This value should be close to 1, but not exactly, so that when water settles the top of caverns will be open. + public const float WaterSpreadPercentage = 0.95f; + public const float HardenedSandstoneLineMagnification = 0.004f; public const int MaxIslandHeight = 16; @@ -86,11 +91,17 @@ namespace CalamityMod.World public const int TreeGrowChance = 5; - // The percentage of tiles on average that should be transformed into water. - // A value of 1 indicates that every tile should have water. - // This value should be close to 1, but not exactly, so that when water settles the top of caverns will be open. - public const float WaterSpreadPercentage = 0.95f; + public const int MinColumnHeight = 5; + public const int MaxColumnHeight = 50; + + public const int BeachMaxDepth = 50; + + public const int ScrapPileAnticlumpDistance = 80; + + public const float SandstoneEdgeNoiseMagnification = 0.00115f; + + // Loop variables that are accessed via getter methods should be stored externally in local variables for performance reasons. public static int BiomeWidth { get @@ -155,11 +166,15 @@ namespace CalamityMod.World #region Placement Methods public static void PlaceSulphurSea() { + // Determine which side the abyss is such that it's at the same side as the dungeon. Abyss.AtLeftSideOfWorld = Main.dungeonX < Main.maxTilesX / 2; + + // Settle the foundation for the sea. This involves creating the base sulphurous sea block, old tile cleanup, and creating water at the surface. DetermineYStart(); GenerateSandBlock(); RemoveStupidTilesAboveSea(); GenerateShallowTopWater(); + GenerateIsland(); // Cave generation. Some of these borrow concepts and tricks used by Minecraft's new generation. GenerateSmallWaterCaverns(); @@ -172,12 +187,14 @@ namespace CalamityMod.World DecideHardSandstoneLine(); MakeSurfaceLessRigid(); LayTreesOnSurface(); - GeneratePillarsInCaverns(); } - - public static void FinishGeneratingSulphurSea() + + public static void SulphurSeaGenerationAfterAbyss() { CreateBeachNearSea(); + PlaceScrapPiles(); + GeneratePillarsInCaverns(); + GenerateHardenedSandstone(); } #endregion @@ -237,8 +254,9 @@ namespace CalamityMod.World { int maxDepth = MaxTopWaterDepth; int totalSandTilesBeforeWater = WorldGen.genRand.Next(TotalSandTilesBeforeWaterMin, TotalSandTilesBeforeWaterMax); - int width = (int)((BiomeWidth - totalSandTilesBeforeWater) * 0.42f); + int width = (int)((BiomeWidth - totalSandTilesBeforeWater) * OpenSeaWidthPercentage); float descentSmoothness = WorldGen.genRand.NextFloat(TopWaterDescentSmoothnessMin, TopWaterDescentSmoothnessMax); + for (int i = 1; i < width; i++) { int x = GetActualX(i); @@ -262,6 +280,37 @@ namespace CalamityMod.World } } + public static void GenerateIsland() + { + int left = -32; + int right = (int)(BiomeWidth * OpenSeaWidthPercentage * 0.68f); + int maxDepth = MaxTopWaterDepth; + ushort blockTileType = (ushort)ModContent.TileType(); + ushort wallID = (ushort)ModContent.WallType(); + + for (int i = left; i < right; i++) + { + if (i < 0) + continue; + + // Generate a bump at the edge of the ocean as an island. + // The inside of this is by default solid but cave generation can sometimes create a really cool "hollow" look. + int x = GetActualX(i); + float xCompletionRatio = Utils.GetLerpValue(left, right, i, true); + int islandHeight = (int)Math.Round(Math.Pow(CalamityUtils.Convert01To010(xCompletionRatio), IslandCurvatureSharpness) * (maxDepth + 4f)); + for (int dy = -30; dy <= islandHeight; dy++) + { + int y = YStart + maxDepth - dy; + Main.tile[x, y].TileType = blockTileType; + + if (dy < islandHeight) + Main.tile[x, y].WallType = wallID; + Main.tile[x, y].LiquidAmount = byte.MaxValue; + Main.tile[x, y].Get().HasTile = true; + } + } + } + public static void GenerateSmallWaterCaverns() { int width = BiomeWidth; @@ -342,6 +391,7 @@ namespace CalamityMod.World // This causes caves to naturally stop as the reach ends instead of abruptly stopping like in the old Sulphurous Sea worldgen. float distanceFromEdge = new Vector2(i / (float)width, (y - YStart) / (float)depth).Length(); float biasAwayFrom0Interpolant = Utils.GetLerpValue(0.82f, 0.96f, distanceFromEdge * 0.8f, true); + biasAwayFrom0Interpolant += Utils.GetLerpValue(YStart + 12f, YStart, y, true) * 0.2f; // If the noise is less than 0, bias to -1, if it's greater than 0, bias away to 1. // This is done instead of biasing to -1 or 1 without exception to ensure that in doing so the noise does not cross into the @@ -401,23 +451,22 @@ namespace CalamityMod.World int depth = BlockDepth; ushort blockTileType = (ushort)ModContent.TileType(); ushort wallID = (ushort)ModContent.WallType(); - - void recursivelyGetAttachedPoints(int x, int y, List points) + + void getAttachedPoints(int x, int y, List points) { Tile t = CalamityUtils.ParanoidTileRetrieval(x, y); Point p = new(x, y); - if (t.TileType != blockTileType || !t.HasTile || points.Count > 300 || points.Contains(p)) + if (t.TileType != blockTileType || !t.HasTile || points.Count > 300 || points.Contains(p) || CalculateDitherChance(width, YStart, YStart + depth, x, y) > 0f) return; points.Add(p); - recursivelyGetAttachedPoints(x + 1, y, points); - recursivelyGetAttachedPoints(x - 1, y, points); - recursivelyGetAttachedPoints(x, y + 1, points); - recursivelyGetAttachedPoints(x, y - 1, points); + getAttachedPoints(x + 1, y, points); + getAttachedPoints(x - 1, y, points); + getAttachedPoints(x, y + 1, points); + getAttachedPoints(x, y - 1, points); } - // Clear out stray chunks created by caverns. for (int i = 1; i < width; i++) { @@ -425,7 +474,7 @@ namespace CalamityMod.World for (int y = YStart; y < YStart + depth; y++) { List chunkPoints = new(); - recursivelyGetAttachedPoints(x, y, chunkPoints); + getAttachedPoints(x, y, chunkPoints); int cutoffLimit = y >= YStart + depth * OpenCavernStartDepthPercentage ? 300 : 50; if (chunkPoints.Count >= 2 && chunkPoints.Count < cutoffLimit) @@ -536,7 +585,7 @@ namespace CalamityMod.World WorldUtils.Gen(new(x, y + dy), new Shapes.Rectangle(1, 1), Actions.Chain(new GenAction[] { heightOffset > 0 ? new Actions.ClearTile() : new Actions.SetTile(blockTileType, true), - new Actions.PlaceWall(MathHelper.Distance(dy, heightOffset) >= 2f ? wallID : WallID.None, true), + new Actions.PlaceWall(MathHelper.Distance(dy, heightOffset) >= 2f && heightOffset < 0f ? wallID : WallID.None, true), new Actions.SetLiquid() })); } @@ -576,13 +625,153 @@ namespace CalamityMod.World } } + public static void GenerateHardenedSandstone() + { + int sandstoneSeed = WorldGen.genRand.Next(); + ushort sandstoneID = (ushort)ModContent.TileType(); + ushort sandstoneWallID = (ushort)ModContent.WallType(); + + // Edge score evaluation function that determines the propensity a tile has to become sandstone. + // This is based on how much nearby empty areas there are, allowing for "edges" to appear. + static int getEdgeScore(int x, int y) + { + int edgeScore = 0; + for (int dx = x - 6; dx <= x + 6; dx++) + { + if (dx == x) + continue; + + if (!CalamityUtils.ParanoidTileRetrieval(dx, y).HasTile) + edgeScore++; + } + for (int dy = y - 6; dy <= y + 6; dy++) + { + if (dy == y) + continue; + + if (!CalamityUtils.ParanoidTileRetrieval(x, dy).HasTile) + edgeScore++; + } + return edgeScore; + } + + for (int i = 1; i < BiomeWidth; i++) + { + for (int y = YStart; y <= YStart + BlockDepth; y++) + { + int x = GetActualX(i); + float sandstoneConvertChance = FractalBrownianMotion(i * SandstoneEdgeNoiseMagnification, y * SandstoneEdgeNoiseMagnification, sandstoneSeed, 7) * 0.5f + 0.5f; + + // Make the sandstone appearance chance dependant on the edge score. + sandstoneConvertChance *= Utils.GetLerpValue(4f, 11f, getEdgeScore(x, y), true); + + // Make sandstone less likely to appear on the surface. + sandstoneConvertChance *= Utils.GetLerpValue(YStart + 30f, YStart + 54f, y, true); + + if (WorldGen.genRand.NextFloat() > sandstoneConvertChance || sandstoneConvertChance < 0.5f) + continue; + + // Convert to sandstone as necessary. + for (int dx = -2; dx <= 2; dx++) + { + for (int dy = -2; dy <= 2; dy++) + { + if (WorldGen.InWorld(x + dx, y + dy)) + { + if (CalamityUtils.ParanoidTileRetrieval(x + dx, y + dy).TileType != sandstoneID && + SulphSeaTiles.Contains(CalamityUtils.ParanoidTileRetrieval(x + dx, y + dy).TileType)) + { + Main.tile[x + dx, y + dy].WallType = sandstoneWallID; + Main.tile[x + dx, y + dy].TileType = sandstoneID; + } + } + } + } + } + } + } + + public static void PlaceScrapPiles() + { + int tries = 0; + List pastPlacementPostiion = new List(); + for (int i = 0; i < 3; i++) + { + tries++; + if (tries > 20000) + continue; + + int x = GetActualX(WorldGen.genRand.Next(75, BiomeWidth - 85)); + int y = WorldGen.genRand.Next(YStart + (int)(BlockDepth * 0.3f), YStart + (int)(BlockDepth * 0.8f)); + + Point pilePlacementPosition = new Point(x, y); + + // If the selected position is sitting inside of a tile, try again. + if (WorldGen.SolidTile(pilePlacementPosition.X, pilePlacementPosition.Y)) + { + i--; + continue; + } + + // If the selected position is close to other piles, try again. + if (pastPlacementPostiion.Any(p => Vector2.Distance(p, pilePlacementPosition.ToVector2()) < ScrapPileAnticlumpDistance)) + { + i--; + continue; + } + + // Otherwise, decide which pile should be created. + int pileVariant = WorldGen.genRand.Next(7); + string schematicName = $"Sulphurous Scrap {pileVariant + 1}"; + Vector2? wrappedSchematicArea = SchematicManager.GetSchematicArea(schematicName); + + // Create a log message if for some reason the schematic in question doesn't exist. + if (!wrappedSchematicArea.HasValue) + { + CalamityMod.Instance.Logger.Warn($"Tried to place a schematic with name \"{schematicName}\". No matching schematic file found."); + continue; + } + + Vector2 schematicArea = wrappedSchematicArea.Value; + + // Decide the placement position by searching downward and looking for the lowest point. + // If the position is quite steep, try again. + Vector2 left = pilePlacementPosition.ToVector2() - Vector2.UnitX * schematicArea.X * 0.5f; + Vector2 right = pilePlacementPosition.ToVector2() + Vector2.UnitX * schematicArea.X * 0.5f; + while (!WorldGen.SolidTile(CalamityUtils.ParanoidTileRetrieval((int)left.X, (int)left.Y))) + left.Y++; + while (!WorldGen.SolidTile(CalamityUtils.ParanoidTileRetrieval((int)right.X, (int)right.Y))) + right.Y++; + + if (Math.Abs(left.Y - right.Y) >= 20f) + { + i--; + continue; + } + + // If the placement position ended up in the abyss, try again. + if (left.Y >= YStart + BlockDepth - 30 || right.Y >= YStart + BlockDepth - 30) + { + i--; + continue; + } + + // Pick the lowest point vertically. + Point bottomCenter = new Point(pilePlacementPosition.X, (int)Math.Max(left.Y, right.Y) + 6); + bool _ = false; + SchematicManager.PlaceSchematic>(schematicName, bottomCenter, SchematicAnchor.BottomCenter, ref _); + + pastPlacementPostiion.Add(bottomCenter.ToVector2()); + tries = 0; + } + } + public static void GeneratePillarsInCaverns() { int columnCount = ColumnCount; int width = BiomeWidth; int depth = BlockDepth; - int maxColumnHeight = 45; - var searchCondition = Searches.Chain(new Searches.Up(maxColumnHeight), new Conditions.IsSolid()); + var searchCondition = Searches.Chain(new Searches.Up(MaxColumnHeight), new Conditions.IsSolid()); for (int c = 0; c < columnCount; c++) { @@ -599,7 +788,7 @@ namespace CalamityMod.World tryAgain = true; // Try again if there is no bottom tile. - if (!bottom.HasTile || !bottomRight.HasTile) + if (!WorldGen.SolidTile(bottom) || !WorldGen.SolidTile(bottomRight)) tryAgain = true; // Try again if there is no tile above or the ceiling is not level. @@ -609,6 +798,10 @@ namespace CalamityMod.World tryAgain = true; } + // Try again if the distance between the top and bottom is too short. + if (MathHelper.Distance(y, top.Y) < MinColumnHeight) + tryAgain = true; + if (tryAgain) { c--; @@ -622,9 +815,13 @@ namespace CalamityMod.World public static void CreateBeachNearSea() { int beachWidth = WorldGen.genRand.Next(150, 190 + 1); - var searchCondition = Searches.Chain(new Searches.Down(3000), new Conditions.IsSolid()); - WorldUtils.Find(new Point(BiomeWidth + 4, (int)WorldGen.worldSurfaceLow - 20), searchCondition, out Point determinedPoint); + ushort sandID = (ushort)ModContent.TileType(); + + // Stop immediately if for some strange reason a valid tile could not be located for the beach starting point. + if (!WorldUtils.Find(new Point(BiomeWidth + 4, (int)WorldGen.worldSurfaceLow - 20), searchCondition, out Point determinedPoint)) + return; + Tile tileAtEdge = CalamityUtils.ParanoidTileRetrieval(determinedPoint.X, determinedPoint.Y); // Extend outward to encompass some of the desert, if there is one. @@ -637,7 +834,7 @@ namespace CalamityMod.World int x = GetActualX(i); float xRatio = Utils.GetLerpValue(BiomeWidth - 10, BiomeWidth + beachWidth, i, true); float ditherChance = Utils.GetLerpValue(0.92f, 0.99f, xRatio, true); - int depth = (int)(Math.Sin((1f - xRatio) * MathHelper.PiOver2) * 45f + 1f); + int depth = (int)(Math.Sin((1f - xRatio) * MathHelper.PiOver2) * BeachMaxDepth + 1f); for (int y = YStart - 50; y < YStart + depth; y++) { Tile tileAtPosition = CalamityUtils.ParanoidTileRetrieval(x, y); @@ -651,7 +848,7 @@ namespace CalamityMod.World } else if (tileAtPosition.HasTile && ValidBeachCovertTiles.Contains(tileAtPosition.TileType) && WorldGen.genRand.NextFloat() >= ditherChance) - Main.tile[x, y].TileType = (ushort)ModContent.TileType(); + Main.tile[x, y].TileType = sandID; } } @@ -663,7 +860,7 @@ namespace CalamityMod.World continue; int y = YStart - 30; - if (!WorldUtils.Find(new Point(trueX, y), Searches.Chain(new Searches.Down(100), new Conditions.IsTile((ushort)ModContent.TileType())), out Point treePlantPosition)) + if (!WorldUtils.Find(new Point(trueX, y), Searches.Chain(new Searches.Down(100), new Conditions.IsTile(sandID)), out Point treePlantPosition)) continue; treePlantPosition.Y--; From e91ade8bf7251d42be19bdba0225e2ea512c1dcd Mon Sep 17 00:00:00 2001 From: Dominic Date: Fri, 7 Oct 2022 06:13:54 -0500 Subject: [PATCH 08/21] Minor wall fixes --- World/SulphurousSea.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/World/SulphurousSea.cs b/World/SulphurousSea.cs index 347f3a7aa1..c61bca636e 100644 --- a/World/SulphurousSea.cs +++ b/World/SulphurousSea.cs @@ -183,7 +183,6 @@ namespace CalamityMod.World ClearOutStrayTiles(); // Lay down decorations and post-processing effects after the caves are generated. - ClearAloneTiles(); DecideHardSandstoneLine(); MakeSurfaceLessRigid(); LayTreesOnSurface(); @@ -192,6 +191,7 @@ namespace CalamityMod.World public static void SulphurSeaGenerationAfterAbyss() { CreateBeachNearSea(); + ClearAloneTiles(); PlaceScrapPiles(); GeneratePillarsInCaverns(); GenerateHardenedSandstone(); @@ -204,6 +204,8 @@ namespace CalamityMod.World int width = BiomeWidth + 1; int maxDepth = BlockDepth; ushort blockTileType = (ushort)ModContent.TileType(); + ushort wallID = (ushort)ModContent.WallType(); + for (int i = 1; i < width; i++) { int x = GetActualX(i); @@ -218,7 +220,11 @@ namespace CalamityMod.World { float ditherChance = CalculateDitherChance(width, top, bottom, i, y); if (WorldGen.genRand.NextFloat() >= ditherChance) + { Main.tile[x, y].TileType = blockTileType; + if (y >= top + 45) + Main.tile[x, y].WallType = wallID; + } // Ensure that the sand pops into existence if there is no chance that dithering will occur. // This doesn't happen if there is dithering to ensure that there aren't stray sand tiles in the middle of open From 2d89b0d9d4228932a1ad8a3d2b4cb69a7176c19c Mon Sep 17 00:00:00 2001 From: Dominic Date: Fri, 7 Oct 2022 17:03:26 -0500 Subject: [PATCH 09/21] 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; From 91a90a53251b7274e4cb3d61c1c815d1843e250a Mon Sep 17 00:00:00 2001 From: Dominic Date: Fri, 7 Oct 2022 18:24:49 -0500 Subject: [PATCH 10/21] Minor steam adjustments --- ILEditing/MechanicILChanges.cs | 7 +++++++ Projectiles/Environment/HotSteam.cs | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ILEditing/MechanicILChanges.cs b/ILEditing/MechanicILChanges.cs index a58deb39f0..08f9d43e40 100644 --- a/ILEditing/MechanicILChanges.cs +++ b/ILEditing/MechanicILChanges.cs @@ -894,6 +894,13 @@ namespace CalamityMod.ILEditing if (tile.LiquidAmount <= 0 || tile.HasTile || Main.waterStyle != ModContent.Find("CalamityMod/SulphuricWater").Slot) return; + Tile above = CalamityUtils.ParanoidTileRetrieval(x, y - 1); + if (!Main.gamePaused && !above.HasTile && above.LiquidAmount <= 0 && Main.rand.NextBool(9)) + { + MediumMistParticle acidFoam = new(new(x * 16f + Main.rand.NextFloat(16f), y * 16f + 8f), -Vector2.UnitY.RotatedByRandom(0.67f) * Main.rand.NextFloat(1f, 2.4f), Color.LightSeaGreen, Color.White, 0.16f, 128f, 0.02f); + GeneralParticleHandler.SpawnParticle(acidFoam); + } + outputColor = Vector3.Lerp(outputColor, Color.LightSeaGreen.ToVector3(), 0.41f); } #endregion Sulph Sea Water Visuals diff --git a/Projectiles/Environment/HotSteam.cs b/Projectiles/Environment/HotSteam.cs index 143dcbf76b..1e4a674748 100644 --- a/Projectiles/Environment/HotSteam.cs +++ b/Projectiles/Environment/HotSteam.cs @@ -38,7 +38,7 @@ namespace CalamityMod.Projectiles.Environment { 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.Opacity = Utils.Remap(Projectile.timeLeft, 160f, 50f, 1.15f, 0.01f); Projectile.velocity.Y *= 0.97f; } @@ -65,8 +65,8 @@ namespace CalamityMod.Projectiles.Environment 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; + float opacity = Projectile.Opacity * 0.3f; + Color drawColor = new Color(159, 207, 181) * opacity; Vector2 scale = Projectile.Size / texture.Size() * Projectile.scale * 1.35f; spriteBatch.Draw(texture, drawPosition, null, drawColor, Projectile.rotation, origin, scale, 0, 0f); } From 2062dad543ab6d76087da147e3a3fd937938788b Mon Sep 17 00:00:00 2001 From: Dominic Date: Fri, 7 Oct 2022 22:28:20 -0500 Subject: [PATCH 11/21] Stalactites/mites. Finally fixed the tile sheets --- .../Stalactite/SulphurousStalacmite1.png | Bin 428 -> 254 bytes .../Stalactite/SulphurousStalacmite2.png | Bin 400 -> 246 bytes .../Stalactite/SulphurousStalacmite3.png | Bin 518 -> 268 bytes .../Stalactite/SulphurousStalacmite4.png | Bin 577 -> 280 bytes .../Stalactite/SulphurousStalacmite5.png | Bin 555 -> 292 bytes .../Stalactite/SulphurousStalacmite6.png | Bin 700 -> 324 bytes .../Abyss/Stalactite/SulphurousStalactite1.cs | 4 +- .../Stalactite/SulphurousStalactite1.png | Bin 448 -> 256 bytes .../Abyss/Stalactite/SulphurousStalactite2.cs | 4 +- .../Stalactite/SulphurousStalactite2.png | Bin 439 -> 245 bytes .../Abyss/Stalactite/SulphurousStalactite3.cs | 4 +- .../Stalactite/SulphurousStalactite3.png | Bin 552 -> 269 bytes .../Abyss/Stalactite/SulphurousStalactite4.cs | 4 +- .../Stalactite/SulphurousStalactite4.png | Bin 582 -> 283 bytes .../Abyss/Stalactite/SulphurousStalactite5.cs | 4 +- .../Stalactite/SulphurousStalactite5.png | Bin 583 -> 288 bytes .../Abyss/Stalactite/SulphurousStalactite6.cs | 4 +- .../Stalactite/SulphurousStalactite6.png | Bin 698 -> 320 bytes World/SulphurousSea.cs | 343 +++++++++++------- 19 files changed, 221 insertions(+), 146 deletions(-) diff --git a/Tiles/Abyss/Stalactite/SulphurousStalacmite1.png b/Tiles/Abyss/Stalactite/SulphurousStalacmite1.png index a7340e66a7135204ce6981a04f5b6b781439b986..a1315356935d75dba6170119d49c145d38272e55 100644 GIT binary patch delta 212 zcmZ3({EtzwGr-TCmrII^fq{Y7)59eQNDBe63I{Wg+-yAS>O@5aQ;7hd5LZisU?o`v zA1mwLO5egL_jE@GMmBz+A`Y*F77$eu&zYohP7t&frpnF#+lD=cGqDF2kj2B;qM}I zTP;rM7GkWuzQ3eM$%*_o+6oeIe{$H~!=UK-SQ~woF}{7cKpIz&xxx9_HcU?Dq?k@w ze+5~re}nh88Ps8~0=j>)kgvd1vEPHAdCbXXaKgwe>{swt>~G*#0*9=+5quft;eKNV z#j+IR3ep{Q-+{x<@|n1MTxN-n@tfh-2;4q^O@5aL(u@A5LYExg~BLz zOM_rWHvV)+2OleIpo(etPjvt(_L3mK;QwI2Amz>MHqlNzmm%EK#W6%9c<*^{z6Jvh zmJ4ER@9I-je`Kx^d35OJlszq(8CFmAv%Z(?xxcbpX?{}DI>8B-XUxco6-`oOa{2RR yhRX(Z^~0i(JD>hZa1DFET5_*W+?O*htE4Yo=4tE--5CnBm%-E3&t;ucLK6TvAW8)Q delta 379 zcmV->0fhec0gwYBiBL{Q4GJ0x0000DNk~Le0000G0000Y2nGNE09HX+$B`i*e+h6% zS#tmY4!-~Z4!;371ydvd00AXQL_t(YOU0DIYr-%T#+za-G4`ZMP*38-r=qTzJV2)KsMC(0;2x~$z2LzdboJ=snCbuk002ovPDHLkV1j!ypRxb| diff --git a/Tiles/Abyss/Stalactite/SulphurousStalacmite3.png b/Tiles/Abyss/Stalactite/SulphurousStalacmite3.png index 56f5f2a261c06e871bd118d4faf6521a8e469fe8..d935926115c8ec8806703f95d8366c75b775bf03 100644 GIT binary patch delta 226 zcmZo;>0wgr4DfU3<&xrJU|`_&^l%9R(n3IN#=#6E|LR)0PE=Gdl?d<&arLpXW@O{< zt@O1t2ri6rPj_@sl2rgI+7hwG6-aTE1o;L3hX96q&3hv!+KJaQWO}+dhFJLTJ@3hN zK!L~MV$auq=6PFKvSgJs{#wtM;90UPw(0s+`4*2OG3T!7bsh;ZU$ixHx#!niT|S;q zSQMG&EXuF_)V}XhM@Ts5nvNNre>U4XrD*r}d#vqXm=hxS{L31n+a delta 498 zcmVbZYKY&K8f4w%axq1?40#Eqfz^y_kIt*W)(cs~B48K2-jN_S` zYKn{JvENn>RP+ak0H0g*)I`!MMw~Qf~j;3GV511iQje!K0!PmgFeH5e*)@2QYM*z zzKXgts6Rd1q?PGOM)FGVRp^KB4MJiLXrm+We6~{wt&oMcTP=9)@dbWgv*1;$0aus6 z0evnipcUOo1R8fu_(8b>cff>Fe~4qT2;`OE%XnF_pxfpfB;!9pDxPK}8G0X(78f!Q zRYk50;X48K0qSq)OSmC0Nc2v}$?P6p@KsQKAf_;Np6I@h7z~FYb!Q;{19BJ26IrC% oDxJdBpMi|%M1lOC@R@+IcNI5z*5Bfl_W%F@07*qoM6N<$f@D13P5=M^ diff --git a/Tiles/Abyss/Stalactite/SulphurousStalacmite4.png b/Tiles/Abyss/Stalactite/SulphurousStalacmite4.png index 792626edd6493bc028f64472b80a285a0a384c2b..d716be54c5747588e50d7f82dc7ca760e58ff436 100644 GIT binary patch delta 239 zcmX@eGJ{F6Gr-TCmrII^fq{Y7)59eQNDBe683!|v{Htr}I#E%y~11ZjuAiv=MP{0uEUm-NnPQ0F>(9^{+#KM2? zxr=-U1bA8>E;{ww{$te*J&9SZZ}uzfTe2W#QMLR33B{%E#-Hq1-k*-Vt^7>FKk#b412{W&nUmMOyJ#OnSf|*-m3DI;0NupE;pyt^VlT*v?b delta 558 zcmV+}0@3}L0>K0!iBL{Q4GJ0x0000DNk~Le0000G0000q2nGNE0E5oBL6IRKe+h6% zS#tmY4!-~Z4!;371ydvd00GuXL_t(YOU;$dF9Sgs#;2{%rbR_aeIz1WL>dy((u<1| zH~t1^|Cob>lcV5(L>iG$@e!(sW|OLJKQwFKXJ;CgNv#=)U-IOcx4YSScING@kGWWy zOY#x3xZ|G9y)dKYTzaf7k>G+_f9!1od5*om_^;#!PsyxrSXRRs*;vm2M|v z`^W2Wf&MkHXR=7~M3|98%`bmJUxHHEfV`qHLB&pB>oIo(WwK?c5&9C8?b%6QQBF|r z#F3$4_)M%9UNnR7-tI2==|uqk_nmlG z2AL&`v@kl%NIykALG`W1NLP;rB%@M&fy9~#)DygxtBlkLBY$p@cv(k10e2~}NDh+m zcM0xpDo`-m3dzu)pwWzOloR-TEu9!7#s}fu9nLp!v@Zg`e|~}I3(g6hesH?=^7b08 zFM$oZY;7fhLQv%2hV2Vyf5!fvFwRktOn-va+b`vs6Qau5n?1k z#y%TJKSe!3HeawvwEAKPK0ZI1dP1{vz*cO_$JlP00000NkvXX1g=70f{l3jh5!Hn diff --git a/Tiles/Abyss/Stalactite/SulphurousStalacmite5.png b/Tiles/Abyss/Stalactite/SulphurousStalacmite5.png index 532fd83e592b3186da5666406df39e18a8ef6862..47d6ffb3d69674c6986d3f337a540c3603c87119 100644 GIT binary patch delta 251 zcmZ3@vV=*oGr-TCmrII^fq{Y7)59eQNDBe62M05dJi{9LWul^jrF4K#h^vp4wWUGu zib)~8mA*={3h9mxg;DN|Z2UlVtDL#l04dIrAiv=MP{0uEUm-NnPQ0F>*3-o?#KQmW zxr=-a3LLBf9uEKicMG3g7JO;#wW=5U3h%folvK7asM_V;k-a51(`%>F5tHK)SB@#U zJl_>7EBJTH%3jx~6ur>dF4sJstY&dAQGO=5RdVuohNu*~Zs(+H$}aO1V)r}k^fF8i sIuX*hb>+VVx8_HVRWY;soNh3RWaTM%o^L6i1au&Sr>mdKI;Vst0KYI_A^-pY delta 535 zcmV+y0_gpu0;>ceiBL{Q4GJ0x0000DNk~Le0000G0000+2nGNE0L3H}i;*E9e+h6% zS#tmY4!-~Z4!;371ydvd00F>BL_t(oN9~l$PQpMKg^Lj|fQV=$#6XDAjZwn_5-*RS zJKw+;@X6e{bL(YcNYI5V7noR746#%~EEUGinVBY(lv}54jZN4;F$-tbW`bKECp&;o>Oe<1P_9OO?SvlD_wMScx*BT1L3)nZ(e?}$;FYc|u zy9T?3RbfiQ48z6EB>xreA8Ukazqky|H=2;OGsGXW@vn%lFKuWT{v{AZ(qYIA z{}T-3KQ2Hzb%=gDRMSha5_yMeT7^*YpQn(Z^=3eBcuo)qgqASaOs~STsW?0pi^8L! zAiVnd4cFW33sp58E-!%vZ7O?Q*ui8g7lS+B|LVEIN9;b8e+uj2AS4j?f!nNG?VdDks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d5L_JG z`hWP}IXF8yI0@n)2qJ}0P$5(uf^F3^_q}_eL?Y6S%(& zs$8ZIN^7Srp<-vq{#+8S14gdIP#xhqINa)ymMv@X-vOV<>H8;idVUK-OwQ@a*w`KL4|Xo5Bow=h|sFcOY~IoWo!EmkfTy@dZMB0rP{6!;MTk-v9sr M07*qoM6N<$f>}+x5C8xG diff --git a/Tiles/Abyss/Stalactite/SulphurousStalactite3.cs b/Tiles/Abyss/Stalactite/SulphurousStalactite3.cs index 56e2ad29eb..2cd9ff358b 100644 --- a/Tiles/Abyss/Stalactite/SulphurousStalactite3.cs +++ b/Tiles/Abyss/Stalactite/SulphurousStalactite3.cs @@ -1,4 +1,4 @@ -using CalamityMod.Dusts; +using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -28,7 +28,7 @@ namespace CalamityMod.Tiles.Abyss.Stalactite TileObjectData.newTile.CoordinatePadding = 2; TileObjectData.newTile.WaterDeath = false; TileObjectData.newTile.LavaDeath = true; - TileObjectData.newTile.DrawYOffset = 2; + TileObjectData.newTile.DrawYOffset = -2; TileObjectData.addTile(Type); ModTranslation name = CreateMapEntryName(); name.SetDefault("Stalactite"); diff --git a/Tiles/Abyss/Stalactite/SulphurousStalactite3.png b/Tiles/Abyss/Stalactite/SulphurousStalactite3.png index 3503dcbd7148a3a60f540979b2452b3b19b2cd89..6b81d670af908ebbfd7aad1f012bd091c3f97a5e 100644 GIT binary patch delta 228 zcmZ3%(#xdS8Q|y6%O%Cdz`(%k>ERLtq=kUkjDs0S{?)Z~ov5f_DiPol;>yUz?_*`1 z?&we$i_r2d`T0!VR`1o;L3hX96q&3hv!+KJaQWO=$chFJLTJ^zre zL4m_9@PL2Ce{;T~ysJXDH@%a8ezU;I<;){P@%|G!iy0;wGS1C1&3AEda9gO<@M?}% zV!q$Ui*s(BvW(rm-0sG)dw~z4UcG+8@}~Sfzm@r-<>yzgQ!;*5=Jx->M*ovJ%+d_P W3$LgK=K$Tp;O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(R3y+58;Q68*e)o6|f9HtTKzD=t+M_!M)BOoPD!n$1}M?|36cDCl39_ogD1J8_jPd z@Od40=Ir{0YzTR$z+pQ>9P`|a`~;ICxPYSk0;(6Hf24Chga7~l2>?k&PDHLkV1o6N B19SiY diff --git a/Tiles/Abyss/Stalactite/SulphurousStalactite5.cs b/Tiles/Abyss/Stalactite/SulphurousStalactite5.cs index 44fcda7007..aee43c8e76 100644 --- a/Tiles/Abyss/Stalactite/SulphurousStalactite5.cs +++ b/Tiles/Abyss/Stalactite/SulphurousStalactite5.cs @@ -1,4 +1,4 @@ -using CalamityMod.Dusts; +using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -29,7 +29,7 @@ namespace CalamityMod.Tiles.Abyss.Stalactite TileObjectData.newTile.CoordinatePadding = 2; TileObjectData.newTile.WaterDeath = false; TileObjectData.newTile.LavaDeath = true; - TileObjectData.newTile.DrawYOffset = 2; + TileObjectData.newTile.DrawYOffset = -2; TileObjectData.addTile(Type); ModTranslation name = CreateMapEntryName(); name.SetDefault("Stalactite"); diff --git a/Tiles/Abyss/Stalactite/SulphurousStalactite5.png b/Tiles/Abyss/Stalactite/SulphurousStalactite5.png index be82d5b48f77282d89a1aa77b90a328a5449dfdb..5b635ff2ae989a1dcf228c7a6f6072afdabb1741 100644 GIT binary patch delta 247 zcmX@kvVcjkGr-TCmrII^fq{Y7)59eQNDBe62M05dJi{9LWul^jrF4K#h$|x-zmJu5 zVU&Biql1#Hf~7%lZ>8^wNg+UW^QSS&0x8atAiv=MP{0uEUm-NnPQ0F>($mE;#KQmS zIY+(&3LGwhjDhd!ABpvJZgY*@Vem5k>U5q=4o00l%3XmeZXL-=mms5>nzopr05CdRk^lez delta 564 zcmV-40?YlN0>=a)iBL{Q4GJ0x0000DNk~Le0000G0000+2nGNE0L3H}i;*E9e+h6% zS#tmY4!-~Z4!;371ydvd00G=dL_t(oN9~kPO9DX{#&@$+R5oKnv(hArASwjw(7$V! z0uNpL27RBtLr{kx=n$Qvx_T0V2uZerNK8pmLECv|#%woHnOQISgU5GXcb)gycidN1 z-J=b~WOsFm1RL}509#SYFBQbge}^pM5IzOyc>`a>196;lFy$G6ION$|#SwO(>iQ%W z`O@dF)8N%xpO-;fxdMBKBzCj^?3-#ZDmH)6oyE(vd&cXDI8|s9x z1KT`UTL~f7E3~>62qGG641Cn+n|YT$MU?Nr1QY4-U>V8DMY9jMmsjREcM9Dy*kG^$ zLEZ))_ZZYG@*E7iyiizAe?r|N?4UUh))V`PiN!i%p-3+UHH-%(ouRdyp9f~822pB< zis$UI4fzhNY$dBI5ld|dJFuOC37%K?y&{Q4y}0M-_zJld`907)d6kHz%2VzOYKOcY zaP~Gf*^2hU1oxcZ-XO6ezXvUl$~K2qgdGe}lyA7Zko4}F)5HJ(3IG5}MNUMnLSTZR CA@>~s diff --git a/Tiles/Abyss/Stalactite/SulphurousStalactite6.cs b/Tiles/Abyss/Stalactite/SulphurousStalactite6.cs index 0639322afc..465b858efe 100644 --- a/Tiles/Abyss/Stalactite/SulphurousStalactite6.cs +++ b/Tiles/Abyss/Stalactite/SulphurousStalactite6.cs @@ -1,4 +1,4 @@ -using CalamityMod.Dusts; +using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -29,7 +29,7 @@ namespace CalamityMod.Tiles.Abyss.Stalactite TileObjectData.newTile.CoordinatePadding = 2; TileObjectData.newTile.WaterDeath = false; TileObjectData.newTile.LavaDeath = true; - TileObjectData.newTile.DrawYOffset = 2; + TileObjectData.newTile.DrawYOffset = -2; TileObjectData.addTile(Type); ModTranslation name = CreateMapEntryName(); name.SetDefault("Stalactite"); diff --git a/Tiles/Abyss/Stalactite/SulphurousStalactite6.png b/Tiles/Abyss/Stalactite/SulphurousStalactite6.png index 40879b24bd637dfd6f63e3b976f18ed3d212749c..dfea6544655f75d15f1e48d0a7dccef5f593cf32 100644 GIT binary patch delta 279 zcmdnRdVoo>Gr-TCmrII^fq{Y7)59eQNDBe62M05dJi{9LWul^jtz3Xlh$|x-zmJu5 zx}!s3l)I9wf~7%lZ>8^wNg-!<_5zjeS+T?rNO6?}`33)n0ftRybk0w-6R&5O>gnPb zV&T8{!fie#MIP6{u8?K_{~!J)qQ2Nc`=r44=WtH{0DD{9P;a z{Z>~`ZR-E0e|6X7j+|@nE|$x^wVC)+$Ku)vwbRR^ayQus?KJCu@h7EZx}CJg6IN9N W1o45amQ-43~z4pwti{UDATvQe(<|@9ek1shbJzEC-+D?Yp~~%=hlMv(ptKJ<@k1 z%Zs}|75v73Ae?|Ip07$3&npUh2^c+z3Hu4YpZOvFwwuo6vGc?G&7SwU{E2Tgwxio)MNg_vfm1I6!wJ6^?s*FHcmoY zb0+F7l-TJ3Jp~-prq%uD-5mVZ&2e}tt7_~Ws8#8;y72n9Cfr^E$sawKzkeNn&NROE z;MRL!oPa8G^}mr^0==@n5*hmm^nHPex}IDQbogzZ7_A6Wa5;elrhP%ATxe%+7rMM2 zM3LMCrI|EjB6fmsKPcUpg;!^?%1bVs@s5-?4ppj+&+p*&deAuB>61Es0h*t4pxo6S zBr8L~@DO_m$`b`a`qA8UNQ~)!X~a*^@3kCKN_3%%Vy_4PN^%nv<-an?#Q)p_W_8Vj z%K5e+1(!oE?-qU@`w;B|ycZC$6NL9PJ6(Z4elP{^_%NqjP+uxvw$wM$hfg2jjQs=> z>^d)BEaK$#n|-(hW349$C&;A7po?NJ!H}#@%DXkFy08S9u$Ukt6G-W4JbQXakb=_z z>?P3Iu5Uo?_6bDKUta@6>;&PxE!}+ruN2kS>G6?=6*)OIiZQR=u8<92F9GwYwhZt6 w9zue2s*5pen+YWtm_SyB82wx)W&+1K1EVVF2!4X8kpKVy07*qoM6N<$f|w*QZU6uP diff --git a/World/SulphurousSea.cs b/World/SulphurousSea.cs index 3d447b4b2f..0c28e72af9 100644 --- a/World/SulphurousSea.cs +++ b/World/SulphurousSea.cs @@ -17,13 +17,6 @@ namespace CalamityMod.World { #region Fields and Properties - public static readonly List SulphSeaTiles = new() - { - ModContent.TileType(), - ModContent.TileType(), - ModContent.TileType() - }; - public const float SandBlockEdgeDescentSmoothness = 0.24f; // What percentage it takes for dither effects to start appearing at the edges. @@ -101,6 +94,10 @@ namespace CalamityMod.World public const float SandstoneEdgeNoiseMagnification = 0.00115f; + public const int StalactitePairMinDistance = 6; + + public const int StalactitePairMaxDistance = 44; + // Loop variables that are accessed via getter methods should be stored externally in local variables for performance reasons. public static int BiomeWidth { @@ -151,7 +148,7 @@ namespace CalamityMod.World public static int MaxCaveMovementSteps => (int)Math.Ceiling(Main.maxTilesX / 40f); - public static int ColumnCount => Main.maxTilesX / 76; + public static int ColumnCount => Main.maxTilesX / 96; public static int GeyserCount => Main.maxTilesX / 137; @@ -161,6 +158,13 @@ namespace CalamityMod.World set; } + public static readonly List SulphSeaTiles = new() + { + ModContent.TileType(), + ModContent.TileType(), + ModContent.TileType() + }; + // Vines cannot grow any higher than this. This is done to prevent vines from growing very close to the sea surface. public static int VineGrowTopLimit => YStart + 100; #endregion @@ -198,6 +202,7 @@ namespace CalamityMod.World GenerateColumnsInCaverns(); GenerateSteamGeysersInCaverns(); GenerateHardenedSandstone(); + PlaceStalactites(); } #endregion @@ -502,38 +507,6 @@ namespace CalamityMod.World } } - public static void ClearAloneTiles() - { - int width = BiomeWidth; - int depth = BlockDepth; - ushort blockTileType = (ushort)ModContent.TileType(); - - for (int i = 0; i < width; i++) - { - int x = GetActualX(i); - for (int y = YStart; y < YStart + depth; y++) - { - Tile t = CalamityUtils.ParanoidTileRetrieval(x, y); - if (!t.HasTile || t.TileType != blockTileType) - continue; - - // Check to see if the tile has any cardinal neighbors. If it doesn't, destroy it. - if (!CalamityUtils.ParanoidTileRetrieval(x - 1, y).HasTile && - !CalamityUtils.ParanoidTileRetrieval(x + 1, y).HasTile && - !CalamityUtils.ParanoidTileRetrieval(x, y - 1).HasTile && - !CalamityUtils.ParanoidTileRetrieval(x, y + 1).HasTile) - { - WorldUtils.Gen(new(x, y), new Shapes.Rectangle(1, 1), Actions.Chain(new GenAction[] - { - new Actions.ClearTile(true), - new Actions.ClearWall(true), - new Actions.SetLiquid() - })); - } - } - } - } - public static void DecideHardSandstoneLine() { int width = BiomeWidth; @@ -634,67 +607,95 @@ namespace CalamityMod.World } } - public static void GenerateHardenedSandstone() + public static void CreateBeachNearSea() { - int sandstoneSeed = WorldGen.genRand.Next(); - ushort sandstoneID = (ushort)ModContent.TileType(); - ushort sandstoneWallID = (ushort)ModContent.WallType(); + int beachWidth = WorldGen.genRand.Next(150, 190 + 1); + var searchCondition = Searches.Chain(new Searches.Down(3000), new Conditions.IsSolid()); + ushort sandID = (ushort)ModContent.TileType(); - // Edge score evaluation function that determines the propensity a tile has to become sandstone. - // This is based on how much nearby empty areas there are, allowing for "edges" to appear. - static int getEdgeScore(int x, int y) + // Stop immediately if for some strange reason a valid tile could not be located for the beach starting point. + if (!WorldUtils.Find(new Point(BiomeWidth + 4, (int)WorldGen.worldSurfaceLow - 20), searchCondition, out Point determinedPoint)) + return; + + Tile tileAtEdge = CalamityUtils.ParanoidTileRetrieval(determinedPoint.X, determinedPoint.Y); + + // Extend outward to encompass some of the desert, if there is one. + if (tileAtEdge.TileType is TileID.Sand or TileID.Ebonsand or TileID.Crimsand) + beachWidth += 85; + + // Transform the landscape. + for (int i = BiomeWidth - 10; i <= BiomeWidth + beachWidth; i++) { - int edgeScore = 0; - for (int dx = x - 6; dx <= x + 6; dx++) + int x = GetActualX(i); + float xRatio = Utils.GetLerpValue(BiomeWidth - 10, BiomeWidth + beachWidth, i, true); + float ditherChance = Utils.GetLerpValue(0.92f, 0.99f, xRatio, true); + int depth = (int)(Math.Sin((1f - xRatio) * MathHelper.PiOver2) * BeachMaxDepth + 1f); + for (int y = YStart - 50; y < YStart + depth; y++) { - if (dx == x) - continue; - - if (!CalamityUtils.ParanoidTileRetrieval(dx, y).HasTile) - edgeScore++; - } - for (int dy = y - 6; dy <= y + 6; dy++) - { - if (dy == y) - continue; + Tile tileAtPosition = CalamityUtils.ParanoidTileRetrieval(x, y); + if (tileAtPosition.HasTile && ValidBeachDestroyTiles.Contains(tileAtPosition.TileType)) + { + // Kill trees manually so that no leftover tiles are present. + if (Main.tile[x, y].TileType == TileID.Trees) + WorldGen.KillTile(x, y); + else + Main.tile[x, y].Get().HasTile = false; + } - if (!CalamityUtils.ParanoidTileRetrieval(x, dy).HasTile) - edgeScore++; + else if (tileAtPosition.HasTile && ValidBeachCovertTiles.Contains(tileAtPosition.TileType) && WorldGen.genRand.NextFloat() >= ditherChance) + Main.tile[x, y].TileType = sandID; } - return edgeScore; } - for (int i = 1; i < BiomeWidth; i++) + // Plant new trees. + for (int x = BiomeWidth - 10; x <= BiomeWidth + beachWidth; x++) { - for (int y = YStart; y <= YStart + BlockDepth; y++) + int trueX = Abyss.AtLeftSideOfWorld ? x : Main.maxTilesX - x; + if (!WorldGen.genRand.NextBool(10)) + continue; + + int y = YStart - 30; + if (!WorldUtils.Find(new Point(trueX, y), Searches.Chain(new Searches.Down(100), new Conditions.IsTile(sandID)), out Point treePlantPosition)) + continue; + + treePlantPosition.Y--; + + // Place the saplings and try to grow them. + WorldGen.PlaceTile(treePlantPosition.X, treePlantPosition.Y, ModContent.TileType()); + Main.tile[treePlantPosition].TileType = TileID.Saplings; + Main.tile[treePlantPosition].Get().HasTile = true; + if (!WorldGen.GrowPalmTree(treePlantPosition.X, treePlantPosition.Y)) + WorldGen.KillTile(treePlantPosition.X, treePlantPosition.Y); + } + } + + public static void ClearAloneTiles() + { + int width = BiomeWidth; + int depth = BlockDepth; + ushort blockTileType = (ushort)ModContent.TileType(); + + for (int i = 0; i < width; i++) + { + int x = GetActualX(i); + for (int y = YStart; y < YStart + depth; y++) { - int x = GetActualX(i); - float sandstoneConvertChance = FractalBrownianMotion(i * SandstoneEdgeNoiseMagnification, y * SandstoneEdgeNoiseMagnification, sandstoneSeed, 7) * 0.5f + 0.5f; - - // Make the sandstone appearance chance dependant on the edge score. - sandstoneConvertChance *= Utils.GetLerpValue(4f, 11f, getEdgeScore(x, y), true); - - // Make sandstone less likely to appear on the surface. - sandstoneConvertChance *= Utils.GetLerpValue(YStart + 30f, YStart + 54f, y, true); - - if (WorldGen.genRand.NextFloat() > sandstoneConvertChance || sandstoneConvertChance < 0.5f) + Tile t = CalamityUtils.ParanoidTileRetrieval(x, y); + if (!t.HasTile || t.TileType != blockTileType) continue; - // Convert to sandstone as necessary. - for (int dx = -2; dx <= 2; dx++) + // Check to see if the tile has any cardinal neighbors. If it doesn't, destroy it. + if (!CalamityUtils.ParanoidTileRetrieval(x - 1, y).HasTile && + !CalamityUtils.ParanoidTileRetrieval(x + 1, y).HasTile && + !CalamityUtils.ParanoidTileRetrieval(x, y - 1).HasTile && + !CalamityUtils.ParanoidTileRetrieval(x, y + 1).HasTile) { - for (int dy = -2; dy <= 2; dy++) + WorldUtils.Gen(new(x, y), new Shapes.Rectangle(1, 1), Actions.Chain(new GenAction[] { - if (WorldGen.InWorld(x + dx, y + dy)) - { - if (CalamityUtils.ParanoidTileRetrieval(x + dx, y + dy).TileType != sandstoneID && - SulphSeaTiles.Contains(CalamityUtils.ParanoidTileRetrieval(x + dx, y + dy).TileType)) - { - Main.tile[x + dx, y + dy].WallType = sandstoneWallID; - Main.tile[x + dx, y + dy].TileType = sandstoneID; - } - } - } + new Actions.ClearTile(true), + new Actions.ClearWall(true), + new Actions.SetLiquid() + })); } } } @@ -864,65 +865,113 @@ namespace CalamityMod.World } } - public static void CreateBeachNearSea() + public static void GenerateHardenedSandstone() { - int beachWidth = WorldGen.genRand.Next(150, 190 + 1); - var searchCondition = Searches.Chain(new Searches.Down(3000), new Conditions.IsSolid()); - ushort sandID = (ushort)ModContent.TileType(); + int sandstoneSeed = WorldGen.genRand.Next(); + ushort sandstoneID = (ushort)ModContent.TileType(); + ushort sandstoneWallID = (ushort)ModContent.WallType(); - // Stop immediately if for some strange reason a valid tile could not be located for the beach starting point. - if (!WorldUtils.Find(new Point(BiomeWidth + 4, (int)WorldGen.worldSurfaceLow - 20), searchCondition, out Point determinedPoint)) - return; - - Tile tileAtEdge = CalamityUtils.ParanoidTileRetrieval(determinedPoint.X, determinedPoint.Y); - - // Extend outward to encompass some of the desert, if there is one. - if (tileAtEdge.TileType is TileID.Sand or TileID.Ebonsand or TileID.Crimsand) - beachWidth += 85; - - // Transform the landscape. - for (int i = BiomeWidth - 10; i <= BiomeWidth + beachWidth; i++) + // Edge score evaluation function that determines the propensity a tile has to become sandstone. + // This is based on how much nearby empty areas there are, allowing for "edges" to appear. + static int getEdgeScore(int x, int y) { - int x = GetActualX(i); - float xRatio = Utils.GetLerpValue(BiomeWidth - 10, BiomeWidth + beachWidth, i, true); - float ditherChance = Utils.GetLerpValue(0.92f, 0.99f, xRatio, true); - int depth = (int)(Math.Sin((1f - xRatio) * MathHelper.PiOver2) * BeachMaxDepth + 1f); - for (int y = YStart - 50; y < YStart + depth; y++) + int edgeScore = 0; + for (int dx = x - 6; dx <= x + 6; dx++) { - Tile tileAtPosition = CalamityUtils.ParanoidTileRetrieval(x, y); - if (tileAtPosition.HasTile && ValidBeachDestroyTiles.Contains(tileAtPosition.TileType)) - { - // Kill trees manually so that no leftover tiles are present. - if (Main.tile[x, y].TileType == TileID.Trees) - WorldGen.KillTile(x, y); - else - Main.tile[x, y].Get().HasTile = false; - } + if (dx == x) + continue; - else if (tileAtPosition.HasTile && ValidBeachCovertTiles.Contains(tileAtPosition.TileType) && WorldGen.genRand.NextFloat() >= ditherChance) - Main.tile[x, y].TileType = sandID; + if (!CalamityUtils.ParanoidTileRetrieval(dx, y).HasTile) + edgeScore++; } + for (int dy = y - 6; dy <= y + 6; dy++) + { + if (dy == y) + continue; + + if (!CalamityUtils.ParanoidTileRetrieval(x, dy).HasTile) + edgeScore++; + } + return edgeScore; } - // Plant new trees. - for (int x = BiomeWidth - 10; x <= BiomeWidth + beachWidth; x++) + for (int i = 1; i < BiomeWidth; i++) { - int trueX = Abyss.AtLeftSideOfWorld ? x : Main.maxTilesX - x; - if (!WorldGen.genRand.NextBool(10)) - continue; + for (int y = YStart; y <= YStart + BlockDepth; y++) + { + int x = GetActualX(i); + float sandstoneConvertChance = FractalBrownianMotion(i * SandstoneEdgeNoiseMagnification, y * SandstoneEdgeNoiseMagnification, sandstoneSeed, 7) * 0.5f + 0.5f; - int y = YStart - 30; - if (!WorldUtils.Find(new Point(trueX, y), Searches.Chain(new Searches.Down(100), new Conditions.IsTile(sandID)), out Point treePlantPosition)) - continue; + // Make the sandstone appearance chance dependant on the edge score. + sandstoneConvertChance *= Utils.GetLerpValue(4f, 11f, getEdgeScore(x, y), true); - treePlantPosition.Y--; + // Make sandstone less likely to appear on the surface. + sandstoneConvertChance *= Utils.GetLerpValue(YStart + 30f, YStart + 54f, y, true); - // Place the saplings and try to grow them. - WorldGen.PlaceTile(treePlantPosition.X, treePlantPosition.Y, ModContent.TileType()); - Main.tile[treePlantPosition].TileType = TileID.Saplings; - Main.tile[treePlantPosition].Get().HasTile = true; - if (!WorldGen.GrowPalmTree(treePlantPosition.X, treePlantPosition.Y)) - WorldGen.KillTile(treePlantPosition.X, treePlantPosition.Y); + if (WorldGen.genRand.NextFloat() > sandstoneConvertChance || sandstoneConvertChance < 0.5f) + continue; + + // Convert to sandstone as necessary. + for (int dx = -2; dx <= 2; dx++) + { + for (int dy = -2; dy <= 2; dy++) + { + if (WorldGen.InWorld(x + dx, y + dy)) + { + if (CalamityUtils.ParanoidTileRetrieval(x + dx, y + dy).TileType != sandstoneID && + SulphSeaTiles.Contains(CalamityUtils.ParanoidTileRetrieval(x + dx, y + dy).TileType)) + { + Main.tile[x + dx, y + dy].WallType = sandstoneWallID; + Main.tile[x + dx, y + dy].TileType = sandstoneID; + } + } + } + } + } + } + } + + public static void PlaceStalactites() + { + static int heightFromType(int type) + { + if (type <= 2) + return 2; + else if (type <= 4) + return 3; + else + return 4; + }; + + for (int i = 1; i < BiomeWidth; i++) + { + int x = GetActualX(i); + for (int y = YStart; y <= YStart + BlockDepth; y++) + { + if (y - YStart > BlockDepth * 0.25f) + { + if (WorldGen.SolidTile(x, y - 1) && WorldGen.genRand.NextBool(10)) + { + int dy = 1; + while (!CalamityUtils.ParanoidTileRetrieval(x, y + dy).HasTile) + { + dy++; + if (dy > StalactitePairMaxDistance) + break; + } + if (dy <= StalactitePairMaxDistance && dy >= StalactitePairMinDistance) + { + int type = WorldGen.genRand.Next(6); + type++; + int height = heightFromType(type); + + PlaceStalactite(x, y, height, CalamityMod.Instance.Find($"SulphurousStalactite{type}").Type); + if (WorldGen.SolidTile(x, y + dy + 1)) + PlaceStalacmite(x, y + dy, height, CalamityMod.Instance.Find($"SulphurousStalacmite{type}").Type); + } + } + } + } } } #endregion Generation Functions @@ -1134,6 +1183,32 @@ namespace CalamityMod.World } } } + + public static void PlaceStalactite(int x, int y, int height, ushort type) + { + for (int dy = 0; dy < height; dy++) + { + ushort oldWall = Main.tile[x, y + dy].WallType; + Main.tile[x, y + dy].ClearEverything(); + Main.tile[x, y + dy].WallType = oldWall; + Main.tile[x, y + dy].TileType = type; + Main.tile[x, y + dy].TileFrameY = (short)(dy * 18); + Main.tile[x, y + dy].Get().HasTile = true; + } + } + + public static void PlaceStalacmite(int x, int y, int height, ushort type) + { + for (int dy = height - 1; dy > 0; dy--) + { + ushort oldWall = Main.tile[x, y + dy].WallType; + Main.tile[x, y - dy].ClearEverything(); + Main.tile[x, y - dy].WallType = oldWall; + Main.tile[x, y - dy].TileType = type; + Main.tile[x, y - dy].TileFrameY = (short)(height * 18 - dy * 18); + Main.tile[x, y - dy].Get().HasTile = true; + } + } #endregion } } From 12c576023889a5e4c8bf92f200ab9998645c7a4f Mon Sep 17 00:00:00 2001 From: Dominic Date: Fri, 7 Oct 2022 22:42:52 -0500 Subject: [PATCH 12/21] Old palm tree removal fix --- World/SulphurousSea.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/World/SulphurousSea.cs b/World/SulphurousSea.cs index 0c28e72af9..f5d75025b1 100644 --- a/World/SulphurousSea.cs +++ b/World/SulphurousSea.cs @@ -244,6 +244,13 @@ namespace CalamityMod.World Main.tile[x, y].Get().HasTile = true; } } + + // Obliterate old palm trees. + for (int y = top - 75; y < top + 50; y++) + { + if (Main.tile[x, y].TileType == TileID.PalmTree) + WorldGen.KillTile(x, y); + } } } From 3a4fe3b586290d1737e1971b26126df4665c3705 Mon Sep 17 00:00:00 2001 From: Dominic Date: Fri, 14 Oct 2022 10:20:17 -0500 Subject: [PATCH 13/21] Rusty chests --- ILEditing/MechanicILChanges.cs | 4 +- NPCs/CalamityGlobalNPCLoot.cs | 20 +- NPCs/SulphurousSea/Catfish.cs | 4 +- Projectiles/Enemy/SulphuricAcidBubble.cs | 1 + Tiles/Abyss/SulphurousColumn.cs | 12 + Utilities/TileUtils.cs | 15 ++ Utilities/WorldgenUtils.cs | 65 ++--- World/SulphurousSea.cs | 298 ++++++++++++++++++++--- 8 files changed, 331 insertions(+), 88 deletions(-) diff --git a/ILEditing/MechanicILChanges.cs b/ILEditing/MechanicILChanges.cs index 08f9d43e40..e77902d279 100644 --- a/ILEditing/MechanicILChanges.cs +++ b/ILEditing/MechanicILChanges.cs @@ -42,6 +42,7 @@ using Terraria.GameContent.Events; using CalamityMod.DataStructures; using CalamityMod.Particles.Metaballs; using Terraria.GameContent.Drawing; +using CalamityMod.Tiles.Abyss; namespace CalamityMod.ILEditing { @@ -901,7 +902,8 @@ namespace CalamityMod.ILEditing GeneralParticleHandler.SpawnParticle(acidFoam); } - outputColor = Vector3.Lerp(outputColor, Color.LightSeaGreen.ToVector3(), 0.41f); + if (tile.TileType != (ushort)ModContent.TileType()) + outputColor = Vector3.Lerp(outputColor, Color.LightSeaGreen.ToVector3(), 0.41f); } #endregion Sulph Sea Water Visuals diff --git a/NPCs/CalamityGlobalNPCLoot.cs b/NPCs/CalamityGlobalNPCLoot.cs index aca78636b5..ca597d6c58 100644 --- a/NPCs/CalamityGlobalNPCLoot.cs +++ b/NPCs/CalamityGlobalNPCLoot.cs @@ -865,7 +865,7 @@ namespace CalamityMod.NPCs EoWKill.Add(DropHelper.PerPlayer(ItemID.WormScarf)); npcLoot.AddNormalOnly(EoWKill); - // Would be in the bag otherwise + // Would be in the bag otherwise npcLoot.AddIf((info) => info.npc.boss, ModContent.ItemType(), ThankYouPainting.DropInt); // Master items drop in Revengeance @@ -889,7 +889,7 @@ namespace CalamityMod.NPCs // Expert+ drops are also available on Normal npcLoot.AddNormalOnly(DropHelper.PerPlayer(ItemID.BrainOfConfusion)); - // Would be in the bag otherwise + // Would be in the bag otherwise npcLoot.AddNormalOnly(ModContent.ItemType(), ThankYouPainting.DropInt); // Master items drop in Revengeance @@ -936,7 +936,7 @@ namespace CalamityMod.NPCs // Expert+ drops are also available on Normal npcLoot.AddNormalOnly(DropHelper.PerPlayer(ItemID.BoneHelm)); - // Would be in the bag otherwise + // Would be in the bag otherwise npcLoot.AddNormalOnly(ModContent.ItemType(), ThankYouPainting.DropInt); // Master items drop in Revengeance @@ -991,7 +991,7 @@ namespace CalamityMod.NPCs // Expert+ drops are also available on Normal npcLoot.AddNormalOnly(DropHelper.PerPlayer(ItemID.BoneGlove)); - // Would be in the bag otherwise + // Would be in the bag otherwise npcLoot.AddNormalOnly(ModContent.ItemType(), ThankYouPainting.DropInt); // Master items drop in Revengeance @@ -1070,7 +1070,7 @@ namespace CalamityMod.NPCs // However, Demon Heart does not work in Normal mode, so it's best to not drop it // npcLoot.AddNormalOnly(DropHelper.PerPlayer(ItemID.DemonHeart)); - // Would be in the bag otherwise + // Would be in the bag otherwise npcLoot.AddNormalOnly(ModContent.ItemType(), ThankYouPainting.DropInt); // WoF drops Evil Keys @@ -1091,7 +1091,7 @@ namespace CalamityMod.NPCs npcLoot.AddNormalOnly(DropHelper.PerPlayer(ItemID.VolatileGelatin)); npcLoot.AddNormalOnly(ItemID.SoulofLight, 1, 15, 20); - // Would be in the bag otherwise + // Would be in the bag otherwise npcLoot.AddNormalOnly(ModContent.ItemType(), ThankYouPainting.DropInt); // Queen Slime drops the Hallowed Key @@ -1113,7 +1113,7 @@ namespace CalamityMod.NPCs // Expert+ drops are also available on Normal npcLoot.AddNormalOnly(DropHelper.PerPlayer(ItemID.MechanicalWagonPiece)); - // Would be in the bag otherwise + // Would be in the bag otherwise npcLoot.AddNormalOnly(ModContent.ItemType(), ThankYouPainting.DropInt); // Master items drop in Revengeance @@ -1152,7 +1152,7 @@ namespace CalamityMod.NPCs npcLoot.AddIf((info) => !Main.expertMode && IsLastTwinStanding(info), ItemID.MechanicalWheelPiece); npcLoot.AddIf((info) => !Main.expertMode && IsLastTwinStanding(info), ModContent.ItemType(), 10); - // Would be in the bag otherwise + // Would be in the bag otherwise npcLoot.AddIf((info) => !Main.expertMode && IsLastTwinStanding(info), ModContent.ItemType(), ThankYouPainting.DropInt); // Master items drop in Revengeance @@ -1174,7 +1174,7 @@ namespace CalamityMod.NPCs // Expert+ drops are also available on Normal npcLoot.AddNormalOnly(DropHelper.PerPlayer(ItemID.MechanicalBatteryPiece)); - // Would be in the bag otherwise + // Would be in the bag otherwise npcLoot.AddNormalOnly(ModContent.ItemType(), ThankYouPainting.DropInt); // Master items drop in Revengeance @@ -1416,7 +1416,7 @@ namespace CalamityMod.NPCs // Expert+ drops are also available on Normal npcLoot.AddNormalOnly(DropHelper.PerPlayer(ItemID.EmpressFlightBooster)); - // Would be in the bag otherwise + // Would be in the bag otherwise npcLoot.AddNormalOnly(ModContent.ItemType(), ThankYouPainting.DropInt); // Master items drop in Revengeance diff --git a/NPCs/SulphurousSea/Catfish.cs b/NPCs/SulphurousSea/Catfish.cs index bb1d23f13d..0e63e5102f 100644 --- a/NPCs/SulphurousSea/Catfish.cs +++ b/NPCs/SulphurousSea/Catfish.cs @@ -48,8 +48,8 @@ namespace CalamityMod.NPCs.SulphurousSea { bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - // Will move to localization whenever that is cleaned up. - new FlavorTextBestiaryInfoElement("An animal which adapted to the toxic waters quite naturally. It uses its whiskers to find its way, and its prey in the murky depths.") + // Will move to localization whenever that is cleaned up. + new FlavorTextBestiaryInfoElement("An animal which adapted to the toxic waters quite naturally. It uses its whiskers to find its way, and its prey in the murky depths.") }); } diff --git a/Projectiles/Enemy/SulphuricAcidBubble.cs b/Projectiles/Enemy/SulphuricAcidBubble.cs index 71757fc8e4..2ffa4ce2c1 100644 --- a/Projectiles/Enemy/SulphuricAcidBubble.cs +++ b/Projectiles/Enemy/SulphuricAcidBubble.cs @@ -23,6 +23,7 @@ namespace CalamityMod.Projectiles.Enemy Projectile.scale = 0.01f; Projectile.hostile = true; Projectile.tileCollide = false; + Projectile.ignoreWater = true; Projectile.Opacity = 0f; Projectile.timeLeft = 360; Projectile.penetrate = 1; diff --git a/Tiles/Abyss/SulphurousColumn.cs b/Tiles/Abyss/SulphurousColumn.cs index d386f0c84e..812b701766 100644 --- a/Tiles/Abyss/SulphurousColumn.cs +++ b/Tiles/Abyss/SulphurousColumn.cs @@ -40,6 +40,18 @@ namespace CalamityMod.Tiles.Abyss base.SetStaticDefaults(); } + + public override void NearbyEffects(int i, int j, bool closer) + { + Tile t = CalamityUtils.ParanoidTileRetrieval(i, j); + Tile left = CalamityUtils.ParanoidTileRetrieval(i - 1, j); + Tile right = CalamityUtils.ParanoidTileRetrieval(i + 1, j); + if (t.TileFrameX % 36 == 0 && !right.HasTile) + WorldGen.KillTile(i, j); + if (t.TileFrameX % 36 == 18 && !left.HasTile) + WorldGen.KillTile(i, j); + } + public override void KillMultiTile(int i, int j, int frameX, int frameY) { if (Main.netMode == NetmodeID.Server) diff --git a/Utilities/TileUtils.cs b/Utilities/TileUtils.cs index 5739e95233..fdb6c541a3 100644 --- a/Utilities/TileUtils.cs +++ b/Utilities/TileUtils.cs @@ -229,6 +229,21 @@ namespace CalamityMod return Main.tile[x, y]; } + public static bool AnySolidTileInSelection(int x, int y, int width, int height) + { + for (int i = x; i != x + width; i += Math.Sign(width)) + { + for (int j = y; j != y + height; j += Math.Sign(height)) + { + if (WorldGen.InWorld(i, j)) + continue; + if (WorldGen.SolidTile(Framing.GetTileSafely(i, j))) + return true; + } + } + return false; + } + public static bool TileSelectionSolid(int x, int y, int width, int height) { for (int i = x; i != x + width; i += Math.Sign(width)) diff --git a/Utilities/WorldgenUtils.cs b/Utilities/WorldgenUtils.cs index 41d5d84caa..e5ea6c2ca1 100644 --- a/Utilities/WorldgenUtils.cs +++ b/Utilities/WorldgenUtils.cs @@ -1,5 +1,4 @@ using System.Linq; -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -34,56 +33,40 @@ namespace CalamityMod } ///

- /// Generates caves via celluar automata in terms of active/inactive states. May also be used to smoothen out areas. + /// Settles all liquids in the world. /// - /// The area to perform the algorithm on. - /// The number of times to iterate. The higher this value is, the more smooth the result is. - public static void GenerateCellularAutomataCave(Rectangle area, int gameIterations) + public static void SettleWater() { - bool[,] cellStates = new bool[area.Width, area.Height]; - int width = cellStates.GetLength(0); - int height = cellStates.GetLength(1); + Liquid.worldGenTilesIgnoreWater(true); + Liquid.QuickWater(3); + WorldGen.WaterCheck(); - // Initialize the cell states. - for (int i = area.Left; i < area.Right; i++) - { - for (int j = area.Top; j < area.Bottom; j++) - cellStates[i - area.Left, j - area.Top] = ParanoidTileRetrieval(i, j).HasTile; - } + Liquid.quickSettle = true; - for (int i = 0; i < gameIterations; i++) + for (int i = 0; i < 10; i++) { - bool[,] newState = cellStates.Clone() as bool[,]; - for (int x = 0; x < width; x++) + int maxLiquid = Liquid.numLiquid + LiquidBuffer.numLiquidBuffer; + int m = maxLiquid * 5; + double maxLiquidDifferencePercentage = 0D; + while (Liquid.numLiquid > 0) { - for (int y = 0; y < height; y++) - { - int nearbyActiveCells = 0; - for (int dx = -1; dx <= 1; dx++) - { - for (int dy = -1; dy <= 1; dy++) - { - if (x + dx < 0 || x + dx >= width || y + dy < 0 || y + dy >= height) - { - nearbyActiveCells++; - continue; - } + m--; + if (m < 0) + break; - nearbyActiveCells += cellStates[x + dx, y + dy].ToInt(); - } - } + double liquidDifferencePercentage = (maxLiquid - Liquid.numLiquid - LiquidBuffer.numLiquidBuffer) / (double)maxLiquid; + if (Liquid.numLiquid + LiquidBuffer.numLiquidBuffer > maxLiquid) + maxLiquid = Liquid.numLiquid + LiquidBuffer.numLiquidBuffer; + + if (liquidDifferencePercentage > maxLiquidDifferencePercentage) + maxLiquidDifferencePercentage = liquidDifferencePercentage; - newState[x, y] = nearbyActiveCells >= 5; - } + Liquid.UpdateLiquid(); } - cellStates = newState; - } - - for (int i = area.Left; i < area.Right; i++) - { - for (int j = area.Top; j < area.Bottom; j++) - Main.tile[i, j].Get().HasTile = cellStates[i - area.Left, j - area.Top]; + WorldGen.WaterCheck(); } + Liquid.quickSettle = false; + Liquid.worldGenTilesIgnoreWater(false); } } } diff --git a/World/SulphurousSea.cs b/World/SulphurousSea.cs index f5d75025b1..59f9448280 100644 --- a/World/SulphurousSea.cs +++ b/World/SulphurousSea.cs @@ -1,4 +1,8 @@ -using CalamityMod.Schematics; +using CalamityMod.Items; +using CalamityMod.Items.Accessories; +using CalamityMod.Items.Placeables.Furniture; +using CalamityMod.Items.Weapons.Summon; +using CalamityMod.Schematics; using CalamityMod.Tiles.Abyss; using CalamityMod.Walls; using Microsoft.Xna.Framework; @@ -38,6 +42,8 @@ namespace CalamityMod.World public const float OpenSeaWidthPercentage = 0.53f; + public const float IslandWidthPercentage = 0.36f; + public const float IslandCurvatureSharpness = 0.74f; // 0-1 value of how jagged the small caves should be. The higher this value is, the more variance you can expect for each step when carving out caves. @@ -51,7 +57,7 @@ namespace CalamityMod.World // terms of direction, size, etc. public const float SpaghettiCaveMagnification = 0.00193f; - // 0-1 value that determines the threshold for spaghetti caves being carved out. At 0, no caves are carved out, at 1, all tiles are carved out. + // 0-1 value that determines the threshold for spaghetti caves being carved out. At 0, no tiles are carved out, at 1, all tiles are carved out. // This is used in the formula 'abs(noise(x, y)) < r' to determine whether the cave should remove tiles. public static readonly float[] SpaghettiCaveCarveOutThresholds = new float[] { @@ -63,7 +69,7 @@ namespace CalamityMod.World public static readonly float[] CheeseCaveCarveOutThresholds = new float[] { - 0.4f + 0.32f }; // Percentage of how far down a tile has to be for open caverns to appear. @@ -72,7 +78,7 @@ namespace CalamityMod.World // The percentage of tiles on average that should be transformed into water. // A value of 1 indicates that every tile should have water. // This value should be close to 1, but not exactly, so that when water settles the top of caverns will be open. - public const float WaterSpreadPercentage = 0.95f; + public const float WaterSpreadPercentage = 0.91f; public const float HardenedSandstoneLineMagnification = 0.004f; @@ -186,7 +192,6 @@ namespace CalamityMod.World GenerateSmallWaterCaverns(); GenerateSpaghettiWaterCaves(); GenerateCheeseWaterCaves(); - ClearOutStrayTiles(); // Lay down decorations and post-processing effects after the caves are generated. DecideHardSandstoneLine(); @@ -197,16 +202,33 @@ namespace CalamityMod.World public static void SulphurSeaGenerationAfterAbyss() { CreateBeachNearSea(); + ClearOutStrayTiles(); ClearAloneTiles(); - PlaceScrapPiles(); + var scrapPilePositions = PlaceScrapPiles(); GenerateColumnsInCaverns(); GenerateSteamGeysersInCaverns(); GenerateHardenedSandstone(); PlaceStalactites(); + GenerateChests(scrapPilePositions); } #endregion #region Generation Functions + public static void DetermineYStart() + { + int xCheckPosition = GetActualX(BiomeWidth + 1); + var searchCondition = Searches.Chain(new Searches.Down(3000), new Conditions.IsSolid()); + Point determinedPoint; + + do + { + WorldUtils.Find(new Point(xCheckPosition, (int)WorldGen.worldSurfaceLow - 20), searchCondition, out determinedPoint); + xCheckPosition += Abyss.AtLeftSideOfWorld.ToDirectionInt(); + } + while (CalamityUtils.ParanoidTileRetrieval(determinedPoint.X, determinedPoint.Y).TileType == TileID.Ebonstone); + YStart = determinedPoint.Y; + } + public static void GenerateSandBlock() { int width = BiomeWidth + 1; @@ -304,7 +326,7 @@ namespace CalamityMod.World public static void GenerateIsland() { int left = -32; - int right = (int)(BiomeWidth * OpenSeaWidthPercentage * 0.68f); + int right = (int)(BiomeWidth * IslandWidthPercentage); int maxDepth = MaxTopWaterDepth; ushort blockTileType = (ushort)ModContent.TileType(); ushort wallID = (ushort)ModContent.WallType(); @@ -413,6 +435,7 @@ namespace CalamityMod.World float distanceFromEdge = new Vector2(i / (float)width, (y - YStart) / (float)depth).Length(); float biasAwayFrom0Interpolant = Utils.GetLerpValue(0.82f, 0.96f, distanceFromEdge * 0.8f, true); biasAwayFrom0Interpolant += Utils.GetLerpValue(YStart + 12f, YStart, y, true) * 0.2f; + biasAwayFrom0Interpolant += Utils.GetLerpValue(width - 19f, width - 4f, i, true) * 0.6f; // If the noise is less than 0, bias to -1, if it's greater than 0, bias away to 1. // This is done instead of biasing to -1 or 1 without exception to ensure that in doing so the noise does not cross into the @@ -450,8 +473,10 @@ namespace CalamityMod.World { float noise = FractalBrownianMotion(i * CheeseCaveMagnification, y * CheeseCaveMagnification, caveSeed, 6); float distanceFromEdge = new Vector2(i / (float)width, (y - YStart) / (float)depth).Length(); + float biasToNegativeOneInterpolant = Utils.GetLerpValue(0.82f, 0.96f, distanceFromEdge * 0.8f, true); biasToNegativeOneInterpolant += Utils.GetLerpValue(YStart + OpenCavernStartDepthPercentage * depth, YStart + OpenCavernStartDepthPercentage * depth - 25f, y, true); + biasToNegativeOneInterpolant += Utils.GetLerpValue(width - 19f, width - 4f, i, true); if (noise - biasToNegativeOneInterpolant > CheeseCaveCarveOutThresholds[c]) { WorldUtils.Gen(new(x, y), new Shapes.Rectangle(1, 1), Actions.Chain(new GenAction[] @@ -470,14 +495,19 @@ namespace CalamityMod.World { int width = BiomeWidth; int depth = BlockDepth; - ushort blockTileType = (ushort)ModContent.TileType(); + List blockTileTypes = new() + { + (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), + }; ushort wallID = (ushort)ModContent.WallType(); void getAttachedPoints(int x, int y, List points) { Tile t = CalamityUtils.ParanoidTileRetrieval(x, y); Point p = new(x, y); - if (t.TileType != blockTileType || !t.HasTile || points.Count > 300 || points.Contains(p) || CalculateDitherChance(width, YStart, YStart + depth, x, y) > 0f) + if (!blockTileTypes.Contains(t.TileType) || !t.HasTile || points.Count > 432 || points.Contains(p) || CalculateDitherChance(width, YStart, YStart + depth, x, y) > 0f) return; points.Add(p); @@ -497,7 +527,7 @@ namespace CalamityMod.World List chunkPoints = new(); getAttachedPoints(x, y, chunkPoints); - int cutoffLimit = y >= YStart + depth * OpenCavernStartDepthPercentage ? 300 : 50; + int cutoffLimit = y >= YStart + depth * OpenCavernStartDepthPercentage ? 432 : 50; if (chunkPoints.Count >= 2 && chunkPoints.Count < cutoffLimit) { foreach (Point p in chunkPoints) @@ -708,10 +738,10 @@ namespace CalamityMod.World } } - public static void PlaceScrapPiles() + public static List PlaceScrapPiles() { int tries = 0; - List pastPlacementPostiion = new List(); + List pastPlacementPositions = new List(); for (int i = 0; i < 3; i++) { tries++; @@ -731,7 +761,7 @@ namespace CalamityMod.World } // If the selected position is close to other piles, try again. - if (pastPlacementPostiion.Any(p => Vector2.Distance(p, pilePlacementPosition.ToVector2()) < ScrapPileAnticlumpDistance)) + if (pastPlacementPositions.Any(p => Vector2.Distance(p, pilePlacementPosition.ToVector2()) < ScrapPileAnticlumpDistance)) { i--; continue; @@ -767,7 +797,7 @@ namespace CalamityMod.World } // If the placement position ended up in the abyss, try again. - if (left.Y >= YStart + BlockDepth - 30 || right.Y >= YStart + BlockDepth - 30) + if (left.Y >= YStart + BlockDepth - 50 || right.Y >= YStart + BlockDepth - 50) { i--; continue; @@ -778,9 +808,10 @@ namespace CalamityMod.World bool _ = false; SchematicManager.PlaceSchematic>(schematicName, bottomCenter, SchematicAnchor.BottomCenter, ref _); - pastPlacementPostiion.Add(bottomCenter.ToVector2()); + pastPlacementPositions.Add(bottomCenter.ToVector2()); tries = 0; } + return pastPlacementPositions; } public static void GenerateColumnsInCaverns() @@ -799,9 +830,10 @@ namespace CalamityMod.World // Try again if inside a tile. Tile tile = CalamityUtils.ParanoidTileRetrieval(x, y); + Tile right = CalamityUtils.ParanoidTileRetrieval(x + 1, y); Tile bottom = CalamityUtils.ParanoidTileRetrieval(x, y + 1); Tile bottomRight = CalamityUtils.ParanoidTileRetrieval(x + 1, y + 1); - if (tile.HasTile) + if (tile.HasTile || right.HasTile) tryAgain = true; // Try again if there is no bottom tile. @@ -839,7 +871,7 @@ namespace CalamityMod.World 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); + int y = WorldGen.genRand.Next(YStart + depth / 2, YStart + depth - 42); bool tryAgain = false; @@ -981,6 +1013,219 @@ namespace CalamityMod.World } } } + + public static void GenerateChests(List scrapPilePositions) + { + GenerateTreasureChest(); + CalamityUtils.SettleWater(); + GenerateOpenAirChestChest(); + GenerateScrapPileChest(scrapPilePositions); + GenerateDeepWaterChest(); + } + + public static void GenerateTreasureChest() + { + // Generate on chest below the island to the edge as buried treasure. + static bool tryToGenerateTreasureChest(Point chestPoint) + { + WorldUtils.Find(chestPoint, Searches.Chain(new Searches.Down(300), new Conditions.IsSolid()), out Point p); + chestPoint = p; + + // Determine how far down the island chest should generate. + int minDepth = 32; + int digDepth = 0; + Point startingIslandChestPoint = chestPoint; + while (true) + { + Tile down = CalamityUtils.ParanoidTileRetrieval(chestPoint.X, chestPoint.Y + digDepth); + Tile downRight = CalamityUtils.ParanoidTileRetrieval(chestPoint.X + 1, chestPoint.Y + digDepth); + + // Stop if far down enough and either the tile to the left or right is open water. + if (((!down.HasTile && down.LiquidAmount >= 127) || (!downRight.HasTile && downRight.LiquidAmount >= 127)) && digDepth >= minDepth) + break; + + digDepth++; + if (digDepth >= 80) + return false; + } + chestPoint.Y += digDepth - 12; + + // Check the nearby area and ensure that it's not exposed to air. The treasure should be buried. + bool nearbyAreaIsClosed = false; + while (!nearbyAreaIsClosed) + { + nearbyAreaIsClosed = true; + for (int dx = -2; dx < 4; dx++) + { + for (int dy = -1; dy < 3; dy++) + { + if (!Main.tile[chestPoint.X + dx, chestPoint.Y - dy].HasTile) + nearbyAreaIsClosed = false; + } + } + + if (!nearbyAreaIsClosed) + chestPoint.Y++; + } + + // Dig up a bit and place the chest. + for (int dx = 0; dx < 2; dx++) + { + for (int dy = 0; dy < 2; dy++) + { + Main.tile[chestPoint.X + dx, chestPoint.Y - dy].LiquidAmount = 0; + Main.tile[chestPoint.X + dx, chestPoint.Y - dy].WallType = (ushort)ModContent.WallType(); + Main.tile[chestPoint.X + dx, chestPoint.Y - dy].Get().HasTile = false; + } + } + + // If a buried chest was placed, force its first item to be the effigy of decay. + Chest chest = MiscWorldgenRoutines.AddChestWithLoot(chestPoint.X + 1, chestPoint.Y + 1, (ushort)ModContent.TileType()); + if (chest != null) + { + chest.item[0].SetDefaults(ModContent.ItemType()); + chest.item[0].Prefix(-1); + } + else + return false; + + // Go back to the surface and leave a little bit of sulphurous sandstone instead of sand as a small marker of the treasure. + for (int dx = 0; dx < 2; dx++) + { + for (int dy = -1; dy < 3; dy++) + { + // Ensure that palm trees and pots are not transformed. + int oldTileType = Main.tile[startingIslandChestPoint.X + dx, startingIslandChestPoint.Y + dy].TileType; + if (oldTileType == TileID.PalmTree || !Main.tileSolid[oldTileType]) + { + WorldGen.KillTile(startingIslandChestPoint.X + dx, startingIslandChestPoint.Y + dy); + continue; + } + + Main.tile[startingIslandChestPoint.X + dx, startingIslandChestPoint.Y + dy].LiquidAmount = 0; + Main.tile[startingIslandChestPoint.X + dx, startingIslandChestPoint.Y + dy].TileType = (ushort)ModContent.TileType(); + } + } + return true; + } + + Point islandChestPoint = new(GetActualX((int)(BiomeWidth * IslandWidthPercentage * 0.5f) + WorldGen.genRand.Next(-8, 9)), YStart - 100); + while (!tryToGenerateTreasureChest(islandChestPoint)) + islandChestPoint.X += Abyss.AtLeftSideOfWorld.ToDirectionInt(); + } + + public static void GenerateOpenAirChestChest() + { + int width = BiomeWidth; + Dictionary depthMap = new(); + + for (int i = 60; i < width - 50; i++) + { + int x = GetActualX(i); + int y = YStart + MaxIslandDepth + 2; + int dy = 0; + + while (CalamityUtils.ParanoidTileRetrieval(x, y + dy).HasTile || CalamityUtils.ParanoidTileRetrieval(x, y + dy).LiquidAmount <= 0) + dy++; + + depthMap[x] = CalamityUtils.ParanoidTileRetrieval(x, y).HasTile ? y + dy : 0; + } + + // Pick a smooth place on the depth map to place the chest. This should happen close to an open air point in the caves. + for (int i = 0; i < 400; i++) + { + int x = depthMap.Keys.ElementAt(WorldGen.genRand.Next(10, depthMap.Count - 10)); + int leftY = depthMap[x - 1]; + int currentY = depthMap[x]; + int rightY = depthMap[x + 1]; + int averageY = (leftY + currentY + rightY) / 3; + + if (Math.Abs(averageY - currentY) < 3f && currentY > 0) + { + currentY += 3; + + // Ignore the current position if the chest cannot be placed due to tiles in the way. + if (CalamityUtils.AnySolidTileInSelection(x, currentY - 1, 4, -4)) + continue; + + // Place the chest and ground. + for (int dx = -1; dx < 3; dx++) + { + Main.tile[x + dx, currentY + 1].LiquidAmount = 0; + Main.tile[x + dx, currentY + 1].TileType = (ushort)ModContent.TileType(); + Main.tile[x + dx, currentY + 1].Get().HasTile = true; + } + + // If a buried chest was placed, force its first item to be the broken water filter. + Chest chest = MiscWorldgenRoutines.AddChestWithLoot(x, currentY - 2, (ushort)ModContent.TileType()); + if (chest != null) + { + chest.item[0].SetDefaults(ModContent.ItemType()); + chest.item[0].Prefix(-1); + break; + } + else + continue; + } + } + } + + public static void GenerateScrapPileChest(List scrapPilePositions) + { + // Pick a random scrap pile to generate near. + for (int i = 0; i < 400; i++) + { + Point placeToGenerateNear = WorldGen.genRand.Next(scrapPilePositions).ToPoint(); + int x = placeToGenerateNear.X + WorldGen.genRand.Next(-25 - i / 15, 25 + i / 15); + int y = placeToGenerateNear.Y + WorldGen.genRand.Next(-16, 4); + if (WorldGen.SolidTile(x, y)) + continue; + + // If a buried chest was successfully placed, force its first item to be the rusty beacon prototype. + Chest chest = MiscWorldgenRoutines.AddChestWithLoot(x, y, (ushort)ModContent.TileType()); + if (chest != null) + { + chest.item[0].SetDefaults(ModContent.ItemType()); + chest.item[0].Prefix(-1); + break; + } + } + } + + public static void GenerateDeepWaterChest() + { + // Pick a random scrap pile to generate near. + for (int i = 0; i < 400; i++) + { + int x = GetActualX(WorldGen.genRand.Next(60, BiomeWidth - 60)); + int y = YStart + WorldGen.genRand.Next(BlockDepth - 150, BlockDepth - 45); + if (WorldGen.SolidTile(x, y)) + continue; + + // Try again if too far down. + while (y < Main.maxTilesY - 210) + { + if (!WorldGen.SolidTile(x, y)) + y++; + else + { + y -= 3; + break; + } + } + if (y >= YStart + BlockDepth - 45) + continue; + + // If a buried chest was successfully placed, force its first item to be the rusty medallion. + Chest chest = MiscWorldgenRoutines.AddChestWithLoot(x, y, (ushort)ModContent.TileType()); + if (chest != null) + { + chest.item[0].SetDefaults(ModContent.ItemType()); + chest.item[0].Prefix(-1); + break; + } + } + } #endregion Generation Functions #region Misc Functions @@ -1111,21 +1356,6 @@ namespace CalamityMod.World return Main.maxTilesX - x; } - public static void DetermineYStart() - { - int xCheckPosition = GetActualX(BiomeWidth + 1); - var searchCondition = Searches.Chain(new Searches.Down(3000), new Conditions.IsSolid()); - Point determinedPoint; - - do - { - WorldUtils.Find(new Point(xCheckPosition, (int)WorldGen.worldSurfaceLow - 20), searchCondition, out determinedPoint); - xCheckPosition += Abyss.AtLeftSideOfWorld.ToDirectionInt(); - } - while (CalamityUtils.ParanoidTileRetrieval(determinedPoint.X, determinedPoint.Y).TileType == TileID.Ebonstone); - YStart = determinedPoint.Y; - } - public static float CalculateDitherChance(int width, int top, int bottom, int x, int y) { float verticalCompletion = Utils.GetLerpValue(top, bottom, y, true); @@ -1164,7 +1394,7 @@ namespace CalamityMod.World public static void GenerateColumn(int left, int top, int bottom) { int depth = BlockDepth; - ushort ColumnID = (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); @@ -1182,7 +1412,7 @@ namespace CalamityMod.World else if (y == bottom) frameY = 36; - Main.tile[x, y].TileType = ColumnID; + 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; From 93aeb92d849cb3f9ccfbdac389bb5b3f3372b78c Mon Sep 17 00:00:00 2001 From: Dominic Date: Fri, 14 Oct 2022 11:24:42 -0500 Subject: [PATCH 14/21] Sulphuric water poison meter --- CalPlayer/CalamityPlayer.cs | 9 +- CalPlayer/CalamityPlayerLifeRegen.cs | 38 ++--- CalamityConfig.cs | 20 +++ Localization/enUS.hjson | 4 + Systems/UIManagementSystem.cs | 8 + UI/SulphurousWaterMeter/SulphWaterBar.png | Bin 0 -> 166 bytes UI/SulphurousWaterMeter/SulphWaterMeter.png | Bin 0 -> 298 bytes .../SulphurousWaterMeterUI.cs | 144 ++++++++++++++++++ 8 files changed, 196 insertions(+), 27 deletions(-) create mode 100644 UI/SulphurousWaterMeter/SulphWaterBar.png create mode 100644 UI/SulphurousWaterMeter/SulphWaterMeter.png create mode 100644 UI/SulphurousWaterMeter/SulphurousWaterMeterUI.cs diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index a08c46c1d0..5343c75a2f 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -80,6 +80,7 @@ namespace CalamityMod.CalPlayer public static bool areThereAnyDamnEvents = false; public bool drawBossHPBar = true; public float stealthUIAlpha = 1f; + public float SulphWaterUIOpacity = 1f; public bool shouldDrawSmallText = true; public int projTypeJustHitBy; public int sCalDeathCount = 0; @@ -195,7 +196,6 @@ namespace CalamityMod.CalPlayer public int modStealthTimer; public int dashTimeMod; public int hInfernoBoost = 0; - public int pissWaterBoost = 0; public int packetTimer = 0; public int navyRodAuraTimer = 0; public int brimLoreInfernoTimer = 0; @@ -225,6 +225,7 @@ namespace CalamityMod.CalPlayer public int aBulwarkRareTimer = 0; public int spiritOriginBullseyeShootCountdown = 0; public int spiritOriginConvertedCrit = 0; + public float SulphWaterPoisoningLevel; private const int DashDisableCooldown = 12; @@ -776,6 +777,9 @@ namespace CalamityMod.CalPlayer public bool banishingFire = false; public bool wither = false; public bool ManaBurn = false; + + public const int SulphSeaWaterSafetyTime = 720; + public const int SulphSeaWaterRecoveryTime = 150; #endregion #region Buff @@ -2120,6 +2124,7 @@ namespace CalamityMod.CalPlayer auralisAurora = 0; fungalSymbioteTimer = 0; aBulwarkRareTimer = 0; + SulphWaterPoisoningLevel = 0f; spiritOriginConvertedCrit = 0; rage = 0f; adrenaline = 0f; @@ -2213,6 +2218,8 @@ namespace CalamityMod.CalPlayer stealthUIAlpha -= 0.035f; stealthUIAlpha = MathHelper.Clamp(stealthUIAlpha, 0f, 1f); } + if (SulphWaterUIOpacity > 0f) + SulphWaterUIOpacity = MathHelper.Clamp(SulphWaterUIOpacity - 0.035f, 0f, 1f); #endregion #region Buffs diff --git a/CalPlayer/CalamityPlayerLifeRegen.cs b/CalPlayer/CalamityPlayerLifeRegen.cs index 7ce319a4a4..690cc1a53f 100644 --- a/CalPlayer/CalamityPlayerLifeRegen.cs +++ b/CalPlayer/CalamityPlayerLifeRegen.cs @@ -9,6 +9,7 @@ using Microsoft.Xna.Framework; using System; using Terraria; using Terraria.ModLoader; +using Terraria.DataStructures; namespace CalamityMod.CalPlayer { @@ -156,39 +157,24 @@ namespace CalamityMod.CalPlayer lifeRegenLost += 4; } + // Slowly increase the sulphuric water poisoning effect. Once it's high enough, the player starts taking damage over time. if (ZoneSulphur && Player.IsUnderwater() && !decayEffigy && !abyssalDivingSuit && !Player.lavaWet && !Player.honeyWet) { - Player.AddBuff(ModContent.BuffType(), 2, true); - pissWaterBoost++; + float increment = 1f / SulphSeaWaterSafetyTime; + if (sulphurskin) + increment *= 0.5f; + if (sulfurSet) + increment *= 0.5f; - if (Player.lifeRegen > 0) - Player.lifeRegen = 0; - - Player.lifeRegenTime = 0; - int waterDivisor = 250; - int minimumRegenLost = 8; - if (sulfurSet && sulphurskin) + SulphWaterPoisoningLevel = MathHelper.Clamp(SulphWaterPoisoningLevel + increment, 0f, 1f); + if (SulphWaterPoisoningLevel >= 1f) { - waterDivisor = 500; - minimumRegenLost = 1; + SulphWaterPoisoningLevel = 0f; + Player.Hurt(PlayerDeathReason.ByCustomReason($"{Player.name}'s flesh was dissolved by sulphuric water."), Math.Min(Player.statLifeMax2 / 2, 200), 0); } - else if (sulfurSet) - { - waterDivisor = 400; - minimumRegenLost = 3; - } - else if (sulphurskin) - { - waterDivisor = 350; - minimumRegenLost = 2; - } - int sulphurWater = pissWaterBoost / waterDivisor; - if (sulphurWater < minimumRegenLost) - sulphurWater = minimumRegenLost; - lifeRegenLost += sulphurWater; } else - pissWaterBoost = 0; + SulphWaterPoisoningLevel = MathHelper.Clamp(SulphWaterPoisoningLevel - 1f / SulphSeaWaterRecoveryTime, 0f, 1f); if (sulphurPoison) { diff --git a/CalamityConfig.cs b/CalamityConfig.cs index f5553c1b85..a5dfabdaa3 100644 --- a/CalamityConfig.cs +++ b/CalamityConfig.cs @@ -17,6 +17,7 @@ using Terraria.ModLoader.Config; using CalamityMod.Items.PermanentBoosters; using CalamityMod.UI.Rippers; using CalamityMod.UI.DraedonsArsenal; +using CalamityMod.UI.SulphurousWaterMeter; namespace CalamityMod { @@ -140,6 +141,22 @@ namespace CalamityMod [Tooltip("$Mods.CalamityMod.Config.EntryTooltip.StealthMeterPosY")] public float StealthMeterPosY { get; set; } + [Label("$Mods.CalamityMod.Config.EntryTitle.SulphuricWaterMeterPosX")] + [BackgroundColor(192, 54, 64, 192)] + [SliderColor(224, 165, 56, 128)] + [Range(0f, 100f)] + [DefaultValue(SulphurousWaterMeterUI.DefaultPosX)] + [Tooltip("$Mods.CalamityMod.Config.EntryTooltip.SulphuricWaterMeterPosX")] + public float SulphuricWaterMeterPosX { get; set; } + + [Label("$Mods.CalamityMod.Config.EntryTitle.SulphuricWaterMeterPosY")] + [BackgroundColor(192, 54, 64, 192)] + [SliderColor(224, 165, 56, 128)] + [Range(0f, 100f)] + [DefaultValue(SulphurousWaterMeterUI.DefaultPosY)] + [Tooltip("$Mods.CalamityMod.Config.EntryTooltip.SulphuricWaterMeterPosY")] + public float SulphuricWaterMeterPosY { get; set; } + [Label("$Mods.CalamityMod.Config.EntryTitle.ChargeMeter")] [BackgroundColor(192, 54, 64, 192)] [DefaultValue(true)] @@ -394,6 +411,9 @@ namespace CalamityMod new("StealthMeterPosX", ItemID.LaserRuler), new("StealthMeterPosY", ItemID.LaserRuler), + new("SulphuricWaterMeterPosX", ItemID.LaserRuler), + new("SulphuricWaterMeterPosY", ItemID.LaserRuler), + new("ChargeMeter", ModContent.ItemType()), new("ChargeMeterPosX", ItemID.LaserRuler), new("ChargeMeterPosY", ItemID.LaserRuler), diff --git a/Localization/enUS.hjson b/Localization/enUS.hjson index 7dfc0377d0..753cd9e2d4 100644 --- a/Localization/enUS.hjson +++ b/Localization/enUS.hjson @@ -56,6 +56,8 @@ Config: "StealthMeter": "Display Stealth Meter", "StealthMeterPosX": "Stealth Meter X Position", "StealthMeterPosY": "Stealth Meter Y Position", + "SulphuricWaterMeterPosX": "Sulphuric Water Poison Meter X Position", + "SulphuricWaterMeterPosY": "Sulphuric Water Poison Meter Y Position", "TownNPCSpawnRateMultiplier": "Town NPC Spawn Rate Multiplier", "TownNPCsSpawnAtNight": "Town NPCs Spawn at Night", "VanillaCooldownDisplay": "Display Vanilla Cooldowns", @@ -102,6 +104,8 @@ Config: "StealthMeter": "Enables the Stealth Meter UI, which shows the player's current stealth level.\nThe Stealth Meter is always hidden if not wearing Rogue armor.", "StealthMeterPosX": "The X position of the Stealth Meter, measured as a % of your screen width.\nThe meter can be dragged with the mouse if Lock Meter Positions is disabled.", "StealthMeterPosY": "The Y position of the Stealth Meter, measured as a % of your screen height.\nThe meter can be dragged with the mouse if Lock Meter Positions is disabled.", + "SulphuricWaterMeterPosX": "The X position of the Sulphuric Water Poison Meter, measured as a % of your screen width.\nThe meter can be dragged with the mouse if Lock Meter Positions is disabled.", + "SulphuricWaterMeterPosY": "The Y position of the Sulphuric Water Poison Meter, measured as a % of your screen height.\nThe meter can be dragged with the mouse if Lock Meter Positions is disabled.", "TownNPCSpawnRateMultiplier": "Directly multiply the rate at which town NPCs spawn and respawn.\nThis reduces waiting times if a boss or event wipes your whole town.", "TownNPCsSpawnAtNight": "When enabled, town NPCs can spawn and respawn at night.\nThis includes the Old Man.", "VanillaCooldownDisplay": "Adds the vanilla debuffs Potion Sickness and Chaos State to the Cooldown Rack.\nThis doesn't remove them from your buff list, but can help with visibility nontheless", diff --git a/Systems/UIManagementSystem.cs b/Systems/UIManagementSystem.cs index 4d93a3799e..bb9155904d 100644 --- a/Systems/UIManagementSystem.cs +++ b/Systems/UIManagementSystem.cs @@ -5,6 +5,7 @@ using CalamityMod.UI.DraedonsArsenal; using CalamityMod.UI.DraedonSummoning; using CalamityMod.UI.ModeIndicator; using CalamityMod.UI.Rippers; +using CalamityMod.UI.SulphurousWaterMeter; using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; @@ -89,6 +90,13 @@ namespace CalamityMod.Systems return true; }, InterfaceScaleType.None)); + // Sulphuric water poison bar + layers.Insert(mouseIndex, new LegacyGameInterfaceLayer("Sulphuric Water Poisoning UI", () => + { + SulphurousWaterMeterUI.Draw(Main.spriteBatch, Main.LocalPlayer); + return true; + }, InterfaceScaleType.None)); + // Charge meter layers.Insert(mouseIndex, new LegacyGameInterfaceLayer("Charge UI", () => { diff --git a/UI/SulphurousWaterMeter/SulphWaterBar.png b/UI/SulphurousWaterMeter/SulphWaterBar.png new file mode 100644 index 0000000000000000000000000000000000000000..0ef0e181d8cfc6b7acd39a437aac5ea8f9c671bb GIT binary patch literal 166 zcmeAS@N?(olHy`uVBq!ia0vp^3P3Ex!3HF)PTTVM%xNb!1@J z*w6hZkrl}2EbxddW?8eR=RL2FMJ#}E(iWC_;A2_iie2P_t5+^pA-*8ZVU z%zNq(U&NJdPLVelch8iX(kg4<_>z%%F&{|j5@t3whHdVwSLPp)ng%q6!PC{xWt~$( F69C1aEqwq0 literal 0 HcmV?d00001 diff --git a/UI/SulphurousWaterMeter/SulphWaterMeter.png b/UI/SulphurousWaterMeter/SulphWaterMeter.png new file mode 100644 index 0000000000000000000000000000000000000000..72b6858ebf13b053c5f716c0ece4de72a4a7bf00 GIT binary patch literal 298 zcmeAS@N?(olHy`uVBq!ia0vp^CO|C2!3-pogLyvzDaPU;cPEB*=VV?2IV|apzK#qG z8~eHcB(ehe5&=FTu8eH_g;DO72Eppers<9jK33K?o{2!olaC@E11XM@Aiv=M5WsM+ zd2b|8jI+QavY3H^?+^$xifVW@00rAUT^vI!{FhD)6lzf5aB;q~=YMZ8^KzeDwW|69 z`%Lbc(NO*6D~yyMr8+!17<5wdL}h$J@H0PU71P$-xQ6R*HtH>1 z=BlcF{KMoaGngMu(o$ghk>ly@s;U=ob=tvcf6Mq;qnSkOmrrQnl3r%;Aiv6PRpuXq h;{QwXTb2az)t~3Qxh8hXKA@8rJYD@<);T3K0RZg{XfXf) literal 0 HcmV?d00001 diff --git a/UI/SulphurousWaterMeter/SulphurousWaterMeterUI.cs b/UI/SulphurousWaterMeter/SulphurousWaterMeterUI.cs new file mode 100644 index 0000000000..4244b70d54 --- /dev/null +++ b/UI/SulphurousWaterMeter/SulphurousWaterMeterUI.cs @@ -0,0 +1,144 @@ +using System; +using CalamityMod.CalPlayer; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Input; +using ReLogic.Content; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.UI.SulphurousWaterMeter +{ + public class SulphurousWaterMeterUI : ModSystem + { + // These values were decided relative to the stealth meter positions, and are by default slightly below them. + internal const float DefaultPosX = StealthUI.DefaultStealthPosX; + internal const float DefaultPosY = StealthUI.DefaultStealthPosY + 0.0377f; + private const float MouseDragEpsilon = 0.05f; // 0.05% + + private static Vector2? dragOffset = null; + private static Texture2D edgeTexture, barTexture; + + public override void OnModLoad() + { + edgeTexture = ModContent.Request("CalamityMod/UI/SulphurousWaterMeter/SulphWaterMeter", AssetRequestMode.ImmediateLoad).Value; + barTexture = ModContent.Request("CalamityMod/UI/SulphurousWaterMeter/SulphWaterBar", AssetRequestMode.ImmediateLoad).Value; + Reset(); + } + + public override void Unload() + { + Reset(); + edgeTexture = barTexture = null; + } + + private static void Reset() => dragOffset = null; + + public static void Draw(SpriteBatch spriteBatch, Player player) + { + // Sanity check the planned position before drawing. This is done relative. + Vector2 screenRatioPosition = new Vector2(CalamityConfig.Instance.SulphuricWaterMeterPosX, CalamityConfig.Instance.SulphuricWaterMeterPosY); + if (screenRatioPosition.X < 0f || screenRatioPosition.X > 100f) + screenRatioPosition.X = DefaultPosX; + if (screenRatioPosition.Y < 0f || screenRatioPosition.Y > 100f) + screenRatioPosition.Y = DefaultPosY; + + // Convert the screen ratio position to an absolute position in pixels + // Cast to integer to prevent blurriness which results from decimal pixel positions + float uiScale = Main.UIScale; + Vector2 screenPos = screenRatioPosition; + screenPos.X = (int)(screenPos.X * 0.01f * Main.screenWidth); + screenPos.Y = (int)(screenPos.Y * 0.01f * Main.screenHeight); + + CalamityPlayer modPlayer = player.Calamity(); + + // If not drawing the water meter, save its latest position to config and leave. + if (modPlayer.SulphWaterUIOpacity > 0f) + DrawWaterBar(spriteBatch, modPlayer, screenPos); + else + { + bool changed = false; + if (CalamityConfig.Instance.SulphuricWaterMeterPosX != screenRatioPosition.X) + { + CalamityConfig.Instance.SulphuricWaterMeterPosX = screenRatioPosition.X; + changed = true; + } + if (CalamityConfig.Instance.SulphuricWaterMeterPosY != screenRatioPosition.Y) + { + CalamityConfig.Instance.SulphuricWaterMeterPosY = screenRatioPosition.Y; + changed = true; + } + + if (changed) + CalamityMod.SaveConfig(CalamityConfig.Instance); + } + + Rectangle mouseHitbox = new Rectangle((int)Main.MouseScreen.X, (int)Main.MouseScreen.Y, 8, 8); + Rectangle waterBarArea = Utils.CenteredRectangle(screenPos, edgeTexture.Size() * uiScale); + + MouseState ms = Mouse.GetState(); + Vector2 mousePos = Main.MouseScreen; + + // Handle mouse dragging + if (waterBarArea.Intersects(mouseHitbox)) + { + if (!CalamityConfig.Instance.MeterPosLock) + Main.LocalPlayer.mouseInterface = true; + + // If the mouse is on top of the meter, show the player's accumulated sulphuric poisoning. + if (modPlayer.SulphWaterPoisoningLevel > 0f && modPlayer.SulphWaterUIOpacity >= 0f) + { + string poisonText = (modPlayer.SulphWaterPoisoningLevel * 100f).ToString("n2"); + string textToDisplay = $"Sulphuric Poisoning: {poisonText}/100"; + Main.instance.MouseText(textToDisplay, 0, 0, -1, -1, -1, -1); + modPlayer.SulphWaterUIOpacity = MathHelper.Lerp(modPlayer.SulphWaterUIOpacity, 0.25f, 0.035f); + } + + Vector2 newScreenRatioPosition = screenRatioPosition; + + // As long as the mouse button is held down, drag the meter along with an offset. + if (!CalamityConfig.Instance.MeterPosLock && ms.LeftButton == ButtonState.Pressed) + { + // If the drag offset doesn't exist yet, create it. + if (!dragOffset.HasValue) + dragOffset = mousePos - screenPos; + + // Given the mouse's absolute current position, compute where the corner of the water bar should be based on the original drag offset. + Vector2 newCorner = mousePos - dragOffset.GetValueOrDefault(Vector2.Zero); + + // Convert the new corner position into a screen ratio position. + newScreenRatioPosition.X = (100f * newCorner.X) / Main.screenWidth; + newScreenRatioPosition.Y = (100f * newCorner.Y) / Main.screenHeight; + } + + // Compute the change in position. If it is large enough, actually move the meter + Vector2 delta = newScreenRatioPosition - screenRatioPosition; + if (Math.Abs(delta.X) >= MouseDragEpsilon || Math.Abs(delta.Y) >= MouseDragEpsilon) + { + CalamityConfig.Instance.SulphuricWaterMeterPosX = newScreenRatioPosition.X; + CalamityConfig.Instance.SulphuricWaterMeterPosY = newScreenRatioPosition.Y; + } + + // When the mouse is released, save the config and destroy the drag offset. + if (ms.LeftButton == ButtonState.Released) + { + dragOffset = null; + CalamityMod.SaveConfig(CalamityConfig.Instance); + } + } + else + modPlayer.SulphWaterUIOpacity = MathHelper.Clamp(modPlayer.SulphWaterUIOpacity + (modPlayer.SulphWaterPoisoningLevel > 0f).ToDirectionInt() * 0.06f, 0f, 1f); + } + + private static void DrawWaterBar(SpriteBatch spriteBatch, CalamityPlayer modPlayer, Vector2 screenPos) + { + float uiScale = Main.UIScale; + float offset = (edgeTexture.Width - barTexture.Width) * 0.5f; + spriteBatch.Draw(edgeTexture, screenPos, null, Color.White * modPlayer.SulphWaterUIOpacity, 0f, edgeTexture.Size() * 0.5f, uiScale, SpriteEffects.None, 0); + + float completionRatio = MathHelper.Clamp(modPlayer.SulphWaterPoisoningLevel, 0f, 1f); + Rectangle barRectangle = new Rectangle(0, 0, (int)(barTexture.Width * completionRatio), barTexture.Width); + spriteBatch.Draw(barTexture, screenPos + new Vector2(offset * uiScale, 0), barRectangle, Color.White * modPlayer.SulphWaterUIOpacity, 0f, edgeTexture.Size() * 0.5f, uiScale, SpriteEffects.None, 0); + } + } +} From 9737de8beae2aa604cf69ef23263b70a9b93c1b1 Mon Sep 17 00:00:00 2001 From: Dominic Date: Sun, 16 Oct 2022 19:17:35 -0500 Subject: [PATCH 15/21] Sulphuric water safe zones (wip) --- CalPlayer/CalamityPlayerLifeRegen.cs | 11 +++++- ILEditing/MechanicILChanges.cs | 32 ++++++++++++++++- Systems/SulphuricWaterSafeZoneSystem.cs | 47 +++++++++++++++++++++++++ 3 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 Systems/SulphuricWaterSafeZoneSystem.cs diff --git a/CalPlayer/CalamityPlayerLifeRegen.cs b/CalPlayer/CalamityPlayerLifeRegen.cs index 690cc1a53f..1e7155e0e3 100644 --- a/CalPlayer/CalamityPlayerLifeRegen.cs +++ b/CalPlayer/CalamityPlayerLifeRegen.cs @@ -10,6 +10,8 @@ using System; using Terraria; using Terraria.ModLoader; using Terraria.DataStructures; +using CalamityMod.Systems; +using System.Linq; namespace CalamityMod.CalPlayer { @@ -158,7 +160,14 @@ namespace CalamityMod.CalPlayer } // Slowly increase the sulphuric water poisoning effect. Once it's high enough, the player starts taking damage over time. - if (ZoneSulphur && Player.IsUnderwater() && !decayEffigy && !abyssalDivingSuit && !Player.lavaWet && !Player.honeyWet) + bool nearSafeZone = false; + if (SulphuricWaterSafeZoneSystem.NearbySafeTiles.Count >= 1) + { + Point closestSafeZone = SulphuricWaterSafeZoneSystem.NearbySafeTiles.Keys.OrderBy(t => t.ToVector2().DistanceSQ(Player.Center / 16f)).First(); + if (Vector2.Distance(Player.Center.ToTileCoordinates().ToVector2(), closestSafeZone.ToVector2()) < SulphuricWaterSafeZoneSystem.NearbySafeTiles[closestSafeZone] * 17f) + nearSafeZone = true; + } + if (ZoneSulphur && Player.IsUnderwater() && !decayEffigy && !abyssalDivingSuit && !Player.lavaWet && !Player.honeyWet && !nearSafeZone) { float increment = 1f / SulphSeaWaterSafetyTime; if (sulphurskin) diff --git a/ILEditing/MechanicILChanges.cs b/ILEditing/MechanicILChanges.cs index e77902d279..bcb08382d1 100644 --- a/ILEditing/MechanicILChanges.cs +++ b/ILEditing/MechanicILChanges.cs @@ -43,6 +43,7 @@ using CalamityMod.DataStructures; using CalamityMod.Particles.Metaballs; using Terraria.GameContent.Drawing; using CalamityMod.Tiles.Abyss; +using System.Collections.Generic; namespace CalamityMod.ILEditing { @@ -779,7 +780,9 @@ namespace CalamityMod.ILEditing cursor.Emit(OpCodes.Ldloc, 8); cursor.Emit(OpCodes.Ldelem_Ref); cursor.Emit(OpCodes.Ldloc, 8); - cursor.EmitDelegate>((initialColor, initialTexture, liquidType) => + cursor.Emit(OpCodes.Ldloc, 3); + cursor.Emit(OpCodes.Ldloc, 4); + cursor.EmitDelegate>((initialColor, initialTexture, liquidType, x, y) => { initialColor.TopLeftColor = SelectLavaColor(initialTexture, initialColor.TopLeftColor, liquidType == 1); initialColor.TopRightColor = SelectLavaColor(initialTexture, initialColor.TopRightColor, liquidType == 1); @@ -787,6 +790,33 @@ namespace CalamityMod.ILEditing initialColor.BottomRightColor = SelectLavaColor(initialTexture, initialColor.BottomRightColor, liquidType == 1); if (liquidType == ModContent.Find("CalamityMod/SulphuricWater").Slot) { + if (SulphuricWaterSafeZoneSystem.NearbySafeTiles.Count >= 1) + { + Color cleanWaterColor = new(10, 62, 193); + Point closestSafeZone = SulphuricWaterSafeZoneSystem.NearbySafeTiles.Keys.OrderBy(t => t.ToVector2().DistanceSQ(new(x, y))).First(); + List points = new() + { + new Vector2(x - 0.5f, y - 0.5f), + new Vector2(x + 0.5f, y - 0.5f), + new Vector2(x - 0.5f, y + 0.5f), + new Vector2(x + 0.5f, y + 0.5f), + }; + + for (int i = 0; i < 4; i++) + { + float distanceToClosest = points[i].Distance(closestSafeZone.ToVector2()); + float acidicWaterInterpolant = Utils.GetLerpValue(12f, 20.5f, distanceToClosest + (1f - SulphuricWaterSafeZoneSystem.NearbySafeTiles[closestSafeZone]) * 21f, true); + if (i == 0) + initialColor.TopLeftColor = Color.Lerp(initialColor.TopLeftColor, cleanWaterColor, 1f - acidicWaterInterpolant); + if (i == 1) + initialColor.TopRightColor = Color.Lerp(initialColor.TopRightColor, cleanWaterColor, 1f - acidicWaterInterpolant); + if (i == 2) + initialColor.BottomLeftColor = Color.Lerp(initialColor.BottomLeftColor, cleanWaterColor, 1f - acidicWaterInterpolant); + if (i == 3) + initialColor.BottomRightColor = Color.Lerp(initialColor.BottomRightColor, cleanWaterColor, 1f - acidicWaterInterpolant); + } + } + initialColor.TopLeftColor *= 0.4f; initialColor.TopRightColor *= 0.4f; initialColor.BottomLeftColor *= 0.4f; diff --git a/Systems/SulphuricWaterSafeZoneSystem.cs b/Systems/SulphuricWaterSafeZoneSystem.cs new file mode 100644 index 0000000000..e716d13f30 --- /dev/null +++ b/Systems/SulphuricWaterSafeZoneSystem.cs @@ -0,0 +1,47 @@ +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Tiles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Systems +{ + public class SulphuricWaterSafeZoneSystem : ModSystem + { + public static Dictionary NearbySafeTiles + { + get; + set; + } = new(); + + public override void PreUpdateEntities() + { + // Make the potency of the current safe tiles gradually dissipate, and eventually disappear from the dictionary once completely gone. + foreach (Point p in NearbySafeTiles.Keys) + NearbySafeTiles[p] -= 0.06f; + foreach (var key in NearbySafeTiles.Keys.Where(key => NearbySafeTiles[key] <= 0f)) + NearbySafeTiles.Remove(key); + + ushort safeTileID = (ushort)ModContent.TileType(); + Point center = Main.LocalPlayer.Center.ToTileCoordinates(); + + for (int dx = -56; dx < 56; dx++) + { + for (int dy = -56; dy < 56; dy++) + { + Point p = new(center.X + dx, center.Y + dy); + Tile t = Main.tile[p]; + + if (!t.HasTile) + continue; + + if (t.TileType != safeTileID) + continue; + + NearbySafeTiles[p] = 1f; + } + } + } + } +} From 6883e1f55e28032143f80b58fc8feea2ae5cfc29 Mon Sep 17 00:00:00 2001 From: Dominic Date: Mon, 17 Oct 2022 13:15:59 -0500 Subject: [PATCH 16/21] Comment out test code --- Systems/SulphuricWaterSafeZoneSystem.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Systems/SulphuricWaterSafeZoneSystem.cs b/Systems/SulphuricWaterSafeZoneSystem.cs index e716d13f30..6024c82d43 100644 --- a/Systems/SulphuricWaterSafeZoneSystem.cs +++ b/Systems/SulphuricWaterSafeZoneSystem.cs @@ -23,6 +23,9 @@ namespace CalamityMod.Systems foreach (var key in NearbySafeTiles.Keys.Where(key => NearbySafeTiles[key] <= 0f)) NearbySafeTiles.Remove(key); + // TODO -- Uncomment the below code to use an actual block and not the auric tesla bar, once sprites for said blocks are created. + + /* ushort safeTileID = (ushort)ModContent.TileType(); Point center = Main.LocalPlayer.Center.ToTileCoordinates(); @@ -42,6 +45,7 @@ namespace CalamityMod.Systems NearbySafeTiles[p] = 1f; } } + */ } } } From ae430dc794e908d093bfb3bcdf4f425a67cde937 Mon Sep 17 00:00:00 2001 From: Dominic Date: Mon, 17 Oct 2022 13:33:46 -0500 Subject: [PATCH 17/21] Nuclear Toads telegraph their explosion --- NPCs/AcidRain/NuclearToad.cs | 43 ++++++++++++++++++++++------- NPCs/CalamityGlobalNPC.cs | 2 +- Projectiles/Enemy/NuclearToadGoo.cs | 4 +-- 3 files changed, 36 insertions(+), 13 deletions(-) diff --git a/NPCs/AcidRain/NuclearToad.cs b/NPCs/AcidRain/NuclearToad.cs index e32e79e0f8..8993909185 100644 --- a/NPCs/AcidRain/NuclearToad.cs +++ b/NPCs/AcidRain/NuclearToad.cs @@ -13,12 +13,29 @@ using Terraria.GameContent.Bestiary; using Terraria.GameContent.ItemDropRules; using Terraria.ID; using Terraria.ModLoader; +using System; namespace CalamityMod.NPCs.AcidRain { public class NuclearToad : ModNPC { public Player Target => Main.player[NPC.target]; + + public static float ExplosionStartRadius + { + get + { + float explodeDistance = DownedBossSystem.downedAquaticScourge ? 360f : 270f; + if (DownedBossSystem.downedPolterghast) + explodeDistance = 560f; + return explodeDistance; + } + } + + public ref float ExplosionTimer => ref NPC.ai[0]; + + public const float ExplosionTelegraphTime = 120f; + public override void SetStaticDefaults() { DisplayName.SetDefault("Nuclear Toad"); @@ -69,8 +86,8 @@ namespace CalamityMod.NPCs.AcidRain { bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - // Will move to localization whenever that is cleaned up. - new FlavorTextBestiaryInfoElement("When threatened underwater they rapidly inflate and bob to the surface. As a last resort, they forcefully burst themselves. Their selfless goal is the prolonged survival of their kin.") + // Will move to localization whenever that is cleaned up. + new FlavorTextBestiaryInfoElement("When threatened underwater they rapidly inflate and bob to the surface. As a last resort, they forcefully burst themselves. Their selfless goal is the prolonged survival of their kin.") }); } @@ -97,24 +114,22 @@ namespace CalamityMod.NPCs.AcidRain NPC.velocity.Y += 0.16f; if (NPC.velocity.Y > 3f) NPC.velocity.Y = 3f; - NPC.ai[0] = 5f; } // Make a frog croak sound from time to time. if (Main.rand.NextBool(480)) SoundEngine.PlaySound(SoundID.Zombie13, NPC.Center); - float explodeDistance = DownedBossSystem.downedAquaticScourge ? 295f : 195f; - if (DownedBossSystem.downedPolterghast) - explodeDistance = 470f; - // Explode if a player gets too close. - if (NPC.WithinRange(Target.Center, explodeDistance)) + if (NPC.WithinRange(Target.Center, ExplosionStartRadius) || ExplosionTimer >= 1f) + ExplosionTimer++; + + if (ExplosionTimer >= ExplosionTelegraphTime) { if (Main.netMode != NetmodeID.MultiplayerClient) { int damage = Main.expertMode ? DownedBossSystem.downedAquaticScourge ? 21 : 8 : DownedBossSystem.downedAquaticScourge ? 27 : 10; - float speed = Main.rand.NextFloat(6f, 9f); + float speed = Main.rand.NextFloat(8f, 12f); if (DownedBossSystem.downedPolterghast) { speed *= 1.8f; @@ -122,7 +137,7 @@ namespace CalamityMod.NPCs.AcidRain } for (int i = 0; i < 7; i++) - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, Main.rand.NextVector2CircularEdge(speed, speed), ModContent.ProjectileType(), damage, 1f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, -Vector2.UnitY.RotatedByRandom(0.79f) * speed * Main.rand.NextFloat(0.8f, 1f), ModContent.ProjectileType(), damage, 1f); } SoundEngine.PlaySound(SoundID.DD2_KoboldExplosion, NPC.Center); NPC.life = 0; @@ -132,6 +147,14 @@ namespace CalamityMod.NPCs.AcidRain } } + public override Color? GetAlpha(Color drawColor) + { + float explosionInterpolant = ExplosionTimer / ExplosionTelegraphTime; + float fadeToRed = (float)Math.Abs(Math.Sin(MathHelper.Pi * Math.Pow(explosionInterpolant, 3D) * 6f)); + Color c = Color.Lerp(drawColor, new(232, 40, 12, 0), fadeToRed * 0.75f); + return c * NPC.Opacity; + } + public override void FindFrame(int frameHeight) { NPC.frameCounter++; diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index dc75cf8428..9bdd68a05c 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -2435,7 +2435,7 @@ namespace CalamityMod.NPCs spriteBatch.Draw(texture, npc.Center - screenOffset + offset, npc.frame, - Color.White, + npc.GetAlpha(Color.White), npc.rotation, npc.frame.Size() * 0.5f, npc.scale, diff --git a/Projectiles/Enemy/NuclearToadGoo.cs b/Projectiles/Enemy/NuclearToadGoo.cs index 0e500cb842..a82d9e1e4b 100644 --- a/Projectiles/Enemy/NuclearToadGoo.cs +++ b/Projectiles/Enemy/NuclearToadGoo.cs @@ -1,4 +1,4 @@ -using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; using Terraria; using Terraria.ModLoader; @@ -29,7 +29,7 @@ namespace CalamityMod.Projectiles.Enemy Projectile.localAI[0] = 1f; } if (Projectile.velocity.Y < 10f) - Projectile.velocity.Y += 0.175f; + Projectile.velocity.Y += 0.27f; } public override void OnHitPlayer(Player target, int damage, bool crit) From 7492f64f4c50835c141783ee671c828a673f013f Mon Sep 17 00:00:00 2001 From: Dominic Date: Mon, 17 Oct 2022 13:36:30 -0500 Subject: [PATCH 18/21] Nerf Skyfin max HP --- NPCs/AcidRain/Skyfin.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NPCs/AcidRain/Skyfin.cs b/NPCs/AcidRain/Skyfin.cs index 9a928ed6c8..7c24854f5f 100644 --- a/NPCs/AcidRain/Skyfin.cs +++ b/NPCs/AcidRain/Skyfin.cs @@ -38,7 +38,7 @@ namespace CalamityMod.NPCs.AcidRain NPC.aiStyle = AIType = -1; NPC.damage = 12; - NPC.lifeMax = 70; + NPC.lifeMax = 50; NPC.defense = 6; NPC.knockBackResist = 1f; From 0733ef344b8b0822c48c84c5722284694f3db21e Mon Sep 17 00:00:00 2001 From: Dominic Date: Mon, 17 Oct 2022 16:57:08 -0500 Subject: [PATCH 19/21] Tile type check update --- World/SulphurousSea.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/World/SulphurousSea.cs b/World/SulphurousSea.cs index 59f9448280..41fa176641 100644 --- a/World/SulphurousSea.cs +++ b/World/SulphurousSea.cs @@ -710,7 +710,12 @@ namespace CalamityMod.World { int width = BiomeWidth; int depth = BlockDepth; - ushort blockTileType = (ushort)ModContent.TileType(); + List blockTileTypes = new() + { + (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), + }; for (int i = 0; i < width; i++) { @@ -718,7 +723,7 @@ namespace CalamityMod.World for (int y = YStart; y < YStart + depth; y++) { Tile t = CalamityUtils.ParanoidTileRetrieval(x, y); - if (!t.HasTile || t.TileType != blockTileType) + if (!t.HasTile || !blockTileTypes.Contains(t.TileType)) continue; // Check to see if the tile has any cardinal neighbors. If it doesn't, destroy it. From 7f98212638173195609c801b68fd0ae6f45b7113 Mon Sep 17 00:00:00 2001 From: Dominic Date: Wed, 19 Oct 2022 09:42:05 -0500 Subject: [PATCH 20/21] Remove SulphurousSandNoWater load hack --- Schematics/CalamitySchematicIO.cs | 4 ---- Tiles/Abyss/SulphurousSand.cs | 7 +++++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Schematics/CalamitySchematicIO.cs b/Schematics/CalamitySchematicIO.cs index ec2dc150d7..e20262d8f9 100644 --- a/Schematics/CalamitySchematicIO.cs +++ b/Schematics/CalamitySchematicIO.cs @@ -557,10 +557,6 @@ namespace CalamityMod.Schematics ModContent.SplitName(tileFullName, out string mod, out string tileName); Mod theMod = ModLoader.GetMod(mod); - // TODO -- This is legacy code to avoid breaking old schematics. It would be ideal to revert this and update the schematics, but this will do for now. - if (tileName == "SulphurousSandNoWater") - tileName = "SulphurousSand"; - // If that mod isn't loaded, spawn in a TML default UnloadedTile instead. smt.TileType = (ushort)(theMod is null ? ModContent.TileType() : theMod.Find(tileName).Type); } diff --git a/Tiles/Abyss/SulphurousSand.cs b/Tiles/Abyss/SulphurousSand.cs index a19ae64783..807073339f 100644 --- a/Tiles/Abyss/SulphurousSand.cs +++ b/Tiles/Abyss/SulphurousSand.cs @@ -1,5 +1,4 @@ - -using CalamityMod.CalPlayer; +using CalamityMod.CalPlayer; using CalamityMod.Projectiles.Enemy; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -10,6 +9,10 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Abyss { + // Old, now deleted sub-variant of sulphurous sand that was only placed by players and did not create water. + // It would create block swap issues with regular sulphurous sand and was rendered obsolete with the removal of this tile's water emission mechanic. + // For compatibility reasons (including with schematics), however, that tile is converted into this one. + [LegacyName("SulphurousSandNoWater")] public class SulphurousSand : ModTile { public override void SetStaticDefaults() From 556fd3db6bf02986c9fa31bf1c6c069ed0566e9a Mon Sep 17 00:00:00 2001 From: Dominic Date: Wed, 19 Oct 2022 09:45:34 -0500 Subject: [PATCH 21/21] DrawCustomLava2 -> ChangeWaterQuadColors --- ILEditing/ILChangesLoading.cs | 4 ++-- ILEditing/ILHelperMethods.cs | 39 ++++++++++++++++++++++++++++++++++ ILEditing/MechanicILChanges.cs | 36 ++----------------------------- 3 files changed, 43 insertions(+), 36 deletions(-) diff --git a/ILEditing/ILChangesLoading.cs b/ILEditing/ILChangesLoading.cs index fb379ad75d..84149f4aa9 100644 --- a/ILEditing/ILChangesLoading.cs +++ b/ILEditing/ILChangesLoading.cs @@ -54,7 +54,7 @@ namespace CalamityMod.ILEditing On.Terraria.Main.DrawInfernoRings += DrawForegroundParticles; On.Terraria.Main.SetDisplayMode += ResetRenderTargetSizes; On.Terraria.GameContent.Drawing.TileDrawing.DrawPartialLiquid += DrawCustomLava; - IL.Terraria.GameContent.Liquid.LiquidRenderer.InternalDraw += DrawCustomLava2; + IL.Terraria.GameContent.Liquid.LiquidRenderer.InternalDraw += ChangeWaterQuadColors; IL.Terraria.Main.oldDrawWater += DrawCustomLava3; IL.Terraria.Player.CollectTaxes += MakeTaxCollectorUseful; On.Terraria.Graphics.Light.TileLightScanner.GetTileLight += MakeSulphSeaWaterBetter; @@ -166,7 +166,7 @@ namespace CalamityMod.ILEditing On.Terraria.Main.DrawInfernoRings -= DrawForegroundParticles; On.Terraria.Main.SetDisplayMode -= ResetRenderTargetSizes; On.Terraria.GameContent.Drawing.TileDrawing.DrawPartialLiquid -= DrawCustomLava; - IL.Terraria.GameContent.Liquid.LiquidRenderer.InternalDraw -= DrawCustomLava2; + IL.Terraria.GameContent.Liquid.LiquidRenderer.InternalDraw -= ChangeWaterQuadColors; IL.Terraria.Main.oldDrawWater -= DrawCustomLava3; IL.Terraria.Player.CollectTaxes -= MakeTaxCollectorUseful; On.Terraria.Graphics.Light.TileLightScanner.GetTileLight -= MakeSulphSeaWaterBetter; diff --git a/ILEditing/ILHelperMethods.cs b/ILEditing/ILHelperMethods.cs index 5b3f53aefa..f11c936e0a 100644 --- a/ILEditing/ILHelperMethods.cs +++ b/ILEditing/ILHelperMethods.cs @@ -5,6 +5,10 @@ using MonoMod.Cil; using Terraria; using Terraria.ID; using Terraria.Audio; +using CalamityMod.Systems; +using Terraria.Graphics; +using System.Collections.Generic; +using System.Linq; namespace CalamityMod.ILEditing { @@ -110,6 +114,41 @@ namespace CalamityMod.ILEditing return initialLightColor; } + private static void SelectSulphuricWaterColor(int x, int y, ref VertexColors initialColor) + { + if (SulphuricWaterSafeZoneSystem.NearbySafeTiles.Count >= 1) + { + Color cleanWaterColor = new(10, 62, 193); + Point closestSafeZone = SulphuricWaterSafeZoneSystem.NearbySafeTiles.Keys.OrderBy(t => t.ToVector2().DistanceSQ(new(x, y))).First(); + List points = new() + { + new Vector2(x - 0.5f, y - 0.5f), + new Vector2(x + 0.5f, y - 0.5f), + new Vector2(x - 0.5f, y + 0.5f), + new Vector2(x + 0.5f, y + 0.5f), + }; + + for (int i = 0; i < 4; i++) + { + float distanceToClosest = points[i].Distance(closestSafeZone.ToVector2()); + float acidicWaterInterpolant = Utils.GetLerpValue(12f, 20.5f, distanceToClosest + (1f - SulphuricWaterSafeZoneSystem.NearbySafeTiles[closestSafeZone]) * 21f, true); + if (i == 0) + initialColor.TopLeftColor = Color.Lerp(initialColor.TopLeftColor, cleanWaterColor, 1f - acidicWaterInterpolant); + if (i == 1) + initialColor.TopRightColor = Color.Lerp(initialColor.TopRightColor, cleanWaterColor, 1f - acidicWaterInterpolant); + if (i == 2) + initialColor.BottomLeftColor = Color.Lerp(initialColor.BottomLeftColor, cleanWaterColor, 1f - acidicWaterInterpolant); + if (i == 3) + initialColor.BottomRightColor = Color.Lerp(initialColor.BottomRightColor, cleanWaterColor, 1f - acidicWaterInterpolant); + } + } + + initialColor.TopLeftColor *= 0.4f; + initialColor.TopRightColor *= 0.4f; + initialColor.BottomLeftColor *= 0.4f; + initialColor.BottomRightColor *= 0.4f; + } + public static void DumpToLog(ILContext il) => CalamityMod.Instance.Logger.Debug(il.ToString()); public static void LogFailure(string name, string reason) => CalamityMod.Instance.Logger.Warn($"IL edit \"{name}\" failed! {reason}"); } diff --git a/ILEditing/MechanicILChanges.cs b/ILEditing/MechanicILChanges.cs index bcb08382d1..da0092b722 100644 --- a/ILEditing/MechanicILChanges.cs +++ b/ILEditing/MechanicILChanges.cs @@ -748,7 +748,7 @@ namespace CalamityMod.ILEditing } } - private static void DrawCustomLava2(ILContext il) + private static void ChangeWaterQuadColors(ILContext il) { ILCursor cursor = new ILCursor(il); @@ -789,39 +789,7 @@ namespace CalamityMod.ILEditing initialColor.BottomLeftColor = SelectLavaColor(initialTexture, initialColor.BottomLeftColor, liquidType == 1); initialColor.BottomRightColor = SelectLavaColor(initialTexture, initialColor.BottomRightColor, liquidType == 1); if (liquidType == ModContent.Find("CalamityMod/SulphuricWater").Slot) - { - if (SulphuricWaterSafeZoneSystem.NearbySafeTiles.Count >= 1) - { - Color cleanWaterColor = new(10, 62, 193); - Point closestSafeZone = SulphuricWaterSafeZoneSystem.NearbySafeTiles.Keys.OrderBy(t => t.ToVector2().DistanceSQ(new(x, y))).First(); - List points = new() - { - new Vector2(x - 0.5f, y - 0.5f), - new Vector2(x + 0.5f, y - 0.5f), - new Vector2(x - 0.5f, y + 0.5f), - new Vector2(x + 0.5f, y + 0.5f), - }; - - for (int i = 0; i < 4; i++) - { - float distanceToClosest = points[i].Distance(closestSafeZone.ToVector2()); - float acidicWaterInterpolant = Utils.GetLerpValue(12f, 20.5f, distanceToClosest + (1f - SulphuricWaterSafeZoneSystem.NearbySafeTiles[closestSafeZone]) * 21f, true); - if (i == 0) - initialColor.TopLeftColor = Color.Lerp(initialColor.TopLeftColor, cleanWaterColor, 1f - acidicWaterInterpolant); - if (i == 1) - initialColor.TopRightColor = Color.Lerp(initialColor.TopRightColor, cleanWaterColor, 1f - acidicWaterInterpolant); - if (i == 2) - initialColor.BottomLeftColor = Color.Lerp(initialColor.BottomLeftColor, cleanWaterColor, 1f - acidicWaterInterpolant); - if (i == 3) - initialColor.BottomRightColor = Color.Lerp(initialColor.BottomRightColor, cleanWaterColor, 1f - acidicWaterInterpolant); - } - } - - initialColor.TopLeftColor *= 0.4f; - initialColor.TopRightColor *= 0.4f; - initialColor.BottomLeftColor *= 0.4f; - initialColor.BottomRightColor *= 0.4f; - } + SelectSulphuricWaterColor(x, y, ref initialColor); return initialColor; });