Fix Legacy Rating/Timing Handler

This commit is contained in:
Ralty
2025-11-18 11:25:07 +07:00
parent 535e702bc2
commit 7fc047615f
6 changed files with 69 additions and 68 deletions
+36 -35
View File
@@ -557,10 +557,11 @@ class PlayState extends MusicBeatState
public var noteTypesArray:Array<String> = [null];
/**
* Hit window, in milliseconds. Defaults to 250ms unless changed in options.
* Base game hit window is 175ms.
* Hit window, in milliseconds. A Legacy CNE Hit window configuration,
* Don't use this, it's for mods that still uses the old judgement timing, instead use ratingManager.
*/
public var hitWindow:Float = Options.hitWindow; // is calculated in create(), is safeFrames in milliseconds.
public var hitWindow:Float = Options.hitWindow;
@:noCompletion @:dox(hide) private var _legacyRating:Rating = {name: "", window: 0, accuracy: 0, score: 0};
@:noCompletion @:dox(hide) private var _startCountdownCalled:Bool = false;
@:noCompletion @:dox(hide) private var _endSongCalled:Bool = false;
@@ -1884,48 +1885,48 @@ class PlayState extends MusicBeatState
note.wasGoodHit = true;
/**
* CALCULATES RATING
*/
var noteDiff = Math.abs(Conductor.songPosition - note.strumTime);
var daRating:Rating = ratingManager.judgeNote(noteDiff);
var noteDiff = Math.abs(Conductor.songPosition - note.strumTime), rating:Rating;
if (!Flags.USE_LEGACY_TIMING) rating = ratingManager.judgeNote(noteDiff);
else {
(rating = _legacyRating).splash = false;
if (noteDiff > hitWindow * 0.9) {
rating.window = hitWindow;
rating.name = "shit";
rating.score = 50;
rating.accuracy = 0.25;
}
else if (noteDiff > hitWindow * 0.75) {
rating.window = hitWindow * 0.9;
rating.name = "bad";
rating.score = 100;
rating.accuracy = 0.45;
}
else if (noteDiff > hitWindow * 0.2) {
rating.window = hitWindow * 0.75;
rating.name = "good";
rating.score = 200;
rating.accuracy = 0.75;
}
else {
rating.window = hitWindow * 0.2;
rating.name = "sick";
rating.score = 300;
rating.accuracy = 1;
rating.splash = true;
}
}
var event:NoteHitEvent;
if (strumLine != null && !strumLine.cpu)
event = EventManager.get(NoteHitEvent).recycle(false, !note.isSustainNote, !note.isSustainNote, null, defaultDisplayRating, defaultDisplayCombo, note, strumLine.characters, true, note.noteType, note.animSuffix.getDefault(note.strumID < strumLine.members.length ? strumLine.members[note.strumID].animSuffix : strumLine.animSuffix), "game/score/", "", note.strumID, daRating.score, note.isSustainNote ? null : daRating.accuracy, 0.023, daRating.name, Options.splashesEnabled && !note.isSustainNote && daRating.splash, 0.5, true, 0.7, true, true, iconP1);
event = EventManager.get(NoteHitEvent).recycle(false, !note.isSustainNote, !note.isSustainNote, null, defaultDisplayRating, defaultDisplayCombo, note, strumLine.characters, true, note.noteType, note.animSuffix.getDefault(note.strumID < strumLine.members.length ? strumLine.members[note.strumID].animSuffix : strumLine.animSuffix), "game/score/", "", note.strumID, rating.score, note.isSustainNote ? null : rating.accuracy, 0.023, rating.name, Options.splashesEnabled && !note.isSustainNote && rating.splash, 0.5, true, 0.7, true, true, iconP1);
else
event = EventManager.get(NoteHitEvent).recycle(false, false, false, null, defaultDisplayRating, defaultDisplayCombo, note, strumLine.characters, false, note.noteType, note.animSuffix.getDefault(note.strumID < strumLine.members.length ? strumLine.members[note.strumID].animSuffix : strumLine.animSuffix), "game/score/", "", note.strumID, 0, null, 0, daRating.name, false, 0.5, true, 0.7, true, true, iconP2);
event = EventManager.get(NoteHitEvent).recycle(false, false, false, null, defaultDisplayRating, defaultDisplayCombo, note, strumLine.characters, false, note.noteType, note.animSuffix.getDefault(note.strumID < strumLine.members.length ? strumLine.members[note.strumID].animSuffix : strumLine.animSuffix), "game/score/", "", note.strumID, 0, null, 0, rating.name, false, 0.5, true, 0.7, true, true, iconP2);
event.deleteNote = !note.isSustainNote; // work around, to allow sustain notes to be deleted
event = scripts.event(strumLine != null && !strumLine.cpu ? "onPlayerHit" : "onDadHit", event);
strumLine.onHit.dispatch(event);
gameAndCharsEvent("onNoteHit", event);
if (!event.cancelled) {
if (event.legacyJudge) {
event.rating = 'sick';
event.score = 300;
event.accuracy = 1;
if (noteDiff > hitWindow * 0.9)
{
event.rating = 'shit';
event.score = 50;
event.accuracy = 0.25;
}
else if (noteDiff > hitWindow * 0.75)
{
event.rating = 'bad';
event.score = 100;
event.accuracy = 0.45;
}
else if (noteDiff > hitWindow * 0.2)
{
event.rating = 'good';
event.score = 200;
event.accuracy = 0.75;
}
}
if (!note.isSustainNote) {
if (event.countScore) songScore += event.score;
if (event.accuracy != null) {
+1 -1
View File
@@ -216,7 +216,7 @@ class StrumLine extends FlxTypedGroup<Strum> {
if (__updateNote_event.cancelled) return;
if (__updateNote_event.__updateHitWindow) {
var hitWindow = PlayState.instance.hitWindow;
var hitWindow = Flags.USE_LEGACY_TIMING ? PlayState.instance.hitWindow : PlayState.instance.ratingManager.lastHitWindow;
daNote.canBeHit = (daNote.strumTime > __updateNote_songPos - (hitWindow * daNote.latePressWindow)
&& daNote.strumTime < __updateNote_songPos + (hitWindow * daNote.earlyPressWindow));
@@ -12,6 +12,7 @@ class RatingManager
{
public var hitWindows:StringMap<Float>;
public var ratingData:Array<Rating> = [];
public var lastHitWindow:Float = -1;
public function new(?preset:WindowPreset):Void
{
@@ -63,6 +64,8 @@ class RatingManager
? data.window
: (hitWindows.exists(name) ? hitWindows.get(name) : -1);
if (window > lastHitWindow) lastHitWindow = window;
var newRating:Rating = {
name: name,
window: window,