diff --git a/YAMS-LIB/Program.cs b/YAMS-LIB/Program.cs index 1755544..c8dbc1d 100644 --- a/YAMS-LIB/Program.cs +++ b/YAMS-LIB/Program.cs @@ -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 @@ -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) { @@ -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) """); @@ -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; @@ -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; @@ -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) { @@ -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) diff --git a/YAMS-LIB/SeedObject.cs b/YAMS-LIB/SeedObject.cs index 9b4f83e..1937654 100644 --- a/YAMS-LIB/SeedObject.cs +++ b/YAMS-LIB/SeedObject.cs @@ -478,6 +478,8 @@ public enum ItemEnum SuperMissileDrop, [EnumMember(Value = "Power Bomb Drop")] PBombDrop, + [EnumMember(Value = "Flashlight")] + Flashlight, [EnumMember(Value = "Speed Booster Upgrade")] SpeedBoosterUpgrade, } diff --git a/YAMS-LIB/sprites/items/flashlight/sItemFlashlight_1.png b/YAMS-LIB/sprites/items/flashlight/sItemFlashlight_1.png new file mode 100644 index 0000000..402ff0b Binary files /dev/null and b/YAMS-LIB/sprites/items/flashlight/sItemFlashlight_1.png differ diff --git a/YAMS-LIB/sprites/items/flashlight/sItemFlashlight_2.png b/YAMS-LIB/sprites/items/flashlight/sItemFlashlight_2.png new file mode 100644 index 0000000..30ad637 Binary files /dev/null and b/YAMS-LIB/sprites/items/flashlight/sItemFlashlight_2.png differ