diff --git a/source/game/Character.hx b/source/game/Character.hx index 555f31605e..d34c35ed2b 100644 --- a/source/game/Character.hx +++ b/source/game/Character.hx @@ -57,6 +57,13 @@ class Character extends FlxSprite { public var singAnimPrefix:String = 'sing'; + public var playFullAnim:Bool = false; + public var preventDanceForAnim:Bool = false; + + + public var lastHitStrumTime:Float = 0; + public var justHitStrumTime:Float = -5000; + public function new(x:Float, y:Float, ?character:String = "bf", ?isPlayer:Bool = false, ?isDeathCharacter:Bool = false) { super(x, y); @@ -325,6 +332,20 @@ class Character extends FlxSprite { override function update(elapsed:Float) { if (!debugMode && curCharacter != '' && animation.curAnim != null) { + if(animation.curAnim.finished && animation.getByName(animation.curAnim.name + '-loop') != null) + { + playAnim(animation.curAnim.name + '-loop'); + } + else if (playFullAnim && animation.curAnim.finished) + { + playFullAnim = false; + dance(); + } + else if (preventDanceForAnim && animation.curAnim.finished) + { + preventDanceForAnim = false; + dance(); + } if (!isPlayer) { if (animation.curAnim.name.startsWith('sing')) holdTimer += elapsed * (FlxG.state == PlayState.instance ? PlayState.songMultiplier : 1); @@ -355,7 +376,7 @@ class Character extends FlxSprite { */ public function dance(?altAnim:String = '') { if (shouldDance) { - if (!debugMode && curCharacter != '' && animation.curAnim != null) { + if (!debugMode && curCharacter != '' && animation.curAnim != null && !playFullAnim && !preventDanceForAnim) { var alt = ""; if ((!dancesLeftAndRight && animation.getByName("idle" + altAnim) != null) @@ -390,6 +411,8 @@ class Character extends FlxSprite { public function playAnim(AnimName:String, Force:Bool = false, Reversed:Bool = false, Frame:Int = 0):Void { if (!animation.exists(AnimName)) return; + + preventDanceForAnim = false; //reset it animation.play(AnimName, Force, Reversed, Frame); diff --git a/source/game/Note.hx b/source/game/Note.hx index 5f4806fdcb..c1108d8674 100644 --- a/source/game/Note.hx +++ b/source/game/Note.hx @@ -62,283 +62,149 @@ class Note extends FlxSprite { public function new(strumTime:Float, noteData:Int, ?prevNote:Note, ?sustainNote:Bool = false, ?character:Int = 0, ?arrowType:String = "default", ?song:SwagSong, ?characters:Array, ?mustPress:Bool = false, ?inEditor:Bool = false) { super(); + reloadNotes(strumTime,noteData,prevNote,sustainNote,character,arrowType,song,characters,mustPress,inEditor); + } - if (prevNote == null) - prevNote = this; - - this.prevNote = prevNote; - this.inEditor = inEditor; - this.character = character; - this.strumTime = strumTime; - this.arrow_Type = arrowType; - this.characters = characters; - this.mustPress = mustPress; - - isSustainNote = sustainNote; - - if (song == null) - song = PlayState.SONG; - - var localKeyCount = mustPress ? song.playerKeyCount : song.keyCount; - - this.noteData = noteData; - - x += 100; - // MAKE SURE ITS DEFINITELY OFF SCREEN? - y = -2000; - - if (PlayState.instance.types.contains(arrow_Type)) - frames = Paths.getSparrowAtlas('ui skins/' + song.ui_Skin + "/arrows/" + arrow_Type, 'shared'); - else - frames = Paths.getSparrowAtlas("ui skins/default/arrows/" + arrow_Type, 'shared'); - - animation.addByPrefix("default", NoteVariables.Other_Note_Anim_Stuff[localKeyCount - 1][noteData] + "0", 24); - animation.addByPrefix("hold", NoteVariables.Other_Note_Anim_Stuff[localKeyCount - 1][noteData] + " hold0", 24); - animation.addByPrefix("holdend", NoteVariables.Other_Note_Anim_Stuff[localKeyCount - 1][noteData] + " hold end0", 24); - animation.addByPrefix("glow", NoteVariables.Other_Note_Anim_Stuff[localKeyCount - 1][noteData] + " glow0", 24); - - var lmaoStuff = Std.parseFloat(PlayState.instance.ui_settings[0]) * (Std.parseFloat(PlayState.instance.ui_settings[2]) - - (Std.parseFloat(PlayState.instance.mania_size[localKeyCount - 1]))); - - if (isSustainNote) - scale.set(lmaoStuff, - Std.parseFloat(PlayState.instance.ui_settings[0]) * (Std.parseFloat(PlayState.instance.ui_settings[2]) - - (Std.parseFloat(PlayState.instance.mania_size[3])))); - else - scale.set(lmaoStuff, lmaoStuff); - - updateHitbox(); - - antialiasing = PlayState.instance.ui_settings[3] == "true"; - - x += swagWidth * noteData; - animation.play("default"); + public function reloadNotes(strumTime:Float, noteData:Int, ?prevNote:Note, ?sustainNote:Bool = false, ?character:Int = 0, ?arrowType:String = "default", + ?song:SwagSong, ?characters:Array, ?mustPress:Bool = false, ?inEditor:Bool = false) { - if (!PlayState.instance.arrow_Configs.exists(arrow_Type)) { + if (prevNote == null) + prevNote = this; + + this.prevNote = prevNote; + this.inEditor = inEditor; + this.character = character; + this.strumTime = strumTime; + this.arrow_Type = arrowType; + this.characters = characters; + this.mustPress = mustPress; + + isSustainNote = sustainNote; + + if (song == null) + song = PlayState.SONG; + + var localKeyCount = mustPress ? song.playerKeyCount : song.keyCount; + + this.noteData = noteData; + + x += 100; + // MAKE SURE ITS DEFINITELY OFF SCREEN? + y = -2000; + if (PlayState.instance.types.contains(arrow_Type)) - PlayState.instance.arrow_Configs.set(arrow_Type, CoolUtil.coolTextFile(Paths.txt("ui skins/" + song.ui_Skin + "/" + arrow_Type))); + frames = Paths.getSparrowAtlas('ui skins/' + song.ui_Skin + "/arrows/" + arrow_Type, 'shared'); else - 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; - - shouldHit = PlayState.instance.type_Configs.get(arrow_Type)[0] == "true"; - hitDamage = Std.parseFloat(PlayState.instance.type_Configs.get(arrow_Type)[1]); - missDamage = Std.parseFloat(PlayState.instance.type_Configs.get(arrow_Type)[2]); - - if (PlayState.instance.type_Configs.get(arrow_Type)[4] != null) - playMissOnMiss = PlayState.instance.type_Configs.get(arrow_Type)[4] == "true"; - else { - if (shouldHit) - playMissOnMiss = true; + frames = Paths.getSparrowAtlas("ui skins/default/arrows/" + arrow_Type, 'shared'); + + animation.addByPrefix("default", NoteVariables.Other_Note_Anim_Stuff[localKeyCount - 1][noteData] + "0", 24); + animation.addByPrefix("hold", NoteVariables.Other_Note_Anim_Stuff[localKeyCount - 1][noteData] + " hold0", 24); + animation.addByPrefix("holdend", NoteVariables.Other_Note_Anim_Stuff[localKeyCount - 1][noteData] + " hold end0", 24); + animation.addByPrefix("glow", NoteVariables.Other_Note_Anim_Stuff[localKeyCount - 1][noteData] + " glow0", 24); + + var lmaoStuff = Std.parseFloat(PlayState.instance.ui_settings[0]) * (Std.parseFloat(PlayState.instance.ui_settings[2]) + - (Std.parseFloat(PlayState.instance.mania_size[localKeyCount - 1]))); + + if (isSustainNote) + scale.set(lmaoStuff, + Std.parseFloat(PlayState.instance.ui_settings[0]) * (Std.parseFloat(PlayState.instance.ui_settings[2]) + - (Std.parseFloat(PlayState.instance.mania_size[3])))); else - playMissOnMiss = false; - } - - if (PlayState.instance.type_Configs.get(arrow_Type)[3] != null) - heldMissDamage = Std.parseFloat(PlayState.instance.type_Configs.get(arrow_Type)[3]); - - if (Options.getData("downscroll") && sustainNote) - flipY = true; - - if (isSustainNote && prevNote != null) { - alpha = 0.6; - - if (song.ui_Skin != 'pixel') - x += width / 2; - - animation.play("holdend"); + scale.set(lmaoStuff, lmaoStuff); + updateHitbox(); - - if (song.ui_Skin != 'pixel') - x -= width / 2; - - if (song.ui_Skin == 'pixel') - x += 30; - - if (prevNote.isSustainNote) { - if (prevNote.animation != null) - prevNote.animation.play("hold"); - - var speed = song.speed; - - if (Options.getData("useCustomScrollSpeed")) - speed = Options.getData("customScrollSpeed") / PlayState.songMultiplier; - - prevNote.scale.y *= Conductor.stepCrochet / 100 * 1.5 * speed; - prevNote.updateHitbox(); + + antialiasing = PlayState.instance.ui_settings[3] == "true"; + + x += swagWidth * noteData; + animation.play("default"); + + if (!PlayState.instance.arrow_Configs.exists(arrow_Type)) { + if (PlayState.instance.types.contains(arrow_Type)) + PlayState.instance.arrow_Configs.set(arrow_Type, CoolUtil.coolTextFile(Paths.txt("ui skins/" + song.ui_Skin + "/" + arrow_Type))); + else + 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); } - - centerOffsets(); - centerOrigin(); - } - - - if (PlayState.instance.arrow_Configs.get(arrow_Type)[5] != null) { - if (PlayState.instance.arrow_Configs.get(arrow_Type)[5] == "true") - affectedbycolor = true; - } - - if (affectedbycolor) { - colorSwap = new ColorSwap(); - shader = colorSwap.shader; - - var charColors = (mustPress) ? PlayState.boyfriend : PlayState.dad; - var noteColor; - if (!Options.getData("customNoteColors")) - noteColor = charColors.noteColors[localKeyCount - 1][noteData]; - else - noteColor = NoteColors.getNoteColor(NoteVariables.Other_Note_Anim_Stuff[song.keyCount - 1][noteData]); - - if(noteColor != null){ - colorSwap.r = noteColor[0]; - colorSwap.g = noteColor[1]; - colorSwap.b = noteColor[2]; + + offset.y += Std.parseFloat(PlayState.instance.arrow_Configs.get(arrow_Type)[0]) * lmaoStuff; + + shouldHit = PlayState.instance.type_Configs.get(arrow_Type)[0] == "true"; + hitDamage = Std.parseFloat(PlayState.instance.type_Configs.get(arrow_Type)[1]); + missDamage = Std.parseFloat(PlayState.instance.type_Configs.get(arrow_Type)[2]); + + if (PlayState.instance.type_Configs.get(arrow_Type)[4] != null) + playMissOnMiss = PlayState.instance.type_Configs.get(arrow_Type)[4] == "true"; + else { + if (shouldHit) + playMissOnMiss = true; + else + playMissOnMiss = false; + } + + if (PlayState.instance.type_Configs.get(arrow_Type)[3] != null) + heldMissDamage = Std.parseFloat(PlayState.instance.type_Configs.get(arrow_Type)[3]); + + if (Options.getData("downscroll") && sustainNote) + flipY = true; + + if (isSustainNote && prevNote != null) { + alpha = 0.6; + + if (song.ui_Skin != 'pixel') + x += width / 2; + + animation.play("holdend"); + updateHitbox(); + + if (song.ui_Skin != 'pixel') + x -= width / 2; + + if (song.ui_Skin == 'pixel') + x += 30; + + if (prevNote.isSustainNote) { + if (prevNote.animation != null) + prevNote.animation.play("hold"); + + var speed = song.speed; + + if (Options.getData("useCustomScrollSpeed")) + speed = Options.getData("customScrollSpeed") / PlayState.songMultiplier; + + prevNote.scale.y *= Conductor.stepCrochet / 100 * 1.5 * speed; + prevNote.updateHitbox(); + } + + centerOffsets(); + centerOrigin(); + } + + + if (PlayState.instance.arrow_Configs.get(arrow_Type)[5] != null) { + if (PlayState.instance.arrow_Configs.get(arrow_Type)[5] == "true") + affectedbycolor = true; + } + + if (affectedbycolor) { + colorSwap = new ColorSwap(); + shader = colorSwap.shader; + + var charColors = (mustPress) ? PlayState.boyfriend : PlayState.dad; + var noteColor; + if (!Options.getData("customNoteColors")) + noteColor = charColors.noteColors[localKeyCount - 1][noteData]; + else + noteColor = NoteColors.getNoteColor(NoteVariables.Other_Note_Anim_Stuff[song.keyCount - 1][noteData]); + + if(noteColor != null){ + colorSwap.r = noteColor[0]; + colorSwap.g = noteColor[1]; + colorSwap.b = noteColor[2]; + } } - } - } - - public function reloadNotes(strumTime:Float, noteData:Int, ?prevNote:Note, ?sustainNote:Bool = false, ?character:Int = 0, ?arrowType:String = "default", - ?song:SwagSong, ?characters:Array, ?mustPress:Bool = false, ?inEditor:Bool = false) { - - if (prevNote == null) - prevNote = this; - - this.prevNote = prevNote; - this.inEditor = inEditor; - this.character = character; - this.strumTime = strumTime; - this.arrow_Type = arrowType; - this.characters = characters; - this.mustPress = mustPress; - - isSustainNote = sustainNote; - - if (song == null) - song = PlayState.SONG; - - var localKeyCount = mustPress ? song.playerKeyCount : song.keyCount; - - this.noteData = noteData; - - x += 100; - // MAKE SURE ITS DEFINITELY OFF SCREEN? - y = -2000; - - if (PlayState.instance.types.contains(arrow_Type)) - frames = Paths.getSparrowAtlas('ui skins/' + song.ui_Skin + "/arrows/" + arrow_Type, 'shared'); - else - frames = Paths.getSparrowAtlas("ui skins/default/arrows/" + arrow_Type, 'shared'); - - animation.addByPrefix("default", NoteVariables.Other_Note_Anim_Stuff[localKeyCount - 1][noteData] + "0", 24); - animation.addByPrefix("hold", NoteVariables.Other_Note_Anim_Stuff[localKeyCount - 1][noteData] + " hold0", 24); - animation.addByPrefix("holdend", NoteVariables.Other_Note_Anim_Stuff[localKeyCount - 1][noteData] + " hold end0", 24); - animation.addByPrefix("glow", NoteVariables.Other_Note_Anim_Stuff[localKeyCount - 1][noteData] + " glow0", 24); - - var lmaoStuff = Std.parseFloat(PlayState.instance.ui_settings[0]) * (Std.parseFloat(PlayState.instance.ui_settings[2]) - - (Std.parseFloat(PlayState.instance.mania_size[localKeyCount - 1]))); - - if (isSustainNote) - scale.set(lmaoStuff, - Std.parseFloat(PlayState.instance.ui_settings[0]) * (Std.parseFloat(PlayState.instance.ui_settings[2]) - - (Std.parseFloat(PlayState.instance.mania_size[3])))); - else - scale.set(lmaoStuff, lmaoStuff); - - updateHitbox(); - - antialiasing = PlayState.instance.ui_settings[3] == "true"; - - x += swagWidth * noteData; - animation.play("default"); - - if (!PlayState.instance.arrow_Configs.exists(arrow_Type)) { - if (PlayState.instance.types.contains(arrow_Type)) - PlayState.instance.arrow_Configs.set(arrow_Type, CoolUtil.coolTextFile(Paths.txt("ui skins/" + song.ui_Skin + "/" + arrow_Type))); - else - 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))); - } - - offset.y += Std.parseFloat(PlayState.instance.arrow_Configs.get(arrow_Type)[0]) * lmaoStuff; - - shouldHit = PlayState.instance.type_Configs.get(arrow_Type)[0] == "true"; - hitDamage = Std.parseFloat(PlayState.instance.type_Configs.get(arrow_Type)[1]); - missDamage = Std.parseFloat(PlayState.instance.type_Configs.get(arrow_Type)[2]); - - if (PlayState.instance.type_Configs.get(arrow_Type)[4] != null) - playMissOnMiss = PlayState.instance.type_Configs.get(arrow_Type)[4] == "true"; - else { - if (shouldHit) - playMissOnMiss = true; - else - playMissOnMiss = false; - } - - if (PlayState.instance.type_Configs.get(arrow_Type)[3] != null) - heldMissDamage = Std.parseFloat(PlayState.instance.type_Configs.get(arrow_Type)[3]); - - if (Options.getData("downscroll") && sustainNote) - flipY = true; - - if (isSustainNote && prevNote != null) { - alpha = 0.6; - - if (song.ui_Skin != 'pixel') - x += width / 2; - - animation.play("holdend"); - updateHitbox(); - - if (song.ui_Skin != 'pixel') - x -= width / 2; - - if (song.ui_Skin == 'pixel') - x += 30; - - if (prevNote.isSustainNote) { - if (prevNote.animation != null) - prevNote.animation.play("hold"); - - var speed = song.speed; - - if (Options.getData("useCustomScrollSpeed")) - speed = Options.getData("customScrollSpeed") / PlayState.songMultiplier; - - prevNote.scale.y *= Conductor.stepCrochet / 100 * 1.5 * speed; - prevNote.updateHitbox(); - } - - centerOffsets(); - centerOrigin(); - } - - - if (PlayState.instance.arrow_Configs.get(arrow_Type)[5] != null) { - if (PlayState.instance.arrow_Configs.get(arrow_Type)[5] == "true") - affectedbycolor = true; - } - - if (affectedbycolor) { - colorSwap = new ColorSwap(); - shader = colorSwap.shader; - - var charColors = (mustPress) ? PlayState.boyfriend : PlayState.dad; - var noteColor; - if (!Options.getData("customNoteColors")) - noteColor = charColors.noteColors[localKeyCount - 1][noteData]; - else - noteColor = NoteColors.getNoteColor(NoteVariables.Other_Note_Anim_Stuff[song.keyCount - 1][noteData]); - - colorSwap.r = noteColor[0]; - colorSwap.g = noteColor[1]; - colorSwap.b = noteColor[2]; - } } override function update(elapsed:Float) { diff --git a/source/modding/ModchartUtilities.hx b/source/modding/ModchartUtilities.hx index 0b4676f44e..14e8565738 100644 --- a/source/modding/ModchartUtilities.hx +++ b/source/modding/ModchartUtilities.hx @@ -326,6 +326,10 @@ class ModchartUtilities { // callbacks + setLuaFunction("trace", function(str:Dynamic = "") { + trace(str); + }); + setLuaFunction("flashCamera", function(camera:String = "", color:String = "#FFFFFF", time:Float = 1, force:Bool = false) { if (Options.getData("flashingLights")) cameraFromString(camera).flash(FlxColor.fromString(color), time, null, force); @@ -881,27 +885,49 @@ class ModchartUtilities { }); setLuaFunction("getActorLayer", function(id:String) { - var actor = getActorByName(id); + if(getCharacterByName(id) != null) + { + var character = getCharacterByName(id); + if (character.otherCharacters != null && character.otherCharacters.length > 0) + { + return PlayState.instance.members.indexOf(character.otherCharacters[0]); + } + + } + var actor = getActorByName(id); - if (actor != null) - return PlayState.instance.members.indexOf(actor); - else - return -1; - }); + if(actor != null) + return PlayState.instance.members.indexOf(actor); + else + return -1; + }); setLuaFunction("setActorLayer", function(id:String, layer:Int) { - var actor = getActorByName(id); - - if (actor != null) { - if (trails.exists(id)) { - PlayState.instance.remove(trails.get(id)); - PlayState.instance.insert(layer - 1, trails.get(id)); - } - - PlayState.instance.remove(actor); - PlayState.instance.insert(layer, actor); - } - }); + if(getCharacterByName(id) != null) + { + var character = getCharacterByName(id); + if (character.otherCharacters != null && character.otherCharacters.length > 0) + { + PlayState.instance.remove(character.otherCharacters[0]); + PlayState.instance.insert(layer, character.otherCharacters[0]); + return; + } + + } + var actor = getActorByName(id); + + if(actor != null) + { + if(trails.exists(id)) + { + PlayState.instance.remove(trails.get(id)); + PlayState.instance.insert(layer - 1, trails.get(id)); + } + + PlayState.instance.remove(actor); + PlayState.instance.insert(layer, actor); + } + }); // health @@ -1209,24 +1235,53 @@ class ModchartUtilities { }); setLuaFunction("setActorX", function(x:Float, id:String) { - if (getActorByName(id) != null) - getActorByName(id).x = x; + if(getCharacterByName(id) != null) + { + var character = getCharacterByName(id); + if (character.otherCharacters != null && character.otherCharacters.length > 0) + { + character.otherCharacters[0].x = x; + return; + } + + } + if(getActorByName(id) != null) + getActorByName(id).x = x; }); setLuaFunction("setActorPos", function(x:Float, y:Float, id:String) { - var actor = getActorByName(id); - - if (actor != null) { - actor.x = x; - actor.y = y; - } + if(getCharacterByName(id) != null) + { + var character = getCharacterByName(id); + if (character.otherCharacters != null && character.otherCharacters.length > 0) + { + character.otherCharacters[0].x = x; + character.otherCharacters[0].y = y; + return; + } + + } + var actor = getActorByName(id); + + if(actor != null) + { + actor.x = x; + actor.y = y; + } }); setLuaFunction("setActorScroll", function(x:Float, y:Float, id:String) { + if(getCharacterByName(id) != null){ + var character = getCharacterByName(id); + if (character.otherCharacters != null && character.otherCharacters.length > 0){ + character.otherCharacters[0].scrollFactor.set(x,y); + return; + } + } var actor = getActorByName(id); - - if (getActorByName(id) != null) { - actor.scrollFactor.set(x, y); + + if(getActorByName(id) != null){ + actor.scrollFactor.set(x,y); } }); @@ -1330,11 +1385,22 @@ class ModchartUtilities { } }); - setLuaFunction("playActorAnimation", function(id:String, anim:String, force:Bool = false, reverse:Bool = false, frame:Int = 0) { - if (getActorByName(id) != null) { - getActorByName(id).animation.play(anim, force, reverse, frame); - } - }); + setLuaFunction("playActorAnimation", function(id:String,anim:String,force:Bool = false,reverse:Bool = false,frame:Int = 0) { + if(getCharacterByName(id) != null) + { + var character = getCharacterByName(id); + if (character.otherCharacters != null && character.otherCharacters.length > 0) + { + character.otherCharacters[0].animation.play(anim, force, reverse, frame); + return; + } + + } + if(getActorByName(id) != null) + { + getActorByName(id).animation.play(anim, force, reverse, frame); + } + }); setLuaFunction("playActorDance", function(id:String, ?altAnim:String = '') { if (getActorByName(id) != null) { @@ -1349,10 +1415,21 @@ class ModchartUtilities { }); setLuaFunction("setCharacterShouldDance", function(id:String, shouldDance:Bool = true) { - if (getActorByName(id) != null) { - getActorByName(id).shouldDance = shouldDance; - } - }); + if(getCharacterByName(id) != null) + { + var character = getCharacterByName(id); + if (character.otherCharacters != null && character.otherCharacters.length > 0) + { + character.otherCharacters[0].shouldDance = shouldDance; + return; + } + + } + if(getActorByName(id) != null) + { + getActorByName(id).shouldDance = shouldDance; + } + }); setLuaFunction("setCharacterPlayFullAnim", function(id:String, playFullAnim:Bool = true) { if(getCharacterByName(id) != null) { @@ -1428,10 +1505,20 @@ class ModchartUtilities { return 0; }); - setLuaFunction("setActorAlpha", function(alpha:Float, id:String) { - if (getActorByName(id) != null) - Reflect.setProperty(getActorByName(id), "alpha", alpha); - }); + setLuaFunction("setActorAlpha", function(alpha:Float,id:String) { + if(getCharacterByName(id) != null) + { + var character = getCharacterByName(id); + if (character.otherCharacters != null && character.otherCharacters.length > 0) + { + Reflect.setProperty(character.otherCharacters[0], "alpha", alpha); + return; + } + + } + if(getActorByName(id) != null) + Reflect.setProperty(getActorByName(id), "alpha", alpha); + }); setLuaFunction("setActorVisible", function(visible:Bool, id:String) { if (getActorByName(id) != null) @@ -1444,10 +1531,20 @@ class ModchartUtilities { } }); - setLuaFunction("setActorY", function(y:Float, id:String) { - if (getActorByName(id) != null) - Reflect.setProperty(getActorByName(id), "y", y); - }); + setLuaFunction("setActorY", function(y:Float,id:String) { + if(getCharacterByName(id) != null) + { + var character = getCharacterByName(id); + if (character.otherCharacters != null && character.otherCharacters.length > 0) + { + Reflect.setProperty(character.otherCharacters[0], "y", y); + return; + } + + } + if(getActorByName(id) != null) + Reflect.setProperty(getActorByName(id), "y", y); + }); setLuaFunction("setActorAccelerationY", function(y:Float, id:String) { if (getActorByName(id) != null) { @@ -1467,10 +1564,20 @@ class ModchartUtilities { } }); - setLuaFunction("setActorAngle", function(angle:Float, id:String) { - if (getActorByName(id) != null) - Reflect.setProperty(getActorByName(id), "angle", angle); - }); + setLuaFunction("setActorAngle", function(angle:Float,id:String) { + if(getCharacterByName(id) != null) + { + var character = getCharacterByName(id); + if (character.otherCharacters != null && character.otherCharacters.length > 0) + { + Reflect.setProperty(character.otherCharacters[0], "angle", angle); + return; + } + + } + if(getActorByName(id) != null) + Reflect.setProperty(getActorByName(id), "angle", angle); + }); setLuaFunction("setActorModAngle", function(angle:Float, id:String) { if (getActorByName(id) != null) @@ -1534,47 +1641,101 @@ class ModchartUtilities { return false; }); - setLuaFunction("getActorWidth", function(id:String) { - if (getActorByName(id) != null) - return getActorByName(id).width; - else - return 0; - }); + setLuaFunction("getActorWidth", function (id:String) { + if(getCharacterByName(id) != null) + { + var character = getCharacterByName(id); + if (character.otherCharacters != null && character.otherCharacters.length > 0) + { + return character.otherCharacters[0].width; + } + + } + if(getActorByName(id) != null) + return getActorByName(id).width; + else + return 0; + }); - setLuaFunction("getActorHeight", function(id:String) { - if (getActorByName(id) != null) - return getActorByName(id).height; - else - return 0; - }); + setLuaFunction("getActorHeight", function (id:String) { + if(getCharacterByName(id) != null) + { + var character = getCharacterByName(id); + if (character.otherCharacters != null && character.otherCharacters.length > 0) + { + return character.otherCharacters[0].height; + } + + } + if(getActorByName(id) != null) + return getActorByName(id).height; + else + return 0; + }); setLuaFunction("getActorAlpha", function(id:String) { - if (getActorByName(id) != null) - return getActorByName(id).alpha; - else - return 0.0; - }); + if(getCharacterByName(id) != null) + { + var character = getCharacterByName(id); + if (character.otherCharacters != null && character.otherCharacters.length > 0) + { + return character.otherCharacters[0].alpha; + } + + } + if(getActorByName(id) != null) + return getActorByName(id).alpha; + else + return 0.0; + }); setLuaFunction("getActorAngle", function(id:String) { - if (getActorByName(id) != null) - return getActorByName(id).angle; - else - return 0.0; - }); + if(getCharacterByName(id) != null) + { + var character = getCharacterByName(id); + if (character.otherCharacters != null && character.otherCharacters.length > 0) + { + return character.otherCharacters[0].angle; + } + + } + if(getActorByName(id) != null) + return getActorByName(id).angle; + else + return 0.0; + }); - setLuaFunction("getActorX", function(id:String) { - if (getActorByName(id) != null) - return getActorByName(id).x; - else - return 0.0; - }); + setLuaFunction("getActorX", function (id:String) { + if(getCharacterByName(id) != null) + { + var character = getCharacterByName(id); + if (character.otherCharacters != null && character.otherCharacters.length > 0) + { + return character.otherCharacters[0].x; + } + + } + if(getActorByName(id) != null) + return getActorByName(id).x; + else + return 0.0; + }); - setLuaFunction("getActorY", function(id:String) { - if (getActorByName(id) != null) - return getActorByName(id).y; - else - return 0.0; - }); + setLuaFunction("getActorY", function (id:String) { + if(getCharacterByName(id) != null) + { + var character = getCharacterByName(id); + if (character.otherCharacters != null && character.otherCharacters.length > 0) + { + return character.otherCharacters[0].y; + } + + } + if(getActorByName(id) != null) + return getActorByName(id).y; + else + return 0.0; + }); setLuaFunction("setActorReflection", function(id:String, r:Bool) { if(getCharacterByName(id) != null) @@ -2508,7 +2669,7 @@ class ModchartUtilities { } }); - setLuaFunction("createCustomShader", function(id:String, file:String, glslVersion:Int = 120 ){ + setLuaFunction("createCustomShader", function(id:String, file:String, ?glslVersion:Int = 120){ var funnyCustomShader:CustomShader = new CustomShader(Assets.getText(Paths.frag(file))); lua_Custom_Shaders.set(id, funnyCustomShader); }); @@ -2575,6 +2736,29 @@ class ModchartUtilities { } }); + //dumb vc functions + setLuaFunction("initShader", function(id:String, file:String, ?glslVersion:Int = 120){ + var funnyCustomShader:CustomShader = new CustomShader(Assets.getText(Paths.frag(file))); + lua_Custom_Shaders.set(id, funnyCustomShader); + }); + + setLuaFunction("setCameraShader", function(camera:String, id:String){ + var funnyCustomShader:CustomShader = lua_Custom_Shaders.get(id); + if(cameraFromString(camera).filters.length == 0){ + cameraFromString(camera).filters = [new ShaderFilter(funnyCustomShader)]; + } + else{ + cameraFromString(camera).filters.push(new ShaderFilter(funnyCustomShader)); + } + trace("shaders"); + trace(cameraFromString(camera).filters); + }); + + setLuaFunction("setShaderProperty", function(id:String, property:String, value:Dynamic) { + var funnyCustomShader:CustomShader = lua_Custom_Shaders.get(id); + funnyCustomShader.setFloat(property, value); + }); + setLuaFunction("updateRating", function() { PlayState.instance.updateRating(); }); diff --git a/source/modding/scripts/languages/HScript.hx b/source/modding/scripts/languages/HScript.hx index 9d05dc6cea..2edc3d61d2 100644 --- a/source/modding/scripts/languages/HScript.hx +++ b/source/modding/scripts/languages/HScript.hx @@ -152,6 +152,15 @@ class HScript #end #if THREE_D_ALLOWED interp.variables.set('Model', models.Model); + interp.variables.set('FlxView3D', flx3D.FlxView3D); + interp.variables.set('Mesh', away3d.entities.Mesh); + interp.variables.set('ControllerBase', away3d.controllers.ControllerBase); + interp.variables.set('FirstPersonController', away3d.controllers.FirstPersonController); + interp.variables.set('HoverController', away3d.controllers.HoverController); + interp.variables.set('ObjectContainer3D', away3d.containers.ObjectContainer3D); + + interp.variables.set('MotionBlurFilter3D', away3d.filters.MotionBlurFilter3D); + interp.variables.set('BloomFilter3D', away3d.filters.BloomFilter3D); #end //modchart tools stuff diff --git a/source/states/FreeplayState.hx b/source/states/FreeplayState.hx index 414513597e..8323389552 100644 --- a/source/states/FreeplayState.hx +++ b/source/states/FreeplayState.hx @@ -259,7 +259,7 @@ class FreeplayState extends MusicBeatState { new FlxTimer().start(1, function(_) songsReady = true); } - if (songs.length != 0){ + if (songs.length != 0 && curSelected <= 0){ selectedColor = songs[curSelected].color; bg.color = selectedColor; } diff --git a/source/states/PlayState.hx b/source/states/PlayState.hx index e6a4a1884f..4a9453e611 100644 --- a/source/states/PlayState.hx +++ b/source/states/PlayState.hx @@ -1681,6 +1681,10 @@ class PlayState extends MusicBeatState { event_lua.setupTheShitCuzPullRequestsSuck(); } } + + for (i in globalLuaScripts) { + i.setupTheShitCuzPullRequestsSuck(); + } for (i in 0...strumLineNotes.length) { var member = strumLineNotes.members[i];