Fixed a bug where you could hold notes forever

This commit is contained in:
EliteMasterEric 2023-06-27 18:06:33 -04:00
parent 2f7708c106
commit d91c341bd2
3 changed files with 39 additions and 8 deletions

View file

@ -24,6 +24,16 @@ class NoteSplash extends FlxSprite
// alpha = 0.75;
}
public override function update(elapsed:Float):Void
{
super.update(elapsed);
if (animation.finished)
{
kill();
}
}
public static function buildSplashFrames(force:Bool = false):FlxAtlasFrames
{
// static variables inside functions are a cool of Haxe 4.3.0.

View file

@ -33,6 +33,7 @@ import funkin.play.event.SongEventData.SongEventParser;
import funkin.play.notes.NoteSprite;
import funkin.play.notes.NoteDirection;
import funkin.play.notes.Strumline;
import funkin.play.notes.SustainTrail;
import funkin.play.scoring.Scoring;
import funkin.play.song.Song;
import funkin.play.song.SongData.SongDataParser;
@ -1728,10 +1729,15 @@ class PlayState extends MusicBeatState
// This handles scoring so we don't need it on the opponent's side.
for (holdNote in playerStrumline.holdNotes.members)
{
if (holdNote == null || !holdNote.alive) continue;
// While the hold note is being hit, and there is length on the hold note...
if (holdNote.hitNote && holdNote.sustainLength > 0)
if (holdNote.hitNote && !holdNote.missedNote && holdNote.sustainLength > 0)
{
// Grant the player health.
trace(holdNote);
trace(holdNote.noteData);
trace(holdNote.sustainLength);
health += Constants.HEALTH_HOLD_BONUS_PER_SECOND * elapsed;
}
}
@ -1760,6 +1766,7 @@ class PlayState extends MusicBeatState
// Generate a list of notes within range.
var notesInRange:Array<NoteSprite> = playerStrumline.getNotesMayHit();
var holdNotesInRange:Array<SustainTrail> = playerStrumline.getHoldNotesHitOrMissed();
// If there are notes in range, pressing a key will cause a ghost miss.
@ -1785,7 +1792,7 @@ class PlayState extends MusicBeatState
// Play the strumline animation.
playerStrumline.playPress(input.noteDirection);
}
else if (Constants.GHOST_TAPPING && notesInRange.length > 0 && notesInDirection.length == 0)
else if (Constants.GHOST_TAPPING && (holdNotesInRange.length + notesInRange.length > 0) && notesInDirection.length == 0)
{
// Pressed a wrong key with no notes nearby AND with notes in a different direction available.
// Perform a ghost miss (anti-spam).

View file

@ -130,6 +130,13 @@ class Strumline extends FlxSpriteGroup
});
}
public function getHoldNotesHitOrMissed():Array<SustainTrail>
{
return holdNotes.members.filter(function(holdNote:SustainTrail) {
return holdNote != null && holdNote.alive && (holdNote.hitNote || holdNote.missedNote);
});
}
public function getHoldNotesInRange(strumTime:Float, hitWindow:Float):Array<SustainTrail>
{
var hitWindowStart:Float = strumTime - hitWindow;
@ -255,15 +262,17 @@ class Strumline extends FlxSpriteGroup
else if (holdNote.hitNote && holdNote.sustainLength <= 0)
{
// Hold note is completed, kill it.
playStatic(holdNote.noteDirection);
if (isKeyHeld(holdNote.noteDirection))
{
playPress(holdNote.noteDirection);
}
else
{
playStatic(holdNote.noteDirection);
}
holdNote.visible = false;
holdNote.kill();
}
else if (holdNote.hitNote && holdNote.sustainLength <= 10)
{
// TODO: Better handle the weird edge case where the hold note is almost completed.
holdNote.visible = false;
}
else if (holdNote.missedNote && (holdNote.fullSustainLength > holdNote.sustainLength))
{
// Hold note was dropped before completing, keep it in its clipped state.
@ -294,6 +303,11 @@ class Strumline extends FlxSpriteGroup
holdNote.sustainLength = (holdNote.strumTime + holdNote.fullSustainLength) - Conductor.songPosition;
if (holdNote.sustainLength <= 10)
{
holdNote.visible = false;
}
if (PreferencesMenu.getPref('downscroll'))
{
holdNote.y = this.y - holdNote.height + STRUMLINE_SIZE / 2;