Skip to content

Commit e6f1fed

Browse files
authored
add preventSustainClip (#856)
1 parent e585de7 commit e6f1fed

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

source/funkin/backend/scripting/events/note/NoteHitEvent.hx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ final class NoteHitEvent extends CancellableEvent {
1111
@:dox(hide) public var unmuteVocals:Bool = true;
1212
@:dox(hide) public var enableCamZooming:Bool = true;
1313
@:dox(hide) public var autoHitLastSustain:Bool = true;
14+
@:dox(hide) public var clipSustain:Bool = true;
1415

1516
/**
1617
* Whenever a miss should be added.
@@ -145,6 +146,13 @@ final class NoteHitEvent extends CancellableEvent {
145146
deleteNote = true;
146147
}
147148

149+
/**
150+
* Prevents the sustain from being cut. Only works if the note is a sustain.
151+
*/
152+
public function preventSustainClip() {
153+
clipSustain = false;
154+
}
155+
148156
/**
149157
* Prevents the vocals volume from being set to 1 after pressing the note.
150158
*/

source/funkin/game/Note.hx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ class Note extends FlxSprite
8383

8484
public var sustainLength:Float = 0;
8585
public var isSustainNote:Bool = false;
86+
public var noSustainClip:Bool = false;
8687
public var flipSustain:Bool = true;
8788

8889
public var noteTypeID:Int = 0;
@@ -222,6 +223,7 @@ class Note extends FlxSprite
222223
public var lastScrollSpeed:Null<Float> = null;
223224
public var gapFix:SingleOrFloat = 0;
224225
public var useAntialiasingFix(get, set):Bool;
226+
225227
inline function set_useAntialiasingFix(v:Bool) {
226228
if(v != useAntialiasingFix) {
227229
gapFix = v ? 1 : 0;
@@ -308,7 +310,7 @@ class Note extends FlxSprite
308310
updateSustainClip();
309311
}
310312

311-
public function updateSustainClip() if (wasGoodHit) {
313+
public function updateSustainClip() if (wasGoodHit && !noSustainClip) {
312314
var t = FlxMath.bound((Conductor.songPosition - strumTime) / height * 0.45 * lastScrollSpeed, 0, 1);
313315
var rect = clipRect == null ? FlxRect.get() : clipRect;
314316
clipRect = rect.set(0, frameHeight * t, frameWidth, frameHeight * (1 - t));

source/funkin/game/PlayState.hx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1952,6 +1952,8 @@ class PlayState extends MusicBeatState
19521952
strumLine.onHit.dispatch(event);
19531953
gameAndCharsEvent("onNoteHit", event);
19541954

1955+
note.noSustainClip = !event.clipSustain;
1956+
19551957
if (!event.cancelled) {
19561958
if (!note.isSustainNote) {
19571959
if (event.countScore) songScore += event.score;

source/funkin/game/StrumLine.hx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,10 @@ class StrumLine extends FlxTypedGroup<Strum> {
224224
daNote.tooLate = true;
225225
}
226226

227-
if (cpu && __updateNote_event.__autoCPUHit && !daNote.avoid && !daNote.wasGoodHit && daNote.strumTime < __updateNote_songPos) PlayState.instance.goodNoteHit(this, daNote);
227+
if (cpu && __updateNote_event.__autoCPUHit && !daNote.avoid && !daNote.wasGoodHit && daNote.strumTime < __updateNote_songPos)
228+
PlayState.instance.goodNoteHit(this, daNote);
228229

229-
if (daNote.wasGoodHit && daNote.isSustainNote && daNote.strumTime + daNote.sustainLength < __updateNote_songPos) {
230+
if (daNote.wasGoodHit && daNote.isSustainNote && daNote.strumTime + daNote.sustainLength < __updateNote_songPos && !daNote.noSustainClip) {
230231
deleteNote(daNote);
231232
return;
232233
}

0 commit comments

Comments
 (0)