Merge pull request #92 from UncleDanny/sulph-sea-changes

Sulphurous Sea world generation made more foolproof. Acid Rain event handling vastly improved.
This commit is contained in:
Cameron Ewell authored and GitHub committed 2020-06-03 21:29:32 -04:00
commit cf43a4ac63
21 files changed
+185 -207

No files matched your search

+1
View File
@@ -3733,6 +3733,7 @@ namespace CalamityMod
case CalamityModMessageType.AcidRainSync:
CalamityWorld.rainingAcid = reader.ReadBoolean();
CalamityWorld.acidRainPoints = reader.ReadInt32();
CalamityWorld.timeSinceAcidRainKill = reader.ReadInt32();
break;
case CalamityModMessageType.AcidRainUIDrawFadeSync:
CalamityWorld.acidRainExtraDrawTime = reader.ReadInt32();
+7 -5
View File
@@ -34,6 +34,8 @@ namespace CalamityMod.Events
// A partially bright pale-ish cyan with a hint of yellow.
public static readonly Color TextColor = new Color(115, 194, 147);
public const int InvasionNoKillPersistTime = 14400; // How long the invasion persists, in frames, if nothing is killed.
public const float BloodwormSpawnRate = 0.1f;
// Not a readonly collection so that if anyone else wants to add stuff in here with their own mod, they can.
@@ -167,17 +169,16 @@ namespace CalamityMod.Events
Main.numClouds = Main.numCloudsTemp;
Main.windSpeedTemp = 0.72f;
Main.windSpeedSet = Main.windSpeedTemp;
Main.weatherCounter = 600;
Main.weatherCounter = 60 * 60 * 10; // 10 minutes of rain. Remember, once the rain goes away, so does the invasion.
Main.rainTime = Main.weatherCounter;
Main.maxRaining = 0.89f;
CalamityWorld.forcedDownpourWithTear = true;
CalamityMod.UpdateServerBoolean();
}
if (CalamityWorld.startAcidicDownpour)
{
Main.raining = true;
}
CalamityWorld.triedToSummonOldDuke = false;
CalamityWorld.timeSinceAcidRainKill = 0; // Reset the kill cooldown, just in case.
}
UpdateInvasion();
BroadcastEventText("Mods.CalamityMod.AcidRainStart"); // A toxic downpour falls over the wasteland seas!
}
@@ -222,6 +223,7 @@ namespace CalamityMod.Events
netMessage.Write((byte)CalamityModMessageType.AcidRainSync);
netMessage.Write(CalamityWorld.rainingAcid);
netMessage.Write(CalamityWorld.acidRainPoints);
netMessage.Write(CalamityWorld.timeSinceAcidRainKill);
netMessage.Send();
}
if (Main.netMode == NetmodeID.Server)
-1
View File
@@ -27,7 +27,6 @@ namespace CalamityMod.Items.Accessories
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ModContent.ItemType<RustyLockpick>(), 1);
recipe.AddIngredient(ModContent.ItemType<SulfuricScale>(), 20);
recipe.AddRecipeGroup("IronBar", 10);
recipe.AddTile(TileID.Anvils);
-1
View File
@@ -31,7 +31,6 @@ namespace CalamityMod.Items.Accessories
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ModContent.ItemType<RustyLockpick>(), 1);
recipe.AddIngredient(ModContent.ItemType<SulfuricScale>(), 20);
recipe.AddRecipeGroup("IronBar", 10);
recipe.AddTile(TileID.Anvils);
@@ -34,7 +34,6 @@ namespace CalamityMod.Items.Placeables.Furniture
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ModContent.ItemType<RustyLockpick>(), 1);
recipe.AddIngredient(ModContent.ItemType<SulfuricScale>(), 20);
recipe.AddRecipeGroup("IronBar", 10);
recipe.AddTile(TileID.Anvils);
+1 -1
View File
@@ -22,7 +22,7 @@ namespace CalamityMod.Items.Placeables.Furniture
item.useStyle = ItemUseStyleID.SwingThrow;
item.consumable = true;
item.value = 500;
item.createTile = ModContent.TileType<RustyChestLocked>();
item.createTile = ModContent.TileType<RustyChestTile>();
}
public override void AddRecipes()
{
-30
View File
@@ -1,30 +0,0 @@
using CalamityMod.Items.Materials;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items
{
public class RustyLockpick : ModItem
{
public override void SetStaticDefaults()
{
Tooltip.SetDefault("Opens locked rusty chests");
}
public override void SetDefaults()
{
item.width = 14;
item.height = 28;
item.maxStack = 99;
item.rare = 1;
item.value = CalamityGlobalItem.Rarity1BuyPrice;
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ModContent.ItemType<SulfuricScale>(), 15);
recipe.AddTile(TileID.Anvils);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 383 B

+1 -13
View File
@@ -32,7 +32,7 @@ namespace CalamityMod.Items.Tools.ClimateChange
public override bool CanUseItem(Player player)
{
return !Main.slimeRain && (Main.rainTime > 3600 || !CalamityWorld.death || !Main.raining);
return !Main.slimeRain && (Main.rainTime > 3600 || !CalamityWorld.death || !Main.raining || CalamityWorld.rainingAcid);
}
public override bool UseItem(Player player)
@@ -48,22 +48,10 @@ namespace CalamityMod.Items.Tools.ClimateChange
Main.rainTime = 3600;
AdjustRainSeverity(true);
}
if (CalamityWorld.rainingAcid)
{
CalamityWorld.acidRainPoints = 0;
CalamityWorld.triedToSummonOldDuke = false;
AcidRainEvent.UpdateInvasion(false);
}
}
else
{
Main.raining = false;
if (CalamityWorld.rainingAcid)
{
CalamityWorld.acidRainPoints = 0;
CalamityWorld.triedToSummonOldDuke = false;
AcidRainEvent.UpdateInvasion(false);
}
}
CalamityMod.UpdateServerBoolean();
+1 -2
View File
@@ -44,8 +44,7 @@ namespace CalamityMod.Items.Weapons.Summon
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ModContent.ItemType<RustyLockpick>(), 1);
ModRecipe recipe = new ModRecipe(mod);;
recipe.AddIngredient(ModContent.ItemType<SulfuricScale>(), 20);
recipe.AddRecipeGroup("IronBar", 10);
recipe.AddTile(TileID.Anvils);
+5 -2
View File
@@ -1614,16 +1614,18 @@ namespace CalamityMod.NPCs
private void AcidRainProgression(NPC npc)
{
Dictionary<int, AcidRainSpawnData> possibleEnemies = AcidRainEvent.PossibleEnemiesPreHM;
if (CalamityWorld.downedAquaticScourge)
possibleEnemies = AcidRainEvent.PossibleEnemiesAS;
if (CalamityWorld.downedPolterghast)
possibleEnemies = AcidRainEvent.PossibleEnemiesPolter;
if (possibleEnemies.Select(enemy => enemy.Key).Contains(npc.type) && CalamityWorld.rainingAcid)
{
CalamityWorld.acidRainPoints -= possibleEnemies[npc.type].InvasionContributionPoints;
if (CalamityWorld.downedPolterghast)
{
CalamityWorld.acidRainPoints = (int)MathHelper.Max(2, CalamityWorld.acidRainPoints); // Cap at 2. The last points are for Old Duke.
CalamityWorld.acidRainPoints = (int)MathHelper.Max(1, CalamityWorld.acidRainPoints); // Cap at 1. The last point is for Old Duke.
}
}
Dictionary<int, AcidRainSpawnData> possibleMinibosses = CalamityWorld.downedPolterghast ? AcidRainEvent.PossibleMinibossesPolter : AcidRainEvent.PossibleMinibossesAS;
@@ -1632,7 +1634,7 @@ namespace CalamityMod.NPCs
CalamityWorld.acidRainPoints -= possibleMinibosses[npc.type].InvasionContributionPoints;
if (CalamityWorld.downedPolterghast)
{
CalamityWorld.acidRainPoints = (int)MathHelper.Max(2, CalamityWorld.acidRainPoints); // Cap at 2. The last points are for Old Duke.
CalamityWorld.acidRainPoints = (int)MathHelper.Max(1, CalamityWorld.acidRainPoints); // Cap at 1. The last point is for Old Duke.
}
}
@@ -1645,6 +1647,7 @@ namespace CalamityMod.NPCs
CalamityWorld.triedToSummonOldDuke = false;
CalamityWorld.acidRainPoints = 0;
}
CalamityWorld.timeSinceAcidRainKill = 0;
AcidRainEvent.UpdateInvasion();
}
#endregion
+3 -3
View File
@@ -15,9 +15,9 @@ namespace CalamityMod.Projectiles.Summon
public const float NPCHomingInertia = 20f;
public const float NPCHomingSpeed = 14f;
public const float AttackRate = 110f;
public const float AttackRate = 140f;
public const float DistanceToCheck = 750f;
public const float DistanceToCheck = 585f;
public const int ExplosionShrapnelBaseDamage = 16; // Uses player.MinionDamage
@@ -138,7 +138,7 @@ namespace CalamityMod.Projectiles.Summon
Utils.PoofOfSmoke(projectile.Center);
for (int i = 0; i < 4; i++)
{
Projectile.NewProjectile(projectile.Center, Vector2.One.RotatedByRandom(MathHelper.TwoPi) * 8f, ModContent.ProjectileType<RustShrapnel>(),
Projectile.NewProjectile(projectile.Center, Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi) * 8f, ModContent.ProjectileType<RustShrapnel>(),
(int)(ExplosionShrapnelBaseDamage * player.MinionDamage()), 2f, projectile.owner);
}
projectile.Kill();
-124
View File
@@ -1,124 +0,0 @@
using CalamityMod.Dusts;
using CalamityMod.Items;
using CalamityMod.Items.Placeables.Furniture;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Tiles.Abyss
{
public class RustyChestLocked : ModTile
{
public override void SetDefaults()
{
this.SetUpChest();
ModTranslation name = CreateMapEntryName("chestRusty");
name.SetDefault("Rusty Chest");
AddMapEntry(new Color(57, 48, 83), name, MapChestName);
dustType = ModContent.DustType<AstralBasic>();
disableSmartCursor = true;
adjTiles = new int[] { TileID.Containers };
chest = "Rusty Chest";
chestDrop = ModContent.ItemType<RustyChest>();
}
public override bool HasSmartInteract() => true;
public override bool IsLockedChest(int i, int j) => Main.tile[i, j].frameX / 36 == 1;
public override bool UnlockChest(int i, int j, ref short frameXAdjustment, ref int dustType, ref bool manual)
{
Player closest = Main.player[Player.FindClosest(new Vector2(i, j) * 16f, 1, 1)];
if (!closest.InventoryHas(ModContent.ItemType<RustyLockpick>()))
return false;
for (int k = 0; k < closest.inventory.Length; k++)
{
if (closest.inventory[k].type == ModContent.ItemType<RustyLockpick>())
{
if (ItemLoader.ConsumeItem(closest.inventory[k], closest))
{
closest.inventory[k].stack--;
}
if (closest.inventory[k].stack <= 0)
{
closest.inventory[k] = new Item();
}
break;
}
}
dustType = this.dustType;
return true;
}
public string MapChestName(string name, int i, int j)
{
// Bounds check
if (i < 0 || i >= Main.maxTilesX || j < 0 || j >= Main.maxTilesY)
return name;
// Tile null check
Tile tile = Main.tile[i, j];
if (tile is null)
return name;
int left = i;
int top = j;
if (tile.frameX % 36 != 0)
left--;
if (tile.frameY != 0)
top--;
int chest = Chest.FindChest(left, top);
return name + (Main.chest[chest].name != "" ? ": " + Main.chest[chest].name : "");
}
public override void NumDust(int i, int j, bool fail, ref int num)
{
num = 1;
}
public override void KillMultiTile(int i, int j, int frameX, int frameY)
{
Item.NewItem(i * 16, j * 16, 32, 32, chestDrop);
Chest.DestroyChest(i, j);
}
public override bool NewRightClick(int i, int j)
{
Tile tile = Main.tile[i, j];
int left = i;
int top = j;
if (tile.frameX % 36 != 0)
{
left--;
}
if (tile.frameY != 0)
{
top--;
}
return CalamityUtils.LockedChestRightClick(IsLockedChest(left, top), left, top, i, j);
}
public override void MouseOver(int i, int j)
{
if (IsLockedChest(i, j))
CalamityUtils.ChestMouseOver<RustyLockpick>("Rusty Chest", i, j);
else
CalamityUtils.ChestMouseOver<RustyChest>("Rusty Chest", i, j);
}
public override void MouseOverFar(int i, int j)
{
if (IsLockedChest(i, j))
CalamityUtils.ChestMouseFar<RustyLockpick>("Rusty Chest", i, j);
else
CalamityUtils.ChestMouseFar<RustyChest>("Rusty Chest", i, j);
}
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 845 B

+81
View File
@@ -0,0 +1,81 @@
using CalamityMod.Items.Placeables.Furniture;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Tiles.Abyss
{
public class RustyChestTile : ModTile
{
public override void SetDefaults()
{
this.SetUpChest();
ModTranslation name = CreateMapEntryName();
name.SetDefault("Rusty Chest");
AddMapEntry(new Color(191, 142, 111), name, MapChestName);
disableSmartCursor = true;
adjTiles = new int[] { TileID.Containers };
chest = "Rusty Chest";
chestDrop = ModContent.ItemType<RustyChest>();
}
public override bool CreateDust(int i, int j, ref int type)
{
Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, 180, 0f, 0f, 1, new Color(255, 255, 255), 1f);
return false;
}
public override bool HasSmartInteract() => true;
public string MapChestName(string name, int i, int j)
{
// Bounds check
if (i < 0 || i >= Main.maxTilesX || j < 0 || j >= Main.maxTilesY)
return name;
// Tile null check
Tile tile = Main.tile[i, j];
if (tile is null)
return name;
int left = i;
int top = j;
if (tile.frameX % 36 != 0)
left--;
if (tile.frameY != 0)
top--;
int chest = Chest.FindChest(left, top);
if (chest == -1)
return name;
return name + (Main.chest[chest].name != "" ? ": " + Main.chest[chest].name : "");
}
public override void NumDust(int i, int j, bool fail, ref int num)
{
num = fail ? 1 : 3;
}
public override void KillMultiTile(int i, int j, int frameX, int frameY)
{
Item.NewItem(i * 16, j * 16, 32, 32, chestDrop);
Chest.DestroyChest(i, j);
}
public override bool NewRightClick(int i, int j)
{
return CalamityUtils.ChestRightClick(i, j);
}
public override void MouseOver(int i, int j)
{
CalamityUtils.ChestMouseOver<RustyChest>("Rusty Chest", i, j);
}
public override void MouseOverFar(int i, int j)
{
CalamityUtils.ChestMouseFar<RustyChest>("Rusty Chest", i, j);
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 995 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 632 B

+38 -9
View File
@@ -71,6 +71,7 @@ namespace CalamityMod.World
GenerateUpperSea();
CreateWater();
GenerateHardenedSandstone();
RemoveStupidTilesAboveSea();
SettleWater(); // The island Y spawn position calculations are relative to water. Settling the water before doing these calculations is ideal.
GenerateIslands();
GenerateVentsAndFossils();
@@ -325,13 +326,6 @@ namespace CalamityMod.World
}
}
}
else if (WorldGen.genRand.NextBool(10))
{
for (int i = 0; i < 20; i++)
{
TileLoader.RandomUpdate(trueX, y, Main.tile[trueX, y].type);
}
}
}
}
}
@@ -742,7 +736,7 @@ namespace CalamityMod.World
SulphSeaTiles.Contains(CalamityUtils.ParanoidTileRetrieval(x, y + 1).type) &&
CalamityUtils.ParanoidTileRetrieval(x, y + 1).active())
{
chest = WorldGenerationMethods.AddChestWithLoot(x, y, (ushort)ModContent.TileType<RustyChestLocked>(), tileStyle: 1);
chest = WorldGenerationMethods.AddChestWithLoot(x, y, (ushort)ModContent.TileType<RustyChestTile>());
}
}
}
@@ -757,9 +751,30 @@ namespace CalamityMod.World
}
#endregion
#region Removal of stupid Tiles above the Sea
public static void RemoveStupidTilesAboveSea()
{
for (int x = 0; x < BiomeWidth; x++)
{
int trueX = CalamityWorld.abyssSide ? x : Main.maxTilesX - x;
for (int y = YStart - 100; y < YStart + 60; y++)
{
if (YStartWhitelist.Contains(CalamityUtils.ParanoidTileRetrieval(trueX, y).type))
{
if (Main.tile[trueX, y] == null)
Main.tile[trueX, y] = new Tile();
Main.tile[trueX, y].active(false);
}
}
}
}
#endregion
#region Misc Functions
public static List<int> YStartWhitelist = new List<int>()
{
TileID.Stone,
TileID.Dirt,
TileID.Sand,
TileID.Ebonsand,
TileID.Crimsand,
@@ -776,12 +791,26 @@ namespace CalamityMod.World
TileID.Tungsten,
TileID.Crimstone,
TileID.Ebonstone,
TileID.HardenedSand,
TileID.CorruptHardenedSand,
TileID.CrimsonHardenedSand,
TileID.Coral,
TileID.BeachPiles,
TileID.Plants,
TileID.Plants2,
TileID.SmallPiles,
TileID.LargePiles,
TileID.LargePiles2,
TileID.Trees,
TileID.Vines,
TileID.CrimsonVines,
TileID.Containers,
TileID.JungleGrass // Yes, this can happen on rare occasion
};
public static void DetermineYStart()
{
int maxHeight = 0;
for (int i = 0; i < BiomeWidth; i++)
for (int i = 0; i < BiomeWidth - 18; i++)
{
int xCheck = CalamityWorld.abyssSide ?
BiomeWidth - i :
+46 -14
View File
@@ -111,6 +111,8 @@ namespace CalamityMod.World
public static bool forcedRainAlready = false;
public static bool forcedDownpourWithTear = false;
public static int forceRainTimer = 0;
public static int timeSinceAcidRainKill = 0;
public static int timeSinceAcidStarted = 0;
public static float AcidRainCompletionRatio
{
get
@@ -967,6 +969,17 @@ namespace CalamityMod.World
if (rainingAcid)
{
timeSinceAcidRainKill++;
timeSinceAcidStarted++;
// If enough time has passed, and no enemy has been killed, end the invasion early.
// The player almost certainly does not want to deal with it.
if (timeSinceAcidRainKill >= AcidRainEvent.InvasionNoKillPersistTime)
{
acidRainPoints = 0;
triedToSummonOldDuke = false;
AcidRainEvent.UpdateInvasion(false);
}
if (!startAcidicDownpour)
{
int sulphSeaWidth = Abyss.BiomeWidth;
@@ -984,6 +997,8 @@ namespace CalamityMod.World
(player2.Center.X >= (Main.maxTilesX - (sulphSeaWidth + 60f)) * 16f && !abyssSide)) &&
player2.Calamity().ZoneSulphur)
{
// Makes rain pour at its maximum intensity (but only after an idiot meanders into the Sulphurous Sea)
// You'll never catch me, Fabs, Not when I shift into MAXIMUM OVERDRIVE!!
startAcidicDownpour = true;
CalamityMod.UpdateServerBoolean();
break;
@@ -992,22 +1007,37 @@ namespace CalamityMod.World
}
}
// Makes rain pour at its maximum intensity (but only after an idiot meanders into the Sulphurous Sea)
// You'll never catch me, Fabs, Not when I shift into MAXIMUM OVERDRIVE!!
if ((startAcidicDownpour || forcedDownpourWithTear) && !NPC.AnyNPCs(ModContent.NPCType<OldDuke>()))
// Stop the rain if the Old Duke is present for visibility during the fight.
if (Main.raining && NPC.AnyNPCs(ModContent.NPCType<OldDuke>()))
{
Main.raining = true;
Main.cloudBGActive = 1f;
Main.numCloudsTemp = Main.cloudLimit;
Main.numClouds = Main.numCloudsTemp;
Main.windSpeedTemp = 0.72f;
Main.windSpeedSet = Main.windSpeedTemp;
Main.weatherCounter = 600;
Main.maxRaining = 0.89f;
}
Main.raining = false;
CalamityMod.UpdateServerBoolean();
}
// If the rain stops for whatever reason, end the invasion.
// This is primarily done for compatibility, so that if another mod wants to manipulate the weather,
// they can without having to deal with endless rain.
if (!Main.raining && !NPC.AnyNPCs(ModContent.NPCType<OldDuke>()) && timeSinceAcidStarted > 20)
{
acidRainPoints = 0;
triedToSummonOldDuke = false;
AcidRainEvent.UpdateInvasion(false);
}
else if (timeSinceAcidStarted < 20)
{
Main.raining = true;
Main.cloudBGActive = 1f;
Main.numCloudsTemp = Main.cloudLimit;
Main.numClouds = Main.numCloudsTemp;
Main.windSpeedTemp = 0.72f;
Main.windSpeedSet = Main.windSpeedTemp;
Main.weatherCounter = 60 * 60 * 10; // 10 minutes of rain. Remember, once the rain goes away, so does the invasion.
Main.rainTime = Main.weatherCounter;
Main.maxRaining = 0.89f;
}
// Summon Old Duke tornado post-Polter as needed
if (downedPolterghast && acidRainPoints == 2)
if (downedPolterghast && acidRainPoints == 1)
{
if (!NPC.AnyNPCs(ModContent.NPCType<OldDuke>()) &&
CalamityUtils.CountProjectiles(ModContent.ProjectileType<OverlyDramaticDukeSummoner>()) <= 0)
@@ -1033,7 +1063,9 @@ namespace CalamityMod.World
}
else
{
startAcidicDownpour = false;
if (timeSinceAcidStarted != 0)
timeSinceAcidStarted = 0;
startAcidicDownpour = false;
}
// Lumenyl crystal, tenebris spread and sea prism crystal spawn rates
+1 -1
View File
@@ -139,7 +139,7 @@ namespace CalamityMod.World
}
PutItemInChest(ref chest, ItemID.GoldCoin, goldCoins);
}
else if (type == ModContent.TileType<RustyChestLocked>())
else if (type == ModContent.TileType<RustyChestTile>())
{
// 15-29 torches (in accordence with vanilla)
PutItemInChest(ref chest, ItemID.Torch, 15, 29);