Merge pull request #440 from theDetourist/replayoverhaul
Replay now uses Botplay to simulate previous sessions
This commit is contained in:
commit
fae01e17c0
@ -182,6 +182,12 @@ class PauseSubState extends MusicBeatSubstate
|
|||||||
case "Restart Song":
|
case "Restart Song":
|
||||||
FlxG.resetState();
|
FlxG.resetState();
|
||||||
case "Exit to menu":
|
case "Exit to menu":
|
||||||
|
if(PlayState.loadRep)
|
||||||
|
{
|
||||||
|
FlxG.save.data.botplay = false;
|
||||||
|
FlxG.save.data.scrollSpeed = 1;
|
||||||
|
FlxG.save.data.downscroll = false;
|
||||||
|
}
|
||||||
PlayState.loadRep = false;
|
PlayState.loadRep = false;
|
||||||
#if windows
|
#if windows
|
||||||
if (PlayState.luaModchart != null)
|
if (PlayState.luaModchart != null)
|
||||||
@ -192,6 +198,7 @@ class PauseSubState extends MusicBeatSubstate
|
|||||||
#end
|
#end
|
||||||
if (FlxG.save.data.fpsCap > 290)
|
if (FlxG.save.data.fpsCap > 290)
|
||||||
(cast (Lib.current.getChildAt(0), Main)).setFPSCap(290);
|
(cast (Lib.current.getChildAt(0), Main)).setFPSCap(290);
|
||||||
|
|
||||||
FlxG.switchState(new MainMenuState());
|
FlxG.switchState(new MainMenuState());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -203,6 +203,8 @@ class PlayState extends MusicBeatState
|
|||||||
public static var songOffset:Float = 0;
|
public static var songOffset:Float = 0;
|
||||||
// BotPlay text
|
// BotPlay text
|
||||||
private var botPlayState:FlxText;
|
private var botPlayState:FlxText;
|
||||||
|
// Replay shit
|
||||||
|
private var saveNotes:Array<Float> = [];
|
||||||
|
|
||||||
private var executeModchart = false;
|
private var executeModchart = false;
|
||||||
|
|
||||||
@ -823,6 +825,16 @@ class PlayState extends MusicBeatState
|
|||||||
|
|
||||||
add(dad);
|
add(dad);
|
||||||
add(boyfriend);
|
add(boyfriend);
|
||||||
|
if (loadRep)
|
||||||
|
{
|
||||||
|
FlxG.watch.addQuick('rep rpesses',repPresses);
|
||||||
|
FlxG.watch.addQuick('rep releases',repReleases);
|
||||||
|
|
||||||
|
FlxG.save.data.botplay = true;
|
||||||
|
FlxG.save.data.scrollSpeed = rep.replay.noteSpeed;
|
||||||
|
FlxG.save.data.downscroll = rep.replay.isDownscroll;
|
||||||
|
// FlxG.watch.addQuick('Queued',inputsQueued);
|
||||||
|
}
|
||||||
|
|
||||||
var doof:DialogueBox = new DialogueBox(false, dialogue);
|
var doof:DialogueBox = new DialogueBox(false, dialogue);
|
||||||
// doof.x += 70;
|
// doof.x += 70;
|
||||||
@ -832,7 +844,6 @@ class PlayState extends MusicBeatState
|
|||||||
|
|
||||||
Conductor.songPosition = -5000;
|
Conductor.songPosition = -5000;
|
||||||
|
|
||||||
|
|
||||||
strumLine = new FlxSprite(0, 50).makeGraphic(FlxG.width, 10);
|
strumLine = new FlxSprite(0, 50).makeGraphic(FlxG.width, 10);
|
||||||
strumLine.scrollFactor.set();
|
strumLine.scrollFactor.set();
|
||||||
|
|
||||||
@ -940,7 +951,7 @@ class PlayState extends MusicBeatState
|
|||||||
botPlayState.setFormat(Paths.font("vcr.ttf"), 42, FlxColor.WHITE, RIGHT, FlxTextBorderStyle.OUTLINE,FlxColor.BLACK);
|
botPlayState.setFormat(Paths.font("vcr.ttf"), 42, FlxColor.WHITE, RIGHT, FlxTextBorderStyle.OUTLINE,FlxColor.BLACK);
|
||||||
botPlayState.scrollFactor.set();
|
botPlayState.scrollFactor.set();
|
||||||
|
|
||||||
if(FlxG.save.data.botplay) add(botPlayState);
|
if(FlxG.save.data.botplay && !loadRep) add(botPlayState);
|
||||||
|
|
||||||
iconP1 = new HealthIcon(SONG.player1, true);
|
iconP1 = new HealthIcon(SONG.player1, true);
|
||||||
iconP1.y = healthBar.y - (iconP1.height / 2);
|
iconP1.y = healthBar.y - (iconP1.height / 2);
|
||||||
@ -2057,12 +2068,6 @@ class PlayState extends MusicBeatState
|
|||||||
|
|
||||||
FlxG.watch.addQuick("beatShit", curBeat);
|
FlxG.watch.addQuick("beatShit", curBeat);
|
||||||
FlxG.watch.addQuick("stepShit", curStep);
|
FlxG.watch.addQuick("stepShit", curStep);
|
||||||
if (loadRep) // rep debug
|
|
||||||
{
|
|
||||||
FlxG.watch.addQuick('rep rpesses',repPresses);
|
|
||||||
FlxG.watch.addQuick('rep releases',repReleases);
|
|
||||||
// FlxG.watch.addQuick('Queued',inputsQueued);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (curSong == 'Fresh')
|
if (curSong == 'Fresh')
|
||||||
{
|
{
|
||||||
@ -2322,7 +2327,13 @@ class PlayState extends MusicBeatState
|
|||||||
function endSong():Void
|
function endSong():Void
|
||||||
{
|
{
|
||||||
if (!loadRep)
|
if (!loadRep)
|
||||||
rep.SaveReplay();
|
rep.SaveReplay(saveNotes);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FlxG.save.data.botplay = false;
|
||||||
|
FlxG.save.data.scrollSpeed = 1;
|
||||||
|
FlxG.save.data.downscroll = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (FlxG.save.data.fpsCap > 290)
|
if (FlxG.save.data.fpsCap > 290)
|
||||||
(cast (Lib.current.getChildAt(0), Main)).setFPSCap(290);
|
(cast (Lib.current.getChildAt(0), Main)).setFPSCap(290);
|
||||||
@ -2868,12 +2879,23 @@ class PlayState extends MusicBeatState
|
|||||||
if(FlxG.save.data.botplay && daNote.canBeHit && daNote.mustPress ||
|
if(FlxG.save.data.botplay && daNote.canBeHit && daNote.mustPress ||
|
||||||
FlxG.save.data.botplay && daNote.tooLate && daNote.mustPress)
|
FlxG.save.data.botplay && daNote.tooLate && daNote.mustPress)
|
||||||
{
|
{
|
||||||
|
if(loadRep)
|
||||||
|
{
|
||||||
|
//trace('ReplayNote ' + tmpRepNote.strumtime + ' | ' + tmpRepNote.direction);
|
||||||
|
if(rep.replay.songNotes.contains(HelperFunctions.truncateFloat(daNote.strumTime, 2)))
|
||||||
|
{
|
||||||
|
goodNoteHit(daNote);
|
||||||
|
boyfriend.holdTimer = daNote.sustainLength;
|
||||||
|
}
|
||||||
|
}else {
|
||||||
goodNoteHit(daNote);
|
goodNoteHit(daNote);
|
||||||
boyfriend.holdTimer = daNote.sustainLength;
|
boyfriend.holdTimer = daNote.sustainLength;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
if (boyfriend.holdTimer > Conductor.stepCrochet * 4 * 0.001 && !holdArray.contains(true))
|
|
||||||
|
if (boyfriend.holdTimer > Conductor.stepCrochet * 4 * 0.001 && (!holdArray.contains(true) || FlxG.save.data.botplay))
|
||||||
{
|
{
|
||||||
if (boyfriend.animation.curAnim.name.startsWith('sing') && !boyfriend.animation.curAnim.name.endsWith('miss'))
|
if (boyfriend.animation.curAnim.name.startsWith('sing') && !boyfriend.animation.curAnim.name.endsWith('miss'))
|
||||||
boyfriend.playAnim('idle');
|
boyfriend.playAnim('idle');
|
||||||
@ -2999,7 +3021,7 @@ class PlayState extends MusicBeatState
|
|||||||
|
|
||||||
note.rating = Ratings.CalculateRating(noteDiff);
|
note.rating = Ratings.CalculateRating(noteDiff);
|
||||||
|
|
||||||
if (loadRep)
|
/* if (loadRep)
|
||||||
{
|
{
|
||||||
if (controlArray[note.noteData])
|
if (controlArray[note.noteData])
|
||||||
goodNoteHit(note, false);
|
goodNoteHit(note, false);
|
||||||
@ -3010,10 +3032,10 @@ class PlayState extends MusicBeatState
|
|||||||
goodNoteHit(note, false);
|
goodNoteHit(note, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} */
|
||||||
else if (controlArray[note.noteData])
|
|
||||||
{
|
|
||||||
|
|
||||||
|
if (controlArray[note.noteData])
|
||||||
|
{
|
||||||
goodNoteHit(note, (mashing > getKeyPresses(note)));
|
goodNoteHit(note, (mashing > getKeyPresses(note)));
|
||||||
|
|
||||||
/*if (mashing > getKeyPresses(note) && mashViolations <= 2)
|
/*if (mashing > getKeyPresses(note) && mashViolations <= 2)
|
||||||
@ -3090,14 +3112,8 @@ class PlayState extends MusicBeatState
|
|||||||
#end
|
#end
|
||||||
|
|
||||||
|
|
||||||
if (!loadRep)
|
if(!loadRep && note.mustPress)
|
||||||
playerStrums.forEach(function(spr:FlxSprite)
|
saveNotes.push(HelperFunctions.truncateFloat(note.strumTime, 2));
|
||||||
{
|
|
||||||
if (Math.abs(note.noteData) == spr.ID)
|
|
||||||
{
|
|
||||||
spr.animation.play('confirm', true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
note.wasGoodHit = true;
|
note.wasGoodHit = true;
|
||||||
vocals.volume = 1;
|
vocals.volume = 1;
|
||||||
@ -3276,17 +3292,8 @@ class PlayState extends MusicBeatState
|
|||||||
// Conductor.changeBPM(SONG.bpm);
|
// Conductor.changeBPM(SONG.bpm);
|
||||||
|
|
||||||
// Dad doesnt interupt his own notes
|
// Dad doesnt interupt his own notes
|
||||||
|
if (SONG.notes[Math.floor(curStep / 16)].mustHitSection)
|
||||||
// Commented out until a reason to bring this back arises in the future
|
|
||||||
/* if (SONG.notes[Math.floor(curStep / 16)].mustHitSection)
|
|
||||||
dad.dance(); */
|
|
||||||
/* no because this is kinda dumb
|
|
||||||
if(dad.animation.curAnim.name.startsWith('sing'))
|
|
||||||
if(dad.animation.finished)
|
|
||||||
dad.dance();
|
dad.dance();
|
||||||
else
|
|
||||||
dad.dance();
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
// FlxG.log.add('change bpm' + SONG.notes[Std.int(curStep / 16)].changeBPM);
|
// FlxG.log.add('change bpm' + SONG.notes[Std.int(curStep / 16)].changeBPM);
|
||||||
wiggleShit.update(Conductor.crochet);
|
wiggleShit.update(Conductor.crochet);
|
||||||
|
@ -11,26 +11,15 @@ import haxe.Json;
|
|||||||
import flixel.input.keyboard.FlxKey;
|
import flixel.input.keyboard.FlxKey;
|
||||||
import openfl.utils.Dictionary;
|
import openfl.utils.Dictionary;
|
||||||
|
|
||||||
typedef KeyPress =
|
|
||||||
{
|
|
||||||
public var time:Float;
|
|
||||||
public var key:String;
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef KeyRelease =
|
|
||||||
{
|
|
||||||
public var time:Float;
|
|
||||||
public var key:String;
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef ReplayJSON =
|
typedef ReplayJSON =
|
||||||
{
|
{
|
||||||
public var replayGameVer:String;
|
public var replayGameVer:String;
|
||||||
public var timestamp:Date;
|
public var timestamp:Date;
|
||||||
public var songName:String;
|
public var songName:String;
|
||||||
public var songDiff:Int;
|
public var songDiff:Int;
|
||||||
public var keyPresses:Array<KeyPress>;
|
public var songNotes:Array<Float>;
|
||||||
public var keyReleases:Array<KeyRelease>;
|
public var noteSpeed:Float;
|
||||||
|
public var isDownscroll:Bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
class Replay
|
class Replay
|
||||||
@ -45,8 +34,9 @@ class Replay
|
|||||||
replay = {
|
replay = {
|
||||||
songName: "Tutorial",
|
songName: "Tutorial",
|
||||||
songDiff: 1,
|
songDiff: 1,
|
||||||
keyPresses: [],
|
noteSpeed: 1.5,
|
||||||
keyReleases: [],
|
isDownscroll: false,
|
||||||
|
songNotes: [],
|
||||||
replayGameVer: version,
|
replayGameVer: version,
|
||||||
timestamp: Date.now()
|
timestamp: Date.now()
|
||||||
};
|
};
|
||||||
@ -58,18 +48,19 @@ class Replay
|
|||||||
|
|
||||||
rep.LoadFromJSON();
|
rep.LoadFromJSON();
|
||||||
|
|
||||||
trace('basic replay data:\nSong Name: ' + rep.replay.songName + '\nSong Diff: ' + rep.replay.songDiff + '\nKeys Length: ' + rep.replay.keyPresses.length);
|
trace('basic replay data:\nSong Name: ' + rep.replay.songName + '\nSong Diff: ' + rep.replay.songDiff + '\nNotes Length: ' + rep.replay.songNotes.length);
|
||||||
|
|
||||||
return rep;
|
return rep;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function SaveReplay()
|
public function SaveReplay(notearray:Array<Float>)
|
||||||
{
|
{
|
||||||
var json = {
|
var json = {
|
||||||
"songName": PlayState.SONG.song.toLowerCase(),
|
"songName": PlayState.SONG.song.toLowerCase(),
|
||||||
"songDiff": PlayState.storyDifficulty,
|
"songDiff": PlayState.storyDifficulty,
|
||||||
"keyPresses": replay.keyPresses,
|
"noteSpeed": (FlxG.save.data.scrollSpeed > 1 ? FlxG.save.data.scrollSpeed : PlayState.SONG.speed),
|
||||||
"keyReleases": replay.keyReleases,
|
"isDownscroll": FlxG.save.data.downscroll,
|
||||||
|
"songNotes": notearray,
|
||||||
"timestamp": Date.now(),
|
"timestamp": Date.now(),
|
||||||
"replayGameVer": version
|
"replayGameVer": version
|
||||||
};
|
};
|
||||||
@ -81,7 +72,6 @@ class Replay
|
|||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function LoadFromJSON()
|
public function LoadFromJSON()
|
||||||
{
|
{
|
||||||
#if sys
|
#if sys
|
||||||
|
Loading…
x
Reference in New Issue
Block a user