1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-18 01:57:48 +08:00
osu-lazer/osu.Game.Rulesets.Osu/Difficulty/Skills/Aim.cs

83 lines
3.0 KiB
C#
Raw Normal View History

// 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.
2018-04-13 17:19:50 +08:00
using System;
using osu.Game.Rulesets.Difficulty.Preprocessing;
using osu.Game.Rulesets.Mods;
2018-05-15 16:36:29 +08:00
using osu.Game.Rulesets.Osu.Difficulty.Preprocessing;
2019-02-18 13:58:33 +08:00
using osu.Game.Rulesets.Osu.Objects;
2018-04-13 17:19:50 +08:00
2018-05-15 16:36:29 +08:00
namespace osu.Game.Rulesets.Osu.Difficulty.Skills
2018-04-13 17:19:50 +08:00
{
/// <summary>
/// Represents the skill required to correctly aim at every object in the map with a uniform CircleSize and normalized distances.
/// </summary>
2021-06-15 01:18:49 +08:00
public class Aim : OsuStrainSkill
2018-04-13 17:19:50 +08:00
{
2018-12-24 11:41:04 +08:00
private const double angle_bonus_begin = Math.PI / 3;
2018-12-22 08:31:30 +08:00
private const double timing_threshold = 107;
2018-12-22 08:56:33 +08:00
public Aim(Mod[] mods)
: base(mods)
{
}
2021-08-17 21:39:18 +08:00
private double currentStrain = 1;
2018-04-13 17:19:50 +08:00
2021-08-17 21:39:18 +08:00
private double skillMultiplier => 26.25;
private double strainDecayBase => 0.15;
private double aimStrainOf(DifficultyHitObject current)
2018-12-08 14:01:26 +08:00
{
2019-02-18 13:58:33 +08:00
if (current.BaseObject is Spinner)
return 0;
var osuCurrent = (OsuDifficultyHitObject)current;
2018-12-24 11:41:04 +08:00
2021-08-17 21:39:18 +08:00
double aimStrain = 0;
2019-01-29 15:35:20 +08:00
2018-12-21 13:52:43 +08:00
if (Previous.Count > 0)
{
var osuPrevious = (OsuDifficultyHitObject)Previous[0];
if (osuCurrent.Angle != null && osuCurrent.Angle.Value > angle_bonus_begin)
2018-12-21 21:52:27 +08:00
{
const double scale = 90;
2018-12-24 11:41:04 +08:00
var angleBonus = Math.Sqrt(
Math.Max(osuPrevious.JumpDistance - scale, 0)
* Math.Pow(Math.Sin(osuCurrent.Angle.Value - angle_bonus_begin), 2)
* Math.Max(osuCurrent.JumpDistance - scale, 0));
2021-08-17 21:39:18 +08:00
aimStrain = 1.4 * applyDiminishingExp(Math.Max(0, angleBonus)) / Math.Max(timing_threshold, osuPrevious.StrainTime);
2018-12-21 21:52:27 +08:00
}
2018-12-21 13:52:43 +08:00
}
double jumpDistanceExp = applyDiminishingExp(osuCurrent.JumpDistance);
double travelDistanceExp = applyDiminishingExp(osuCurrent.TravelDistance);
2019-01-29 15:35:20 +08:00
2018-12-24 11:41:04 +08:00
return Math.Max(
2021-08-17 21:39:18 +08:00
aimStrain + (jumpDistanceExp + travelDistanceExp + Math.Sqrt(travelDistanceExp * jumpDistanceExp)) / Math.Max(osuCurrent.StrainTime, timing_threshold),
(Math.Sqrt(travelDistanceExp * jumpDistanceExp) + jumpDistanceExp + travelDistanceExp) / osuCurrent.StrainTime
2019-01-29 15:35:20 +08:00
);
2018-12-08 14:01:26 +08:00
}
private double applyDiminishingExp(double val) => Math.Pow(val, 0.99);
2021-08-17 21:39:18 +08:00
private double strainDecay(double ms) => Math.Pow(strainDecayBase, ms / 1000);
protected override double CalculateInitialStrain(double time) => currentStrain * strainDecay(time - Previous[0].StartTime);
protected override double StrainValueAt(DifficultyHitObject current)
{
double aimStrain = aimStrainOf(current);
currentStrain *= strainDecay(current.DeltaTime);
currentStrain += aimStrain * skillMultiplier;
// Console.WriteLine(currentStrain);
return currentStrain;
}
2018-04-13 17:19:50 +08:00
}
}