Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IBJ as item #197

Merged
merged 1 commit into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions YAMS-LIB/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1974,6 +1974,23 @@ void RotateTextureAndSaveToTexturePage(int rotation, UndertaleTexturePageItem te
"if (state == JUMPING && statetime > 4 && position_meeting(x, (y + 8), oSolid) == 0 && justwalljumped == 0 && walljumping == 0 && monster_drain == 0)",
"if (state == JUMPING && statetime > 4 && position_meeting(x, (y + 8), oSolid) == 0 && justwalljumped == 0 && walljumping == 0 && monster_drain == 0 && global.hasWJ)");

// Add IBJ as item
characterVarsCode.PrependGMLInCode("global.hasIBJ = 0;");
gmData.Code.ByName("gml_Script_characterCreateEvent").AppendGMLInCode("IBJ_MIDAIR_MAX = 3; IBJLaidInAir = IBJ_MIDAIR_MAX;");
gmData.Code.ByName("gml_Object_oCharacter_Collision_435").ReplaceGMLInCode("if (isCollisionTop(6) == 0)",
"""
if (!global.hasIBJ)
{
if (state == AIRBALL)
IBJLaidInAir--
else
IBJLaidInAir = IBJ_MIDAIR_MAX
if (IBJLaidInAir <= 0)
exit
}
if (isCollisionTop(6) == 0)
""");

// Save current hash seed, so we can compare saves later
characterVarsCode.PrependGMLInCode($"global.gameHash = \"{seedObject.Identifier.WordHash} ({seedObject.Identifier.Hash}) (World: {seedObject.Identifier.WorldUUID})\"");

Expand Down Expand Up @@ -2396,6 +2413,9 @@ void RotateTextureAndSaveToTexturePage(int rotation, UndertaleTexturePageItem te
case ItemEnum.Walljump:
characterVarsCode.ReplaceGMLInCode("global.hasWJ = 0", $"global.hasWJ = {quantity}");
break;
case ItemEnum.InfiniteBombJump:
characterVarsCode.ReplaceGMLInCode("global.hasIBJ = 0", $"global.hasIBJ = {quantity}");
break;
case ItemEnum.Nothing:
break;
default:
Expand Down Expand Up @@ -2623,6 +2643,7 @@ void RotateTextureAndSaveToTexturePage(int rotation, UndertaleTexturePageItem te
gmData.Scripts.AddScript("get_blindfold", "global.flashlightLevel -= argument0; with (oLightEngine) instance_destroy(); with (oFlashlight64) instance_destroy(); if (instance_exists(oCharacter)) ApplyLightPreset();");
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;");

// 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 @@ -2706,6 +2727,7 @@ void RotateTextureAndSaveToTexturePage(int rotation, UndertaleTexturePageItem te
$"event_inherited(); if (active) {{ get_blindfold({pickup.Quantity}); }}",
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.Nothing => "event_inherited();",
_ => throw new NotSupportedException("Unsupported item! " + pickup.ItemEffect)
};
Expand Down Expand Up @@ -3645,6 +3667,9 @@ void RotateTextureAndSaveToTexturePage(int rotation, UndertaleTexturePageItem te
case "{{ItemEnum.Walljump.GetEnumMemberValue()}}":
get_walljump_upgrade()
break
case "{{ItemEnum.InfiniteBombJump.GetEnumMemberValue()}}":
get_IBJ_upgrade()
break
default:
if (string_count("Metroid DNA", itemName) > 0)
{
Expand Down
2 changes: 2 additions & 0 deletions YAMS-LIB/SeedObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
{
[JsonInclude]
[JsonPropertyName("configuration_identifier")]
public ConfigurationIdentifier Identifier;

Check warning on line 15 in YAMS-LIB/SeedObject.cs

View workflow job for this annotation

GitHub Actions / Build YAMS-Lib and Python Wheel

Non-nullable field 'Identifier' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

[JsonInclude]
[JsonPropertyName("game_patches")]
public GamePatches Patches;

Check warning on line 19 in YAMS-LIB/SeedObject.cs

View workflow job for this annotation

GitHub Actions / Build YAMS-Lib and Python Wheel

Non-nullable field 'Patches' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

[JsonInclude]
[JsonPropertyName("door_locks")]
Expand Down Expand Up @@ -293,15 +293,15 @@

[JsonInclude]
[JsonPropertyName("locked_missile_text")]
public TextDetails LockedMissileText;

Check warning on line 296 in YAMS-LIB/SeedObject.cs

View workflow job for this annotation

GitHub Actions / Build YAMS-Lib and Python Wheel

Non-nullable field 'LockedMissileText' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

[JsonInclude]
[JsonPropertyName("locked_super_text")]
public TextDetails LockedSuperText;

Check warning on line 300 in YAMS-LIB/SeedObject.cs

View workflow job for this annotation

GitHub Actions / Build YAMS-Lib and Python Wheel

Non-nullable field 'LockedSuperText' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

[JsonInclude]
[JsonPropertyName("locked_pb_text")]
public TextDetails LockedPBombText;

Check warning on line 304 in YAMS-LIB/SeedObject.cs

View workflow job for this annotation

GitHub Actions / Build YAMS-Lib and Python Wheel

Non-nullable field 'LockedPBombText' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.
}

public class ConfigurationIdentifier
Expand Down Expand Up @@ -526,16 +526,18 @@
SpeedBoosterUpgrade,
[EnumMember(Value = "Walljump")]
Walljump,
[EnumMember(Value = "Infinite Bomb Jump")]
InfiniteBombJump,
}

public class PickupObject
{
[JsonInclude]
[JsonPropertyName("item_id")]
public string ItemID;

Check warning on line 537 in YAMS-LIB/SeedObject.cs

View workflow job for this annotation

GitHub Actions / Build YAMS-Lib and Python Wheel

Non-nullable field 'ItemID' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.
[JsonInclude]
[JsonPropertyName("sprite_details")]
public SpriteDetails SpriteDetails;

Check warning on line 540 in YAMS-LIB/SeedObject.cs

View workflow job for this annotation

GitHub Actions / Build YAMS-Lib and Python Wheel

Non-nullable field 'SpriteDetails' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.
[JsonInclude]
[JsonPropertyName("item_effect")]
public ItemEnum ItemEffect;
Expand All @@ -545,7 +547,7 @@

[JsonInclude]
[JsonPropertyName("text")]
public TextDetails Text;

Check warning on line 550 in YAMS-LIB/SeedObject.cs

View workflow job for this annotation

GitHub Actions / Build YAMS-Lib and Python Wheel

Non-nullable field 'Text' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

}

Expand Down
Loading