diff --git a/source/PlayState.hx b/source/PlayState.hx index 08b8d53..3e6dfe3 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -420,6 +420,8 @@ class PlayState extends MusicBeatState override public function create() { + + if (FlxG.sound.music != null) FlxG.sound.music.stop(); @@ -1347,6 +1349,10 @@ class PlayState extends MusicBeatState // hud/camera + trace(Lua_helper.add_callback(lua,"setHudAngle", function (x:Float) { + camHUD.angle = x; + })); + trace(Lua_helper.add_callback(lua,"setHudPosition", function (x:Int, y:Int) { camHUD.x = x; camHUD.y = y; @@ -2600,7 +2606,10 @@ class PlayState extends MusicBeatState { if (FlxG.save.data.downscroll) { - daNote.y = (strumLine.y + 0.45 * (Conductor.songPosition - daNote.strumTime) * FlxMath.roundDecimal(FlxG.save.data.scrollSpeed == 1 ? SONG.speed : FlxG.save.data.scrollSpeed, 2)); + if (daNote.mustPress) + daNote.y = (playerStrums.members[Math.floor(Math.abs(daNote.noteData))].y + 0.45 * (Conductor.songPosition - daNote.strumTime) * FlxMath.roundDecimal(FlxG.save.data.scrollSpeed == 1 ? SONG.speed : FlxG.save.data.scrollSpeed, 2)); + else + daNote.y = (strumLineNotes.members[Math.floor(Math.abs(daNote.noteData))].y + 0.45 * (Conductor.songPosition - daNote.strumTime) * FlxMath.roundDecimal(FlxG.save.data.scrollSpeed == 1 ? SONG.speed : FlxG.save.data.scrollSpeed, 2)); if(daNote.isSustainNote) { // Remember = minus makes notes go up, plus makes them go down @@ -2613,7 +2622,7 @@ class PlayState extends MusicBeatState { // Clip to strumline var swagRect = new FlxRect(0, 0, daNote.frameWidth * 2, daNote.frameHeight * 2); - swagRect.height = (strumLine.y + Note.swagWidth / 2 - daNote.y) / daNote.scale.y; + swagRect.height = (strumLineNotes.members[Math.floor(Math.abs(daNote.noteData))].y + Note.swagWidth / 2 - daNote.y) / daNote.scale.y; swagRect.y = daNote.frameHeight - swagRect.height; daNote.clipRect = swagRect; @@ -2621,7 +2630,10 @@ class PlayState extends MusicBeatState } }else { - daNote.y = (strumLine.y - 0.45 * (Conductor.songPosition - daNote.strumTime) * FlxMath.roundDecimal(FlxG.save.data.scrollSpeed == 1 ? SONG.speed : FlxG.save.data.scrollSpeed, 2)); + if (daNote.mustPress) + daNote.y = (playerStrums.members[Math.floor(Math.abs(daNote.noteData))].y - 0.45 * (Conductor.songPosition - daNote.strumTime) * FlxMath.roundDecimal(FlxG.save.data.scrollSpeed == 1 ? SONG.speed : FlxG.save.data.scrollSpeed, 2)); + else + daNote.y = (strumLineNotes.members[Math.floor(Math.abs(daNote.noteData))].y - 0.45 * (Conductor.songPosition - daNote.strumTime) * FlxMath.roundDecimal(FlxG.save.data.scrollSpeed == 1 ? SONG.speed : FlxG.save.data.scrollSpeed, 2)); if(daNote.isSustainNote) { daNote.y -= daNote.height / 2; @@ -2630,7 +2642,7 @@ class PlayState extends MusicBeatState { // Clip to strumline var swagRect = new FlxRect(0, 0, daNote.width / daNote.scale.x, daNote.height / daNote.scale.y); - swagRect.y = (strumLine.y + Note.swagWidth / 2 - daNote.y) / daNote.scale.y; + swagRect.y = (strumLineNotes.members[Math.floor(Math.abs(daNote.noteData))].y + Note.swagWidth / 2 - daNote.y) / daNote.scale.y; swagRect.height -= swagRect.y; daNote.clipRect = swagRect; @@ -3149,368 +3161,135 @@ class PlayState extends MusicBeatState var rightHold:Bool = false; var leftHold:Bool = false; - private function keyShit():Void - { - if (mashing != 0) - mashing = 0; - - // HOLDING - var up = controls.UP; - var right = controls.RIGHT; - var down = controls.DOWN; - var left = controls.LEFT; - - var upP = controls.UP_P; - var rightP = controls.RIGHT_P; - var downP = controls.DOWN_P; - var leftP = controls.LEFT_P; - - var upR = controls.UP_R; - var rightR = controls.RIGHT_R; - var downR = controls.DOWN_R; - var leftR = controls.LEFT_R; - - - - if (loadRep) // replay code - { - // disable input - up = false; - down = false; - right = false; - left = false; - - // new input - - - //if (rep.replay.keys[repPresses].time == Conductor.songPosition) - // trace('DO IT!!!!!'); - - //timeCurrently = Math.abs(rep.replay.keyPresses[repPresses].time - Conductor.songPosition); - //timeCurrentlyR = Math.abs(rep.replay.keyReleases[repReleases].time - Conductor.songPosition); - - - if (repPresses < rep.replay.keyPresses.length && repReleases < rep.replay.keyReleases.length) + private function keyShit():Void // I've invested in emma stocks { - upP = rep.replay.keyPresses[repPresses].time + 1 <= Conductor.songPosition && rep.replay.keyPresses[repPresses].key == "up"; - rightP = rep.replay.keyPresses[repPresses].time + 1 <= Conductor.songPosition && rep.replay.keyPresses[repPresses].key == "right"; - downP = rep.replay.keyPresses[repPresses].time + 1 <= Conductor.songPosition && rep.replay.keyPresses[repPresses].key == "down"; - leftP = rep.replay.keyPresses[repPresses].time + 1 <= Conductor.songPosition && rep.replay.keyPresses[repPresses].key == "left"; - - upR = rep.replay.keyPresses[repReleases].time - 1 <= Conductor.songPosition && rep.replay.keyReleases[repReleases].key == "up"; - rightR = rep.replay.keyPresses[repReleases].time - 1 <= Conductor.songPosition && rep.replay.keyReleases[repReleases].key == "right"; - downR = rep.replay.keyPresses[repReleases].time - 1<= Conductor.songPosition && rep.replay.keyReleases[repReleases].key == "down"; - leftR = rep.replay.keyPresses[repReleases].time - 1<= Conductor.songPosition && rep.replay.keyReleases[repReleases].key == "left"; - - upHold = upP ? true : upR ? false : true; - rightHold = rightP ? true : rightR ? false : true; - downHold = downP ? true : downR ? false : true; - leftHold = leftP ? true : leftR ? false : true; - } - } - else if (!loadRep) // record replay code - { - if (upP) - rep.replay.keyPresses.push({time: Conductor.songPosition, key: "up"}); - if (rightP) - rep.replay.keyPresses.push({time: Conductor.songPosition, key: "right"}); - if (downP) - rep.replay.keyPresses.push({time: Conductor.songPosition, key: "down"}); - if (leftP) - rep.replay.keyPresses.push({time: Conductor.songPosition, key: "left"}); - - if (upR) - rep.replay.keyReleases.push({time: Conductor.songPosition, key: "up"}); - if (rightR) - rep.replay.keyReleases.push({time: Conductor.songPosition, key: "right"}); - if (downR) - rep.replay.keyReleases.push({time: Conductor.songPosition, key: "down"}); - if (leftR) - rep.replay.keyReleases.push({time: Conductor.songPosition, key: "left"}); - } - var controlArray:Array = [leftP, downP, upP, rightP]; - - for (b in controlArray) { // get every key press - if (b) - mashing++; - } - - // FlxG.watch.addQuick('asdfa', upP); - if ((upP || rightP || downP || leftP) && !boyfriend.stunned && generatedMusic) - { - repPresses++; - boyfriend.holdTimer = 0; - - var possibleNotes:Array = []; - - var ignoreList:Array = []; - - notes.forEachAlive(function(daNote:Note) + // control arrays, order L D R U + var holdArray:Array = [controls.LEFT, controls.DOWN, controls.UP, controls.RIGHT]; + var pressArray:Array = [ + controls.LEFT_P, + controls.DOWN_P, + controls.UP_P, + controls.RIGHT_P + ]; + var releaseArray:Array = [ + controls.LEFT_R, + controls.DOWN_R, + controls.UP_R, + controls.RIGHT_R + ]; + + // HOLDS, check for sustain notes + if (holdArray.contains(true) && /*!boyfriend.stunned && */ generatedMusic) { - if (daNote.canBeHit && daNote.mustPress && !daNote.tooLate) + notes.forEachAlive(function(daNote:Note) { - // 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]; - - // Jump notes - if (possibleNotes.length >= 2) - { - if (possibleNotes[0].strumTime == possibleNotes[1].strumTime) - { - for (coolNote in possibleNotes) - { - - if (controlArray[coolNote.noteData]) - { - - goodNoteHit(coolNote, (mashing > getKeyPresses(coolNote))); - - } - } - } - else if (possibleNotes[0].noteData == possibleNotes[1].noteData) - { - if (loadRep) - { - var noteDiff:Float = Math.abs(daNote.strumTime - Conductor.songPosition); - - daNote.rating = Ratings.CalculateRating(noteDiff); - - if (NearlyEquals(daNote.strumTime,rep.replay.keyPresses[repPresses].time, 30)) - { - //goodNoteHit(daNote, (mashing > getKeyPresses(daNote))); - trace('force note hit'); - } - else - noteCheck(controlArray, daNote); - } - else - noteCheck(controlArray, daNote); - } - else - { - for (coolNote in possibleNotes) - { - if (loadRep) - { - if (NearlyEquals(coolNote.strumTime,rep.replay.keyPresses[repPresses].time, 30)) - { - var noteDiff:Float = Math.abs(coolNote.strumTime - Conductor.songPosition); - - if (noteDiff > Conductor.safeZoneOffset * 0.70 || noteDiff < Conductor.safeZoneOffset * -0.70) - coolNote.rating = "shit"; - else if (noteDiff > Conductor.safeZoneOffset * 0.50 || noteDiff < Conductor.safeZoneOffset * -0.50) - coolNote.rating = "bad"; - else if (noteDiff > Conductor.safeZoneOffset * 0.45 || noteDiff < Conductor.safeZoneOffset * -0.45) - coolNote.rating = "good"; - else if (noteDiff < Conductor.safeZoneOffset * 0.44 && noteDiff > Conductor.safeZoneOffset * -0.44) - coolNote.rating = "sick"; - //goodNoteHit(coolNote, (mashing > getKeyPresses(coolNote))); - trace('force note hit'); - } - else - noteCheck(controlArray, daNote); - } - else - noteCheck(controlArray, coolNote); - } - } - } - else // regular notes? - { - if (loadRep) - { - if (NearlyEquals(daNote.strumTime,rep.replay.keyPresses[repPresses].time, 30)) - { - var noteDiff:Float = Math.abs(daNote.strumTime - Conductor.songPosition); - - daNote.rating = Ratings.CalculateRating(noteDiff); - - //goodNoteHit(daNote, (mashing > getKeyPresses(daNote))); - trace('force note hit'); - } - else - noteCheck(controlArray, daNote); - } - else - noteCheck(controlArray, daNote); - } - /* - if (controlArray[daNote.noteData]) + if (daNote.isSustainNote && daNote.canBeHit && daNote.mustPress && holdArray[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); - } - */ - if (daNote.wasGoodHit) - { - daNote.kill(); - notes.remove(daNote, true); - daNote.destroy(); - } + }); } - } - - if ((up || right || down || left) && generatedMusic || (upHold || downHold || leftHold || rightHold) && loadRep && generatedMusic) - { - notes.forEachAlive(function(daNote:Note) + + // PRESSES, check for note hits + if (pressArray.contains(true) && /*!boyfriend.stunned && */ generatedMusic) { - if (daNote.canBeHit && daNote.mustPress && daNote.isSustainNote) + boyfriend.holdTimer = 0; + + var possibleNotes:Array = []; // notes that can be hit + var directionList:Array = []; // directions that can be hit + var dumbNotes:Array = []; // notes to kill later + + notes.forEachAlive(function(daNote:Note) { - switch (daNote.noteData) + if (daNote.canBeHit && daNote.mustPress && !daNote.tooLate && !daNote.wasGoodHit) { - // NOTES YOU ARE HOLDING - case 2: - if (up || upHold) - goodNoteHit(daNote, (mashing > getKeyPresses(daNote))); - case 3: - if (right || rightHold) - goodNoteHit(daNote, (mashing > getKeyPresses(daNote))); - case 1: - if (down || downHold) - goodNoteHit(daNote, (mashing > getKeyPresses(daNote))); - case 0: - if (left || leftHold) - goodNoteHit(daNote, (mashing > getKeyPresses(daNote))); + if (directionList.contains(daNote.noteData)) + { + for (coolNote in possibleNotes) + { + 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 + { + 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)); + + var dontCheck = false; + + for (i in 0...pressArray.length) + { + if (pressArray[i] && !directionList.contains(i)) + dontCheck = true; + } + + if (perfectMode) + goodNoteHit(possibleNotes[0]); + else if (possibleNotes.length > 0 && !dontCheck) + { + for (coolNote in possibleNotes) + { + if (pressArray[coolNote.noteData]) + { + if (mashViolations != 0) + mashViolations--; + scoreTxt.color = FlxColor.WHITE; + goodNoteHit(coolNote); + } } } - }); - } - - if (boyfriend.holdTimer > Conductor.stepCrochet * 4 * 0.001 && !up && !down && !right && !left) - { - if (boyfriend.animation.curAnim.name.startsWith('sing') && !boyfriend.animation.curAnim.name.endsWith('miss')) - { - boyfriend.playAnim('idle'); + + if (dontCheck && possibleNotes.length > 0) + { + if (mashViolations > 4) + { + trace('mash violations ' + mashViolations); + scoreTxt.color = FlxColor.RED; + noteMiss(0,null); + } + else + mashViolations++; + } + } - } - + + if (boyfriend.holdTimer > Conductor.stepCrochet * 4 * 0.001 && !holdArray.contains(true)) + { + if (boyfriend.animation.curAnim.name.startsWith('sing') && !boyfriend.animation.curAnim.name.endsWith('miss')) + { + boyfriend.playAnim('idle'); + } + } + playerStrums.forEach(function(spr:FlxSprite) { - switch (spr.ID) - { - case 2: - if (loadRep) - { - /*if (upP) - { - spr.animation.play('pressed'); - new FlxTimer().start(Math.abs(rep.replay.keyPresses[repReleases].time - Conductor.songPosition) + 10, function(tmr:FlxTimer) - { - spr.animation.play('static'); - repReleases++; - }); - }*/ - } - else - { - if (upP && spr.animation.curAnim.name != 'confirm' && !loadRep) - { - spr.animation.play('pressed'); - trace('play'); - } - if (upR) - { - spr.animation.play('static'); - repReleases++; - } - } - case 3: - if (loadRep) - { - /*if (upP) - { - spr.animation.play('pressed'); - new FlxTimer().start(Math.abs(rep.replay.keyPresses[repReleases].time - Conductor.songPosition) + 10, function(tmr:FlxTimer) - { - spr.animation.play('static'); - repReleases++; - }); - }*/ - } - else - { - if (rightP && spr.animation.curAnim.name != 'confirm' && !loadRep) - spr.animation.play('pressed'); - if (rightR) - { - spr.animation.play('static'); - repReleases++; - } - } - case 1: - if (loadRep) - { - /*if (upP) - { - spr.animation.play('pressed'); - new FlxTimer().start(Math.abs(rep.replay.keyPresses[repReleases].time - Conductor.songPosition) + 10, function(tmr:FlxTimer) - { - spr.animation.play('static'); - repReleases++; - }); - }*/ - } - else - { - if (downP && spr.animation.curAnim.name != 'confirm' && !loadRep) - spr.animation.play('pressed'); - if (downR) - { - spr.animation.play('static'); - repReleases++; - } - } - case 0: - if (loadRep) - { - /*if (upP) - { - spr.animation.play('pressed'); - new FlxTimer().start(Math.abs(rep.replay.keyPresses[repReleases].time - Conductor.songPosition) + 10, function(tmr:FlxTimer) - { - spr.animation.play('static'); - repReleases++; - }); - }*/ - } - else - { - if (leftP && spr.animation.curAnim.name != 'confirm' && !loadRep) - spr.animation.play('pressed'); - if (leftR) - { - spr.animation.play('static'); - repReleases++; - } - } - } - + 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')) { spr.centerOffsets(); @@ -3520,7 +3299,7 @@ class PlayState extends MusicBeatState else spr.centerOffsets(); }); - } + } function noteMiss(direction:Int = 1, daNote:Note):Void { @@ -3534,11 +3313,11 @@ class PlayState extends MusicBeatState combo = 0; misses++; - var noteDiff:Float = Math.abs(daNote.strumTime - Conductor.songPosition); - var wife:Float = EtternaFunctions.wife3(noteDiff, FlxG.save.data.etternaMode ? 1 : 1.7); + //var noteDiff:Float = Math.abs(daNote.strumTime - Conductor.songPosition); + //var wife:Float = EtternaFunctions.wife3(noteDiff, FlxG.save.data.etternaMode ? 1 : 1.7); if (FlxG.save.data.accuracyMod == 1) - totalNotesHit += wife; + totalNotesHit -= 1; songScore -= 10;