diff --git a/assets/data/characters/gf.xml b/assets/data/characters/gf.xml index 54a09ad8..c5b3506a 100644 --- a/assets/data/characters/gf.xml +++ b/assets/data/characters/gf.xml @@ -1,13 +1,36 @@ - - - - - - - - - - + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/assets/data/cutscenes/eggnog-end.hx b/assets/data/cutscenes/eggnog-end.hx new file mode 100644 index 00000000..0c0d7eb3 --- /dev/null +++ b/assets/data/cutscenes/eggnog-end.hx @@ -0,0 +1,9 @@ +function create() { + game.camHUD.fade(0xFF000000, 0); + + var sound = FlxG.sound.load(Paths.sound('Lights_Shut_off')); + sound.onComplete = function() { + close(); + }; + sound.play(); +} \ No newline at end of file diff --git a/assets/videos/flying ghost.mp4 b/assets/videos/flying ghost.mp4 new file mode 100644 index 00000000..b74ad703 Binary files /dev/null and b/assets/videos/flying ghost.mp4 differ diff --git a/assets/videos/garfield.mp4 b/assets/videos/garfield.mp4 new file mode 100644 index 00000000..149dc9e2 Binary files /dev/null and b/assets/videos/garfield.mp4 differ diff --git a/buildnumber.txt b/buildnumber.txt index 68d2b328..4dedbee1 100644 --- a/buildnumber.txt +++ b/buildnumber.txt @@ -1 +1 @@ -1210 \ No newline at end of file +1214 \ No newline at end of file diff --git a/source/funkin/cutscenes/Cutscene.hx b/source/funkin/cutscenes/Cutscene.hx index 7805d458..72507fb9 100644 --- a/source/funkin/cutscenes/Cutscene.hx +++ b/source/funkin/cutscenes/Cutscene.hx @@ -1,12 +1,19 @@ package funkin.cutscenes; class Cutscene extends MusicBeatSubstate { + var __callback:Void->Void; + var game:PlayState = PlayState.instance; + + public function new(callback:Void->Void) { + super(); + __callback = callback; + } public override function update(elapsed:Float) { super.update(elapsed); } public override function close() { - PlayState.instance.startCountdown(); + __callback(); super.close(); } } \ No newline at end of file diff --git a/source/funkin/cutscenes/ScriptedCutscene.hx b/source/funkin/cutscenes/ScriptedCutscene.hx new file mode 100644 index 00000000..e98d836d --- /dev/null +++ b/source/funkin/cutscenes/ScriptedCutscene.hx @@ -0,0 +1,49 @@ +package funkin.cutscenes; + +import funkin.scripting.Script; + +class ScriptedCutscene extends Cutscene { + var script:Script; + + public function new(scriptPath:String, callback:Void->Void) { + super(callback); + + script = Script.create(scriptPath); + script.setPublicMap(PlayState.instance.scripts.publicVariables); + script.setParent(this); + script.load(); + } + + public override function create() { + super.create(); + script.call("create"); + } + + public override function update(elapsed:Float) { + script.call("update", [elapsed]); + super.update(elapsed); + script.call("updatePost", [elapsed]); + } + + public override function beatHit(curBeat:Int) { + super.beatHit(curBeat); + script.call("beatHit", [curBeat]); + } + + public override function stepHit(curStep:Int) { + super.stepHit(curStep); + script.call("stepHit", [curStep]); + } + + public override function destroy() { + script.call("destroy"); + super.destroy(); + } + + public function startVideo(path:String, ?callback:Void->Void) { + openSubState(new VideoCutscene(path, function() { + if (callback != null) + callback(); + })); + } +} \ No newline at end of file diff --git a/source/funkin/cutscenes/VideoCutscene.hx b/source/funkin/cutscenes/VideoCutscene.hx index c9f4a0b2..bf5b5a26 100644 --- a/source/funkin/cutscenes/VideoCutscene.hx +++ b/source/funkin/cutscenes/VideoCutscene.hx @@ -12,8 +12,9 @@ class VideoCutscene extends Cutscene { var video:MP4Handler; var videoSprite:FlxSprite; var cutsceneCamera:FlxCamera; - public function new(path:String) { - super(); + + public function new(path:String, callback:Void->Void) { + super(callback); localPath = Assets.getPath(this.path = path); } diff --git a/source/funkin/game/PlayState.hx b/source/funkin/game/PlayState.hx index 96ab7a80..fb7cb55a 100644 --- a/source/funkin/game/PlayState.hx +++ b/source/funkin/game/PlayState.hx @@ -198,6 +198,16 @@ class PlayState extends MusicBeatState detailsText = "Freeplay"; } + // Checks if cutscene files exists + var cutscenePath = Paths.script('data/cutscenes/${SONG.song.toLowerCase()}'); + var endCutscenePath = Paths.script('data/cutscenes/${SONG.song.toLowerCase()}-end'); + trace(cutscenePath); + trace(endCutscenePath); + if (Assets.exists(cutscenePath)) + cutscene = cutscenePath; + if (Assets.exists(endCutscenePath)) + endCutscene = endCutscenePath; + // String for when the game is paused detailsPausedText = "Paused - " + detailsText; @@ -324,27 +334,57 @@ class PlayState extends MusicBeatState super.create(); } - // PATH TO STRING CUTSCENE + // PATH TO STRING CUTSCENE (Paths.script + public var playCutscenes:Bool = isStoryMode; public var cutscene:String = null; + public var endCutscene:String = null; public override function createPost() { - - var videoCutscene = Paths.video('${PlayState.SONG.song.toLowerCase()}-cutscene'); - - FlxTransitionableState.skipNextTransIn = true; - if (cutscene != null) { - // TODO: Script cutscenes - } else if (Assets.exists(videoCutscene)) { - openSubState(new VideoCutscene(videoCutscene)); - persistentUpdate = false; - persistentDraw = false; - } else { - FlxTransitionableState.skipNextTransIn = false; - startCountdown(); - } + startCutscene(); super.createPost(); scripts.call("createPost"); } + public function startCutscene() { + if (playCutscenes) { + var videoCutscene = Paths.video('${PlayState.SONG.song.toLowerCase()}-cutscene'); + persistentUpdate = false; + if (cutscene != null) { + openSubState(new ScriptedCutscene(cutscene, function() { + nextSong(); + })); + } else if (Assets.exists(videoCutscene)) { + FlxTransitionableState.skipNextTransIn = true; + openSubState(new VideoCutscene(videoCutscene, function() { + startCountdown(); + })); + persistentDraw = false; + } else { + startCountdown(); + } + } else + startCountdown(); + } + + public function startEndCutscene() { + if (playCutscenes) { + var videoCutscene = Paths.video('${PlayState.SONG.song.toLowerCase()}-end-cutscene'); + persistentUpdate = false; + if (endCutscene != null) { + openSubState(new ScriptedCutscene(endCutscene, function() { + nextSong(); + })); + } else if (Assets.exists(videoCutscene)) { + openSubState(new VideoCutscene(videoCutscene, function() { + nextSong(); + })); + persistentDraw = false; + } else { + nextSong(); + } + } else + nextSong(); + } + public var startTimer:FlxTimer; public var perfectMode:Bool = false; public var introLength:Int = 5; @@ -1030,8 +1070,11 @@ class PlayState extends MusicBeatState { scripts.call("onSongEnd"); canPause = false; - FlxG.sound.music.volume = 0; + inst.volume = 0; vocals.volume = 0; + inst.pause(); + vocals.pause(); + if (SONG.validScore) { #if !switch @@ -1043,6 +1086,10 @@ class PlayState extends MusicBeatState #end } + startEndCutscene(); + } + + public function nextSong() { if (isStoryMode) { campaignScore += songScore;