diff --git a/source/game/Note.hx b/source/game/Note.hx index 0ffe0135e5..a67eaaaa8e 100644 --- a/source/game/Note.hx +++ b/source/game/Note.hx @@ -1,5 +1,6 @@ package game; +import flixel.util.FlxColor; import utilities.Options; import shaders.NoteColors; import shaders.ColorSwap; @@ -21,6 +22,8 @@ class Note extends FlxSprite { public var tooLate:Bool = false; public var wasGoodHit:Bool = false; public var prevNote:Note; + public var prevNoteStrumtime:Float = 0; + public var prevNoteIsSustainNote:Bool = false; public var singAnimPrefix:String = "sing"; //hopefully should make things easier public var singAnimSuffix:String = ""; //for alt anims lol @@ -35,6 +38,11 @@ class Note extends FlxSprite { public static var swagWidth:Float = 160 * 0.7; + public var sustainScaleY:Float = 1; + + public var xOffset:Float = 0; + public var yOffset:Float = 0; + public var rawNoteData:Int = 0; public var character:Int = 0; @@ -59,6 +67,34 @@ class Note extends FlxSprite { public var z:Float = 0; #end + /** + * @see https://discord.com/channels/929608653173051392/1034954605253107844/1163134784277590056 + * @see https://step-mania.fandom.com/wiki/Notes + */ + public static var quantColors:Array = [ + 0xff230f, + 0x134fff, + 0x8a07e0, + 0x47fa16, + 0xd600d3, + 0xf67904, + 0x00c8ac, + 0x26a829, + 0xbbbbbb, + 0xA7C7E7, + 0x808000, + ]; + + public static var ratingColors:Array = [ + + ]; + + /** + * @see https://discord.com/channels/929608653173051392/1034954605253107844/1163134784277590056 + * @see https://step-mania.fandom.com/wiki/Notes + */ + public static var beats:Array = [4, 8, 12, 16, 24, 32, 48, 64, 96, 128, 192]; + public function new(strumTime:Float, noteData:Int, ?prevNote:Note, ?sustainNote:Bool = false, ?character:Int = 0, ?arrowType:String = "default", ?song:SwagSong, ?characters:Array, ?mustPress:Bool = false, ?inEditor:Bool = false) { super(); @@ -152,6 +188,9 @@ class Note extends FlxSprite { if (isSustainNote && prevNote != null) { alpha = 0.6; + + prevNoteStrumtime = prevNote.strumTime; + prevNoteIsSustainNote = prevNote.isSustainNote; if (song.ui_Skin != 'pixel') x += width / 2; @@ -176,10 +215,13 @@ class Note extends FlxSprite { prevNote.scale.y *= Conductor.stepCrochet / 100 * 1.5 * speed; prevNote.updateHitbox(); + prevNote.sustainScaleY = prevNote.scale.y; } centerOffsets(); centerOrigin(); + + sustainScaleY = scale.y; } diff --git a/source/modding/ModchartUtilities.hx b/source/modding/ModchartUtilities.hx index c0fdfc1a7b..a9da7d66f2 100644 --- a/source/modding/ModchartUtilities.hx +++ b/source/modding/ModchartUtilities.hx @@ -1,5 +1,8 @@ package modding; +import flixel.input.gamepad.FlxGamepad; +import flixel.input.FlxInput.FlxInputState; +import game.Note; import flixel.math.FlxMath; import openfl.filters.BitmapFilter; import openfl.display.ShaderParameter; @@ -210,6 +213,7 @@ class ModchartUtilities { setVar("playerKeyCount", PlayState.SONG.playerKeyCount); setVar("scrollspeed", PlayState.SONG.speed); setVar("fpsCap", Options.getData("maxFPS")); + setVar("opponentPlay", PlayState.characterPlayingAs == 1); setVar("bot", Options.getData("botplay")); setVar("noDeath", Options.getData("noDeath")); setVar("downscroll", Options.getData("downscroll") == true ? 1 : 0); // fuck you compatibility @@ -397,6 +401,20 @@ class ModchartUtilities { Reflect.setProperty(actor, "cameras", [cameraFromString(camera)]); }); + setLuaFunction("justPressedDodgeKey", function() { + + var gamepad:FlxGamepad = FlxG.gamepads.lastActive; + if (gamepad != null) + { + if (gamepad.checkStatus(FlxGamepadInputID.fromString("SPACE"), FlxInputState.JUST_PRESSED)) + { + return true; + } + + } + return FlxG.keys.checkStatus(FlxKey.fromString("SPACE"), FlxInputState.JUST_PRESSED); + }); + setLuaFunction("justPressed", function(key:String = "SPACE") { return Reflect.getProperty(FlxG.keys.justPressed, key); }); @@ -1181,6 +1199,10 @@ class ModchartUtilities { return PlayState.instance.notes.members[id].scale.x; }); + setLuaFunction("getRenderedNoteScaleY", function(id:Int) { + return PlayState.instance.notes.members[id].scale.y; + }); + setLuaFunction("setRenderedNotePos", function(x:Float, y:Float, id:Int) { if (PlayState.instance.notes.members[id] == null) throw('error! you cannot set a rendered notes position when it doesnt exist! ID: ' + id); @@ -1198,9 +1220,50 @@ class ModchartUtilities { PlayState.instance.notes.members[id].scale.set(scale, scale); }); + setLuaFunction("setRenderedNoteScaleX", function(scale:Float, id:Int) { + PlayState.instance.notes.members[id].scale.x = scale; + }); + setLuaFunction("setRenderedNoteScaleY", function(scale:Float, id:Int) { + PlayState.instance.notes.members[id].scale.y = scale; + }); + setLuaFunction("setRenderedNoteScaleXY", function(scaleX:Int, scaleY:Int, id:Int) { PlayState.instance.notes.members[id].scale.set(scaleX, scaleY); - }); + }); + + setLuaFunction("isRenderedNoteSustainEnd", function(id:Int) { + if (PlayState.instance.notes.members[id].animation.curAnim != null) + return PlayState.instance.notes.members[id].animation.curAnim.name.endsWith('end'); + return false; + }); + + setLuaFunction("getRenderedNoteSustainScaleY", function(id:Int) { + return PlayState.instance.notes.members[id].sustainScaleY; + }); + + setLuaFunction("getRenderedNoteOffsetX", function(id:Int) { + var daNote:Note = PlayState.instance.notes.members[id]; + if (daNote.mustPress) + { + var arrayVal = Std.string([daNote.noteData, daNote.arrow_Type, daNote.isSustainNote]); + if (PlayState.instance.prevPlayerXVals.exists(arrayVal)) + return PlayState.instance.prevPlayerXVals.get(arrayVal) - daNote.xOffset; + } + else + { + var arrayVal = Std.string([daNote.noteData, daNote.arrow_Type, daNote.isSustainNote]); + if (PlayState.instance.prevEnemyXVals.exists(arrayVal)) + return PlayState.instance.prevEnemyXVals.get(arrayVal) - daNote.xOffset; + } + + return 0; + }); + + setLuaFunction("getRenderedNoteOffsetY", function(id:Int) { + var daNote:Note = PlayState.instance.notes.members[id]; + return daNote.yOffset; + }); + setLuaFunction("getRenderedNoteWidth", function(id:Int) { return PlayState.instance.notes.members[id].width; @@ -1210,6 +1273,10 @@ class ModchartUtilities { return PlayState.instance.notes.members[id].height; }); + setLuaFunction("getRenderedNotePrevNoteStrumtime", function(id:Int) { + return PlayState.instance.notes.members[id].prevNoteStrumtime; + }); + setLuaFunction("setRenderedNoteAngle", function(angle:Float, id:Int) { PlayState.instance.notes.members[id].angle = angle; }); @@ -2644,6 +2711,31 @@ class ModchartUtilities { return id; }); + setLuaFunction("getStrumTimeFromStep", function(step:Float) { + var beat = step*0.25; + var totalTime:Float = 0; + var curBpm = Conductor.bpm; + if (PlayState.SONG != null) + curBpm = PlayState.SONG.bpm; + for (i in 0...Math.floor(beat)) + { + if (Conductor.bpmChangeMap.length > 0) + { + for (j in 0...Conductor.bpmChangeMap.length) + { + if (totalTime >= Conductor.bpmChangeMap[j].songTime) + curBpm = Conductor.bpmChangeMap[j].bpm; + } + } + totalTime += (60/curBpm)*1000; + } + + var leftOverBeat = beat - Math.floor(beat); + totalTime += (60/curBpm)*1000*leftOverBeat; + + return totalTime; + }); + // shader bullshit setLuaFunction("setActor3DShader", function(id:String, ?speed:Float = 3, ?frequency:Float = 10, ?amplitude:Float = 0.25) { diff --git a/source/states/PlayState.hx b/source/states/PlayState.hx index 8d6c2aeba5..48ccadcba1 100644 --- a/source/states/PlayState.hx +++ b/source/states/PlayState.hx @@ -1398,6 +1398,7 @@ class PlayState extends MusicBeatState { HScript.interp.variables.set('ModchartFile', modcharting.ModchartFile); } #end*/ + super.create(); for (script_funny in scripts) {