Skip to content
Open
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
16 changes: 14 additions & 2 deletions scripts/game/Runner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

public partial class Runner : Node3D
{
private const uint MaxScore = 1_000_000;

[Signal] public delegate void AttemptStatsUpdatedEventHandler(Attempt attempt);
[Signal] public delegate void SkipAvailableEventHandler(Attempt attempt);
[Signal] public delegate void HitResultChangedEventHandler(int noteIndex, HitResult hitResult);
Expand Down Expand Up @@ -439,11 +441,21 @@ public void Stop(bool results = true)
}
}

public uint CalculateHitScore(float factor, uint comboMultiplier, uint combo, double modsMultiplier)
{
double maxScorePerNote = Attempt?.Map?.Notes.Length > 0 ? MaxScore / (double)Attempt.Map.Notes.Length : 0;
double comboFactor = 1 + combo / 100d;
double speedFactor = ((Speed - 1) / 2.5 + 1);
double rawScore = maxScorePerNote * comboMultiplier * comboFactor * factor * modsMultiplier * speedFactor;

return (uint)Math.Round(rawScore);
}

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));
uint hitScore = CalculateHitScore(factor, Attempt.ComboMultiplier, Attempt.Combo, Attempt.ModsMultiplier);

switch (hitResult)
{
Expand All @@ -454,7 +466,7 @@ private void onHitResultChanged(int noteIndex, HitResult hitResult)
Attempt.Combo++;
Attempt.ComboMultiplierProgress++;
Attempt.LastHitColour = SkinManager.Instance.Skin.NoteColors[noteIndex % SkinManager.Instance.Skin.NoteColors.Length];
Attempt.Score += hitScore;
Attempt.Score = Math.Min(MaxScore, Attempt.Score + hitScore);

if (!Attempt.IsReplay)
{
Expand Down
2 changes: 1 addition & 1 deletion scripts/game/ui/Grid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private void onHitResultChanged(int noteIndex, HitResult result)
{
float lateness = Runner.Attempt.IsReplay ? Runner.Attempt.HitsInfo[noteIndex] : (float)(((int)Runner.Attempt.Progress - Runner.Attempt.Map.Notes[noteIndex].Millisecond) / Runner.Speed);
float factor = 1 - Math.Max(0, lateness - 25) / 150f;
uint hitScore = (uint)(100 * Runner.Attempt.ComboMultiplier * Runner.Attempt.ModsMultiplier * factor * ((Runner.Speed - 1) / 2.5 + 1));
uint hitScore = Runner.CalculateHitScore(factor, Runner.Attempt.ComboMultiplier, Runner.Attempt.Combo, Runner.Attempt.ModsMultiplier);

switch (result)
{
Expand Down