1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-16 04:57:19 +08:00

Merge pull request #15665 from MBmasher/fl-opacity

Consider opacity of hit objects in Flashlight skill
This commit is contained in:
Dan Balasescu 2022-05-12 19:00:21 +09:00 committed by GitHub
commit b71274265f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 55 additions and 10 deletions

View File

@ -122,6 +122,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty
new OsuModEasy(), new OsuModEasy(),
new OsuModHardRock(), new OsuModHardRock(),
new OsuModFlashlight(), new OsuModFlashlight(),
new MultiMod(new OsuModFlashlight(), new OsuModHidden())
}; };
} }
} }

View File

@ -219,9 +219,6 @@ namespace osu.Game.Rulesets.Osu.Difficulty
double flashlightValue = Math.Pow(rawFlashlight, 2.0) * 25.0; double flashlightValue = Math.Pow(rawFlashlight, 2.0) * 25.0;
if (score.Mods.Any(h => h is OsuModHidden))
flashlightValue *= 1.3;
// Penalize misses by assessing # of misses relative to the total # of objects. Default a 3% reduction for any # of misses. // Penalize misses by assessing # of misses relative to the total # of objects. Default a 3% reduction for any # of misses.
if (effectiveMissCount > 0) if (effectiveMissCount > 0)
flashlightValue *= 0.97 * Math.Pow(1 - Math.Pow(effectiveMissCount / totalHits, 0.775), Math.Pow(effectiveMissCount, .875)); flashlightValue *= 0.97 * Math.Pow(1 - Math.Pow(effectiveMissCount / totalHits, 0.775), Math.Pow(effectiveMissCount, .875));

View File

@ -4,6 +4,7 @@
using System; using System;
using osu.Game.Rulesets.Difficulty.Preprocessing; using osu.Game.Rulesets.Difficulty.Preprocessing;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
using osuTK; using osuTK;
@ -85,6 +86,35 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing
setDistances(clockRate); setDistances(clockRate);
} }
public double OpacityAt(double time, bool hidden)
{
if (time > BaseObject.StartTime)
{
// Consider a hitobject as being invisible when its start time is passed.
// In reality the hitobject will be visible beyond its start time up until its hittable window has passed,
// but this is an approximation and such a case is unlikely to be hit where this function is used.
return 0.0;
}
double fadeInStartTime = BaseObject.StartTime - BaseObject.TimePreempt;
double fadeInDuration = BaseObject.TimeFadeIn;
if (hidden)
{
// Taken from OsuModHidden.
double fadeOutStartTime = BaseObject.StartTime - BaseObject.TimePreempt + BaseObject.TimeFadeIn;
double fadeOutDuration = BaseObject.TimePreempt * OsuModHidden.FADE_OUT_DURATION_MULTIPLIER;
return Math.Min
(
Math.Clamp((time - fadeInStartTime) / fadeInDuration, 0.0, 1.0),
1.0 - Math.Clamp((time - fadeOutStartTime) / fadeOutDuration, 0.0, 1.0)
);
}
return Math.Clamp((time - fadeInStartTime) / fadeInDuration, 0.0, 1.0);
}
private void setDistances(double clockRate) private void setDistances(double clockRate)
{ {
if (BaseObject is Slider currentSlider) if (BaseObject is Slider currentSlider)

View File

@ -2,8 +2,10 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System; using System;
using System.Linq;
using osu.Game.Rulesets.Difficulty.Preprocessing; using osu.Game.Rulesets.Difficulty.Preprocessing;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Rulesets.Osu.Difficulty.Preprocessing; using osu.Game.Rulesets.Osu.Difficulty.Preprocessing;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
@ -17,13 +19,19 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Skills
public Flashlight(Mod[] mods) public Flashlight(Mod[] mods)
: base(mods) : base(mods)
{ {
hidden = mods.Any(m => m is OsuModHidden);
} }
private double skillMultiplier => 0.07; private double skillMultiplier => 0.05;
private double strainDecayBase => 0.15; private double strainDecayBase => 0.15;
protected override double DecayWeight => 1.0; protected override double DecayWeight => 1.0;
protected override int HistoryLength => 10; // Look back for 10 notes is added for the sake of flashlight calculations. protected override int HistoryLength => 10; // Look back for 10 notes is added for the sake of flashlight calculations.
private readonly bool hidden;
private const double max_opacity_bonus = 0.4;
private const double hidden_bonus = 0.2;
private double currentStrain; private double currentStrain;
private double strainValueOf(DifficultyHitObject current) private double strainValueOf(DifficultyHitObject current)
@ -61,13 +69,22 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Skills
// We also want to nerf stacks so that only the first object of the stack is accounted for. // We also want to nerf stacks so that only the first object of the stack is accounted for.
double stackNerf = Math.Min(1.0, (currentObj.LazyJumpDistance / scalingFactor) / 25.0); double stackNerf = Math.Min(1.0, (currentObj.LazyJumpDistance / scalingFactor) / 25.0);
result += stackNerf * scalingFactor * jumpDistance / cumulativeStrainTime; // Bonus based on how visible the object is.
double opacityBonus = 1.0 + max_opacity_bonus * (1.0 - osuCurrent.OpacityAt(currentHitObject.StartTime, hidden));
result += stackNerf * opacityBonus * scalingFactor * jumpDistance / cumulativeStrainTime;
} }
lastObj = currentObj; lastObj = currentObj;
} }
return Math.Pow(smallDistNerf * result, 2.0); result = Math.Pow(smallDistNerf * result, 2.0);
// Additional bonus for Hidden due to there being no approach circles.
if (hidden)
result *= 1.0 + hidden_bonus;
return result;
} }
private double strainDecay(double ms) => Math.Pow(strainDecayBase, ms / 1000); private double strainDecay(double ms) => Math.Pow(strainDecayBase, ms / 1000);

