Skip to content

Commit 4a99e7e

Browse files
HEIHUAaRaltyro
andauthored
Input Improvements & Fixes (#837)
* Input * Health * optimize * Update StrumLine.hx * Update StrumLine.hx * Delete directly? * Update StrumLine.hx * optimize * Update StrumLine.hx * Options.sustainsAsOneNote * languages * Update Options.xml * Update PlayState.hx * Flags * Automatically set SUSTAINS_AS_ONE_NOTE --------- Co-authored-by: Ralty <78720179+Raltyro@users.noreply.github.com>
1 parent 8bab844 commit 4a99e7e

File tree

3 files changed

+39
-25
lines changed

3 files changed

+39
-25
lines changed

source/funkin/backend/system/Flags.hx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ class Flags {
136136
public static var DEFAULT_MODCHART_HOLD_SUBDIVISIONS:Int = 4;
137137
#end
138138

139+
public static var SUSTAINS_AS_ONE_NOTE:Null<Bool> = null;
140+
139141
@:also(funkin.game.Character.FALLBACK_DEAD_CHARACTER)
140142
public static var DEFAULT_GAMEOVER_CHARACTER:String = "bf-dead";
141143

@@ -305,8 +307,9 @@ class Flags {
305307
private static function loadPost() {
306308
if (MOD_API_VERSION == null) MOD_API_VERSION = CURRENT_API_VERSION;
307309
if (WINDOW_TITLE_USE_MOD_NAME == null) WINDOW_TITLE_USE_MOD_NAME = !overridenFlags.exists('TITLE') && overridenFlags.exists('MOD_NAME');
308-
if (USE_LEGACY_TIMING == null) USE_LEGACY_TIMING = MOD_API_VERSION <= 1;
309-
if (USE_LEGACY_ZOOM_FACTOR == null) USE_LEGACY_ZOOM_FACTOR = MOD_API_VERSION <= 1;
310+
if (USE_LEGACY_TIMING == null) USE_LEGACY_TIMING = MOD_API_VERSION < 2;
311+
if (USE_LEGACY_ZOOM_FACTOR == null) USE_LEGACY_ZOOM_FACTOR = MOD_API_VERSION < 2;
312+
if (SUSTAINS_AS_ONE_NOTE == null) SUSTAINS_AS_ONE_NOTE = MOD_API_VERSION >= 2;
310313
}
311314

312315
public static function loadFromDatas(datas:Array<String>):Map<String, String> {
@@ -381,4 +384,4 @@ class Flags {
381384
}
382385
loadPost();
383386
}
384-
}
387+
}

source/funkin/game/PlayState.hx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1837,7 +1837,14 @@ class PlayState extends MusicBeatState
18371837
var directionID:Null<Int> = note == null ? direction : note.strumID;
18381838
if (playerID == null || directionID == null || playerID == -1) return;
18391839

1840-
var event:NoteMissEvent = gameAndCharsEvent("onPlayerMiss", EventManager.get(NoteMissEvent).recycle(note, -10, 1, muteVocalsOnMiss, note != null ? -0.0475 : -0.04, Paths.sound(FlxG.random.getObject(Flags.DEFAULT_MISS_SOUNDS)), FlxG.random.float(0.1, 0.2), note == null, combo > 5, "sad", true, true, "miss", strumLines.members[playerID].characters, playerID, note != null ? note.noteType : null, directionID, 0));
1840+
if (Flags.SUSTAINS_AS_ONE_NOTE) {
1841+
if (note != null ? (note.isSustainNote && note.prevNote != null && note.prevNote.isSustainNote && !note.prevNote.wasGoodHit) : false) {
1842+
strumLine.deleteNote(note);
1843+
return;
1844+
}
1845+
}
1846+
1847+
var event:NoteMissEvent = gameAndCharsEvent("onPlayerMiss", EventManager.get(NoteMissEvent).recycle(note, -10, 1, muteVocalsOnMiss, note != null ? ((note.isSustainNote && Flags.SUSTAINS_AS_ONE_NOTE) ? -0.1425 : -0.0475) : -0.04, Paths.sound(FlxG.random.getObject(Flags.DEFAULT_MISS_SOUNDS)), FlxG.random.float(0.1, 0.2), note == null, combo > 5, "sad", true, true, "miss", strumLines.members[playerID].characters, playerID, note != null ? note.noteType : null, directionID, 0));
18411848
strumLine.onMiss.dispatch(event);
18421849
if (event.cancelled) {
18431850
gameAndCharsEvent("onPostPlayerMiss", event);

source/funkin/game/StrumLine.hx

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -258,14 +258,19 @@ class StrumLine extends FlxTypedGroup<Strum> {
258258
}
259259
}
260260

261-
var __funcsToExec:Array<Note->Void> = [];
262261
var __pressed:Array<Bool> = [];
263262
var __justPressed:Array<Bool> = [];
264263
var __justReleased:Array<Bool> = [];
265264
var __notePerStrum:Array<Note> = [];
266265

267266
function __inputProcessPressed(note:Note) {
268-
if (__pressed[note.strumID] && note.isSustainNote && note.sustainParent != null && note.sustainParent.wasGoodHit && note.strumTime < __updateNote_songPos && !note.wasGoodHit) {
267+
if (__pressed[note.strumID] && note.isSustainNote && note.strumTime < __updateNote_songPos && !note.wasGoodHit) {
268+
note.tripTimer = 1;
269+
PlayState.instance.goodNoteHit(this, note);
270+
}
271+
}
272+
function __inputProcessPressedOne(note:Note) {
273+
if (__pressed[note.strumID] && note.isSustainNote && note.sustainParent != null && note.prevNote != null && note.prevNote.wasGoodHit && note.strumTime < __updateNote_songPos && !note.wasGoodHit) {
269274
note.tripTimer = 1;
270275
PlayState.instance.goodNoteHit(this, note);
271276
}
@@ -297,12 +302,11 @@ class StrumLine extends FlxTypedGroup<Strum> {
297302

298303
if (cpu) return;
299304

300-
__funcsToExec.clear();
301305
__pressed.resize(members.length);
302306
__justPressed.resize(members.length);
303307
__justReleased.resize(members.length);
304308

305-
for(i in 0...members.length) {
309+
for (i in 0...members.length) {
306310
__pressed[i] = members[i].__getPressed(this);
307311
__justPressed[i] = members[i].__getJustPressed(this);
308312
__justReleased[i] = members[i].__getJustReleased(this);
@@ -316,34 +320,34 @@ class StrumLine extends FlxTypedGroup<Strum> {
316320
__justPressed = CoolUtil.getDefault(event.justPressed, []);
317321
__justReleased = CoolUtil.getDefault(event.justReleased, []);
318322

319-
__notePerStrum = cast new haxe.ds.Vector(members.length);//[for(_ in 0...members.length) null];
323+
__notePerStrum = cast new haxe.ds.Vector(members.length); // [for(_ in 0...members.length) null];
324+
325+
if (__justPressed.contains(true)) {
326+
notes.forEachAlive(__inputProcessJustPressed);
320327

328+
if (!ghostTapping) for (k => pr in __justPressed) if (pr && __notePerStrum[k] == null)
329+
PlayState.instance.noteMiss(this, null, k, ID); // FUCK YOU
330+
}
321331

322332
if (__pressed.contains(true)) {
323-
for(c in characters)
333+
for (e in __notePerStrum)
334+
if (e != null)
335+
PlayState.instance.goodNoteHit(this, e);
336+
337+
for (c in characters)
324338
if (c.lastAnimContext != DANCE)
325339
c.__lockAnimThisFrame = true;
326340

327-
__funcsToExec.push(__inputProcessPressed);
328-
}
329-
if (__justPressed.contains(true))
330-
__funcsToExec.push(__inputProcessJustPressed);
331-
332-
if (__funcsToExec.length > 0) {
333-
notes.forEachAlive(function(note:Note) {
334-
for(e in __funcsToExec) if (e != null) e(note);
335-
});
341+
if (Flags.SUSTAINS_AS_ONE_NOTE)
342+
notes.forEachAlive(__inputProcessPressedOne);
343+
else
344+
notes.forEachAlive(__inputProcessPressed);
336345
}
337346

338-
if (!ghostTapping) for(k=>pr in __justPressed) if (pr && __notePerStrum[k] == null) {
339-
// FUCK YOU
340-
PlayState.instance.noteMiss(this, null, k, ID);
341-
}
342-
for(e in __notePerStrum) if (e != null) PlayState.instance.goodNoteHit(this, e);
343-
344347
forEach(function(str:Strum) {
345348
str.updatePlayerInput(str.__getPressed(this), str.__getJustPressed(this), str.__getJustReleased(this));
346349
});
350+
347351
PlayState.instance.gameAndCharsCall("onPostInputUpdate");
348352
}
349353

0 commit comments

Comments
 (0)