(Read desc) Abyss chest unlock fix

Do not try to merge or create a pull request for this branch until it has been fully tested.
This commit is contained in:
NalydddNobel authored and Cameron Ewell committed 2023-11-24 20:51:27 -05:00
1 parent afb42a665e
commit 76bf62bc93
4 files changed
+38 -33

No files matched your search

+4
View File
@@ -162,6 +162,9 @@ namespace CalamityMod
// Tile Entities
//
case CalamityModMessageType.UnlockAbyssChests:
Abyss.UnlockAllAbyssChests();
break;
case CalamityModMessageType.PowerCellFactory:
TEPowerCellFactory.ReadSyncPacket(mod, reader);
break;
@@ -359,6 +362,7 @@ namespace CalamityMod
UpdateCodebreakerConstituents,
UpdateCodebreakerContainedStuff,
UpdateCodebreakerDecryptCountdown,
UnlockAbyssChests,
// Draedon Summoner
CodebreakerSummonStuff,
+1 -6
View File
@@ -1783,15 +1783,10 @@ namespace CalamityMod.NPCs
// First kill: Notify of Abyss chests being unlocked.
if (!NPC.downedBoss3)
{
// Abyss chest auto unlock has been shelved, the bug has still not fucking died despite several attempts to fix it.
// Commented it out just in case someone is willing to fix it in the future - Shade
/*
if (Main.netMode != NetmodeID.MultiplayerClient) //Only the server should do this to prevent already unlocked chests from attempting to be unlocked
if (Main.netMode != NetmodeID.MultiplayerClient)
{
World.Abyss.AbleToUnlockChests = true;
World.Abyss.UnlockAllAbyssChests();
}
*/
string keysk = "Mods.CalamityMod.Status.Progression.SkeletronAbyssChestNotification";
CalamityUtils.DisplayLocalizedText(keysk, new Color(76, 181, 76));
}
+3 -5
View File
@@ -27,11 +27,9 @@ namespace CalamityMod.Tiles.Abyss
public override bool IsLockedChest(int i, int j) => Main.tile[i, j].TileFrameX / 36 == 1;
public override bool UnlockChest(int i, int j, ref short frameXAdjustment, ref int dustType, ref bool manual)
{
//Only unlock if Skeletron is dead
if (NPC.downedBoss3)
return true;
else
return false;
//Skeletron must be dead, NPC.downedBoss3 is added as failsave in case chests fail to open in the Abyss' method. AbleToUnlockChests should be false unless
//the Abyss' unlock method is being run to prevent chests spawning already unlocked.
return World.Abyss.UnlockChests || NPC.downedBoss3;
}
public override bool RightClick(int i, int j)
+30 -22
View File
@@ -36,7 +36,11 @@ namespace CalamityMod.World
public static bool AtLeftSideOfWorld = false;
public static int AbyssChasmBottom = 0;
//public static bool AbleToUnlockChests = false; //used for unlocking chests during skeletron's death and so that they cannot be opened beforehand
/// <summary>
/// Forces abyss chests to unlock even if <see cref="NPC.downedBoss3"/> is false. Used in <see cref="UnlockAllAbyssChests"/> as it is ran during Skeletron's death, not after.
/// </summary>
public static bool UnlockChests { get; set; }
public static void PlaceAbyss()
{
int x = Main.maxTilesX;
@@ -1155,34 +1159,38 @@ namespace CalamityMod.World
WorldGen.PlaceObject(i, j - 2, (ushort)ModContent.TileType<AbyssFossilTile>());
}
// Commented out the method in case we ever use it again in the future, or some guy in the public github fixes it,
// but for now this is a buggy mess that is too disruptive especially in multiplayer despite several attempts at fixing it - Shade
/*
/// <summary>
/// Unlocks all abyss chests, automatically synced across the server.
/// Only run initally on the server.
/// </summary>
public static void UnlockAllAbyssChests()
{
int genLimit = Main.maxTilesX / 2;
int abyssChasmX = AtLeftSideOfWorld ? genLimit - (genLimit - 135) + 35 : genLimit + (genLimit - 135) - 35;
int abyssMinX = AtLeftSideOfWorld ? 0 : abyssChasmX - 150;
int abyssMaxX = AtLeftSideOfWorld ? abyssChasmX + 150 : Main.maxTilesX;
UnlockChests = true;
//loop to unlock all abyss treasure chests
for (int x = abyssMinX; x < abyssMaxX; x++)
if (Main.netMode == NetmodeID.Server)
{
for (int y = Main.remixWorld ? SulphurousSea.YStart - (int)((Main.maxTilesY - 200) * 0.4f) : (int)Main.worldSurface; y < Main.maxTilesY - 300; y++)
var netMessage = CalamityMod.Instance.GetPacket();
netMessage.Write((byte)CalamityModMessageType.UnlockAbyssChests);
netMessage.Send();
}
for (int c = 0; c < Main.maxChests; c++)
{
var chest = Main.chest[c];
if (chest == null)
{
//make SURE to check for the entire chest at once, otherwise it will break when unlocking
if (Main.tile[x, y].TileType == ModContent.TileType<Tiles.Abyss.AbyssTreasureChest>() && //top left
Main.tile[x + 1, y].TileType == ModContent.TileType<Tiles.Abyss.AbyssTreasureChest>() && //top right
Main.tile[x, y + 1].TileType == ModContent.TileType<Tiles.Abyss.AbyssTreasureChest>() && //bottom left
Main.tile[x + 1, y + 1].TileType == ModContent.TileType<Tiles.Abyss.AbyssTreasureChest>()) //bottom right
{
Chest.Unlock(x, y);
NetMessage.SendData(MessageID.LockAndUnlock, -1, -1, null, Main.LocalPlayer.whoAmI, 1f, x, y);
}
continue;
}
var chestTile = Framing.GetTileSafely(chest.x, chest.y);
if (chestTile.HasTile && chestTile.TileType == ModContent.TileType<AbyssTreasureChest>() && Chest.IsLocked(chest.x, chest.y))
{
Chest.Unlock(chest.x, chest.y);
}
}
AbleToUnlockChests = false; //reseting the variable in case players generate multiple worlds to prevent already unlocked chests from spawning
UnlockChests = false;
}
*/
}
}