From 4172fd861d321d18a54067461f5427417ba848ba Mon Sep 17 00:00:00 2001 From: Eric Myllyoja Date: Thu, 14 Jul 2022 19:03:42 -0400 Subject: [PATCH] First prototype of can logic --- hmm.json | 68 +++++++++---------- source/Main.hx | 26 ++++--- source/funkin/FreeplayState.hx | 3 +- source/funkin/GameOverSubstate.hx | 5 +- source/funkin/modding/IScriptedClass.hx | 51 +++++++++++++- source/funkin/play/PlayState.hx | 18 +++-- source/funkin/play/character/BaseCharacter.hx | 6 +- source/funkin/play/stage/Bopper.hx | 2 +- source/funkin/play/stage/Stage.hx | 2 +- 9 files changed, 121 insertions(+), 60 deletions(-) diff --git a/hmm.json b/hmm.json index 985375c42..0134944ed 100644 --- a/hmm.json +++ b/hmm.json @@ -1,17 +1,35 @@ { "dependencies": [ { - "name": "discord_rpc", - "type": "git", - "dir": null, - "ref": "2d83fa8", - "url": "https://github.com/Aidan63/linc_discord-rpc" + "name": "hxcpp", + "type": "haxelib", + "version": "4.2.1" + }, + { + "name": "hxcpp-debug-server", + "type": "haxelib", + "version": "1.2.4" + }, + { + "name": "thx.semver", + "type": "haxelib", + "version": "0.2.2" + }, + { + "name": "lime", + "type": "haxelib", + "version": "7.9.0" + }, + { + "name": "openfl", + "type": "haxelib", + "version": "9.1.0" }, { "name": "flixel", "type": "git", "dir": null, - "ref": "0637ac4", + "ref": "75a2789", "url": "https://github.com/haxeflixel/flixel" }, { @@ -25,38 +43,16 @@ "version": "2.4.0" }, { - "name": "flxanimate", + "name": "discord_rpc", "type": "git", "dir": null, - "ref": "master", - "url": "https://github.com/Dot-Stuff/flxanimate" + "ref": "2d83fa8", + "url": "https://github.com/Aidan63/linc_discord-rpc" }, { "name": "hscript", - "type": "git", - "dir": null, - "ref": "7124b6c", - "url": "https://github.com/HaxeFoundation/hscript" - }, - { - "name": "hxcpp", "type": "haxelib", - "version": "4.2.1" - }, - { - "name": "hxcpp-debug-server", - "type": "haxelib", - "version": "1.2.4" - }, - { - "name": "lime", - "type": "haxelib", - "version": "7.9.0" - }, - { - "name": "openfl", - "type": "haxelib", - "version": "9.1.0" + "version": "2.5.0" }, { "name": "polymod", @@ -66,9 +62,11 @@ "url": "https://github.com/larsiusprime/polymod" }, { - "name": "thx.semver", - "type": "haxelib", - "version": "0.2.2" + "name": "flxanimate", + "type": "git", + "dir": null, + "ref": "90c44ca", + "url": "https://github.com/Dot-Stuff/flxanimate" } ] } \ No newline at end of file diff --git a/source/Main.hx b/source/Main.hx index 191ebef53..4b3adf7ff 100644 --- a/source/Main.hx +++ b/source/Main.hx @@ -74,20 +74,28 @@ class Main extends Sprite var stageWidth:Int = Lib.current.stage.stageWidth; var stageHeight:Int = Lib.current.stage.stageHeight; - if (zoom == -1) - { - var ratioX:Float = stageWidth / gameWidth; - var ratioY:Float = stageHeight / gameHeight; - zoom = Math.min(ratioX, ratioY); - gameWidth = Math.ceil(stageWidth / zoom); - gameHeight = Math.ceil(stageHeight / zoom); - } + // if (zoom == -1) + // { + // var ratioX:Float = stageWidth / gameWidth; + // var ratioY:Float = stageHeight / gameHeight; + // zoom = Math.min(ratioX, ratioY); + // gameWidth = Math.ceil(stageWidth / zoom); + // gameHeight = Math.ceil(stageHeight / zoom); + // } + + /** + * The `zoom` argument of FlxGame was removed in the dev branch of Flixel, + * since it was considered confusing and unintuitive. + * If you want to change how the game scales when you resize the window, + * you can use `FlxG.scaleMode`. + * -Eric + */ #if !debug initialState = TitleState; #end - addChild(new FlxGame(gameWidth, gameHeight, initialState, zoom, framerate, framerate, skipSplash, startFullscreen)); + addChild(new FlxGame(gameWidth, gameHeight, initialState, framerate, framerate, skipSplash, startFullscreen)); #if debug fpsCounter = new FPS(10, 3, 0xFFFFFF); diff --git a/source/funkin/FreeplayState.hx b/source/funkin/FreeplayState.hx index c9e498647..658f201c2 100644 --- a/source/funkin/FreeplayState.hx +++ b/source/funkin/FreeplayState.hx @@ -80,7 +80,7 @@ class FreeplayState extends MusicBeatSubstate #if debug isDebug = true; addSong('Test', 1, 'bf-pixel'); - addSong('Pyro', 4, 'bf'); + addSong('Pyro', 8, 'darnell'); #end var initSonglist = CoolUtil.coolTextFile(Paths.txt('freeplaySonglist')); @@ -127,7 +127,6 @@ class FreeplayState extends MusicBeatSubstate trace(FlxG.camera.zoom); trace(FlxG.camera.initialZoom); trace(FlxCamera.defaultZoom); - trace(FlxG.initialZoom); var pinkBack:FlxSprite = new FlxSprite().loadGraphic(Paths.image('freeplay/pinkBack')); pinkBack.color = 0xFFffd4e9; // sets it to pink! diff --git a/source/funkin/GameOverSubstate.hx b/source/funkin/GameOverSubstate.hx index 45fa0134d..24afd1e00 100644 --- a/source/funkin/GameOverSubstate.hx +++ b/source/funkin/GameOverSubstate.hx @@ -61,6 +61,7 @@ class GameOverSubstate extends MusicBeatSubstate Conductor.songPosition = 0; + // TODO: Make SFX and music easily overriden by scripts. playBlueBalledSFX(); switch (PlayState.instance.currentStageId) @@ -68,7 +69,7 @@ class GameOverSubstate extends MusicBeatSubstate case 'school' | 'schoolEvil': musicVariant = "-pixel"; default: - if (PlayState.instance.currentStage.getBoyfriend().characterId == 'pico') + if (['pico', 'pico-playable'].contains(PlayState.instance.currentStage.getBoyfriend().characterId)) { musicVariant = "Pico"; } @@ -89,7 +90,7 @@ class GameOverSubstate extends MusicBeatSubstate boyfriend.isDead = true; add(boyfriend); boyfriend.resetCharacter(); - boyfriend.playAnimation('firstDeath'); + boyfriend.playAnimation('firstDeath', true, true); cameraFollowPoint = new FlxObject(PlayState.instance.cameraFollowPoint.x, PlayState.instance.cameraFollowPoint.y, 1, 1); cameraFollowPoint.x = boyfriend.getGraphicMidpoint().x; diff --git a/source/funkin/modding/IScriptedClass.hx b/source/funkin/modding/IScriptedClass.hx index 0855ee604..b6eca7e68 100644 --- a/source/funkin/modding/IScriptedClass.hx +++ b/source/funkin/modding/IScriptedClass.hx @@ -54,23 +54,72 @@ interface INoteScriptedClass extends IScriptedClass */ interface IPlayStateScriptedClass extends IScriptedClass { + /** + * Called when the game is paused. + * Has properties to set whether the pause easter egg will happen, + * and can be cancelled by scripts. + */ public function onPause(event:PauseScriptEvent):Void; + /** + * Called when the game is unpaused. + */ public function onResume(event:ScriptEvent):Void; - public function onSongLoaded(eent:SongLoadScriptEvent):Void; + /** + * Called when the song has been parsed, before notes have been placed. + * Use this to mutate the chart. + */ + public function onSongLoaded(event:SongLoadScriptEvent):Void; + /** + * Called when the song starts (conductor time is 0 seconds). + */ public function onSongStart(event:ScriptEvent):Void; + /** + * Called when the song ends and the song is about to be unloaded. + */ public function onSongEnd(event:ScriptEvent):Void; + /** + * Called as the player runs out of health just before the game over substate is entered. + */ public function onGameOver(event:ScriptEvent):Void; + /** + * Called when the player restarts the song, either via pause menu or restarting after a game over. + */ public function onSongRetry(event:ScriptEvent):Void; + /** + * Called when EITHER player hits a note. + * Query the note attached to the event to determine if it was hit by the player or CPU. + */ public function onNoteHit(event:NoteScriptEvent):Void; + /** + * Called when EITHER player (usually the player) misses a note. + */ public function onNoteMiss(event:NoteScriptEvent):Void; + /** + * Called when the player presses a key when no note is on the strumline. + */ public function onNoteGhostMiss(event:GhostMissNoteScriptEvent):Void; + /** + * Called once every step of the song. + */ public function onStepHit(event:SongTimeScriptEvent):Void; + /** + * Called once every beat of the song. + */ public function onBeatHit(event:SongTimeScriptEvent):Void; + /** + * Called when the countdown of the song starts. + */ public function onCountdownStart(event:CountdownScriptEvent):Void; + /** + * Called when the a part of the countdown happens. + */ public function onCountdownStep(event:CountdownScriptEvent):Void; + /** + * Called when the countdown of the song ends. + */ public function onCountdownEnd(event:CountdownScriptEvent):Void; } diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index 719bb52b9..d27c4d99c 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -779,6 +779,8 @@ class PlayState extends MusicBeatState implements IHook function startSong():Void { + dispatchEvent(new ScriptEvent(ScriptEvent.SONG_START)); + startingSong = false; previousFrameTime = FlxG.game.ticks; @@ -1387,6 +1389,8 @@ class PlayState extends MusicBeatState implements IHook function endSong():Void { + dispatchEvent(new ScriptEvent(ScriptEvent.SONG_END)); + seenCutscene = false; deathCounter = 0; mayPauseGame = false; @@ -1844,13 +1848,15 @@ class PlayState extends MusicBeatState implements IHook // bruh this var is bonkers i thot it was a function lmfaooo + // Break up into individual lines to aid debugging. + var shouldShowComboText:Bool = (curBeat % 8 == 7); + var daSection = SongLoad.getSong()[Std.int(curStep / 16)]; + shouldShowComboText = shouldShowComboText && (daSection != null && daSection.mustHitSection); + shouldShowComboText = shouldShowComboText && (combo > 5); - var shouldShowComboText:Bool = (curBeat % 8 == 7) // End of measure. TODO: Is this always the correct time? - && (SongLoad.getSong()[Std.int(curStep / 16)].mustHitSection) // Current section is BF's. - && (combo > 5) // Don't want to show on small combos. - && ((SongLoad.getSong().length < Std.int(curStep / 16)) // Show at the end of the song. - || (!SongLoad.getSong()[Std.int(curStep / 16) + 1].mustHitSection) // Or when the next section is Dad's. - ); + var daNextSection = SongLoad.getSong()[Std.int(curStep / 16) + 1]; + var isEndOfSong = SongLoad.getSong().length < Std.int(curStep / 16); + shouldShowComboText = shouldShowComboText && (isEndOfSong || (daNextSection != null && !daNextSection.mustHitSection)); if (shouldShowComboText) { diff --git a/source/funkin/play/character/BaseCharacter.hx b/source/funkin/play/character/BaseCharacter.hx index 7bcd1f71d..0580e95ef 100644 --- a/source/funkin/play/character/BaseCharacter.hx +++ b/source/funkin/play/character/BaseCharacter.hx @@ -249,9 +249,9 @@ class BaseCharacter extends Bopper // so we can query which ones are available. this.comboNoteCounts = findCountAnimations('combo'); // example: combo50 this.dropNoteCounts = findCountAnimations('drop'); // example: drop50 - trace('${this.animation.getNameList()}'); - trace('Combo note counts: ' + this.comboNoteCounts); - trace('Drop note counts: ' + this.dropNoteCounts); + // trace('${this.animation.getNameList()}'); + // trace('Combo note counts: ' + this.comboNoteCounts); + // trace('Drop note counts: ' + this.dropNoteCounts); super.onCreate(event); } diff --git a/source/funkin/play/stage/Bopper.hx b/source/funkin/play/stage/Bopper.hx index f417781e3..4e65525f8 100644 --- a/source/funkin/play/stage/Bopper.hx +++ b/source/funkin/play/stage/Bopper.hx @@ -360,7 +360,7 @@ class Bopper extends FlxSprite implements IPlayStateScriptedClass public function onCountdownEnd(event:CountdownScriptEvent) {} - public function onSongLoaded(eent:SongLoadScriptEvent) {} + public function onSongLoaded(event:SongLoadScriptEvent) {} public function onSongRetry(event:ScriptEvent) {} } diff --git a/source/funkin/play/stage/Stage.hx b/source/funkin/play/stage/Stage.hx index 52e0c4c9f..421315d64 100644 --- a/source/funkin/play/stage/Stage.hx +++ b/source/funkin/play/stage/Stage.hx @@ -561,7 +561,7 @@ class Stage extends FlxSpriteGroup implements IHook implements IPlayStateScripte public function onNoteGhostMiss(event:GhostMissNoteScriptEvent) {} - public function onSongLoaded(eent:SongLoadScriptEvent) {} + public function onSongLoaded(event:SongLoadScriptEvent) {} public function onSongRetry(event:ScriptEvent) {} }