diff --git a/assets/charts/milf/bump.hx b/assets/charts/milf/bump.hx index 750d8770..c0fb462e 100644 --- a/assets/charts/milf/bump.hx +++ b/assets/charts/milf/bump.hx @@ -5,4 +5,8 @@ function beatHit(curBeat:Int) { case 200: camZoomingInterval = 4; } +} + +function onPlayerHit(event:NoteHitEvent) { + event.direction = 3 - event.direction; } \ No newline at end of file diff --git a/buildnumber.txt b/buildnumber.txt index 61f9147f..65de5029 100644 --- a/buildnumber.txt +++ b/buildnumber.txt @@ -1 +1 @@ -275 \ No newline at end of file +294 \ No newline at end of file diff --git a/source/funkin/game/PlayState.hx b/source/funkin/game/PlayState.hx index 2571c64b..ad05a589 100644 --- a/source/funkin/game/PlayState.hx +++ b/source/funkin/game/PlayState.hx @@ -201,7 +201,6 @@ class PlayState extends MusicBeatState if (SONG.stage == null || SONG.stage.trim() == "") SONG.stage = "stage"; - // TODO: Custom Stage Loading add(new Stage(SONG.stage)); @@ -209,7 +208,9 @@ class PlayState extends MusicBeatState // case "": // ADD YOUR HARDCODED SCRIPTS HERE! default: - var content = Paths.getFolderContent('charts/${SONG.song.toLowerCase()}/', false, true, !fromMods); + trace('charts/${SONG.song}/'); + var content = Paths.getFolderContent('charts/${SONG.song}/', false, true, false); + trace(content); for(file in content) { var ext = Path.extension(file).toLowerCase(); @@ -1349,57 +1350,63 @@ class PlayState extends MusicBeatState camZooming = true; if (note.mustPress) { // TODO: See TODO above - scripts.event("onPlayerHit", new NoteHitEvent(note, note.mustPress ? boyfriend : dad, note.mustPress, note.noteType)); - if (!note.isSustainNote) - { - combo++; - popUpScore(note.strumTime); - } - - if (note.noteData >= 0) - health += 0.023; - else - health += 0.004; - - // TODO: NOTE PRESSED HANDLER - switch (note.noteData) - { - case 0: - boyfriend.playAnim('singLEFT', true); - case 1: - boyfriend.playAnim('singDOWN', true); - case 2: - boyfriend.playAnim('singUP', true); - case 3: - boyfriend.playAnim('singRIGHT', true); - } - - playerStrums.forEach(function(str:Strum) { - if (str.ID == Math.abs(note.noteData % 4)) { - str.press(note.strumTime); + var event = scripts.event("onPlayerHit", new NoteHitEvent(note, boyfriend, true, note.noteType, note.strumID)); + if (!event.cancelled) { + if (!note.isSustainNote) + { + combo++; + popUpScore(note.strumTime); } - }); + + if (note.noteData >= 0) + health += 0.023; + else + health += 0.004; + + if (!event.animCancelled) { + switch (event.direction) + { + case 0: + boyfriend.playAnim('singLEFT', true); + case 1: + boyfriend.playAnim('singDOWN', true); + case 2: + boyfriend.playAnim('singUP', true); + case 3: + boyfriend.playAnim('singRIGHT', true); + } + } + + playerStrums.forEach(function(str:Strum) { + if (str.ID == Math.abs(note.noteData % 4)) { + str.press(note.strumTime); + } + }); + } } else { // TODO: See TODO above the todo above - scripts.call("onDadHit", [note]); - // TODO: NOTE PRESSED HANDLER FOR DAD - switch (note.noteData) - { - case 0: - dad.playAnim('singLEFT', true); - case 1: - dad.playAnim('singDOWN', true); - case 2: - dad.playAnim('singUP', true); - case 3: - dad.playAnim('singRIGHT', true); - } - - cpuStrums.forEach(function(str:Strum) { - if (str.ID == Math.abs(note.noteData % 4)) { - str.press(note.strumTime); + var event = scripts.event("onDadHit", new NoteHitEvent(note, dad, false, note.noteType, note.strumID)); + if (!event.cancelled) { + if (!event.animCancelled) { + switch (event.direction) + { + case 0: + dad.playAnim('singLEFT', true); + case 1: + dad.playAnim('singDOWN', true); + case 2: + dad.playAnim('singUP', true); + case 3: + dad.playAnim('singRIGHT', true); + } } - }); + + cpuStrums.forEach(function(str:Strum) { + if (str.ID == Math.abs(note.noteData % 4)) { + str.press(note.strumTime); + } + }); + } } note.wasGoodHit = true; diff --git a/source/funkin/mods/ModsAssetLibrary.hx b/source/funkin/mods/ModsAssetLibrary.hx index 5ef35807..4ddd0893 100644 --- a/source/funkin/mods/ModsAssetLibrary.hx +++ b/source/funkin/mods/ModsAssetLibrary.hx @@ -114,7 +114,7 @@ class ModsAssetLibrary extends AssetLibrary { if (!folder.endsWith("/")) folder = folder + "/"; if (!__parseAsset(folder)) return []; var path = getAssetPath(); - + trace(path); try { var result:Array = []; for(e in FileSystem.readDirectory(path)) diff --git a/source/funkin/scripting/HScript.hx b/source/funkin/scripting/HScript.hx index 347a8c8a..1c51861b 100644 --- a/source/funkin/scripting/HScript.hx +++ b/source/funkin/scripting/HScript.hx @@ -16,7 +16,7 @@ class HScript extends Script { var code:String = Assets.getText(path); var parser = new hscript.Parser(); parser.allowJSON = parser.allowMetadata = parser.allowTypes = true; - // interp.errorHandler = _errorHandler; + interp.errorHandler = _errorHandler; try { expr = parser.parseString(code, fileName); } catch(e) { diff --git a/source/funkin/scripting/events/CancellableEvent.hx b/source/funkin/scripting/events/CancellableEvent.hx index a7816797..0bedf327 100644 --- a/source/funkin/scripting/events/CancellableEvent.hx +++ b/source/funkin/scripting/events/CancellableEvent.hx @@ -5,7 +5,7 @@ import funkin.scripting.ScriptPack; @:allow(ScriptPack) class CancellableEvent { @:dox(hide) public var cancelled:Bool = false; - @:dox(hide) private var __continueCalls:Bool = false; + @:dox(hide) private var __continueCalls:Bool = true; /** * Additional data if used in scripts @@ -14,19 +14,21 @@ class CancellableEvent { /** * Prevents default action from occuring. + * @param c Whenever the scripts following this one should be called or not. (Defaults to `true`) */ - public function cancel() { + public function preventDefault(c:Bool = true) { cancelled = true; + __continueCalls = c; } + @:dox(hide) + public function cancel(c:Bool = true) {preventDefault(c);} + /** * Creates a new cancellable event. * This allows scripts to call `cancel()` to cancel the event. - * @param continueCalls Whenever the `ScriptPack` should continue calling functions from other scripts after a script cancelled the event. */ - public function new(continueCalls:Bool) { - __continueCalls = continueCalls; - } + public function new() {} public function toString():String { var rep = '[CancellableEvent ${cancelled ? "(Cancelled)" : ""} - ]'; diff --git a/source/funkin/scripting/events/NoteHitEvent.hx b/source/funkin/scripting/events/NoteHitEvent.hx index a524e882..7dce8da7 100644 --- a/source/funkin/scripting/events/NoteHitEvent.hx +++ b/source/funkin/scripting/events/NoteHitEvent.hx @@ -4,17 +4,38 @@ import funkin.game.Note; import funkin.game.Character; class NoteHitEvent extends CancellableEvent { + @:dox(hide) public var animCancelled:Bool = false; + public var note:Note; public var character:Character; public var player:Bool; public var noteType:String; + public var direction:Int; - public function new(note:Note, char:Character, player:Bool, ?noteType:String) { - super(true); + /** + * Creates a new NoteHitEvent with the following values: + * @param note + * @param character + * @param player + * @param noteType + */ + public function new(note:Note, character:Character, player:Bool, noteType:String, direction:Int) { + super(); this.note = note; - this.character = char; + this.character = character; this.player = player; this.noteType = noteType; + this.direction = direction; } + + /** + * Prevents the default sing animation from being played. + */ + public function preventAnim() { + animCancelled = true; + } + + @:dox(hide) + public function cancelAnim() {preventAnim();} } \ No newline at end of file diff --git a/source/funkin/system/CoolUtil.hx b/source/funkin/system/CoolUtil.hx index 8764c9a7..55e2ad51 100644 --- a/source/funkin/system/CoolUtil.hx +++ b/source/funkin/system/CoolUtil.hx @@ -46,7 +46,7 @@ class CoolUtil if (Math.abs(h1-h2) > 180) h1 += 360; - if (Math.abs(h1 - h2) > 90 || s2 < 0.125 || s1 < 0.125) { + if (Math.abs(h1 - h2) > 180 || (s2 < 0.125 || s1 < 0.125)) { // classic r,g,b lerp var r1 = color1.redFloat; var g1 = color1.greenFloat; diff --git a/source/funkin/system/Paths.hx b/source/funkin/system/Paths.hx index 73d0ad28..3a08dcef 100644 --- a/source/funkin/system/Paths.hx +++ b/source/funkin/system/Paths.hx @@ -41,6 +41,7 @@ class Paths inline static function getLibraryPathForce(file:String, library:String) { + if (library.startsWith("mods")) library = library.toLowerCase(); return '$library:assets/$library/$file'; } @@ -148,7 +149,7 @@ class Paths return FlxAtlasFrames.fromSpriteSheetPacker(image(key, library), file('images/$key.txt', library)); } - inline static public function getFolderContent(key:String, includeSource:Bool = true, addPath:Bool = false, scanSource:Bool = false):Array { + static public function getFolderContent(key:String, includeSource:Bool = true, addPath:Bool = false, scanSource:Bool = false):Array { // designed to work both on windows and web if (!key.endsWith("/")) key = key + "/"; @@ -160,11 +161,13 @@ class Paths var libThing = new LimeLibrarySymbol(folderPath); var library = libThing.library; + trace(library); if (library is openfl.utils.AssetLibrary) { var lib = cast(libThing.library, openfl.utils.AssetLibrary); @:privateAccess if (lib.__proxy != null) library = lib.__proxy; } + trace(library); var content:Array = []; #if sys @@ -175,14 +178,15 @@ class Paths if (addPath) for(i in 0...content.length) content[i] = '$folderPath${content[i]}'; - } else #end - if (library is lime.utils.AssetLibrary) { - var lib = cast(library, lime.utils.AssetLibrary); + } else #end { @:privateAccess - for(k=>e in lib.paths) { - if (k.startsWith(libThing.symbolName)) { + for(k=>e in library.paths) { + if (k.toLowerCase().startsWith(libThing.symbolName.toLowerCase())) { if (addPath) { - content.push('${libThing.libraryName}:$k'); + if (libThing.libraryName != "") + content.push('${libThing.libraryName}:$k'); + else + content.push(k); } else { var barebonesFileName = k.substr(libThing.symbolName.length); if (!barebonesFileName.contains("/"))