From 7eca945ed4e2facff4700a9d0a83c2a0c0d99812 Mon Sep 17 00:00:00 2001
From: CongratsIsTrash <1q2w3e4dasd@gmail.com>
Date: Sun, 17 Nov 2024 15:42:49 -0500
Subject: [PATCH] Calamity now edits the Master Mode worldgen description to
mention boss changes
---
ILEditing/ILChangesLoading.cs | 1 +
ILEditing/WorldgenILChanges.cs | 24 +++++++++++++++++++-
Localization/en-US/Mods.CalamityMod.UI.hjson | 2 ++
3 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/ILEditing/ILChangesLoading.cs b/ILEditing/ILChangesLoading.cs
index e40c1c10e1..962e20cadf 100644
--- a/ILEditing/ILChangesLoading.cs
+++ b/ILEditing/ILChangesLoading.cs
@@ -181,6 +181,7 @@ namespace CalamityMod.ILEditing
IL_WorldGen.Chlorophyte += AdjustChlorophyteSpawnLimits;
IL_UIWorldCreation.SetDefaultOptions += ChangeDefaultWorldSize;
IL_UIWorldCreation.AddWorldSizeOptions += SwapSmallDescriptionKey;
+ IL_UIWorldCreation.AddWorldDifficultyOptions += SwapMasterModeDescriptionKey;
Terraria.IO.On_WorldFile.ClearTempTiles += ClearModdedTempTiles;
On_WorldGen.MakeDungeon += LimitDungeonEntranceXPosition;
IL_WorldGen.DungeonHalls += LimitDungeonHallsXPosition;
diff --git a/ILEditing/WorldgenILChanges.cs b/ILEditing/WorldgenILChanges.cs
index 2347363be0..b6ca1da325 100644
--- a/ILEditing/WorldgenILChanges.cs
+++ b/ILEditing/WorldgenILChanges.cs
@@ -161,7 +161,7 @@ namespace CalamityMod.ILEditing
}
#endregion
- #region Change Small World Description
+ #region Change World Generation Descriptions
///
/// Changes the description of Small worlds to serve as a warning.
///
@@ -181,6 +181,28 @@ namespace CalamityMod.ILEditing
// Emit our new string "Mods.CalamityMod.UI.SmallWorldWarning".
c.Emit(OpCodes.Ldstr, "Mods.CalamityMod.UI.SmallWorldWarning");
+
+
+ }
+
+ ///
+ /// Changes the description of Master Mode to mention boss changes.
+ ///
+ private static void SwapMasterModeDescriptionKey(ILContext il)
+ {
+ // Swap vanilla's Master Mode description string (UI.WorldDescriptionMaster) with Calamity's edited version (Mods.CalamityMod.UI.WorldMaster).
+ var cursor = new ILCursor(il);
+
+ // Move to after the string.
+ if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdstr("UI.WorldDescriptionMaster")))
+ {
+ LogFailure("Change Master Mode Description", "Could not match string \"UI.WorldDescriptionMaster\".");
+ return;
+ }
+
+ // Pop this value off, then replace it with Calamity's new string.
+ cursor.EmitPop();
+ cursor.Emit(OpCodes.Ldstr, "Mods.CalamityMod.UI.WorldMaster");
}
#endregion
diff --git a/Localization/en-US/Mods.CalamityMod.UI.hjson b/Localization/en-US/Mods.CalamityMod.UI.hjson
index 3b8b83aede..0fa1723928 100644
--- a/Localization/en-US/Mods.CalamityMod.UI.hjson
+++ b/Localization/en-US/Mods.CalamityMod.UI.hjson
@@ -1,4 +1,6 @@
+// Vanilla UI edits
SmallWorldWarning: "[c/FF0000:SMALL WORLDS NOT SUPPORTED BY CALAMITY]"
+WorldMaster: Game over man, game over! (Brutally hard boss changes, for the truly brave)
// Main UI Elements
Adrenaline: Adrenaline
Nanomachines: Nanomachines