From 912612d79255ac8f53f39df8306900c9f7514e1d Mon Sep 17 00:00:00 2001 From: NeeEoo Date: Thu, 19 Oct 2023 14:44:04 +0200 Subject: [PATCH] Fix GameOver Event --- .../backend/scripting/events/GameOverEvent.hx | 55 ++++++++++++------- source/funkin/game/PlayState.hx | 7 ++- 2 files changed, 40 insertions(+), 22 deletions(-) diff --git a/source/funkin/backend/scripting/events/GameOverEvent.hx b/source/funkin/backend/scripting/events/GameOverEvent.hx index cdf46256..b0e83795 100644 --- a/source/funkin/backend/scripting/events/GameOverEvent.hx +++ b/source/funkin/backend/scripting/events/GameOverEvent.hx @@ -3,28 +3,43 @@ package funkin.backend.scripting.events; import funkin.game.Character; final class GameOverEvent extends CancellableEvent { - /** - * Character which died. Default to `boyfriend`. - */ - public var character:Character; + /** + * The X pos of where the gameover character will be. + */ + public var x:Float; - /** - * Character ID (name) for game over. Default to whatever is specified in the character's XML. - */ - public var deathCharID:String; + /** + * The Y pos of where the gameover character will be. + */ + public var y:Float; - /** - * Song for the game over screen. Default to `this.gameOverSong` (`gameOver`) - */ - public var gameOverSong:String; + /** + * Character which died. Default to `boyfriend`. + */ + public var character:Character; - /** - * SFX at the beginning of the game over (Mic drop). Default to `this.lossSFX` (`gameOverSFX`) - */ - public var lossSFX:String; + /** + * Character ID (name) for game over. Default to whatever is specified in the character's XML. + */ + public var deathCharID:String; - /** - * SFX played whenever the player retries. Defaults to `retrySFX` (`gameOverEnd`) - */ - public var retrySFX:String; + /** + * If the character has isPlayer + */ + public var isPlayer:Bool; + + /** + * Song for the game over screen. Default to `this.gameOverSong` (`gameOver`) + */ + public var gameOverSong:String; + + /** + * SFX at the beginning of the game over (Mic drop). Default to `this.lossSFX` (`gameOverSFX`) + */ + public var lossSFX:String; + + /** + * SFX played whenever the player retries. Defaults to `retrySFX` (`gameOverEnd`) + */ + public var retrySFX:String; } \ No newline at end of file diff --git a/source/funkin/game/PlayState.hx b/source/funkin/game/PlayState.hx index 7f454a00..d57adcd7 100644 --- a/source/funkin/game/PlayState.hx +++ b/source/funkin/game/PlayState.hx @@ -1246,8 +1246,11 @@ class PlayState extends MusicBeatState */ public function gameOver(?character:Character, ?deathCharID:String, ?gameOverSong:String, ?lossSFX:String, ?retrySFX:String) { var event:GameOverEvent = scripts.event("onGameOver", EventManager.get(GameOverEvent).recycle( + character == null ? 0 : character.x, + character == null ? 0 : character.y, character.getDefault(opponentMode ? dad : boyfriend), deathCharID.getDefault(character != null ? character.gameOverCharacter : "bf-dead"), + character != null ? character.isPlayer : true, gameOverSong.getDefault(this.gameOverSong), lossSFX.getDefault(this.lossSFX), retrySFX.getDefault(this.retrySFX) @@ -1266,9 +1269,9 @@ class PlayState extends MusicBeatState if (FlxG.sound.music != null) FlxG.sound.music.stop(); - openSubState(new GameOverSubstate(character == null ? 0 : character.x, character == null ? 0 : character.y, deathCharID, character != null ? character.isPlayer : true, gameOverSong, lossSFX, retrySFX)); + openSubState(new GameOverSubstate(event.x, event.y, event.deathCharID, event.isPlayer, event.gameOverSong, event.lossSFX, event.retrySFX)); - scripts.event("onGameOver", event); + scripts.event("onPostGameOver", event); } /**