1 - Made *all* worldgenned chests that contain the EoC summon replace it with early game potions

2 - Made Sandstone Chest contain a Desert Medallion at a 20% chance
This commit is contained in:
Phuc Nguyen (Brav) authored and Cameron Ewell committed 2022-08-17 10:22:19 -04:00
1 parent 16243a970a
commit 4ce5607289
1 file changed
+39 -7
+39 -7
View File
@@ -7,6 +7,7 @@ using Terraria.GameContent.Generation;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.WorldBuilding;
using CalamityMod.Items.SummonItems;
using static CalamityMod.World.CalamityWorld;
namespace CalamityMod.Systems
@@ -219,17 +220,29 @@ namespace CalamityMod.Systems
#region PostWorldGen
public override void PostWorldGen()
{
// Replace Suspicious Looking Eyes in Chests with random useful early game potions.
for (int chestIndex = 0; chestIndex < Main.maxChests; chestIndex++)
{
Chest chest = Main.chest[chestIndex];
if (chest != null && Main.tile[chest.x, chest.y].TileType == TileID.Containers)
if (chest != null)
{
bool isGoldChest = Main.tile[chest.x, chest.y].TileFrameX == 36;
bool isMahoganyChest = Main.tile[chest.x, chest.y].TileFrameX == 8 * 36;
bool isIvyChest = Main.tile[chest.x, chest.y].TileFrameX == 10 * 36;
bool isIceChest = Main.tile[chest.x, chest.y].TileFrameX == 11 * 36;
if (isGoldChest || isMahoganyChest || isIvyChest || isIceChest)
//Checks which sheet a chest belongs to
bool isContainer1 = Main.tile[chest.x, chest.y].TileType == TileID.Containers;
bool isContainer2 = Main.tile[chest.x, chest.y].TileType == TileID.Containers2;
//Pre-1.4 chests
bool isGoldChest = isContainer1 && (Main.tile[chest.x, chest.y].TileFrameX == 36 || Main.tile[chest.x, chest.y].TileFrameX == 2*36); //Includes Locked Gold Chests
bool isMahoganyChest = isContainer1 && Main.tile[chest.x, chest.y].TileFrameX == 8 * 36;
bool isIvyChest = isContainer1 && Main.tile[chest.x, chest.y].TileFrameX == 10 * 36;
bool isIceChest = isContainer1 && Main.tile[chest.x, chest.y].TileFrameX == 11 * 36;
bool isMushroomChest = isContainer1 && Main.tile[chest.x, chest.y].TileFrameX == 32 * 36;
bool isMarniteChest = isContainer1 && (Main.tile[chest.x, chest.y].TileFrameX == 50 * 36 || Main.tile[chest.x, chest.y].TileFrameX == 51 * 36);
//1.4 chests
bool isDeadManChest = isContainer2 && Main.tile[chest.x, chest.y].TileFrameX == 4 * 36;
bool isSandstoneChest = isContainer2 && Main.tile[chest.x, chest.y].TileFrameX == 10 * 36;
// Replace Suspicious Looking Eyes in Chests with random useful early game potions.
if (isGoldChest || isMahoganyChest || isIvyChest || isIceChest || isMushroomChest || isMarniteChest || isDeadManChest || isSandstoneChest)
{
for (int inventoryIndex = 0; inventoryIndex < 40; inventoryIndex++)
{
@@ -258,6 +271,25 @@ namespace CalamityMod.Systems
}
}
}
// Adds Desert Medallion to Sandstone Chests at a 20% chance
if (isSandstoneChest)
{
float rng = WorldGen.genRand.NextFloat();
if (rng < 0.2f)
{
for (int inventoryIndex = 0; inventoryIndex < 40; inventoryIndex++)
{
if (chest.item[inventoryIndex].IsAir)
{
chest.item[inventoryIndex].SetDefaults(ModContent.ItemType<DesertMedallion>());
chest.item[inventoryIndex].stack = 1;
break;
}
}
}
}
}
}