Adding health stuff to Modcharts

This commit is contained in:
craftersshaft 2021-05-25 16:03:45 -04:00
parent e02d9a546f
commit 1af694d72d
3 changed files with 43 additions and 3 deletions

View File

@ -145,6 +145,7 @@ Kade Engine provides a list of global variables to be used in the lua scripting
| scrollSpeed | Int | The current scrollspeed | | scrollSpeed | Int | The current scrollspeed |
| mustHit | Bool | If the current section is a must hit section | | mustHit | Bool | If the current section is a must hit section |
| strumLineY | Float | The current Strum Line Y Position | | strumLineY | Float | The current Strum Line Y Position |
| health | Float | The current health of the player |
## Functions ## Functions
@ -465,3 +466,11 @@ Sets the window's position
##### resizeWindow(int width, int height) ##### resizeWindow(int width, int height)
Resizes the window Resizes the window
### Misc
##### setHealth(float heal)
Sets the player's health

View File

@ -232,7 +232,23 @@ class ModchartState
public static var luaSprites:Map<String,FlxSprite> = []; public static var luaSprites:Map<String,FlxSprite> = [];
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) function makeLuaSprite(spritePath:String,toBeCalled:String, drawBehind:Bool)
{ {
@ -312,6 +328,7 @@ class ModchartState
// get some fukin globals up in here bois // get some fukin globals up in here bois
setVar("difficulty", PlayState.storyDifficulty); setVar("difficulty", PlayState.storyDifficulty);
setVar("health", PlayState.instance.health);
setVar("bpm", Conductor.bpm); setVar("bpm", Conductor.bpm);
setVar("scrollspeed", FlxG.save.data.scrollSpeed != 1 ? FlxG.save.data.scrollSpeed : PlayState.SONG.speed); setVar("scrollspeed", FlxG.save.data.scrollSpeed != 1 ? FlxG.save.data.scrollSpeed : PlayState.SONG.speed);
setVar("fpsCap", FlxG.save.data.fpsCap); setVar("fpsCap", FlxG.save.data.fpsCap);
@ -349,6 +366,10 @@ class ModchartState
// sprites // sprites
Lua_helper.add_callback(lua,"makeSprite", makeLuaSprite); 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); Lua_helper.add_callback(lua,"getProperty", getPropertyByName);
@ -365,6 +386,10 @@ class ModchartState
Lua_helper.add_callback(lua,"setHudAngle", function (x:Float) { Lua_helper.add_callback(lua,"setHudAngle", function (x:Float) {
PlayState.instance.camHUD.angle = x; 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) { Lua_helper.add_callback(lua,"setHudPosition", function (x:Int, y:Int) {
PlayState.instance.camHUD.x = x; PlayState.instance.camHUD.x = x;

View File

@ -125,7 +125,7 @@ class PlayState extends MusicBeatState
private var curSong:String = ""; private var curSong:String = "";
private var gfSpeed:Int = 1; 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; private var combo:Int = 0;
public static var misses:Int = 0; public static var misses:Int = 0;
private var accuracy:Float = 0.00; private var accuracy:Float = 0.00;
@ -143,8 +143,8 @@ class PlayState extends MusicBeatState
private var generatedMusic:Bool = false; private var generatedMusic:Bool = false;
private var startingSong:Bool = false; private var startingSong:Bool = false;
private var iconP1:HealthIcon; public var iconP1:HealthIcon; //making these public for modcharts cause i dont know how else to do it
private var iconP2:HealthIcon; public var iconP2:HealthIcon; //what could go wrong?
public var camHUD:FlxCamera; public var camHUD:FlxCamera;
private var camGame:FlxCamera; private var camGame:FlxCamera;
@ -1833,6 +1833,7 @@ class PlayState extends MusicBeatState
if (health > 2) if (health > 2)
health = 2; health = 2;
if (executeModchart && luaModchart != null){luaModchart.setVar('health', health);};
if (healthBar.percent < 20) if (healthBar.percent < 20)
iconP1.animation.curAnim.curFrame = 1; iconP1.animation.curAnim.curFrame = 1;
@ -2362,6 +2363,7 @@ class PlayState extends MusicBeatState
else else
{ {
health -= 0.075; health -= 0.075;
if (executeModchart && luaModchart != null){ luaModchart.setVar('health', health);};
vocals.volume = 0; vocals.volume = 0;
if (theFunne) if (theFunne)
noteMiss(daNote.noteData, daNote); noteMiss(daNote.noteData, daNote);
@ -2557,6 +2559,7 @@ class PlayState extends MusicBeatState
combo = 0; combo = 0;
misses++; misses++;
health -= 0.2; health -= 0.2;
if (executeModchart && luaModchart != null){ luaModchart.setVar('health', health);};
ss = false; ss = false;
shits++; shits++;
if (FlxG.save.data.accuracyMod == 0) if (FlxG.save.data.accuracyMod == 0)
@ -2565,6 +2568,7 @@ class PlayState extends MusicBeatState
daRating = 'bad'; daRating = 'bad';
score = 0; score = 0;
health -= 0.06; health -= 0.06;
if (executeModchart && luaModchart != null){ luaModchart.setVar('health', health);};
ss = false; ss = false;
bads++; bads++;
if (FlxG.save.data.accuracyMod == 0) if (FlxG.save.data.accuracyMod == 0)
@ -2576,11 +2580,13 @@ class PlayState extends MusicBeatState
goods++; goods++;
if (health < 2) if (health < 2)
health += 0.04; health += 0.04;
if (executeModchart && luaModchart != null){ luaModchart.setVar('health', health);};
if (FlxG.save.data.accuracyMod == 0) if (FlxG.save.data.accuracyMod == 0)
totalNotesHit += 0.75; totalNotesHit += 0.75;
case 'sick': case 'sick':
if (health < 2) if (health < 2)
health += 0.1; health += 0.1;
if (executeModchart && luaModchart != null){ luaModchart.setVar('health', health);};
if (FlxG.save.data.accuracyMod == 0) if (FlxG.save.data.accuracyMod == 0)
totalNotesHit += 1; totalNotesHit += 1;
sicks++; sicks++;