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 180882767c..0000000000 Binary files a/Tiles/Abyss/SulphurousSandNoWater.png and /dev/null differ 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);