diff --git a/YAMS-LIB/Program.cs b/YAMS-LIB/Program.cs index 0b90d0f..3bfc332 100644 --- a/YAMS-LIB/Program.cs +++ b/YAMS-LIB/Program.cs @@ -1,6 +1,8 @@ -using System.Globalization; +using System.Data.Common; +using System.Globalization; using System.Reflection; using System.Text.Json; +using SixLabors.ImageSharp.Processing; using UndertaleModLib; using UndertaleModLib.Decompiler; using UndertaleModLib.Models; @@ -102,7 +104,7 @@ public static void Main(string am2rPath, string outputAm2rPath, string jsonPath) // Killing queen should not lock you out of the rest of the game - gmData.Code.ByName("gml_RoomCC_rm_a0h01_3762_Create").AppendGMLInCode("instance_destroy()"); + gmData.Rooms.ByName("rm_a0h01").GameObjects.Remove(gmData.Rooms.ByName("rm_a0h01").GameObjects.First(go => go.X == 4432 && go.Y == 992 && (Math.Abs(go.ScaleY - 4.0) < 0.1))); gmData.Code.ByName("gml_Room_rm_a0h01_Create").AppendGMLInCode("tile_layer_delete(-119)"); // Killing Queen spawns pickups (helps prevent softlocks with DLR) @@ -140,10 +142,10 @@ public static void Main(string am2rPath, string outputAm2rPath, string jsonPath) gmData.Code.ByName("gml_Object_oErisBossTrigger_Create_0").AppendGMLInCode("else { with (oDoor) lock = 4; }"); gmData.Code.ByName("gml_Room_rm_a8a11_Create").AppendGMLInCode("if (!global.event[307]) {with (oDoor) lock = 4;}"); - // Fix doors in tester to be always blue - TODO: remove instance IDs - foreach (string codeName in new[] { "gml_RoomCC_rm_a4a05_6510_Create", "gml_RoomCC_rm_a4a05_6511_Create" }) + // Fix doors in tester to be always blue + foreach (var door in gmData.Rooms.ByName("rm_a4a05").GameObjects.Where(go => go.ObjectDefinition.Name.Content == "oDoorA4")) { - gmData.Code.ByName(codeName).SubstituteGMLCode("lock = 0;"); + door.CreationCode.SubstituteGMLCode("lock = 0;"); } // Fix Tower activation unlocking right door for door lock rando @@ -154,8 +156,8 @@ public static void Main(string am2rPath, string outputAm2rPath, string jsonPath) "global.darkness = 0; with (oLightEngine) instance_destroy(); with (oFlashlight64); instance_destroy()"); gmData.Code.ByName("gml_Object_oProboscum_Create_0").AppendGMLInCode("active = true; image_index = 0;"); - // Fix tester events sharing an event with tower activated - moved tester to 207 - TODO: remove instance IDs - gmData.Code.ByName("gml_RoomCC_rm_a4a04_6496_Create").ReplaceGMLInCode("global.event[200] < 2", "!global.event[207]"); + // Fix tester events sharing an event with tower activated - moved tester to 207 + gmData.Rooms.ByName("rm_a4a04").GameObjects.First(go => go.X == 24 && go.Y == 80 && go.ObjectDefinition.Name.Content == "oDoorA4").CreationCode.ReplaceGMLInCode("global.event[200] < 2", "!global.event[207]"); gmData.Code.ByName("gml_Object_oTesterBossTrigger_Create_0").ReplaceGMLInCode("global.event[200] != 1", "global.event[207]"); gmData.Code.ByName("gml_Object_oTester_Step_0").ReplaceGMLInCode("global.event[200] = 2", "global.event[207] = 1;"); @@ -168,17 +170,14 @@ public static void Main(string am2rPath, string outputAm2rPath, string jsonPath) gmData.Code.ByName("gml_Object_oLightEngine_Other_11").ReplaceGMLInCode("1, 0.4", "0.7, 1.4"); gmData.Code.ByName("gml_Object_oLightEngine_Other_11").ReplaceGMLInCode("1, -0.4", "0.7, -1.4"); - // Fix doors in labs, by making them always blue, and the metroid listener lock/unlock them - TODO: remove instance IDs - foreach (string codeName in new[] - { - "gml_RoomCC_rm_a7b05_9400_Create", "gml_RoomCC_rm_a7b06_9413_Create", "gml_RoomCC_rm_a7b06_9414_Create", - "gml_RoomCC_rm_a7b06A_9421_Create", "gml_RoomCC_rm_a7b06A_9420_Create", "gml_RoomCC_rm_a7b07_9437_Create", "gml_RoomCC_rm_a7b07_9438_Create", - "gml_RoomCC_rm_a7b08_9455_Create", "gml_RoomCC_rm_a7b08_9454_Create", "gml_RoomCC_rm_a7b08A_9467_Create", "gml_RoomCC_rm_a7b08A_9470_Create" - }) + // Fix doors in labs, by making them always blue, and the metroid listener lock/unlock them + foreach (var roomName in new[] { "rm_a7b05", "rm_a7b06", "rm_a7b06A", "rm_a7b07", "rm_a7b08", "rm_a7b08A" }) { - gmData.Code.ByName(codeName).SubstituteGMLCode(""); + foreach (var door in gmData.Rooms.ByName(roomName).GameObjects.Where(go => go.ObjectDefinition.Name.Content == "oDoor")) + { + door.CreationCode.SubstituteGMLCode(""); + } } - gmData.Code.ByName("gml_Object_oMonsterDoorControl_Alarm_0").SubstituteGMLCode("if (instance_number(oMonster) > 0) { with (oDoor) lock = 4 }"); // Have option for missile doors to not open by supers @@ -273,8 +272,8 @@ public static void Main(string am2rPath, string outputAm2rPath, string jsonPath) gmData.Code.ByName("gml_Room_rm_a2a09_Create").ReplaceGMLInCode("global.event[101] = 4", ""); gmData.Code.ByName("gml_Room_rm_a2a19_Create").ReplaceGMLInCode("global.event[101] = 4", ""); - // Fix plasma chamber having a missile door instead of normal after tester dead - TODO: instance IDs - gmData.Code.ByName("gml_RoomCC_rm_a4a09_6582_Create").ReplaceGMLInCode("lock = 1", "lock = 0;"); + // Fix plasma chamber having a missile door instead of normal after tester dead + gmData.Rooms.ByName("rm_a4a09").GameObjects.First(go => go.X == 24 && go.Y == 80 && go.ObjectDefinition.Name.Content == "oDoorA4").CreationCode.ReplaceGMLInCode("lock = 1", "lock = 0;"); // Fix lab log not displaying progress bar gmData.Code.ByName("gml_Room_rm_a7b04A_Create").ReplaceGMLInCode("create_log_trigger(0, 44, 440, 111, 0, 0)", "create_log_trigger(0, 44, 438, 111, -60, 1)"); @@ -311,8 +310,8 @@ public static void Main(string am2rPath, string outputAm2rPath, string jsonPath) AddA6Pipes.Apply(gmData, decompileContext, seedObject); } - // Move alpha in nest - TODO: instance IDs - gmData.Code.ByName("gml_RoomCC_rm_a6a09_8945_Create").ReplaceGMLInCode("if (global.lavastate > 8)", "y = 320; if (false)"); + // Move alpha in nest + gmData.Rooms.ByName("rm_a6a09").GameObjects.First(go => go.X == 800 && go.Y == 368 && go.ObjectDefinition.Name.Content == "oMalpha3TriggerProx").CreationCode.ReplaceGMLInCode("if (global.lavastate > 8)", "y = 320; if (false)"); // Lock these blocks behind a setting because they can make for some interesting changes gmData.Code.ByName("gml_Room_rm_a0h07_Create").ReplaceGMLInCode( diff --git a/YAMS-LIB/patches/misc/RemoveHelperSeptoggs.cs b/YAMS-LIB/patches/misc/RemoveHelperSeptoggs.cs index fcd4578..4785e9e 100644 --- a/YAMS-LIB/patches/misc/RemoveHelperSeptoggs.cs +++ b/YAMS-LIB/patches/misc/RemoveHelperSeptoggs.cs @@ -17,23 +17,41 @@ public static void Apply(UndertaleData gmData, GlobalDecompileContext decompileC code.PrependGMLInCode("if (!global.septoggHelpers) return true; else return false;"); } - // TODO: do not use ignoreErrors, also get rid of instance IDs UndertaleGameObject? elderSeptogg = gmData.GameObjects.ByName("oElderSeptogg"); - foreach (UndertaleRoom room in gmData.Rooms) + foreach (var septogg in new[] + { + gmData.Rooms.ByName("rm_a0h11").GameObjects.First(go => go.X == 480 && go.Y == 768 && go.ObjectDefinition == elderSeptogg), + gmData.Rooms.ByName("rm_a0h29").GameObjects.First(go => go.X == 384 && go.Y == 312 && go.ObjectDefinition == elderSeptogg), + gmData.Rooms.ByName("rm_a1h05").GameObjects.First(go => go.X == 1184 && go.Y == 832 && go.ObjectDefinition == elderSeptogg), + gmData.Rooms.ByName("rm_a3h04").GameObjects.First(go => go.X == 528 && go.Y == 1344 && go.ObjectDefinition == elderSeptogg), + gmData.Rooms.ByName("rm_a3h04").GameObjects.First(go => go.X == 1728 && go.Y == 1248 && go.ObjectDefinition == elderSeptogg), + gmData.Rooms.ByName("rm_a3a07").GameObjects.First(go => go.X == 112 && go.Y == 240 && go.ObjectDefinition == elderSeptogg), + gmData.Rooms.ByName("rm_a3b02").GameObjects.First(go => go.X == 192 && go.Y == 896 && go.ObjectDefinition == elderSeptogg), + gmData.Rooms.ByName("rm_a3b08").GameObjects.First(go => go.X == 224 && go.Y == 352 && go.ObjectDefinition == elderSeptogg), + gmData.Rooms.ByName("rm_a0h17").GameObjects.First(go => go.X == 96 && go.Y == 352 && go.ObjectDefinition == elderSeptogg), + gmData.Rooms.ByName("rm_a4b02a").GameObjects.First(go => go.X == 120 && go.Y == 816 && go.ObjectDefinition == elderSeptogg), + gmData.Rooms.ByName("rm_a4b10").GameObjects.First(go => go.X == 144 && go.Y == 624 && go.ObjectDefinition == elderSeptogg), + gmData.Rooms.ByName("rm_a4b10").GameObjects.First(go => go.X == 512 && go.Y == 256 && go.ObjectDefinition == elderSeptogg), + gmData.Rooms.ByName("rm_a4b11").GameObjects.First(go => go.X == 224 && go.Y == 2288 && go.ObjectDefinition == elderSeptogg), + gmData.Rooms.ByName("rm_a5c13").GameObjects.First(go => go.X == 96 && go.Y == 704 && go.ObjectDefinition == elderSeptogg), + gmData.Rooms.ByName("rm_a5c14").GameObjects.First(go => go.X == 1056 && go.Y == 288 && go.ObjectDefinition == elderSeptogg), + gmData.Rooms.ByName("rm_a5c17").GameObjects.First(go => go.X == 192 && go.Y == 288 && go.ObjectDefinition == elderSeptogg), + gmData.Rooms.ByName("rm_a5c18").GameObjects.First(go => go.X == 128 && go.Y == 192 && go.ObjectDefinition == elderSeptogg), + gmData.Rooms.ByName("rm_a5c18").GameObjects.First(go => go.X == 480 && go.Y == 192 && go.ObjectDefinition == elderSeptogg), + gmData.Rooms.ByName("rm_a5c21").GameObjects.First(go => go.X == 160 && go.Y == 384 && go.ObjectDefinition == elderSeptogg), + gmData.Rooms.ByName("rm_a5c21").GameObjects.First(go => go.X == 96 && go.Y == 560 && go.ObjectDefinition == elderSeptogg), + }) { - foreach (UndertaleRoom.GameObject go in room.GameObjects.Where(go => go.ObjectDefinition == elderSeptogg && go.CreationCode is not null)) - { - go.CreationCode.ReplaceGMLInCode("oControl.mod_septoggs_bombjumps_easy == 0 && global.hasBombs == 1", - "!global.septoggHelpers", true); - } + septogg.CreationCode.ReplaceGMLInCode("oControl.mod_septoggs_bombjumps_easy == 0 && global.hasBombs == 1", + "!global.septoggHelpers"); } - gmData.Code.ByName("gml_RoomCC_rm_a0h25_4105_Create").ReplaceGMLInCode("else if (global.hasBombs == 1 || global.hasSpiderball == 1 || global.hasSpacejump == 1)", + gmData.Rooms.ByName("rm_a0h25").GameObjects.First(go => go.X == 120 && go.Y == 816 && go.ObjectDefinition == elderSeptogg).CreationCode.ReplaceGMLInCode( + "else if (global.hasBombs == 1 || global.hasSpiderball == 1 || global.hasSpacejump == 1)", "else if (!global.septoggHelpers)"); // Make these septoggs always appear instead of only when coming from certain room - gmData.Code.ByName("gml_RoomCC_rm_a2a13_5007_Create").ReplaceGMLInCode("&& oControl.mod_previous_room == 103", ""); - gmData.Code.ByName("gml_RoomCC_rm_a3a07_5533_Create").ReplaceGMLInCode("&& oControl.mod_previous_room == 136", ""); - gmData.Code.ByName("gml_RoomCC_rm_a5a05_8701_Create").ReplaceGMLInCode("&& oControl.mod_previous_room == 300", ""); - + gmData.Rooms.ByName("rm_a2a13").GameObjects.First(go => go.ObjectDefinition == elderSeptogg).CreationCode.ReplaceGMLInCode("&& oControl.mod_previous_room == 103", ""); + gmData.Rooms.ByName("rm_a3a07").GameObjects.First(go => go.ObjectDefinition == elderSeptogg).CreationCode.ReplaceGMLInCode("&& oControl.mod_previous_room == 136", ""); + gmData.Rooms.ByName("rm_a5a05").GameObjects.First(go => go.ObjectDefinition == elderSeptogg).CreationCode.ReplaceGMLInCode("&& oControl.mod_previous_room == 300", ""); } }