Skip to content

Commit

Permalink
Add option to enforce screw attack for BG2
Browse files Browse the repository at this point in the history
  • Loading branch information
Miepee committed Jul 5, 2024
1 parent 5bc41b9 commit 6cdebd2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions YAMS-LIB/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ public static void Main(string am2rPath, string outputAm2rPath, string jsonPath)
BombBeforeA3.Apply(gmData, decompileContext, seedObject);
SoftlockPrevention.Apply(gmData, decompileContext, seedObject, isHorde);
DontRespawnBombBlocks.Apply(gmData, decompileContext, seedObject);
EnforceScrewForBG2.Apply(gmData, decompileContext, seedObject);


// On start, make all rooms show being "unexplored" similar to prime/super rando
Expand Down
4 changes: 4 additions & 0 deletions YAMS-LIB/SeedObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,10 @@ [JsonInclude] [JsonPropertyName("grave_grotto_blocks")]
[JsonPropertyName("screw_blocks")]
public bool ScrewPipeBlocks;

[JsonInclude]
[JsonPropertyName("enforce_screw_for_bg2")]
public bool EnforceScrewForBG2;

[JsonInclude]
[JsonPropertyName("sabre_designed_skippy")]
public bool SabreSkippy;
Expand Down
16 changes: 16 additions & 0 deletions YAMS-LIB/patches/geometry/EnforceScrewForBG2.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using UndertaleModLib;
using UndertaleModLib.Decompiler;
using UndertaleModLib.Models;

namespace YAMS_LIB.patches.geometry;

public class EnforceScrewForBG2
{
public static void Apply(UndertaleData gmData, GlobalDecompileContext decompileContext, SeedObject seedObject)
{
UndertaleCode? characterVarsCode = gmData.Code.ByName("gml_Script_load_character_vars");
characterVarsCode.AppendGMLInCode($"global.enforceScrewForBG2 = {(seedObject.Patches.EnforceScrewForBG2 ? "1" : "0")};");

gmData.Code.ByName("gml_Object_Rooma3c03Fix_Collision_267").ReplaceGMLInCode("global.screwattack == 0", "!global.screwattack && !global.enforceScrewForBG2");
}
}

0 comments on commit 6cdebd2

Please sign in to comment.