Skip to content

Commit

Permalink
voi croncle
Browse files Browse the repository at this point in the history
  • Loading branch information
Vortex2Oblivion committed Nov 12, 2023
1 parent 67d1ec0 commit d7afa20
Show file tree
Hide file tree
Showing 4 changed files with 199 additions and 7 deletions.
2 changes: 2 additions & 0 deletions source/game/Character.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions source/game/Note.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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<Note> = [];
public var missesSustains:Bool = false;

Expand Down Expand Up @@ -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;
Expand Down
137 changes: 136 additions & 1 deletion source/modding/ModchartUtilities.hx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package modding;

import flixel.math.FlxMath;
import openfl.filters.BitmapFilter;
import openfl.display.ShaderParameter;
import shaders.custom.CustomShader;
Expand Down Expand Up @@ -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<String, Dynamic>;

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);

Expand Down Expand Up @@ -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;
});
Expand Down Expand Up @@ -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;
});
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down
63 changes: 57 additions & 6 deletions source/states/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -586,13 +586,21 @@ class PlayState extends MusicBeatState {
// unused for now ;)
// public var scripts:Array<HScript> = [];
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;

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -1391,6 +1414,7 @@ class PlayState extends MusicBeatState {
public var scripts:Array<HScript> = [];

var script:HScript;
var noteScript:HScript;
var globalScript:HScript;
var localScript:HScript;
#if linc_luajit
Expand Down Expand Up @@ -1795,6 +1819,8 @@ class PlayState extends MusicBeatState {
#end
executeALuaState("startSong", []);
allScriptCall("startSong", []);
executeALuaState("songStart", []);
allScriptCall("songStart", []);

resyncVocals();
}
Expand Down Expand Up @@ -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]);
}
Expand All @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit d7afa20

Please sign in to comment.