Skip to content

Commit

Permalink
this took me a day to write, fml
Browse files Browse the repository at this point in the history
  • Loading branch information
Snirozu committed Nov 18, 2024
1 parent dd274fc commit 8bdab8d
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 40 deletions.
40 changes: 33 additions & 7 deletions source/online/FunkinPoints.hx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ class FunkinPoints {
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 (2000 combo will double base fp)
fp *= 1 + maxCombo / 2000;

// depends on the amount of hitted notes (1fp per 10-300 notes)
var fp:Float = notesHit / denseNotes;
// depends on player's note streak (x2fp per 1000 combo)
fp *= 1 + maxCombo / 1000;
// 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 All @@ -27,4 +26,31 @@ class FunkinPoints {
GameClient.send("updateFP", funkinPoints);
return gained;
}
}
}

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

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

// // depends on player's hitted notes (1fp per 100 hitted notes)
// var fp:Float = notesHit / 100;
// // depends on player's note streak (x2fp per 500 combo)
// fp *= 1 + maxCombo / 500;
// // 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);
// }

// public static function save(accuracy:Float, misses:Float, notesHit:Float, maxCombo:Float) {
// var gained:Float = online.FunkinPoints.calcFP(accuracy, misses, notesHit, maxCombo);
// funkinPoints += gained;
// FlxG.save.flush();
// GameClient.send("updateFP", funkinPoints);
// return gained;
// }
// }
2 changes: 1 addition & 1 deletion source/online/gui/sidebar/MainTab.hx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class MainTab extends TabSprite {

var msg:TextField = new TextField();
var format = TabSprite.getDefaultFormat();
format.color = data.hue != null ? FlxColor.fromHSL(data.hue, 0.8, 0.6) : FlxColor.WHITE;
format.color = data.hue != null ? FlxColor.fromHSL(data.hue, 1.0, 0.8) : FlxColor.WHITE;
msg.defaultTextFormat = format;
msg.height = 10000;
msg.wordWrap = true;
Expand Down
2 changes: 1 addition & 1 deletion source/online/objects/ChatBox.hx
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ class ChatMessage extends FlxText {

public function new(fieldWidth:Float = 0, msg:LogData) {
super(0, 0, fieldWidth, msg.content);
setFormat("VCR OSD Mono", 16, msg.hue != null ? FlxColor.fromHSL(msg.hue, 0.8, 0.6) : FlxColor.WHITE, LEFT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK);
setFormat("VCR OSD Mono", 16, msg.hue != null ? FlxColor.fromHSL(msg.hue, 1.0, 0.8) : FlxColor.WHITE, LEFT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK);

var _split = msg.content.split("");
var i = -1;
Expand Down
58 changes: 27 additions & 31 deletions source/states/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1937,14 +1937,14 @@ class PlayState extends MusicBeatState
makeEvent(event, i);
}

var tension:Float = 0;
var tenseCombo:Float = 0;
var densLastStrumTime:Float = -1;
var densNotes:Float = 0;
var densNotesCount:Float = 0;
var densNotesBonus:Float = 0;
var csc = 125; //Conductor.stepCrochet * 1.5;
trace('step crochet: ' + csc);
var lastNoteDiff:Float = 0;
var cNoteCount:Float = 0;

//csc = Conductor.stepCrochet * 1.5;
var csc = 300; //130
for (section in noteData)
{
for (songNotes in section.sectionNotes)
Expand Down Expand Up @@ -1984,31 +1984,27 @@ class PlayState extends MusicBeatState
gottaHitNote = !section.mustHitSection;
}

if (songNotes[2] <= 0 && playsAsBF() ? gottaHitNote : !gottaHitNote) {
if (songNotes[2] <= 0 && playsAsBF() ? gottaHitNote : !gottaHitNote && daStrumTime - densLastStrumTime > 0) {
var noteDiff = (daStrumTime - densLastStrumTime) / playbackRate;
// var keepCombo = noteDiff < csc && noteDiff + 20 < lastNoteDiff;

if (densLastStrumTime != -1 && noteDiff > 10) {
var keepCombo = tenseCombo < 2 || csc - noteDiff + 10 >= tension / tenseCombo;
// if (noteDiff < csc_2) {
// lessDenseCount++;
// }

if (noteDiff <= csc) {
if (keepCombo) {
tenseCombo++;
tension += csc - noteDiff;
}
densNotesCount++;
densNotes += (csc - noteDiff) / csc;
}

if (noteDiff > csc || !keepCombo) {
if (tenseCombo > 0 && tension > 0) {
var temp = tension / (csc * 5) * Math.pow(tenseCombo, 1.15);
densNotesBonus += temp;
if (ClientPrefs.isDebug())
trace(temp, tenseCombo);
}
tenseCombo = 0;
tension = 0;
}
// if (keepCombo) {
// if (noteDiff > 10) {
// densNotesCount++;
// densNotes += (csc - noteDiff) / csc;
// }
// }

// lastNoteDiff = noteDiff;
// densLastStrumTime = daStrumTime;

if (noteDiff > 10 && noteDiff < csc) {
densNotes += noteDiff;
densNotesCount++;
}

densLastStrumTime = daStrumTime;
Expand Down Expand Up @@ -2098,9 +2094,10 @@ class PlayState extends MusicBeatState
}
}
}
denseNotes = densNotesCount == 0 ? 0 : (densNotes + densNotesBonus) / 1000;
trace(' + predensity: ' + densNotes);
trace(' + bonus: ' + densNotesBonus);
// denseNotes = densNotesCount == 0 ? 0 : (densNotes + densNotesBonus) / 1000;
// trace(' + predensity: ' + densNotes);
// trace(' + bonus: ' + densNotesBonus);
denseNotes = densNotesCount == 0 ? csc : densNotes / densNotesCount;
trace("note density score: " + denseNotes);
for (event in songData.events) //Event Notes
for (i in 0...event[1].length)
Expand Down Expand Up @@ -3640,7 +3637,6 @@ class PlayState extends MusicBeatState
songGoods++;
case "bad":
songBads++;
combo = 0;
case "shit":
songShits++;
combo = 0;
Expand Down

0 comments on commit 8bdab8d

Please sign in to comment.