View File

@ -27,8 +27,8 @@ namespace osu.Game.Rulesets.Osu.Mods
public override Type[] IncompatibleMods => new[] { typeof(IRequiresApproachCircles), typeof(OsuModSpinIn) }; public override Type[] IncompatibleMods => new[] { typeof(IRequiresApproachCircles), typeof(OsuModSpinIn) };
private const double fade_in_duration_multiplier = 0.4; public const double FADE_IN_DURATION_MULTIPLIER = 0.4;
private const double fade_out_duration_multiplier = 0.3; public const double FADE_OUT_DURATION_MULTIPLIER = 0.3;
protected override bool IsFirstAdjustableObject(HitObject hitObject) => !(hitObject is Spinner || hitObject is SpinnerTick); protected override bool IsFirstAdjustableObject(HitObject hitObject) => !(hitObject is Spinner || hitObject is SpinnerTick);
@ -41,7 +41,7 @@ namespace osu.Game.Rulesets.Osu.Mods
static void applyFadeInAdjustment(OsuHitObject osuObject) static void applyFadeInAdjustment(OsuHitObject osuObject)
{ {
osuObject.TimeFadeIn = osuObject.TimePreempt * fade_in_duration_multiplier; osuObject.TimeFadeIn = osuObject.TimePreempt * FADE_IN_DURATION_MULTIPLIER;
foreach (var nested in osuObject.NestedHitObjects.OfType<OsuHitObject>()) foreach (var nested in osuObject.NestedHitObjects.OfType<OsuHitObject>())
applyFadeInAdjustment(nested); applyFadeInAdjustment(nested);
} }
@ -156,7 +156,7 @@ namespace osu.Game.Rulesets.Osu.Mods
static (double fadeStartTime, double fadeDuration) getParameters(OsuHitObject hitObject) static (double fadeStartTime, double fadeDuration) getParameters(OsuHitObject hitObject)
{ {
double fadeOutStartTime = hitObject.StartTime - hitObject.TimePreempt + hitObject.TimeFadeIn; double fadeOutStartTime = hitObject.StartTime - hitObject.TimePreempt + hitObject.TimeFadeIn;
double fadeOutDuration = hitObject.TimePreempt * fade_out_duration_multiplier; double fadeOutDuration = hitObject.TimePreempt * FADE_OUT_DURATION_MULTIPLIER;
// new duration from completed fade in to end (before fading out) // new duration from completed fade in to end (before fading out)
double longFadeDuration = hitObject.GetEndTime() - fadeOutStartTime; double longFadeDuration = hitObject.GetEndTime() - fadeOutStartTime;