Skip to content

Commit

Permalink
YAMS: Add Flashlight item (#95)
Browse files Browse the repository at this point in the history
* YAMS: Add Flashlight item

- Added: Flashlight item to brighten rooms
- TODO: better sprites

* Fix comment style and add missing break

* Slightly rephrase todo

---------

Co-authored-by: Miepee <[email protected]>
  • Loading branch information
JeffGainsNGames and Miepee authored Oct 2, 2023
1 parent a562c6a commit 4cdb901
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
29 changes: 27 additions & 2 deletions YAMS-LIB/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,17 @@ void AddAllSpritesFromDir(string dirPath)
}
});

// TODO: add better Flashlight sprites
gmData.Sprites.Add(new UndertaleSprite()
{
Name = gmData.Strings.MakeString("sFlashlight"), Height = 16, Width = 16, MarginRight = 15, MarginBottom = 15, OriginX = 0, OriginY = 16,
Textures =
{
new UndertaleSprite.TextureEntry() {Texture = gmData.TexturePageItems[nameToPageItemDict["sItemFlashlight_1"]] },
new UndertaleSprite.TextureEntry() {Texture = gmData.TexturePageItems[nameToPageItemDict["sItemFlashlight_2"]] },
}
});

gmData.Sprites.Add(new UndertaleSprite()
{
// TODO: sprite is offset by a bit? Double check whether thats still the case
Expand Down Expand Up @@ -2007,7 +2018,9 @@ void RotateTextureAndSaveToTexturePage(int rotation, UndertaleTexturePageItem te
ds_list_add(list, global.gameHash)
ds_list_add(list, global.dna)
ds_list_add(list, global.startingSave)
ds_list_add(list, global.flashlightLevel)
ds_list_add(list, global.speedBoosterFramesReduction)
comment = "gives me some leeway in case i need to add more"
repeat (14)
{
Expand Down Expand Up @@ -2059,7 +2072,8 @@ void RotateTextureAndSaveToTexturePage(int rotation, UndertaleTexturePageItem te
global.maxpbombs = readline()
global.gameHash = readline()
global.dna = readline()
global.startingSave = readline();
global.startingSave = readline()
global.flashlightLevel = readline()
global.speedBoosterFramesReduction = readline();
ds_list_clear(list)
""");
Expand Down Expand Up @@ -2115,6 +2129,14 @@ void RotateTextureAndSaveToTexturePage(int rotation, UndertaleTexturePageItem te
ReplaceGMLInCode(characterVarsCode, "global.playerhealth = 99", $"global.playerhealth = {seedObject.Patches.EnergyPerTank-1};");
ReplaceGMLInCode(eTankCharacterEvent, "global.maxhealth += (100 * oControl.mod_etankhealthmult)", $"global.maxhealth += {seedObject.Patches.EnergyPerTank}");

// Flashlight
PrependGMLInCode(characterVarsCode, "global.flashlightLevel = 0;");
PrependGMLInCode(gmData.Code.ByName("gml_Script_ApplyLightPreset"), """
global.darkness -= global.flashlightLevel
if (global.darkness < 0)
global.darkness = 0
""");

// Set starting items
bool alreadyAddedMissiles = false;
bool alreadyAddedSupers = false;
Expand Down Expand Up @@ -2236,6 +2258,9 @@ void RotateTextureAndSaveToTexturePage(int rotation, UndertaleTexturePageItem te
case ItemEnum.Morphball:
ReplaceGMLInCode(characterVarsCode, "global.hasMorph = 0", $"global.hasMorph = {quantity};");
break;
case ItemEnum.Flashlight:
ReplaceGMLInCode(characterVarsCode, "global.flashlightLevel = 0", $"global.flashlightLevel = {quantity};");
break;
case ItemEnum.SpeedBoosterUpgrade:
ReplaceGMLInCode(characterVarsCode, "global.speedBoosterFramesReduction = 0", $"global.speedBoosterFramesReduction = {quantity}");
break;
Expand Down Expand Up @@ -2455,7 +2480,6 @@ void RotateTextureAndSaveToTexturePage(int rotation, UndertaleTexturePageItem te
throw new NotSupportedException($"There is no door with ID {id}!");
}


// Modify every location item, to give the wished item, spawn the wished text and the wished sprite
foreach ((var pickupName, PickupObject pickup) in seedObject.PickupObjects)
{
Expand Down Expand Up @@ -2575,6 +2599,7 @@ void RotateTextureAndSaveToTexturePage(int rotation, UndertaleTexturePageItem te
ItemEnum.MissileDrop => $"event_inherited(); if (active) {{ global.missiles += {pickup.Quantity}; if (global.missiles > global.maxmissiles) global.missiles = global.maxmissiles }}",
ItemEnum.SuperMissileDrop => $"event_inherited(); if (active) {{ global.smissiles += {pickup.Quantity}; if (global.smissiles > global.maxsmissiles) global.smissiles = global.maxsmissiles }}",
ItemEnum.PBombDrop => $"event_inherited(); if (active) {{ global.pbombs += {pickup.Quantity}; if (global.pbombs > global.maxpbombs) global.pbombs = global.maxpbombs }}",
ItemEnum.Flashlight => $"event_inherited(); if (active) {{ global.flashlightLevel += {pickup.Quantity}; with (oLightEngine) instance_destroy(); with (oFlashlight64) instance_destroy(); ApplyLightPreset() }}",
ItemEnum.SpeedBoosterUpgrade => $"event_inherited(); if (active) {{ global.speedBoosterFramesReduction += {pickup.Quantity}; }}",
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 @@ -478,6 +478,8 @@ public enum ItemEnum
SuperMissileDrop,
[EnumMember(Value = "Power Bomb Drop")]
PBombDrop,
[EnumMember(Value = "Flashlight")]
Flashlight,
[EnumMember(Value = "Speed Booster Upgrade")]
SpeedBoosterUpgrade,
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 4cdb901

Please sign in to comment.