Skip to content

Commit

Permalink
Add Long beam as an item
Browse files Browse the repository at this point in the history
  • Loading branch information
Miepee committed May 17, 2024
1 parent 403616c commit f62e15f
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 0 deletions.
13 changes: 13 additions & 0 deletions YAMS-LIB/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1428,6 +1428,11 @@ public static void Main(string am2rPath, string outputAm2rPath, string jsonPath)
global.curropt = 0
""");

// Add Long Beam as an item
characterVarsCode.PrependGMLInCode("global.hasLongBeam = 0;");
gmData.Code.ByName("gml_Object_oBeam_Create_0").AppendGMLInCode("existingTimer = 12;");
gmData.Code.ByName("gml_Object_oBeam_Step_0").PrependGMLInCode("if (existingTimer > 0) existingTimer--; if (existingTimer <= 0 && !global.hasLongBeam) instance_destroy()");

// Add WJ as item - TODO: set this to 0 when we have sprites!!!
characterVarsCode.PrependGMLInCode("global.hasWJ = 1;");
gmData.Code.ByName("gml_Script_characterStepEvent").ReplaceGMLInCode(
Expand Down Expand Up @@ -1615,6 +1620,7 @@ public static void Main(string am2rPath, string outputAm2rPath, string jsonPath)
ds_list_add(list, global.collectedItems)
ds_list_add(list, global.hasWJ)
ds_list_add(list, global.hasIBJ)
ds_list_add(list, global.hasLongBeam)
str_list = ds_list_write(list)
ds_list_clear(list)
return str_list;
Expand Down Expand Up @@ -1679,6 +1685,9 @@ public static void Main(string am2rPath, string outputAm2rPath, string jsonPath)
global.hasIBJ = readline()
if (global.hasIBJ == undefined)
global.hasIBJ = 1
global.hasLongBeam = readline()
if (global.hasLongBeam == undefined)
global.hasLongBeam = 1
ds_list_clear(list)
""");
gmData.Code.Add(loadGlobalsCode);
Expand Down Expand Up @@ -1891,6 +1900,8 @@ public static void Main(string am2rPath, string outputAm2rPath, string jsonPath)
case ItemEnum.InfiniteBombJump:
characterVarsCode.ReplaceGMLInCode("global.hasIBJ = 0", $"global.hasIBJ = {quantity}");
break;
case ItemEnum.LongBeam:

Check failure on line 1903 in YAMS-LIB/Program.cs

View workflow job for this annotation

GitHub Actions / Build YAMS-Lib and Python Wheel

Control cannot fall through from one case label ('case ItemEnum.LongBeam:') to another
characterVarsCode.ReplaceGMLInCode("global.hasLongBeam = 0", $"global.hasLongBeam = {quantity}");
case ItemEnum.Nothing:
break;
default:
Expand Down Expand Up @@ -2121,6 +2132,7 @@ public static void Main(string am2rPath, string outputAm2rPath, string jsonPath)
gmData.Scripts.AddScript("get_speed_booster_upgrade", "global.speedBoosterFramesReduction += argument0;");
gmData.Scripts.AddScript("get_walljump_upgrade", "global.hasWJ = 1;");
gmData.Scripts.AddScript("get_IBJ_upgrade", "global.hasIBJ = 1;");
gmData.Scripts.AddScript("get_long_beam", "global.hasLongBeam = 1;");

// Modify every location item, to give the wished item, spawn the wished text and the wished sprite
foreach ((string pickupName, PickupObject pickup) in seedObject.PickupObjects)
Expand Down Expand Up @@ -2205,6 +2217,7 @@ public static void Main(string am2rPath, string outputAm2rPath, string jsonPath)
ItemEnum.SpeedBoosterUpgrade => $"event_inherited(); if (active) {{ get_speed_booster_upgrade({pickup.Quantity}); }}",
ItemEnum.Walljump => "event_inherited(); if (active) { get_walljump_upgrade(); }",
ItemEnum.InfiniteBombJump => "event_inherited(); if (active) { get_IBJ_upgrade(); }",
ItemEnum.LongBeam => "event_inherited(); if (active) { get_long_beam(); }",
ItemEnum.Nothing => "event_inherited();",
_ => throw new NotSupportedException("Unsupported item! " + pickup.ItemEffect)
};
Expand Down
2 changes: 2 additions & 0 deletions YAMS-LIB/SeedObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,8 @@ public enum ItemEnum
Walljump,
[EnumMember(Value = "Infinite Bomb Jump")]
InfiniteBombJump,
[EnumMember(Value = "Long Beam")]
LongBeam,
}

public class PickupObject
Expand Down
3 changes: 3 additions & 0 deletions YAMS-LIB/patches/Multiworld.cs
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,9 @@ public static void Apply(UndertaleData gmData, GlobalDecompileContext decompileC
case "{{ItemEnum.InfiniteBombJump.GetEnumMemberValue()}}":
get_IBJ_upgrade()
break
case "{{ItemEnum.InfiniteBombJump.GetEnumMemberValue()}}":
get_long_beam()
break
default:
if (string_count("Metroid DNA", itemName) > 0)
{
Expand Down
2 changes: 2 additions & 0 deletions YAMS-LIB/patches/Sprites.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ void CreateAndAddItemSprite(string name)
Textures = GetTexturePageItemsForSpriteName("sItemSpeedBoosterUpgrade_")
});

CreateAndAddItemSprite("sItemLongBeam");

gmData.Sprites.Add(new UndertaleSprite
{
// TODO: sprite is offset by a bit? Double check whether thats still the case
Expand Down
Binary file added YAMS-LIB/sprites/items/longBeam/sItemLongBeam_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added YAMS-LIB/sprites/items/longBeam/sItemLongBeam_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added YAMS-LIB/sprites/items/longBeam/sItemLongBeam_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added YAMS-LIB/sprites/items/longBeam/sItemLongBeam_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f62e15f

Please sign in to comment.