Skip to content

Commit

Permalink
more vc stupid
Browse files Browse the repository at this point in the history
  • Loading branch information
Vortex2Oblivion committed Nov 24, 2023
1 parent 0e72590 commit eb92d86
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 1 deletion.
42 changes: 42 additions & 0 deletions source/game/Note.hx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package game;

import flixel.util.FlxColor;
import utilities.Options;
import shaders.NoteColors;
import shaders.ColorSwap;
Expand All @@ -21,6 +22,8 @@ class Note extends FlxSprite {
public var tooLate:Bool = false;
public var wasGoodHit:Bool = false;
public var prevNote:Note;
public var prevNoteStrumtime:Float = 0;
public var prevNoteIsSustainNote:Bool = false;

public var singAnimPrefix:String = "sing"; //hopefully should make things easier
public var singAnimSuffix:String = ""; //for alt anims lol
Expand All @@ -35,6 +38,11 @@ class Note extends FlxSprite {

public static var swagWidth:Float = 160 * 0.7;

public var sustainScaleY:Float = 1;

public var xOffset:Float = 0;
public var yOffset:Float = 0;

public var rawNoteData:Int = 0;

public var character:Int = 0;
Expand All @@ -59,6 +67,34 @@ class Note extends FlxSprite {
public var z:Float = 0;
#end

/**
* @see https://discord.com/channels/929608653173051392/1034954605253107844/1163134784277590056
* @see https://step-mania.fandom.com/wiki/Notes
*/
public static var quantColors:Array<FlxColor> = [
0xff230f,
0x134fff,
0x8a07e0,
0x47fa16,
0xd600d3,
0xf67904,
0x00c8ac,
0x26a829,
0xbbbbbb,
0xA7C7E7,
0x808000,
];

public static var ratingColors:Array<FlxColor> = [

];

/**
* @see https://discord.com/channels/929608653173051392/1034954605253107844/1163134784277590056
* @see https://step-mania.fandom.com/wiki/Notes
*/
public static var beats:Array<Int> = [4, 8, 12, 16, 24, 32, 48, 64, 96, 128, 192];

public function new(strumTime:Float, noteData:Int, ?prevNote:Note, ?sustainNote:Bool = false, ?character:Int = 0, ?arrowType:String = "default",
?song:SwagSong, ?characters:Array<Int>, ?mustPress:Bool = false, ?inEditor:Bool = false) {
super();
Expand Down Expand Up @@ -152,6 +188,9 @@ class Note extends FlxSprite {

if (isSustainNote && prevNote != null) {
alpha = 0.6;

prevNoteStrumtime = prevNote.strumTime;
prevNoteIsSustainNote = prevNote.isSustainNote;

if (song.ui_Skin != 'pixel')
x += width / 2;
Expand All @@ -176,10 +215,13 @@ class Note extends FlxSprite {

prevNote.scale.y *= Conductor.stepCrochet / 100 * 1.5 * speed;
prevNote.updateHitbox();
prevNote.sustainScaleY = prevNote.scale.y;
}

centerOffsets();
centerOrigin();

sustainScaleY = scale.y;
}


Expand Down
94 changes: 93 additions & 1 deletion source/modding/ModchartUtilities.hx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package modding;

import flixel.input.gamepad.FlxGamepad;
import flixel.input.FlxInput.FlxInputState;
import game.Note;
import flixel.math.FlxMath;
import openfl.filters.BitmapFilter;
import openfl.display.ShaderParameter;
Expand Down Expand Up @@ -210,6 +213,7 @@ class ModchartUtilities {
setVar("playerKeyCount", PlayState.SONG.playerKeyCount);
setVar("scrollspeed", PlayState.SONG.speed);
setVar("fpsCap", Options.getData("maxFPS"));
setVar("opponentPlay", PlayState.characterPlayingAs == 1);
setVar("bot", Options.getData("botplay"));
setVar("noDeath", Options.getData("noDeath"));
setVar("downscroll", Options.getData("downscroll") == true ? 1 : 0); // fuck you compatibility
Expand Down Expand Up @@ -397,6 +401,20 @@ class ModchartUtilities {
Reflect.setProperty(actor, "cameras", [cameraFromString(camera)]);
});

setLuaFunction("justPressedDodgeKey", function() {

var gamepad:FlxGamepad = FlxG.gamepads.lastActive;
if (gamepad != null)
{
if (gamepad.checkStatus(FlxGamepadInputID.fromString("SPACE"), FlxInputState.JUST_PRESSED))
{
return true;
}

}
return FlxG.keys.checkStatus(FlxKey.fromString("SPACE"), FlxInputState.JUST_PRESSED);
});

setLuaFunction("justPressed", function(key:String = "SPACE") {
return Reflect.getProperty(FlxG.keys.justPressed, key);
});
Expand Down Expand Up @@ -1181,6 +1199,10 @@ class ModchartUtilities {
return PlayState.instance.notes.members[id].scale.x;
});

setLuaFunction("getRenderedNoteScaleY", function(id:Int) {
return PlayState.instance.notes.members[id].scale.y;
});

setLuaFunction("setRenderedNotePos", function(x:Float, y:Float, id:Int) {
if (PlayState.instance.notes.members[id] == null)
throw('error! you cannot set a rendered notes position when it doesnt exist! ID: ' + id);
Expand All @@ -1198,9 +1220,50 @@ class ModchartUtilities {
PlayState.instance.notes.members[id].scale.set(scale, scale);
});

setLuaFunction("setRenderedNoteScaleX", function(scale:Float, id:Int) {
PlayState.instance.notes.members[id].scale.x = scale;
});
setLuaFunction("setRenderedNoteScaleY", function(scale:Float, id:Int) {
PlayState.instance.notes.members[id].scale.y = scale;
});

setLuaFunction("setRenderedNoteScaleXY", function(scaleX:Int, scaleY:Int, id:Int) {
PlayState.instance.notes.members[id].scale.set(scaleX, scaleY);
});
});

setLuaFunction("isRenderedNoteSustainEnd", function(id:Int) {
if (PlayState.instance.notes.members[id].animation.curAnim != null)
return PlayState.instance.notes.members[id].animation.curAnim.name.endsWith('end');
return false;
});

setLuaFunction("getRenderedNoteSustainScaleY", function(id:Int) {
return PlayState.instance.notes.members[id].sustainScaleY;
});

setLuaFunction("getRenderedNoteOffsetX", function(id:Int) {
var daNote:Note = PlayState.instance.notes.members[id];
if (daNote.mustPress)
{
var arrayVal = Std.string([daNote.noteData, daNote.arrow_Type, daNote.isSustainNote]);
if (PlayState.instance.prevPlayerXVals.exists(arrayVal))
return PlayState.instance.prevPlayerXVals.get(arrayVal) - daNote.xOffset;
}
else
{
var arrayVal = Std.string([daNote.noteData, daNote.arrow_Type, daNote.isSustainNote]);
if (PlayState.instance.prevEnemyXVals.exists(arrayVal))
return PlayState.instance.prevEnemyXVals.get(arrayVal) - daNote.xOffset;
}

return 0;
});

setLuaFunction("getRenderedNoteOffsetY", function(id:Int) {
var daNote:Note = PlayState.instance.notes.members[id];
return daNote.yOffset;
});


setLuaFunction("getRenderedNoteWidth", function(id:Int) {
return PlayState.instance.notes.members[id].width;
Expand All @@ -1210,6 +1273,10 @@ class ModchartUtilities {
return PlayState.instance.notes.members[id].height;
});

setLuaFunction("getRenderedNotePrevNoteStrumtime", function(id:Int) {
return PlayState.instance.notes.members[id].prevNoteStrumtime;
});

setLuaFunction("setRenderedNoteAngle", function(angle:Float, id:Int) {
PlayState.instance.notes.members[id].angle = angle;
});
Expand Down Expand Up @@ -2644,6 +2711,31 @@ class ModchartUtilities {
return id;
});

setLuaFunction("getStrumTimeFromStep", function(step:Float) {
var beat = step*0.25;
var totalTime:Float = 0;
var curBpm = Conductor.bpm;
if (PlayState.SONG != null)
curBpm = PlayState.SONG.bpm;
for (i in 0...Math.floor(beat))
{
if (Conductor.bpmChangeMap.length > 0)
{
for (j in 0...Conductor.bpmChangeMap.length)
{
if (totalTime >= Conductor.bpmChangeMap[j].songTime)
curBpm = Conductor.bpmChangeMap[j].bpm;
}
}
totalTime += (60/curBpm)*1000;
}

var leftOverBeat = beat - Math.floor(beat);
totalTime += (60/curBpm)*1000*leftOverBeat;

return totalTime;
});

// shader bullshit

setLuaFunction("setActor3DShader", function(id:String, ?speed:Float = 3, ?frequency:Float = 10, ?amplitude:Float = 0.25) {
Expand Down
1 change: 1 addition & 0 deletions source/states/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1398,6 +1398,7 @@ class PlayState extends MusicBeatState {
HScript.interp.variables.set('ModchartFile', modcharting.ModchartFile);
}
#end*/

super.create();

for (script_funny in scripts) {
Expand Down

0 comments on commit eb92d86

Please sign in to comment.