From 337802a6bfc0ba7283f861d917b151a2042a2231 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Thu, 20 Apr 2023 13:48:15 -0400 Subject: [PATCH] Fixed an issue where SongEventScriptEvent would not be dispatched --- hmm.json | 2 +- source/funkin/modding/events/ScriptEvent.hx | 6 ------ .../funkin/modding/events/ScriptEventDispatcher.hx | 6 +++++- source/funkin/play/PlayState.hx | 12 +++++++----- source/funkin/play/character/CharacterData.hx | 1 + 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/hmm.json b/hmm.json index 69f5827a5..7cb2c460e 100644 --- a/hmm.json +++ b/hmm.json @@ -104,7 +104,7 @@ "name": "polymod", "type": "git", "dir": null, - "ref": "4e5b4b3", + "ref": "6594dd8", "url": "https://github.com/larsiusprime/polymod" }, { diff --git a/source/funkin/modding/events/ScriptEvent.hx b/source/funkin/modding/events/ScriptEvent.hx index 9e31a3032..5ee0c42ea 100644 --- a/source/funkin/modding/events/ScriptEvent.hx +++ b/source/funkin/modding/events/ScriptEvent.hx @@ -385,12 +385,6 @@ class SongEventScriptEvent extends ScriptEvent */ public var event(default, null):funkin.play.song.SongData.SongEventData; - /** - * The combo count as it is with this event. - * Will be (combo) on miss events and (combo + 1) on hit events (the stored combo count won't update if the event is cancelled). - */ - public var comboCount(default, null):Int; - public function new(event:funkin.play.song.SongData.SongEventData):Void { super(ScriptEvent.SONG_EVENT, true); diff --git a/source/funkin/modding/events/ScriptEventDispatcher.hx b/source/funkin/modding/events/ScriptEventDispatcher.hx index dda3ead00..05a3fb36e 100644 --- a/source/funkin/modding/events/ScriptEventDispatcher.hx +++ b/source/funkin/modding/events/ScriptEventDispatcher.hx @@ -72,6 +72,9 @@ class ScriptEventDispatcher case ScriptEvent.RESUME: t.onResume(event); return; + case ScriptEvent.SONG_EVENT: + t.onSongEvent(cast event); + return; case ScriptEvent.COUNTDOWN_START: t.onCountdownStart(cast event); return; @@ -118,7 +121,8 @@ class ScriptEventDispatcher return; } - throw "No function called for event type: " + event.type; + // If you get a crash on this line, that means ERIC FUCKED UP! + throw 'No function called for event type: ${event.type}'; } public static function callEventOnAllTargets(targets:Iterator, event:ScriptEvent):Void diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index 8e51db8a0..3c4a31169 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -1771,7 +1771,13 @@ class PlayState extends MusicBeatState trace('Found ${songEventsToActivate.length} event(s) to activate.'); for (event in songEventsToActivate) { - SongEventParser.handleEvent(event); + var eventEvent:SongEventScriptEvent = new SongEventScriptEvent(event); + dispatchEvent(eventEvent); + // Calling event.cancelEvent() skips the event. Neat! + if (!eventEvent.eventCanceled) + { + SongEventParser.handleEvent(event); + } } } } @@ -2674,10 +2680,6 @@ class PlayState extends MusicBeatState // Dispatch event to character script(s). if (currentStage != null) currentStage.dispatchToCharacters(event); - - // TODO: Dispatch event to song script - - // TODO: Dispatch event to note script } /** diff --git a/source/funkin/play/character/CharacterData.hx b/source/funkin/play/character/CharacterData.hx index 7b0ac8981..28763710f 100644 --- a/source/funkin/play/character/CharacterData.hx +++ b/source/funkin/play/character/CharacterData.hx @@ -83,6 +83,7 @@ class CharacterDataParser try { var character:SparrowCharacter = ScriptedSparrowCharacter.init(charCls, DEFAULT_CHAR_ID); + trace(' Initialized character ${character.characterName}'); characterScriptedClass.set(character.characterId, charCls); } catch (e)