2021-08-08 21:56:03 +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 osu.Game.Rulesets.Difficulty.Preprocessing;
|
|
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Difficulty.Preprocessing;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Difficulty.Skills
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Represents the skill required to memorise and hit every object in a map with the Flashlight mod enabled.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class Flashlight : OsuStrainSkill
|
|
|
|
|
{
|
|
|
|
|
public Flashlight(Mod[] mods)
|
|
|
|
|
: base(mods)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-25 10:52:10 +08:00
|
|
|
|
private double skillMultiplier => 0.15;
|
|
|
|
|
private double strainDecayBase => 0.15;
|
2021-08-08 21:56:03 +08:00
|
|
|
|
protected override double DecayWeight => 1.0;
|
2021-08-11 11:30:40 +08:00
|
|
|
|
protected override int HistoryLength => 10; // Look back for 10 notes is added for the sake of flashlight calculations.
|
2021-11-08 08:53:51 +08:00
|
|
|
|
|
|
|
|
|
private double currentStrain;
|
2021-08-08 21:56:03 +08:00
|
|
|
|
|
2021-09-25 10:52:10 +08:00
|
|
|
|
private double strainValueOf(DifficultyHitObject current)
|
2021-08-08 21:56:03 +08:00
|
|
|
|
{
|
|
|
|
|
if (current.BaseObject is Spinner)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
var osuCurrent = (OsuDifficultyHitObject)current;
|
|
|
|
|
var osuHitObject = (OsuHitObject)(osuCurrent.BaseObject);
|
|
|
|
|
|
|
|
|
|
double scalingFactor = 52.0 / osuHitObject.Radius;
|
|
|
|
|
double smallDistNerf = 1.0;
|
2021-09-14 08:23:11 +08:00
|
|
|
|
double cumulativeStrainTime = 0.0;
|
2021-08-08 21:56:03 +08:00
|
|
|
|
|
|
|
|
|
double result = 0.0;
|
|
|
|
|
|
2021-09-14 08:23:11 +08:00
|
|
|
|
for (int i = 0; i < Previous.Count; i++)
|
2021-08-08 21:56:03 +08:00
|
|
|
|
{
|
2021-09-14 08:23:11 +08:00
|
|
|
|
var osuPrevious = (OsuDifficultyHitObject)Previous[i];
|
|
|
|
|
var osuPreviousHitObject = (OsuHitObject)(osuPrevious.BaseObject);
|
2021-08-08 21:56:03 +08:00
|
|
|
|
|
2021-09-14 08:23:11 +08:00
|
|
|
|
if (!(osuPrevious.BaseObject is Spinner))
|
2021-08-10 14:06:20 +08:00
|
|
|
|
{
|
2021-09-14 08:23:11 +08:00
|
|
|
|
double jumpDistance = (osuHitObject.StackedPosition - osuPreviousHitObject.EndPosition).Length;
|
2021-08-09 06:31:28 +08:00
|
|
|
|
|
2021-09-14 08:23:11 +08:00
|
|
|
|
cumulativeStrainTime += osuPrevious.StrainTime;
|
2021-08-08 21:56:03 +08:00
|
|
|
|
|
2021-09-14 08:23:11 +08:00
|
|
|
|
// We want to nerf objects that can be easily seen within the Flashlight circle radius.
|
|
|
|
|
if (i == 0)
|
|
|
|
|
smallDistNerf = Math.Min(1.0, jumpDistance / 75.0);
|
2021-08-08 21:56:03 +08:00
|
|
|
|
|
2021-09-14 08:23:11 +08:00
|
|
|
|
// We also want to nerf stacks so that only the first object of the stack is accounted for.
|
|
|
|
|
double stackNerf = Math.Min(1.0, (osuPrevious.JumpDistance / scalingFactor) / 25.0);
|
2021-08-08 21:56:03 +08:00
|
|
|
|
|
2021-09-14 08:23:11 +08:00
|
|
|
|
result += Math.Pow(0.8, i) * stackNerf * scalingFactor * jumpDistance / cumulativeStrainTime;
|
2021-08-08 21:56:03 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-11 13:54:30 +08:00
|
|
|
|
return Math.Pow(smallDistNerf * result, 2.0);
|
2021-08-08 21:56:03 +08:00
|
|
|
|
}
|
2021-09-25 10:52:10 +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)
|
|
|
|
|
{
|
|
|
|
|
currentStrain *= strainDecay(current.DeltaTime);
|
2021-10-04 01:36:34 +08:00
|
|
|
|
currentStrain += strainValueOf(current) * skillMultiplier;
|
2021-09-25 10:52:10 +08:00
|
|
|
|
|
|
|
|
|
return currentStrain;
|
|
|
|
|
}
|
2021-08-08 21:56:03 +08:00
|
|
|
|
}
|
|
|
|
|
}
|