diff --git a/source/online/FunkinPoints.hx b/source/online/FunkinPoints.hx index e523a0f0..4d7f2788 100644 --- a/source/online/FunkinPoints.hx +++ b/source/online/FunkinPoints.hx @@ -5,52 +5,27 @@ class FunkinPoints { @:forwardField(FlxG.save.data.funkinPointsv4, 0) public static var funkinPoints(get, set):Float; - public static function calcFP(accuracy:Float, misses:Float, denseNotes:Float, notesHit:Float, maxCombo:Float):Float { + public static function calcFP(accuracy:Float, misses:Float, songDensity:Float, notesHit:Float, maxCombo:Float):Float { if (accuracy <= 0 || notesHit <= 0) return 0; - // depends on the amount of hitted notes (1fp per 5-150 notes) - var fp:Float = notesHit / (denseNotes / 2); - // depends on player's note streak (x2fp per 1000 combo) - fp *= 1 + maxCombo / 1000; + // depends on the amount of hitted notes and the density of the song + // density values for songs: 2.9p (unbeatable), 3.6 (ballistic), 4.2 (spookeez erect), 4.6 (sporting) + // so for a song with 3.0 density (ex. spookeez erect), for every ~65 hitted notes a player will gain 1 fp (without combo bonus) + var fp:Float = (1 + songDensity) * (notesHit / 200); + // depends on player's note streak (x2fp per 2000 combo) + fp *= 1 + maxCombo / 2000; // depends on player's note accuracy (weighted by power of 3; 95% = x0.85, 90% = x0.72, 80% = x0.512) fp *= Math.pow(accuracy, 3) / (1 + misses * 0.25); return Math.ffloor(fp); } - public static function save(accuracy:Float, misses:Float, denseNotes:Float, notesHit:Float, maxCombo:Float) { - var gained:Float = online.FunkinPoints.calcFP(accuracy, misses, denseNotes, notesHit, maxCombo); + public static function save(accuracy:Float, misses:Float, songDensity:Float, notesHit:Float, maxCombo:Float) { + var gained:Float = online.FunkinPoints.calcFP(accuracy, misses, songDensity, notesHit, maxCombo); funkinPoints += gained; FlxG.save.flush(); GameClient.send("updateFP", funkinPoints); return gained; } -} - -// @:build(online.backend.Macros.getSetForwarder()) -// class FunkinPoints { -// @:forwardField(FlxG.save.data.funkinPointsv4, 0) -// public static var funkinPoints(get, set):Float; - -// public static function calcFP(accuracy:Float, misses:Float, notesHit:Float, maxCombo:Float):Float { -// if (accuracy <= 0 || notesHit <= 0) -// return 0; - -// // depends on player's hitted notes (1fp per 100 hitted notes) -// var fp:Float = notesHit / 100; -// // depends on player's note streak (x2fp per 500 combo) -// fp *= 1 + maxCombo / 500; -// // depends on player's note accuracy (weighted by power of 3; 95% = x0.85, 90% = x0.72, 80% = x0.512) -// fp *= Math.pow(accuracy, 3) / (1 + misses * 0.25); -// return Math.ffloor(fp); -// } - -// public static function save(accuracy:Float, misses:Float, notesHit:Float, maxCombo:Float) { -// var gained:Float = online.FunkinPoints.calcFP(accuracy, misses, notesHit, maxCombo); -// funkinPoints += gained; -// FlxG.save.flush(); -// GameClient.send("updateFP", funkinPoints); -// return gained; -// } -// } \ No newline at end of file +} \ No newline at end of file diff --git a/source/online/replay/ReplayRecorder.hx b/source/online/replay/ReplayRecorder.hx index 8440c940..ec2920dc 100644 --- a/source/online/replay/ReplayRecorder.hx +++ b/source/online/replay/ReplayRecorder.hx @@ -147,7 +147,7 @@ class ReplayRecorder extends FlxBasic { data.goods = state.songGoods; data.bads = state.songBads; data.shits = state.songShits; - data.points = FunkinPoints.calcFP(state.ratingPercent, state.songMisses, state.denseNotes, state.totalNotesHit, state.combo); + data.points = FunkinPoints.calcFP(state.ratingPercent, state.songMisses, state.songDensity, state.totalNotesHit, state.combo); data.beat_time = Date.now().getTime(); data.note_offset = ClientPrefs.data.noteOffset; diff --git a/source/states/PlayState.hx b/source/states/PlayState.hx index 53434dd0..3ed59739 100644 --- a/source/states/PlayState.hx +++ b/source/states/PlayState.hx @@ -431,7 +431,7 @@ class PlayState extends MusicBeatState } var waitReadySpr:Alphabet; - public var denseNotes:Float = 0; + public var songDensity:Float = 0; var stageData:StageFile; var stageModDir:String; @@ -1751,7 +1751,7 @@ class PlayState extends MusicBeatState scoreTextObject.text = 'Score: ' + FlxStringUtil.formatMoney(songScore, false) + ' | Misses: ' + songMisses + ' | Rating: ' + str; } - var points = online.FunkinPoints.calcFP(ratingPercent, songMisses, denseNotes, totalNotesHit, maxCombo); + var points = online.FunkinPoints.calcFP(ratingPercent, songMisses, songDensity, totalNotesHit, maxCombo); if (points != songPoints) { songPoints = points; resetRPC(true); @@ -1937,19 +1937,16 @@ class PlayState extends MusicBeatState makeEvent(event, i); } - var densLastStrumTime:Float = -1; - var densNotes:Float = 0; - var densNotesCount:Float = 0; - var lastNoteDiff:Float = 0; - var cNoteCount:Float = 0; + var playingNoteCount:Float = 0; + var lastStrumTime:Float = 0; - //csc = Conductor.stepCrochet * 1.5; - var csc = 300; //130 for (section in noteData) { for (songNotes in section.sectionNotes) { var daStrumTime:Float = songNotes[0]; + if (daStrumTime > inst.length) + continue; var daNoteData:Int = Std.int(songNotes[1] % 4); var maniaKeys:Int = 4; switch (SONG.mania) { @@ -1984,31 +1981,10 @@ class PlayState extends MusicBeatState gottaHitNote = !section.mustHitSection; } - if (songNotes[2] <= 0 && playsAsBF() ? gottaHitNote : !gottaHitNote && daStrumTime - densLastStrumTime > 0) { - var noteDiff = (daStrumTime - densLastStrumTime) / playbackRate; - // var keepCombo = noteDiff < csc && noteDiff + 20 < lastNoteDiff; - - // if (noteDiff < csc_2) { - // lessDenseCount++; - // } - - // if (keepCombo) { - // if (noteDiff > 10) { - // densNotesCount++; - // densNotes += (csc - noteDiff) / csc; - // } - // } - - // lastNoteDiff = noteDiff; - // densLastStrumTime = daStrumTime; - - if (noteDiff > 10 && noteDiff < csc) { - densNotes += noteDiff; - densNotesCount++; - } - - densLastStrumTime = daStrumTime; + if (playsAsBF() ? gottaHitNote : !gottaHitNote && daStrumTime - lastStrumTime > 10) { + playingNoteCount++; } + lastStrumTime = daStrumTime; var oldNote:Note; if (unspawnNotes.length > 0) @@ -2094,11 +2070,8 @@ class PlayState extends MusicBeatState } } } - // denseNotes = densNotesCount == 0 ? 0 : (densNotes + densNotesBonus) / 1000; - // trace(' + predensity: ' + densNotes); - // trace(' + bonus: ' + densNotesBonus); - denseNotes = densNotesCount == 0 ? csc : densNotes / densNotesCount; - trace("note density score: " + denseNotes); + songDensity = playingNoteCount == 0 ? 0 : playingNoteCount / (inst.length / playbackRate / 1000) / 2; + trace("note density score (w/ fp): " + (1 + songDensity)); for (event in songData.events) //Event Notes for (i in 0...event[1].length) makeEvent(event, i); @@ -3249,7 +3222,7 @@ class PlayState extends MusicBeatState return false; } - songPoints = online.FunkinPoints.calcFP(ratingPercent, songMisses, denseNotes, totalNotesHit, maxCombo); + songPoints = online.FunkinPoints.calcFP(ratingPercent, songMisses, songDensity, totalNotesHit, maxCombo); //Should kill you if you tried to cheat if(!startingSong) { @@ -3305,7 +3278,7 @@ class PlayState extends MusicBeatState if(Math.isNaN(percent)) percent = 0; if (!isInvalidScore() && finishingSong) { Highscore.saveScore(SONG.song, songScore, storyDifficulty, percent); - var offlinePoints = online.FunkinPoints.save(ratingPercent, songMisses, denseNotes, totalNotesHit, maxCombo); + var offlinePoints = online.FunkinPoints.save(ratingPercent, songMisses, songDensity, totalNotesHit, maxCombo); if (!online.network.FunkinNetwork.loggedIn) gainedPoints = offlinePoints; if (replayRecorder != null)