Skip to content

Commit

Permalink
Merge pull request ppy#15665 from MBmasher/fl-opacity
Browse files Browse the repository at this point in the history
Consider opacity of hit objects in Flashlight skill
  • Loading branch information
smoogipoo authored May 12, 2022
2 parents c3d4723 + 4463a26 commit b712742
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ protected override Skill[] CreateSkills(IBeatmap beatmap, Mod[] mods, double clo
new OsuModEasy(),
new OsuModHardRock(),
new OsuModFlashlight(),
new MultiMod(new OsuModFlashlight(), new OsuModHidden())
};
}
}
3 changes: 0 additions & 3 deletions osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,6 @@ private double computeFlashlightValue(ScoreInfo score, OsuDifficultyAttributes a

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.
if (effectiveMissCount > 0)
flashlightValue *= 0.97 * Math.Pow(1 - Math.Pow(effectiveMissCount / totalHits, 0.775), Math.Pow(effectiveMissCount, .875));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using osu.Game.Rulesets.Difficulty.Preprocessing;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Rulesets.Osu.Objects;
using osuTK;

Expand Down Expand Up @@ -85,6 +86,35 @@ public OsuDifficultyHitObject(HitObject hitObject, HitObject lastLastObject, Hit
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)
{
if (BaseObject is Slider currentSlider)
Expand Down
23 changes: 20 additions & 3 deletions osu.Game.Rulesets.Osu/Difficulty/Skills/Flashlight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
// See the LICENCE file in the repository root for full licence text.

using System;
using System.Linq;
using osu.Game.Rulesets.Difficulty.Preprocessing;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Rulesets.Osu.Difficulty.Preprocessing;
using osu.Game.Rulesets.Osu.Objects;

Expand All @@ -17,13 +19,19 @@ public class Flashlight : OsuStrainSkill
public Flashlight(Mod[] 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;
protected override double DecayWeight => 1.0;
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 strainValueOf(DifficultyHitObject current)
Expand Down Expand Up @@ -61,13 +69,22 @@ private double strainValueOf(DifficultyHitObject current)
// 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);

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;
}

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);
Expand Down
8 changes: 4 additions & 4 deletions osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public class OsuModHidden : ModHidden, IHidesApproachCircles

public override Type[] IncompatibleMods => new[] { typeof(IRequiresApproachCircles), typeof(OsuModSpinIn) };

private const double fade_in_duration_multiplier = 0.4;
private const double fade_out_duration_multiplier = 0.3;
public const double FADE_IN_DURATION_MULTIPLIER = 0.4;
public const double FADE_OUT_DURATION_MULTIPLIER = 0.3;

protected override bool IsFirstAdjustableObject(HitObject hitObject) => !(hitObject is Spinner || hitObject is SpinnerTick);

Expand All @@ -41,7 +41,7 @@ public override void ApplyToBeatmap(IBeatmap beatmap)

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>())
applyFadeInAdjustment(nested);
}
Expand Down Expand Up @@ -156,7 +156,7 @@ private void applyHiddenState(DrawableHitObject drawableObject, bool increaseVis
static (double fadeStartTime, double fadeDuration) getParameters(OsuHitObject hitObject)
{
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)
double longFadeDuration = hitObject.GetEndTime() - fadeOutStartTime;
Expand Down

0 comments on commit b712742

Please sign in to comment.