From d7afa204c9a5826c8eeddf438e9b3e93531b16ea Mon Sep 17 00:00:00 2001 From: Vortex2Oblivion <73261680+Vortex2Oblivion@users.noreply.github.com> Date: Sun, 12 Nov 2023 16:21:23 -0500 Subject: [PATCH] voi croncle --- source/game/Character.hx | 2 + source/game/Note.hx | 4 + source/modding/ModchartUtilities.hx | 137 +++++++++++++++++++++++++++- source/states/PlayState.hx | 63 +++++++++++-- 4 files changed, 199 insertions(+), 7 deletions(-) diff --git a/source/game/Character.hx b/source/game/Character.hx index 5d8824f3d0..555f31605e 100644 --- a/source/game/Character.hx +++ b/source/game/Character.hx @@ -55,6 +55,8 @@ class Character extends FlxSprite { public var script:HScript; + public var singAnimPrefix:String = 'sing'; + public function new(x:Float, y:Float, ?character:String = "bf", ?isPlayer:Bool = false, ?isDeathCharacter:Bool = false) { super(x, y); diff --git a/source/game/Note.hx b/source/game/Note.hx index b0c43005ea..5f4806fdcb 100644 --- a/source/game/Note.hx +++ b/source/game/Note.hx @@ -22,6 +22,9 @@ class Note extends FlxSprite { public var wasGoodHit:Bool = false; public var prevNote:Note; + public var singAnimPrefix:String = "sing"; //hopefully should make things easier + public var singAnimSuffix:String = ""; //for alt anims lol + public var sustains:Array = []; public var missesSustains:Bool = false; @@ -118,6 +121,7 @@ class Note extends FlxSprite { PlayState.instance.arrow_Configs.set(arrow_Type, CoolUtil.coolTextFile(Paths.txt("ui skins/default/" + arrow_Type))); PlayState.instance.type_Configs.set(arrow_Type, CoolUtil.coolTextFile(Paths.txt("arrow types/" + arrow_Type))); + PlayState.instance.setupNoteTypeScript(arrow_Type); } offset.y += Std.parseFloat(PlayState.instance.arrow_Configs.get(arrow_Type)[0]) * lmaoStuff; diff --git a/source/modding/ModchartUtilities.hx b/source/modding/ModchartUtilities.hx index fd096f0a59..bdd53e54b7 100644 --- a/source/modding/ModchartUtilities.hx +++ b/source/modding/ModchartUtilities.hx @@ -1,5 +1,6 @@ package modding; +import flixel.math.FlxMath; import openfl.filters.BitmapFilter; import openfl.display.ShaderParameter; import shaders.custom.CustomShader; @@ -344,6 +345,40 @@ class ModchartUtilities { PlayState.instance.processEvent([event_name, Conductor.songPosition, string_arg_1, string_arg_2]); }); + setLuaFunction("addCharacterToMap", function(m:String, character:String) { + var map:Map; + + switch(m.toLowerCase()) + { + case "dad" | "opponent" | "player2" | "1": + map = PlayState.instance.dadMap; + case "gf" | "girlfriend" | "player3" | "2": + map = PlayState.instance.gfMap; + default: + map = PlayState.instance.bfMap; + } + var funnyCharacter:Character; + + if(map == PlayState.instance.bfMap) + funnyCharacter = new Boyfriend(100, 100, character); + else + funnyCharacter = new Character(100, 100, character); + + funnyCharacter.alpha = 0.00001; + PlayState.instance.add(funnyCharacter); + + map.set(character, funnyCharacter); + + if(funnyCharacter.otherCharacters != null) + { + for(character in funnyCharacter.otherCharacters) + { + character.alpha = 0.00001; + PlayState.instance.add(character); + } + } + }); + setLuaFunction("setCamera", function(id:String, camera:String = "") { var actor:FlxSprite = getActorByName(id); @@ -1091,7 +1126,6 @@ class ModchartUtilities { return PlayState.instance.notes.members[id].noteData; }); - setLuaFunction("getRenderedNoteParentX", function(id:Int) { return PlayState.instance.notes.members[id].prevNote.x; }); @@ -1153,6 +1187,14 @@ class ModchartUtilities { PlayState.instance.notes.members[id].angle = angle; }); + setLuaFunction("setUnspawnedNoteSingAnimPrefix", function(id:Int, prefix:String) { + PlayState.instance.unspawnNotes[id].singAnimPrefix = prefix; + }); + + setLuaFunction("setUnspawnedNoteSingAnimPrefix", function(id:Int, prefix:String) { + PlayState.instance.unspawnNotes[id].singAnimPrefix = prefix; + }); + setLuaFunction("isSustain", function(id:Int) { return PlayState.instance.notes.members[id].isSustainNote; }); @@ -1310,6 +1352,56 @@ class ModchartUtilities { getActorByName(id).shouldDance = shouldDance; } }); + setLuaFunction("setCharacterPlayFullAnim", function(id:String, playFullAnim:Bool = true) { + if(getCharacterByName(id) != null) + { + var character = getCharacterByName(id); + if (character.otherCharacters != null && character.otherCharacters.length > 0) + { + character.otherCharacters[0].playFullAnim = playFullAnim; + return; + } + + } + if(getActorByName(id) != null) + { + getActorByName(id).playFullAnim = playFullAnim; + } + }); + + setLuaFunction("setCharacterSingPrefix", function(id:String, prefix:String) { + if(getCharacterByName(id) != null) + { + var character = getCharacterByName(id); + if (character.otherCharacters != null && character.otherCharacters.length > 0) + { + character.otherCharacters[0].singAnimPrefix = prefix; + return; + } + + } + if(getActorByName(id) != null) + { + getActorByName(id).singAnimPrefix = prefix; + } + }); + + setLuaFunction("setCharacterPreventDanceForAnim", function(id:String, preventDanceForAnim:Bool = true) { + if(getCharacterByName(id) != null) + { + var character = getCharacterByName(id); + if (character.otherCharacters != null && character.otherCharacters.length > 0) + { + character.otherCharacters[0].preventDanceForAnim = preventDanceForAnim; + return; + } + + } + if(getActorByName(id) != null) + { + getActorByName(id).preventDanceForAnim = preventDanceForAnim; + } + }); setLuaFunction("playCharacterDance", function(id:String, ?altAnim:String) { if (getActorByName(id) != null) { @@ -1404,6 +1496,18 @@ class ModchartUtilities { getActorByName(id).flipY = flip; }); + setLuaFunction("getActorFlipX", function(id:String) { + if(getActorByName(id) != null) + return getActorByName(id).flipX; + return false; + }); + + setLuaFunction("getActorFlipY", function(flip:Bool, id:String) { + if(getActorByName(id) != null) + return getActorByName(id).flipY; + return false; + }); + setLuaFunction("setActorTrailVisible", function(id:String, visibleVal:Bool) { var char = getCharacterByName(id); @@ -2096,6 +2200,37 @@ class ModchartUtilities { }); }); + //vc dumb + setLuaFunction("tweenFadeCubeInOut", function(id:String, toAlpha:Float, time:Float, onComplete:String = "") { + if(getActorByName(id) != null) + PlayState.instance.tweenManager.tween(getActorByName(id), {alpha: toAlpha}, time, {ease: FlxEase.cubeInOut, onComplete: function(flxTween:FlxTween) { if (onComplete != '' && onComplete != null) {executeState(onComplete,[id]);}}}); + }); + + setLuaFunction("tweenActorProperty", function(id:String, prop:String, value:Dynamic, time:Float, easeStr:String = "linear") { + var actor = getActorByName(id); + var ease = easeFromString(easeStr); + + if(actor != null && Reflect.getProperty(actor, prop) != null) + { + var startVal = Reflect.getProperty(actor, prop); + + PlayState.instance.tweenManager.num(startVal, value, time, {onUpdate: function(tween:FlxTween){ + var ting = FlxMath.lerp(startVal,value, ease(tween.percent)); + Reflect.setProperty(actor, prop, ting); + }, ease: ease, onComplete: function(tween:FlxTween) { + Reflect.setProperty(actor, prop, value); + }}); + } + }); + + setLuaFunction("setActorProperty", function(id:String, prop:String, value:Dynamic) { + var actor = getActorByName(id); + if(actor != null && Reflect.getProperty(actor, prop) != null) + { + Reflect.setProperty(actor, prop, value); + } + }); + setLuaFunction("tweenActorColor", function(id:String, r1:Int, g1:Int, b1:Int, r2:Int, g2:Int, b2:Int, time:Float, onComplete:String = "") { var actor = getActorByName(id); diff --git a/source/states/PlayState.hx b/source/states/PlayState.hx index 04e303aa15..044464136e 100644 --- a/source/states/PlayState.hx +++ b/source/states/PlayState.hx @@ -586,13 +586,21 @@ class PlayState extends MusicBeatState { // unused for now ;) // public var scripts:Array = []; public var ratingsGroup:FlxSpriteGroup = new FlxSpriteGroup(); + /** * Stage HScript */ public static var stage_script:HScript = null; + + /** + * Manages a dumb tween thing + */ + public var tweenManager:FlxTweenManager; override public function create() { + + tweenManager = new FlxTweenManager(); // set instance because duh instance = this; @@ -1000,12 +1008,6 @@ class PlayState extends MusicBeatState { if (boyfriend.script != null) scripts.push(boyfriend.script); - if (Assets.exists(Paths.hx("data/song data/" + SONG.song.toLowerCase() + "/script"))) { - script = new HScript(Paths.hx("data/song data/" + SONG.song.toLowerCase() + "/script")); - script.start(); - - scripts.push(script); - } //global scripts yay. @@ -1102,6 +1104,27 @@ class PlayState extends MusicBeatState { } } } + + if (sys.FileSystem.exists("mods/" + Options.getData("curMod") + "/data/scripts/local/")){ + var localScripts = sys.FileSystem.readDirectory("mods/" + Options.getData("curMod") + "/data/song data/" + curSong + "/"); + if (localScripts.length > 0){ + for (file in localScripts){ + if(file.endsWith('.hx')){ + localScript = new HScript("mods/" + Options.getData("curMod") + "/data/song data/" + curSong + "/" + file, true); + localScript.start(); + + scripts.push(localScript); + } + #if linc_luajit + if(file.endsWith('.lua')){ + globalLuaExists = true; + globalLuaScript = (new ModchartUtilities("mods/" + Options.getData("curMod") + "/data/song data/" + curSong + "/" + file)); + globalLuaScripts.push(globalLuaScript); + } + #end + } + } + } #end @@ -1391,6 +1414,7 @@ class PlayState extends MusicBeatState { public var scripts:Array = []; var script:HScript; + var noteScript:HScript; var globalScript:HScript; var localScript:HScript; #if linc_luajit @@ -1795,6 +1819,8 @@ class PlayState extends MusicBeatState { #end executeALuaState("startSong", []); allScriptCall("startSong", []); + executeALuaState("songStart", []); + allScriptCall("songStart", []); resyncVocals(); } @@ -2181,6 +2207,12 @@ class PlayState extends MusicBeatState { if (boyfriend.script != null) boyfriend.script.call("fixedUpdate", [fixedUpdateFPS]); + setLuaVar("songPos", Conductor.songPosition); + setLuaVar("bot", Options.getData("botplay")); + setLuaVar("hudZoom", camHUD.zoom); + setLuaVar("curBeat", curBeat); + setLuaVar("cameraZoom", FlxG.camera.zoom); + executeALuaState("fixedUpdate", [fixedUpdateFPS]); allScriptCall("fixedUpdate", [fixedUpdateFPS]); } @@ -2198,8 +2230,11 @@ class PlayState extends MusicBeatState { fixedUpdateTime = 0; } + super.update(elapsed); + tweenManager.update(elapsed); + FlxG.camera.followLerp = elapsed * 2.4; var icon_Zoom_Lerp = elapsed * 9; @@ -5023,6 +5058,22 @@ class PlayState extends MusicBeatState { events.sort((a, b) -> Std.int(a[1] - b[1])); } + public function setupNoteTypeScript(noteType:String) + { + #if linc_luajit + if(!event_luas.exists(noteType.toLowerCase()) && Assets.exists(Paths.lua("arrow types/" + noteType))) + { + event_luas.set(noteType.toLowerCase(), new ModchartUtilities(PolymodAssets.getPath(Paths.lua("arrow types/" + noteType)))); + generatedSomeDumbEventLuas = true; + } + #end + if (Assets.exists(Paths.hx("data/arrow types/" + noteType))) { + noteScript = new HScript(Paths.hx("data/arrow types/" + noteType)); + noteScript.start(); + + scripts.push(noteScript); + } + } } enum Execute_On {