modcharts!!

This commit is contained in:
Yoshman29
2022-10-09 23:21:25 +02:00
parent abee99f94c
commit 9009916ce6
9 changed files with 107 additions and 69 deletions
+4
View File
@@ -6,3 +6,7 @@ function beatHit(curBeat:Int) {
camZoomingInterval = 4;
}
}
function onPlayerHit(event:NoteHitEvent) {
event.direction = 3 - event.direction;
}
+1 -1
View File
@@ -1 +1 @@
275
294
+56 -49
View File
@@ -201,7 +201,6 @@ class PlayState extends MusicBeatState
if (SONG.stage == null || SONG.stage.trim() == "") SONG.stage = "stage";
// TODO: Custom Stage Loading
add(new Stage(SONG.stage));
@@ -209,7 +208,9 @@ class PlayState extends MusicBeatState
// case "":
// ADD YOUR HARDCODED SCRIPTS HERE!
default:
var content = Paths.getFolderContent('charts/${SONG.song.toLowerCase()}/', false, true, !fromMods);
trace('charts/${SONG.song}/');
var content = Paths.getFolderContent('charts/${SONG.song}/', false, true, false);
trace(content);
for(file in content) {
var ext = Path.extension(file).toLowerCase();
@@ -1349,57 +1350,63 @@ class PlayState extends MusicBeatState
camZooming = true;
if (note.mustPress) {
// TODO: See TODO above
scripts.event("onPlayerHit", new NoteHitEvent(note, note.mustPress ? boyfriend : dad, note.mustPress, note.noteType));
if (!note.isSustainNote)
{
combo++;
popUpScore(note.strumTime);
}
if (note.noteData >= 0)
health += 0.023;
else
health += 0.004;
// TODO: NOTE PRESSED HANDLER
switch (note.noteData)
{
case 0:
boyfriend.playAnim('singLEFT', true);
case 1:
boyfriend.playAnim('singDOWN', true);
case 2:
boyfriend.playAnim('singUP', true);
case 3:
boyfriend.playAnim('singRIGHT', true);
}
playerStrums.forEach(function(str:Strum) {
if (str.ID == Math.abs(note.noteData % 4)) {
str.press(note.strumTime);
var event = scripts.event("onPlayerHit", new NoteHitEvent(note, boyfriend, true, note.noteType, note.strumID));
if (!event.cancelled) {
if (!note.isSustainNote)
{
combo++;
popUpScore(note.strumTime);
}
});
if (note.noteData >= 0)
health += 0.023;
else
health += 0.004;
if (!event.animCancelled) {
switch (event.direction)
{
case 0:
boyfriend.playAnim('singLEFT', true);
case 1:
boyfriend.playAnim('singDOWN', true);
case 2:
boyfriend.playAnim('singUP', true);
case 3:
boyfriend.playAnim('singRIGHT', true);
}
}
playerStrums.forEach(function(str:Strum) {
if (str.ID == Math.abs(note.noteData % 4)) {
str.press(note.strumTime);
}
});
}
} else {
// TODO: See TODO above the todo above
scripts.call("onDadHit", [note]);
// TODO: NOTE PRESSED HANDLER FOR DAD
switch (note.noteData)
{
case 0:
dad.playAnim('singLEFT', true);
case 1:
dad.playAnim('singDOWN', true);
case 2:
dad.playAnim('singUP', true);
case 3:
dad.playAnim('singRIGHT', true);
}
cpuStrums.forEach(function(str:Strum) {
if (str.ID == Math.abs(note.noteData % 4)) {
str.press(note.strumTime);
var event = scripts.event("onDadHit", new NoteHitEvent(note, dad, false, note.noteType, note.strumID));
if (!event.cancelled) {
if (!event.animCancelled) {
switch (event.direction)
{
case 0:
dad.playAnim('singLEFT', true);
case 1:
dad.playAnim('singDOWN', true);
case 2:
dad.playAnim('singUP', true);
case 3:
dad.playAnim('singRIGHT', true);
}
}
});
cpuStrums.forEach(function(str:Strum) {
if (str.ID == Math.abs(note.noteData % 4)) {
str.press(note.strumTime);
}
});
}
}
note.wasGoodHit = true;
+1 -1
View File
@@ -114,7 +114,7 @@ class ModsAssetLibrary extends AssetLibrary {
if (!folder.endsWith("/")) folder = folder + "/";
if (!__parseAsset(folder)) return [];
var path = getAssetPath();
trace(path);
try {
var result:Array<String> = [];
for(e in FileSystem.readDirectory(path))
+1 -1
View File
@@ -16,7 +16,7 @@ class HScript extends Script {
var code:String = Assets.getText(path);
var parser = new hscript.Parser();
parser.allowJSON = parser.allowMetadata = parser.allowTypes = true;
// interp.errorHandler = _errorHandler;
interp.errorHandler = _errorHandler;
try {
expr = parser.parseString(code, fileName);
} catch(e) {
@@ -5,7 +5,7 @@ import funkin.scripting.ScriptPack;
@:allow(ScriptPack)
class CancellableEvent {
@:dox(hide) public var cancelled:Bool = false;
@:dox(hide) private var __continueCalls:Bool = false;
@:dox(hide) private var __continueCalls:Bool = true;
/**
* Additional data if used in scripts
@@ -14,19 +14,21 @@ class CancellableEvent {
/**
* Prevents default action from occuring.
* @param c Whenever the scripts following this one should be called or not. (Defaults to `true`)
*/
public function cancel() {
public function preventDefault(c:Bool = true) {
cancelled = true;
__continueCalls = c;
}
@:dox(hide)
public function cancel(c:Bool = true) {preventDefault(c);}
/**
* Creates a new cancellable event.
* This allows scripts to call `cancel()` to cancel the event.
* @param continueCalls Whenever the `ScriptPack` should continue calling functions from other scripts after a script cancelled the event.
*/
public function new(continueCalls:Bool) {
__continueCalls = continueCalls;
}
public function new() {}
public function toString():String {
var rep = '[CancellableEvent ${cancelled ? "(Cancelled)" : ""} - ]';
+24 -3
View File
@@ -4,17 +4,38 @@ import funkin.game.Note;
import funkin.game.Character;
class NoteHitEvent extends CancellableEvent {
@:dox(hide) public var animCancelled:Bool = false;
public var note:Note;
public var character:Character;
public var player:Bool;
public var noteType:String;
public var direction:Int;
public function new(note:Note, char:Character, player:Bool, ?noteType:String) {
super(true);
/**
* Creates a new NoteHitEvent with the following values:
* @param note
* @param character
* @param player
* @param noteType
*/
public function new(note:Note, character:Character, player:Bool, noteType:String, direction:Int) {
super();
this.note = note;
this.character = char;
this.character = character;
this.player = player;
this.noteType = noteType;
this.direction = direction;
}
/**
* Prevents the default sing animation from being played.
*/
public function preventAnim() {
animCancelled = true;
}
@:dox(hide)
public function cancelAnim() {preventAnim();}
}
+1 -1
View File
@@ -46,7 +46,7 @@ class CoolUtil
if (Math.abs(h1-h2) > 180) h1 += 360;
if (Math.abs(h1 - h2) > 90 || s2 < 0.125 || s1 < 0.125) {
if (Math.abs(h1 - h2) > 180 || (s2 < 0.125 || s1 < 0.125)) {
// classic r,g,b lerp
var r1 = color1.redFloat;
var g1 = color1.greenFloat;
+11 -7
View File
@@ -41,6 +41,7 @@ class Paths
inline static function getLibraryPathForce(file:String, library:String)
{
if (library.startsWith("mods")) library = library.toLowerCase();
return '$library:assets/$library/$file';
}
@@ -148,7 +149,7 @@ class Paths
return FlxAtlasFrames.fromSpriteSheetPacker(image(key, library), file('images/$key.txt', library));
}
inline static public function getFolderContent(key:String, includeSource:Bool = true, addPath:Bool = false, scanSource:Bool = false):Array<String> {
static public function getFolderContent(key:String, includeSource:Bool = true, addPath:Bool = false, scanSource:Bool = false):Array<String> {
// designed to work both on windows and web
if (!key.endsWith("/")) key = key + "/";
@@ -160,11 +161,13 @@ class Paths
var libThing = new LimeLibrarySymbol(folderPath);
var library = libThing.library;
trace(library);
if (library is openfl.utils.AssetLibrary) {
var lib = cast(libThing.library, openfl.utils.AssetLibrary);
@:privateAccess
if (lib.__proxy != null) library = lib.__proxy;
}
trace(library);
var content:Array<String> = [];
#if sys
@@ -175,14 +178,15 @@ class Paths
if (addPath)
for(i in 0...content.length)
content[i] = '$folderPath${content[i]}';
} else #end
if (library is lime.utils.AssetLibrary) {
var lib = cast(library, lime.utils.AssetLibrary);
} else #end {
@:privateAccess
for(k=>e in lib.paths) {
if (k.startsWith(libThing.symbolName)) {
for(k=>e in library.paths) {
if (k.toLowerCase().startsWith(libThing.symbolName.toLowerCase())) {
if (addPath) {
content.push('${libThing.libraryName}:$k');
if (libThing.libraryName != "")
content.push('${libThing.libraryName}:$k');
else
content.push(k);
} else {
var barebonesFileName = k.substr(libThing.symbolName.length);
if (!barebonesFileName.contains("/"))