Skip to content

Commit

Permalink
ghost tapping, yes 0 antimash, i checked
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesisfeline committed Jun 25, 2024
1 parent fae8a0d commit 250d673
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 39 deletions.
2 changes: 1 addition & 1 deletion source/Postbuild.hx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Postbuild

var buildTime:Float = roundToTwoDecimals(end - start);

trace('Build took: ${buildTime} seconds');
haxe.Log.trace('Build took: ${buildTime} seconds', null);
}
}

Expand Down
2 changes: 1 addition & 1 deletion source/Prebuild.hx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Prebuild
static function main():Void
{
saveBuildTime();
trace('Building...');
haxe.Log.trace('Building...', null);
}

static function saveBuildTime():Void
Expand Down
20 changes: 20 additions & 0 deletions source/funkin/Preferences.hx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,26 @@ class Preferences
return value;
}

/**
* If true, the player will not receive the ghost miss penalty if there are no notes within the hit window.
* This is the thing people have been begging for forever lolol.
* @default `false`
*/
public static var ghostTapping(get, set):Bool;

static function get_ghostTapping():Bool
{
return Save?.instance?.options?.ghostTapping ?? false;
}

static function set_ghostTapping(value:Bool):Bool
{
var save:Save = Save.instance;
save.options.ghostTapping = value;
save.flush();
return value;
}

/**
* If disabled, flashing lights in the main menu and other areas will be less intense.
* @default `true`
Expand Down
39 changes: 11 additions & 28 deletions source/funkin/play/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2421,62 +2421,45 @@ class PlayState extends MusicBeatSubState
for (note in notesInRange)
notesByDirection[note.direction].push(note);

while (inputPressQueue.length > 0)
while (inputPressQueue.length != 0)
{
var input:PreciseInputEvent = inputPressQueue.shift();

playerStrumline.pressKey(input.noteDirection);

var notesInDirection:Array<NoteSprite> = notesByDirection[input.noteDirection];

if (!Constants.GHOST_TAPPING && notesInDirection.length == 0)
if ((!Preferences.ghostTapping || (Preferences.ghostTapping && (holdNotesInRange.length + notesInRange.length != 0)))
&& notesInDirection.length == 0)
{
// Pressed a wrong key with no notes nearby.
// Pressed a wrong key with no notes nearby or pressed a wrong key with no notes nearby AND with notes in a different direction available.
// Perform a ghost miss (anti-spam).
ghostNoteMiss(input.noteDirection, notesInRange.length > 0);

// Play the strumline animation.
playerStrumline.playPress(input.noteDirection);
trace('PENALTY Score: ${songScore}');
}
else if (Constants.GHOST_TAPPING && (!playerStrumline.mayGhostTap()) && notesInDirection.length == 0)
{
// Pressed a wrong key with notes visible on-screen.
// Perform a ghost miss (anti-spam).
ghostNoteMiss(input.noteDirection, notesInRange.length > 0);

// Play the strumline animation.
playerStrumline.playPress(input.noteDirection);
trace('PENALTY Score: ${songScore}');
}
else if (notesInDirection.length == 0)
{
// Press a key with no penalty.

// Play the strumline animation.
playerStrumline.playPress(input.noteDirection);
trace('NO PENALTY Score: ${songScore}');
}
else
else if (notesInDirection.length != 0)
{
// Choose the first note, deprioritizing low priority notes.
var targetNote:Null<NoteSprite> = notesInDirection.find((note) -> !note.lowPriority);
if (targetNote == null) targetNote = notesInDirection[0];
if (targetNote == null) continue;

// Judge and hit the note.
trace('Hit note! ${targetNote.noteData}');
goodNoteHit(targetNote, input);
trace('Score: ${songScore}');

notesInDirection.remove(targetNote);

// Play the strumline animation.
playerStrumline.playConfirm(input.noteDirection);
}
else
{
// Play the strumline animation.
playerStrumline.playPress(input.noteDirection);
}
}

while (inputReleaseQueue.length > 0)
while (inputReleaseQueue.length != 0)
{
var input:PreciseInputEvent = inputReleaseQueue.shift();

Expand Down
8 changes: 8 additions & 0 deletions source/funkin/save/Save.hx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class Save
framerate: 60,
naughtyness: true,
downscroll: false,
ghostTapping: false,
flashingLights: true,
zoomCamera: true,
debugDisplay: false,
Expand Down Expand Up @@ -1074,6 +1075,13 @@ typedef SaveDataOptions =
*/
var downscroll:Bool;

