FIX NOTE HITS
fixes weird note misses when multiple notes are hittable also fixes notes on HUD appearing pressed when the button is released during game pause/window unfocus
This commit is contained in:
parent
333cd2711b
commit
8ae8aaec51
|
@ -2014,157 +2014,92 @@ class PlayState extends MusicBeatState
|
|||
|
||||
private function keyShit():Void
|
||||
{
|
||||
// HOLDING
|
||||
var up = controls.NOTE_UP;
|
||||
var right = controls.NOTE_RIGHT;
|
||||
var down = controls.NOTE_DOWN;
|
||||
var left = controls.NOTE_LEFT;
|
||||
// control arrays, order L D R U
|
||||
var holdArray:Array<Bool> = [controls.NOTE_LEFT, controls.NOTE_DOWN, controls.NOTE_UP, controls.NOTE_RIGHT];
|
||||
var pressArray:Array<Bool> = [controls.NOTE_LEFT_P, controls.NOTE_DOWN_P, controls.NOTE_UP_P, controls.NOTE_RIGHT_P];
|
||||
var releaseArray:Array<Bool> = [controls.NOTE_LEFT_R, controls.NOTE_DOWN_R, controls.NOTE_UP_R, controls.NOTE_RIGHT_R];
|
||||
|
||||
var upP = controls.NOTE_UP_P;
|
||||
var rightP = controls.NOTE_RIGHT_P;
|
||||
var downP = controls.NOTE_DOWN_P;
|
||||
var leftP = controls.NOTE_LEFT_P;
|
||||
|
||||
var upR = controls.NOTE_UP_R;
|
||||
var rightR = controls.NOTE_RIGHT_R;
|
||||
var downR = controls.NOTE_DOWN_R;
|
||||
var leftR = controls.NOTE_LEFT_R;
|
||||
|
||||
var controlArray:Array<Bool> = [leftP, downP, upP, rightP];
|
||||
|
||||
// FlxG.watch.addQuick('asdfa', upP);
|
||||
if ((upP || rightP || downP || leftP) && generatedMusic)
|
||||
// HOLDS, check for sustain notes
|
||||
if (holdArray.contains(true) && /*!boyfriend.stunned && */ generatedMusic)
|
||||
{
|
||||
// note to self, used to have stunned
|
||||
// && !boyfriend.stunned
|
||||
notes.forEachAlive(function(daNote:Note)
|
||||
{
|
||||
if (daNote.isSustainNote && daNote.canBeHit && daNote.mustPress && holdArray[daNote.noteData])
|
||||
goodNoteHit(daNote);
|
||||
});
|
||||
}
|
||||
|
||||
// PRESSES, check for note hits
|
||||
if (pressArray.contains(true) && /*!boyfriend.stunned && */ generatedMusic)
|
||||
{
|
||||
boyfriend.holdTimer = 0;
|
||||
|
||||
var possibleNotes:Array<Note> = [];
|
||||
|
||||
var ignoreList:Array<Int> = [];
|
||||
var possibleNotes:Array<Note> = []; // notes that can be hit
|
||||
var directionList:Array<Int> = []; // directions that can be hit
|
||||
var dumbNotes:Array<Note> = []; // notes to kill later
|
||||
|
||||
notes.forEachAlive(function(daNote:Note)
|
||||
{
|
||||
if (daNote.canBeHit && daNote.mustPress && !daNote.tooLate && !daNote.wasGoodHit)
|
||||
{
|
||||
// the sorting probably doesn't need to be in here? who cares lol
|
||||
possibleNotes.push(daNote);
|
||||
possibleNotes.sort((a, b) -> Std.int(a.strumTime - b.strumTime));
|
||||
|
||||
ignoreList.push(daNote.noteData);
|
||||
}
|
||||
});
|
||||
|
||||
if (possibleNotes.length > 0)
|
||||
{
|
||||
var daNote = possibleNotes[0];
|
||||
|
||||
if (perfectMode)
|
||||
noteCheck(true, daNote);
|
||||
|
||||
// Jump notes
|
||||
if (possibleNotes.length >= 2)
|
||||
{
|
||||
if (possibleNotes[0].strumTime == possibleNotes[1].strumTime)
|
||||
if (directionList.contains(daNote.noteData))
|
||||
{
|
||||
for (coolNote in possibleNotes)
|
||||
{
|
||||
if (controlArray[coolNote.noteData])
|
||||
goodNoteHit(coolNote);
|
||||
else
|
||||
{
|
||||
var inIgnoreList:Bool = false;
|
||||
for (shit in 0...ignoreList.length)
|
||||
{
|
||||
if (controlArray[ignoreList[shit]])
|
||||
inIgnoreList = true;
|
||||
}
|
||||
if (!inIgnoreList)
|
||||
badNoteCheck();
|
||||
if (coolNote.noteData == daNote.noteData && Math.abs(daNote.strumTime - coolNote.strumTime) < 10)
|
||||
{ // if it's the same note twice at < 10ms distance, just delete it
|
||||
// EXCEPT u cant delete it in this loop cuz it fucks with the collection lol
|
||||
dumbNotes.push(daNote);
|
||||
break;
|
||||
}
|
||||
else if (coolNote.noteData == daNote.noteData && daNote.strumTime < coolNote.strumTime)
|
||||
{ // if daNote is earlier than existing note (coolNote), replace
|
||||
possibleNotes.remove(coolNote);
|
||||
possibleNotes.push(daNote);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (possibleNotes[0].noteData == possibleNotes[1].noteData)
|
||||
{
|
||||
noteCheck(controlArray[daNote.noteData], daNote);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (coolNote in possibleNotes)
|
||||
{
|
||||
noteCheck(controlArray[coolNote.noteData], coolNote);
|
||||
}
|
||||
}
|
||||
}
|
||||
else // regular notes?
|
||||
{
|
||||
noteCheck(controlArray[daNote.noteData], daNote);
|
||||
}
|
||||
/*
|
||||
if (controlArray[daNote.noteData])
|
||||
goodNoteHit(daNote);
|
||||
*/
|
||||
// trace(daNote.noteData);
|
||||
/*
|
||||
switch (daNote.noteData)
|
||||
{
|
||||
case 2: // NOTES YOU JUST PRESSED
|
||||
if (upP || rightP || downP || leftP)
|
||||
noteCheck(upP, daNote);
|
||||
case 3:
|
||||
if (upP || rightP || downP || leftP)
|
||||
noteCheck(rightP, daNote);
|
||||
case 1:
|
||||
if (upP || rightP || downP || leftP)
|
||||
noteCheck(downP, daNote);
|
||||
case 0:
|
||||
if (upP || rightP || downP || leftP)
|
||||
noteCheck(leftP, daNote);
|
||||
}
|
||||
|
||||
//this is already done in noteCheck / goodNoteHit
|
||||
if (daNote.wasGoodHit)
|
||||
{
|
||||
daNote.kill();
|
||||
notes.remove(daNote, true);
|
||||
daNote.destroy();
|
||||
}
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
badNoteCheck();
|
||||
}
|
||||
}
|
||||
|
||||
if ((up || right || down || left) && /*!boyfriend.stunned && */ generatedMusic)
|
||||
{
|
||||
notes.forEachAlive(function(daNote:Note)
|
||||
{
|
||||
if (daNote.canBeHit && daNote.mustPress && daNote.isSustainNote)
|
||||
{
|
||||
switch (daNote.noteData)
|
||||
{
|
||||
// NOTES YOU ARE HOLDING
|
||||
case 0:
|
||||
if (left)
|
||||
goodNoteHit(daNote);
|
||||
case 1:
|
||||
if (down)
|
||||
goodNoteHit(daNote);
|
||||
case 2:
|
||||
if (up)
|
||||
goodNoteHit(daNote);
|
||||
case 3:
|
||||
if (right)
|
||||
goodNoteHit(daNote);
|
||||
possibleNotes.push(daNote);
|
||||
directionList.push(daNote.noteData);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
for (note in dumbNotes)
|
||||
{
|
||||
FlxG.log.add("killing dumb ass note at "+note.strumTime);
|
||||
note.kill();
|
||||
notes.remove(note, true);
|
||||
note.destroy();
|
||||
}
|
||||
|
||||
possibleNotes.sort((a, b) -> Std.int(a.strumTime - b.strumTime));
|
||||
|
||||
if (perfectMode)
|
||||
goodNoteHit(possibleNotes[0]);
|
||||
else if (possibleNotes.length > 0)
|
||||
{
|
||||
for (shit in 0...pressArray.length)
|
||||
{ // if a direction is hit that shouldn't be
|
||||
if (pressArray[shit] && !directionList.contains(shit))
|
||||
badNoteHit();
|
||||
}
|
||||
for (coolNote in possibleNotes)
|
||||
{
|
||||
if (pressArray[coolNote.noteData])
|
||||
goodNoteHit(coolNote);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
badNoteHit();
|
||||
}
|
||||
}
|
||||
|
||||
if (boyfriend.holdTimer > Conductor.stepCrochet * 4 * 0.001 && !up && !down && !right && !left)
|
||||
if (boyfriend.holdTimer > Conductor.stepCrochet * 4 * 0.001 && !holdArray.contains(true))
|
||||
{
|
||||
if (boyfriend.animation.curAnim.name.startsWith('sing') && !boyfriend.animation.curAnim.name.endsWith('miss'))
|
||||
{
|
||||
|
@ -2174,29 +2109,10 @@ class PlayState extends MusicBeatState
|
|||
|
||||
playerStrums.forEach(function(spr:FlxSprite)
|
||||
{
|
||||
switch (spr.ID)
|
||||
{
|
||||
case 0:
|
||||
if (leftP && spr.animation.curAnim.name != 'confirm')
|
||||
spr.animation.play('pressed');
|
||||
if (leftR)
|
||||
spr.animation.play('static');
|
||||
case 1:
|
||||
if (downP && spr.animation.curAnim.name != 'confirm')
|
||||
spr.animation.play('pressed');
|
||||
if (downR)
|
||||
spr.animation.play('static');
|
||||
case 2:
|
||||
if (upP && spr.animation.curAnim.name != 'confirm')
|
||||
spr.animation.play('pressed');
|
||||
if (upR)
|
||||
spr.animation.play('static');
|
||||
case 3:
|
||||
if (rightP && spr.animation.curAnim.name != 'confirm')
|
||||
spr.animation.play('pressed');
|
||||
if (rightR)
|
||||
spr.animation.play('static');
|
||||
}
|
||||
if (pressArray[spr.ID] && spr.animation.curAnim.name != 'confirm')
|
||||
spr.animation.play('pressed');
|
||||
if (!holdArray[spr.ID])
|
||||
spr.animation.play('static');
|
||||
|
||||
if (spr.animation.curAnim.name == 'confirm' && !curStage.startsWith('school'))
|
||||
{
|
||||
|
@ -2248,14 +2164,14 @@ class PlayState extends MusicBeatState
|
|||
}
|
||||
}
|
||||
|
||||
function badNoteCheck()
|
||||
function badNoteHit()
|
||||
{
|
||||
// just double pasting this shit cuz fuk u
|
||||
// REDO THIS SYSTEM!
|
||||
var leftP = controls.NOTE_LEFT_P;
|
||||
var downP = controls.NOTE_DOWN_P;
|
||||
var upP = controls.NOTE_UP_P;
|
||||
var rightP = controls.NOTE_RIGHT_P;
|
||||
var downP = controls.NOTE_DOWN_P;
|
||||
var leftP = controls.NOTE_LEFT_P;
|
||||
|
||||
if (leftP)
|
||||
noteMiss(0);
|
||||
|
@ -2267,16 +2183,6 @@ class PlayState extends MusicBeatState
|
|||
noteMiss(3);
|
||||
}
|
||||
|
||||
function noteCheck(keyP:Bool, note:Note):Void
|
||||
{
|
||||
if (keyP)
|
||||
goodNoteHit(note);
|
||||
else
|
||||
{
|
||||
badNoteCheck();
|
||||
}
|
||||
}
|
||||
|
||||
function goodNoteHit(note:Note):Void
|
||||
{
|
||||
if (!note.wasGoodHit)
|
||||
|
|
Loading…
Reference in New Issue