From b946e364f7fc7a42bdec35c43a8a92fb07e7a927 Mon Sep 17 00:00:00 2001 From: Miepee Date: Mon, 10 Jun 2024 16:01:27 +0200 Subject: [PATCH] move variables away --- YAMS-LIB/Program.cs | 4 +--- YAMS-LIB/patches/CosmeticHud.cs | 2 +- YAMS-LIB/patches/geometry/BombBeforeA3.cs | 6 ++---- YAMS-LIB/patches/geometry/ScrewPipeBlocks.cs | 2 +- YAMS-LIB/patches/geometry/SoftlockPrevention.cs | 2 +- YAMS-LIB/patches/misc/DontRespawnBombBlocks.cs | 2 +- YAMS-LIB/patches/misc/RemoveHelperSeptoggs.cs | 2 +- YAMS-LIB/patches/qol/GameplayCutsceneSkip.cs | 2 +- YAMS-LIB/patches/qol/SaveCutsceneSkip.cs | 2 +- YAMS-LIB/patches/qol/ShowUnveiledBreakables.cs | 2 +- YAMS-LIB/patches/qol/SkipItemFanfares.cs | 2 +- 11 files changed, 12 insertions(+), 16 deletions(-) diff --git a/YAMS-LIB/Program.cs b/YAMS-LIB/Program.cs index f585a47..63f000e 100644 --- a/YAMS-LIB/Program.cs +++ b/YAMS-LIB/Program.cs @@ -514,9 +514,7 @@ public static void Main(string am2rPath, string outputAm2rPath, string jsonPath) // Have new variables for certain events because they are easier to debug via a switch than changing a ton of values // TODO: move these all into their seperate patches. - characterVarsCode.PrependGMLInCode( - "global.septoggHelpers = 0; global.skipCutscenes = 0; global.skipSaveCutscene = 0; global.skipItemFanfare = 0; global.respawnBombBlocks = 0; global.screwPipeBlocks = 0;" + - "global.a3Block = 0; global.softlockPrevention = 0; global.unveilBlocks = 0; global.canUseSupersOnMissileDoors = 0;"); + characterVarsCode.PrependGMLInCode("global.canUseSupersOnMissileDoors = 0;"); // Set geothermal reactor to always be exploded characterVarsCode.AppendGMLInCode("global.event[203] = 9"); diff --git a/YAMS-LIB/patches/CosmeticHud.cs b/YAMS-LIB/patches/CosmeticHud.cs index b27322e..3a043d5 100644 --- a/YAMS-LIB/patches/CosmeticHud.cs +++ b/YAMS-LIB/patches/CosmeticHud.cs @@ -24,7 +24,7 @@ static void RotateTextureAndSaveToTexturePage(UndertaleEmbeddedTexture texture, public static void Apply(UndertaleData gmData, GlobalDecompileContext decompileContext, SeedObject seedObject) { - Dictionary>> textureDict = new Dictionary>>(); + var textureDict = new Dictionary>>(); // TODO: less copypaste // Hue shift etanks diff --git a/YAMS-LIB/patches/geometry/BombBeforeA3.cs b/YAMS-LIB/patches/geometry/BombBeforeA3.cs index cd5b269..4de4823 100644 --- a/YAMS-LIB/patches/geometry/BombBeforeA3.cs +++ b/YAMS-LIB/patches/geometry/BombBeforeA3.cs @@ -11,10 +11,8 @@ public static void Apply(UndertaleData gmData, GlobalDecompileContext decompileC UndertaleCode? characterVarsCode = gmData.Code.ByName("gml_Script_load_character_vars"); // Bomb block before a3 entry - if (seedObject.Patches.A3EntranceBlocks) - { - characterVarsCode.ReplaceGMLInCode("global.a3Block = 0", "global.a3Block = 1;"); - } + characterVarsCode.AppendGMLInCode($"global.a3Block = {(seedObject.Patches.A3EntranceBlocks ? "1" : "0")};"); + var bombBlock = gmData.Rooms.ByName("rm_a3h03").GameObjects.First(go => go.X == 896 && go.Y == 160 && go.ObjectDefinition.Name.Content == "oBlockBomb"); bombBlock.CreationCode.ReplaceGMLInCode( diff --git a/YAMS-LIB/patches/geometry/ScrewPipeBlocks.cs b/YAMS-LIB/patches/geometry/ScrewPipeBlocks.cs index 3fbba01..8c85cb6 100644 --- a/YAMS-LIB/patches/geometry/ScrewPipeBlocks.cs +++ b/YAMS-LIB/patches/geometry/ScrewPipeBlocks.cs @@ -11,7 +11,7 @@ public static void Apply(UndertaleData gmData, GlobalDecompileContext decompileC UndertaleCode? characterVarsCode = gmData.Code.ByName("gml_Script_load_character_vars"); // screw+pipes related - if (seedObject.Patches.ScrewPipeBlocks) characterVarsCode.ReplaceGMLInCode("global.screwPipeBlocks = 0", "global.screwPipeBlocks = 1"); + characterVarsCode.AppendGMLInCode($"global.screwPipeBlocks = {(seedObject.Patches.ScrewPipeBlocks ? "1" : "0")}"); // Screw blocks before normal pipe rooms foreach (string codeName in new[] diff --git a/YAMS-LIB/patches/geometry/SoftlockPrevention.cs b/YAMS-LIB/patches/geometry/SoftlockPrevention.cs index 758ffe7..3c498a2 100644 --- a/YAMS-LIB/patches/geometry/SoftlockPrevention.cs +++ b/YAMS-LIB/patches/geometry/SoftlockPrevention.cs @@ -11,7 +11,7 @@ public static void Apply(UndertaleData gmData, GlobalDecompileContext decompileC UndertaleCode? characterVarsCode = gmData.Code.ByName("gml_Script_load_character_vars"); // Softlock prevention blocks - if (seedObject.Patches.SoftlockPrevention) characterVarsCode.ReplaceGMLInCode("global.softlockPrevention = 0", "global.softlockPrevention = 1;"); + characterVarsCode.AppendGMLInCode($"global.softlockPrevention = {(seedObject.Patches.SoftlockPrevention ? "1" : "0")};"); // gml_Room_rm_a3b08_Create - some shot / solid blocks in BG3 // Also change these to chain bomb blocks diff --git a/YAMS-LIB/patches/misc/DontRespawnBombBlocks.cs b/YAMS-LIB/patches/misc/DontRespawnBombBlocks.cs index 107e380..45ffff1 100644 --- a/YAMS-LIB/patches/misc/DontRespawnBombBlocks.cs +++ b/YAMS-LIB/patches/misc/DontRespawnBombBlocks.cs @@ -11,7 +11,7 @@ public static void Apply(UndertaleData gmData, GlobalDecompileContext decompileC UndertaleCode? characterVarsCode = gmData.Code.ByName("gml_Script_load_character_vars"); // Stop Bomb blocks from respawning - if (seedObject.Patches.RespawnBombBlocks) characterVarsCode.ReplaceGMLInCode("global.respawnBombBlocks = 0", "global.respawnBombBlocks = 1"); + characterVarsCode.AppendGMLInCode($"global.respawnBombBlocks = {(seedObject.Patches.RespawnBombBlocks ? "1" : "0")}"); // The position here is for a puzzle in a2, that when not respawned makes it a tad hard. gmData.Code.ByName("gml_Object_oBlockBomb_Other_10").PrependGMLInCode("if (!global.respawnBombBlocks && !(room == rm_a2a06 && x == 624 && y == 128)) regentime = -1"); diff --git a/YAMS-LIB/patches/misc/RemoveHelperSeptoggs.cs b/YAMS-LIB/patches/misc/RemoveHelperSeptoggs.cs index 6d1b239..fcd4578 100644 --- a/YAMS-LIB/patches/misc/RemoveHelperSeptoggs.cs +++ b/YAMS-LIB/patches/misc/RemoveHelperSeptoggs.cs @@ -10,7 +10,7 @@ public static void Apply(UndertaleData gmData, GlobalDecompileContext decompileC { UndertaleCode? characterVarsCode = gmData.Code.ByName("gml_Script_load_character_vars"); // Turn off Septoggs if the wished configuration - if (seedObject.Patches.SeptoggHelpers) characterVarsCode.ReplaceGMLInCode("global.septoggHelpers = 0", "global.septoggHelpers = 1"); + characterVarsCode.AppendGMLInCode($"global.septoggHelpers = {(seedObject.Patches.SeptoggHelpers ? "1" : "0")}"); foreach (UndertaleCode? code in gmData.Code.Where(c => c.Name.Content.StartsWith("gml_Script_scr_septoggs_"))) { diff --git a/YAMS-LIB/patches/qol/GameplayCutsceneSkip.cs b/YAMS-LIB/patches/qol/GameplayCutsceneSkip.cs index bb7f772..2866d11 100644 --- a/YAMS-LIB/patches/qol/GameplayCutsceneSkip.cs +++ b/YAMS-LIB/patches/qol/GameplayCutsceneSkip.cs @@ -10,7 +10,7 @@ public static void Apply(UndertaleData gmData, GlobalDecompileContext decompileC { UndertaleCode? characterVarsCode = gmData.Code.ByName("gml_Script_load_character_vars"); // Skip most cutscenes when enabled - if (seedObject.Patches.SkipCutscenes) characterVarsCode.ReplaceGMLInCode("global.skipCutscenes = 0", "global.skipCutscenes = 1"); + characterVarsCode.AppendGMLInCode($"global.skipCutscenes = {(seedObject.Patches.SkipCutscenes ? "1" : "0")}"); // Skip Intro cutscene instantly gmData.Code.ByName("gml_Object_oIntroCutscene_Create_0").PrependGMLInCode("room_change(15, 0)"); diff --git a/YAMS-LIB/patches/qol/SaveCutsceneSkip.cs b/YAMS-LIB/patches/qol/SaveCutsceneSkip.cs index 66260a0..3469c65 100644 --- a/YAMS-LIB/patches/qol/SaveCutsceneSkip.cs +++ b/YAMS-LIB/patches/qol/SaveCutsceneSkip.cs @@ -10,7 +10,7 @@ public static void Apply(UndertaleData gmData, GlobalDecompileContext decompileC { UndertaleCode? characterVarsCode = gmData.Code.ByName("gml_Script_load_character_vars"); - if (seedObject.Patches.SkipSaveCutscene) characterVarsCode.ReplaceGMLInCode("global.skipSaveCutscene = 0", "global.skipSaveCutscene = 1"); + characterVarsCode.AppendGMLInCode($"global.skipSaveCutscene = {(seedObject.Patches.SkipSaveCutscene ? "1" : "0")}"); gmData.Code.ByName("gml_Script_characterStepEvent").ReplaceGMLInCode(""" if (statetime == 1) diff --git a/YAMS-LIB/patches/qol/ShowUnveiledBreakables.cs b/YAMS-LIB/patches/qol/ShowUnveiledBreakables.cs index 730ae40..4aa6f9c 100644 --- a/YAMS-LIB/patches/qol/ShowUnveiledBreakables.cs +++ b/YAMS-LIB/patches/qol/ShowUnveiledBreakables.cs @@ -9,7 +9,7 @@ public static void Apply(UndertaleData gmData, GlobalDecompileContext decompileC { var characterVarsCode = gmData.Code.ByName("gml_Script_load_character_vars"); // Force all breakables (except the hidden super blocks) to be visible - if (seedObject.Cosmetics.UnveilBlocks) characterVarsCode.ReplaceGMLInCode("global.unveilBlocks = 0", "global.unveilBlocks = 1"); + characterVarsCode.AppendGMLInCode($"global.unveilBlocks = {(seedObject.Cosmetics.UnveilBlocks ? "1" : "0")}"); gmData.Code.ByName("gml_Object_oSolid_Alarm_5").AppendGMLInCode("if (global.unveilBlocks && sprite_index >= sBlockShoot && sprite_index <= sBlockSand)\n" + "{ event_user(1); visible = true; }"); diff --git a/YAMS-LIB/patches/qol/SkipItemFanfares.cs b/YAMS-LIB/patches/qol/SkipItemFanfares.cs index 5fd05e1..a90fe18 100644 --- a/YAMS-LIB/patches/qol/SkipItemFanfares.cs +++ b/YAMS-LIB/patches/qol/SkipItemFanfares.cs @@ -10,7 +10,7 @@ public static void Apply(UndertaleData gmData, GlobalDecompileContext decompileC { UndertaleCode? characterVarsCode = gmData.Code.ByName("gml_Script_load_character_vars"); - if (seedObject.Patches.SkipItemFanfares) characterVarsCode.ReplaceGMLInCode("global.skipItemFanfare = 0", "global.skipItemFanfare = 1"); + characterVarsCode.AppendGMLInCode($"global.skipItemFanfare = {(seedObject.Patches.SkipItemFanfares ? "1" : "0")}"); // Put all items as type one gmData.Code.ByName("gml_Object_oItem_Other_10").PrependGMLInCode("if (global.skipItemFanfare) itemtype = 1;");