Skip to content

Commit

Permalink
move variables away
Browse files Browse the repository at this point in the history
  • Loading branch information
Miepee committed Jun 10, 2024
1 parent 57ae16e commit b946e36
Show file tree
Hide file tree
Showing 11 changed files with 12 additions and 16 deletions.
4 changes: 1 addition & 3 deletions YAMS-LIB/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion YAMS-LIB/patches/CosmeticHud.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ static void RotateTextureAndSaveToTexturePage(UndertaleEmbeddedTexture texture,

public static void Apply(UndertaleData gmData, GlobalDecompileContext decompileContext, SeedObject seedObject)
{
Dictionary<UndertaleEmbeddedTexture, List<Tuple<Rectangle, int>>> textureDict = new Dictionary<UndertaleEmbeddedTexture, List<Tuple<Rectangle, int>>>();
var textureDict = new Dictionary<UndertaleEmbeddedTexture, List<Tuple<Rectangle, int>>>();

// TODO: less copypaste
// Hue shift etanks
Expand Down
6 changes: 2 additions & 4 deletions YAMS-LIB/patches/geometry/BombBeforeA3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion YAMS-LIB/patches/geometry/ScrewPipeBlocks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
Expand Down
2 changes: 1 addition & 1 deletion YAMS-LIB/patches/geometry/SoftlockPrevention.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion YAMS-LIB/patches/misc/DontRespawnBombBlocks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion YAMS-LIB/patches/misc/RemoveHelperSeptoggs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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_")))
{
Expand Down
2 changes: 1 addition & 1 deletion YAMS-LIB/patches/qol/GameplayCutsceneSkip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)");
Expand Down
2 changes: 1 addition & 1 deletion YAMS-LIB/patches/qol/SaveCutsceneSkip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion YAMS-LIB/patches/qol/ShowUnveiledBreakables.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }");
Expand Down
2 changes: 1 addition & 1 deletion YAMS-LIB/patches/qol/SkipItemFanfares.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;");
Expand Down

0 comments on commit b946e36

Please sign in to comment.