Skip to content

Commit

Permalink
shit
Browse files Browse the repository at this point in the history
  • Loading branch information
Snirozu committed Nov 16, 2024
1 parent 6bf7386 commit cc0bb60
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 41 deletions.
4 changes: 3 additions & 1 deletion source/backend/ClientPrefs.hx
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class ClientPrefs {
'pause' => [ENTER, ESCAPE],
'reset' => [R],
'taunt' => [SPACE],
'sidebar' => [GRAVEACCENT],

'volume_mute' => [ZERO],
'volume_up' => [NUMPADPLUS, PLUS],
Expand All @@ -139,7 +140,8 @@ class ClientPrefs {
'back' => [B],
'pause' => [START],
'reset' => [BACK],
'taunt' => [A]
'taunt' => [A],
'sidebar' => []
];
public static var defaultKeys:Map<String, Array<FlxKey>> = null;
public static var defaultButtons:Map<String, Array<FlxGamepadInputID>> = null;
Expand Down
2 changes: 2 additions & 0 deletions source/backend/Controls.hx
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,13 @@ class Controls
public var PAUSE(get, never):Bool;
public var RESET(get, never):Bool;
public var TAUNT(get, never):Bool;
public var SIDEBAR(get, never):Bool;
private function get_ACCEPT() return justPressed('accept');
private function get_BACK() return justPressed('back');
private function get_PAUSE() return justPressed('pause');
private function get_RESET() return justPressed('reset');
private function get_TAUNT() return justPressed('taunt');
private function get_SIDEBAR() return justPressed('sidebar');

//Gamepad & Keyboard stuff
public var keyboardBinds:Map<String, Array<FlxKey>>;
Expand Down
2 changes: 1 addition & 1 deletion source/backend/InputFormatter.hx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class InputFormatter {
//case SLASH:
// return "/";
case GRAVEACCENT:
return "`";
return "Tilde";
case LBRACKET:
return "[";
//case BACKSLASH:
Expand Down
12 changes: 7 additions & 5 deletions source/online/FunkinPoints.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,21 @@ package online;

@:build(online.backend.Macros.getSetForwarder())
class FunkinPoints {
@:forwardField(FlxG.save.data.funkinPointsv3, 0)
@:forwardField(FlxG.save.data.funkinPointsv4, 0)
public static var funkinPoints(get, set):Float;

public static function calcFP(accuracy:Float, misses:Float, denseNotes:Float, notesHit:Float, maxCombo:Float):Float {
if (accuracy <= 0 || notesHit <= 0)
return 0;

// depends on player's hitted notes and the density of all notes
// hard songs will average somewhere between 3.0 (spookeez erect) and 13.0 (ballistic)
// so for a song with 3.0 density (ex. spookeez erect), for every ~65 hitted notes a player will gain 1 fp (without combo bonus)
var fp:Float = Math.max(1, 1 + denseNotes) * (notesHit / 200);
// depends on player's note streak (1000 combo doubles base fp)
fp *= 1 + maxCombo / 1000;
// depends on player's note accuracy (weighted by power of 4; 95% = x0.81, 90% = x0.65, 80% = x0.40)
fp *= Math.pow(accuracy, 5) / (1 + misses * 0.25);
// depends on player's note streak (2000 combo will double base fp)
fp *= 1 + maxCombo / 2000;
// depends on player's note accuracy (weighted by power of 3; 95% = x0.85, 90% = x0.72, 80% = x0.512)
fp *= Math.pow(accuracy, 3) / (1 + misses * 0.25);
return Math.ffloor(fp);
}

Expand Down
10 changes: 9 additions & 1 deletion source/online/gui/sidebar/SideUI.hx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class SideUI extends Sprite {
x = -width;

stage.addEventListener(KeyboardEvent.KEY_DOWN, (e:KeyboardEvent) -> {
if (e.keyCode == 192 && stage.focus == null) {
if (checkKey(e.keyCode, ClientPrefs.keyBinds.get('sidebar')) && stage.focus == null) {
if (FunkinNetwork.loggedIn) {
active = !active;
return;
Expand Down Expand Up @@ -104,6 +104,14 @@ class SideUI extends Sprite {
}
return active = show;
}

public static function checkKey(key:Int, keys:Array<Int>):Bool {
for (k in keys) {
if (key == k)
return true;
}
return false;
}
}

@:bitmap("assets/images/ui/cursor.png")
Expand Down
4 changes: 2 additions & 2 deletions source/online/replay/ReplayPlayer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ class ReplayPlayer extends FlxBasic {
}
else if (state.controls.UI_RIGHT) {
state.playbackRate += elapsed * 0.25 * shiftMult;
if (state.playbackRate > 4) {
state.playbackRate = 4;
if (state.playbackRate > 6) {
state.playbackRate = 6;
}
state.botplayTxt.text = data.player + "'s\nREPLAY\n" + '(${CoolUtil.floorDecimal(state.playbackRate, 2)}x)';
}
Expand Down
2 changes: 1 addition & 1 deletion source/online/replay/ReplayRecorder.hx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class ReplayRecorder extends FlxBasic {
ghost_tapping: true,
rating_offset: null,
safe_frames: null,
version: 2,
version: 3,
mod_url: ''
};

Expand Down
1 change: 1 addition & 0 deletions source/options/ControlsSubState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class ControlsSubState extends MusicBeatSubstate
[true, 'Accept', 'accept', 'Accept'],
[true, 'Back', 'back', 'Back'],
[true, 'Pause', 'pause', 'Pause'],
[true, 'Sidebar', 'sidebar', 'Sidebar'],
[false],
[false, 'VOLUME'],
[false, 'Mute', 'volume_mute', 'Volume Mute'],
Expand Down
85 changes: 55 additions & 30 deletions source/states/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1942,7 +1942,9 @@ class PlayState extends MusicBeatState
var densLastStrumTime:Float = -1;
var densNotes:Float = 0;
var densNotesCount:Float = 0;
var _densNotesBonus:Float = 0;
var densNotesBonus:Float = 0;
var csc = 125; //Conductor.stepCrochet * 1.5;
trace('step crochet: ' + csc);
for (section in noteData)
{
for (songNotes in section.sectionNotes)
Expand Down Expand Up @@ -1986,22 +1988,21 @@ class PlayState extends MusicBeatState
var noteDiff = (daStrumTime - densLastStrumTime) / playbackRate;

if (densLastStrumTime != -1 && noteDiff > 10) {
var keepCombo = tenseCombo < 2 || Math.pow(150 - noteDiff, 2) <= tension / tenseCombo + 10;
var keepCombo = tenseCombo < 2 || csc - noteDiff + 10 >= tension / tenseCombo;

if (noteDiff <= 150) {
if (noteDiff <= csc) {
if (keepCombo) {
tenseCombo++;
tension += Math.pow(150 - noteDiff, 2);
tension += csc - noteDiff;
}
densNotesCount++;
densNotes += (150 - noteDiff) / 50;
densNotes += (csc - noteDiff) / csc;
}

if (noteDiff > 150 || !keepCombo) {
if (noteDiff > csc || !keepCombo) {
if (tenseCombo > 0 && tension > 0) {
var temp = tension / tenseCombo * tenseCombo / 500;
_densNotesBonus += temp;
densNotes += temp;
var temp = tension / (csc * 5) * Math.pow(tenseCombo, 1.15);
densNotesBonus += temp;
if (ClientPrefs.isDebug())
trace(temp, tenseCombo);
}
Expand Down Expand Up @@ -2097,9 +2098,9 @@ class PlayState extends MusicBeatState
}
}
}
denseNotes = densNotesCount == 0 ? 0 : densNotes / 1000;
denseNotes = densNotesCount == 0 ? 0 : (densNotes + densNotesBonus) / 1000;
trace(' + predensity: ' + densNotes);
trace(' + bonus: ' + _densNotesBonus);
trace(' + bonus: ' + densNotesBonus);
trace("note density score: " + denseNotes);
for (event in songData.events) //Event Notes
for (i in 0...event[1].length)
Expand Down Expand Up @@ -2388,16 +2389,6 @@ class PlayState extends MusicBeatState
return;
}

if (!GameClient.isConnected() && !finishingSong && elapsed >= 0.1 && Conductor.songPosition > lastLagPos) {
setSongTime(Conductor.songPosition - 3000);
lastLagPos = Conductor.songPosition;
Alert.alert("Mod Lag Detected (-3s)");
}

if (!GameClient.isConnected() && FlxG.keys.justPressed.F6) {
swingMode = !swingMode;
}

if (FlxG.keys.justPressed.F7) {
ClientPrefs.data.showFP = !ClientPrefs.data.showFP;
ClientPrefs.saveSettings();
Expand All @@ -2409,15 +2400,49 @@ class PlayState extends MusicBeatState
ClientPrefs.saveSettings();
Alert.alert("Replay Submiting: " + (ClientPrefs.data.disableSubmiting ? "OFF" : "ON"));
}

if (!GameClient.isConnected()) {
if (!finishingSong && elapsed >= 0.1 && Conductor.songPosition > lastLagPos) {
setSongTime(Conductor.songPosition - 3000);
lastLagPos = Conductor.songPosition;
Alert.alert("Mod Lag Detected (-3s)");
}

if (FlxG.keys.justPressed.F6) {
swingMode = !swingMode;
}

if (!GameClient.isConnected() && FlxG.keys.justPressed.F8 && replayPlayer == null) {
opponentMode = !opponentMode;
remove(replayRecorder);
replayRecorder.destroy();
songScore = 0;
boyfriend.isPlayer = !boyfriend.isPlayer;
dad.isPlayer = !dad.isPlayer;
addHealth(2);
if (FlxG.keys.justPressed.F8 && replayPlayer == null) {
opponentMode = !opponentMode;
remove(replayRecorder);
replayRecorder.destroy();
songScore = 0;
boyfriend.isPlayer = !boyfriend.isPlayer;
dad.isPlayer = !dad.isPlayer;
addHealth(2);
}

if (cpuControlled) {
var shiftMult = FlxG.keys.pressed.SHIFT ? 3 : 1;
if (controls.UI_LEFT) {
if (playbackRate - elapsed * 0.25 * shiftMult > 0)
playbackRate -= elapsed * 0.25 * shiftMult;
if (playbackRate < 0.01) {
playbackRate = 0.01;
}
botplayTxt.text = "BOTPLAY\n" + '(${CoolUtil.floorDecimal(playbackRate, 2)}x)';
}
else if (controls.UI_RIGHT) {
playbackRate += elapsed * 0.25 * shiftMult;
if (playbackRate > 8) {
playbackRate = 8;
}
botplayTxt.text = "BOTPLAY\n" + '(${CoolUtil.floorDecimal(playbackRate, 2)}x)';
}
else if (controls.RESET) {
playbackRate = 1;
}
}
}

if (FlxG.keys.justPressed.F11 && GameClient.isConnected()) {
Expand Down Expand Up @@ -2553,7 +2578,7 @@ class PlayState extends MusicBeatState
FlxG.watch.addQuick("stepShit", curStep);

// RESET = Quick Game Over Screen
if (!GameClient.isConnected() && !ClientPrefs.data.noReset && controls.RESET && canReset && !inCutscene && startedCountdown && !endingSong && canInput() && replayData == null)
if (!GameClient.isConnected() && !ClientPrefs.data.noReset && controls.RESET && canReset && !inCutscene && startedCountdown && !endingSong && canInput() && replayData == null && !cpuControlled)
{
health = 0;
trace("RESET = True");
Expand Down

0 comments on commit cc0bb60

Please sign in to comment.