diff --git a/ModCharts.md b/ModCharts.md index efd8bf6..3dcadee 100644 --- a/ModCharts.md +++ b/ModCharts.md @@ -133,8 +133,9 @@ Kade Engine provides a list of global variables to be used in the lua scripting | screenHeight | Int | The height of the current gamespace | | hudWidth | Int | The width of the hud | | hudHeight | Int | The height of the hud | - - +| scrollSpeed | Int | The current scrollspeed | +| mustHit | Bool | If the current section is a must hit section | +| strumLineY | Float | The current Strum Line Y Position | ## Functions @@ -205,31 +206,89 @@ Returns the amount of rendered notes. ##### getRenderedNoteX(int id) -Return's the x position of the rendered note id +Returns the x position of the rendered note id *Note: Rendered Notes id's are special in the way that they act. 0 = closest note to any receptor, last index = the farthest away from any receptor.* ##### getRenderedNoteY(int id) -Return's the y position of the rendered note id +Returns the y position of the rendered note id *Note: Rendered Notes id's are special in the way that they act. 0 = closest note to any receptor, last index = the farthest away from any receptor.* ##### getRenderedNoteScaleX(int id) -Return's the scale x of the rendered note id +Returns the scale x of the rendered note id *Note: Rendered Notes id's are special in the way that they act. 0 = closest note to any receptor, last index = the farthest away from any receptor.* ##### getRenderedNoteScaleY(int id) -Return's the scale y of the rendered note id +Returns the scale y of the rendered note id + +*Note: Rendered Notes id's are special in the way that they act. 0 = closest note to any receptor, last index = the farthest away from any receptor.* + +##### getRenderedNoteType(int id) + +Returns the note data of an note (0-3, left, down, up, right) + +*Note: Rendered Notes id's are special in the way that they act. 0 = closest note to any receptor, last index = the farthest away from any receptor.* + +##### isSustain(int id) + +Returns whether a rendered note is a sustain note or not (if they appear as the trail) + +*Note: Rendered Notes id's are special in the way that they act. 0 = closest note to any receptor, last index = the farthest away from any receptor.* + +##### isParentSustain(int id) + +Returns whether a rendered note's parrent is a sustain note or not (if they appear as the trail) + +*Note: Rendered Notes id's are special in the way that they act. 0 = closest note to any receptor, last index = the farthest away from any receptor.* + +##### getRenderedNoteParentX(int id) + +Returns the current parent x of the specified rendered note's id + +*Note: Rendered Notes id's are special in the way that they act. 0 = closest note to any receptor, last index = the farthest away from any receptor.* + +##### getRenderedNoteParentY(int id) + +Returns the current parent y of the specified rendered note's id + +*Note: Rendered Notes id's are special in the way that they act. 0 = closest note to any receptor, last index = the farthest away from any receptor.* + +##### getRenderedNoteCalcX(int id) + +Returns what the game would normally put the specified rendered note x. + +*Note: Rendered Notes id's are special in the way that they act. 0 = closest note to any receptor, last index = the farthest away from any receptor.* + +##### anyNotes() + +Returns the number of rendered notes on the screen. + +##### getRenderedNoteStrumtime(int id) + +Returns strum time of the rendered note. *Note: Rendered Notes id's are special in the way that they act. 0 = closest note to any receptor, last index = the farthest away from any receptor.* ##### getRenderedNoteAlpha(int id) -Return's the alpha of the rendered note id +Returns the alpha of the rendered note id + +*Note: Rendered Notes id's are special in the way that they act. 0 = closest note to any receptor, last index = the farthest away from any receptor.* + +##### getRenderedNoteWidth(int id) + +Returns the width of the specified rendered note. + +*Note: Rendered Notes id's are special in the way that they act. 0 = closest note to any receptor, last index = the farthest away from any receptor.* + +##### getRenderedNoteAngle(int id) + +Returns the angle of the specified rendered note. *Note: Rendered Notes id's are special in the way that they act. 0 = closest note to any receptor, last index = the farthest away from any receptor.* diff --git a/source/HelperFunctions.hx b/source/HelperFunctions.hx new file mode 100644 index 0000000..8f6c6fc --- /dev/null +++ b/source/HelperFunctions.hx @@ -0,0 +1,9 @@ +class HelperFunctions +{ + public static function truncateFloat( number : Float, precision : Int): Float { + var num = number; + num = num * Math.pow(10, precision); + num = Math.round( num ) / Math.pow(10, precision); + return num; + } +} \ No newline at end of file diff --git a/source/Note.hx b/source/Note.hx index 4b16f9a..8685ee2 100644 --- a/source/Note.hx +++ b/source/Note.hx @@ -188,13 +188,13 @@ class Note extends FlxSprite if (mustPress) { // The * 0.5 is so that it's easier to hit them too late, instead of too early - if (strumTime > Conductor.songPosition - Conductor.safeZoneOffset + if (strumTime > Conductor.songPosition - (Conductor.safeZoneOffset * 1.5) && strumTime < Conductor.songPosition + (Conductor.safeZoneOffset * 0.5)) canBeHit = true; else canBeHit = false; - if (strumTime < Conductor.songPosition - Conductor.safeZoneOffset && !wasGoodHit) + if (strumTime < Conductor.songPosition - Conductor.safeZoneOffset * Conductor.timeScale && !wasGoodHit) tooLate = true; } else diff --git a/source/Options.hx b/source/Options.hx index 9483d39..aafebd8 100644 --- a/source/Options.hx +++ b/source/Options.hx @@ -191,11 +191,11 @@ class Judgement extends Option Conductor.recalculateTimings(); OptionsMenu.versionShit.text = "Current Safe Frames: " + Conductor.safeFrames + " - Description - " + description + - " - SIK: " + OptionsMenu.truncateFloat(45 * Conductor.timeScale, 0) + - "ms GD: " + OptionsMenu.truncateFloat(90 * Conductor.timeScale, 0) + - "ms BD: " + OptionsMenu.truncateFloat(135 * Conductor.timeScale, 0) + - "ms SHT: " + OptionsMenu.truncateFloat(155 * Conductor.timeScale, 0) + - "ms TOTAL: " + OptionsMenu.truncateFloat(Conductor.safeZoneOffset,0) + "ms"; + " - SIK: " + HelperFunctions.truncateFloat(45 * Conductor.timeScale, 0) + + "ms GD: " + HelperFunctions.truncateFloat(90 * Conductor.timeScale, 0) + + "ms BD: " + HelperFunctions.truncateFloat(135 * Conductor.timeScale, 0) + + "ms SHT: " + HelperFunctions.truncateFloat(155 * Conductor.timeScale, 0) + + "ms TOTAL: " + HelperFunctions.truncateFloat(Conductor.safeZoneOffset,0) + "ms"; return true; } @@ -210,11 +210,11 @@ class Judgement extends Option Conductor.recalculateTimings(); OptionsMenu.versionShit.text = "Current Safe Frames: " + Conductor.safeFrames + " - Description - " + description + - " - SIK: " + OptionsMenu.truncateFloat(45 * Conductor.timeScale, 0) + - "ms GD: " + OptionsMenu.truncateFloat(90 * Conductor.timeScale, 0) + - "ms BD: " + OptionsMenu.truncateFloat(135 * Conductor.timeScale, 0) + - "ms SHT: " + OptionsMenu.truncateFloat(155 * Conductor.timeScale, 0) + - "ms TOTAL: " + OptionsMenu.truncateFloat(Conductor.safeZoneOffset,0) + "ms"; + " - SIK: " + HelperFunctions.truncateFloat(44 * Conductor.timeScale, 0) + + "ms GD: " + HelperFunctions.truncateFloat(45 * Conductor.timeScale, 0) + + "ms BD: " + HelperFunctions.truncateFloat(90 * Conductor.timeScale, 0) + + "ms SHT: " + HelperFunctions.truncateFloat(135 * Conductor.timeScale, 0) + + "ms TOTAL: " + HelperFunctions.truncateFloat(Conductor.safeZoneOffset,0) + "ms"; return true; } } @@ -312,7 +312,7 @@ class ScrollSpeedOption extends Option if (FlxG.save.data.scrollSpeed > 10) FlxG.save.data.scrollSpeed = 10; - OptionsMenu.versionShit.text = "Current Scroll Speed: " + OptionsMenu.truncateFloat(FlxG.save.data.scrollSpeed,1) + " - Description - " + description; + OptionsMenu.versionShit.text = "Current Scroll Speed: " + HelperFunctions.truncateFloat(FlxG.save.data.scrollSpeed,1) + " - Description - " + description; return true; } @@ -326,7 +326,7 @@ class ScrollSpeedOption extends Option FlxG.save.data.scrollSpeed = 10; - OptionsMenu.versionShit.text = "Current Scroll Speed: " + OptionsMenu.truncateFloat(FlxG.save.data.scrollSpeed,1) + " - Description - " + description; + OptionsMenu.versionShit.text = "Current Scroll Speed: " + HelperFunctions.truncateFloat(FlxG.save.data.scrollSpeed,1) + " - Description - " + description; return true; } } diff --git a/source/OptionsMenu.hx b/source/OptionsMenu.hx index c0e71c7..139279f 100644 --- a/source/OptionsMenu.hx +++ b/source/OptionsMenu.hx @@ -93,12 +93,6 @@ class OptionsMenu extends MusicBeatState var isCat:Bool = false; - public static function truncateFloat( number : Float, precision : Int): Float { - var num = number; - num = num * Math.pow(10, precision); - num = Math.round( num ) / Math.pow(10, precision); - return num; - } override function update(elapsed:Float) { @@ -159,7 +153,7 @@ class OptionsMenu extends MusicBeatState else if (FlxG.keys.pressed.LEFT) FlxG.save.data.offset -= 0.1; - versionShit.text = "Offset (Left, Right, Shift for slow): " + truncateFloat(FlxG.save.data.offset,2) + " - Description - " + currentDescription; + versionShit.text = "Offset (Left, Right, Shift for slow): " + HelperFunctions.truncateFloat(FlxG.save.data.offset,2) + " - Description - " + currentDescription; } } else @@ -176,7 +170,7 @@ class OptionsMenu extends MusicBeatState else if (FlxG.keys.pressed.LEFT) FlxG.save.data.offset -= 0.1; - versionShit.text = "Offset (Left, Right, Shift for slow): " + truncateFloat(FlxG.save.data.offset,2) + " - Description - " + currentDescription; + versionShit.text = "Offset (Left, Right, Shift for slow): " + HelperFunctions.truncateFloat(FlxG.save.data.offset,2) + " - Description - " + currentDescription; } @@ -234,7 +228,7 @@ class OptionsMenu extends MusicBeatState currentDescription = currentSelectedCat.getOptions()[curSelected].getDescription(); else currentDescription = "Please select a catagory"; - versionShit.text = "Offset (Left, Right, Shift for slow): " + truncateFloat(FlxG.save.data.offset,2) + " - Description - " + currentDescription; + versionShit.text = "Offset (Left, Right, Shift for slow): " + HelperFunctions.truncateFloat(FlxG.save.data.offset,2) + " - Description - " + currentDescription; // selector.y = (70 * curSelected) + 30; diff --git a/source/PlayState.hx b/source/PlayState.hx index e33e953..a43bd9a 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -1,5 +1,6 @@ package; +import haxe.Exception; import openfl.geom.Matrix; import openfl.display.BitmapData; import openfl.utils.AssetType; @@ -227,12 +228,19 @@ class PlayState extends MusicBeatState } result = Lua.pcall(lua, args.length, 1, 0); + var p = Lua.tostring(lua,result); + var e = getLuaErrorMessage(lua); - if (getLuaErrorMessage(lua) != null) - if (Lua.tostring(lua,result) != null) - throw(func_name + ' LUA CALL ERROR ' + Lua.tostring(lua,result)); - else - trace(func_name + ' prolly doesnt exist lol'); + if (e != null) + { + if (p != null) + { + Application.current.window.alert("LUA ERROR:\n" + p + "\nhaxe things: " + e,"Kade Engine Modcharts"); + lua = null; + LoadingState.loadAndSwitchState(new MainMenuState()); + } + // trace('err: ' + e); + } if( result == null) { return null; } else { @@ -473,7 +481,7 @@ class PlayState extends MusicBeatState detailsPausedText = "Paused - " + detailsText; // Updating Discord Rich Presence. - DiscordClient.changePresence(detailsText + " " + SONG.song + " (" + storyDifficultyText + ") " + generateRanking(), "\nAcc: " + truncateFloat(accuracy, 2) + "% | Score: " + songScore + " | Misses: " + misses , iconRPC); + DiscordClient.changePresence(detailsText + " " + SONG.song + " (" + storyDifficultyText + ") " + Ratings.GenerateLetterRank(accuracy), "\nAcc: " + HelperFunctions.truncateFloat(accuracy, 2) + "% | Score: " + songScore + " | Misses: " + misses , iconRPC); #end @@ -1282,12 +1290,17 @@ class PlayState extends MusicBeatState var result = LuaL.dofile(lua, Paths.lua(PlayState.SONG.song.toLowerCase() + "/modchart")); // execute le file if (result != 0) - throw('COMPILE ERROR\n' + getLuaErrorMessage(lua)); + { + Application.current.window.alert("LUA COMPILE ERROR:\n" + Lua.tostring(lua,result),"Kade Engine Modcharts"); + lua = null; + LoadingState.loadAndSwitchState(new MainMenuState()); + } // get some fukin globals up in here bois setVar("difficulty", storyDifficulty); setVar("bpm", Conductor.bpm); + setVar("scrollspeed", FlxG.save.data.scrollSpeed != 1 ? FlxG.save.data.scrollSpeed : PlayState.SONG.speed); setVar("fpsCap", FlxG.save.data.fpsCap); setVar("downscroll", FlxG.save.data.downscroll); @@ -1314,6 +1327,10 @@ class PlayState extends MusicBeatState setVar("hudWidth", camHUD.width); setVar("hudHeight", camHUD.height); + setVar("mustHit", false); + + setVar("strumLineY", strumLine.y); + // callbacks // sprites @@ -1377,15 +1394,59 @@ class PlayState extends MusicBeatState trace(Lua_helper.add_callback(lua,"getRenderedNoteY", function(id:Int) { return notes.members[id].y; })); + + trace(Lua_helper.add_callback(lua,"getRenderedNoteType", function(id:Int) { + return notes.members[id].noteData; + })); + + trace(Lua_helper.add_callback(lua,"isSustain", function(id:Int) { + return notes.members[id].isSustainNote; + })); + + trace(Lua_helper.add_callback(lua,"isParentSustain", function(id:Int) { + return notes.members[id].prevNote.isSustainNote; + })); + + + trace(Lua_helper.add_callback(lua,"getRenderedNoteParentX", function(id:Int) { + return notes.members[id].prevNote.x; + })); + + trace(Lua_helper.add_callback(lua,"getRenderedNoteParentY", function(id:Int) { + return notes.members[id].prevNote.y; + })); + + trace(Lua_helper.add_callback(lua,"getRenderedNoteHit", function(id:Int) { + return notes.members[id].mustPress; + })); + + trace(Lua_helper.add_callback(lua,"getRenderedNoteCalcX", function(id:Int) { + if (notes.members[id].mustPress) + return playerStrums.members[Math.floor(Math.abs(notes.members[id].noteData))].x; + return strumLineNotes.members[Math.floor(Math.abs(notes.members[id].noteData))].x; + })); + + trace(Lua_helper.add_callback(lua,"anyNotes", function() { + return notes.members.length != 0; + })); + + trace(Lua_helper.add_callback(lua,"getRenderedNoteStrumtime", function(id:Int) { + return notes.members[id].strumTime; + })); trace(Lua_helper.add_callback(lua,"getRenderedNoteScaleX", function(id:Int) { return notes.members[id].scale.x; })); - trace(Lua_helper.add_callback(lua,"setRenderedNotePos", function(x:Int,y:Int, id:Int) { - notes.members[id].modifiedByLua = true; - notes.members[id].x = x; - notes.members[id].y = y; + trace(Lua_helper.add_callback(lua,"setRenderedNotePos", function(x:Float,y:Float, id:Int) { + if (notes.members[id] == null) + throw('error! you cannot set a rendered notes position when it doesnt exist! ID: ' + id); + else + { + notes.members[id].modifiedByLua = true; + notes.members[id].x = x; + notes.members[id].y = y; + } })); trace(Lua_helper.add_callback(lua,"setRenderedNoteAlpha", function(alpha:Float, id:Int) { @@ -1397,6 +1458,21 @@ class PlayState extends MusicBeatState notes.members[id].modifiedByLua = true; notes.members[id].setGraphicSize(Std.int(notes.members[id].width * scale)); })); + + trace(Lua_helper.add_callback(lua,"setRenderedNoteScale", function(scaleX:Int, scaleY:Int, id:Int) { + notes.members[id].modifiedByLua = true; + notes.members[id].setGraphicSize(scaleX,scaleY); + })); + + trace(Lua_helper.add_callback(lua,"getRenderedNoteWidth", function(id:Int) { + return notes.members[id].width; + })); + + + trace(Lua_helper.add_callback(lua,"setRenderedNoteAngle", function(angle:Float, id:Int) { + notes.members[id].modifiedByLua = true; + notes.members[id].angle = angle; + })); trace(Lua_helper.add_callback(lua,"setActorX", function(x:Int,id:String) { getActorByName(id).x = x; @@ -1732,7 +1808,7 @@ class PlayState extends MusicBeatState #if windows // Updating Discord Rich Presence (with Time Left) - DiscordClient.changePresence(detailsText + " " + SONG.song + " (" + storyDifficultyText + ") " + generateRanking(), "\nAcc: " + truncateFloat(accuracy, 2) + "% | Score: " + songScore + " | Misses: " + misses , iconRPC); + DiscordClient.changePresence(detailsText + " " + SONG.song + " (" + storyDifficultyText + ") " + Ratings.GenerateLetterRank(accuracy), "\nAcc: " + HelperFunctions.truncateFloat(accuracy, 2) + "% | Score: " + songScore + " | Misses: " + misses , iconRPC); #end } @@ -1980,7 +2056,7 @@ class PlayState extends MusicBeatState } #if windows - DiscordClient.changePresence("PAUSED on " + SONG.song + " (" + storyDifficultyText + ") " + generateRanking(), "Acc: " + truncateFloat(accuracy, 2) + "% | Score: " + songScore + " | Misses: " + misses , iconRPC); + DiscordClient.changePresence("PAUSED on " + SONG.song + " (" + storyDifficultyText + ") " + Ratings.GenerateLetterRank(accuracy), "Acc: " + HelperFunctions.truncateFloat(accuracy, 2) + "% | Score: " + songScore + " | Misses: " + misses , iconRPC); #end if (!startTimer.finished) startTimer.active = false; @@ -2005,11 +2081,11 @@ class PlayState extends MusicBeatState #if windows if (startTimer.finished) { - DiscordClient.changePresence(detailsText + " " + SONG.song + " (" + storyDifficultyText + ") " + generateRanking(), "\nAcc: " + truncateFloat(accuracy, 2) + "% | Score: " + songScore + " | Misses: " + misses, iconRPC, true, songLength - Conductor.songPosition); + DiscordClient.changePresence(detailsText + " " + SONG.song + " (" + storyDifficultyText + ") " + Ratings.GenerateLetterRank(accuracy), "\nAcc: " + HelperFunctions.truncateFloat(accuracy, 2) + "% | Score: " + songScore + " | Misses: " + misses, iconRPC, true, songLength - Conductor.songPosition); } else { - DiscordClient.changePresence(detailsText, SONG.song + " (" + storyDifficultyText + ") " + generateRanking(), iconRPC); + DiscordClient.changePresence(detailsText, SONG.song + " (" + storyDifficultyText + ") " + Ratings.GenerateLetterRank(accuracy), iconRPC); } #end } @@ -2028,7 +2104,7 @@ class PlayState extends MusicBeatState vocals.play(); #if windows - DiscordClient.changePresence(detailsText + " " + SONG.song + " (" + storyDifficultyText + ") " + generateRanking(), "\nAcc: " + truncateFloat(accuracy, 2) + "% | Score: " + songScore + " | Misses: " + misses , iconRPC); + DiscordClient.changePresence(detailsText + " " + SONG.song + " (" + storyDifficultyText + ") " + Ratings.GenerateLetterRank(accuracy), "\nAcc: " + HelperFunctions.truncateFloat(accuracy, 2) + "% | Score: " + songScore + " | Misses: " + misses , iconRPC); #end } @@ -2036,100 +2112,6 @@ class PlayState extends MusicBeatState var startedCountdown:Bool = false; var canPause:Bool = true; - function truncateFloat( number : Float, precision : Int): Float { - var num = number; - num = num * Math.pow(10, precision); - num = Math.round( num ) / Math.pow(10, precision); - return num; - } - - - function generateRanking():String - { - var ranking:String = "N/A"; - - if (misses == 0 && bads == 0 && shits == 0 && goods == 0) // Marvelous (SICK) Full Combo - ranking = "(MFC)"; - else if (misses == 0 && bads == 0 && shits == 0 && goods >= 1) // Good Full Combo (Nothing but Goods & Sicks) - ranking = "(GFC)"; - else if (misses == 0) // Regular FC - ranking = "(FC)"; - else if (misses < 10) // Single Digit Combo Breaks - ranking = "(SDCB)"; - else - ranking = "(Clear)"; - - // WIFE TIME :)))) (based on Wife3) - - var wifeConditions:Array = [ - accuracy >= 99.9935, // AAAAA - accuracy >= 99.980, // AAAA: - accuracy >= 99.970, // AAAA. - accuracy >= 99.955, // AAAA - accuracy >= 99.90, // AAA: - accuracy >= 99.80, // AAA. - accuracy >= 99.70, // AAA - accuracy >= 99, // AA: - accuracy >= 96.50, // AA. - accuracy >= 93, // AA - accuracy >= 90, // A: - accuracy >= 85, // A. - accuracy >= 80, // A - accuracy >= 70, // B - accuracy >= 60, // C - accuracy < 60 // D - ]; - - for(i in 0...wifeConditions.length) - { - var b = wifeConditions[i]; - if (b) - { - switch(i) - { - case 0: - ranking += " AAAAA"; - case 1: - ranking += " AAAA:"; - case 2: - ranking += " AAAA."; - case 3: - ranking += " AAAA"; - case 4: - ranking += " AAA:"; - case 5: - ranking += " AAA."; - case 6: - ranking += " AAA"; - case 7: - ranking += " AA:"; - case 8: - ranking += " AA."; - case 9: - ranking += " AA"; - case 10: - ranking += " A:"; - case 11: - ranking += " A."; - case 12: - ranking += " A"; - case 13: - ranking += " B"; - case 14: - ranking += " C"; - case 15: - ranking += " D"; - } - break; - } - } - - if (accuracy == 0) - ranking = "N/A"; - - return ranking; - } - public static var songRate = 1.5; override public function update(elapsed:Float) @@ -2235,22 +2217,7 @@ class PlayState extends MusicBeatState super.update(elapsed); - if (!offsetTesting) - { - if (FlxG.save.data.accuracyDisplay) - { - scoreTxt.text = (FlxG.save.data.npsDisplay ? "NPS: " + nps + " | " : "") + "Score:" + (Conductor.safeFrames != 10 ? songScore + " (" + songScoreDef + ")" : "" + songScore) + " | Combo Breaks:" + misses + " | Accuracy:" + truncateFloat(accuracy, 2) + "% | " + generateRanking(); - } - else - { - scoreTxt.text = (FlxG.save.data.npsDisplay ? "NPS: " + nps + " | " : "") + "Score:" + songScore; - } - } - else - { - scoreTxt.text = "Suggested Offset: " + offsetTest; - - } + scoreTxt.text = Ratings.CalculateRanking(songScore,songScoreDef,nps,accuracy); if (FlxG.keys.justPressed.ENTER && startedCountdown && canPause) { persistentUpdate = false; @@ -2460,6 +2427,11 @@ class PlayState extends MusicBeatState } } + #if cpp + if (lua != null) + setVar("mustHit",PlayState.SONG.notes[Std.int(curStep / 16)].mustHitSection); + #end + if (camFollow.x != dad.getMidpoint().x + 150 && !PlayState.SONG.notes[Std.int(curStep / 16)].mustHitSection) { var offsetX = 0; @@ -2588,7 +2560,7 @@ class PlayState extends MusicBeatState #if windows // Game Over doesn't get his own variable because it's only used here - DiscordClient.changePresence("GAME OVER -- " + SONG.song + " (" + storyDifficultyText + ") " + generateRanking(),"\nAcc: " + truncateFloat(accuracy, 2) + "% | Score: " + songScore + " | Misses: " + misses , iconRPC); + DiscordClient.changePresence("GAME OVER -- " + SONG.song + " (" + storyDifficultyText + ") " + Ratings.GenerateLetterRank(accuracy),"\nAcc: " + HelperFunctions.truncateFloat(accuracy, 2) + "% | Score: " + songScore + " | Misses: " + misses , iconRPC); #end // FlxG.switchState(new GameOverState(boyfriend.getScreenPosition().x, boyfriend.getScreenPosition().y)); @@ -2596,7 +2568,7 @@ class PlayState extends MusicBeatState if (unspawnNotes[0] != null) { - if (unspawnNotes[0].strumTime - Conductor.songPosition < 1500) + if (unspawnNotes[0].strumTime - Conductor.songPosition < 3500) { var dunceNote:Note = unspawnNotes[0]; notes.add(dunceNote); @@ -2610,7 +2582,10 @@ class PlayState extends MusicBeatState { notes.forEachAlive(function(daNote:Note) { - if (daNote.y > FlxG.height) + + // instead of doing stupid y > FlxG.height + // we be men and actually calculate the time :) + if (daNote.tooLate) { daNote.active = false; daNote.visible = false; @@ -2663,10 +2638,13 @@ class PlayState extends MusicBeatState daNote.destroy(); } - if (FlxG.save.data.downscroll) - daNote.y = (strumLine.y - (Conductor.songPosition - daNote.strumTime) * (-0.45 * FlxMath.roundDecimal(FlxG.save.data.scrollSpeed == 1 ? SONG.speed : FlxG.save.data.scrollSpeed, 2))); - else - daNote.y = (strumLine.y - (Conductor.songPosition - daNote.strumTime) * (0.45 * FlxMath.roundDecimal(FlxG.save.data.scrollSpeed == 1 ? SONG.speed : FlxG.save.data.scrollSpeed, 2))); + if (!daNote.modifiedByLua) + { + if (FlxG.save.data.downscroll) + daNote.y = (strumLine.y - (Conductor.songPosition - daNote.strumTime) * (-0.45 * FlxMath.roundDecimal(FlxG.save.data.scrollSpeed == 1 ? SONG.speed : FlxG.save.data.scrollSpeed, 2))); + else + daNote.y = (strumLine.y - (Conductor.songPosition - daNote.strumTime) * (0.45 * FlxMath.roundDecimal(FlxG.save.data.scrollSpeed == 1 ? SONG.speed : FlxG.save.data.scrollSpeed, 2))); + } if (daNote.mustPress && !daNote.modifiedByLua) { @@ -2695,7 +2673,7 @@ class PlayState extends MusicBeatState // WIP interpolation shit? Need to fix the pause issue // daNote.y = (strumLine.y - (songTime - daNote.strumTime) * (0.45 * PlayState.SONG.speed)); - if ((daNote.y < -daNote.height && !FlxG.save.data.downscroll || daNote.y >= strumLine.y + 106 && FlxG.save.data.downscroll) && daNote.mustPress) + if ((daNote.mustPress && daNote.tooLate && !FlxG.save.data.downscroll || daNote.mustPress && daNote.tooLate && FlxG.save.data.downscroll) && daNote.mustPress) { if (daNote.isSustainNote && daNote.wasGoodHit) { @@ -2951,7 +2929,7 @@ class PlayState extends MusicBeatState rating.velocity.x -= FlxG.random.int(0, 10); - var msTiming = truncateFloat(noteDiff, 3); + var msTiming = HelperFunctions.truncateFloat(noteDiff, 3); if (currentTimingShown != null) remove(currentTimingShown); @@ -2991,7 +2969,7 @@ class PlayState extends MusicBeatState - offsetTest = truncateFloat(total / hits.length,2); + offsetTest = HelperFunctions.truncateFloat(total / hits.length,2); } if (currentTimingShown.alpha != 1) @@ -3138,6 +3116,9 @@ class PlayState extends MusicBeatState private function keyShit():Void { + if (mashing != 0) + mashing = 0; + // HOLDING var up = controls.UP; var right = controls.RIGHT; @@ -3154,6 +3135,8 @@ class PlayState extends MusicBeatState var downR = controls.DOWN_R; var leftR = controls.LEFT_R; + + if (loadRep) // replay code { // disable input @@ -3212,6 +3195,11 @@ class PlayState extends MusicBeatState } var controlArray:Array = [leftP, downP, upP, rightP]; + for (b in controlArray) { // get every key press + if (b) + mashing++; + } + // FlxG.watch.addQuick('asdfa', upP); if ((upP || rightP || downP || leftP) && !boyfriend.stunned && generatedMusic) { @@ -3248,7 +3236,30 @@ class PlayState extends MusicBeatState { if (controlArray[coolNote.noteData]) - goodNoteHit(coolNote); + { + + // ANTI MASH CODE FOR THE BOYS + + if (mashing > getKeyPresses(coolNote) && mashViolations < 2) + { + mashViolations++; + + goodNoteHit(coolNote, (mashing > getKeyPresses(coolNote))); + } + else + { + // this is bad but fuck you + playerStrums.members[0].animation.play('static'); + playerStrums.members[1].animation.play('static'); + playerStrums.members[2].animation.play('static'); + playerStrums.members[3].animation.play('static'); + health -= 0.2; + trace('mash ' + mashing); + } + + if (mashing != 0) + mashing = 0; + } else { var inIgnoreList:Bool = false; @@ -3270,7 +3281,7 @@ class PlayState extends MusicBeatState if (NearlyEquals(daNote.strumTime,rep.replay.keyPresses[repPresses].time, 30)) { - goodNoteHit(daNote); + //goodNoteHit(daNote, (mashing > getKeyPresses(daNote))); trace('force note hit'); } else @@ -3297,7 +3308,7 @@ class PlayState extends MusicBeatState coolNote.rating = "good"; else if (noteDiff < Conductor.safeZoneOffset * 0.44 && noteDiff > Conductor.safeZoneOffset * -0.44) coolNote.rating = "sick"; - goodNoteHit(coolNote); + //goodNoteHit(coolNote, (mashing > getKeyPresses(coolNote))); trace('force note hit'); } else @@ -3318,7 +3329,7 @@ class PlayState extends MusicBeatState daNote.rating = Ratings.CalculateRating(noteDiff); - goodNoteHit(daNote); + //goodNoteHit(daNote, (mashing > getKeyPresses(daNote))); trace('force note hit'); } else @@ -3369,16 +3380,16 @@ class PlayState extends MusicBeatState // NOTES YOU ARE HOLDING case 2: if (up || upHold) - goodNoteHit(daNote); + goodNoteHit(daNote, (mashing > getKeyPresses(daNote))); case 3: if (right || rightHold) - goodNoteHit(daNote); + goodNoteHit(daNote, (mashing > getKeyPresses(daNote))); case 1: if (down || downHold) - goodNoteHit(daNote); + goodNoteHit(daNote, (mashing > getKeyPresses(daNote))); case 0: if (left || leftHold) - goodNoteHit(daNote); + goodNoteHit(daNote, (mashing > getKeyPresses(daNote))); } } }); @@ -3604,55 +3615,44 @@ class PlayState extends MusicBeatState { var noteDiff:Float = Math.abs(note.strumTime - Conductor.songPosition); - if (noteDiff > Conductor.safeZoneOffset * 0.70 || noteDiff < Conductor.safeZoneOffset * -0.70) - note.rating = "shit"; - else if (noteDiff > Conductor.safeZoneOffset * 0.50 || noteDiff < Conductor.safeZoneOffset * -0.50) - note.rating = "bad"; - else if (noteDiff > Conductor.safeZoneOffset * 0.45 || noteDiff < Conductor.safeZoneOffset * -0.45) - note.rating = "good"; - else if (noteDiff < Conductor.safeZoneOffset * 0.44 && noteDiff > Conductor.safeZoneOffset * -0.44) - note.rating = "sick"; + note.rating = Ratings.CalculateRating(noteDiff); if (loadRep) { if (controlArray[note.noteData]) - goodNoteHit(note); + goodNoteHit(note, false); else if (rep.replay.keyPresses.length > repPresses && !controlArray[note.noteData]) { if (NearlyEquals(note.strumTime,rep.replay.keyPresses[repPresses].time, 4)) { - goodNoteHit(note); + goodNoteHit(note, false); } } } else if (controlArray[note.noteData]) { - for (b in controlArray) { - if (b) - mashing++; - } - // ANTI MASH CODE FOR THE BOYS - - if (mashing <= getKeyPresses(note) && mashViolations < 2) + if (mashing > getKeyPresses(note) && mashViolations <= 2) { mashViolations++; - - goodNoteHit(note, (mashing <= getKeyPresses(note))); + + goodNoteHit(note, (mashing > getKeyPresses(note))); } - else + else if (mashViolations > 2) { // this is bad but fuck you playerStrums.members[0].animation.play('static'); playerStrums.members[1].animation.play('static'); playerStrums.members[2].animation.play('static'); playerStrums.members[3].animation.play('static'); - health -= 0.2; + health -= 0.4; trace('mash ' + mashing); + if (mashing != 0) + mashing = 0; } + else + goodNoteHit(note, false); - if (mashing != 0) - mashing = 0; } } @@ -3661,6 +3661,9 @@ class PlayState extends MusicBeatState function goodNoteHit(note:Note, resetMashViolation = true):Void { + if (mashing != 0) + mashing = 0; + var noteDiff:Float = Math.abs(note.strumTime - Conductor.songPosition); note.rating = Ratings.CalculateRating(noteDiff); @@ -3668,9 +3671,12 @@ class PlayState extends MusicBeatState if (!note.isSustainNote) notesHitArray.push(Date.now()); - if (resetMashViolation) + if (!resetMashViolation && mashViolations >= 1) mashViolations--; + if (mashViolations < 0) + mashViolations = 0; + if (!note.wasGoodHit) { if (!note.isSustainNote) @@ -3839,7 +3845,7 @@ class PlayState extends MusicBeatState songLength = FlxG.sound.music.length; // Updating Discord Rich Presence (with Time Left) - DiscordClient.changePresence(detailsText + " " + SONG.song + " (" + storyDifficultyText + ") " + generateRanking(), "Acc: " + truncateFloat(accuracy, 2) + "% | Score: " + songScore + " | Misses: " + misses , iconRPC,true, songLength - Conductor.songPosition); + DiscordClient.changePresence(detailsText + " " + SONG.song + " (" + storyDifficultyText + ") " + Ratings.GenerateLetterRank(accuracy), "Acc: " + HelperFunctions.truncateFloat(accuracy, 2) + "% | Score: " + songScore + " | Misses: " + misses , iconRPC,true, songLength - Conductor.songPosition); #end } @@ -3875,7 +3881,15 @@ class PlayState extends MusicBeatState // Conductor.changeBPM(SONG.bpm); // Dad doesnt interupt his own notes - if (SONG.notes[Math.floor(curStep / 16)].mustHitSection) + + // Commented out until a reason to bring this back arises in the future + /* if (SONG.notes[Math.floor(curStep / 16)].mustHitSection) + dad.dance(); */ + + if(dad.animation.curAnim.name.startsWith('sing')) + if(dad.animation.finished) + dad.dance(); + else dad.dance(); } // FlxG.log.add('change bpm' + SONG.notes[Std.int(curStep / 16)].changeBPM); diff --git a/source/Ratings.hx b/source/Ratings.hx index 46e9ffb..f8be3ed 100644 --- a/source/Ratings.hx +++ b/source/Ratings.hx @@ -1,6 +1,94 @@ +import flixel.FlxG; + class Ratings { - public static function CalculateRating(noteDiff:Float, ?customSafeZone:Float):String + public static function GenerateLetterRank(accuracy:Float) // generate a letter ranking + { + var ranking:String = "N/A"; + + if (PlayState.misses == 0 && PlayState.bads == 0 && PlayState.shits == 0 && PlayState.goods == 0) // Marvelous (SICK) Full Combo + ranking = "(MFC)"; + else if (PlayState.misses == 0 && PlayState.bads == 0 && PlayState.shits == 0 && PlayState.goods >= 1) // Good Full Combo (Nothing but Goods & Sicks) + ranking = "(GFC)"; + else if (PlayState.misses == 0) // Regular FC + ranking = "(FC)"; + else if (PlayState.misses < 10) // Single Digit Combo Breaks + ranking = "(SDCB)"; + else + ranking = "(Clear)"; + + // WIFE TIME :)))) (based on Wife3) + + var wifeConditions:Array = [ + accuracy >= 99.9935, // AAAAA + accuracy >= 99.980, // AAAA: + accuracy >= 99.970, // AAAA. + accuracy >= 99.955, // AAAA + accuracy >= 99.90, // AAA: + accuracy >= 99.80, // AAA. + accuracy >= 99.70, // AAA + accuracy >= 99, // AA: + accuracy >= 96.50, // AA. + accuracy >= 93, // AA + accuracy >= 90, // A: + accuracy >= 85, // A. + accuracy >= 80, // A + accuracy >= 70, // B + accuracy >= 60, // C + accuracy < 60 // D + ]; + + for(i in 0...wifeConditions.length) + { + var b = wifeConditions[i]; + if (b) + { + switch(i) + { + case 0: + ranking += " AAAAA"; + case 1: + ranking += " AAAA:"; + case 2: + ranking += " AAAA."; + case 3: + ranking += " AAAA"; + case 4: + ranking += " AAA:"; + case 5: + ranking += " AAA."; + case 6: + ranking += " AAA"; + case 7: + ranking += " AA:"; + case 8: + ranking += " AA."; + case 9: + ranking += " AA"; + case 10: + ranking += " A:"; + case 11: + ranking += " A."; + case 12: + ranking += " A"; + case 13: + ranking += " B"; + case 14: + ranking += " C"; + case 15: + ranking += " D"; + } + break; + } + } + + if (accuracy == 0) + ranking = "N/A"; + + return ranking; + } + + public static function CalculateRating(noteDiff:Float, ?customSafeZone:Float):String // Generate a judgement through some timing shit { var customTimeScale = Conductor.timeScale; @@ -13,6 +101,10 @@ class Ratings // I HATE THIS IF CONDITION // IF LEMON SEES THIS I'M SORRY :( + // trace('Hit Info\nDifference: ' + noteDiff + '\nZone: ' + Conductor.safeZoneOffset * 1.5 + "\nTS: " + customTimeScale + "\nLate: " + 155 * customTimeScale); + + if (noteDiff > 166 * customTimeScale) // so god damn early its a miss + return "miss"; if (noteDiff > 135 * customTimeScale) // way early return "shit"; else if (noteDiff > 90 * customTimeScale) // early @@ -25,6 +117,18 @@ class Ratings return "bad"; else if (noteDiff < -135 * customTimeScale) // late as fuck return "shit"; + else if (noteDiff < -166 * customTimeScale) // so god damn late its a miss + return "miss"; return "sick"; } + + public static function CalculateRanking(score:Int,scoreDef:Int,nps:Int,accuracy:Float):String + { + return + (FlxG.save.data.npsDisplay ? "NPS: " + nps + " | " : "") + // NPS Toggle + "Score:" + (Conductor.safeFrames != 10 ? score + " (" + scoreDef + ")" : "" + score) + // Score + " | Combo Breaks:" + PlayState.misses + // Misses/Combo Breaks + " | Accuracy:" + HelperFunctions.truncateFloat(accuracy, 2) + // Accuracy + "% | " + GenerateLetterRank(accuracy); // Letter Rank + } } \ No newline at end of file