diff --git a/BiomeManagers/AbovegroundAstralSnowBiome.cs b/BiomeManagers/AbovegroundAstralSnowBiome.cs index 7fc5fbb12c..ec777420f3 100644 --- a/BiomeManagers/AbovegroundAstralSnowBiome.cs +++ b/BiomeManagers/AbovegroundAstralSnowBiome.cs @@ -21,7 +21,7 @@ namespace CalamityMod.BiomeManagers public override bool IsBiomeActive(Player player) { - return !player.ZoneDungeon && BiomeTileCounterSystem.AstralTiles > 950 && !player.ZoneDesert && player.ZoneSnow; + return !player.ZoneDungeon && BiomeTileCounterSystem.AstralTiles > 950 && player.ZoneSnow; } public override void SpecialVisuals(Player player, bool isActive) diff --git a/BiomeManagers/BrimstoneCragsBiome.cs b/BiomeManagers/BrimstoneCragsBiome.cs index 69a189028b..1c84e5ce42 100644 --- a/BiomeManagers/BrimstoneCragsBiome.cs +++ b/BiomeManagers/BrimstoneCragsBiome.cs @@ -20,7 +20,7 @@ namespace CalamityMod.BiomeManagers public override bool IsBiomeActive(Player player) { - return BiomeTileCounterSystem.BrimstoneCragTiles > 100; + return BiomeTileCounterSystem.BrimstoneCragTiles > 100 && player.ZoneUnderworldHeight; } } } diff --git a/Buffs/Pets/SeaSlugBuff.cs b/Buffs/Pets/SeaSlugBuff.cs new file mode 100644 index 0000000000..ba44988cf8 --- /dev/null +++ b/Buffs/Pets/SeaSlugBuff.cs @@ -0,0 +1,29 @@ +using CalamityMod.Projectiles.Pets; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Pets +{ + public class SeaSlugBuff : ModBuff + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Sea Slug"); + Description.SetDefault("The bioluminscent sea slug is following you"); + Main.buffNoTimeDisplay[Type] = true; + Main.vanityPet[Type] = true; + } + + public override void Update(Player player, ref int buffIndex) + { + player.buffTime[buffIndex] = 18000; + player.Calamity().seaSlugPet = true; + bool petProjectileNotSpawned = player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0; + if (petProjectileNotSpawned && player.whoAmI == Main.myPlayer) + { + Projectile.NewProjectile(player.GetSource_Buff(buffIndex), player.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, player.whoAmI, 0f, 0f); + } + } + } +} diff --git a/Buffs/Pets/SeaSlugBuff.png b/Buffs/Pets/SeaSlugBuff.png new file mode 100644 index 0000000000..3500e7f445 Binary files /dev/null and b/Buffs/Pets/SeaSlugBuff.png differ diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index d7c333a390..a549e70c2d 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -326,6 +326,7 @@ namespace CalamityMod.CalPlayer public bool bendyPet = false; public bool littleLightPet = false; public bool pineapplePet = false; + public bool seaSlugPet = false; #endregion #region Rage @@ -1477,6 +1478,7 @@ namespace CalamityMod.CalPlayer bendyPet = false; littleLightPet = false; pineapplePet = false; + seaSlugPet = false; onyxExcavator = false; rimehound = false; diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index fa82dfc892..ec7059200b 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -2030,8 +2030,6 @@ namespace CalamityMod.CalPlayer // New textures if (Main.netMode != NetmodeID.Server && Player.whoAmI == Main.myPlayer) { - Asset sulphSeaRain = ModContent.Request("CalamityMod/ExtraTextures/VanillaReplacements/RainSulphSea"); - Asset rainOriginal = ModContent.Request("CalamityMod/ExtraTextures/VanillaReplacements/RainOriginal"); Asset cometShard = ModContent.Request("CalamityMod/UI/HealthManaTextures/ManaCometShard"); Asset etherealCore = ModContent.Request("CalamityMod/UI/HealthManaTextures/ManaEtherealCore"); Asset phantomHeart = ModContent.Request("CalamityMod/UI/HealthManaTextures/ManaPhantomHeart"); @@ -2059,13 +2057,6 @@ namespace CalamityMod.CalPlayer break; } - if (Main.bloodMoon) - TextureAssets.Rain = rainOriginal; - else if (Main.raining && ZoneSulphur) - TextureAssets.Rain = sulphSeaRain; - else - TextureAssets.Rain = rainOriginal; - if (auricSet) TextureAssets.FlyingCarpet = carpetAuric; else diff --git a/CalamityMod.cs b/CalamityMod.cs index 2aa086b793..a90926c3fd 100644 --- a/CalamityMod.cs +++ b/CalamityMod.cs @@ -4,6 +4,8 @@ using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; +using System.Linq; +using CalamityMod.Systems; using CalamityMod.Balancing; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; @@ -72,6 +74,7 @@ using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; using Terraria.ModLoader.Config; +using Terraria.DataStructures; [assembly: InternalsVisibleTo("CalTestHelpers")] [assembly: InternalsVisibleTo("InfernumMode")] @@ -144,6 +147,9 @@ namespace CalamityMod internal Mod varia = null; internal Mod wikithis = null; + //hell background + //private List loadCache; + #region Load public override void Load() { @@ -239,6 +245,29 @@ namespace CalamityMod BalancingChangesManager.Load(); BaseIdleHoldoutProjectile.LoadAll(); PlayerDashManager.Load(); + + /* + //keep this disabled for now, hell bg system isnt used and there is a better way to load it + //hell background loading + HellBGManager.Load(); + + //load stuff for hell background + loadCache = new List(); + + foreach (Type type in Code.GetTypes()) + { + if (!type.IsAbstract && type.GetInterfaces().Contains(typeof(HellBGLoad))) + { + var instance = Activator.CreateInstance(type); + loadCache.Add(instance as HellBGLoad); + } + } + + for (int k = 0; k < loadCache.Count; k++) + { + loadCache[k].Load(); + } + */ } private void LoadClient() @@ -279,6 +308,9 @@ namespace CalamityMod Filters.Scene["CalamityMod:MonolithAccursed"] = new Filter(new MonolithScreenShaderData("FilterMiniTower").UseColor(1.1f, 0.3f, 0.3f).UseOpacity(0.65f), EffectPriority.VeryHigh); SkyManager.Instance["CalamityMod:MonolithAccursed"] = new MonolithSky(); + Filters.Scene["CalamityMod:BrimstoneCrag"] = new Filter(new MonolithScreenShaderData("FilterMiniTower").UseColor(0f, 0f, 0f).UseOpacity(0f), EffectPriority.VeryHigh); + SkyManager.Instance["CalamityMod:BrimstoneCrag"] = new BrimstoneCragSky(); + SkyManager.Instance["CalamityMod:Astral"] = new AstralSky(); SkyManager.Instance["CalamityMod:Cryogen"] = new CryogenSky(); SkyManager.Instance["CalamityMod:StormWeaverFlash"] = new StormWeaverFlashSky(); @@ -425,6 +457,21 @@ namespace CalamityMod manaOriginal = null; carpetOriginal = null; + /* + //unload hell background stuff + HellBGManager.Unload(); + + if (loadCache != null) + { + foreach (var loadable in loadCache) + { + loadable.Unload(); + } + } + + loadCache = null; + */ + ILChanges.Unload(); Instance = null; base.Unload(); diff --git a/Dusts/CinderBlossomDust.cs b/Dusts/CinderBlossomDust.cs new file mode 100644 index 0000000000..2b23116d6d --- /dev/null +++ b/Dusts/CinderBlossomDust.cs @@ -0,0 +1,46 @@ +using Terraria; +using Terraria.ModLoader; +using Microsoft.Xna.Framework; + +namespace CalamityMod.Dusts +{ + public class CinderBlossomDust : ModDust + { + public override void OnSpawn(Dust dust) + { + dust.velocity *= 0.05f; + dust.velocity.Y *= 0.5f; + dust.noGravity = true; + dust.noLight = true; + dust.alpha = 0; + dust.fadeIn = 12f; + dust.scale *= Main.rand.NextFloat(0.75f, 1f); + } + + public override bool Update(Dust dust) + { + float strength = dust.scale * 1.4f; + Lighting.AddLight(dust.position, 0.025f * strength, 0.1f * strength, 0.1f * strength); + + if (Main.rand.Next(20) == 0) + { + dust.alpha += 5; + } + + if (Main.rand.Next(12) == 0) + { + dust.velocity.X += Main.rand.NextFloat(-0.1f, 0.1f); + dust.velocity.Y += Main.rand.NextFloat(0.02f, 0.08f); + } + + dust.position -= dust.velocity; + + if (dust.alpha > 255) + { + dust.active = false; + } + + return false; + } + } +} \ No newline at end of file diff --git a/Dusts/CinderBlossomDust.png b/Dusts/CinderBlossomDust.png new file mode 100644 index 0000000000..e15ea39c59 Binary files /dev/null and b/Dusts/CinderBlossomDust.png differ diff --git a/ExtraTextures/VanillaReplacements/RainAstral.png b/ExtraTextures/VanillaReplacements/RainAstral.png new file mode 100644 index 0000000000..e178d0380e Binary files /dev/null and b/ExtraTextures/VanillaReplacements/RainAstral.png differ diff --git a/ExtraTextures/VanillaReplacements/RainOriginal.png b/ExtraTextures/VanillaReplacements/RainOriginal.png deleted file mode 100644 index fcf8f439da..0000000000 Binary files a/ExtraTextures/VanillaReplacements/RainOriginal.png and /dev/null differ diff --git a/ILEditing/MechanicILChanges.cs b/ILEditing/MechanicILChanges.cs index dd5521da6e..38dd4dd9cc 100644 --- a/ILEditing/MechanicILChanges.cs +++ b/ILEditing/MechanicILChanges.cs @@ -837,6 +837,12 @@ namespace CalamityMod.ILEditing if (liquidType == ModContent.Find("CalamityMod/SulphuricWater").Slot) SelectSulphuricWaterColor(x, y, ref initialColor); + if (liquidType == ModContent.Find("CalamityMod/SunkenSeaWater").Slot) + SelectSulphuricWaterColor(x, y, ref initialColor); + + if (liquidType == ModContent.Find("CalamityMod/AbyssWater").Slot) + SelectSulphuricWaterColor(x, y, ref initialColor); + // Apply any extra color conditions. initialColor = ExtraColorChangeConditions?.Invoke(initialColor, liquidType, new(x, y)) ?? initialColor; @@ -961,11 +967,13 @@ namespace CalamityMod.ILEditing 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) + if (tile.LiquidAmount <= 0 || tile.HasTile || Main.waterStyle != ModContent.Find("CalamityMod/SulphuricWater").Slot && + Main.waterStyle != ModContent.Find("CalamityMod/SunkenSeaWater").Slot) return; Tile above = CalamityUtils.ParanoidTileRetrieval(x, y - 1); - if (!Main.gamePaused && !above.HasTile && above.LiquidAmount <= 0 && Main.rand.NextBool(9)) + if (!Main.gamePaused && !above.HasTile && above.LiquidAmount <= 0 && Main.rand.NextBool(9) && + Main.waterStyle == ModContent.Find("CalamityMod/SulphuricWater").Slot) { 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); diff --git a/Items/Armor/Fearmonger/FearmongerGreathelm.cs b/Items/Armor/Fearmonger/FearmongerGreathelm.cs index 3bddaafe79..84214f25b4 100644 --- a/Items/Armor/Fearmonger/FearmongerGreathelm.cs +++ b/Items/Armor/Fearmonger/FearmongerGreathelm.cs @@ -49,12 +49,12 @@ namespace CalamityMod.Items.Armor.Fearmonger public override void UpdateArmorSet(Player player) { - player.setBonus = @"20% increased minion damage and +2 max minions - The minion damage nerf while wielding weaponry is reduced - Immunity to all forms of frost and flame - All minion attacks grant colossal life regeneration - 15% increased damage reduction during the Pumpkin and Frost Moons - This extra damage reduction ignores the soft cap"; + player.setBonus = "20% increased minion damage and +2 max minions\n" + + "The minion damage nerf while wielding weaponry is reduced\n" + + "Immunity to all forms of frost and flame\n" + + "All minion attacks grant colossal life regeneration\n" + + "15% increased damage reduction during the Pumpkin and Frost Moons\n" + + "This extra damage reduction ignores the soft cap"; // This bool encompasses cross-class nerf immunity, colossal life regen on minion attack, and the holiday moon DR // TODO -- Fearmonger life regen from minion attacks needs some sort of cool visual effect diff --git a/Items/Armor/GodSlayer/GodSlayerHeadMelee.cs b/Items/Armor/GodSlayer/GodSlayerHeadMelee.cs index 03c0f10965..0eb6229f42 100644 --- a/Items/Armor/GodSlayer/GodSlayerHeadMelee.cs +++ b/Items/Armor/GodSlayer/GodSlayerHeadMelee.cs @@ -45,14 +45,14 @@ namespace CalamityMod.Items.Armor.GodSlayer modPlayer.godSlayerDamage = true; var hotkey = CalamityKeybinds.GodSlayerDashHotKey.TooltipHotkeyString(); player.setBonus = "Allows you to dash for an immense distance in 8 directions\n" + - "Press " + hotkey + " while holding down the movement keys in the direction you want to dash\n" + - "Enemies you dash through take massive damage\n" + - "During the dash you are immune to most debuffs\n" + - "The dash has a " + GodslayerArmorDash.GodslayerCooldown + " second cooldown\n" + - "Enemies are more likely to target you\n" + - "Taking over 80 damage in one hit will cause you to release a swarm of high-damage god killer darts\n" + - "Enemies take a lot of damage when they hit you\n" + - "An attack that would deal 80 damage or less will have its damage reduced to 1"; + "Press " + hotkey + " while holding down the movement keys in the direction you want to dash\n" + + "Enemies you dash through take massive damage\n" + + "During the dash you are immune to most debuffs\n" + + "The dash has a " + GodslayerArmorDash.GodslayerCooldown + " second cooldown\n" + + "Enemies are more likely to target you\n" + + "Taking over 80 damage in one hit will cause you to release a swarm of high-damage god killer darts\n" + + "Enemies take a lot of damage when they hit you\n" + + "An attack that would deal 80 damage or less will have its damage reduced to 1"; player.thorns += 2.5f; player.aggro += 1000; diff --git a/Items/Pets/SeaSlugCerata.cs b/Items/Pets/SeaSlugCerata.cs new file mode 100644 index 0000000000..5933d6c8aa --- /dev/null +++ b/Items/Pets/SeaSlugCerata.cs @@ -0,0 +1,48 @@ +using CalamityMod.Buffs.Pets; +using CalamityMod.Projectiles.Pets; +using CalamityMod.Rarities; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Pets +{ + public class SeaSlugCerata : ModItem + { + public override void SetStaticDefaults() + { + SacrificeTotal = 1; + DisplayName.SetDefault("Sea Slug Cerata"); + Tooltip.SetDefault("Summons a bioluminescent sea slug to follow you" + + "\nThe sea slug will change colors in different environments"); + } + + public override void SetDefaults() + { + Item.damage = 0; + Item.useStyle = ItemUseStyleID.Swing; + Item.useAnimation = 20; + Item.useTime = 20; + Item.noMelee = true; + Item.width = 26; + Item.height = 28; + + Item.value = Item.sellPrice(gold: 20); + Item.rare = ModContent.RarityType(); + Item.Calamity().devItem = true; + + Item.shoot = ModContent.ProjectileType(); + Item.buffType = ModContent.BuffType(); + Item.UseSound = SoundID.Item2; + } + + public override void UseStyle(Player player, Rectangle heldItemFrame) + { + if (player.whoAmI == Main.myPlayer && player.itemTime == 0) + { + player.AddBuff(Item.buffType, 15, true); + } + } + } +} diff --git a/Items/Pets/SeaSlugCerata.png b/Items/Pets/SeaSlugCerata.png new file mode 100644 index 0000000000..12adeb6ada Binary files /dev/null and b/Items/Pets/SeaSlugCerata.png differ diff --git a/Items/Placeables/BrimstoneSlab.cs b/Items/Placeables/BrimstoneSlab.cs index aa4e9ddb99..3c6aec3eda 100644 --- a/Items/Placeables/BrimstoneSlab.cs +++ b/Items/Placeables/BrimstoneSlab.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Placeables.Walls; using Terraria.ID; using Terraria.ModLoader; + namespace CalamityMod.Items.Placeables { public class BrimstoneSlab : ModItem diff --git a/Items/Placeables/CinderBlossomSeeds.cs b/Items/Placeables/CinderBlossomSeeds.cs new file mode 100644 index 0000000000..4762bcdce0 --- /dev/null +++ b/Items/Placeables/CinderBlossomSeeds.cs @@ -0,0 +1,46 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.Audio; + +namespace CalamityMod.Items.Placeables +{ + public class CinderBlossomSeeds : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Cinder Blossom Seeds"); + Tooltip.SetDefault("Places cinder blossom grass on scorched remains"); + } + + public override void SetDefaults() + { + Item.useTurn = true; + Item.autoReuse = true; + Item.consumable = true; + Item.width = 16; + Item.height = 16; + Item.useTime = 15; + Item.useAnimation = 15; + Item.useStyle = ItemUseStyleID.Swing; + Item.maxStack = 999; + } + + public override bool? UseItem(Player player) + { + Tile tile = Framing.GetTileSafely(Player.tileTargetX, Player.tileTargetY); + Tile tileAbove = Framing.GetTileSafely(Player.tileTargetX, Player.tileTargetY - 1); + + if (tile.HasTile && !tileAbove.HasTile && tileAbove.LiquidAmount == 0 && tile.TileType == ModContent.TileType() && player.IsInTileInteractionRange(Player.tileTargetX, Player.tileTargetY)) + { + Main.tile[Player.tileTargetX, Player.tileTargetY].TileType = (ushort)ModContent.TileType(); + + SoundEngine.PlaySound(SoundID.Dig, player.Center); + + return true; + } + + return false; + } + } +} \ No newline at end of file diff --git a/Items/Placeables/CinderBlossomSeeds.png b/Items/Placeables/CinderBlossomSeeds.png new file mode 100644 index 0000000000..2062ad9a82 Binary files /dev/null and b/Items/Placeables/CinderBlossomSeeds.png differ diff --git a/Items/Placeables/ScorchedBone.cs b/Items/Placeables/ScorchedBone.cs new file mode 100644 index 0000000000..298787cbd8 --- /dev/null +++ b/Items/Placeables/ScorchedBone.cs @@ -0,0 +1,49 @@ +using CalamityMod.Items.Placeables; +using CalamityMod.Items.Placeables.Walls; +using CalamityMod.Tiles.Crags; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables +{ + public class ScorchedBone : ModItem + { + public override void SetStaticDefaults() + { + SacrificeTotal = 100; + DisplayName.SetDefault("Scorched Bone"); + } + + public override void SetDefaults() + { + Item.width = 26; + Item.height = 22; + Item.maxStack = 999; + Item.useTurn = true; + Item.autoReuse = true; + Item.useAnimation = 15; + Item.useTime = 10; + Item.useStyle = ItemUseStyleID.Swing; + Item.consumable = true; + Item.rare = ItemRarityID.Orange; + Item.createTile = ModContent.TileType(); + } + + public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) + { + itemGroup = ContentSamples.CreativeHelper.ItemGroup.Wood; + } + + //i assume this is supposed to be for when the platforms and walls for this tile are finished + /*public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(2). + Register(); + + CreateRecipe(1). + AddIngredient(ModContent.ItemType(), 4). + AddTile(TileID.WorkBenches).Register(); + }*/ + } +} diff --git a/Items/Placeables/ScorchedBone.png b/Items/Placeables/ScorchedBone.png new file mode 100644 index 0000000000..267520bcd5 Binary files /dev/null and b/Items/Placeables/ScorchedBone.png differ diff --git a/Items/Placeables/ScorchedRemains.cs b/Items/Placeables/ScorchedRemains.cs new file mode 100644 index 0000000000..695c409951 --- /dev/null +++ b/Items/Placeables/ScorchedRemains.cs @@ -0,0 +1,31 @@ +using CalamityMod.Items.Placeables.Walls; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables +{ + public class ScorchedRemains : ModItem + { + public override void SetStaticDefaults() + { + SacrificeTotal = 100; + DisplayName.SetDefault("Scorched Remains"); + } + + public override void SetDefaults() + { + Item.createTile = ModContent.TileType(); + Item.useStyle = ItemUseStyleID.Swing; + Item.useTurn = true; + Item.useAnimation = 15; + Item.useTime = 10; + Item.autoReuse = true; + Item.consumable = true; + Item.width = 13; + Item.height = 10; + Item.maxStack = 999; + Item.value = 1000; + Item.rare = ItemRarityID.Orange; + } + } +} diff --git a/Items/Placeables/ScorchedRemains.png b/Items/Placeables/ScorchedRemains.png new file mode 100644 index 0000000000..09c4f40f34 Binary files /dev/null and b/Items/Placeables/ScorchedRemains.png differ diff --git a/Localization/CalamityLocalization.cs b/Localization/CalamityLocalization.cs index 440c385d7e..93dcaafc9b 100644 --- a/Localization/CalamityLocalization.cs +++ b/Localization/CalamityLocalization.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Localization { _localizations = new[] { - new [] { "SkyOreText", "The ground is glittering with cyan light." }, + new [] { "SkyOreText", "The sky is glittering with cyan light." }, new [] { "IceOreText", "The ice caves are crackling with frigid energy." }, new [] { "PlantOreText", "Energized plant matter has formed in the underground." }, new [] { "TreeOreText", "Fossilized tree bark is bursting through the jungle's mud." }, diff --git a/NPCs/CalamityAI.cs b/NPCs/CalamityAI.cs index e427e8ceed..d8d7f8a190 100644 --- a/NPCs/CalamityAI.cs +++ b/NPCs/CalamityAI.cs @@ -2939,8 +2939,8 @@ namespace CalamityMod.NPCs if (npc.velocity.Y == 0f) { // Play stomp sound. Gotta specify the filepath to avoid confusion between the namespace and npc - SoundStyle soundToPlay = Main.getGoodWorld ? NPCs.ExoMechs.Ares.AresGaussNuke.NukeExplosionSound : NPCs.AstrumAureus.AstrumAureus.StompSound; // move to zenith seed later - SoundEngine.PlaySound(soundToPlay, npc.position); + // move to zenith seed later + SoundEngine.PlaySound(Main.getGoodWorld ? NPCs.ExoMechs.Ares.AresGaussNuke.NukeExplosionSound : NPCs.AstrumAureus.AstrumAureus.StompSound, npc.position); if (Main.getGoodWorld) // move to zenith seed later { @@ -7475,7 +7475,24 @@ namespace CalamityMod.NPCs position.X += npc.velocity.X; int x = (int)((position.X + (float)(npc.width / 2) + (float)((npc.width / 2 + 1) * num10)) / 16f); int y = (int)((position.Y + (float)npc.height - 1f) / 16f); - if ((float)(x * 16) < position.X + (float)npc.width && (float)(x * 16 + 16) > position.X && ((Main.tile[x, y].HasUnactuatedTile && !Main.tile[x, y].TopSlope && !Main.tile[x, y - 1].TopSlope && Main.tileSolid[(int)Main.tile[x, y].TileType] && !Main.tileSolidTop[(int)Main.tile[x, y].TileType]) || (Main.tile[x, y - 1].IsHalfBlock && Main.tile[x, y - 1].HasUnactuatedTile)) && (!Main.tile[x, y - 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 1].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 1].TileType] || (Main.tile[x, y - 1].IsHalfBlock && (!Main.tile[x, y - 4].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 4].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 4].TileType]))) && (!Main.tile[x, y - 2].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 2].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 2].TileType]) && (!Main.tile[x, y - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 3].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 3].TileType]) && (!Main.tile[x - num10, y - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x - num10, y - 3].TileType])) + + // 21JAN2023: Ozzatron -- this is probably the single most unmaintainable if statement I've ever seen + // I have broken all the individual statements out even though I do not fully understand the code. + Tile t_xy = CalamityUtils.ParanoidTileRetrieval(x, y); + Tile t_xy1 = CalamityUtils.ParanoidTileRetrieval(x, y - 1); + Tile t_xy2 = CalamityUtils.ParanoidTileRetrieval(x, y - 2); + Tile t_xy3 = CalamityUtils.ParanoidTileRetrieval(x, y - 3); + Tile t_xOffY3 = CalamityUtils.ParanoidTileRetrieval(x - num10, y - 3); // 3 down, offset 1 in the direction of the NPC's movement + Tile t_xy4 = CalamityUtils.ParanoidTileRetrieval(x, y - 4); + bool positionCheck = (float)(x * 16) < position.X + (float)npc.width && (float)(x * 16 + 16) > position.X; + bool tileSolidityCheck1 = t_xy.HasUnactuatedTile && !t_xy.TopSlope && !t_xy1.TopSlope && Main.tileSolid[t_xy.TileType] && !Main.tileSolidTop[t_xy.TileType]; + bool oneBelowIsSolidHalf = t_xy1.IsHalfBlock && t_xy1.HasUnactuatedTile; + bool canFallThrough = !t_xy1.HasUnactuatedTile || !Main.tileSolid[t_xy1.TileType] || Main.tileSolidTop[t_xy1.TileType] || (t_xy1.IsHalfBlock && (!t_xy4.HasUnactuatedTile || !Main.tileSolid[t_xy4.TileType] || Main.tileSolidTop[t_xy4.TileType])); + bool twoDownIsNonSolid = !t_xy2.HasUnactuatedTile || !Main.tileSolid[t_xy2.TileType] || Main.tileSolidTop[t_xy2.TileType]; + bool threeDownIsNonSolid = !t_xy3.HasUnactuatedTile || !Main.tileSolid[t_xy3.TileType] || Main.tileSolidTop[t_xy3.TileType]; + // Notice it doesn't check for platforms in ther offset position. This is why walking AIs twirl on 1-wide platforms in hellevators. They have to turn around before this check succeeds. + bool threeDownOffsetIsNonSolid = !t_xOffY3.HasUnactuatedTile || !Main.tileSolid[t_xOffY3.TileType]; + if (positionCheck && (tileSolidityCheck1 || oneBelowIsSolidHalf) && canFallThrough && twoDownIsNonSolid && threeDownIsNonSolid && threeDownOffsetIsNonSolid) { float num13 = (float)(y * 16); if (Main.tile[x, y].IsHalfBlock) diff --git a/NPCs/Crags/DespairStone.cs b/NPCs/Crags/DespairStone.cs index e783f44ea2..7afcbc0c5a 100644 --- a/NPCs/Crags/DespairStone.cs +++ b/NPCs/Crags/DespairStone.cs @@ -1,18 +1,30 @@ using CalamityMod.BiomeManagers; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; +using CalamityMod.Particles; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Banners; using CalamityMod.World; +using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; using Terraria.GameContent.Bestiary; using Terraria.GameContent.ItemDropRules; using Terraria.ID; using Terraria.ModLoader; +using ReLogic.Utilities; +using System; + namespace CalamityMod.NPCs.Crags { public class DespairStone : ModNPC { + public SlotId ChainsawSoundSlot; + + public static readonly SoundStyle ChainsawStartSound = new("CalamityMod/Sounds/Custom/ChainsawStart") { Volume = 0.15f }; + + public static readonly SoundStyle ChainsawEndSound = new("CalamityMod/Sounds/Custom/ChainsawEnd") { Volume = 0.15f }; + public override void SetStaticDefaults() { DisplayName.SetDefault("Despair Stone"); @@ -59,7 +71,84 @@ namespace CalamityMod.NPCs.Crags public override void AI() { - CalamityAI.UnicornAI(NPC, Mod, true, CalamityWorld.death ? 8f : CalamityWorld.revenge ? 6f : 4f, 5f, 0.2f); + float buzzsawStartTime = 480f; + NPC.ai[1]++; + if (NPC.ai[2] != 0f) BuzzsawMode(); + if (NPC.ai[1] > buzzsawStartTime) //time needed for buzzsaw mode to be able to be started + { + if (NPC.ai[2] == 0f) + { + NPC.ai[1] = buzzsawStartTime + 1f; //freeze buzzsaw timer until buzzsaw mode is initiated. + NPC.rotation += NPC.velocity.X * 0.01f; + NPC.spriteDirection = -NPC.direction; + if (NPC.velocity.Y == 0f || NPC.lavaWet) BuzzsawMode(); //initiate Buzzsaw mode once the npc hits the ground + } + } + else //run regular ai if buzzsaw mode isn't available + { + NPC.ai[2] = 0f; + CalamityAI.UnicornAI(NPC, Mod, true, CalamityWorld.death ? 8f : CalamityWorld.revenge ? 6f : 4f, 5f, 0.2f); + } + if (NPC.lavaWet) //float on lava + NPC.velocity.Y += -0.8f; + } + + public void BuzzsawMode() + { + float distance; + float speedCap = 10f; + //Choose Direction + if (NPC.ai[2] == 0f) + { + ChainsawSoundSlot = SoundEngine.PlaySound(ChainsawStartSound, NPC.Center); + if (NPC.velocity.X < 0f) //left + { + NPC.ai[2] = -1f; + } + else if (NPC.velocity.X > 0f) //right + { + NPC.ai[2] = 1f; + } + else //if npc is stationary when selecting direction, go towards target. + { + distance = Main.player[NPC.target].Center.X - NPC.Center.X; + if (distance != 0f) + { + NPC.ai[2] = distance / Math.Abs(distance); + } + else NPC.ai[2] = 1f; + } + } + if (SoundEngine.TryGetActiveSound(ChainsawSoundSlot, out var chainsawSound) && chainsawSound.IsPlaying) + chainsawSound.Position = NPC.Center; + if (NPC.velocity.X == 0f) //go up if against wall + { + if (NPC.velocity.Y > -speedCap) //Accelerate to top speed + NPC.velocity.Y += -1.66f; + if (NPC.velocity.Y < -speedCap) //Cap top speed + NPC.velocity.Y = -speedCap; + } + + if (NPC.velocity.X == 0f || NPC.velocity.Y == 0f) //check if on solid ground + SpawnSparks(); + else if (Main.player[NPC.target].Center.Y - NPC.Center.Y < 0f && NPC.velocity.Y < 0f && !NPC.lavaWet) //if not on solid ground and target player is above the NPC, reduce gravity + NPC.velocity.Y += -0.03f; + + if (Math.Abs(NPC.velocity.X) < speedCap) //Accelerate to top speed + NPC.velocity.X += 1.66f * NPC.ai[2]; + if (Math.Abs(NPC.velocity.X) > speedCap) //Cap top speed + NPC.velocity.X = speedCap * NPC.ai[2]; + + NPC.rotation += speedCap * 0.03f * NPC.ai[2]; //rotate sprite in chosen direction + NPC.spriteDirection = -NPC.direction; + //stop buzzsaw mode + if (NPC.ai[1] > Main.rand.Next(670, 740)) + { + NPC.ai[1] = 0f; + NPC.velocity.Y += -3f; + chainsawSound?.Stop(); + SoundEngine.PlaySound(ChainsawEndSound, NPC.Center); + } } public override float SpawnChance(NPCSpawnInfo spawnInfo) @@ -100,5 +189,48 @@ namespace CalamityMod.NPCs.Crags } } } + public override bool PreKill() + { + if (SoundEngine.TryGetActiveSound(ChainsawSoundSlot, out var chainsawSound) && chainsawSound.IsPlaying) + chainsawSound?.Stop(); + return true; + } + public void SpawnSparks() + { + Vector2 particleSpawnDisplacement; + Vector2 splatterDirection; + if (NPC.velocity.X == 0f) + { + particleSpawnDisplacement = new Vector2 (24f * NPC.ai[2], 20f); + splatterDirection = new Vector2(0f, 1f); + } + else + { + particleSpawnDisplacement = new Vector2(20f * -NPC.ai[2], 24f); + splatterDirection = new Vector2(-NPC.ai[2], 0f); + } + + //Color impactColor = Color.Lerp(Color.Silver, Color.Gold, Main.rand.NextFloat(0.5f)); + Vector2 bloodSpawnPosition = NPC.Center + particleSpawnDisplacement; + + if (NPC.ai[1] % 4 == 0) + { + for (int i = 0; i < 2; i++) + { + int sparkLifetime = Main.rand.Next(14, 21); + float sparkScale = Main.rand.NextFloat(0.8f, 1f) + 1f * 0.05f; + Color sparkColor = Color.Lerp(Color.DarkGray, Color.DarkRed, Main.rand.NextFloat(0.7f)); + sparkColor = Color.Lerp(sparkColor, Color.OrangeRed, Main.rand.NextFloat()); + + if (Main.rand.NextBool(10)) + sparkScale *= 1.4f; + + Vector2 sparkVelocity = splatterDirection.RotatedByRandom(0.45f) * Main.rand.NextFloat(6f, 13f); + sparkVelocity.Y -= 6f; + SparkParticle spark = new SparkParticle(bloodSpawnPosition, sparkVelocity, true, sparkLifetime, sparkScale, sparkColor); + GeneralParticleHandler.SpawnParticle(spark); + } + } + } } } diff --git a/NPCs/Cryogen/Cryogen.cs b/NPCs/Cryogen/Cryogen.cs index 2741546587..31beaeaa4a 100644 --- a/NPCs/Cryogen/Cryogen.cs +++ b/NPCs/Cryogen/Cryogen.cs @@ -218,7 +218,6 @@ namespace CalamityMod.NPCs.Cryogen int iceRain = Main.getGoodWorld ? ModContent.ProjectileType() : ModContent.ProjectileType(); int dustType = Main.getGoodWorld ? 235 : 67; - SoundStyle frostSound = Main.getGoodWorld ? SoundID.Item20 : SoundID.Item28; NPC.HitSound = Main.getGoodWorld ? SoundID.NPCHit41 : HitSound; NPC.DeathSound = Main.getGoodWorld ? SoundID.NPCDeath14 : DeathSound; @@ -308,7 +307,7 @@ namespace CalamityMod.NPCs.Cryogen if (calamityGlobalNPC.newAI[3] >= (bossRush ? 660f : 900f)) { calamityGlobalNPC.newAI[3] = 0f; - SoundEngine.PlaySound(frostSound, NPC.Center); + SoundEngine.PlaySound(Main.getGoodWorld ? SoundID.NPCHit41 : HitSound, NPC.Center); int totalProjectiles = 3; float radians = MathHelper.TwoPi / totalProjectiles; int type = iceBomb; @@ -339,7 +338,7 @@ namespace CalamityMod.NPCs.Cryogen NPC.TargetClosest(); if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) { - SoundEngine.PlaySound(frostSound, NPC.Center); + SoundEngine.PlaySound(Main.getGoodWorld ? SoundID.NPCHit41 : HitSound, NPC.Center); int totalProjectiles = bossRush ? 24 : 16; float radians = MathHelper.TwoPi / totalProjectiles; int type = iceBlast; @@ -399,7 +398,7 @@ namespace CalamityMod.NPCs.Cryogen NPC.TargetClosest(); if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) { - SoundEngine.PlaySound(frostSound, NPC.Center); + SoundEngine.PlaySound(Main.getGoodWorld ? SoundID.NPCHit41 : HitSound, NPC.Center); int totalProjectiles = bossRush ? 18 : 12; float radians = MathHelper.TwoPi / totalProjectiles; int type = iceBlast; @@ -473,7 +472,7 @@ namespace CalamityMod.NPCs.Cryogen { if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) { - SoundEngine.PlaySound(frostSound, NPC.Center); + SoundEngine.PlaySound(Main.getGoodWorld ? SoundID.NPCHit41 : HitSound, NPC.Center); int type = iceRain; int damage = NPC.GetProjectileDamage(type); float maxVelocity = 9f + enrageScale; @@ -573,7 +572,7 @@ namespace CalamityMod.NPCs.Cryogen NPC.TargetClosest(); if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) { - SoundEngine.PlaySound(frostSound, NPC.Center); + SoundEngine.PlaySound(Main.getGoodWorld ? SoundID.NPCHit41 : HitSound, NPC.Center); int totalProjectiles = bossRush ? 18 : 12; float radians = MathHelper.TwoPi / totalProjectiles; int type = iceBlast; @@ -619,7 +618,7 @@ namespace CalamityMod.NPCs.Cryogen { if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) { - SoundEngine.PlaySound(frostSound, NPC.Center); + SoundEngine.PlaySound(Main.getGoodWorld ? SoundID.NPCHit41 : HitSound, NPC.Center); int type = iceRain; int damage = NPC.GetProjectileDamage(type); float maxVelocity = 9f + enrageScale; @@ -721,7 +720,7 @@ namespace CalamityMod.NPCs.Cryogen NPC.localAI[0] = 0f; if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) { - SoundEngine.PlaySound(frostSound, NPC.Center); + SoundEngine.PlaySound(Main.getGoodWorld ? SoundID.NPCHit41 : HitSound, NPC.Center); int totalProjectiles = bossRush ? 18 : 12; float radians = MathHelper.TwoPi / totalProjectiles; int type = iceBlast; @@ -831,7 +830,7 @@ namespace CalamityMod.NPCs.Cryogen if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) { NPC.localAI[0] = 0f; - SoundEngine.PlaySound(frostSound, NPC.Center); + SoundEngine.PlaySound(Main.getGoodWorld ? SoundID.NPCHit41 : HitSound, NPC.Center); int type = iceRain; int damage = NPC.GetProjectileDamage(type); float velocity = 9f + enrageScale; @@ -914,7 +913,7 @@ namespace CalamityMod.NPCs.Cryogen { if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) { - SoundEngine.PlaySound(frostSound, NPC.Center); + SoundEngine.PlaySound(Main.getGoodWorld ? SoundID.NPCHit41 : HitSound, NPC.Center); int type = iceBlast; int damage = NPC.GetProjectileDamage(type); float velocity = 1.5f + enrageScale * 0.5f; @@ -1028,7 +1027,7 @@ namespace CalamityMod.NPCs.Cryogen if (calamityGlobalNPC.newAI[3] >= (bossRush ? 50f : 75f)) { calamityGlobalNPC.newAI[3] = 0f; - SoundEngine.PlaySound(frostSound, NPC.Center); + SoundEngine.PlaySound(Main.getGoodWorld ? SoundID.NPCHit41 : HitSound, NPC.Center); int totalProjectiles = 2; float radians = MathHelper.TwoPi / totalProjectiles; int type = iceBomb; @@ -1108,8 +1107,7 @@ namespace CalamityMod.NPCs.Cryogen private void HandlePhaseTransition(int newPhase) { // Move to zenith seed later - SoundStyle sound = Main.getGoodWorld ? SoundID.NPCDeath14 : TransitionSound; - SoundEngine.PlaySound(sound, NPC.Center); + SoundEngine.PlaySound(Main.getGoodWorld ? SoundID.NPCDeath14 : TransitionSound, NPC.Center); if (Main.netMode != NetmodeID.Server && !Main.getGoodWorld) { int chipGoreAmount = newPhase >= 5 ? 3 : newPhase >= 3 ? 2 : 1; diff --git a/NPCs/HiveMind/HiveMind.cs b/NPCs/HiveMind/HiveMind.cs index c77e9a25b2..d0788d953c 100644 --- a/NPCs/HiveMind/HiveMind.cs +++ b/NPCs/HiveMind/HiveMind.cs @@ -1136,7 +1136,7 @@ namespace CalamityMod.NPCs.HiveMind { string key = "Mods.CalamityMod.SkyOreText"; Color messageColor = Color.Cyan; - CalamityUtils.SpawnOre(ModContent.TileType(), 12E-05, 0.5f, 0.7f, 3, 8); + CalamityUtils.SpawnAerialiteOre(); CalamityUtils.DisplayLocalizedText(key, messageColor); } diff --git a/NPCs/NormalNPCs/AeroSlime.cs b/NPCs/NormalNPCs/AeroSlime.cs index 03d98a3d83..e37a794a0b 100644 --- a/NPCs/NormalNPCs/AeroSlime.cs +++ b/NPCs/NormalNPCs/AeroSlime.cs @@ -51,12 +51,12 @@ namespace CalamityMod.NPCs.NormalNPCs public override float SpawnChance(NPCSpawnInfo spawnInfo) { - if (spawnInfo.PlayerSafe || (!DownedBossSystem.downedHiveMind && !DownedBossSystem.downedPerforator) || spawnInfo.Player.Calamity().ZoneAbyss || - spawnInfo.Player.Calamity().ZoneSunkenSea) + if (spawnInfo.PlayerSafe || (!DownedBossSystem.downedHiveMind && !DownedBossSystem.downedPerforator)) { return 0f; } - return SpawnCondition.Cavern.Chance * 0.05f; + + return SpawnCondition.Sky.Chance * 0.2f; } public override void HitEffect(int hitDirection, double damage) diff --git a/NPCs/Perforator/PerforatorHive.cs b/NPCs/Perforator/PerforatorHive.cs index 286684e5ce..7797c8a362 100644 --- a/NPCs/Perforator/PerforatorHive.cs +++ b/NPCs/Perforator/PerforatorHive.cs @@ -521,7 +521,7 @@ namespace CalamityMod.NPCs.Perforator { string key = "Mods.CalamityMod.SkyOreText"; Color messageColor = Color.Cyan; - CalamityUtils.SpawnOre(ModContent.TileType(), 12E-05, 0.5f, 0.7f, 3, 8); + CalamityUtils.SpawnAerialiteOre(); CalamityUtils.DisplayLocalizedText(key, messageColor); } diff --git a/NPCs/TownNPCs/SEAHOE.cs b/NPCs/TownNPCs/SEAHOE.cs index 2b6937a398..30bc043f91 100644 --- a/NPCs/TownNPCs/SEAHOE.cs +++ b/NPCs/TownNPCs/SEAHOE.cs @@ -5,6 +5,7 @@ using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Items.Weapons.Summon; +using CalamityMod.Items.Pets; using CalamityMod.Projectiles.Rogue; using System.Collections.Generic; using Terraria; @@ -375,6 +376,8 @@ namespace CalamityMod.NPCs.TownNPCs nextSlot++; shop.item[nextSlot].SetDefaults(ModContent.ItemType()); nextSlot++; + shop.item[nextSlot].SetDefaults(ModContent.ItemType()); + nextSlot++; if (CalamityConfig.Instance.PotionSelling) { shop.item[nextSlot].SetDefaults(ItemID.GillsPotion); diff --git a/Projectiles/Pets/SeaSlug.cs b/Projectiles/Pets/SeaSlug.cs new file mode 100644 index 0000000000..086a022db8 --- /dev/null +++ b/Projectiles/Pets/SeaSlug.cs @@ -0,0 +1,411 @@ +using CalamityMod.CalPlayer; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; +using System; + +namespace CalamityMod.Projectiles.Pets +{ + public class SeaSlug : ModProjectile + { + private int playerStill = 0; + private bool fly = false; + private int idleTimer = 0; + + private Form SeaSlugColor = Form.Normal; + private enum Form + { + Normal, Sulphur, Abyss, Sunken, Astral, Crags, Snow, Desert, Jungle + } + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Sea Slug"); + Main.projFrames[Projectile.type] = 6; + Main.projPet[Projectile.type] = true; + } + + public override void SetDefaults() + { + Projectile.netImportant = true; + Projectile.width = 54; + Projectile.height = 38; + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.timeLeft *= 5; + Projectile.tileCollide = true; + Projectile.ignoreWater = true; + } + + private void UpdateColor(Player player) + { + if (player.InSulphur()) + { + SeaSlugColor = Form.Sulphur; + } + else if (player.InAbyss()) + { + SeaSlugColor = Form.Abyss; + } + else if (player.InSunkenSea()) + { + SeaSlugColor = Form.Sunken; + } + else if (player.InAstral()) + { + SeaSlugColor = Form.Astral; + } + else if (player.InCalamity()) + { + SeaSlugColor = Form.Crags; + } + else if (player.ZoneSnow) + { + SeaSlugColor = Form.Snow; + } + else if (player.ZoneDesert) + { + SeaSlugColor = Form.Desert; + } + else if (player.ZoneJungle) + { + SeaSlugColor = Form.Jungle; + } + else + { + SeaSlugColor = Form.Normal; + } + } + + public override bool PreDraw(ref Color lightColor) + { + Draw(lightColor, ModContent.Request("CalamityMod/Projectiles/Pets/SeaSlug").Value); + return false; + } + + public override void PostDraw(Color lightColor) + { + DrawGlowmask(Color.White, ModContent.Request("CalamityMod/Projectiles/Pets/SeaSlug_Glow").Value, + ModContent.Request("CalamityMod/Projectiles/Pets/SeaSlugSulphur_Glow").Value, + ModContent.Request("CalamityMod/Projectiles/Pets/SeaSlugAbyss_Glow").Value, + ModContent.Request("CalamityMod/Projectiles/Pets/SeaSlugSunken_Glow").Value, + ModContent.Request("CalamityMod/Projectiles/Pets/SeaSlugAstral_Glow").Value, + ModContent.Request("CalamityMod/Projectiles/Pets/SeaSlugCrags_Glow").Value, + ModContent.Request("CalamityMod/Projectiles/Pets/SeaSlugSnow_Glow").Value, + ModContent.Request("CalamityMod/Projectiles/Pets/SeaSlugDesert_Glow").Value, + ModContent.Request("CalamityMod/Projectiles/Pets/SeaSlugJungle_Glow").Value); + } + + private void Draw(Color color, Texture2D texture) + { + int height = texture.Height / Main.projFrames[Projectile.type]; + int frameHeight = height * Projectile.frame; + SpriteEffects spriteEffects = SpriteEffects.None; + if (Projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; + + Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, frameHeight, texture.Width, height)), color, Projectile.rotation, new Vector2(texture.Width / 2f, height / 2f), Projectile.scale, spriteEffects, 0); + } + + private void DrawGlowmask(Color color, Texture2D normal, Texture2D sulphur, Texture2D abyss, Texture2D sunken, Texture2D astral, Texture2D crags, Texture2D snow, Texture2D desert, Texture2D jungle) + { + Texture2D texture = normal; + switch (SeaSlugColor) + { + case Form.Normal: + texture = normal; + break; + case Form.Sulphur: + texture = sulphur; + break; + case Form.Abyss: + texture = abyss; + break; + case Form.Sunken: + texture = sunken; + break; + case Form.Astral: + texture = astral; + break; + case Form.Crags: + texture = crags; + break; + case Form.Snow: + texture = snow; + break; + case Form.Desert: + texture = desert; + break; + case Form.Jungle: + texture = jungle; + break; + } + + int height = texture.Height / Main.projFrames[Projectile.type]; + int frameHeight = height * Projectile.frame; + SpriteEffects spriteEffects = SpriteEffects.None; + if (Projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; + + Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, frameHeight, texture.Width, height)), color, Projectile.rotation, new Vector2(texture.Width / 2f, height / 2f), Projectile.scale, spriteEffects, 0); + } + + public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough, ref Vector2 hitboxCenterFrac) + { + Player player = Main.player[Projectile.owner]; + Vector2 center2 = Projectile.Center; + Vector2 vector48 = player.Center - center2; + float playerDistance = vector48.Length(); + fallThrough = playerDistance > 200f; + return true; + } + + public override void AI() + { + Player player = Main.player[Projectile.owner]; + if (!player.active) + { + Projectile.active = false; + return; + } + CalamityPlayer modPlayer = player.Calamity(); + if (player.dead) + { + modPlayer.seaSlugPet = false; + } + if (modPlayer.seaSlugPet) + { + Projectile.timeLeft = 2; + } + + UpdateColor(player); + + Vector2 vector46 = Projectile.position; + if (!fly) + { + Projectile.rotation = 0; + Vector2 center2 = Projectile.Center; + Vector2 vector48 = player.Center - center2; + float playerDistance = vector48.Length(); + if (Projectile.velocity.Y == 0 && (HoleBelow() || (playerDistance > 110f && Projectile.position.X == Projectile.oldPosition.X))) + { + Projectile.velocity.Y = -8f; + } + Projectile.velocity.Y += 0.35f; + if (Projectile.velocity.Y > 15f) + { + Projectile.velocity.Y = 15f; + } + if (playerDistance > 600f) + { + fly = true; + Projectile.velocity.X = 0f; + Projectile.velocity.Y = 0f; + } + if (playerDistance > 100f) + { + if (player.position.X - Projectile.position.X > 0f) + { + Projectile.velocity.X += 0.10f; + if (Projectile.velocity.X > 5f) + { + Projectile.velocity.X = 5f; + } + } + else + { + Projectile.velocity.X -= 0.10f; + if (Projectile.velocity.X < -5f) + { + Projectile.velocity.X = -5f; + } + } + } + if (playerDistance < 100f) + { + if (Projectile.velocity.X != 0f) + { + if (Projectile.velocity.X > 0.8f) + { + Projectile.velocity.X -= 0.25f; + } + else if (Projectile.velocity.X < -0.8f) + { + Projectile.velocity.X += 0.25f; + } + else if (Projectile.velocity.X < 0.8f && Projectile.velocity.X > -0.8f) + { + Projectile.velocity.X = 0f; + } + } + } + if (playerDistance < 70f) + { + Projectile.velocity.X *= 0.5f; + } + if (Projectile.position.X == Projectile.oldPosition.X && Projectile.position.Y == Projectile.oldPosition.Y && Projectile.velocity.X == 0) + { + Projectile.frame = 0; + Projectile.frameCounter = 0; + } + if (Projectile.velocity.Y > 0.3f && Projectile.position.Y != Projectile.oldPosition.Y) + { + Projectile.frame = 4; + Projectile.frameCounter = 0; + } + else + { + Projectile.frameCounter++; + if (Projectile.frameCounter > 3) + { + Projectile.frame++; + Projectile.frameCounter = 0; + } + if (Projectile.frame > 4) + { + Projectile.frame = 1; + } + } + + if (Projectile.velocity.X > 0.8f) + { + Projectile.spriteDirection = 1; + } + else if (Projectile.velocity.X < -0.8f) + { + Projectile.spriteDirection = -1; + } + } + else if (fly) + { + float num16 = 0.5f; + Projectile.tileCollide = false; + Vector2 vector3 = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f); + float horiPos = Main.player[Projectile.owner].position.X + (float)(Main.player[Projectile.owner].width / 2) - vector3.X; + float vertiPos = Main.player[Projectile.owner].position.Y + (float)(Main.player[Projectile.owner].height / 2) - vector3.Y; + vertiPos += (float)Main.rand.Next(-10, 21); + horiPos += (float)Main.rand.Next(-10, 21); + horiPos += (float)(60 * -(float)player.direction); + vertiPos -= 60f; + float playerDistance = (float)Math.Sqrt((double)(horiPos * horiPos + vertiPos * vertiPos)); + float num21 = 18f; + float num27 = (float)Math.Sqrt((double)(horiPos * horiPos + vertiPos * vertiPos)); + if (playerDistance > 1200f) + { + Projectile.position.X = player.Center.X - (float)(Projectile.width / 2); + Projectile.position.Y = player.Center.Y - (float)(Projectile.height / 2); + Projectile.netUpdate = true; + } + if (playerDistance < 100f) + { + num16 = 0.5f; + if (player.velocity.Y == 0f) + { + ++playerStill; + } + else + { + playerStill = 0; + } + if (playerStill > 10 && !Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height)) + { + fly = false; + Projectile.velocity *= 0.2f; + Projectile.tileCollide = true; + } + } + if (playerDistance < 50f) + { + if (Math.Abs(Projectile.velocity.X) > 2f || Math.Abs(Projectile.velocity.Y) > 2f) + { + Projectile.velocity *= 0.90f; + } + num16 = 0.02f; + } + else + { + if (playerDistance < 100f) + { + num16 = 0.35f; + } + if (playerDistance > 300f) + { + num16 = 1f; + } + playerDistance = num21 / playerDistance; + horiPos *= playerDistance; + vertiPos *= playerDistance; + } + if (Projectile.velocity.X <= horiPos) + { + Projectile.velocity.X = Projectile.velocity.X + num16; + if (num16 > 0.05f && Projectile.velocity.X < 0f) + { + Projectile.velocity.X = Projectile.velocity.X + num16; + } + } + if (Projectile.velocity.X > horiPos) + { + Projectile.velocity.X = Projectile.velocity.X - num16; + if (num16 > 0.05f && Projectile.velocity.X > 0f) + { + Projectile.velocity.X = Projectile.velocity.X - num16; + } + } + if (Projectile.velocity.Y <= vertiPos) + { + Projectile.velocity.Y = Projectile.velocity.Y + num16; + if (num16 > 0.05f && Projectile.velocity.Y < 0f) + { + Projectile.velocity.Y = Projectile.velocity.Y + num16 * 2f; + } + } + if (Projectile.velocity.Y > vertiPos) + { + Projectile.velocity.Y = Projectile.velocity.Y - num16; + if (num16 > 0.05f && Projectile.velocity.Y > 0f) + { + Projectile.velocity.Y = Projectile.velocity.Y - num16 * 2f; + } + } + + Projectile.rotation += (Math.Abs(Projectile.velocity.X) + Math.Abs(Projectile.velocity.Y)) * 0.01f * (float)Projectile.direction; + + if (Projectile.Center.X < Main.player[Projectile.owner].Center.X) + { + Projectile.spriteDirection = 1; + } + else if (Projectile.Center.X > Main.player[Projectile.owner].Center.X) + { + Projectile.spriteDirection = -1; + } + + Projectile.frame = 5; + idleTimer = 0; + } + } + + private bool HoleBelow() + { + int tileWidth = 4; + int tileX = (int)(Projectile.Center.X / 16f) - tileWidth; + if (Projectile.velocity.X > 0) + { + tileX += tileWidth; + } + int tileY = (int)((Projectile.position.Y + Projectile.height) / 16f); + for (int y = tileY; y < tileY + 2; y++) + { + for (int x = tileX; x < tileX + tileWidth; x++) + { + if (Main.tile[x, y].HasTile) + { + return false; + } + } + } + return true; + } + } +} diff --git a/Projectiles/Pets/SeaSlug.png b/Projectiles/Pets/SeaSlug.png new file mode 100644 index 0000000000..7d13907832 Binary files /dev/null and b/Projectiles/Pets/SeaSlug.png differ diff --git a/Projectiles/Pets/SeaSlugAbyss_Glow.png b/Projectiles/Pets/SeaSlugAbyss_Glow.png new file mode 100644 index 0000000000..9bebb47fd5 Binary files /dev/null and b/Projectiles/Pets/SeaSlugAbyss_Glow.png differ diff --git a/Projectiles/Pets/SeaSlugAstral_Glow.png b/Projectiles/Pets/SeaSlugAstral_Glow.png new file mode 100644 index 0000000000..79ca874914 Binary files /dev/null and b/Projectiles/Pets/SeaSlugAstral_Glow.png differ diff --git a/Projectiles/Pets/SeaSlugCrags_Glow.png b/Projectiles/Pets/SeaSlugCrags_Glow.png new file mode 100644 index 0000000000..a48ae83743 Binary files /dev/null and b/Projectiles/Pets/SeaSlugCrags_Glow.png differ diff --git a/Projectiles/Pets/SeaSlugDesert_Glow.png b/Projectiles/Pets/SeaSlugDesert_Glow.png new file mode 100644 index 0000000000..ab66005a3a Binary files /dev/null and b/Projectiles/Pets/SeaSlugDesert_Glow.png differ diff --git a/Projectiles/Pets/SeaSlugJungle_Glow.png b/Projectiles/Pets/SeaSlugJungle_Glow.png new file mode 100644 index 0000000000..867ca38784 Binary files /dev/null and b/Projectiles/Pets/SeaSlugJungle_Glow.png differ diff --git a/Projectiles/Pets/SeaSlugSnow_Glow.png b/Projectiles/Pets/SeaSlugSnow_Glow.png new file mode 100644 index 0000000000..7d1a29a4a2 Binary files /dev/null and b/Projectiles/Pets/SeaSlugSnow_Glow.png differ diff --git a/Projectiles/Pets/SeaSlugSulphur_Glow.png b/Projectiles/Pets/SeaSlugSulphur_Glow.png new file mode 100644 index 0000000000..060d36f600 Binary files /dev/null and b/Projectiles/Pets/SeaSlugSulphur_Glow.png differ diff --git a/Projectiles/Pets/SeaSlugSunken_Glow.png b/Projectiles/Pets/SeaSlugSunken_Glow.png new file mode 100644 index 0000000000..44145c20cd Binary files /dev/null and b/Projectiles/Pets/SeaSlugSunken_Glow.png differ diff --git a/Projectiles/Pets/SeaSlug_Glow.png b/Projectiles/Pets/SeaSlug_Glow.png new file mode 100644 index 0000000000..5587370bd3 Binary files /dev/null and b/Projectiles/Pets/SeaSlug_Glow.png differ diff --git a/Scenes/MiscScenes/BrimstoneCragScene.cs b/Scenes/MiscScenes/BrimstoneCragScene.cs new file mode 100644 index 0000000000..6d9151f525 --- /dev/null +++ b/Scenes/MiscScenes/BrimstoneCragScene.cs @@ -0,0 +1,17 @@ +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Systems +{ + public class BrimstoneCragScene : ModSceneEffect + { + public override SceneEffectPriority Priority => SceneEffectPriority.Environment; + + public override bool IsSceneEffectActive(Player player) => player.Calamity().ZoneCalamity; + + public override void SpecialVisuals(Player player, bool isActive) + { + player.ManageSpecialBiomeVisuals("CalamityMod:BrimstoneCrag", isActive); + } + } +} diff --git a/Schematics/CragBridge.csch b/Schematics/CragBridge.csch new file mode 100644 index 0000000000..c6cdd43de8 Binary files /dev/null and b/Schematics/CragBridge.csch differ diff --git a/Schematics/SchematicManager.cs b/Schematics/SchematicManager.cs index b2297b3f2c..13df51b004 100644 --- a/Schematics/SchematicManager.cs +++ b/Schematics/SchematicManager.cs @@ -64,6 +64,9 @@ namespace CalamityMod.Schematics internal const string AstralBeaconKey = "Astral Beacon"; internal const string AstralBeaconFilename = "Schematics/AstralBeacon.csch"; + + internal const string CragBridgeKey = "Crags Bridge"; + internal const string CragBridgeFilename = "Schematics/CragBridge.csch"; internal static Dictionary TileMaps; internal static Dictionary PilePlacementMaps; @@ -98,6 +101,9 @@ namespace CalamityMod.Schematics // Astral world gen structures [AstralBeaconKey] = CalamitySchematicIO.LoadSchematic(AstralBeaconFilename), + //crag bridge + [CragBridgeKey] = CalamitySchematicIO.LoadSchematic(CragBridgeFilename), + // Sulphurous Sea scrap world gen structures ["Sulphurous Scrap 1"] = CalamitySchematicIO.LoadSchematic("Schematics/SulphurousScrap1.csch").ShaveOffEdge(), ["Sulphurous Scrap 2"] = CalamitySchematicIO.LoadSchematic("Schematics/SulphurousScrap2.csch").ShaveOffEdge(), diff --git a/Skies/BrimstoneCragSky.cs b/Skies/BrimstoneCragSky.cs new file mode 100644 index 0000000000..81f01080bf --- /dev/null +++ b/Skies/BrimstoneCragSky.cs @@ -0,0 +1,133 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.Collections.Generic; +using Terraria; +using Terraria.GameContent; +using Terraria.Graphics.Effects; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Skies +{ + public class BrimstoneCragSky : CustomSky + { + public int skyActiveLeeway = 0; + public class Cinder + { + public int Time; + public int Lifetime; + public int IdentityIndex; + public float Scale; + public float Depth; + public Color DrawColor; + public Vector2 Velocity; + public Vector2 Center; + public Cinder(int lifetime, int identity, float depth, Color color, Vector2 startingPosition, Vector2 startingVelocity) + { + Lifetime = lifetime; + IdentityIndex = identity; + Depth = depth; + DrawColor = color; + Center = startingPosition; + Velocity = startingVelocity; + } + } + + private bool skyActive; + private float opacity; + public List Cinders = new List(); + + public override void Deactivate(params object[] args) => skyActive = false; + + public override void Reset() => skyActive = false; + + public override bool IsActive() => skyActive || opacity > 0f; + + public override void Activate(Vector2 position, params object[] args) => skyActive = true; + + public override void Update(GameTime gameTime) + { + if (!Main.LocalPlayer.Calamity().ZoneCalamity || Main.gameMenu) + { + skyActive = false; + if (skyActiveLeeway > 0) skyActiveLeeway--; + } + else if (skyActiveLeeway < 60) skyActiveLeeway++; + + if (skyActive && opacity < 1f) + { + opacity += 0.02f; + } + else if (!skyActive && opacity > 0f) + { + opacity -= 0.02f; + } + + static Color selectCinderColor() + { + if (Main.rand.NextBool(3)) + return Color.Lerp(Color.DarkGray, Color.LightGray, Main.rand.NextFloat()); + + return Color.Lerp(Color.Red, Color.Yellow, Main.rand.NextFloat(0.9f)); + } + + // Randomly add cinders. + if (Main.rand.NextBool(12) && skyActive) + { + int lifetime = Main.rand.Next(285, 445); + float depth = Main.rand.NextFloat(1.8f, 5f); + Vector2 startingPosition = Main.screenPosition + new Vector2(Main.screenWidth * Main.rand.NextFloat(-0.1f, 1.1f), Main.screenHeight * 1.05f); + Vector2 startingVelocity = -Vector2.UnitY.RotatedByRandom(0.91f); + Cinders.Add(new Cinder(lifetime, Cinders.Count, depth, selectCinderColor(), startingPosition, startingVelocity)); + } + + // Update all cinders. + if (skyActive || skyActiveLeeway > 0) + { + float cinderSpeed = 5.6f; + for (int i = 0; i < Cinders.Count; i++) + { + Cinders[i].Scale = Utils.GetLerpValue(Cinders[i].Lifetime, Cinders[i].Lifetime / 3, Cinders[i].Time, true); + Cinders[i].Scale *= MathHelper.Lerp(0.6f, 0.9f, Cinders[i].IdentityIndex % 6f / 6f); + + Vector2 idealVelocity = -Vector2.UnitY.RotatedBy(MathHelper.Lerp(-0.94f, 0.94f, (float)Math.Sin(Cinders[i].Time / 36f + Cinders[i].IdentityIndex) * 0.5f + 0.5f)) * cinderSpeed; + float movementInterpolant = MathHelper.Lerp(0.01f, 0.08f, Utils.GetLerpValue(45f, 145f, Cinders[i].Time, true)); + Cinders[i].Velocity = Vector2.Lerp(Cinders[i].Velocity, idealVelocity, movementInterpolant); + Cinders[i].Velocity = Cinders[i].Velocity.SafeNormalize(-Vector2.UnitY) * cinderSpeed; + Cinders[i].Time++; + + Cinders[i].Center += Cinders[i].Velocity; + } + } + + // Clear away all dead cinders. + Cinders.RemoveAll(c => c.Time >= c.Lifetime); + + if (!Main.LocalPlayer.Calamity().ZoneCalamity) + Filters.Scene["CalamityMod:BrimstoneCrag"].Deactivate(Array.Empty()); + } + + public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth) + { + if (!Main.LocalPlayer.Calamity().ZoneCalamity && skyActiveLeeway == 0) + return; + + // Draw cinders. + Texture2D cinderTexture = ModContent.Request("CalamityMod/Skies/CalamitasCinder").Value; + float scaleFade = skyActiveLeeway / 60f; + for (int i = 0; i < Cinders.Count; i++) + { + Vector2 drawPosition = Cinders[i].Center - Main.screenPosition; + for (int j = 0; j < 3; j++) + { + Vector2 offsetDrawPosition = drawPosition + (MathHelper.TwoPi * j / 3f).ToRotationVector2() * 1.4f; + Color offsetDrawColor = Color.Red * 0.56f; + offsetDrawColor.A = 0; + spriteBatch.Draw(cinderTexture, offsetDrawPosition, null, offsetDrawColor, 0f, cinderTexture.Size() * 0.5f, Cinders[i].Scale * 1.5f * scaleFade, SpriteEffects.None, 0f); + } + spriteBatch.Draw(cinderTexture, drawPosition, null, Cinders[i].DrawColor, 0f, cinderTexture.Size() * 0.5f, Cinders[i].Scale * scaleFade, SpriteEffects.None, 0f); + } + } + } +} diff --git a/Sounds/Custom/ChainsawEnd.ogg b/Sounds/Custom/ChainsawEnd.ogg new file mode 100644 index 0000000000..cdb79909bb Binary files /dev/null and b/Sounds/Custom/ChainsawEnd.ogg differ diff --git a/Sounds/Custom/ChainsawStart.ogg b/Sounds/Custom/ChainsawStart.ogg new file mode 100644 index 0000000000..b5205d0a72 Binary files /dev/null and b/Sounds/Custom/ChainsawStart.ogg differ diff --git a/Systems/HellBackgroundSystem.cs b/Systems/HellBackgroundSystem.cs new file mode 100644 index 0000000000..da2600efed --- /dev/null +++ b/Systems/HellBackgroundSystem.cs @@ -0,0 +1,239 @@ +/* +using Terraria; +using Terraria.ModLoader; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; + +namespace CalamityMod.Systems +{ + public interface HellBGLoad + { + void Load(); + void Unload(); + } + + //hell background system since it will probably be used in the future + //also example at the bottom + internal static class HellBGManager + { + public static int CurrentBGID = -1; + public static HellBGType[] HellBGs; + + public static void Load() + { + CurrentBGID = -1; + HellBGs = new HellBGType[0]; + + //super epic detour + On.Terraria.Main.DrawUnderworldBackground += DrawHellBG; + } + + public static void Unload() + { + HellBGs = null; + } + + private static void DrawHellBG(On.Terraria.Main.orig_DrawUnderworldBackground orig, Main self, bool flat) + { + int oldID = CurrentBGID; + CurrentBGID = -1; + + if (Main.gameMenu || Main.screenPosition.Y + Main.screenHeight < (Main.maxTilesY - 220) * 16f) + { + orig(self, flat); + return; + } + for (int i = 0; i < HellBGs.Length; i++) + { + if (HellBGs[i].IsActive()) + { + CurrentBGID = i; + break; + } + } + if (oldID != CurrentBGID && oldID != -1) + { + CurrentBGID = oldID; + oldID = -2; + HellBGs[CurrentBGID].Transparency -= HellBGs[CurrentBGID].TransitionSpeed; + } + else if (CurrentBGID == -1) + { + orig(self, flat); + return; + } + + var currentBG = HellBGs[CurrentBGID]; + float transparency = 1f; + + if (currentBG.Transparency < 1f) + { + orig(self, flat); + if (oldID != -2) + { + currentBG.Transparency += currentBG.TransitionSpeed; + + if (currentBG.Transparency > 1f) + { + currentBG.Transparency = 1f; + } + } + else + { + currentBG.Transparency -= currentBG.TransitionSpeed; + + if (currentBG.Transparency < 0f) + { + currentBG.Transparency = 0f; + } + } + + transparency = currentBG.Transparency; + } + + Vector2 vector = Main.screenPosition + new Vector2((Main.screenWidth >> 1), (Main.screenHeight >> 1)); + float num = (Main.GameViewMatrix.Zoom.Y - 1f) * 0.5f * 200f; + int bg0Height = ModContent.Request(currentBG.TexturePath + "0").Height(); + bg0Height += bg0Height >> 1; + float Scale = 1.4f; //how much the bg textures are scaled up in game + for (int Layers = 4; Layers >= 0; Layers--) + { + //get each background texture + Texture2D BGTexture = ModContent.Request(currentBG.TexturePath + Layers).Value; + //get each glowmask texture for the bg + Texture2D BGTextureGlow = ModContent.Request(currentBG.TexturePath + Layers + "_Glow").Value; + + Vector2 vector2 = new Vector2(BGTexture.Width, BGTexture.Height) * 0.5f; + float num2 = flat ? 1f : (Layers * 2 + 3f); + Vector2 vector3 = new Vector2(1f / num2); + Rectangle rectangle = new Rectangle(0, 0, BGTexture.Width, BGTexture.Height); + Vector2 zero = Vector2.Zero; + + switch (Layers) + { + //zero.Y is the y-offset for each bg, if it draws too high or too low then it can be changed to fix that + case 0: + { + zero.Y += 0f; + break; + } + case 1: + { + zero.Y += 0f; + break; + } + case 2: + { + zero.Y += 0f; + break; + } + case 3: + { + zero.Y += 0f; + break; + } + case 4: + { + zero.Y += 0f; + break; + } + } + + if (flat) + { + zero.Y += bg0Height * 1.3f - vector2.Y; + } + + vector2 *= Scale; + + zero.Y -= num; + float num5 = Scale * rectangle.Width; + int num6 = (int)((vector.X * vector3.X - vector2.X + zero.X - (Main.screenWidth >> 1)) / num5); + + for (int j = num6 - 2; j < num6 + 4 + (int)(Main.screenWidth / num5); j++) + { + Vector2 drawPosition = (new Vector2(j * Scale * (rectangle.Width / vector3.X), (Main.maxTilesY - 200) * 16f) + vector2 - vector) * vector3 + vector - Main.screenPosition - vector2 + zero; + var frame = rectangle; + var clr = currentBG.DrawColor * transparency; + + if (currentBG.PreDraw(BGTexture, ref drawPosition, ref frame, ref clr, Scale, Layers)) + { + //draw the bg textures themselves + Main.spriteBatch.Draw(BGTexture, drawPosition, frame, clr, 0f, Vector2.Zero, Scale, SpriteEffects.None, 0f); + + //draws the glowmask over each background + Main.spriteBatch.Draw(BGTextureGlow, drawPosition, frame, Color.White * transparency, 0f, Vector2.Zero, Scale, SpriteEffects.None, 0f); + } + } + } + } + + public static void AddHellBG(HellBGType hellBG) + { + int id = HellBGs.Length; + Array.Resize(ref HellBGs, id + 1); + hellBG.ID = id; + HellBGs[id] = hellBG; + } + } + + public abstract class HellBGType : HellBGLoad + { + public int ID; + public float Transparency; + void HellBGLoad.Load() + { + if (Main.dedServ) + { + return; + } + HellBGManager.AddHellBG(this); + OnLoad(); + } + + void HellBGLoad.Unload() + { + OnUnload(); + } + + public abstract bool IsActive(); + public abstract string TexturePath { get; } + + public virtual float TransitionSpeed => 0.02f; + public virtual Color DrawColor => new Color(255, 255, 255, 255); + + protected virtual void OnLoad() + { + } + + protected virtual void OnUnload() + { + } + + public virtual bool PreDraw(Texture2D texture, ref Vector2 drawPosition, ref Rectangle frame, ref Color drawColor, float Scale, int Layer) + { + return true; + } + + public virtual void PostDraw(Texture2D texture, Vector2 drawPosition, Rectangle frame, Color drawColor, float Scale, int Layer) + { + } + } + + //example hell background using the system + public class SpookyHellBG : HellBGType + { + //get the texture for each background + //you dont need to put any numbers at the end of the bg texture name since the hell bg system manages that + public override string TexturePath => "CalamityMod/Backgrounds/BgTextureName"; + + public override bool IsActive() + { + return whatever; //return the condition(s) required for this background to be drawn + } + + public override Color DrawColor => Color.Gray; //draw color of the bg + } +} +*/ \ No newline at end of file diff --git a/Systems/WorldgenManagementSystem.cs b/Systems/WorldgenManagementSystem.cs index ac46cd156c..b669b5bc9e 100644 --- a/Systems/WorldgenManagementSystem.cs +++ b/Systems/WorldgenManagementSystem.cs @@ -29,6 +29,7 @@ namespace CalamityMod.Systems #region ModifyWorldGenTasks public override void ModifyWorldGenTasks(List tasks, ref float totalWeight) { + //evil island int islandIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Floating Island Houses")); if (islandIndex != -1) { @@ -39,12 +40,14 @@ namespace CalamityMod.Systems })); } + //biome chests in dungeon int DungeonChestIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Dungeon")); if (DungeonChestIndex != -1) { tasks.Insert(DungeonChestIndex + 1, new PassLegacy("CalamityDungeonBiomeChests", MiscWorldgenRoutines.GenerateBiomeChests)); } + //big jungle temple int JungleTempleIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Jungle Temple")); tasks[JungleTempleIndex] = new PassLegacy("Jungle Temple", (progress, config) => { @@ -52,8 +55,9 @@ namespace CalamityMod.Systems CustomTemple.NewJungleTemple(); }); - int hiveIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Hives")); - tasks[JungleTempleIndex] = new PassLegacy("Giant Hive", (progress, config) => + //giant hive + int HiveIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Hives")); + tasks[HiveIndex] = new PassLegacy("Giant Hive", (progress, config) => { progress.Message = "Building a giant beehive"; int attempts = 0; @@ -66,6 +70,7 @@ namespace CalamityMod.Systems } }); + //big jungle temple golem arena i assume int JungleTempleIndex2 = tasks.FindIndex(genpass => genpass.Name.Equals("Temple")); tasks[JungleTempleIndex2] = new PassLegacy("Temple", (progress, config) => { @@ -91,6 +96,7 @@ namespace CalamityMod.Systems })); } + //better temple altar int LihzahrdAltarIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Lihzahrd Altars")); tasks[LihzahrdAltarIndex] = new PassLegacy("Lihzahrd Altars", (progress, config) => { @@ -98,11 +104,11 @@ namespace CalamityMod.Systems CustomTemple.NewJungleTempleLihzahrdAltar(); }); - // TODO -- Most of the below worldgen should be spaced out at better points of generation instead of all crammed at the end - + //stuff that gens after vanilla worldgen int FinalIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Final Cleanup")); if (FinalIndex != -1) { + //gem deposits int currentFinalIndex = FinalIndex; tasks.Insert(++currentFinalIndex, new PassLegacy("Gem Depth Adjustment", (progress, config) => { @@ -110,43 +116,10 @@ namespace CalamityMod.Systems MiscWorldgenRoutines.SmartGemGen(); })); + //planetoids tasks.Insert(++currentFinalIndex, new PassLegacy("Planetoids", Planetoid.GenerateAllBasePlanetoids)); - //Not touching this yet because the Crags will be reworked in the future - #region BrimstoneCrag - tasks.Insert(++currentFinalIndex, new PassLegacy("Brimstone Crag", (progress, config) => - { - progress.Message = "Uncovering the ruins of a fallen empire"; - - int x = Main.maxTilesX; - - int xUnderworldGen = WorldGen.genRand.Next((int)((double)x * 0.1), (int)((double)x * 0.15)); - int yUnderworldGen = Main.maxTilesY - 100; - - MiscWorldgenRoutines.UnderworldIsland(xUnderworldGen, yUnderworldGen, 180, 201, 120, 136); - MiscWorldgenRoutines.UnderworldIsland(xUnderworldGen - 50, yUnderworldGen - 30, 100, 111, 60, 71); - MiscWorldgenRoutines.UnderworldIsland(xUnderworldGen + 50, yUnderworldGen - 30, 100, 111, 60, 71); - - MiscWorldgenRoutines.ChasmGenerator(xUnderworldGen - 110, yUnderworldGen - 10, WorldGen.genRand.Next(150) + 150); - MiscWorldgenRoutines.ChasmGenerator(xUnderworldGen + 110, yUnderworldGen - 10, WorldGen.genRand.Next(150) + 150); - - MiscWorldgenRoutines.UnderworldIsland(xUnderworldGen - 150, yUnderworldGen - 30, 60, 66, 35, 41); - MiscWorldgenRoutines.UnderworldIsland(xUnderworldGen + 150, yUnderworldGen - 30, 60, 66, 35, 41); - MiscWorldgenRoutines.UnderworldIsland(xUnderworldGen - 180, yUnderworldGen - 20, 60, 66, 35, 41); - MiscWorldgenRoutines.UnderworldIsland(xUnderworldGen + 180, yUnderworldGen - 20, 60, 66, 35, 41); - - MiscWorldgenRoutines.UnderworldIslandHouse(xUnderworldGen, yUnderworldGen + 30, 1323); - MiscWorldgenRoutines.UnderworldIslandHouse(xUnderworldGen - 22, yUnderworldGen + 15, 1322); - MiscWorldgenRoutines.UnderworldIslandHouse(xUnderworldGen + 22, yUnderworldGen + 15, 535); - MiscWorldgenRoutines.UnderworldIslandHouse(xUnderworldGen - 50, yUnderworldGen - 30, 112); - MiscWorldgenRoutines.UnderworldIslandHouse(xUnderworldGen + 50, yUnderworldGen - 30, 906); - MiscWorldgenRoutines.UnderworldIslandHouse(xUnderworldGen - 150, yUnderworldGen - 30, 218); - MiscWorldgenRoutines.UnderworldIslandHouse(xUnderworldGen + 150, yUnderworldGen - 30, 3019); - MiscWorldgenRoutines.UnderworldIslandHouse(xUnderworldGen - 180, yUnderworldGen - 20, 274); - MiscWorldgenRoutines.UnderworldIslandHouse(xUnderworldGen + 180, yUnderworldGen - 20, 220); - })); - #endregion - + //sulfur sea int SulphurIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Micro Biomes")); if (SulphurIndex != -1) { @@ -157,6 +130,21 @@ namespace CalamityMod.Systems })); } + //brimstone crags + tasks.Insert(++currentFinalIndex, new PassLegacy("Brimstone Crag", (progress, config) => + { + progress.Message = "Uncovering the ruins of a fallen empire"; + BrimstoneCrag.GenAllCragsStuff(); + })); + + //biome shrines + tasks.Insert(++currentFinalIndex, new PassLegacy("Special Shrines", (progress, config) => + { + progress.Message = "Placing hidden shrines"; + UndergroundShrines.PlaceShrines(); + })); + + //draedon labs tasks.Insert(++currentFinalIndex, new PassLegacy("Draedon Structures", (progress, config) => { progress.Message = "Rust and Dust"; @@ -196,33 +184,22 @@ namespace CalamityMod.Systems workshopPositions.Add(placementPosition); } })); - - tasks.Insert(++currentFinalIndex, new PassLegacy("Special Shrines", (progress, config) => - { - progress.Message = "Placing hidden shrines"; - - UndergroundShrines.PlaceCorruptionShrine(WorldGen.structures); - UndergroundShrines.PlaceCrimsonShrine(WorldGen.structures); - UndergroundShrines.PlaceDesertShrine(WorldGen.structures); - UndergroundShrines.PlaceGraniteShrine(WorldGen.structures); - UndergroundShrines.PlaceIceShrine(WorldGen.structures); - UndergroundShrines.PlaceMarbleShrine(WorldGen.structures); - UndergroundShrines.PlaceMushroomShrine(WorldGen.structures); - UndergroundShrines.PlaceSurfaceShrine(WorldGen.structures); - })); + //abyss tasks.Insert(++currentFinalIndex, new PassLegacy("Abyss", (progress, config) => { progress.Message = "Discovering the new Challenger Deep"; Abyss.PlaceAbyss(); })); + //sulfur sea extra gen tasks.Insert(++currentFinalIndex, new PassLegacy("Sulphur Sea 2", (progress, config) => { progress.Message = "Further polluting one of the oceans"; SulphurousSea.SulphurSeaGenerationAfterAbyss(); })); + //roxcalibur tasks.Insert(++currentFinalIndex, new PassLegacy("Roxcalibur", (progress, config) => { progress.Message = "I Wanna Rock"; @@ -317,7 +294,6 @@ namespace CalamityMod.Systems } } } - } } diff --git a/Tiles/Abyss/AbyssGravel.cs b/Tiles/Abyss/AbyssGravel.cs index b47504e4d1..797ff326c9 100644 --- a/Tiles/Abyss/AbyssGravel.cs +++ b/Tiles/Abyss/AbyssGravel.cs @@ -1,5 +1,4 @@ - -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -9,8 +8,7 @@ namespace CalamityMod.Tiles.Abyss { public class AbyssGravel : ModTile { - int subsheetHeight = 270; - int subsheetWidth = 288; + int animationFrameWidth = 288; public static readonly SoundStyle MineSound = new("CalamityMod/Sounds/Custom/AbyssGravelMine", 3); @@ -43,14 +41,100 @@ namespace CalamityMod.Tiles.Abyss public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset) { - frameXOffset = i % 1 * subsheetWidth; //the 1 should be 2, but it looks weird right now, should be looked into later - frameYOffset = j % 1 * subsheetHeight; + int uniqueAnimationFrameX = 0; + int xPos = i % 4; + int yPos = j % 4; + switch (xPos) + { + case 0: + switch (yPos) + { + case 0: + uniqueAnimationFrameX = 0; + break; + case 1: + uniqueAnimationFrameX = 2; + break; + case 2: + uniqueAnimationFrameX = 1; + break; + case 3: + uniqueAnimationFrameX = 2; + break; + default: + uniqueAnimationFrameX = 2; + break; + } + break; + case 1: + switch (yPos) + { + case 0: + uniqueAnimationFrameX = 2; + break; + case 1: + uniqueAnimationFrameX = 0; + break; + case 2: + uniqueAnimationFrameX = 2; + break; + case 3: + uniqueAnimationFrameX = 2; + break; + default: + uniqueAnimationFrameX = 2; + break; + } + break; + case 2: + switch (yPos) + { + case 0: + uniqueAnimationFrameX = 2; + break; + case 1: + uniqueAnimationFrameX = 0; + break; + case 2: + uniqueAnimationFrameX = 1; + break; + case 3: + uniqueAnimationFrameX = 2; + break; + default: + uniqueAnimationFrameX = 2; + break; + } + break; + case 3: + switch (yPos) + { + case 0: + uniqueAnimationFrameX = 1; + break; + case 1: + uniqueAnimationFrameX = 2; + break; + case 2: + uniqueAnimationFrameX = 0; + break; + case 3: + uniqueAnimationFrameX = 2; + break; + default: + uniqueAnimationFrameX = 2; + break; + } + break; + } + frameXOffset = uniqueAnimationFrameX * animationFrameWidth; } + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) { TileFraming.CustomMergeFrame(i, j, Type, TileID.Dirt); return false; } } -} +} \ No newline at end of file diff --git a/Tiles/Abyss/AbyssGravel.png b/Tiles/Abyss/AbyssGravel.png index d92e9b7831..05ffefa6d8 100644 Binary files a/Tiles/Abyss/AbyssGravel.png and b/Tiles/Abyss/AbyssGravel.png differ diff --git a/Tiles/Abyss/AcidwoodTile.cs b/Tiles/Abyss/AcidwoodTile.cs index d116456dee..89bc2514e5 100644 --- a/Tiles/Abyss/AcidwoodTile.cs +++ b/Tiles/Abyss/AcidwoodTile.cs @@ -14,10 +14,11 @@ namespace CalamityMod.Tiles.Abyss Main.tileSolid[Type] = true; Main.tileMergeDirt[Type] = false; Main.tileBlockLight[Type] = true; - TileMaterials.SetForTileId(Type, TileMaterials._materialsByName["Wood"]); + TileMaterials.SetForTileId(Type, TileMaterials._materialsByName["Wood"]); CalamityUtils.MergeWithGeneral(Type); CalamityUtils.MergeDecorativeTiles(Type); + CalamityUtils.MergeWithAbyss(Type); ItemDrop = ModContent.ItemType(); HitSound = SoundID.Dig; diff --git a/Tiles/Abyss/ViperVines.png b/Tiles/Abyss/ViperVines.png index b9fad1a574..2fe199034b 100644 Binary files a/Tiles/Abyss/ViperVines.png and b/Tiles/Abyss/ViperVines.png differ diff --git a/Tiles/Abyss/Voidstone.cs b/Tiles/Abyss/Voidstone.cs index e77f71ff31..88e1f5b766 100644 --- a/Tiles/Abyss/Voidstone.cs +++ b/Tiles/Abyss/Voidstone.cs @@ -1,5 +1,4 @@ - -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; @@ -30,6 +29,7 @@ namespace CalamityMod.Tiles.Abyss ItemDrop = ModContent.ItemType(); AddMapEntry(new Color(15, 15, 15)); } + int animationFrameWidth = 288; public override bool CreateDust(int i, int j, ref int type) diff --git a/Tiles/CalamityGlobalTile.cs b/Tiles/CalamityGlobalTile.cs index fc9d8b6669..0fcc3addc1 100644 --- a/Tiles/CalamityGlobalTile.cs +++ b/Tiles/CalamityGlobalTile.cs @@ -8,6 +8,7 @@ using CalamityMod.Tiles.DraedonStructures; using CalamityMod.Tiles.DraedonSummoner; using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.SunkenSea; +using CalamityMod.Tiles.Crags; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System.Collections.Generic; @@ -44,7 +45,8 @@ namespace CalamityMod.Tiles TileID.HallowedPlants2, TileID.CrimsonPlants, (ushort)ModContent.TileType(), - (ushort)ModContent.TileType() + (ushort)ModContent.TileType(), + (ushort)ModContent.TileType() }; public static List GrowthTiles = new List() diff --git a/Tiles/Crags/CinderBlossomGrassGrass.png b/Tiles/Crags/CinderBlossomGrassGrass.png new file mode 100644 index 0000000000..e4a85196d0 Binary files /dev/null and b/Tiles/Crags/CinderBlossomGrassGrass.png differ diff --git a/Tiles/Crags/CinderBlossomTallPlants.cs b/Tiles/Crags/CinderBlossomTallPlants.cs new file mode 100644 index 0000000000..7df792ee3b --- /dev/null +++ b/Tiles/Crags/CinderBlossomTallPlants.cs @@ -0,0 +1,43 @@ +using CalamityMod.Dusts; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.GameContent.Metadata; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.Crags +{ + public class CinderBlossomTallPlants : ModTile + { + public override void SetStaticDefaults() + { + Main.tileCut[Type] = true; + Main.tileSolid[Type] = false; + Main.tileNoAttach[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileLavaDeath[Type] = true; + Main.tileWaterDeath[Type] = true; + Main.tileFrameImportant[Type] = true; + TileID.Sets.ReplaceTileBreakUp[Type] = true; + TileID.Sets.SwaysInWindBasic[Type] = true; + TileMaterials.SetForTileId(Type, TileMaterials._materialsByName["Plant"]); + + TileObjectData.newTile.CopyFrom(TileObjectData.Style1x2); + TileObjectData.addTile(Type); + + HitSound = SoundID.Grass; + + AddMapEntry(new Color(200, 80, 210)); + + base.SetStaticDefaults(); + } + + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) + { + offsetY = -16; + height = 32; + } + } +} diff --git a/Tiles/Crags/CinderBlossomTallPlants.png b/Tiles/Crags/CinderBlossomTallPlants.png new file mode 100644 index 0000000000..fb4967e317 Binary files /dev/null and b/Tiles/Crags/CinderBlossomTallPlants.png differ diff --git a/Tiles/Crags/ScorchedBone.cs b/Tiles/Crags/ScorchedBone.cs new file mode 100644 index 0000000000..27eedbcb41 --- /dev/null +++ b/Tiles/Crags/ScorchedBone.cs @@ -0,0 +1,46 @@ +using CalamityMod.Tiles.Ores; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; +using Terraria.ID; + +namespace CalamityMod.Tiles.Crags +{ + public class ScorchedBone : ModTile + { + private int sheetWidth = 450; + private int sheetHeight = 270; + + public override void SetStaticDefaults() + { + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + + CalamityUtils.MergeWithGeneral(Type); + CalamityUtils.MergeWithHell(Type); + CalamityUtils.SetMerge(Type, ModContent.TileType()); + + DustType = 155; + HitSound = SoundID.Dig; + MineResist = 1f; + MinPick = 100; + ItemDrop = ModContent.ItemType(); + AddMapEntry(new Color(87, 62, 67)); + } + + public override bool CanExplode(int i, int j) + { + return false; + } + + public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset) + { + frameXOffset = i % 3 * sheetWidth; + frameYOffset = j % 3 * sheetHeight; + } + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + return TileFraming.BrimstoneFraming(i, j, resetFrame); + } + } +} diff --git a/Tiles/Crags/ScorchedBone.png b/Tiles/Crags/ScorchedBone.png new file mode 100644 index 0000000000..16a09277e4 Binary files /dev/null and b/Tiles/Crags/ScorchedBone.png differ diff --git a/Tiles/Crags/ScorchedRemains.cs b/Tiles/Crags/ScorchedRemains.cs new file mode 100644 index 0000000000..3eea2ca07d --- /dev/null +++ b/Tiles/Crags/ScorchedRemains.cs @@ -0,0 +1,65 @@ +using CalamityMod.Tiles.Ores; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; +using Terraria.ID; + +namespace CalamityMod.Tiles.Crags +{ + public class ScorchedRemains : ModTile + { + private int sheetWidth = 288; + private int sheetHeight = 270; + + public override void SetStaticDefaults() + { + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + + CalamityUtils.MergeWithGeneral(Type); + CalamityUtils.MergeWithHell(Type); + CalamityUtils.SetMerge(Type, ModContent.TileType()); + + DustType = 155; + HitSound = SoundID.Dig; + MineResist = 1f; + MinPick = 100; + ItemDrop = ModContent.ItemType(); + AddMapEntry(new Color(57, 52, 72)); + } + + public override void RandomUpdate(int i, int j) + { + Tile left = Main.tile[i - 1, j]; + Tile right = Main.tile[i + 1, j]; + + if (WorldGen.genRand.Next(3) == 0 && (left.TileType == ModContent.TileType() || right.TileType == ModContent.TileType())) + { + WorldGen.SpreadGrass(i, j, Type, ModContent.TileType(), false); + } + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, 60, 0f, 0f, 1, new Color(255, 255, 255), 1f); + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, 1, 0f, 0f, 1, new Color(100, 100, 100), 1f); + return false; + } + + public override bool CanExplode(int i, int j) + { + return false; + } + + public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset) + { + frameXOffset = i % 3 * sheetWidth; + frameYOffset = j % 3 * sheetHeight; + } + 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/Crags/ScorchedRemains.png b/Tiles/Crags/ScorchedRemains.png new file mode 100644 index 0000000000..3fe8139b3c Binary files /dev/null and b/Tiles/Crags/ScorchedRemains.png differ diff --git a/Tiles/Crags/ScorchedRemainsGrass.cs b/Tiles/Crags/ScorchedRemainsGrass.cs new file mode 100644 index 0000000000..0f1e287685 --- /dev/null +++ b/Tiles/Crags/ScorchedRemainsGrass.cs @@ -0,0 +1,408 @@ +using CalamityMod.Tiles.Ores; +using CalamityMod.Dusts; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.DataStructures; +using Terraria.ModLoader; +using Terraria.ID; + +namespace CalamityMod.Tiles.Crags +{ + public class ScorchedRemainsGrass : ModTile + { + private const short subsheetWidth = 450; + private const short subsheetHeight = 198; + private int extraFrameHeight = 36; + private int extraFrameWidth = 90; + + public override void SetStaticDefaults() + { + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + Main.tileLighted[Type] = true; + + CalamityUtils.MergeWithGeneral(Type); + CalamityUtils.MergeWithHell(Type); + CalamityUtils.SetMerge(Type, ModContent.TileType()); + + HitSound = SoundID.Dig; + MineResist = 1f; + MinPick = 100; + ItemDrop = ModContent.ItemType(); + AddMapEntry(new Color(212, 82, 227)); + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + r = 1.82f; + g = 0.56f; + b = 1.07f; + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, 1, 0f, 0f, 1, new Color(100, 100, 100), 1f); + return false; + } + + public override bool CanExplode(int i, int j) + { + return false; + } + + public override void KillTile(int i, int j, ref bool fail, ref bool effectOnly, ref bool noItem) + { + if (fail && !effectOnly) + { + Main.tile[i, j].TileType = (ushort)ModContent.TileType(); + } + } + + public override void RandomUpdate(int i, int j) + { + Tile up = Main.tile[i, j - 1]; + Tile up2 = Main.tile[i, j - 2]; + + //convert this tile back into scorched remains if any liquid is above it + //will change this to only check for lava if necessary + if (up.LiquidAmount > 0) + { + Main.tile[i, j].TileType = (ushort)ModContent.TileType(); + } + + if (WorldGen.genRand.Next(5) == 0 && !up.HasTile && !up2.HasTile && up.LiquidAmount == 0) + { + up.TileType = (ushort)ModContent.TileType(); + up.HasTile = true; + up.TileFrameY = 0; + up.TileFrameX = (short)(WorldGen.genRand.Next(21) * 18); + WorldGen.SquareTileFrame(i, j - 1, true); + + if (Main.netMode == NetmodeID.Server) + { + NetMessage.SendTileSquare(-1, i, j - 1, 3, TileChangeType.None); + } + } + } + + public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) + { + bool isPlayerNear = WorldGen.PlayerLOS(i, j); + Tile Above = Framing.GetTileSafely(i, j - 1); + + if (!Main.gamePaused && Main.instance.IsActive && !Above.HasTile && isPlayerNear) + { + if (Main.rand.Next(550) == 0) + { + int newDust = Dust.NewDust(new Vector2((i - 2) * 16, (j - 1) * 16), 5, 5, ModContent.DustType()); + Main.dust[newDust].velocity.Y += 0.09f; + } + } + + if (Main.tile[i - 1, j - 1].TileType != Type || Main.tile[i, j - 1].TileType != Type || Main.tile[i + 1, j - 1].TileType != Type || + Main.tile[i - 1, j - 2].TileType != Type || Main.tile[i, j - 2].TileType != Type || Main.tile[i + 1, j - 2].TileType != Type) + { + try + { + Main.instance.TilesRenderer.AddSpecialLegacyPoint(i, j); + } + catch { } + } + } + + public override void SpecialDraw(int i, int j, SpriteBatch spriteBatch) + { + Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); + Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; + Color drawColour = GetDrawColour(i, j); + Texture2D leaves = ModContent.Request("CalamityMod/Tiles/Crags/CinderBlossomGrassGrass").Value; + + DrawExtraTop(i, j, leaves, drawOffset, drawColour); + DrawExtraWallEnds(i, j, leaves, drawOffset, drawColour); + DrawExtraDrapes(i, j, leaves, drawOffset, drawColour); + } + + #region 'Extra Drapes' Drawing + private void DrawExtraTop(int i, int j, Texture2D extras, Vector2 drawOffset, Color drawColour) + { + /* + If the tile directly above this tile is not otherworldly stone, or if it is, there is air to both sides of that tile, draw the Extra surface + */ + if ( + CheckTile(Type, false, 0, 1, i, j) || + (CheckTile(Type, true, 0, 1, i, j) && CheckTile(Type, false, 1, 1, i, j) && CheckTile(Type, false, -1, 1, i, j) && CheckTile(Type, true, 1, 0, i, j) && CheckTile(Type, true, -1, 0, i, j)) + ) + { + Main.spriteBatch.Draw(extras, drawOffset, new Rectangle?(new Rectangle(GetExtraState("middle") + GetExtraVariant(i, j), GetExtraPattern(i), 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + Main.spriteBatch.Draw(extras, drawOffset + new Vector2(0f, 16f), new Rectangle?(new Rectangle(GetExtraState("middle") + GetExtraVariant(i, j), GetExtraPattern(i) + 18, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + + DrawExtraOverhang(i, j, extras, drawOffset, drawColour); + } + } + + private void DrawExtraWallEnds(int i, int j, Texture2D extras, Vector2 drawOffset, Color drawColour) + { + /* + Ending the Extra when a wall is reached + */ + + //Left + if ( + CheckTile(Type, true, 1, 0, i, j) && CheckTile(Type, false, 1, 1, i, j) && CheckTile(Type, true, 0, 1, i, j) && + (CheckTile(Type, true, -1, 1, i, j) || CheckTile(Type, false, -1, 0, i, j)) + ) + { + Main.spriteBatch.Draw(extras, drawOffset, new Rectangle?(new Rectangle(GetExtraState("wallEndLeft") + GetExtraVariant(i + 1, j), GetExtraPattern(i), 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + Main.spriteBatch.Draw(extras, drawOffset + new Vector2(0f, 16f), new Rectangle?(new Rectangle(GetExtraState("wallEndLeft") + GetExtraVariant(i + 1, j), GetExtraPattern(i) + 18, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + } + //Right + if ( + CheckTile(Type, true, -1, 0, i, j) && CheckTile(Type, false, -1, 1, i, j) && CheckTile(Type, true, 0, 1, i, j) && + (CheckTile(Type, true, 1, 1, i, j) || CheckTile(Type, false, 1, 0, i, j)) + ) + { + Main.spriteBatch.Draw(extras, drawOffset, new Rectangle?(new Rectangle(GetExtraState("wallEndRight") + GetExtraVariant(i - 1, j), GetExtraPattern(i), 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + Main.spriteBatch.Draw(extras, drawOffset + new Vector2(0f, 16f), new Rectangle?(new Rectangle(GetExtraState("wallEndRight") + GetExtraVariant(i - 1, j), GetExtraPattern(i) + 18, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + } + } + + private void DrawExtraOverhang(int i, int j, Texture2D extras, Vector2 drawOffset, Color drawColour) + { + /* + Called from DrawExtraTop(). Ending the Extra when the edge of the tile is reached + */ + + //Left + if ( + CheckTile(Type, false, -1, 0, i, j) + ) + { + Main.spriteBatch.Draw(extras, drawOffset + new Vector2(-16f, 0f), new Rectangle?(new Rectangle(GetExtraState("overhangLeft") + GetExtraVariant(i, j), GetExtraPattern(i - 1), 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + Main.spriteBatch.Draw(extras, drawOffset + new Vector2(-16f, 16f), new Rectangle?(new Rectangle(GetExtraState("overhangLeft") + GetExtraVariant(i, j), GetExtraPattern(i - 1) + 18, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + } + //Right + if ( + CheckTile(Type, false, 1, 0, i, j) + ) + { + Main.spriteBatch.Draw(extras, drawOffset + new Vector2(16f, 0f), new Rectangle?(new Rectangle(GetExtraState("overhangRight") + GetExtraVariant(i, j), GetExtraPattern(i + 1), 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + Main.spriteBatch.Draw(extras, drawOffset + new Vector2(16f, 16f), new Rectangle?(new Rectangle(GetExtraState("overhangRight") + GetExtraVariant(i, j), GetExtraPattern(i + 1) + 18, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + } + } + + private void DrawExtraDrapes(int i, int j, Texture2D extras, Vector2 drawOffset, Color drawColour) + { + /* + Hanging 'drapes' of the extra element + */ + + //Base + if ( + (CheckTile(Type, true, 0, 1, i, j) && CheckTile(Type, false, 0, 2, i, j)) || + (CheckTile(Type, true, 0, 2, i, j) && CheckTile(Type, false, 1, 2, i, j) && CheckTile(Type, false, -1, 2, i, j) && CheckTile(Type, true, 1, 1, i, j) && CheckTile(Type, true, -1, 1, i, j)) + ) + { + Main.spriteBatch.Draw(extras, drawOffset, new Rectangle?(new Rectangle(GetExtraState("middle") + GetExtraVariant(i, j - 1), GetExtraPattern(i) + 18, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + } + //Left Wall + if ( + CheckTile(Type, true, 1, 1, i, j) && CheckTile(Type, false, 1, 2, i, j) && CheckTile(Type, true, 0, 2, i, j) && + (CheckTile(Type, true, -1, 2, i, j) || CheckTile(Type, false, -1, 1, i, j)) + ) + { + Main.spriteBatch.Draw(extras, drawOffset, new Rectangle?(new Rectangle(GetExtraState("wallEndLeft") + GetExtraVariant(i + 1, j - 1), GetExtraPattern(i) + 18, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + } + //Right Wall + if ( + CheckTile(Type, true, -1, 1, i, j) && CheckTile(Type, false, -1, 2, i, j) && CheckTile(Type, true, 0, 2, i, j) && + (CheckTile(Type, true, 1, 2, i, j) || CheckTile(Type, false, 1, 1, i, j)) + ) + { + Main.spriteBatch.Draw(extras, drawOffset, new Rectangle?(new Rectangle(GetExtraState("wallEndRight") + GetExtraVariant(i - 1, j - 1), GetExtraPattern(i) + 18, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + } + //Left Overhang + if ( + CheckTile(Type, true, 1, 1, i, j) && CheckTile(Type, false, 0, 1, i, j) && CheckTile(Type, false, 0, 2, i, j) && CheckTile(Type, false, 1, 2, i, j) + ) + { + Main.spriteBatch.Draw(extras, drawOffset, new Rectangle?(new Rectangle(GetExtraState("overhangLeft") + GetExtraVariant(i + 1, j - 1), GetExtraPattern(i) + 18, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + } + //Right Overhang + if ( + CheckTile(Type, true, -1, 1, i, j) && CheckTile(Type, false, 0, 1, i, j) && CheckTile(Type, false, 0, 2, i, j) && CheckTile(Type, false, -1, 2, i, j) + ) + { + Main.spriteBatch.Draw(extras, drawOffset, new Rectangle?(new Rectangle(GetExtraState("overhangRight") + GetExtraVariant(i - 1, j - 1), GetExtraPattern(i) + 18, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + } + } + #endregion + + #region Tile Data + private bool CheckTile(int type, bool equal, int x, int y, int i, int j) + { + //Subtract y so that y is vertical for ease of readability + return Main.tile[i + x, j - y].TileType == type == equal; + } + + private Color GetDrawColour(int i, int j) + { + int colType = Main.tile[i, j].TileColor; + Color paintCol = WorldGen.paintColor(colType); + if (colType < 13) + { + paintCol.R = (byte)((paintCol.R / 2f) + 128); + paintCol.G = (byte)((paintCol.G / 2f) + 128); + paintCol.B = (byte)((paintCol.B / 2f) + 128); + } + if (colType == 29) + { + paintCol = Color.Black; + } + Color col = Lighting.GetColor(i, j); + col.R = (byte)(paintCol.R / 255f * col.R); + col.G = (byte)(paintCol.G / 255f * col.G); + col.B = (byte)(paintCol.B / 255f * col.B); + return col; + } + + private int GetExtraState(string type) + { + switch (type) + { + case "middle": + return 36; + case "overhangLeft": + return 18; + case "overhangRight": + return 54; + case "wallEndLeft": + return 0; + case "wallEndRight": + return 72; + default: + Main.NewText(type.ToString() + " is not a valid Extra sheet state"); + return 0; + } + } + + private int GetExtraPattern(int i) + { + return i % 3 * extraFrameHeight; + } + + private int GetExtraVariant(int i, int j) + { + return Main.tile[i, j].TileFrameNumber * extraFrameWidth; + } + + /* + private int GetTileVariant(int i, int j) + { + int variant = 0; //Default to using variant 1 + Tile sourceTile = Main.tile[i, j]; + //Now to get the particular 'variant group' to use, which is used to take the frameX/frameY of the tile and convert it to the variant the tile is using + int frameX = sourceTile.frameX / 18; + int frameY = sourceTile.frameY / 18; + if (frameY < 3 && !(frameX >= 6 && frameX < 9)) + { + int group = 0; + int[] group1XPos = new int[] { 1, 2, 3 }; + int[] group2XPos = new int[] { 0, 4, 5, 9, 10, 11, 12 }; + foreach (int k in group1XPos) + { + if (frameX < k + 1 && frameX >= k) + { + group = 1; + } + } + foreach (int k in group2XPos) + { + if (frameX < k + 1 && frameX >= k) + { + group = 2; + } + } + if (group == 1) + { + if (frameX < 2) + { + variant = 0; + } + else if (frameX < 3) + { + variant = 1; + } + else + { + variant = 2; + } + } + else if (group == 2) + { + if (frameY < 1) + { + variant = 0; + } + else if (frameY < 2) + { + variant = 1; + } + else + { + variant = 2; + } + } + } + else if (frameX < 6 && frameY >= 3) + { + if (frameX < 2) + { + variant = 0; + } + else if (frameX < 4) + { + variant = 1; + } + else + { + variant = 2; + } + } + else if (frameX >= 6 && frameX < 9) + { + if (frameX < 7) + { + variant = 0; + } + else if (frameX < 8) + { + variant = 1; + } + else + { + variant = 2; + } + } + else if (frameX >= 9 && frameY >= 3) + { + if (frameX < 10) + { + variant = 0; + } + else if (frameX < 11) + { + variant = 1; + } + else + { + variant = 2; + } + } + return (variant); + } + */ + #endregion + } +} + diff --git a/Tiles/Crags/ScorchedRemainsGrass.png b/Tiles/Crags/ScorchedRemainsGrass.png new file mode 100644 index 0000000000..540758b1f2 Binary files /dev/null and b/Tiles/Crags/ScorchedRemainsGrass.png differ diff --git a/Tiles/Crags/Spike/CragStalactiteGiant.cs b/Tiles/Crags/Spike/CragStalactiteGiant.cs new file mode 100644 index 0000000000..d52cc6bbff --- /dev/null +++ b/Tiles/Crags/Spike/CragStalactiteGiant.cs @@ -0,0 +1,42 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; +using Terraria.DataStructures; +using Terraria.Enums; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace CalamityMod.Tiles.Crags.Spike +{ + public class CragStalactiteGiant1 : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + TileObjectData.newTile.Width = 4; + TileObjectData.newTile.Height = 8; + TileObjectData.newTile.Origin = new Point16(2, 1); + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16, 16, 16, 16, 16, 16 }; + TileObjectData.newTile.StyleWrapLimit = 36; + TileObjectData.newTile.AnchorTop = new AnchorData(AnchorType.SolidTile, TileObjectData.newTile.Width, 0); + TileObjectData.newTile.AnchorBottom = default(AnchorData); + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.DrawYOffset = -3; + TileObjectData.addTile(Type); + AddMapEntry(new Color(43, 23, 46)); + DustType = 155; + HitSound = SoundID.Tink; + } + } + + public class CragStalactiteGiant2 : CragStalactiteGiant1 + { + } + + public class CragStalactiteGiant3 : CragStalactiteGiant1 + { + } +} \ No newline at end of file diff --git a/Tiles/Crags/Spike/CragStalactiteGiant1.png b/Tiles/Crags/Spike/CragStalactiteGiant1.png new file mode 100644 index 0000000000..224c971459 Binary files /dev/null and b/Tiles/Crags/Spike/CragStalactiteGiant1.png differ diff --git a/Tiles/Crags/Spike/CragStalactiteGiant2.png b/Tiles/Crags/Spike/CragStalactiteGiant2.png new file mode 100644 index 0000000000..0c1392559a Binary files /dev/null and b/Tiles/Crags/Spike/CragStalactiteGiant2.png differ diff --git a/Tiles/Crags/Spike/CragStalactiteGiant3.png b/Tiles/Crags/Spike/CragStalactiteGiant3.png new file mode 100644 index 0000000000..2ef5c8ab41 Binary files /dev/null and b/Tiles/Crags/Spike/CragStalactiteGiant3.png differ diff --git a/Tiles/Crags/Spike/CragStalactiteLarge1.png b/Tiles/Crags/Spike/CragStalactiteLarge1.png new file mode 100644 index 0000000000..6a7dbaa402 Binary files /dev/null and b/Tiles/Crags/Spike/CragStalactiteLarge1.png differ diff --git a/Tiles/Crags/Spike/CragStalactiteLarge2.png b/Tiles/Crags/Spike/CragStalactiteLarge2.png new file mode 100644 index 0000000000..d1c7751849 Binary files /dev/null and b/Tiles/Crags/Spike/CragStalactiteLarge2.png differ diff --git a/Tiles/Crags/Spike/CragStalactiteLarge2x4.cs b/Tiles/Crags/Spike/CragStalactiteLarge2x4.cs new file mode 100644 index 0000000000..91516d13e9 --- /dev/null +++ b/Tiles/Crags/Spike/CragStalactiteLarge2x4.cs @@ -0,0 +1,34 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; +using Terraria.DataStructures; +using Terraria.Enums; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace CalamityMod.Tiles.Crags.Spike +{ + public class CragStalactiteLarge3 : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + TileObjectData.newTile.Width = 2; + TileObjectData.newTile.Height = 4; + TileObjectData.newTile.Origin = new Point16(1, 1); + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16, 16 }; + TileObjectData.newTile.StyleWrapLimit = 36; + TileObjectData.newTile.AnchorTop = new AnchorData(AnchorType.SolidTile, TileObjectData.newTile.Width, 0); + TileObjectData.newTile.AnchorBottom = default(AnchorData); + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.DrawYOffset = -3; + TileObjectData.addTile(Type); + AddMapEntry(new Color(43, 23, 46)); + DustType = 155; + HitSound = SoundID.Tink; + } + } +} \ No newline at end of file diff --git a/Tiles/Crags/Spike/CragStalactiteLarge2x5.cs b/Tiles/Crags/Spike/CragStalactiteLarge2x5.cs new file mode 100644 index 0000000000..43a568b671 --- /dev/null +++ b/Tiles/Crags/Spike/CragStalactiteLarge2x5.cs @@ -0,0 +1,38 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; +using Terraria.DataStructures; +using Terraria.Enums; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace CalamityMod.Tiles.Crags.Spike +{ + public class CragStalactiteLarge1 : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + TileObjectData.newTile.Width = 2; + TileObjectData.newTile.Height = 5; + TileObjectData.newTile.Origin = new Point16(1, 1); + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16, 16, 16 }; + TileObjectData.newTile.StyleWrapLimit = 36; + TileObjectData.newTile.AnchorTop = new AnchorData(AnchorType.SolidTile, TileObjectData.newTile.Width, 0); + TileObjectData.newTile.AnchorBottom = default(AnchorData); + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.DrawYOffset = -3; + TileObjectData.addTile(Type); + AddMapEntry(new Color(43, 23, 46)); + DustType = 155; + HitSound = SoundID.Tink; + } + } + + public class CragStalactiteLarge2 : CragStalactiteLarge1 + { + } +} \ No newline at end of file diff --git a/Tiles/Crags/Spike/CragStalactiteLarge3.png b/Tiles/Crags/Spike/CragStalactiteLarge3.png new file mode 100644 index 0000000000..7fbaffa0be Binary files /dev/null and b/Tiles/Crags/Spike/CragStalactiteLarge3.png differ diff --git a/Tiles/Crags/Spike/CragStalactiteSmall1.png b/Tiles/Crags/Spike/CragStalactiteSmall1.png new file mode 100644 index 0000000000..50adb7fd52 Binary files /dev/null and b/Tiles/Crags/Spike/CragStalactiteSmall1.png differ diff --git a/Tiles/Crags/Spike/CragStalactiteSmall2.png b/Tiles/Crags/Spike/CragStalactiteSmall2.png new file mode 100644 index 0000000000..d1603249a0 Binary files /dev/null and b/Tiles/Crags/Spike/CragStalactiteSmall2.png differ diff --git a/Tiles/Crags/Spike/CragStalactiteSmall2x2.cs b/Tiles/Crags/Spike/CragStalactiteSmall2x2.cs new file mode 100644 index 0000000000..b907a41a74 --- /dev/null +++ b/Tiles/Crags/Spike/CragStalactiteSmall2x2.cs @@ -0,0 +1,32 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; +using Terraria.DataStructures; +using Terraria.Enums; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace CalamityMod.Tiles.Crags.Spike +{ + public class CragStalactiteSmall3 : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); + TileObjectData.newTile.Origin = new Point16(1, 1); + TileObjectData.newTile.StyleWrapLimit = 36; + TileObjectData.newTile.AnchorTop = new AnchorData(AnchorType.SolidTile, TileObjectData.newTile.Width, 0); + TileObjectData.newTile.AnchorBottom = default(AnchorData); + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.DrawYOffset = -3; + TileObjectData.addTile(Type); + AddMapEntry(new Color(43, 23, 46)); + DustType = 155; + HitSound = SoundID.Tink; + } + } +} \ No newline at end of file diff --git a/Tiles/Crags/Spike/CragStalactiteSmall2x3.cs b/Tiles/Crags/Spike/CragStalactiteSmall2x3.cs new file mode 100644 index 0000000000..aa16d21c4a --- /dev/null +++ b/Tiles/Crags/Spike/CragStalactiteSmall2x3.cs @@ -0,0 +1,38 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; +using Terraria.DataStructures; +using Terraria.Enums; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace CalamityMod.Tiles.Crags.Spike +{ + public class CragStalactiteSmall1 : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + TileObjectData.newTile.Width = 2; + TileObjectData.newTile.Height = 3; + TileObjectData.newTile.Origin = new Point16(1, 1); + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16 }; + TileObjectData.newTile.StyleWrapLimit = 36; + TileObjectData.newTile.AnchorTop = new AnchorData(AnchorType.SolidTile, TileObjectData.newTile.Width, 0); + TileObjectData.newTile.AnchorBottom = default(AnchorData); + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.DrawYOffset = -3; + TileObjectData.addTile(Type); + AddMapEntry(new Color(43, 23, 46)); + DustType = 155; + HitSound = SoundID.Tink; + } + } + + public class CragStalactiteSmall2 : CragStalactiteSmall1 + { + } +} \ No newline at end of file diff --git a/Tiles/Crags/Spike/CragStalactiteSmall3.png b/Tiles/Crags/Spike/CragStalactiteSmall3.png new file mode 100644 index 0000000000..b5b7a56be1 Binary files /dev/null and b/Tiles/Crags/Spike/CragStalactiteSmall3.png differ diff --git a/Tiles/Crags/Spike/CragStalagmiteGiant.cs b/Tiles/Crags/Spike/CragStalagmiteGiant.cs new file mode 100644 index 0000000000..96c7270acc --- /dev/null +++ b/Tiles/Crags/Spike/CragStalagmiteGiant.cs @@ -0,0 +1,41 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; +using Terraria.DataStructures; +using Terraria.Enums; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace CalamityMod.Tiles.Crags.Spike +{ + public class CragStalagmiteGiant1 : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + TileObjectData.newTile.Width = 4; + TileObjectData.newTile.Height = 8; + TileObjectData.newTile.Origin = new Point16(2, 7); + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16, 16, 16, 16, 16, 16 }; + TileObjectData.newTile.StyleWrapLimit = 36; + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.DrawYOffset = 3; + TileObjectData.addTile(Type); + AddMapEntry(new Color(43, 23, 46)); + DustType = 155; + HitSound = SoundID.Tink; + } + } + + public class CragStalagmiteGiant2 : CragStalagmiteGiant1 + { + } + + public class CragStalagmiteGiant3 : CragStalagmiteGiant1 + { + } +} \ No newline at end of file diff --git a/Tiles/Crags/Spike/CragStalagmiteGiant1.png b/Tiles/Crags/Spike/CragStalagmiteGiant1.png new file mode 100644 index 0000000000..cd48c9a8a7 Binary files /dev/null and b/Tiles/Crags/Spike/CragStalagmiteGiant1.png differ diff --git a/Tiles/Crags/Spike/CragStalagmiteGiant2.png b/Tiles/Crags/Spike/CragStalagmiteGiant2.png new file mode 100644 index 0000000000..72e22ca9bf Binary files /dev/null and b/Tiles/Crags/Spike/CragStalagmiteGiant2.png differ diff --git a/Tiles/Crags/Spike/CragStalagmiteGiant3.png b/Tiles/Crags/Spike/CragStalagmiteGiant3.png new file mode 100644 index 0000000000..045c46af0b Binary files /dev/null and b/Tiles/Crags/Spike/CragStalagmiteGiant3.png differ diff --git a/Tiles/Crags/Spike/CragStalagmiteLarge1.png b/Tiles/Crags/Spike/CragStalagmiteLarge1.png new file mode 100644 index 0000000000..a58093d4cf Binary files /dev/null and b/Tiles/Crags/Spike/CragStalagmiteLarge1.png differ diff --git a/Tiles/Crags/Spike/CragStalagmiteLarge2.png b/Tiles/Crags/Spike/CragStalagmiteLarge2.png new file mode 100644 index 0000000000..c40b894a76 Binary files /dev/null and b/Tiles/Crags/Spike/CragStalagmiteLarge2.png differ diff --git a/Tiles/Crags/Spike/CragStalagmiteLarge2x4.cs b/Tiles/Crags/Spike/CragStalagmiteLarge2x4.cs new file mode 100644 index 0000000000..2d00e16c06 --- /dev/null +++ b/Tiles/Crags/Spike/CragStalagmiteLarge2x4.cs @@ -0,0 +1,33 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; +using Terraria.DataStructures; +using Terraria.Enums; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace CalamityMod.Tiles.Crags.Spike +{ + public class CragStalagmiteLarge3 : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + TileObjectData.newTile.Width = 2; + TileObjectData.newTile.Height = 4; + TileObjectData.newTile.Origin = new Point16(1, 3); + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16, 16 }; + TileObjectData.newTile.StyleWrapLimit = 36; + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.DrawYOffset = 3; + TileObjectData.addTile(Type); + AddMapEntry(new Color(43, 23, 46)); + DustType = 155; + HitSound = SoundID.Tink; + } + } +} \ No newline at end of file diff --git a/Tiles/Crags/Spike/CragStalagmiteLarge2x5.cs b/Tiles/Crags/Spike/CragStalagmiteLarge2x5.cs new file mode 100644 index 0000000000..033f454fcb --- /dev/null +++ b/Tiles/Crags/Spike/CragStalagmiteLarge2x5.cs @@ -0,0 +1,37 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; +using Terraria.DataStructures; +using Terraria.Enums; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace CalamityMod.Tiles.Crags.Spike +{ + public class CragStalagmiteLarge1 : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + TileObjectData.newTile.Width = 2; + TileObjectData.newTile.Height = 5; + TileObjectData.newTile.Origin = new Point16(1, 4); + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16, 16, 16 }; + TileObjectData.newTile.StyleWrapLimit = 36; + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.DrawYOffset = 3; + TileObjectData.addTile(Type); + AddMapEntry(new Color(43, 23, 46)); + DustType = 155; + HitSound = SoundID.Tink; + } + } + + public class CragStalagmiteLarge2 : CragStalagmiteLarge1 + { + } +} \ No newline at end of file diff --git a/Tiles/Crags/Spike/CragStalagmiteLarge3.png b/Tiles/Crags/Spike/CragStalagmiteLarge3.png new file mode 100644 index 0000000000..71ccd11aac Binary files /dev/null and b/Tiles/Crags/Spike/CragStalagmiteLarge3.png differ diff --git a/Tiles/Crags/Spike/CragStalagmiteSmall1.png b/Tiles/Crags/Spike/CragStalagmiteSmall1.png new file mode 100644 index 0000000000..2a016fc808 Binary files /dev/null and b/Tiles/Crags/Spike/CragStalagmiteSmall1.png differ diff --git a/Tiles/Crags/Spike/CragStalagmiteSmall2.png b/Tiles/Crags/Spike/CragStalagmiteSmall2.png new file mode 100644 index 0000000000..858da12207 Binary files /dev/null and b/Tiles/Crags/Spike/CragStalagmiteSmall2.png differ diff --git a/Tiles/Crags/Spike/CragStalagmiteSmall2x2.cs b/Tiles/Crags/Spike/CragStalagmiteSmall2x2.cs new file mode 100644 index 0000000000..051fa823a2 --- /dev/null +++ b/Tiles/Crags/Spike/CragStalagmiteSmall2x2.cs @@ -0,0 +1,31 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; +using Terraria.DataStructures; +using Terraria.Enums; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace CalamityMod.Tiles.Crags.Spike +{ + public class CragStalagmiteSmall3 : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); + TileObjectData.newTile.Origin = new Point16(1, 1); + TileObjectData.newTile.StyleWrapLimit = 36; + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.DrawYOffset = 3; + TileObjectData.addTile(Type); + AddMapEntry(new Color(43, 23, 46)); + DustType = 155; + HitSound = SoundID.Tink; + } + } +} \ No newline at end of file diff --git a/Tiles/Crags/Spike/CragStalagmiteSmall2x3.cs b/Tiles/Crags/Spike/CragStalagmiteSmall2x3.cs new file mode 100644 index 0000000000..0ffa4e555d --- /dev/null +++ b/Tiles/Crags/Spike/CragStalagmiteSmall2x3.cs @@ -0,0 +1,37 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; +using Terraria.DataStructures; +using Terraria.Enums; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace CalamityMod.Tiles.Crags.Spike +{ + public class CragStalagmiteSmall1 : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + TileObjectData.newTile.Width = 2; + TileObjectData.newTile.Height = 3; + TileObjectData.newTile.Origin = new Point16(1, 2); + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16 }; + TileObjectData.newTile.StyleWrapLimit = 36; + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.DrawYOffset = 3; + TileObjectData.addTile(Type); + AddMapEntry(new Color(43, 23, 46)); + DustType = 155; + HitSound = SoundID.Tink; + } + } + + public class CragStalagmiteSmall2 : CragStalagmiteSmall1 + { + } +} \ No newline at end of file diff --git a/Tiles/Crags/Spike/CragStalagmiteSmall3.png b/Tiles/Crags/Spike/CragStalagmiteSmall3.png new file mode 100644 index 0000000000..6f59e304a9 Binary files /dev/null and b/Tiles/Crags/Spike/CragStalagmiteSmall3.png differ diff --git a/Tiles/Crags/Tree/SpineBottom.png b/Tiles/Crags/Tree/SpineBottom.png new file mode 100644 index 0000000000..282cb4a0bd Binary files /dev/null and b/Tiles/Crags/Tree/SpineBottom.png differ diff --git a/Tiles/Crags/Tree/SpineRib1Left.png b/Tiles/Crags/Tree/SpineRib1Left.png new file mode 100644 index 0000000000..92403cf0e7 Binary files /dev/null and b/Tiles/Crags/Tree/SpineRib1Left.png differ diff --git a/Tiles/Crags/Tree/SpineRib1Right.png b/Tiles/Crags/Tree/SpineRib1Right.png new file mode 100644 index 0000000000..af1b7d5f6a Binary files /dev/null and b/Tiles/Crags/Tree/SpineRib1Right.png differ diff --git a/Tiles/Crags/Tree/SpineRib2Left.png b/Tiles/Crags/Tree/SpineRib2Left.png new file mode 100644 index 0000000000..992ab812cb Binary files /dev/null and b/Tiles/Crags/Tree/SpineRib2Left.png differ diff --git a/Tiles/Crags/Tree/SpineRib2Right.png b/Tiles/Crags/Tree/SpineRib2Right.png new file mode 100644 index 0000000000..57ead12e2e Binary files /dev/null and b/Tiles/Crags/Tree/SpineRib2Right.png differ diff --git a/Tiles/Crags/Tree/SpineRib3Left.png b/Tiles/Crags/Tree/SpineRib3Left.png new file mode 100644 index 0000000000..4435bef84c Binary files /dev/null and b/Tiles/Crags/Tree/SpineRib3Left.png differ diff --git a/Tiles/Crags/Tree/SpineRib3Right.png b/Tiles/Crags/Tree/SpineRib3Right.png new file mode 100644 index 0000000000..182c9e0ee8 Binary files /dev/null and b/Tiles/Crags/Tree/SpineRib3Right.png differ diff --git a/Tiles/Crags/Tree/SpineSegments.png b/Tiles/Crags/Tree/SpineSegments.png new file mode 100644 index 0000000000..d447eedca5 Binary files /dev/null and b/Tiles/Crags/Tree/SpineSegments.png differ diff --git a/Tiles/Crags/Tree/SpineTop.png b/Tiles/Crags/Tree/SpineTop.png new file mode 100644 index 0000000000..35c40ce235 Binary files /dev/null and b/Tiles/Crags/Tree/SpineTop.png differ diff --git a/Tiles/Crags/Tree/SpineTree.cs b/Tiles/Crags/Tree/SpineTree.cs new file mode 100644 index 0000000000..23bd0fbcc2 --- /dev/null +++ b/Tiles/Crags/Tree/SpineTree.cs @@ -0,0 +1,365 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.Utilities; +using Terraria.DataStructures; +using Terraria.Audio; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using CalamityMod.Items.Placeables; +using CalamityMod.Tiles.Crags; +using System; +using System.Linq; + +namespace CalamityMod.Tiles.Crags.Tree +{ + internal class SpineTree : ModTile + { + /* + What each frame of the tree means + (refer to the sprite sheet for the colors) + X frame 0 (orange) = bottom segment + X frame 18 (dark purple) = main body segment, each of the three y-frame variants draws a different tree segment variant + X frame 36 (light purple) = top of the tree + X frame 54 (teal) = rib branch segments, each of the three y-frame variants has a different pattern where: + + for the branch segments: + y-frame 1 = left branch + y-frame 2 = right branch + y-frame 3 = both left and right branch + */ + + public override void SetStaticDefaults() + { + TileID.Sets.IsATreeTrunk[Type] = true; + Main.tileFrameImportant[Type] = true; + Main.tileAxe[Type] = true; + Main.tileMergeDirt[Type] = false; + Main.tileSolid[Type] = false; + Main.tileLighted[Type] = false; + Main.tileBlockLight[Type] = false; + ModTranslation name = CreateMapEntryName(); + name.SetDefault("Giant Spine"); + AddMapEntry(new Color(38, 25, 27), name); + DustType = 155; + HitSound = SoundID.DD2_SkeletonHurt; + ItemDrop = ModContent.ItemType(); + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + resetFrame = false; + noBreak = true; + return false; + } + + public static bool SolidTile(int i, int j) + { + return Framing.GetTileSafely(i, j).HasTile && Main.tileSolid[Framing.GetTileSafely(i, j).TileType]; + } + + public static bool SolidTopTile(int i, int j) + { + return Framing.GetTileSafely(i, j).HasTile && (Main.tileSolidTop[Framing.GetTileSafely(i, j).TileType] || + Main.tileSolid[Framing.GetTileSafely(i, j).TileType]); + } + + public static bool Spawn(int i, int j, int minSize = 5, int maxSize = 18, bool leaves = false, int leavesType = -1, bool saplingExists = false) + { + //if this tree grew from a sapling, then kill the sapling its growing from + if (saplingExists) + { + WorldGen.KillTile(i, j, false, false, true); + WorldGen.KillTile(i, j - 1, false, false, true); + } + + //set the minimum and maximum height the tree can grow to + int height = Main.rand.Next(minSize, maxSize); + for (int k = 1; k < height; ++k) + { + if (SolidTile(i, j - k)) + { + height = k - 2; + break; + } + } + + if (height < 4 || height < minSize) + { + return false; + } + + //this places the base, probably a bit weird looking here but it works + //problem is messing around with this completely broke the hell out of the tree so i refuse to modify it for now + //if someone else by some miracle can figure out how to change it, please let me know :) + bool[] extraPlaces = new bool[5]; + for (int k = -2; k <= 2; k++) + { + extraPlaces[k + 2] = false; + + if ((SolidTopTile(i + k, j + 1) || SolidTile(i + k, j + 1)) && !Framing.GetTileSafely(i + k, j).HasTile) + { + extraPlaces[k + 2] = true; + } + } + + if (!extraPlaces[1]) extraPlaces[0] = false; + if (!extraPlaces[3]) extraPlaces[4] = false; + + if (!extraPlaces[2]) + { + return false; + } + + extraPlaces = new bool[5] { false, false, true, false, false }; + + //place the actual base + for (int k = -2; k <= 2; k++) + { + if (extraPlaces[k + 2]) + { + WorldGen.PlaceTile(i + k, j, ModContent.TileType(), true); + } + else + { + continue; + } + + //always place the bottom segment on the first frame since it doesnt have variants + Framing.GetTileSafely(i + k, j).TileFrameX = 0; + Framing.GetTileSafely(i + k, j).TileFrameY = 0; + + if (!extraPlaces[1] && !extraPlaces[3] && k == 0) + { + Framing.GetTileSafely(i + k, j).TileFrameX = 0; + } + } + + int branchSegmentDelay = 0; + + for (int k = 1; k < height; k++) + { + WorldGen.PlaceTile(i, j - k, ModContent.TileType(), true); + + if (branchSegmentDelay > 0) + { + branchSegmentDelay--; + } + + //chance to place a branch segment + //also dont place branches below a certain threshold + if (Main.rand.Next(3) == 0 && branchSegmentDelay == 0 && k > 5) + { + Framing.GetTileSafely(i, j - k).TileFrameX = 3 * 18; + Framing.GetTileSafely(i, j - k).TileFrameY = (short)(Main.rand.Next(3) * 18); + branchSegmentDelay = 3; + } + //otherwise place a normal segment + else + { + Framing.GetTileSafely(i, j - k).TileFrameX = 18; + Framing.GetTileSafely(i, j - k).TileFrameY = (short)(Main.rand.Next(3) * 18); + } + + //once the top is reached, place the top segment + if (k == height - 1) + { + Framing.GetTileSafely(i, j - k).TileFrameX = 2 * 18; + Framing.GetTileSafely(i, j - k).TileFrameY = (short)(Main.rand.Next(3) * 18); + } + } + + return true; + } + + public override void NearbyEffects(int i, int j, bool closer) + { + //kill the tree tiles if there are no tiles below it + if (!Framing.GetTileSafely(i, j + 1).HasTile) + { + WorldGen.KillTile(i, j, false, false, false); + } + } + + public override bool Drop(int i, int j) + { + /* + //drop seeds from the top of the tree + if (Framing.GetTileSafely(i, j).TileFrameX == 36) + { + int totalSeeds = Main.rand.Next(1, 3); + for (int numSeed = 0; numSeed < totalSeeds; numSeed++) + { + Item.NewItem(new EntitySource_TileBreak(i, j), (new Vector2(i, j) * 16) + new Vector2(Main.rand.Next(-46, 46), + Main.rand.Next(-40, 40) - 66), ModContent.ItemType(), Main.rand.Next(1, 5)); + } + } + */ + + //chance to drop extra wood + if (Main.rand.NextBool()) + { + Item.NewItem(new EntitySource_TileBreak(i, j), (new Vector2(i, j) * 16) + new Vector2(Main.rand.Next(-46, 46), + Main.rand.Next(-40, 40) - 66), ModContent.ItemType(), Main.rand.Next(1, 2)); + } + + return true; + } + + //this checks the entire tree from bottom to top + private void CheckEntireTree(ref int x, ref int y) + { + while (Main.tile[x, y].TileType == Type) + { + y--; + } + + y++; + + if (Main.tile[x, y].TileFrameX == 16) + { + for (int k = 0; k < WorldGen.numTreeShakes; k++) + { + if (WorldGen.treeShakeX[k] == x && WorldGen.treeShakeY[k] == y) + { + return; + } + } + + WorldGen.treeShakeX[WorldGen.numTreeShakes] = x; + WorldGen.treeShakeY[WorldGen.numTreeShakes] = y; + WorldGen.numTreeShakes++; + + //this is where you can make stuff happen when the tree is shaken like in vanilla + //for example, when trees drop a fruit when you begin to break it + } + } + + public override void KillTile(int i, int j, ref bool fail, ref bool effectOnly, ref bool noItem) + { + Tile tile = Framing.GetTileSafely(i, j); + + if (fail && !effectOnly && !noItem) + { + (int x, int y) = (i, j); + CheckEntireTree(ref x, ref y); + } + + if (fail) + { + return; + } + + int belowFrame = Framing.GetTileSafely(i, j + 1).TileFrameX; + + SoundEngine.PlaySound(SoundID.DD2_SkeletonHurt, (new Vector2(i, j) * 16)); + + //here is where you can make effects happen when the tree segments break, like adding dust, dropping gore, ect + + /* + //TODO: save this since this tree will also produce bone gores when broken (gores for this tree still need assets) + Gore.NewGore(new EntitySource_TileInteraction(Main.LocalPlayer, i, j), (new Vector2(i, j - 2) * 16), + new Vector2(Main.rand.Next(-3, 3), Main.rand.Next(-3, 3)), ModContent.Find("CalamityMod/WhateverGore").Type); + */ + } + + public static Vector2 TileOffset => Lighting.LegacyEngine.Mode > 1 ? Vector2.Zero : Vector2.One * 12; + + public static Vector2 TileCustomPosition(int i, int j, Vector2? off = null) + { + return ((new Vector2(i, j) + TileOffset) * 16) - Main.screenPosition - (off ?? new Vector2(0, -2)); + } + + internal static void DrawTreeSegments(int i, int j, Texture2D tex, Rectangle? source, Vector2? offset = null, Vector2? origin = null, bool Glow = false) + { + Tile tile = Main.tile[i, j]; + Vector2 drawPos = new Vector2(i, j).ToWorldCoordinates() - Main.screenPosition + (offset ?? new Vector2(0, -2)); + Color color = Lighting.GetColor(i, j); + + Main.spriteBatch.Draw(tex, drawPos, source, Glow ? Color.White : color, 0, origin ?? source.Value.Size() / 3f, 1f, SpriteEffects.None, 0f); + } + + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) + { + Tile tile = Framing.GetTileSafely(i, j); + Color col = Lighting.GetColor(i, j); + float xOff = (float)Math.Sin((j * 19) * 0.04f) * 1.2f; + + if (xOff == 1 && (j / 4f) == 0) + { + xOff = 0; + } + + int frameSizeX = 16; + int frameSizeY = 16; + int frameOff = 0; + + Vector2 offset = new((xOff * 2) - (frameOff / 2), 0); + Vector2 pos = TileCustomPosition(i, j) - offset; + + Vector2 treeSegmentOffset = new Vector2((xOff * 2) - (frameOff / 2) + 25, 14); + Vector2 topSegmentOffset = new Vector2((xOff * 2) - (frameOff / 2) + 20, 16); + + //draw the base of the tree + if (Framing.GetTileSafely(i, j).TileFrameX == 0) + { + Texture2D segmentTex = ModContent.Request("CalamityMod/Tiles/Crags/Tree/SpineBottom").Value; + int frame = tile.TileFrameY / 18; + + DrawTreeSegments(i, j, segmentTex, new Rectangle(34 * frame, 0, 32, 20), TileOffset.ToWorldCoordinates(), treeSegmentOffset, false); + } + + //draw the different segments of the tree + if (Framing.GetTileSafely(i, j).TileFrameX == 18) + { + Texture2D segmentTex = ModContent.Request("CalamityMod/Tiles/Crags/Tree/SpineSegments").Value; + int frame = tile.TileFrameY / 18; + + DrawTreeSegments(i, j, segmentTex, new Rectangle(34 * frame, 0, 32, 20), TileOffset.ToWorldCoordinates(), treeSegmentOffset, false); + } + + //draw branch segments + if (Framing.GetTileSafely(i, j).TileFrameX == 54) + { + int frame = tile.TileFrameY / 18; + + //branch drawing stuff + Texture2D leftBranchTex = ModContent.Request("CalamityMod/Tiles/Crags/Tree/SpineRib1Left").Value; + Texture2D rightBranchTex = ModContent.Request("CalamityMod/Tiles/Crags/Tree/SpineRib1Right").Value; + + Vector2 leftBranchOffset = new Vector2((xOff * 2) - (frameOff / 2) + 50, 14); + Vector2 rightBranchOffset = new Vector2((xOff * 2) - (frameOff / 2) + 4, 14); + + //ok so, terraria just does not want to cooperate when i draw a single branch texture on the side of the tree segments + //i changed them into a horitonzal sheet with blanks in it so it gives the illusion of branches being random + //not a good idea if branches are meant to be separate tiles, but here they are purely visual so it doesnt matter + DrawTreeSegments(i, j, leftBranchTex, new Rectangle(38 * frame, 0, 38, 40), TileOffset.ToWorldCoordinates(), leftBranchOffset, false); + DrawTreeSegments(i, j, rightBranchTex, new Rectangle(38 * frame, 0, 38, 40), TileOffset.ToWorldCoordinates(), rightBranchOffset, false); + + //draw segments + Texture2D segmentTex = ModContent.Request("CalamityMod/Tiles/Crags/Tree/SpineSegments").Value; + + DrawTreeSegments(i, j, segmentTex, new Rectangle(34 * frame, 0, 32, 20), TileOffset.ToWorldCoordinates(), treeSegmentOffset, false); + } + + //draw top segment + if (Framing.GetTileSafely(i, j).TileFrameX == 36) + { + Texture2D topTex = ModContent.Request("CalamityMod/Tiles/Crags/Tree/SpineTop").Value; + int frame = tile.TileFrameY / 18; + + DrawTreeSegments(i, j, topTex, new Rectangle(26 * frame, 0, 24, 24), TileOffset.ToWorldCoordinates(), topSegmentOffset, false); + } + + return false; + } + + /* + //this is where you can draw any glowmasks, if needed + //literally all you have to do is copy all the code from predraw and just get the glowmask textures instead of the regular ones + public override void PostDraw(int i, int j, SpriteBatch spriteBatch) + { + } + */ + } +} diff --git a/Tiles/Crags/Tree/SpineTree.png b/Tiles/Crags/Tree/SpineTree.png new file mode 100644 index 0000000000..940dc94972 Binary files /dev/null and b/Tiles/Crags/Tree/SpineTree.png differ diff --git a/Tiles/Ores/AerialiteOre.cs b/Tiles/Ores/AerialiteOre.cs index b35e5024cd..56fd7a74ee 100644 --- a/Tiles/Ores/AerialiteOre.cs +++ b/Tiles/Ores/AerialiteOre.cs @@ -19,6 +19,10 @@ namespace CalamityMod.Tiles.Ores TileID.Sets.OreMergesWithMud[Type] = true; CalamityUtils.MergeWithGeneral(Type); + CalamityUtils.SetMerge(Type, TileID.Cloud); + + TileID.Sets.ChecksForMerge[Type] = true; + ItemDrop = ModContent.ItemType(); ModTranslation name = CreateMapEntryName(); name.SetDefault("Aerialite"); @@ -33,5 +37,10 @@ namespace CalamityMod.Tiles.Ores { num = fail ? 1 : 3; } + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + TileFraming.CustomMergeFrame(i, j, Type, TileID.Cloud); + return false; + } } } diff --git a/Tiles/Ores/AerialiteOre.png b/Tiles/Ores/AerialiteOre.png index 973ec03628..e67bf09f95 100644 Binary files a/Tiles/Ores/AerialiteOre.png and b/Tiles/Ores/AerialiteOre.png differ diff --git a/Tiles/SunkenSea/BrainCoral.cs b/Tiles/SunkenSea/BrainCoral.cs index d3a1984f9c..75c3c24c15 100644 --- a/Tiles/SunkenSea/BrainCoral.cs +++ b/Tiles/SunkenSea/BrainCoral.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Tiles.SunkenSea DustType = 253; ModTranslation name = CreateMapEntryName(); name.SetDefault("Brain Coral"); - AddMapEntry(new Color(0, 0, 80)); + AddMapEntry(new Color(36, 61, 111)); MineResist = 3f; base.SetStaticDefaults(); diff --git a/Tiles/SunkenSea/FanCoral.cs b/Tiles/SunkenSea/FanCoral.cs index d345f8ca59..1a5fb65deb 100644 --- a/Tiles/SunkenSea/FanCoral.cs +++ b/Tiles/SunkenSea/FanCoral.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Tiles.SunkenSea DustType = 253; ModTranslation name = CreateMapEntryName(); name.SetDefault("Fan Coral"); - AddMapEntry(new Color(0, 0, 80)); + AddMapEntry(new Color(54, 69, 72)); MineResist = 3f; base.SetStaticDefaults(); diff --git a/Tiles/SunkenSea/SeaAnemone.cs b/Tiles/SunkenSea/SeaAnemone.cs index a54d426ec0..3506fe6c16 100644 --- a/Tiles/SunkenSea/SeaAnemone.cs +++ b/Tiles/SunkenSea/SeaAnemone.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Tiles.SunkenSea DustType = 253; ModTranslation name = CreateMapEntryName(); name.SetDefault("Sea Anemone"); - AddMapEntry(new Color(0, 0, 80)); + AddMapEntry(new Color(54, 69, 72)); MineResist = 2f; base.SetStaticDefaults(); diff --git a/Tiles/SunkenSea/SmallBrainCoral.cs b/Tiles/SunkenSea/SmallBrainCoral.cs index 4e74c643e4..49ab406f7e 100644 --- a/Tiles/SunkenSea/SmallBrainCoral.cs +++ b/Tiles/SunkenSea/SmallBrainCoral.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Tiles.SunkenSea DustType = 253; ModTranslation name = CreateMapEntryName(); name.SetDefault("Small Brain Coral"); - AddMapEntry(new Color(0, 0, 80)); + AddMapEntry(new Color(36, 61, 111)); MineResist = 3f; base.SetStaticDefaults(); diff --git a/Tiles/SunkenSea/SmallTubeCoral.cs b/Tiles/SunkenSea/SmallTubeCoral.cs index f471602d1f..c433c90852 100644 --- a/Tiles/SunkenSea/SmallTubeCoral.cs +++ b/Tiles/SunkenSea/SmallTubeCoral.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Tiles.SunkenSea DustType = 253; ModTranslation name = CreateMapEntryName(); name.SetDefault("Small Tube Coral"); - AddMapEntry(new Color(0, 0, 80)); + AddMapEntry(new Color(36, 61, 111)); MineResist = 3f; base.SetStaticDefaults(); diff --git a/Tiles/SunkenSea/SunkenSeaStalactite.cs b/Tiles/SunkenSea/SunkenSeaStalactite.cs deleted file mode 100644 index 143e5cf61f..0000000000 --- a/Tiles/SunkenSea/SunkenSeaStalactite.cs +++ /dev/null @@ -1,44 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ModLoader; -namespace CalamityMod.Tiles.SunkenSea -{ - public class SunkenSeaStalactite : ModTile - { - public override void SetStaticDefaults() - { - Main.tileFrameImportant[Type] = true; - Main.tileNoFail[Type] = true; - Main.tileObsidianKill[Type] = true; - Main.tileBlockLight[Type] = true; - DustType = 96; - AddMapEntry(new Color(0, 50, 50)); - - base.SetStaticDefaults(); - } - - public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) - { - Tile tile = Main.tile[i, j]; - if (tile.TileFrameY <= 18 || tile.TileFrameY == 72) - { - offsetY = -2; - } - else if ((tile.TileFrameY >= 36 && tile.TileFrameY <= 54) || tile.TileFrameY == 90) - { - offsetY = 2; - } - } - - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - WorldGen.CheckTight(i, j); - return false; - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 4; - } - } -} diff --git a/Tiles/SunkenSea/SunkenSeaStalactite.png b/Tiles/SunkenSea/SunkenSeaStalactite.png deleted file mode 100644 index 7ed7c07179..0000000000 Binary files a/Tiles/SunkenSea/SunkenSeaStalactite.png and /dev/null differ diff --git a/Tiles/SunkenSea/SunkenStalactites.cs b/Tiles/SunkenSea/SunkenStalactites.cs new file mode 100644 index 0000000000..c06715ed61 --- /dev/null +++ b/Tiles/SunkenSea/SunkenStalactites.cs @@ -0,0 +1,31 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.Enums; +using Terraria.ObjectData; +using Terraria.DataStructures; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; + +namespace CalamityMod.Tiles.SunkenSea +{ + public class SunkenStalactites : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoAttach[Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style1x2); + TileObjectData.newTile.AnchorTop = new AnchorData(AnchorType.SolidTile, TileObjectData.newTile.Width, 0); + TileObjectData.newTile.AnchorBottom = default(AnchorData); + TileObjectData.addTile(Type); + DustType = 253; + ModTranslation name = CreateMapEntryName(); + AddMapEntry(new Color(31, 92, 114)); + MineResist = 3f; + + base.SetStaticDefaults(); + } + } +} \ No newline at end of file diff --git a/Tiles/SunkenSea/SunkenStalactites.png b/Tiles/SunkenSea/SunkenStalactites.png new file mode 100644 index 0000000000..a620f4b89e Binary files /dev/null and b/Tiles/SunkenSea/SunkenStalactites.png differ diff --git a/Tiles/SunkenSea/SunkenStalactitesSmall.cs b/Tiles/SunkenSea/SunkenStalactitesSmall.cs new file mode 100644 index 0000000000..388a45b9dc --- /dev/null +++ b/Tiles/SunkenSea/SunkenStalactitesSmall.cs @@ -0,0 +1,31 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.Enums; +using Terraria.ObjectData; +using Terraria.DataStructures; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; + +namespace CalamityMod.Tiles.SunkenSea +{ + public class SunkenStalactitesSmall : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoAttach[Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style1x1); + TileObjectData.newTile.AnchorTop = new AnchorData(AnchorType.SolidTile, TileObjectData.newTile.Width, 0); + TileObjectData.newTile.AnchorBottom = default(AnchorData); + TileObjectData.addTile(Type); + DustType = 253; + ModTranslation name = CreateMapEntryName(); + AddMapEntry(new Color(31, 92, 114)); + MineResist = 3f; + + base.SetStaticDefaults(); + } + } +} \ No newline at end of file diff --git a/Tiles/SunkenSea/SunkenStalactitesSmall.png b/Tiles/SunkenSea/SunkenStalactitesSmall.png new file mode 100644 index 0000000000..4fd5dd587c Binary files /dev/null and b/Tiles/SunkenSea/SunkenStalactitesSmall.png differ diff --git a/Tiles/SunkenSea/SunkenStalagmites.cs b/Tiles/SunkenSea/SunkenStalagmites.cs new file mode 100644 index 0000000000..5161a828cc --- /dev/null +++ b/Tiles/SunkenSea/SunkenStalagmites.cs @@ -0,0 +1,29 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.Enums; +using Terraria.ObjectData; +using Terraria.DataStructures; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; + +namespace CalamityMod.Tiles.SunkenSea +{ + public class SunkenStalagmites : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoAttach[Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style1x2); + TileObjectData.addTile(Type); + DustType = 253; + ModTranslation name = CreateMapEntryName(); + AddMapEntry(new Color(31, 92, 114)); + MineResist = 3f; + + base.SetStaticDefaults(); + } + } +} \ No newline at end of file diff --git a/Tiles/SunkenSea/SunkenStalagmites.png b/Tiles/SunkenSea/SunkenStalagmites.png new file mode 100644 index 0000000000..d82d67ca1e Binary files /dev/null and b/Tiles/SunkenSea/SunkenStalagmites.png differ diff --git a/Tiles/SunkenSea/SunkenStalagmitesSmall.cs b/Tiles/SunkenSea/SunkenStalagmitesSmall.cs new file mode 100644 index 0000000000..6aad893e52 --- /dev/null +++ b/Tiles/SunkenSea/SunkenStalagmitesSmall.cs @@ -0,0 +1,29 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.Enums; +using Terraria.ObjectData; +using Terraria.DataStructures; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; + +namespace CalamityMod.Tiles.SunkenSea +{ + public class SunkenStalagmitesSmall : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoAttach[Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style1x1); + TileObjectData.addTile(Type); + DustType = 253; + ModTranslation name = CreateMapEntryName(); + AddMapEntry(new Color(31, 92, 114)); + MineResist = 3f; + + base.SetStaticDefaults(); + } + } +} \ No newline at end of file diff --git a/Tiles/SunkenSea/SunkenStalagmitesSmall.png b/Tiles/SunkenSea/SunkenStalagmitesSmall.png new file mode 100644 index 0000000000..6a1d01c5c1 Binary files /dev/null and b/Tiles/SunkenSea/SunkenStalagmitesSmall.png differ diff --git a/Tiles/SunkenSea/TableCoral.cs b/Tiles/SunkenSea/TableCoral.cs index ee89e12920..0552d076b3 100644 --- a/Tiles/SunkenSea/TableCoral.cs +++ b/Tiles/SunkenSea/TableCoral.cs @@ -26,7 +26,7 @@ namespace CalamityMod.Tiles.SunkenSea DustType = 253; ModTranslation name = CreateMapEntryName(); name.SetDefault("Table Coral"); - AddMapEntry(new Color(0, 0, 80)); + AddMapEntry(new Color(54, 69, 72)); MineResist = 3f; base.SetStaticDefaults(); diff --git a/Tiles/SunkenSea/TubeCoral.cs b/Tiles/SunkenSea/TubeCoral.cs index 397461e1aa..7811364e1b 100644 --- a/Tiles/SunkenSea/TubeCoral.cs +++ b/Tiles/SunkenSea/TubeCoral.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Tiles.SunkenSea DustType = 253; ModTranslation name = CreateMapEntryName(); name.SetDefault("Tube Coral"); - AddMapEntry(new Color(0, 0, 80)); + AddMapEntry(new Color(36, 61, 111)); MineResist = 3f; base.SetStaticDefaults(); diff --git a/Utilities/TileFraming.cs b/Utilities/TileFraming.cs index 092f203a32..dd79ddb252 100644 --- a/Utilities/TileFraming.cs +++ b/Utilities/TileFraming.cs @@ -61,6 +61,7 @@ namespace CalamityMod PlantCheckAgainst[TileID.CrimsonPlants] = new int[1] { TileID.CrimsonPlants }; PlantCheckAgainst[ModContent.TileType()] = new int[1] { ModContent.TileType() }; PlantCheckAgainst[ModContent.TileType()] = new int[1] { ModContent.TileType() }; + PlantCheckAgainst[ModContent.TileType()] = new int[1] { ModContent.TileType() }; VineToGrass = new Dictionary { diff --git a/Utilities/TileUtils.cs b/Utilities/TileUtils.cs index fee51387f9..2902ed69aa 100644 --- a/Utilities/TileUtils.cs +++ b/Utilities/TileUtils.cs @@ -435,6 +435,9 @@ namespace CalamityMod TileID.ObsidianBrick, TileID.HellstoneBrick, TileType(), + TileType(), + TileType(), + TileType(), }); /// diff --git a/Utilities/WorldgenUtils.cs b/Utilities/WorldgenUtils.cs index aa88bc0cba..87cd55f6fa 100644 --- a/Utilities/WorldgenUtils.cs +++ b/Utilities/WorldgenUtils.cs @@ -1,5 +1,6 @@ using Terraria; using Terraria.ID; +using Terraria.ModLoader; using Terraria.DataStructures; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -36,6 +37,48 @@ namespace CalamityMod } } + //place a circular clump of tiles + public static void NaturalCircle(int i, int j, int size, int tileType) + { + int BaseRadius = size; + int radius = BaseRadius; + + for (int y = j - radius; y <= j + radius; y++) + { + for (int x = i - radius; x <= i + radius + 1; x++) + { + if ((int)Vector2.Distance(new Vector2(x, y), new Vector2(i, j)) <= radius && WorldGen.InWorld(x, y)) + { + Tile tile = Framing.GetTileSafely(x, y); + + WorldGen.KillTile(x, y); + WorldGen.PlaceTile(x, y, tileType); + tile.Slope = 0; + } + } + + radius = BaseRadius - WorldGen.genRand.Next(-1, 2); + } + } + + //for some reason orerunner wasnt working with clouds, so just have a seperate thing for aerialite here + public static void SpawnAerialiteOre() + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + for (int x = 5; x < Main.maxTilesX - 5; x++) + { + for (int y = 5; y < 300; y++) + { + if (WorldGen.genRand.Next(350) == 0 && Main.tile[x, y].TileType == TileID.Cloud) + { + NaturalCircle(x, y, WorldGen.genRand.Next(1, 4), ModContent.TileType()); + } + } + } + } + } + /// /// Settles all liquids in the world. /// @@ -74,7 +117,7 @@ namespace CalamityMod } } - //tile runner, probably useful for caves and probably other useful stuff? + //tile runner, useful for caves and other stuff public class TileRunner { public Vector2 pos; @@ -180,4 +223,17 @@ namespace CalamityMod tile.LiquidAmount = 255; } } + + class LavaTileRunner : TileRunner + { + public LavaTileRunner(Vector2 pos, Vector2 speed, Point16 hRange, Point16 vRange, double strength, int steps, ushort type, bool addTile, bool overRide) : base(pos, speed, hRange, vRange, strength, steps, type, addTile, overRide) + { + } + public override void ChangeTile(Tile tile) + { + tile.HasTile = false; + tile.LiquidType = LiquidID.Lava; + tile.LiquidAmount = 255; + } + } } diff --git a/Walls/AbyssGravelWall.png b/Walls/AbyssGravelWall.png index 90a8303f16..663bfa049a 100644 Binary files a/Walls/AbyssGravelWall.png and b/Walls/AbyssGravelWall.png differ diff --git a/Walls/AbyssGravelWallSafe.png b/Walls/AbyssGravelWallSafe.png index b486909ee3..b01e323001 100644 Binary files a/Walls/AbyssGravelWallSafe.png and b/Walls/AbyssGravelWallSafe.png differ diff --git a/Walls/BrimstoneSlabWall.cs b/Walls/BrimstoneSlabWall.cs index aac2e7237a..086a7b8d03 100644 --- a/Walls/BrimstoneSlabWall.cs +++ b/Walls/BrimstoneSlabWall.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Walls { Main.wallHouse[Type] = true; ItemDrop = ModContent.ItemType(); - AddMapEntry(new Color(24, 16, 29)); + AddMapEntry(new Color(41, 34, 43)); } public override bool CreateDust(int i, int j, ref int type) diff --git a/Waters/AstralWater.cs b/Waters/AstralWater.cs index 75ef019ee3..98aaa8d93a 100644 --- a/Waters/AstralWater.cs +++ b/Waters/AstralWater.cs @@ -1,5 +1,8 @@ -using Microsoft.Xna.Framework; +using Terraria; using Terraria.ModLoader; +using ReLogic.Content; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; namespace CalamityMod.Waters { @@ -20,6 +23,16 @@ namespace CalamityMod.Waters return ModContent.Find("CalamityMod/AstralWaterDroplet").Type; } + public override Asset GetRainTexture() + { + return ModContent.Request("CalamityMod/ExtraTextures/VanillaReplacements/RainAstral"); + } + + public override byte GetRainVariant() + { + return (byte)Main.rand.Next(3); + } + public override Color BiomeHairColor() { return Color.MediumPurple; diff --git a/Waters/CragsLava.png b/Waters/CragsLava.png index 8039047658..54571d96df 100644 Binary files a/Waters/CragsLava.png and b/Waters/CragsLava.png differ diff --git a/Waters/CragsLavaStyle.cs b/Waters/CragsLavaStyle.cs index 999ffd7d12..86c150e699 100644 --- a/Waters/CragsLavaStyle.cs +++ b/Waters/CragsLavaStyle.cs @@ -25,7 +25,6 @@ namespace CalamityMod.Waters public override void SelectLightColor(ref Color initialLightColor) { initialLightColor = Color.Lerp(initialLightColor, Color.White, 0.5f); - initialLightColor = Color.Lerp(initialLightColor, Color.DarkRed, 0.45f); initialLightColor.A = 255; } } diff --git a/Waters/CragsLava_Block.png b/Waters/CragsLava_Block.png index 530bc3d0d6..2c36f5a88a 100644 Binary files a/Waters/CragsLava_Block.png and b/Waters/CragsLava_Block.png differ diff --git a/Waters/CragsLava_Slope.png b/Waters/CragsLava_Slope.png index 18e07be5d7..10d6495401 100644 Binary files a/Waters/CragsLava_Slope.png and b/Waters/CragsLava_Slope.png differ diff --git a/Waters/CragsLavaflow.png b/Waters/CragsLavaflow.png index 0df9555c05..75eb21e0dc 100644 Binary files a/Waters/CragsLavaflow.png and b/Waters/CragsLavaflow.png differ diff --git a/Waters/SulphuricWater.cs b/Waters/SulphuricWater.cs index 2e3de550c8..9305bde5d0 100644 --- a/Waters/SulphuricWater.cs +++ b/Waters/SulphuricWater.cs @@ -1,5 +1,8 @@ -using Microsoft.Xna.Framework; +using Terraria; using Terraria.ModLoader; +using ReLogic.Content; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; namespace CalamityMod.Waters { @@ -20,6 +23,16 @@ namespace CalamityMod.Waters return 708; } + public override Asset GetRainTexture() + { + return ModContent.Request("CalamityMod/ExtraTextures/VanillaReplacements/RainSulphSea"); + } + + public override byte GetRainVariant() + { + return (byte)Main.rand.Next(3); + } + public override Color BiomeHairColor() { return Color.Turquoise; diff --git a/Waters/SunkenSeaWater.png b/Waters/SunkenSeaWater.png index 75032ee095..55938da31d 100644 Binary files a/Waters/SunkenSeaWater.png and b/Waters/SunkenSeaWater.png differ diff --git a/Waters/SunkenSeaWater_Block.png b/Waters/SunkenSeaWater_Block.png index 0194ffae12..9aecd8d559 100644 Binary files a/Waters/SunkenSeaWater_Block.png and b/Waters/SunkenSeaWater_Block.png differ diff --git a/Waters/SunkenSeaWaterflow.png b/Waters/SunkenSeaWaterflow.png index 5130afd9e1..f1a381e0c8 100644 Binary files a/Waters/SunkenSeaWaterflow.png and b/Waters/SunkenSeaWaterflow.png differ diff --git a/World/Abyss.cs b/World/Abyss.cs index 3d0b30e8ab..42c28eccf1 100644 --- a/World/Abyss.cs +++ b/World/Abyss.cs @@ -49,17 +49,10 @@ namespace CalamityMod.World for (int abyssIndex2 = 0; abyssIndex2 < abyssChasmY; abyssIndex2++) { Tile tile = Framing.GetTileSafely(abyssIndex, abyssIndex2); - bool canConvert = tile.HasTile && - tile.TileType < TileID.Count && - tile.TileType != TileID.DyePlants && - tile.TileType != TileID.Trees && - tile.TileType != TileID.PalmTree && - tile.TileType != TileID.Sand && - tile.TileType != TileID.Containers && - tile.TileType != TileID.Coral && - tile.TileType != TileID.BeachPiles && - tile.TileType != ModContent.TileType() && - tile.TileType != ModContent.TileType(); + bool canConvert = tile.HasTile && tile.TileType < TileID.Count && tile.TileType != TileID.DyePlants && tile.TileType != TileID.Trees && + tile.TileType != TileID.PalmTree && tile.TileType != TileID.Sand && tile.TileType != TileID.Containers && tile.TileType != TileID.Coral && + tile.TileType != TileID.BeachPiles && tile.TileType != ModContent.TileType() && tile.TileType != ModContent.TileType(); + if (abyssIndex2 > rockLayer - WorldGen.genRand.Next(30)) { if (abyssIndex > abyssChasmX + 75 - WorldGen.genRand.Next(30)) @@ -105,11 +98,23 @@ namespace CalamityMod.World tile.TileType = (ushort)ModContent.TileType(); tile.WallType = (ushort)ModContent.WallType(); } - else if (abyssIndex2 > (rockLayer + y * 0.143) && WorldGen.genRand.NextBool(3)) + else if (abyssIndex2 > (rockLayer + y * 0.142) && WorldGen.genRand.NextBool(3)) { tile.TileType = (ushort)ModContent.TileType(); tile.WallType = (ushort)ModContent.WallType(); } + else if (abyssIndex2 > (rockLayer + y * 0.145)) + { + if (WorldGen.genRand.NextBool(3)) + { + tile.TileType = (ushort)ModContent.TileType(); + } + else + { + tile.TileType = (ushort)ModContent.TileType(); + } + tile.WallType = (ushort)ModContent.WallType(); + } else { tile.TileType = (ushort)ModContent.TileType(); @@ -124,15 +129,27 @@ namespace CalamityMod.World tile.TileType = (ushort)ModContent.TileType(); tile.WallType = (ushort)ModContent.WallType(); } - else if (abyssIndex2 > (rockLayer + y * 0.143) && WorldGen.genRand.NextBool(3)) + else if (abyssIndex2 > (rockLayer + y * 0.142) && WorldGen.genRand.NextBool(3)) { tile.TileType = (ushort)ModContent.TileType(); tile.WallType = (ushort)ModContent.WallType(); } + else if (abyssIndex2 > (rockLayer + y * 0.145)) + { + if (WorldGen.genRand.NextBool(3)) + { + tile.TileType = (ushort)ModContent.TileType(); + } + else + { + tile.TileType = (ushort)ModContent.TileType(); + } + tile.WallType = (ushort)ModContent.WallType(); + } else { - tile.WallType = (ushort)ModContent.WallType(); tile.TileType = (ushort)ModContent.TileType(); + tile.WallType = (ushort)ModContent.WallType(); } } } @@ -147,15 +164,10 @@ namespace CalamityMod.World for (int abyssIndex2 = 0; abyssIndex2 < abyssChasmY; abyssIndex2++) { Tile tile = Framing.GetTileSafely(abyssIndex, abyssIndex2); - bool canConvert = tile.HasTile && - tile.TileType < TileID.Count && - tile.TileType != TileID.DyePlants && - tile.TileType != TileID.Trees && - tile.TileType != TileID.PalmTree && - tile.TileType != TileID.Sand && - tile.TileType != TileID.Containers && - tile.TileType != TileID.Coral && - tile.TileType != TileID.BeachPiles; + bool canConvert = tile.HasTile && tile.TileType < TileID.Count && tile.TileType != TileID.DyePlants && tile.TileType != TileID.Trees && + tile.TileType != TileID.PalmTree && tile.TileType != TileID.Sand && tile.TileType != TileID.Containers && tile.TileType != TileID.Coral && + tile.TileType != TileID.BeachPiles && tile.TileType != ModContent.TileType() && tile.TileType != ModContent.TileType(); + if (abyssIndex2 > rockLayer - WorldGen.genRand.Next(30)) { if (abyssIndex < abyssChasmX - 75) @@ -201,11 +213,23 @@ namespace CalamityMod.World tile.TileType = (ushort)ModContent.TileType(); tile.WallType = (ushort)ModContent.WallType(); } - else if (abyssIndex2 > (rockLayer + y * 0.143) && WorldGen.genRand.NextBool(3)) + else if (abyssIndex2 > (rockLayer + y * 0.140) && WorldGen.genRand.NextBool(3)) { tile.TileType = (ushort)ModContent.TileType(); tile.WallType = (ushort)ModContent.WallType(); } + else if (abyssIndex2 > (rockLayer + y * 0.145)) + { + if (WorldGen.genRand.NextBool(3)) + { + tile.TileType = (ushort)ModContent.TileType(); + } + else + { + tile.TileType = (ushort)ModContent.TileType(); + } + tile.WallType = (ushort)ModContent.WallType(); + } else { tile.TileType = (ushort)ModContent.TileType(); @@ -220,15 +244,27 @@ namespace CalamityMod.World tile.TileType = (ushort)ModContent.TileType(); tile.WallType = (ushort)ModContent.WallType(); } - else if (abyssIndex2 > (rockLayer + y * 0.143) && WorldGen.genRand.NextBool(3)) + else if (abyssIndex2 > (rockLayer + y * 0.140) && WorldGen.genRand.NextBool(3)) { tile.TileType = (ushort)ModContent.TileType(); tile.WallType = (ushort)ModContent.WallType(); } + else if (abyssIndex2 > (rockLayer + y * 0.145)) + { + if (WorldGen.genRand.NextBool(3)) + { + tile.TileType = (ushort)ModContent.TileType(); + } + else + { + tile.TileType = (ushort)ModContent.TileType(); + } + tile.WallType = (ushort)ModContent.WallType(); + } else { - tile.WallType = (ushort)ModContent.WallType(); tile.TileType = (ushort)ModContent.TileType(); + tile.WallType = (ushort)ModContent.WallType(); } } } @@ -316,6 +352,7 @@ namespace CalamityMod.World { for (int abyssIndex2 = 0; abyssIndex2 < abyssChasmY; abyssIndex2++) { + //pots if (!Main.tile[abyssIndex, abyssIndex2].HasTile) { if (WorldGen.SolidTile(abyssIndex, abyssIndex2 + 1) && @@ -346,6 +383,7 @@ namespace CalamityMod.World { for (int abyssIndex2 = 0; abyssIndex2 < abyssChasmY; abyssIndex2++) { + //pots if (!Main.tile[abyssIndex, abyssIndex2].HasTile) { if (WorldGen.SolidTile(abyssIndex, abyssIndex2 + 1) && @@ -814,4 +852,4 @@ namespace CalamityMod.World } #endregion } -} +} \ No newline at end of file diff --git a/World/AstralBiome.cs b/World/AstralBiome.cs index abe5393a44..b5b1711bdc 100644 --- a/World/AstralBiome.cs +++ b/World/AstralBiome.cs @@ -18,6 +18,9 @@ using Terraria.WorldBuilding; namespace CalamityMod.World { + //DylanDoe's TODO: + //change the astral monolith thing so it places away from the meteor, chosen side possibly based on the side of the world? + //raise the astral biome generation height limit to prevent things like mountain tops not being fully replaced, ect public class AstralBiome { public static readonly SoundStyle MeteorSound = new("CalamityMod/Sounds/Custom/AstralStarFall"); @@ -134,6 +137,7 @@ namespace CalamityMod.World while (y < Main.maxTilesY) { //check to place the astral meteor on valid tiles, place automatically on ebonstone walls, and avoid platforms + //TODO: at this point just make a list of invalid tiles the meteor cannot be placed on if (((Main.tile[x, y].HasTile && Main.tileSolid[(int)Main.tile[x, y].TileType]) || Main.tile[x, y].WallType == 3) && !TileID.Sets.Platforms[Main.tile[x, y].TileType]) { int suitableTiles = 0; @@ -395,68 +399,27 @@ namespace CalamityMod.World if (j < 181) j = 181; - int checkWidth = 180; - float averageHeight = 0f; - float lowestHeight = 0f; + int xOffset = WorldGen.dungeonX < Main.maxTilesX / 2 ? WorldGen.genRand.Next(-80, -40) : WorldGen.genRand.Next(40, 80); - int xAreaToSpawn = i; - - Dictionary xAreaHeightMap = new Dictionary(); - - // Gauge the bumpiness of various potential locations. - // The least bumpy one will be selected as the place to spawn the monolith. - for (int tries = 0; tries < 30; tries++) + bool altarPlaced = false; + while (!altarPlaced) { - int x = i + Main.rand.Next(-60, 61); + int x = i + xOffset; + int y = j - 100; - // Don't attempt to add duplicate keys. - if (xAreaHeightMap.ContainsKey(x)) - continue; - - float averageRelativeHeight = 0f; - for (int dx = -30; dx <= 30; dx++) + while (!WorldGen.SolidTile(x, y) && y <= Main.worldSurface) { - WorldUtils.Find(new Point(x + dx, j - 180), Searches.Chain(new Searches.Down(360), new Conditions.IsSolid()), out Point result); - averageRelativeHeight += Math.Abs(result.Y - j); + y += 5; } - averageRelativeHeight /= 60f; - xAreaHeightMap.Add(x, averageRelativeHeight); - } - i = xAreaHeightMap.OrderBy(x => x.Value).First().Key; - - for (int x = i - checkWidth / 2; x < i + checkWidth / 2; x++) - { - int y = j - 200; - Tile tileAtPosition = CalamityUtils.ParanoidTileRetrieval(x, y); - while (!Main.tileSolid[tileAtPosition.TileType] || - !tileAtPosition.HasTile || - TileID.Sets.Platforms[tileAtPosition.TileType]) + if (Main.tile[x, y].HasTile || Main.tile[x, y].WallType > 0) { - y++; - if (y > j - 10) - break; - tileAtPosition = CalamityUtils.ParanoidTileRetrieval(x, y); + bool place = true; + SchematicManager.PlaceSchematic>(SchematicManager.AstralBeaconKey, new Point(x, y - 5), SchematicAnchor.Center, ref place); + + altarPlaced = true; } - lowestHeight = (int)MathHelper.Max(lowestHeight, y); - averageHeight += y; } - lowestHeight -= 35f; - averageHeight /= checkWidth; - float height = lowestHeight; - - // If there's a sudden change between the average and lowest height (which is indicative of holes/chasms), go with the average. - if (Math.Abs(lowestHeight - averageHeight) > 50f) - height = averageHeight; - - // WorldGen.gen prevents NewItem from working, and thus prevents a bunch of dumb items from being spawned immediately and deleting the WoF/Aureus loot in the process. - WorldGen.gen = true; - // Add the average height of a tree to the Y position to offset trees usually messing with the calculation. - // Then also add 10 blocks because these things seem to always like to appear standing on the floor. - int finalVerticalOffset = 18; - bool _ = true; - SchematicManager.PlaceSchematic>(SchematicManager.AstralBeaconKey, new Point(i, (int)height + finalVerticalOffset), SchematicAnchor.Center, ref _); - WorldGen.gen = false; } } return true; @@ -1237,7 +1200,7 @@ namespace CalamityMod.World if (collapse) //Collapse ensures the ellipse is shrunk down a lot in terms of distance. { float distY = center.Y - point.Y; - point.Y -= distY * 8f; + point.Y -= distY * 3f; } float distance1 = Vector2.Distance(point, focus1); float distance2 = Vector2.Distance(point, focus2); diff --git a/World/BrimstoneCrag.cs b/World/BrimstoneCrag.cs new file mode 100644 index 0000000000..530e9fc9f9 --- /dev/null +++ b/World/BrimstoneCrag.cs @@ -0,0 +1,447 @@ +using CalamityMod.Tiles.Crags; +using CalamityMod.Tiles.Crags.Spike; +using CalamityMod.Tiles.Crags.Tree; +using CalamityMod.Tiles.Ores; +using CalamityMod.Walls; +using CalamityMod.Schematics; +using static CalamityMod.Schematics.SchematicManager; +using Terraria; +using Terraria.IO; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.DataStructures; +using Terraria.WorldBuilding; +using Terraria.Utilities; +using Terraria.GameContent.Generation; +using Microsoft.Xna.Framework; +using System; +using System.Linq; +using System.Collections.Generic; + +namespace CalamityMod.World +{ + public class BrimstoneCrag + { + static int StartX = 0; + + static int lavaLakePlaceDelay = 0; + static int lavaLakeBigPlaceDelay = 0; + + static int TreeDelay = 0; + + //basic terrain (sorry for the excessive amount of loops lmao) + private static void GenCrags() + { + //set this here so it can properly scale to the worldsize and whatever + //the 25's are there to offset it from the exact edge of the world so no "out of bounds" crashing occurs + StartX = WorldGen.dungeonX < Main.maxTilesX / 2 ? 25 : (Main.maxTilesX - (Main.maxTilesX / 5)) - 25; + + //set these to be able to easily place things in certain locations, like structures + int biomeStart = StartX; + int biomeEdge = biomeStart + (Main.maxTilesX / 5); + int biomeMiddle = (biomeStart + biomeEdge) / 2; + + //clear all blocks and lava in the area + for (int x = biomeStart; x <= biomeEdge; x++) + { + for (int y = Main.maxTilesY - 200; y < Main.maxTilesY - 2; y++) + { + Tile tile = Main.tile[x, y]; + tile.ClearEverything(); + WorldGen.KillWall(x, y); + } + } + + //place basic rectangle of brimstone slag + for (int x = biomeStart; x <= biomeEdge; x++) + { + for (int y = Main.maxTilesY - 90; y <= Main.maxTilesY - 5; y++) + { + WorldGen.PlaceTile(x, y, (ushort)ModContent.TileType()); + Main.tile[x, y + 5].WallType = (ushort)ModContent.WallType(); + } + } + + //place clusters of slag around the edges of the main square to create a more interesting shape + for (int x = biomeStart; x <= biomeEdge; x++) + { + for (int y = Main.maxTilesY - 110; y <= Main.maxTilesY - 5; y++) + { + Tile tile = Main.tile[x, y]; + Tile tileUp = Main.tile[x, y - 1]; + Tile tileDown = Main.tile[x, y + 1]; + Tile tileLeft = Main.tile[x - 1, y]; + Tile tileRight = Main.tile[x + 1, y]; + + if (tile.TileType == ModContent.TileType() && (tileUp.TileType != ModContent.TileType() || + tileDown.TileType != ModContent.TileType() || tileLeft.TileType != ModContent.TileType() || + tileRight.TileType != ModContent.TileType())) + { + CalamityUtils.NaturalCircle(x, y, WorldGen.genRand.Next(5, 22), ModContent.TileType()); + } + } + } + + //scorched remains patches + for (int x = biomeStart + 30; x <= biomeEdge - 30; x++) + { + if (WorldGen.genRand.Next(150) == 0) + { + ScorchedGrassPatches(new Point(x, Main.maxTilesY - 135)); + } + } + + //place ceiling across the top of the biome + for (int x = biomeStart; x <= biomeEdge; x++) + { + for (int y = Main.maxTilesY - 200; y <= Main.maxTilesY - 192; y++) + { + if (WorldGen.genRand.Next(25) == 0) + { + CalamityUtils.NaturalCircle(x, y, WorldGen.genRand.Next(5, 15), ModContent.TileType()); + } + } + } + + //tile cleanup + for (int x = biomeStart; x <= biomeEdge; x++) + { + for (int y = Main.maxTilesY - 140; y <= Main.maxTilesY - 5; y++) + { + Tile tile = Main.tile[x, y]; + Tile tileUp = Main.tile[x, y - 1]; + Tile tileDown = Main.tile[x, y + 1]; + Tile tileDown2 = Main.tile[x, y + 2]; + Tile tileLeft = Main.tile[x - 1, y]; + Tile tileRight = Main.tile[x + 1, y]; + + //place tiles under slag tiles that are sticking out and look weird + if (tile.TileType == ModContent.TileType() && !tileDown.HasTile) + { + WorldGen.PlaceTile(x, y + 1, (ushort)ModContent.TileType()); + } + + //same as above, but for scorched remains + if (tile.TileType == ModContent.TileType() && !tileDown.HasTile) + { + WorldGen.PlaceTile(x, y + 1, (ushort)ModContent.TileType()); + } + + //place more walls behind slag so theres not just a box of walls from the initial rectangle + if (tile.HasTile && tileDown.HasTile && tileDown2.HasTile && Main.tile[x, y + 5].HasTile) + { + Main.tile[x, y + 5].WallType = (ushort)ModContent.WallType(); + } + + if (tile.LiquidType == LiquidID.Water && tile.LiquidAmount > 0) + { + tile.ClearEverything(); + tile.LiquidType = LiquidID.Lava; + tile.LiquidAmount = 255; + } + } + } + + //ceiling cleanup + for (int x = biomeStart; x <= biomeEdge; x++) + { + for (int y = Main.maxTilesY - 195; y <= Main.maxTilesY - 180; y++) + { + Tile tile = Main.tile[x, y]; + Tile tileUp = Main.tile[x, y - 1]; + + if (tile.TileType == ModContent.TileType() && !tileUp.HasTile) + { + WorldGen.PlaceTile(x, y - 1, (ushort)ModContent.TileType()); + } + } + } + + //place lava throughout the biome + for (int x = biomeStart; x <= biomeEdge; x++) + { + //cooldown before another lava pit can be placed + if (lavaLakeBigPlaceDelay > 0) + { + lavaLakeBigPlaceDelay--; + } + + //surface lava lakes and pits + //the reason theres three different runners being used is so that a shallow lava pit is placed above each lava pit + if (lavaLakeBigPlaceDelay == 0) + { + LavaTileRunner runner1 = new LavaTileRunner(new Vector2(x - 10, Main.maxTilesY - 110), new Vector2(0, 5), new Point16(-150, 150), + new Point16(250, 500), 15f, WorldGen.genRand.Next(200, 300), 0, true, true); + runner1.Start(); + + LavaTileRunner runner2 = new LavaTileRunner(new Vector2(x + 10, Main.maxTilesY - 110), new Vector2(0, 5), new Point16(-150, 150), + new Point16(250, 500), 15f, WorldGen.genRand.Next(200, 300), 0, true, true); + runner2.Start(); + + LavaTileRunner runner3 = new LavaTileRunner(new Vector2(x, Main.maxTilesY - 165), new Vector2(0, 5), new Point16(-500, 500), + new Point16(250, 1000), 15f, WorldGen.genRand.Next(300, 400), 0, true, true); + runner3.Start(); + + lavaLakeBigPlaceDelay = 240; //set lava lake delay so it cant just spam lava lakes everywhere + } + } + + //place random blotches of lava underground + for (int x = biomeStart; x <= biomeEdge; x++) + { + for (int y = Main.maxTilesY - 100; y <= Main.maxTilesY - 20; y++) + { + if (WorldGen.genRand.Next(1200) == 0) + { + LavaTileRunner runner = new LavaTileRunner(new Vector2(x, y), new Vector2(0, 5), new Point16(-20000, 20000), + new Point16(-12, 12), 15f, WorldGen.genRand.Next(12, 25), 0, true, true); + runner.Start(); + } + } + } + + //spread grass on all scorched remains + for (int x = biomeStart; x <= biomeEdge; x++) + { + for (int y = Main.maxTilesY - 200; y <= Main.maxTilesY - 5; y++) + { + Tile tile = Main.tile[x, y]; + Tile tileUp = Main.tile[x, y - 1]; + + if (tile.TileType == ModContent.TileType() && !tileUp.HasTile && tileUp.LiquidAmount == 0) + { + tile.TileType = (ushort)ModContent.TileType(); + } + + Tile.SmoothSlope(x, y, true); + } + } + + //charred ore + for (int x = biomeStart; x <= biomeEdge; x++) + { + for (int y = Main.maxTilesY - 150; y <= Main.maxTilesY - 45; y++) + { + Tile tile = Main.tile[x, y]; + Tile tileUp = Main.tile[x, y - 1]; + Tile tileDown = Main.tile[x, y + 1]; + Tile tileLeft = Main.tile[x - 1, y]; + Tile tileRight = Main.tile[x + 1, y]; + + //only place ore nearby lava + if (WorldGen.genRand.Next(200) == 0 && tile.TileType == ModContent.TileType() && (tileUp.LiquidAmount > 0 || + tileDown.LiquidAmount > 0 || tileLeft.LiquidAmount > 0 || tileRight.LiquidAmount > 0)) + { + WorldGen.TileRunner(x + WorldGen.genRand.Next(-15, 15), y + WorldGen.genRand.Next(-15, 15), + WorldGen.genRand.Next(8, 12), WorldGen.genRand.Next(8, 12), ModContent.TileType(), false, 0f, 0f, false, true); + } + } + } + + //place bridge in the center of the biome + bool firstItem = false; + SchematicManager.PlaceSchematic(SchematicManager.CragBridgeKey, new Point(biomeMiddle, Main.maxTilesY - 100), + SchematicAnchor.Center, ref firstItem, new Action(FillBrimstoneChests)); + + for (int x = biomeStart; x <= biomeEdge; x++) + { + for (int y = Main.maxTilesY - 200; y <= Main.maxTilesY - 5; y++) + { + Tile tile = Main.tile[x, y]; + if (tile.LiquidAmount > 0) + { + tile.LiquidType = LiquidID.Lava; + tile.LiquidAmount = 255; + } + } + } + + //clean up any lava above a certain threshold to prevent the biome's surface from being flooded + for (int x = biomeStart; x <= biomeEdge; x++) + { + for (int y = Main.maxTilesY - 150; y <= Main.maxTilesY - 122; y++) + { + Main.tile[x, y].LiquidAmount = 0; + } + } + } + + //place ambient objects and other stuff + private static void GenCragsAmbience() + { + int biomeStart = StartX; + int biomeEdge = biomeStart + (Main.maxTilesX / 5); + int biomeMiddle = (biomeStart + biomeEdge) / 2; + + for (int x = biomeStart; x <= biomeEdge; x++) + { + for (int y = Main.maxTilesY - 200; y <= Main.maxTilesY - 5; y++) + { + Tile tile = Main.tile[x, y]; + Tile tileUp = Main.tile[x, y - 1]; + + //stalactites and stalagmites + if (tile.TileType == ModContent.TileType()) + { + if (WorldGen.genRand.Next(32) == 0) + { + ushort[] Stalactites = new ushort[] { (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; + + WorldGen.PlaceObject(x, y + 2, WorldGen.genRand.Next(Stalactites)); + } + + if (WorldGen.genRand.Next(10) == 0) + { + ushort[] Stalactites = new ushort[] { (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), + (ushort)ModContent.TileType() }; + + WorldGen.PlaceObject(x, y + 2, WorldGen.genRand.Next(Stalactites)); + } + + if (WorldGen.genRand.Next(25) == 0) + { + ushort[] Stalagmites = new ushort[] { (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; + + WorldGen.PlaceObject(x, y - 1, WorldGen.genRand.Next(Stalagmites)); + } + + if (WorldGen.genRand.Next(8) == 0) + { + ushort[] Stalagmites = new ushort[] { (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), + (ushort)ModContent.TileType() }; + + WorldGen.PlaceObject(x, y - 1, WorldGen.genRand.Next(Stalagmites)); + } + + //decrease tree delay + if (TreeDelay > 0) + { + TreeDelay--; + } + + //grow spine tree + if (WorldGen.genRand.Next(12) == 0 && TreeDelay == 0 && !tile.LeftSlope && !tile.RightSlope && !tile.IsHalfBlock) + { + SpineTree.Spawn(x, y - 1, 22, 28, false, -1, false); + TreeDelay = 15; + } + } + } + } + } + + public static void FillBrimstoneChests(Chest chest, int Type, bool firstItem) + { + /* + Potential other item ideas: + Charred Idol + Obsidian Rose + Demon Conch + Lava Charm + */ + + int potionType = Utils.SelectRandom(WorldGen.genRand, ItemID.ObsidianSkinPotion, ItemID.BattlePotion, ItemID.InfernoPotion, ItemID.PotionOfReturn); + List contents = new List() + { + new ChestItem(ItemID.HellstoneBar, WorldGen.genRand.Next(4, 6)), + new ChestItem(ModContent.ItemType(), WorldGen.genRand.Next(4, 15)), + new ChestItem(ModContent.ItemType(), WorldGen.genRand.Next(2, 5)), + new ChestItem(ItemID.HellfireArrow, WorldGen.genRand.Next(25, 50)), + new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(2, 12)), + }; + + if (!firstItem) + { + contents.Insert(0, new ChestItem(ModContent.ItemType(), 1)); + } + else + { + contents.RemoveAt(0); + contents.Insert(0, new ChestItem(ModContent.ItemType(), 1)); + //re-add hellstone bars to the list since removing the first item also removes hellstone bars for some reason + contents.Insert(1, new ChestItem(ItemID.HellstoneBar, WorldGen.genRand.Next(2, 5))); + } + + for (int i = 0; i < contents.Count; i++) + { + chest.item[i].SetDefaults(contents[i].Type); + chest.item[i].stack = contents[i].Stack; + } + } + + //shamelessly copy pasted from the astral biome generation + public static void ScorchedGrassPatches(object obj) + { + //Pre-calculate all variables necessary for elliptical area checking + Point origin = (Point)obj; + Vector2 center = origin.ToVector2() * 16f + new Vector2(8f); + + float angle = MathHelper.Pi * 0.15f; + float otherAngle = MathHelper.PiOver2 - angle; + + int distanceInTiles = WorldGen.genRand.Next(20, 50); + float distance = distanceInTiles * 16f; + float constant = distance * 2f / (float)Math.Sin(angle); + + float fociSpacing = distance * (float)Math.Sin(otherAngle) / (float)Math.Sin(angle); + int verticalRadius = (int)(constant / 16f); + + Vector2 fociOffset = Vector2.UnitY * fociSpacing; + Vector2 topFoci = center - fociOffset; + Vector2 bottomFoci = center + fociOffset; + + UnifiedRandom rand = WorldGen.genRand; + for (int x = origin.X - distanceInTiles - 2; x <= origin.X + distanceInTiles + 2; x++) + { + for (int y = (int)(origin.Y - verticalRadius * 0.4f) - 3; y <= origin.Y + verticalRadius + 3; y++) + { + if (CheckInEllipse(new Point(x, y), topFoci, bottomFoci, constant, center, out float dist, y < origin.Y)) + { + //If we're in the outer blurPercent% of the ellipse + float percent = dist / constant; + float blurPercent = 0.98f; + if (percent > blurPercent) + { + float outerEdgePercent = (percent - blurPercent) / (1f - blurPercent); + if (rand.NextFloat(1f) > outerEdgePercent && Main.tile[x, y].HasTile && WorldGen.InWorld(x, y)) + { + Main.tile[x, y].TileType = (ushort)ModContent.TileType(); + } + } + else if (Main.tile[x, y].HasTile && WorldGen.InWorld(x, y)) + { + Main.tile[x, y].TileType = (ushort)ModContent.TileType(); + } + } + } + } + } + + //shamelessly copy pasted from the astral biome generation + public static bool CheckInEllipse(Point tile, Vector2 focus1, Vector2 focus2, float distanceConstant, Vector2 center, out float distance, bool collapse = false) + { + Vector2 point = tile.ToWorldCoordinates(); + if (collapse) //Collapse ensures the ellipse is shrunk down a lot in terms of distance. + { + float distY = center.Y - point.Y; + point.Y -= distY * 8f; + } + float distance1 = Vector2.Distance(point, focus1); + float distance2 = Vector2.Distance(point, focus2); + distance = distance1 + distance2; + return distance <= distanceConstant; + } + + public static void GenAllCragsStuff() + { + GenCrags(); + GenCragsAmbience(); + } + } +} \ No newline at end of file diff --git a/World/DraedonStructures.cs b/World/DraedonStructures.cs index cec3358c8a..96ccf975db 100644 --- a/World/DraedonStructures.cs +++ b/World/DraedonStructures.cs @@ -264,7 +264,8 @@ namespace CalamityMod.World do { int underworldTop = Main.maxTilesY - 200; - int placementPositionX = WorldGen.genRand.Next((int)(Main.maxTilesX * 0.82), (int)(Main.maxTilesX * 0.925)); + //gen opposite to the brimstone crags + int placementPositionX = (Main.dungeonX > Main.maxTilesX / 2) ? WorldGen.genRand.Next((int)(Main.maxTilesX / 12), (int)(Main.maxTilesX / 9)) : WorldGen.genRand.Next((int)(Main.maxTilesX * 0.82), (int)(Main.maxTilesX * 0.925)); int placementPositionY = WorldGen.genRand.Next(Main.maxTilesY - 150, Main.maxTilesY - 125); placementPoint = new Point(placementPositionX, placementPositionY); @@ -387,8 +388,8 @@ namespace CalamityMod.World shouldAvoidArea = true; } } - tries++; */ + tries++; if (/*!shouldAvoidArea &&*/ structures.CanPlace(new Rectangle(placementPoint.X, placementPoint.Y, (int)schematicSize.X, (int)schematicSize.Y))) break; } diff --git a/World/MiscWorldgenRoutines.cs b/World/MiscWorldgenRoutines.cs index ab12a21f8c..eacfe182da 100644 --- a/World/MiscWorldgenRoutines.cs +++ b/World/MiscWorldgenRoutines.cs @@ -710,272 +710,7 @@ namespace CalamityMod.World } #endregion - // NOTE - The crag gen is scheduled for a rework soon. As such, its code will not be moved. - - #region UnderworldIsland - public static void UnderworldIsland(int i, int j, int sizeMin, int sizeMax, int sizeMin2, int sizeMax2) - { - double num = (double)WorldGen.genRand.Next(sizeMin, sizeMax); //100 150 - float num2 = (float)WorldGen.genRand.Next(sizeMin / 5, sizeMax / 5); //20 30 - int num3 = i; - int num4 = i; - int num5 = i; - int num6 = j; - Vector2 vector; - vector.X = (float)i; - vector.Y = (float)j; - Vector2 vector2; - vector2.X = (float)WorldGen.genRand.Next(-20, 21) * 0.2f; - while (vector2.X > -2f && vector2.X < 2f) - { - vector2.X = (float)WorldGen.genRand.Next(-20, 21) * 0.2f; - } - vector2.Y = (float)WorldGen.genRand.Next(-20, -10) * 0.02f; - while (num > 0.0 && num2 > 0f) - { - num -= (double)WorldGen.genRand.Next(4); - num2 -= 1f; - int num7 = (int)((double)vector.X - num * 0.5); - int num8 = (int)((double)vector.X + num * 0.5); - int num9 = (int)((double)vector.Y - num * 0.5); - int num10 = (int)((double)vector.Y + num * 0.5); - if (num7 < 0) - { - num7 = 0; - } - if (num8 > Main.maxTilesX) - { - num8 = Main.maxTilesX; - } - if (num9 < Main.maxTilesY - 270) - { - num9 = Main.maxTilesY - 270; - } - if (num10 > Main.maxTilesY) - { - num10 = Main.maxTilesY; - } - double num11 = num * (double)WorldGen.genRand.Next(sizeMin, sizeMax) * 0.01; //80 120 - float num12 = vector.Y + 1f; - for (int k = num7; k < num8; k++) - { - if (WorldGen.genRand.Next(2) == 0) - { - num12 += (float)WorldGen.genRand.Next(-1, 2); - } - if (num12 < vector.Y) - { - num12 = vector.Y; - } - if (num12 > vector.Y + 2f) - { - num12 = vector.Y + 2f; - } - for (int l = num9; l < num10; l++) - { - if ((float)l > num12) - { - float arg_218_0 = Math.Abs((float)k - vector.X); - float num13 = Math.Abs((float)l - vector.Y) * 3f; - if (Math.Sqrt((double)(arg_218_0 * arg_218_0 + num13 * num13)) < num11 * 0.4) - { - if (k < num3) - { - num3 = k; - } - if (k > num4) - { - num4 = k; - } - if (l < num5) - { - num5 = l; - } - if (l > num6) - { - num6 = l; - } - Main.tile[k, l].Get().HasTile = true; - Main.tile[k, l].TileType = (ushort)ModContent.TileType(); - WorldGen.SquareTileFrame(k, l, true); - } - } - } - } - vector += vector2; - vector2.X += (float)WorldGen.genRand.Next(-20, 21) * 0.05f; - if (vector2.X > 1f) - { - vector2.X = 1f; - } - if (vector2.X < -1f) - { - vector2.X = -1f; - } - if ((double)vector2.Y > 0.2) - { - vector2.Y = -0.2f; - } - if ((double)vector2.Y < -0.2) - { - vector2.Y = -0.2f; - } - } - int m = num3; - int num15; - for (m += WorldGen.genRand.Next(5); m < num4; m += WorldGen.genRand.Next(num15, (int)((double)num15 * 1.5))) - { - int num14 = num6; - while (!Main.tile[m, num14].HasTile) - { - num14--; - if (num14 < Main.maxTilesX - WorldGen.genRand.Next(265, 275 + 1)) - break; - } - num14 += WorldGen.genRand.Next(-3, 4); - num15 = WorldGen.genRand.Next(4, 8); - int num16 = ModContent.TileType(); - if (WorldGen.genRand.Next(4) == 0) - { - num16 = ModContent.TileType(); - } - for (int n = m - num15; n <= m + num15; n++) - { - for (int num17 = num14 - num15; num17 <= num14 + num15; num17++) - { - if (num17 > num5) - { - float arg_409_0 = (float)Math.Abs(n - m); - float num18 = (float)(Math.Abs(num17 - num14) * 2); - if (Math.Sqrt((double)(arg_409_0 * arg_409_0 + num18 * num18)) < (double)(num15 + WorldGen.genRand.Next(2))) - { - Main.tile[n, num17].Get().HasTile = true; - Main.tile[n, num17].TileType = (ushort)num16; - WorldGen.SquareTileFrame(n, num17, true); - } - } - } - } - } - num = (double)WorldGen.genRand.Next(sizeMin2, sizeMax2); - num2 = (float)WorldGen.genRand.Next(sizeMin2 / 8, sizeMax2 / 8); - vector.X = (float)i; - vector.Y = (float)num5; - vector2.X = (float)WorldGen.genRand.Next(-20, 21) * 0.2f; - while (vector2.X > -2f && vector2.X < 2f) - { - vector2.X = (float)WorldGen.genRand.Next(-20, 21) * 0.2f; - } - vector2.Y = (float)WorldGen.genRand.Next(-20, -10) * 0.02f; - while (num > 0.0 && num2 > 0f) - { - num -= (double)WorldGen.genRand.Next(4); - num2 -= 1f; - vector += vector2; - vector2.X += (float)WorldGen.genRand.Next(-20, 21) * 0.05f; - if (vector2.X > 1f) - { - vector2.X = 1f; - } - if (vector2.X < -1f) - { - vector2.X = -1f; - } - if ((double)vector2.Y > 0.2) - { - vector2.Y = -0.2f; - } - if ((double)vector2.Y < -0.2) - { - vector2.Y = -0.2f; - } - } - int num23 = num3; - num23 += WorldGen.genRand.Next(5); - while (num23 < num4) - { - int num24 = num6; - while ((!Main.tile[num23, num24].HasTile || Main.tile[num23, num24].TileType != 0) && num23 < num4) - { - num24--; - if (num24 < num5) - { - num24 = num6; - num23 += WorldGen.genRand.Next(1, 4); - } - } - if (num23 < num4) - { - num24 += WorldGen.genRand.Next(0, 4); - int num25 = WorldGen.genRand.Next(2, 5); - int num26 = ModContent.TileType(); - for (int num27 = num23 - num25; num27 <= num23 + num25; num27++) - { - for (int num28 = num24 - num25; num28 <= num24 + num25; num28++) - { - if (num28 > num5) - { - float arg_890_0 = (float)Math.Abs(num27 - num23); - float num29 = (float)(Math.Abs(num28 - num24) * 2); - if (Math.Sqrt((double)(arg_890_0 * arg_890_0 + num29 * num29)) < (double)num25) - { - Main.tile[num27, num28].TileType = (ushort)num26; - WorldGen.SquareTileFrame(num27, num28, true); - } - } - } - } - num23 += WorldGen.genRand.Next(num25, (int)((double)num25 * 1.5)); - } - } - for (int num34 = num3; num34 <= num4; num34++) - { - int num35 = num5 - 10; - while (!Main.tile[num34, num35 + 1].HasTile) - { - num35++; - } - if (num35 < num6 && Main.tile[num34, num35 + 1].TileType == (ushort)ModContent.TileType()) - { - if (WorldGen.genRand.Next(10) == 0) - { - int num36 = WorldGen.genRand.Next(1, 3); - for (int num37 = num34 - num36; num37 <= num34 + num36; num37++) - { - if (Main.tile[num37, num35].TileType == (ushort)ModContent.TileType()) - { - Main.tile[num37, num35].Get().HasTile = false; - Main.tile[num37, num35].LiquidAmount = 255; - Main.tile[num37, num35].Get().LiquidType = LiquidID.Water; - WorldGen.SquareTileFrame(num34, num35, true); - } - if (Main.tile[num37, num35 + 1].TileType == (ushort)ModContent.TileType()) - { - Main.tile[num37, num35 + 1].Get().HasTile = false; - Main.tile[num37, num35 + 1].LiquidAmount = 255; - Main.tile[num37, num35 + 1].Get().LiquidType = LiquidID.Water; - WorldGen.SquareTileFrame(num34, num35 + 1, true); - } - if (num37 > num34 - num36 && num37 < num34 + 2 && Main.tile[num37, num35 + 2].TileType == (ushort)ModContent.TileType()) - { - Main.tile[num37, num35 + 2].Get().HasTile = false; - Main.tile[num37, num35 + 2].LiquidAmount = 255; - Main.tile[num37, num35 + 2].Get().LiquidType = LiquidID.Water; - WorldGen.SquareTileFrame(num34, num35 + 2, true); - } - } - } - if (WorldGen.genRand.Next(5) == 0) - { - Main.tile[num34, num35].LiquidAmount = 255; - } - Main.tile[num34, num35].Get().LiquidType = LiquidID.Water; - WorldGen.SquareTileFrame(num34, num35, true); - } - } - } - #endregion - + /* #region UnderworldIslandHouse public static void UnderworldIslandHouse(int i, int j, int item) { @@ -1095,6 +830,7 @@ namespace CalamityMod.World WorldGen.PlaceTile(num22 + 2, num7 - 1, ModContent.TileType(), true, false, 0); //chair } #endregion + */ #region ChasmGenerator public static void ChasmGenerator(int i, int j, int steps, bool ocean = false) diff --git a/World/SunkenSea.cs b/World/SunkenSea.cs index 1fd678ffa7..afb937ad4c 100644 --- a/World/SunkenSea.cs +++ b/World/SunkenSea.cs @@ -361,30 +361,6 @@ namespace CalamityMod.World } } - //place a circular clump of tiles - public static void NaturalCircle(int i, int j, int size, int tileType, bool killTile) - { - int BaseRadius = size; - int radius = BaseRadius; - - for (int y = j - radius; y <= j + radius; y++) - { - for (int x = i - radius; x <= i + radius + 1; x++) - { - if ((int)Vector2.Distance(new Vector2(x, y), new Vector2(i, j)) <= radius && WorldGen.InWorld(x, y)) - { - Tile tile = Framing.GetTileSafely(x, y); - - WorldGen.KillTile(x, y); - WorldGen.PlaceTile(x, y, tileType); - tile.Slope = 0; - } - } - - radius = BaseRadius - WorldGen.genRand.Next(-1, 2); - } - } - // Adds tile variation to generated tile clusters and generates open areas with sea prism ore called "Tits" // Generates sea prism crystals on prism ore and occasionally on navystone private static void AddGeodes(ClusterGroup clusters, Point start, Vector2 terrainApplicationScaleVector, float overallBiomeScale) @@ -666,11 +642,10 @@ namespace CalamityMod.World WorldGen.PlaceTile(num5, num6 - 1, (ushort)ModContent.TileType(), true, false, -1, 0); } - /* //note: the stalactites and stalagmites only use their first frame for now //this is because the previous tile frame randomizer code i had was janky and bad, ill make sure to fix it eventually //stalactites - /*if (WorldGen.genRand.Next(5) == 0) + if (WorldGen.genRand.Next(5) == 0) { WorldGen.PlaceTile(num5, num6 + 2, (ushort)ModContent.TileType(), true, false, -1, 0); } @@ -687,7 +662,6 @@ namespace CalamityMod.World { WorldGen.PlaceTile(num5, num6 - 1, (ushort)ModContent.TileType(), true, false, -1, 0); } - */ } if (!tile.HasTile) {