Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion scripts/game/Attempt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ public partial class Attempt : RefCounted
public uint Hits = 0;
public uint Misses = 0;
public uint Sum = 0;
public uint Score = 0;
public double Score = 0;
public double UnitHitScore = 0;
public uint NoteWeight;
public uint Combo = 0;
public uint ComboMultiplier = 1;
public uint ComboMultiplierProgress = 0;
Expand Down Expand Up @@ -82,6 +84,25 @@ public Attempt(Map map, double speed, double startFrom, CameraMode cameraMode, L
Objects[typeof(Note)] = [.. map.Notes];
HitsInfo = IsReplay ? Replays[0].Notes : new float[Map.Notes.Length];

uint noteWeightIterations = (uint)Math.Clamp(Math.Floor((double)Map.Notes.Length / ComboMultiplierIncrement), 1, 7);

for (uint i = 1; i <= noteWeightIterations; i++)
{
NoteWeight += Math.Min(ComboMultiplierIncrement, (uint)Map.Notes.Length) * i;
}

NoteWeight += ((uint)Map.Notes.Length - Math.Min(ComboMultiplierIncrement, (uint)Map.Notes.Length) * noteWeightIterations) * (noteWeightIterations + 1);

if (Modifiers.Count >= 1)
{
foreach (Modifier modifier in Modifiers)
{
ModsMultiplier += modifier.ScoreMultiplier - 1;
}
}

UnitHitScore = 1000000f * ModsMultiplier * ((Speed - 1) / 2.5 + 1) / NoteWeight;

if (IsReplay)
{
foreach (var replay in Replays)
Expand Down
8 changes: 4 additions & 4 deletions scripts/game/Runner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -410,13 +410,13 @@ public void Stop(bool results = true)

Leaderboard leaderboard = new(Attempt.Map.Name, $"{Constants.USER_FOLDER}/pbs/{Attempt.Map.Name}");

leaderboard.Add(new(Attempt.ID, "You", Attempt.Qualifies, Attempt.Score, Attempt.Accuracy, Time.GetUnixTimeFromSystem(), Attempt.Progress, Attempt.Map.Length, Speed, mods));
leaderboard.Add(new(Attempt.ID, "You", Attempt.Qualifies, (ulong)Math.Round(Attempt.Score), Attempt.Accuracy, Time.GetUnixTimeFromSystem(), Attempt.Progress, Attempt.Map.Length, Speed, mods));
leaderboard.Save();

if (Attempt.Qualifies)
{
Stats.Instance.Passes++;
Stats.Instance.TotalScore += Attempt.Score;
Stats.Instance.TotalScore += (ulong)Math.Round(Attempt.Score);

if (Attempt.Accuracy == 100)
{
Expand All @@ -425,7 +425,7 @@ public void Stop(bool results = true)

if (Attempt.Score > Stats.Instance.HighestScore)
{
Stats.Instance.HighestScore = Attempt.Score;
Stats.Instance.HighestScore = (ulong)Math.Round(Attempt.Score);
}

Stats.Instance.AverageAccuracy = (Stats.Instance.AverageAccuracy + Attempt.Accuracy) / Stats.Instance.Passes;
Expand All @@ -445,7 +445,7 @@ private void onHitResultChanged(int noteIndex, HitResult hitResult)
{
float lateness = Attempt.IsReplay ? Attempt.HitsInfo[noteIndex] : (float)(((int)Attempt.Progress - Attempt.Map.Notes[noteIndex].Millisecond) / Speed);
float factor = 1 - Math.Max(0, lateness - 25) / 150f;
uint hitScore = (uint)(100 * Attempt.ComboMultiplier * Attempt.ModsMultiplier * factor * ((Speed - 1) / 2.5 + 1));
double hitScore = Attempt.UnitHitScore * Attempt.ComboMultiplier * factor;

switch (hitResult)
{
Expand Down
2 changes: 1 addition & 1 deletion scripts/game/ui/PanelLeft.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public override void _PhysicsProcess(double delta)

public void OnStatsUpdated(Attempt attempt)
{
score.Text = Util.String.PadMagnitude(attempt.Score.ToString());
score.Text = Util.String.PadMagnitude(Math.Round(attempt.Score).ToString());
multiplier.Text = $"{attempt.ComboMultiplier}x";
altCombo.Text = $"{attempt.Combo}";

Expand Down
2 changes: 1 addition & 1 deletion scripts/scenes/Results.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public override void _Ready()
holder.GetNode<Label>("Difficulty").Text = attempt.Map.DifficultyName;
holder.GetNode<Label>("Mappers").Text = $"by {attempt.Map.PrettyMappers}";
holder.GetNode<Label>("Accuracy").Text = $"{attempt.Accuracy:F2}%";
holder.GetNode<Label>("Score").Text = $"{Util.String.PadMagnitude(attempt.Score.ToString())}";
holder.GetNode<Label>("Score").Text = $"{Util.String.PadMagnitude(Math.Round(attempt.Score).ToString())}";
holder.GetNode<Label>("Hits").Text = $"{Util.String.PadMagnitude(attempt.Hits.ToString())} / {Util.String.PadMagnitude(attempt.Sum.ToString())}";
holder.GetNode<Label>("Status").Text = attempt.IsReplay ? attempt.Replays[0].Status : attempt.Alive ? (attempt.Qualifies ? "PASSED" : "DISQUALIFIED") : "FAILED";
holder.GetNode<Label>("Speed").Text = $"{attempt.Speed:F2}x";
Expand Down