/**
* If true, the player will not receive the ghost miss penalty if there are no notes within the hit window.
* This is the thing people have been begging for forever lolol.
* @default `false`
*/
var ghostTapping:Bool;

/**
* If disabled, flashing lights in the main menu and other areas will be less intense.
* @default `true`
Expand Down
3 changes: 3 additions & 0 deletions source/funkin/ui/options/PreferencesMenu.hx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ class PreferencesMenu extends Page
Preferences.framerate = Std.int(value);
}, Preferences.framerate, 12, 480, 1, 0);
#end
createPrefItemCheckbox('Ghost Tapping', 'Enable to disable ghost misses', function(value:Bool):Void {
Preferences.ghostTapping = value;
}, Preferences.ghostTapping);
createPrefItemCheckbox('Naughtyness', 'Toggle displaying raunchy content', function(value:Bool):Void {
Preferences.naughtyness = value;
}, Preferences.naughtyness);
Expand Down
2 changes: 1 addition & 1 deletion source/funkin/ui/options/items/CheckboxPreferenceItem.hx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class CheckboxPreferenceItem extends FlxSprite
animation.addByPrefix('static', 'Check Box unselected', 24, false);
animation.addByPrefix('checked', 'Check Box selecting animation', 24, false);

setGraphicSize(Std.int(width * 0.7));
setGraphicSize(width * 0.7);
updateHitbox();

this.currentValue = defaultValue;
Expand Down
9 changes: 8 additions & 1 deletion source/funkin/util/Constants.hx
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,14 @@ class Constants
* If true, the player will not receive the ghost miss penalty if there are no notes within the hit window.
* This is the thing people have been begging for forever lolol.
*/
public static final GHOST_TAPPING:Bool = false;
@:deprecated("Deprecated! Use Preferences.ghostTapping instead!")
public static var GHOST_TAPPING(get, set):Bool;

@:noCompletion inline static function get_GHOST_TAPPING():Bool
return Preferences.ghostTapping;

@:noCompletion inline static function set_GHOST_TAPPING(value:Bool):Bool
return Preferences.ghostTapping = value;

/**
* The maximum number of previous file paths for the Chart Editor to remember.
Expand Down
20 changes: 13 additions & 7 deletions source/funkin/util/MathUtil.hx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class MathUtil
*
* @return The interpolated value.
*/
@:deprecated('Use smoothLerp instead')
public static function coolLerp(base:Float, target:Float, ratio:Float):Float
// @:deprecated('Use smoothLerp instead')
public static inline function coolLerp(base:Float, target:Float, ratio:Float):Float
{
return base + cameraLerp(ratio) * (target - base);
}
Expand All @@ -34,8 +34,8 @@ class MathUtil
*
* @return The interpolated value.
*/
@:deprecated('Use smoothLerp instead')
public static function cameraLerp(lerp:Float):Float
// @:deprecated('Use smoothLerp instead')
public static inline function cameraLerp(lerp:Float):Float
{
return lerp * (FlxG.elapsed / (1 / 60));
}
Expand All @@ -47,7 +47,7 @@ class MathUtil
* @param target The array or group used in the wrapping procedure.
* @return The wrapped value.
*/
public static function curSelectionWrap(curSelection, increment, target):Int
public static inline function curSelectionWrap(curSelection, increment, target):Int
{
return FlxMath.wrap(curSelection + increment, 0, target.length - 1);
}
Expand All @@ -58,7 +58,7 @@ class MathUtil
* @param value The value to get the logarithm of.
* @return `log_base(value)`
*/
public static function logBase(base:Float, value:Float):Float
public static inline function logBase(base:Float, value:Float):Float
{
return Math.log(value) / Math.log(base);
}
Expand Down Expand Up @@ -108,7 +108,7 @@ class MathUtil
* @param x value
* @return `2^x`
*/
public static function exp2(x:Float):Float
inline public static function exp2(x:Float):Float
{
return Math.pow(2, x);
}
Expand Down Expand Up @@ -153,4 +153,10 @@ class MathUtil

return result;
}

inline public static function boundInt(value:Int, ?min:Int, ?max:Int):Int
{
final lowerBound = (min != null && value < min) ? min : value;
return (max != null && lowerBound > max) ? max : lowerBound;
}
}

0 comments on commit 250d673

Please sign in to comment.