From e4baf51e062fb00144215a5d7eae9ab690497adb Mon Sep 17 00:00:00 2001 From: Ralty <78720179+Raltyro@users.noreply.github.com> Date: Wed, 2 Jul 2025 22:40:56 +0700 Subject: [PATCH] Fix Inconsistency in Sustain Input (#663) Make player sustains the same as cpu sustains --- source/funkin/game/Note.hx | 32 +++++++++++++------------------- source/funkin/game/StrumLine.hx | 5 +++-- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/source/funkin/game/Note.hx b/source/funkin/game/Note.hx index b39743cb..0f007b25 100644 --- a/source/funkin/game/Note.hx +++ b/source/funkin/game/Note.hx @@ -278,30 +278,22 @@ class Note extends FlxSprite public function updateSustain(strum:Strum) { var scrollSpeed = strum.getScrollSpeed(this); - var len = 0.45 * CoolUtil.quantize(scrollSpeed, 100); - - if (nextSustain != null && lastScrollSpeed != scrollSpeed) { - // is long sustain + if (lastScrollSpeed != scrollSpeed) { lastScrollSpeed = scrollSpeed; - - scale.y = (sustainLength * len) / frameHeight; - updateHitbox(); - scale.y += gapFix / frameHeight; + if (nextSustain != null) { + scale.y = (sustainLength * 0.45 * scrollSpeed) / frameHeight; + updateHitbox(); + scale.y += gapFix / frameHeight; + } } - if (!wasGoodHit) return; - var t = FlxMath.bound((Conductor.songPosition - strumTime) / (height) * len, 0, 1); - var swagRect = this.clipRect == null ? new FlxRect() : this.clipRect; - swagRect.x = 0; - swagRect.y = t * frameHeight; - swagRect.width = frameWidth; - swagRect.height = frameHeight; - - setClipRect(swagRect); + updateSustainClip(); } - public inline function setClipRect(rect:FlxRect) { - this.clipRect = rect; + public function updateSustainClip() if (wasGoodHit) { + var t = FlxMath.bound((Conductor.songPosition - strumTime) / height * 0.45 * lastScrollSpeed, 0, 1); + var rect = clipRect == null ? FlxRect.get() : clipRect; + clipRect = rect.set(0, frameHeight * t, frameWidth, frameHeight * (1 - t)); } @:noCompletion @@ -317,5 +309,7 @@ class Note extends FlxSprite public override function destroy() { super.destroy(); + + clipRect = FlxDestroyUtil.put(clipRect); } } diff --git a/source/funkin/game/StrumLine.hx b/source/funkin/game/StrumLine.hx index 1b0780dd..7797ed12 100644 --- a/source/funkin/game/StrumLine.hx +++ b/source/funkin/game/StrumLine.hx @@ -189,7 +189,7 @@ class StrumLine extends FlxTypedGroup { if (cpu && __updateNote_event.__autoCPUHit && !daNote.avoid && !daNote.wasGoodHit && daNote.strumTime < __updateNote_songPos) PlayState.instance.goodNoteHit(this, daNote); - if (daNote.wasGoodHit && daNote.isSustainNote && daNote.strumTime + (daNote.sustainLength) < __updateNote_songPos) { + if (daNote.wasGoodHit && daNote.isSustainNote && daNote.strumTime + daNote.sustainLength < __updateNote_songPos) { deleteNote(daNote); return; } @@ -215,8 +215,9 @@ class StrumLine extends FlxTypedGroup { var __notePerStrum:Array = []; function __inputProcessPressed(note:Note) { - if (__pressed[note.strumID] && note.isSustainNote && note.canBeHit && !note.wasGoodHit) { + if (__pressed[note.strumID] && note.isSustainNote && note.strumTime < __updateNote_songPos && !note.wasGoodHit) { PlayState.instance.goodNoteHit(this, note); + note.updateSustainClip(); } } function __inputProcessJustPressed(note:Note) {