rating refactoring

This commit is contained in:
KadeDev
2021-04-23 11:18:34 -07:00
parent fe0529ee85
commit 160008ef05
4 changed files with 291 additions and 172 deletions

View File

@ -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;
}
}

View File

@ -188,13 +188,13 @@ class Note extends FlxSprite
if (mustPress) if (mustPress)
{ {
// The * 0.5 is so that it's easier to hit them too late, instead of too early // 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)) && strumTime < Conductor.songPosition + (Conductor.safeZoneOffset * 0.5))
canBeHit = true; canBeHit = true;
else else
canBeHit = false; canBeHit = false;
if (strumTime < Conductor.songPosition - Conductor.safeZoneOffset && !wasGoodHit) if (strumTime < Conductor.songPosition - Conductor.safeZoneOffset * Conductor.timeScale && !wasGoodHit)
tooLate = true; tooLate = true;
} }
else else

View File

@ -1,5 +1,6 @@
package; package;
import haxe.Exception;
import openfl.geom.Matrix; import openfl.geom.Matrix;
import openfl.display.BitmapData; import openfl.display.BitmapData;
import openfl.utils.AssetType; import openfl.utils.AssetType;
@ -227,12 +228,19 @@ class PlayState extends MusicBeatState
} }
result = Lua.pcall(lua, args.length, 1, 0); result = Lua.pcall(lua, args.length, 1, 0);
var p = Lua.tostring(lua,result);
var e = getLuaErrorMessage(lua);
if (getLuaErrorMessage(lua) != null) if (e != null)
if (Lua.tostring(lua,result) != null) {
throw(func_name + ' LUA CALL ERROR ' + Lua.tostring(lua,result)); if (p != null)
else {
trace(func_name + ' prolly doesnt exist lol'); 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) { if( result == null) {
return null; return null;
} else { } else {
@ -473,7 +481,7 @@ class PlayState extends MusicBeatState
detailsPausedText = "Paused - " + detailsText; detailsPausedText = "Paused - " + detailsText;
// Updating Discord Rich Presence. // 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 #end
@ -1282,12 +1290,17 @@ class PlayState extends MusicBeatState
var result = LuaL.dofile(lua, Paths.lua(PlayState.SONG.song.toLowerCase() + "/modchart")); // execute le file var result = LuaL.dofile(lua, Paths.lua(PlayState.SONG.song.toLowerCase() + "/modchart")); // execute le file
if (result != 0) 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 // get some fukin globals up in here bois
setVar("difficulty", storyDifficulty); setVar("difficulty", storyDifficulty);
setVar("bpm", Conductor.bpm); 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("fpsCap", FlxG.save.data.fpsCap);
setVar("downscroll", FlxG.save.data.downscroll); setVar("downscroll", FlxG.save.data.downscroll);
@ -1314,6 +1327,10 @@ class PlayState extends MusicBeatState
setVar("hudWidth", camHUD.width); setVar("hudWidth", camHUD.width);
setVar("hudHeight", camHUD.height); setVar("hudHeight", camHUD.height);
setVar("mustHit", false);
setVar("strumLineY", strumLine.y);
// callbacks // callbacks
// sprites // sprites
@ -1378,14 +1395,58 @@ class PlayState extends MusicBeatState
return notes.members[id].y; 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) { trace(Lua_helper.add_callback(lua,"getRenderedNoteScaleX", function(id:Int) {
return notes.members[id].scale.x; return notes.members[id].scale.x;
})); }));
trace(Lua_helper.add_callback(lua,"setRenderedNotePos", function(x:Int,y:Int, id:Int) { 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].modifiedByLua = true;
notes.members[id].x = x; notes.members[id].x = x;
notes.members[id].y = y; notes.members[id].y = y;
}
})); }));
trace(Lua_helper.add_callback(lua,"setRenderedNoteAlpha", function(alpha:Float, id:Int) { trace(Lua_helper.add_callback(lua,"setRenderedNoteAlpha", function(alpha:Float, id:Int) {
@ -1398,6 +1459,21 @@ class PlayState extends MusicBeatState
notes.members[id].setGraphicSize(Std.int(notes.members[id].width * scale)); 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) { trace(Lua_helper.add_callback(lua,"setActorX", function(x:Int,id:String) {
getActorByName(id).x = x; getActorByName(id).x = x;
})); }));
@ -1732,7 +1808,7 @@ class PlayState extends MusicBeatState
#if windows #if windows
// Updating Discord Rich Presence (with Time Left) // 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 #end
} }
@ -1980,7 +2056,7 @@ class PlayState extends MusicBeatState
} }
#if windows #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 #end
if (!startTimer.finished) if (!startTimer.finished)
startTimer.active = false; startTimer.active = false;
@ -2005,11 +2081,11 @@ class PlayState extends MusicBeatState
#if windows #if windows
if (startTimer.finished) 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 else
{ {
DiscordClient.changePresence(detailsText, SONG.song + " (" + storyDifficultyText + ") " + generateRanking(), iconRPC); DiscordClient.changePresence(detailsText, SONG.song + " (" + storyDifficultyText + ") " + Ratings.GenerateLetterRank(accuracy), iconRPC);
} }
#end #end
} }
@ -2028,7 +2104,7 @@ class PlayState extends MusicBeatState
vocals.play(); vocals.play();
#if windows #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 #end
} }
@ -2036,100 +2112,6 @@ class PlayState extends MusicBeatState
var startedCountdown:Bool = false; var startedCountdown:Bool = false;
var canPause:Bool = true; 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<Bool> = [
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; public static var songRate = 1.5;
override public function update(elapsed:Float) override public function update(elapsed:Float)
@ -2235,22 +2217,7 @@ class PlayState extends MusicBeatState
super.update(elapsed); super.update(elapsed);
if (!offsetTesting) scoreTxt.text = Ratings.CalculateRanking(songScore,songScoreDef,nps,accuracy);
{
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;
}
if (FlxG.keys.justPressed.ENTER && startedCountdown && canPause) if (FlxG.keys.justPressed.ENTER && startedCountdown && canPause)
{ {
persistentUpdate = false; 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) if (camFollow.x != dad.getMidpoint().x + 150 && !PlayState.SONG.notes[Std.int(curStep / 16)].mustHitSection)
{ {
var offsetX = 0; var offsetX = 0;
@ -2588,7 +2560,7 @@ class PlayState extends MusicBeatState
#if windows #if windows
// Game Over doesn't get his own variable because it's only used here // 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 #end
// FlxG.switchState(new GameOverState(boyfriend.getScreenPosition().x, boyfriend.getScreenPosition().y)); // 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] != null)
{ {
if (unspawnNotes[0].strumTime - Conductor.songPosition < 1500) if (unspawnNotes[0].strumTime - Conductor.songPosition < 3500)
{ {
var dunceNote:Note = unspawnNotes[0]; var dunceNote:Note = unspawnNotes[0];
notes.add(dunceNote); notes.add(dunceNote);
@ -2610,7 +2582,10 @@ class PlayState extends MusicBeatState
{ {
notes.forEachAlive(function(daNote:Note) 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.active = false;
daNote.visible = false; daNote.visible = false;
@ -2663,10 +2638,13 @@ class PlayState extends MusicBeatState
daNote.destroy(); daNote.destroy();
} }
if (!daNote.modifiedByLua)
{
if (FlxG.save.data.downscroll) 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))); 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 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))); 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) if (daNote.mustPress && !daNote.modifiedByLua)
{ {
@ -2695,7 +2673,7 @@ class PlayState extends MusicBeatState
// WIP interpolation shit? Need to fix the pause issue // WIP interpolation shit? Need to fix the pause issue
// daNote.y = (strumLine.y - (songTime - daNote.strumTime) * (0.45 * PlayState.SONG.speed)); // 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) if (daNote.isSustainNote && daNote.wasGoodHit)
{ {
@ -2951,7 +2929,7 @@ class PlayState extends MusicBeatState
rating.velocity.x -= FlxG.random.int(0, 10); rating.velocity.x -= FlxG.random.int(0, 10);
var msTiming = truncateFloat(noteDiff, 3); var msTiming = HelperFunctions.truncateFloat(noteDiff, 3);
if (currentTimingShown != null) if (currentTimingShown != null)
remove(currentTimingShown); 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) if (currentTimingShown.alpha != 1)
@ -3138,6 +3116,9 @@ class PlayState extends MusicBeatState
private function keyShit():Void private function keyShit():Void
{ {
if (mashing != 0)
mashing = 0;
// HOLDING // HOLDING
var up = controls.UP; var up = controls.UP;
var right = controls.RIGHT; var right = controls.RIGHT;
@ -3154,6 +3135,8 @@ class PlayState extends MusicBeatState
var downR = controls.DOWN_R; var downR = controls.DOWN_R;
var leftR = controls.LEFT_R; var leftR = controls.LEFT_R;
if (loadRep) // replay code if (loadRep) // replay code
{ {
// disable input // disable input
@ -3212,6 +3195,11 @@ class PlayState extends MusicBeatState
} }
var controlArray:Array<Bool> = [leftP, downP, upP, rightP]; var controlArray:Array<Bool> = [leftP, downP, upP, rightP];
for (b in controlArray) { // get every key press
if (b)
mashing++;
}
// FlxG.watch.addQuick('asdfa', upP); // FlxG.watch.addQuick('asdfa', upP);
if ((upP || rightP || downP || leftP) && !boyfriend.stunned && generatedMusic) if ((upP || rightP || downP || leftP) && !boyfriend.stunned && generatedMusic)
{ {
@ -3248,7 +3236,30 @@ class PlayState extends MusicBeatState
{ {
if (controlArray[coolNote.noteData]) 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 else
{ {
var inIgnoreList:Bool = false; var inIgnoreList:Bool = false;
@ -3270,7 +3281,7 @@ class PlayState extends MusicBeatState
if (NearlyEquals(daNote.strumTime,rep.replay.keyPresses[repPresses].time, 30)) if (NearlyEquals(daNote.strumTime,rep.replay.keyPresses[repPresses].time, 30))
{ {
goodNoteHit(daNote); //goodNoteHit(daNote, (mashing > getKeyPresses(daNote)));
trace('force note hit'); trace('force note hit');
} }
else else
@ -3297,7 +3308,7 @@ class PlayState extends MusicBeatState
coolNote.rating = "good"; coolNote.rating = "good";
else if (noteDiff < Conductor.safeZoneOffset * 0.44 && noteDiff > Conductor.safeZoneOffset * -0.44) else if (noteDiff < Conductor.safeZoneOffset * 0.44 && noteDiff > Conductor.safeZoneOffset * -0.44)
coolNote.rating = "sick"; coolNote.rating = "sick";
goodNoteHit(coolNote); //goodNoteHit(coolNote, (mashing > getKeyPresses(coolNote)));
trace('force note hit'); trace('force note hit');
} }
else else
@ -3318,7 +3329,7 @@ class PlayState extends MusicBeatState
daNote.rating = Ratings.CalculateRating(noteDiff); daNote.rating = Ratings.CalculateRating(noteDiff);
goodNoteHit(daNote); //goodNoteHit(daNote, (mashing > getKeyPresses(daNote)));
trace('force note hit'); trace('force note hit');
} }
else else
@ -3369,16 +3380,16 @@ class PlayState extends MusicBeatState
// NOTES YOU ARE HOLDING // NOTES YOU ARE HOLDING
case 2: case 2:
if (up || upHold) if (up || upHold)
goodNoteHit(daNote); goodNoteHit(daNote, (mashing > getKeyPresses(daNote)));
case 3: case 3:
if (right || rightHold) if (right || rightHold)
goodNoteHit(daNote); goodNoteHit(daNote, (mashing > getKeyPresses(daNote)));
case 1: case 1:
if (down || downHold) if (down || downHold)
goodNoteHit(daNote); goodNoteHit(daNote, (mashing > getKeyPresses(daNote)));
case 0: case 0:
if (left || leftHold) if (left || leftHold)
goodNoteHit(daNote); goodNoteHit(daNote, (mashing > getKeyPresses(daNote)));
} }
} }
}); });
@ -3604,56 +3615,45 @@ class PlayState extends MusicBeatState
{ {
var noteDiff:Float = Math.abs(note.strumTime - Conductor.songPosition); var noteDiff:Float = Math.abs(note.strumTime - Conductor.songPosition);
if (noteDiff > Conductor.safeZoneOffset * 0.70 || noteDiff < Conductor.safeZoneOffset * -0.70) note.rating = Ratings.CalculateRating(noteDiff);
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";
if (loadRep) if (loadRep)
{ {
if (controlArray[note.noteData]) if (controlArray[note.noteData])
goodNoteHit(note); goodNoteHit(note, false);
else if (rep.replay.keyPresses.length > repPresses && !controlArray[note.noteData]) else if (rep.replay.keyPresses.length > repPresses && !controlArray[note.noteData])
{ {
if (NearlyEquals(note.strumTime,rep.replay.keyPresses[repPresses].time, 4)) if (NearlyEquals(note.strumTime,rep.replay.keyPresses[repPresses].time, 4))
{ {
goodNoteHit(note); goodNoteHit(note, false);
} }
} }
} }
else if (controlArray[note.noteData]) 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++; mashViolations++;
goodNoteHit(note, (mashing <= getKeyPresses(note))); goodNoteHit(note, (mashing > getKeyPresses(note)));
} }
else else if (mashViolations > 2)
{ {
// this is bad but fuck you // this is bad but fuck you
playerStrums.members[0].animation.play('static'); playerStrums.members[0].animation.play('static');
playerStrums.members[1].animation.play('static'); playerStrums.members[1].animation.play('static');
playerStrums.members[2].animation.play('static'); playerStrums.members[2].animation.play('static');
playerStrums.members[3].animation.play('static'); playerStrums.members[3].animation.play('static');
health -= 0.2; health -= 0.4;
trace('mash ' + mashing); trace('mash ' + mashing);
}
if (mashing != 0) if (mashing != 0)
mashing = 0; mashing = 0;
} }
else
goodNoteHit(note, false);
}
} }
var nps:Int = 0; var nps:Int = 0;
@ -3661,6 +3661,9 @@ class PlayState extends MusicBeatState
function goodNoteHit(note:Note, resetMashViolation = true):Void function goodNoteHit(note:Note, resetMashViolation = true):Void
{ {
if (mashing != 0)
mashing = 0;
var noteDiff:Float = Math.abs(note.strumTime - Conductor.songPosition); var noteDiff:Float = Math.abs(note.strumTime - Conductor.songPosition);
note.rating = Ratings.CalculateRating(noteDiff); note.rating = Ratings.CalculateRating(noteDiff);
@ -3668,9 +3671,12 @@ class PlayState extends MusicBeatState
if (!note.isSustainNote) if (!note.isSustainNote)
notesHitArray.push(Date.now()); notesHitArray.push(Date.now());
if (resetMashViolation) if (!resetMashViolation && mashViolations >= 1)
mashViolations--; mashViolations--;
if (mashViolations < 0)
mashViolations = 0;
if (!note.wasGoodHit) if (!note.wasGoodHit)
{ {
if (!note.isSustainNote) if (!note.isSustainNote)
@ -3839,7 +3845,7 @@ class PlayState extends MusicBeatState
songLength = FlxG.sound.music.length; songLength = FlxG.sound.music.length;
// Updating Discord Rich Presence (with Time Left) // 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 #end
} }

View File

@ -1,6 +1,94 @@
import flixel.FlxG;
class Ratings 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<Bool> = [
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; var customTimeScale = Conductor.timeScale;
@ -13,6 +101,10 @@ class Ratings
// I HATE THIS IF CONDITION // I HATE THIS IF CONDITION
// IF LEMON SEES THIS I'M SORRY :( // 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 if (noteDiff > 135 * customTimeScale) // way early
return "shit"; return "shit";
else if (noteDiff > 90 * customTimeScale) // early else if (noteDiff > 90 * customTimeScale) // early
@ -25,6 +117,18 @@ class Ratings
return "bad"; return "bad";
else if (noteDiff < -135 * customTimeScale) // late as fuck else if (noteDiff < -135 * customTimeScale) // late as fuck
return "shit"; return "shit";
else if (noteDiff < -166 * customTimeScale) // so god damn late its a miss
return "miss";
return "sick"; 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
}
} }