From 1af694d72dc003edaef8f2f3036008d0fd443286 Mon Sep 17 00:00:00 2001 From: craftersshaft Date: Tue, 25 May 2021 16:03:45 -0400 Subject: [PATCH 1/7] Adding health stuff to Modcharts --- docs/modchart.md | 9 +++++++++ source/ModchartState.hx | 25 +++++++++++++++++++++++++ source/PlayState.hx | 12 +++++++++--- 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/docs/modchart.md b/docs/modchart.md index 5bf68a5..4e5b08a 100644 --- a/docs/modchart.md +++ b/docs/modchart.md @@ -145,6 +145,7 @@ Kade Engine provides a list of global variables to be used in the lua scripting | scrollSpeed | Int | The current scrollspeed | | mustHit | Bool | If the current section is a must hit section | | strumLineY | Float | The current Strum Line Y Position | +| health | Float | The current health of the player | ## Functions @@ -465,3 +466,11 @@ Sets the window's position ##### resizeWindow(int width, int height) Resizes the window + + +### Misc + +##### setHealth(float heal) + +Sets the player's health + diff --git a/source/ModchartState.hx b/source/ModchartState.hx index 62fdeb7..4c2ac07 100644 --- a/source/ModchartState.hx +++ b/source/ModchartState.hx @@ -232,7 +232,23 @@ class ModchartState public static var luaSprites:Map = []; + function changeDadCharacter(id:String) + { var olddadx = PlayState.dad.x; + var olddady = PlayState.dad.y; + PlayState.instance.removeObject(PlayState.dad); + PlayState.dad = new Character(olddadx, olddady, id); + PlayState.instance.addObject(PlayState.dad); + PlayState.instance.iconP2.animation.play(id); + } + function changeBoyfriendCharacter(id:String) + { var oldboyfriendx = PlayState.boyfriend.x; + var oldboyfriendy = PlayState.boyfriend.y; + PlayState.instance.removeObject(PlayState.boyfriend); + PlayState.boyfriend = new Boyfriend(oldboyfriendx, oldboyfriendy, id); + PlayState.instance.addObject(PlayState.boyfriend); + PlayState.instance.iconP2.animation.play(id); + } function makeLuaSprite(spritePath:String,toBeCalled:String, drawBehind:Bool) { @@ -312,6 +328,7 @@ class ModchartState // get some fukin globals up in here bois setVar("difficulty", PlayState.storyDifficulty); + setVar("health", PlayState.instance.health); setVar("bpm", Conductor.bpm); setVar("scrollspeed", FlxG.save.data.scrollSpeed != 1 ? FlxG.save.data.scrollSpeed : PlayState.SONG.speed); setVar("fpsCap", FlxG.save.data.fpsCap); @@ -349,6 +366,10 @@ class ModchartState // sprites Lua_helper.add_callback(lua,"makeSprite", makeLuaSprite); + + Lua_helper.add_callback(lua,"changeDadCharacter", changeDadCharacter); + + Lua_helper.add_callback(lua,"changeBoyfriendCharacter", changeBoyfriendCharacter); Lua_helper.add_callback(lua,"getProperty", getPropertyByName); @@ -365,6 +386,10 @@ class ModchartState Lua_helper.add_callback(lua,"setHudAngle", function (x:Float) { PlayState.instance.camHUD.angle = x; }); + + Lua_helper.add_callback(lua,"setHealth", function (heal:Float) { + PlayState.instance.health = heal; + }); Lua_helper.add_callback(lua,"setHudPosition", function (x:Int, y:Int) { PlayState.instance.camHUD.x = x; diff --git a/source/PlayState.hx b/source/PlayState.hx index 8b8f567..3e3040d 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -125,7 +125,7 @@ class PlayState extends MusicBeatState private var curSong:String = ""; private var gfSpeed:Int = 1; - private var health:Float = 1; + public var health:Float = 1; //making public for modchart's sake, but things could go wrong private var combo:Int = 0; public static var misses:Int = 0; private var accuracy:Float = 0.00; @@ -143,8 +143,8 @@ class PlayState extends MusicBeatState private var generatedMusic:Bool = false; private var startingSong:Bool = false; - private var iconP1:HealthIcon; - private var iconP2:HealthIcon; + public var iconP1:HealthIcon; //making these public for modcharts cause i dont know how else to do it + public var iconP2:HealthIcon; //what could go wrong? public var camHUD:FlxCamera; private var camGame:FlxCamera; @@ -1833,6 +1833,7 @@ class PlayState extends MusicBeatState if (health > 2) health = 2; + if (executeModchart && luaModchart != null){luaModchart.setVar('health', health);}; if (healthBar.percent < 20) iconP1.animation.curAnim.curFrame = 1; @@ -2362,6 +2363,7 @@ class PlayState extends MusicBeatState else { health -= 0.075; + if (executeModchart && luaModchart != null){ luaModchart.setVar('health', health);}; vocals.volume = 0; if (theFunne) noteMiss(daNote.noteData, daNote); @@ -2557,6 +2559,7 @@ class PlayState extends MusicBeatState combo = 0; misses++; health -= 0.2; + if (executeModchart && luaModchart != null){ luaModchart.setVar('health', health);}; ss = false; shits++; if (FlxG.save.data.accuracyMod == 0) @@ -2565,6 +2568,7 @@ class PlayState extends MusicBeatState daRating = 'bad'; score = 0; health -= 0.06; + if (executeModchart && luaModchart != null){ luaModchart.setVar('health', health);}; ss = false; bads++; if (FlxG.save.data.accuracyMod == 0) @@ -2576,11 +2580,13 @@ class PlayState extends MusicBeatState goods++; if (health < 2) health += 0.04; + if (executeModchart && luaModchart != null){ luaModchart.setVar('health', health);}; if (FlxG.save.data.accuracyMod == 0) totalNotesHit += 0.75; case 'sick': if (health < 2) health += 0.1; + if (executeModchart && luaModchart != null){ luaModchart.setVar('health', health);}; if (FlxG.save.data.accuracyMod == 0) totalNotesHit += 1; sicks++; From c11bb668ba56a7b08815d6b719f242a0d419f99c Mon Sep 17 00:00:00 2001 From: craftersshaft Date: Tue, 25 May 2021 16:20:10 -0400 Subject: [PATCH 2/7] when the keys are Just Pressed --- docs/modchart.md | 1 + source/PlayState.hx | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/docs/modchart.md b/docs/modchart.md index 4e5b08a..f6f9947 100644 --- a/docs/modchart.md +++ b/docs/modchart.md @@ -116,6 +116,7 @@ Current calls to functions include, | update | Elapsed frames | Gets called every frame (after the song starts) | | stepHit | Current Step | Gets called when ever a step hits (steps are in between beats, aka 4 steps are in a beat) | | beatHit | Current Beat | Gets called when ever a beat hits | +| keyPressed | Key Pressed | Gets called when a key just got pressed (up, down, left, right, accept) | diff --git a/source/PlayState.hx b/source/PlayState.hx index 3e3040d..d1a301e 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -2832,6 +2832,13 @@ class PlayState extends MusicBeatState controls.UP_R, controls.RIGHT_R ]; + if (luaModchart != null){ + if (controls.LEFT_P){luaModchart.executeState('keyPressed',["left"]);}; + if (controls.DOWN_P){luaModchart.executeState('keyPressed',["down"]);}; + if (controls.UP_P){luaModchart.executeState('keyPressed',["up"]);}; + if (controls.RIGHT_P){luaModchart.executeState('keyPressed',["right"]);}; + if (controls.ACCEPT_P){luaModchart.executeState('keyPressed',["accept"]);}; + }; // Prevent player input if botplay is on if(FlxG.save.data.botplay) From 17e5f2fb8b475f0f79eb9a84ee227b03c470f5ef Mon Sep 17 00:00:00 2001 From: craftersshaft Date: Tue, 25 May 2021 16:33:43 -0400 Subject: [PATCH 3/7] I May Be Stupid --- source/PlayState.hx | 1 - 1 file changed, 1 deletion(-) diff --git a/source/PlayState.hx b/source/PlayState.hx index d1a301e..7d4c82f 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -2837,7 +2837,6 @@ class PlayState extends MusicBeatState if (controls.DOWN_P){luaModchart.executeState('keyPressed',["down"]);}; if (controls.UP_P){luaModchart.executeState('keyPressed',["up"]);}; if (controls.RIGHT_P){luaModchart.executeState('keyPressed',["right"]);}; - if (controls.ACCEPT_P){luaModchart.executeState('keyPressed',["accept"]);}; }; // Prevent player input if botplay is on From 1307b8498d57e59d0efa11c2ec00ff448f111679 Mon Sep 17 00:00:00 2001 From: craftersshaft Date: Tue, 25 May 2021 16:51:47 -0400 Subject: [PATCH 4/7] I'm Even Stupider --- source/PlayState.hx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/source/PlayState.hx b/source/PlayState.hx index 7d4c82f..4fc23ee 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -2363,7 +2363,9 @@ class PlayState extends MusicBeatState else { health -= 0.075; + #if windows if (executeModchart && luaModchart != null){ luaModchart.setVar('health', health);}; + #end vocals.volume = 0; if (theFunne) noteMiss(daNote.noteData, daNote); @@ -2559,7 +2561,9 @@ class PlayState extends MusicBeatState combo = 0; misses++; health -= 0.2; + #if windows if (executeModchart && luaModchart != null){ luaModchart.setVar('health', health);}; + #end ss = false; shits++; if (FlxG.save.data.accuracyMod == 0) @@ -2568,7 +2572,9 @@ class PlayState extends MusicBeatState daRating = 'bad'; score = 0; health -= 0.06; + #if windows if (executeModchart && luaModchart != null){ luaModchart.setVar('health', health);}; + #end ss = false; bads++; if (FlxG.save.data.accuracyMod == 0) @@ -2580,13 +2586,17 @@ class PlayState extends MusicBeatState goods++; if (health < 2) health += 0.04; + #if windows if (executeModchart && luaModchart != null){ luaModchart.setVar('health', health);}; + #end if (FlxG.save.data.accuracyMod == 0) totalNotesHit += 0.75; case 'sick': if (health < 2) health += 0.1; + #if windows if (executeModchart && luaModchart != null){ luaModchart.setVar('health', health);}; + #end if (FlxG.save.data.accuracyMod == 0) totalNotesHit += 1; sicks++; @@ -2832,12 +2842,14 @@ class PlayState extends MusicBeatState controls.UP_R, controls.RIGHT_R ]; + #if windows if (luaModchart != null){ if (controls.LEFT_P){luaModchart.executeState('keyPressed',["left"]);}; if (controls.DOWN_P){luaModchart.executeState('keyPressed',["down"]);}; if (controls.UP_P){luaModchart.executeState('keyPressed',["up"]);}; if (controls.RIGHT_P){luaModchart.executeState('keyPressed',["right"]);}; }; + #end // Prevent player input if botplay is on if(FlxG.save.data.botplay) From 7a53d1ee08d84192f82f90e21c81aa926c4b7863 Mon Sep 17 00:00:00 2001 From: craftersshaft Date: Wed, 26 May 2021 07:03:18 -0400 Subject: [PATCH 5/7] Oops! --- source/PlayState.hx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/PlayState.hx b/source/PlayState.hx index 4fc23ee..f64a4e4 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -1833,8 +1833,9 @@ class PlayState extends MusicBeatState if (health > 2) health = 2; + #if windows if (executeModchart && luaModchart != null){luaModchart.setVar('health', health);}; - + #end if (healthBar.percent < 20) iconP1.animation.curAnim.curFrame = 1; else From ec2a16b02576df927d2e66d939c8c2827d151178 Mon Sep 17 00:00:00 2001 From: craftersshaft Date: Thu, 27 May 2021 14:22:57 -0400 Subject: [PATCH 6/7] health dies yay --- source/ModchartState.hx | 1 - source/PlayState.hx | 20 +------------------- 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/source/ModchartState.hx b/source/ModchartState.hx index 4c2ac07..7c8df78 100644 --- a/source/ModchartState.hx +++ b/source/ModchartState.hx @@ -328,7 +328,6 @@ class ModchartState // get some fukin globals up in here bois setVar("difficulty", PlayState.storyDifficulty); - setVar("health", PlayState.instance.health); setVar("bpm", Conductor.bpm); setVar("scrollspeed", FlxG.save.data.scrollSpeed != 1 ? FlxG.save.data.scrollSpeed : PlayState.SONG.speed); setVar("fpsCap", FlxG.save.data.fpsCap); diff --git a/source/PlayState.hx b/source/PlayState.hx index f64a4e4..ecf029c 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -125,7 +125,7 @@ class PlayState extends MusicBeatState private var curSong:String = ""; private var gfSpeed:Int = 1; - public var health:Float = 1; //making public for modchart's sake, but things could go wrong + private var health:Float = 1; private var combo:Int = 0; public static var misses:Int = 0; private var accuracy:Float = 0.00; @@ -1833,9 +1833,6 @@ class PlayState extends MusicBeatState if (health > 2) health = 2; - #if windows - if (executeModchart && luaModchart != null){luaModchart.setVar('health', health);}; - #end if (healthBar.percent < 20) iconP1.animation.curAnim.curFrame = 1; else @@ -2364,9 +2361,6 @@ class PlayState extends MusicBeatState else { health -= 0.075; - #if windows - if (executeModchart && luaModchart != null){ luaModchart.setVar('health', health);}; - #end vocals.volume = 0; if (theFunne) noteMiss(daNote.noteData, daNote); @@ -2562,9 +2556,6 @@ class PlayState extends MusicBeatState combo = 0; misses++; health -= 0.2; - #if windows - if (executeModchart && luaModchart != null){ luaModchart.setVar('health', health);}; - #end ss = false; shits++; if (FlxG.save.data.accuracyMod == 0) @@ -2573,9 +2564,6 @@ class PlayState extends MusicBeatState daRating = 'bad'; score = 0; health -= 0.06; - #if windows - if (executeModchart && luaModchart != null){ luaModchart.setVar('health', health);}; - #end ss = false; bads++; if (FlxG.save.data.accuracyMod == 0) @@ -2587,17 +2575,11 @@ class PlayState extends MusicBeatState goods++; if (health < 2) health += 0.04; - #if windows - if (executeModchart && luaModchart != null){ luaModchart.setVar('health', health);}; - #end if (FlxG.save.data.accuracyMod == 0) totalNotesHit += 0.75; case 'sick': if (health < 2) health += 0.1; - #if windows - if (executeModchart && luaModchart != null){ luaModchart.setVar('health', health);}; - #end if (FlxG.save.data.accuracyMod == 0) totalNotesHit += 1; sicks++; From 190670c3b23d00d3eb311a8dbdfadc80d16a694e Mon Sep 17 00:00:00 2001 From: craftersshaft Date: Thu, 27 May 2021 14:25:46 -0400 Subject: [PATCH 7/7] My Bad --- docs/modchart.md | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/docs/modchart.md b/docs/modchart.md index f6f9947..40c7b14 100644 --- a/docs/modchart.md +++ b/docs/modchart.md @@ -32,6 +32,10 @@ function stepHit (step) -- do nothing end +function keyPressed (key) + -- do nothing +end + print("Mod Chart script loaded :)") ``` @@ -146,7 +150,6 @@ Kade Engine provides a list of global variables to be used in the lua scripting | scrollSpeed | Int | The current scrollspeed | | mustHit | Bool | If the current section is a must hit section | | strumLineY | Float | The current Strum Line Y Position | -| health | Float | The current health of the player | ## Functions @@ -437,6 +440,13 @@ Smoothly fade in to an alpha Smoothly fade out to an alpha +##### changeBoyfriendCharacter(string id) + +Changes the Boyfriend sprite to another character + +##### changeDadCharacter(string id) + +Changes the Dad sprite to another character @@ -467,11 +477,3 @@ Sets the window's position ##### resizeWindow(int width, int height) Resizes the window - - -### Misc - -##### setHealth(float heal) - -Sets the player's health -