From 6525680510b01bf705b6b04e86ee5c58b2615268 Mon Sep 17 00:00:00 2001 From: Vortex2Oblivion <73261680+Vortex2Oblivion@users.noreply.github.com> Date: Thu, 30 Nov 2023 17:10:39 -0500 Subject: [PATCH] vc is weird --- assets/preload/data/eventList.txt | 2 + source/game/Character.hx | 10 +++ source/modding/ModchartUtilities.hx | 16 ++++ source/states/PlayState.hx | 134 +++++++++++++++++++++++----- 4 files changed, 141 insertions(+), 21 deletions(-) diff --git a/assets/preload/data/eventList.txt b/assets/preload/data/eventList.txt index 5ced2e59e0..04bad15b51 100644 --- a/assets/preload/data/eventList.txt +++ b/assets/preload/data/eventList.txt @@ -4,6 +4,8 @@ Change Scroll Speed~Scroll Speed~Time To Change In Seconds (default is 0) Change Character Alpha~Character (BF, Dad, GF)~Alpha to change to. (default is 0.5) Change Keycount~Player 1 Keycount~Player 2 Keycount Change Ui Skin~Ui Skin~Nothing +Change Camera Speed~Speed~Nothing +Change Camera Zoom Speed~Speed~Nothing Play Character Animation~Character (Dad, BF, GF)~Animation to play Hey!~BF = Only BF, GF = Only GF, anything else = Both~Nothing Character Will Idle~Character (BF, Dad, GF)~"true" or "false" diff --git a/source/game/Character.hx b/source/game/Character.hx index d34c35ed2b..d4b18fd743 100644 --- a/source/game/Character.hx +++ b/source/game/Character.hx @@ -427,4 +427,14 @@ class Character extends FlxSprite { public function addOffset(name:String, x:Float = 0, y:Float = 0) { animOffsets.set(name, [(isPlayer && offsetsFlipWhenPlayer) || (!isPlayer && offsetsFlipWhenEnemy) ? -x : x, y]); } + public var followMainCharacter:Bool = false; + public function getMainCharacter():Character + { + if (otherCharacters != null && otherCharacters.length > 0) + { + if (followMainCharacter) + return otherCharacters[0]; + } + return this; + } } diff --git a/source/modding/ModchartUtilities.hx b/source/modding/ModchartUtilities.hx index d4bcb95678..6b56d4f816 100644 --- a/source/modding/ModchartUtilities.hx +++ b/source/modding/ModchartUtilities.hx @@ -117,6 +117,13 @@ class ModchartUtilities { return lua_Cameras.get("game"); } + public static function killShaders(){ + for (cam in lua_Cameras){ + cam.shaders = []; + cam.shaderNames = []; + } + } + public function die() { PlayState.songMultiplier = oldMultiplier; @@ -2744,6 +2751,15 @@ class ModchartUtilities { } }); + setLuaFunction("tweenShaderProperty", function(id:String, property:String, value:Float, duration:Float, ?ease:String = "linear", ?startDelay:Float = 0.0, ?onComplete:Dynamic) { + var shader:CustomShader = lua_Custom_Shaders.get(id); + if (shader != null) { + shader.tween(property, value, duration, easeFromString(ease), startDelay, onComplete); + } else { + trace('Shader named $shader doesn\'t exist!', ERROR); + } + }); + setLuaFunction("updateRating", function() { PlayState.instance.updateRating(); }); diff --git a/source/states/PlayState.hx b/source/states/PlayState.hx index b8991aa938..fc088c794c 100644 --- a/source/states/PlayState.hx +++ b/source/states/PlayState.hx @@ -187,6 +187,12 @@ class PlayState extends MusicBeatState { **/ public var camFollow:FlxObject; + + /** + * Should the camera be centered? + */ + public var centerCamera:Bool = false; + /** Copy of `camFollow` used for transitioning between songs smoother. **/ @@ -197,6 +203,16 @@ class PlayState extends MusicBeatState { **/ public var camZooming:Bool = false; + /** + Speed of camera. + **/ + public var cameraSpeed:Float = 1; + + /** + Speed of camera zooming. + **/ + public var cameraZoomSpeed:Float = 1; + /** Shortner for `SONG.song`. **/ @@ -2251,10 +2267,10 @@ class PlayState extends MusicBeatState { tweenManager.update(elapsed); - FlxG.camera.followLerp = elapsed * 2.4; + FlxG.camera.followLerp = (elapsed * 2.4) *cameraSpeed; var icon_Zoom_Lerp = elapsed * 9; - var camera_Zoom_Lerp = elapsed * 3; + var camera_Zoom_Lerp = (elapsed * 3) * cameraZoomSpeed; iconP1.scale.set(FlxMath.lerp(iconP1.scale.x, iconP1.startSize, icon_Zoom_Lerp * songMultiplier), FlxMath.lerp(iconP1.scale.y, iconP1.startSize, icon_Zoom_Lerp * songMultiplier)); @@ -2386,12 +2402,15 @@ class PlayState extends MusicBeatState { // offsetY = luaModchart.getVar("followYOffset", "float"); setLuaVar("mustHit", PlayState.SONG.notes[Std.int(curStep / Conductor.stepsPerSection)].mustHitSection); + + if(!PlayState.SONG.notes[Std.int(curStep / Conductor.stepsPerSection)].mustHitSection) + { + var midPos = dad.getMainCharacter().getMidpoint(); - if (!PlayState.SONG.notes[Std.int(curStep / Conductor.stepsPerSection)].mustHitSection) { - var midPos = dad.getMidpoint(); - - if (Options.getData("cameraTracksDirections") && dad.animation.curAnim != null) { - switch (dad.animation.curAnim.name.toLowerCase()) { + if(utilities.Options.getData("cameraTracksDirections") && dad.animation.curAnim != null) + { + switch(dad.animation.curAnim.name.toLowerCase()) + { case "singleft": midPos.x -= 50; case "singright": @@ -2406,10 +2425,12 @@ class PlayState extends MusicBeatState { midPos.x += stage.p2_Cam_Offset.x; midPos.y += stage.p2_Cam_Offset.y; - if (camFollow.x != midPos.x + 150 + dad.cameraOffset[0] || camFollow.y != midPos.y + -100 + dad.cameraOffset[1]) { - camFollow.setPosition(midPos.x + 150 + dad.cameraOffset[0], midPos.y - 100 + dad.cameraOffset[1]); - - switch (dad.curCharacter) { + //if(camFollow.x != midPos.x + 150 + dad.cameraOffset[0] || camFollow.y != midPos.y + - 100 + dad.cameraOffset[1]) + //{ + camFollow.setPosition(midPos.x + 150 + dad.getMainCharacter().cameraOffset[0], midPos.y - 100 + dad.getMainCharacter().cameraOffset[1]); + + switch (dad.curCharacter) + { case 'mom': camFollow.y = midPos.y; case 'senpai': @@ -2424,14 +2445,17 @@ class PlayState extends MusicBeatState { executeALuaState("turnChange", ['dad']); allScriptCall("playerTwoTurn"); allScriptCall("turnChange", ['dad']); - } + //} } - if (PlayState.SONG.notes[Std.int(curStep / Conductor.stepsPerSection)].mustHitSection) { - var midPos = boyfriend.getMidpoint(); + if(PlayState.SONG.notes[Std.int(curStep / Conductor.stepsPerSection)].mustHitSection) + { + var midPos = boyfriend.getMainCharacter().getMidpoint(); - if (Options.getData("cameraTracksDirections") && boyfriend.animation.curAnim != null) { - switch (boyfriend.animation.curAnim.name) { + if(Options.getData("cameraTracksDirections") && boyfriend.animation.curAnim != null) + { + switch(boyfriend.animation.curAnim.name) + { case "singLEFT": midPos.x -= 50; case "singRIGHT": @@ -2446,11 +2470,12 @@ class PlayState extends MusicBeatState { midPos.x += stage.p1_Cam_Offset.x; midPos.y += stage.p1_Cam_Offset.y; - if (camFollow.x != midPos.x - 100 + boyfriend.cameraOffset[0] - || camFollow.y != midPos.y - 100 + boyfriend.cameraOffset[1]) { - camFollow.setPosition(midPos.x - 100 + boyfriend.cameraOffset[0], midPos.y - 100 + boyfriend.cameraOffset[1]); - - switch (curStage) { + //if(camFollow.x != midPos.x - 100 + boyfriend.cameraOffset[0] || camFollow.y != midPos.y - 100 + boyfriend.cameraOffset[1]) + //{ + camFollow.setPosition(midPos.x - 100 + boyfriend.getMainCharacter().cameraOffset[0], midPos.y - 100 + boyfriend.getMainCharacter().cameraOffset[1]); + + switch (curStage) + { case 'limo': camFollow.x = midPos.x - 300; case 'mall': @@ -2461,6 +2486,55 @@ class PlayState extends MusicBeatState { executeALuaState("turnChange", ['bf']); allScriptCall("playerOneTurn"); allScriptCall("turnChange", ['bf']); + //} + } + + if (centerCamera) + { + var midPos = boyfriend.getMainCharacter().getMidpoint(); + midPos.x += stage.p1_Cam_Offset.x; + midPos.y += stage.p1_Cam_Offset.y; + camFollow.setPosition(midPos.x - 100 + boyfriend.getMainCharacter().cameraOffset[0], midPos.y - 100 + boyfriend.getMainCharacter().cameraOffset[1]); + midPos = dad.getMainCharacter().getMidpoint(); + midPos.x += stage.p2_Cam_Offset.x; + midPos.y += stage.p2_Cam_Offset.y; + camFollow.x += midPos.x + 150 + dad.getMainCharacter().cameraOffset[0]; + camFollow.y += midPos.y - 100 + dad.getMainCharacter().cameraOffset[1]; + camFollow.x *= 0.5; + camFollow.y *= 0.5; + if(PlayState.SONG.notes[Std.int(curStep / Conductor.stepsPerSection)].mustHitSection) + { + if(Options.getData("cameraTracksDirections") && boyfriend.getMainCharacter().animation.curAnim != null) + { + switch(boyfriend.getMainCharacter().animation.curAnim.name) + { + case "singLEFT": + camFollow.x -= 50; + case "singRIGHT": + camFollow.x += 50; + case "singUP": + camFollow.y -= 50; + case "singDOWN": + camFollow.y += 50; + } + } + } + else + { + if(Options.getData("cameraTracksDirections") && dad.getMainCharacter().animation.curAnim != null) + { + switch(dad.getMainCharacter().animation.curAnim.name.toLowerCase()) + { + case "singleft": + camFollow.x -= 50; + case "singright": + camFollow.x += 50; + case "singup": + camFollow.y -= 50; + case "singdown": + camFollow.y += 50; + } + } } } } @@ -2997,6 +3071,14 @@ class PlayState extends MusicBeatState { executeALuaState("updatePost", [elapsed]); } + override function destroy() + { + #if linc_luajit + ModchartUtilities.killShaders(); + #end + super.destroy(); + } + function endSong():Void { canPause = false; FlxG.sound.music.volume = 0; @@ -4791,6 +4873,16 @@ class PlayState extends MusicBeatState { else speed = funnySpeed; } + case "change camera speed": + var speed:Float = Std.parseFloat(event[2]); + if(Math.isNaN(speed)) + speed = 1; + cameraSpeed = speed; + case "change camera zoom speed": + var speed:Float = Std.parseFloat(event[2]); + if(Math.isNaN(speed)) + speed = 1; + cameraZoomSpeed = speed; case "character will idle?": var char = getCharFromEvent(event[2]);