2019-02-12 15:03:28 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Rulesets.Difficulty;
|
|
|
|
using osu.Game.Rulesets.Difficulty.Preprocessing;
|
|
|
|
using osu.Game.Rulesets.Difficulty.Skills;
|
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
using osu.Game.Rulesets.Osu.Difficulty.Preprocessing;
|
|
|
|
using osu.Game.Rulesets.Osu.Difficulty.Skills;
|
|
|
|
using osu.Game.Rulesets.Osu.Mods;
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
2019-09-06 14:24:00 +08:00
|
|
|
using osu.Game.Rulesets.Osu.Scoring;
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2019-02-12 15:03:28 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Difficulty
|
|
|
|
{
|
|
|
|
public class OsuDifficultyCalculator : DifficultyCalculator
|
|
|
|
{
|
|
|
|
private const double difficulty_multiplier = 0.0675;
|
2021-09-15 17:52:50 +08:00
|
|
|
private double hitWindowGreat;
|
2019-02-12 15:03:28 +08:00
|
|
|
|
|
|
|
public OsuDifficultyCalculator(Ruleset ruleset, WorkingBeatmap beatmap)
|
|
|
|
: base(ruleset, beatmap)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-02-19 16:38:33 +08:00
|
|
|
protected override DifficultyAttributes CreateDifficultyAttributes(IBeatmap beatmap, Mod[] mods, Skill[] skills, double clockRate)
|
2019-02-12 15:03:28 +08:00
|
|
|
{
|
2019-02-19 16:38:33 +08:00
|
|
|
if (beatmap.HitObjects.Count == 0)
|
2019-05-29 17:22:51 +08:00
|
|
|
return new OsuDifficultyAttributes { Mods = mods, Skills = skills };
|
2019-02-12 15:03:28 +08:00
|
|
|
|
|
|
|
double aimRating = Math.Sqrt(skills[0].DifficultyValue()) * difficulty_multiplier;
|
|
|
|
double speedRating = Math.Sqrt(skills[1].DifficultyValue()) * difficulty_multiplier;
|
2021-08-08 21:56:03 +08:00
|
|
|
double flashlightRating = Math.Sqrt(skills[2].DifficultyValue()) * difficulty_multiplier;
|
2021-10-11 09:12:57 +08:00
|
|
|
double speedNotes = (skills[1] as Speed).RelevantNoteCount();
|
2021-08-01 21:27:05 +08:00
|
|
|
|
2021-10-06 23:53:33 +08:00
|
|
|
if (mods.Any(h => h is OsuModRelax))
|
|
|
|
speedRating = 0.0;
|
|
|
|
|
2021-08-01 00:23:03 +08:00
|
|
|
double baseAimPerformance = Math.Pow(5 * Math.Max(1, aimRating / 0.0675) - 4, 3) / 100000;
|
|
|
|
double baseSpeedPerformance = Math.Pow(5 * Math.Max(1, speedRating / 0.0675) - 4, 3) / 100000;
|
2021-09-15 17:03:42 +08:00
|
|
|
double baseFlashlightPerformance = 0.0;
|
2021-09-21 11:43:29 +08:00
|
|
|
|
2021-09-15 17:03:42 +08:00
|
|
|
if (mods.Any(h => h is OsuModFlashlight))
|
|
|
|
baseFlashlightPerformance = Math.Pow(flashlightRating, 2.0) * 25.0;
|
2021-09-21 11:43:29 +08:00
|
|
|
|
2021-09-15 17:03:42 +08:00
|
|
|
double basePerformance =
|
|
|
|
Math.Pow(
|
|
|
|
Math.Pow(baseAimPerformance, 1.1) +
|
|
|
|
Math.Pow(baseSpeedPerformance, 1.1) +
|
|
|
|
Math.Pow(baseFlashlightPerformance, 1.1), 1.0 / 1.1
|
|
|
|
);
|
2021-09-21 11:43:29 +08:00
|
|
|
|
2021-08-04 06:57:33 +08:00
|
|
|
double starRating = basePerformance > 0.00001 ? Math.Cbrt(1.12) * 0.027 * (Math.Cbrt(100000 / Math.Pow(2, 1 / 1.1) * basePerformance) + 4) : 0;
|
2019-02-12 15:03:28 +08:00
|
|
|
|
2021-10-09 17:08:57 +08:00
|
|
|
double preempt = IBeatmapDifficultyInfo.DifficultyRange(beatmap.Difficulty.ApproachRate, 1800, 1200, 450) / clockRate;
|
2021-10-08 18:50:31 +08:00
|
|
|
double drainRate = beatmap.Difficulty.DrainRate;
|
2019-02-12 15:03:28 +08:00
|
|
|
|
|
|
|
int maxCombo = beatmap.HitObjects.Count;
|
|
|
|
// Add the ticks + tail of the slider. 1 is subtracted because the head circle would be counted twice (once for the slider itself in the line above)
|
|
|
|
maxCombo += beatmap.HitObjects.OfType<Slider>().Sum(s => s.NestedHitObjects.Count - 1);
|
|
|
|
|
2020-10-03 01:34:41 +08:00
|
|
|
int hitCirclesCount = beatmap.HitObjects.Count(h => h is HitCircle);
|
2020-12-08 21:09:48 +08:00
|
|
|
int spinnerCount = beatmap.HitObjects.Count(h => h is Spinner);
|
2020-10-03 01:34:41 +08:00
|
|
|
|
2019-02-19 16:38:33 +08:00
|
|
|
return new OsuDifficultyAttributes
|
|
|
|
{
|
|
|
|
StarRating = starRating,
|
2019-02-19 16:39:30 +08:00
|
|
|
Mods = mods,
|
2019-02-19 16:38:33 +08:00
|
|
|
AimStrain = aimRating,
|
|
|
|
SpeedStrain = speedRating,
|
2021-10-11 09:12:57 +08:00
|
|
|
SpeedNoteCount = speedNotes,
|
2021-09-14 08:34:21 +08:00
|
|
|
FlashlightRating = flashlightRating,
|
2019-02-19 16:38:33 +08:00
|
|
|
ApproachRate = preempt > 1200 ? (1800 - preempt) / 120 : (1200 - preempt) / 150 + 5,
|
|
|
|
OverallDifficulty = (80 - hitWindowGreat) / 6,
|
2021-09-24 22:02:19 +08:00
|
|
|
DrainRate = drainRate,
|
2019-05-29 17:22:51 +08:00
|
|
|
MaxCombo = maxCombo,
|
2020-10-03 22:52:33 +08:00
|
|
|
HitCircleCount = hitCirclesCount,
|
2020-12-08 21:09:48 +08:00
|
|
|
SpinnerCount = spinnerCount,
|
2019-05-29 17:22:51 +08:00
|
|
|
Skills = skills
|
2019-02-19 16:38:33 +08:00
|
|
|
};
|
2019-02-12 15:03:28 +08:00
|
|
|
}
|
|
|
|
|
2019-02-19 16:40:35 +08:00
|
|
|
protected override IEnumerable<DifficultyHitObject> CreateDifficultyHitObjects(IBeatmap beatmap, double clockRate)
|
2019-02-12 15:03:28 +08:00
|
|
|
{
|
|
|
|
// The first jump is formed by the first two hitobjects of the map.
|
|
|
|
// If the map has less than two OsuHitObjects, the enumerator will not return anything.
|
|
|
|
for (int i = 1; i < beatmap.HitObjects.Count; i++)
|
|
|
|
{
|
|
|
|
var lastLast = i > 1 ? beatmap.HitObjects[i - 2] : null;
|
|
|
|
var last = beatmap.HitObjects[i - 1];
|
|
|
|
var current = beatmap.HitObjects[i];
|
|
|
|
|
2019-02-19 16:40:35 +08:00
|
|
|
yield return new OsuDifficultyHitObject(current, lastLast, last, clockRate);
|
2019-02-12 15:03:28 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-15 17:52:50 +08:00
|
|
|
protected override Skill[] CreateSkills(IBeatmap beatmap, Mod[] mods, double clockRate)
|
2019-02-12 15:03:28 +08:00
|
|
|
{
|
2021-09-15 17:52:50 +08:00
|
|
|
HitWindows hitWindows = new OsuHitWindows();
|
2021-10-02 11:34:29 +08:00
|
|
|
hitWindows.SetDifficulty(beatmap.Difficulty.OverallDifficulty);
|
2021-09-15 17:52:50 +08:00
|
|
|
|
2021-10-09 17:08:57 +08:00
|
|
|
hitWindowGreat = hitWindows.WindowFor(HitResult.Great) / clockRate;
|
2021-09-15 17:52:50 +08:00
|
|
|
|
|
|
|
return new Skill[]
|
|
|
|
{
|
|
|
|
new Aim(mods),
|
|
|
|
new Speed(mods, hitWindowGreat),
|
2021-09-21 17:41:27 +08:00
|
|
|
new Flashlight(mods)
|
2021-09-15 17:52:50 +08:00
|
|
|
};
|
|
|
|
}
|
2019-02-12 15:03:28 +08:00
|
|
|
|
|
|
|
protected override Mod[] DifficultyAdjustmentMods => new Mod[]
|
|
|
|
{
|
|
|
|
new OsuModDoubleTime(),
|
|
|
|
new OsuModHalfTime(),
|
|
|
|
new OsuModEasy(),
|
|
|
|
new OsuModHardRock(),
|
2021-09-15 17:03:42 +08:00
|
|
|
new OsuModFlashlight(),
|
2019-02-12 15:03:28 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|