@rian8337/osu-rebalance-difficulty-calculator 4.0.0-beta.96 → 4.0.0-beta.98

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -60,6 +60,118 @@ class DifficultyCalculator {
60
60
  flashlight: skills[3].peaks,
61
61
  };
62
62
  }
63
+ /**
64
+ * Calculates the difficulty of a `Beatmap` with specific `Mod`s and returns a set of
65
+ * `TimedDifficultyAttributes` representing the difficulty at every relevant time value in the `Beatmap`.
66
+ *
67
+ * @param beatmap The `Beatmap` whose difficulty is to be calculated.
68
+ * @param mods The `Mod`s to apply to the `Beatmap`.
69
+ * @return The set of `TimedDifficultyAttributes`.
70
+ */
71
+ calculateTimed(beatmap, mods) {
72
+ if (beatmap.hitObjects.objects.length === 0) {
73
+ return [];
74
+ }
75
+ const playableBeatmap = this.createPlayableBeatmap(beatmap, mods);
76
+ const attributes = osuBase.Utils.initializeArray(beatmap.hitObjects.objects.length);
77
+ const skills = this.createSkills(playableBeatmap);
78
+ const progressiveBeatmap = new ProgressiveCalculationBeatmap(playableBeatmap);
79
+ const { objects } = playableBeatmap.hitObjects;
80
+ const difficultyObjects = this.createDifficultyHitObjects(playableBeatmap);
81
+ let currentIndex = 0;
82
+ for (let i = 0; i < objects.length; ++i) {
83
+ const obj = objects[i];
84
+ progressiveBeatmap.hitObjects.add(obj);
85
+ while (currentIndex < difficultyObjects.length && difficultyObjects[currentIndex].object.endTime <= obj.endTime) {
86
+ for (const skill of skills) {
87
+ skill.process(difficultyObjects[currentIndex]);
88
+ }
89
+ ++currentIndex;
90
+ }
91
+ attributes[i] = {
92
+ time: obj.endTime,
93
+ attributes: this.createDifficultyAttributes(beatmap, playableBeatmap, skills, difficultyObjects.slice(0, currentIndex)),
94
+ sliderCount: progressiveBeatmap.hitObjects.sliders,
95
+ sliderTickCount: progressiveBeatmap.hitObjects.sliderTicks,
96
+ sliderRepeatCount: progressiveBeatmap.hitObjects.sliderRepeatPoints
97
+ };
98
+ }
99
+ return attributes;
100
+ }
101
+ }
102
+ /**
103
+ * A {@link PlayableBeatmap} for timed difficulty calculation.
104
+ */
105
+ class ProgressiveCalculationBeatmap extends osuBase.PlayableBeatmap {
106
+ get maxCombo() {
107
+ return this.hitObjects.maxCombo;
108
+ }
109
+ constructor(baseBeatmap) {
110
+ super(baseBeatmap, baseBeatmap.mods);
111
+ this.hitObjects = new ProgressiveCalculationHitObjects();
112
+ this.baseHitWindow = baseBeatmap.hitWindow;
113
+ }
114
+ createHitWindow() {
115
+ return this.baseHitWindow;
116
+ }
117
+ }
118
+ class ProgressiveCalculationHitObjects extends osuBase.BeatmapHitObjects {
119
+ constructor() {
120
+ super(...arguments);
121
+ this.maxCombo = 0;
122
+ // We store these locally since the super class's getters iterate through all objects, which is inefficient for progressive calculation.
123
+ this.sliderTickCount = 0;
124
+ this.sliderRepeatCount = 0;
125
+ }
126
+ get sliderTicks() {
127
+ return this.sliderTickCount;
128
+ }
129
+ get sliderRepeatPoints() {
130
+ return this.sliderRepeatCount;
131
+ }
132
+ add(...objects) {
133
+ super.add(...objects);
134
+ for (const obj of objects) {
135
+ if (obj instanceof osuBase.Slider) {
136
+ this.maxCombo += obj.nestedHitObjects.length;
137
+ // Similarly, we loop through the nested hit objects since `Slider.ticks` also loops
138
+ // through the nested hit objects, which is inefficient for progressive calculation.
139
+ for (const nestedObj of obj.nestedHitObjects) {
140
+ if (nestedObj instanceof osuBase.SliderTick) {
141
+ ++this.sliderTickCount;
142
+ }
143
+ else if (nestedObj instanceof osuBase.SliderRepeat) {
144
+ ++this.sliderRepeatCount;
145
+ }
146
+ }
147
+ }
148
+ else {
149
+ ++this.maxCombo;
150
+ }
151
+ }
152
+ }
153
+ removeAt(index) {
154
+ const obj = super.removeAt(index);
155
+ if (obj !== null) {
156
+ if (obj instanceof osuBase.Slider) {
157
+ this.maxCombo -= obj.nestedHitObjects.length;
158
+ // Similarly, we loop through the nested hit objects since `Slider.ticks` also loops
159
+ // through the nested hit objects, which is inefficient for progressive calculation.
160
+ for (const nestedObj of obj.nestedHitObjects) {
161
+ if (nestedObj instanceof osuBase.SliderTick) {
162
+ --this.sliderTickCount;
163
+ }
164
+ else if (nestedObj instanceof osuBase.SliderRepeat) {
165
+ --this.sliderRepeatCount;
166
+ }
167
+ }
168
+ }
169
+ else {
170
+ --this.maxCombo;
171
+ }
172
+ }
173
+ return obj;
174
+ }
63
175
  }
64
176
 
65
177
  /**
@@ -151,11 +263,11 @@ class PerformanceCalculator {
151
263
  * @param options Options for performance calculation.
152
264
  */
153
265
  handleOptions(options) {
154
- var _a, _b;
266
+ var _a, _b, _c;
155
267
  if ((options === null || options === void 0 ? void 0 : options.accPercent) instanceof osuBase.Accuracy) {
156
268
  // Copy into new instance to not modify the original
157
269
  this.computedAccuracy = new osuBase.Accuracy(options.accPercent);
158
- if (this.computedAccuracy.n300 <= 0) {
270
+ if (!this.computedAccuracy.isN300Resolved) {
159
271
  this.computedAccuracy.n300 = Math.max(0, this.totalHits -
160
272
  this.computedAccuracy.n100 -
161
273
  this.computedAccuracy.n50 -
@@ -165,16 +277,15 @@ class PerformanceCalculator {
165
277
  this.computedAccuracy.nmiss = Math.max(0, this.totalHits - this.totalSuccessfulHits);
166
278
  }
167
279
  }
280
+ else if ((options === null || options === void 0 ? void 0 : options.accPercent) !== undefined) {
281
+ this.computedAccuracy = osuBase.Accuracy.fromPercent(options.accPercent, this.totalHits, (_a = options.miss) !== null && _a !== void 0 ? _a : 0);
282
+ }
168
283
  else {
169
- this.computedAccuracy = new osuBase.Accuracy({
170
- percent: options === null || options === void 0 ? void 0 : options.accPercent,
171
- nobjects: this.totalHits,
172
- nmiss: (_a = options === null || options === void 0 ? void 0 : options.miss) !== null && _a !== void 0 ? _a : 0,
173
- });
284
+ this.computedAccuracy = osuBase.Accuracy.fromHitCounts({ nmiss: (_b = options === null || options === void 0 ? void 0 : options.miss) !== null && _b !== void 0 ? _b : 0 }, this.totalHits);
174
285
  }
175
286
  const maxCombo = this.difficultyAttributes.maxCombo;
176
287
  const miss = this.computedAccuracy.nmiss;
177
- this.combo = (_b = options === null || options === void 0 ? void 0 : options.combo) !== null && _b !== void 0 ? _b : maxCombo - miss;
288
+ this.combo = (_c = options === null || options === void 0 ? void 0 : options.combo) !== null && _c !== void 0 ? _c : maxCombo - miss;
178
289
  if ((options === null || options === void 0 ? void 0 : options.sliderEndsDropped) !== undefined &&
179
290
  options.sliderTicksMissed !== undefined) {
180
291
  this._usingClassicSliderAccuracy = false;
@@ -1757,7 +1868,7 @@ class DroidReading extends HarmonicSkill {
1757
1868
  current.readingDifficulty = difficulty;
1758
1869
  }
1759
1870
  calculateAdjustedDifficulty(current) {
1760
- let difficulty = DroidReadingEvaluator.evaluateDifficultyOf(current, this.mods);
1871
+ let difficulty = Math.pow(DroidReadingEvaluator.evaluateDifficultyOf(current, this.mods), 0.89);
1761
1872
  if (this.mods.has(osuBase.ModRelax)) {
1762
1873
  difficulty *= 0.4;
1763
1874
  }
@@ -1812,11 +1923,16 @@ class DroidTapEvaluator {
1812
1923
  current.isOverlapping(false)) {
1813
1924
  return 0;
1814
1925
  }
1815
- let { strainTime } = current;
1816
- // Nerf doubletappable doubles.
1817
1926
  const doubletapness = considerCheesability
1818
1927
  ? 1 - current.getDoubletapness(current.next(0))
1819
1928
  : 1;
1929
+ let difficulty = osuBase.MathUtils.millisecondsToBPM(current.strainTime);
1930
+ difficulty *= this.calculateSpeedBonus(current);
1931
+ // Apply penalty if there's doubletappable doubles
1932
+ return difficulty * doubletapness;
1933
+ }
1934
+ static calculateSpeedBonus(current) {
1935
+ let { strainTime } = current;
1820
1936
  // Cap deltatime to the OD 300 hitwindow.
1821
1937
  // 0.63 is derived from making sure 200 BPM 1/4 OD8 streams aren't nerfed harshly, whilst 0.92 limits the effect of the cap.
1822
1938
  strainTime /= osuBase.MathUtils.clamp(strainTime / current.hitWindowFor(osuBase.HitResult.Great) / 0.63, 0.92, 1);
@@ -1830,14 +1946,7 @@ class DroidTapEvaluator {
1830
1946
  strainTime) /
1831
1947
  40), 2);
1832
1948
  }
1833
- // Base difficulty with all bonuses
1834
- let difficulty = ((1 + speedBonus) * 1000) / strainTime;
1835
- difficulty *= this.highBpmBonus(current.strainTime);
1836
- // Apply penalty if there's doubletappable doubles
1837
- return difficulty * doubletapness;
1838
- }
1839
- static highBpmBonus(ms) {
1840
- return 1 / (1 - Math.pow(0.3, ms / 1000));
1949
+ return (1 + speedBonus) / strainTime;
1841
1950
  }
1842
1951
  }
1843
1952
  // ~200 1/4 BPM streams
@@ -1850,7 +1959,7 @@ class DroidTap extends HarmonicSkill {
1850
1959
  constructor(mods, considerCheesability) {
1851
1960
  super(mods);
1852
1961
  this.harmonicScale = 20;
1853
- this.skillMultiplier = 1.16;
1962
+ this.skillMultiplier = 66.2;
1854
1963
  this.strainDecayBase = 0.3;
1855
1964
  this.currentTapDifficulty = 0;
1856
1965
  this.currentRhythmMultiplier = 0;
@@ -2093,7 +2202,8 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
2093
2202
  * Calculates the tap performance value of the beatmap.
2094
2203
  */
2095
2204
  calculateTapValue() {
2096
- let tapValue = DroidTap.difficultyToPerformance(this.difficultyAttributes.tapDifficulty);
2205
+ const tapDifficulty = this.difficultyAttributes.tapDifficulty * this.calculateTapHighDeviationNerf();
2206
+ let tapValue = DroidTap.difficultyToPerformance(tapDifficulty);
2097
2207
  if (this._effectiveMissCount > 0) {
2098
2208
  const tapEstimatedSliderBreaks = this.calculateEstimatedSliderBreaks(this.difficultyAttributes.tapTopWeightedSliderFactor);
2099
2209
  const relevantMissCount = Math.min(this._effectiveMissCount + tapEstimatedSliderBreaks, this.totalImperfectHits + this.sliderTicksMissed);
@@ -2105,12 +2215,11 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
2105
2215
  tapValue *= Math.min(1, this.calculateDeviationBasedLengthScaling(Math.min(this.difficultyAttributes.speedNoteCount, this.totalHits / 1.45)));
2106
2216
  // An effective hit window is created based on the tap SR. The higher the tap difficulty, the shorter the hit window.
2107
2217
  // For example, a tap SR of 4 leads to an effective hit window of 35ms.
2108
- const effectiveHitWindow = 35 * Math.pow(4 / this.difficultyAttributes.tapDifficulty, 1.8);
2218
+ const effectiveHitWindow = 35 * Math.pow(4 / tapDifficulty, 1.8);
2109
2219
  // Find the proportion of 300s on speed notes assuming the hit window was the effective hit window.
2110
2220
  const effectiveAccuracy = osuBase.ErrorFunction.erf(effectiveHitWindow / this._tapDeviation);
2111
2221
  // Scale the tap value with normalized accuracy.
2112
2222
  tapValue *= Math.pow(effectiveAccuracy, 2);
2113
- tapValue *= this.calculateTapHighDeviationNerf();
2114
2223
  // Scale the tap value with three-fingered penalty.
2115
2224
  tapValue /= this._tapPenalty;
2116
2225
  return tapValue;
@@ -2341,21 +2450,21 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
2341
2450
  if (this.tapDeviation == Number.POSITIVE_INFINITY) {
2342
2451
  return 0;
2343
2452
  }
2344
- const tapValue = DroidTap.difficultyToPerformance(this.difficultyAttributes.tapDifficulty);
2345
- // Decide a point where the PP value achieved compared to the tap deviation is assumed to be tapped
2346
- // improperly. Any PP above this point is considered "excess" tap difficulty. This is used to cause
2453
+ const { tapDifficulty } = this.difficultyAttributes;
2454
+ // Decide a point where the difficulty value achieved compared to the tap deviation is assumed to be tapped
2455
+ // improperly. Any difficulty above this point is considered "excess" tap difficulty. This is used to cause
2347
2456
  // PP above the cutoff to scale logarithmically towards the original tap value thus nerfing the value.
2348
- const excessTapDifficultyCutoff = 100 + 250 * Math.pow(25 / this.tapDeviation, 6.5);
2349
- if (tapValue <= excessTapDifficultyCutoff) {
2457
+ const excessTapDifficultyCutoff = 2.9 + 1.45 * Math.pow(25 / this.tapDeviation, 5);
2458
+ if (tapDifficulty <= excessTapDifficultyCutoff) {
2350
2459
  return 1;
2351
2460
  }
2352
- const scale = 50;
2353
- const adjustedTapValue = scale *
2354
- (Math.log((tapValue - excessTapDifficultyCutoff) / scale + 1) +
2461
+ const scale = 0.45;
2462
+ const adjustedTapDifficulty = scale *
2463
+ (Math.log((tapDifficulty - excessTapDifficultyCutoff) / scale + 1) +
2355
2464
  excessTapDifficultyCutoff / scale);
2356
2465
  // 250 UR and less are considered tapped correctly to ensure that normal scores will be punished as little as possible.
2357
2466
  const t = 1 - osuBase.Interpolation.reverseLerp(this.tapDeviation, 25, 30);
2358
- return osuBase.Interpolation.lerp(adjustedTapValue, tapValue, t) / tapValue;
2467
+ return osuBase.Interpolation.lerp(adjustedTapDifficulty, tapDifficulty, t) / tapDifficulty;
2359
2468
  }
2360
2469
  getHitWindow() {
2361
2470
  const { overallDifficulty } = this.difficultyAttributes;
@@ -2948,7 +3057,7 @@ class DroidDifficultyHitObject extends DifficultyHitObject {
2948
3057
  return this.normalizedRadius * 2;
2949
3058
  }
2950
3059
  get smallCircleBonus() {
2951
- return 1 + Math.pow(Math.max(0, 65 - this.object.radius) / 40, 2);
3060
+ return 1 + Math.pow(Math.max(0, 62.5 - this.object.radius) / 30, 1.5);
2952
3061
  }
2953
3062
  opacityAt(time, mods) {
2954
3063
  // Traceable hides the primary piece of a hit circle (that is, its body), so consider it as fully invisible.
@@ -3412,15 +3521,16 @@ class DroidScoreUtils {
3412
3521
  /**
3413
3522
  * Calculates the maximum possible spinner bonus for a given beatmap.
3414
3523
  *
3415
- * @param beatmap The beatmap to calculate the maximum spinner bonus for.
3524
+ * @param beatmap The `Beatmap` to calculate the maximum spinner bonus for.
3525
+ * @param playableBeatmap The `PlayableBeatmap` to calculate the maximum spinner bonus for.
3416
3526
  * @returns The maximum spinner bonus.
3417
3527
  */
3418
- static calculateMaximumSpinnerBonus(beatmap) {
3419
- const { hitObjects } = beatmap;
3528
+ static calculateMaximumSpinnerBonus(beatmap, playableBeatmap) {
3529
+ const { hitObjects } = playableBeatmap;
3420
3530
  if (hitObjects.spinners === 0) {
3421
3531
  return 0;
3422
3532
  }
3423
- const scoreMultiplier = osuBase.ModUtil.calculateScoreMultiplier(beatmap.mods.values(), osuBase.Modes.Droid);
3533
+ const scoreMultiplier = new osuBase.DroidScoreMultiplierCalculator(beatmap.difficulty).calculateFor(playableBeatmap.mods.values());
3424
3534
  let bonus = 0;
3425
3535
  // In osu!droid, there is no time-based limit to spinner RPM, since the limit is
3426
3536
  // π/2 rad/*frame* and not rad/second.
@@ -3429,7 +3539,7 @@ class DroidScoreUtils {
3429
3539
  // the actual maximum spinner bonus.
3430
3540
  const maximumRotationsPerSecond = (Math.PI / 2) * 120;
3431
3541
  // Taken from https://github.com/osudroid/osu-droid/blob/45ae4d66ce275382c5de037245ceca8704b3ae75/src/ru/nsu/ccfit/zuev/osu/game/GameScene.java#L1640.
3432
- const minimumRotationsPerSecond = 2 + (2 * beatmap.difficulty.od) / 10;
3542
+ const minimumRotationsPerSecond = 2 + (2 * playableBeatmap.difficulty.od) / 10;
3433
3543
  for (const obj of hitObjects.objects) {
3434
3544
  if (!(obj instanceof osuBase.Spinner)) {
3435
3545
  continue;
@@ -3472,8 +3582,9 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
3472
3582
  attributes.overallDifficulty = playableBeatmap.difficulty.od;
3473
3583
  // Cap at 32-bit signed integer since that's the maximum score that can be submitted
3474
3584
  // to the game's leaderboards.
3475
- attributes.maximumScore = Math.min(beatmap.maxDroidScore(playableBeatmap.mods) +
3476
- DroidScoreUtils.calculateMaximumSpinnerBonus(playableBeatmap), 2147483647);
3585
+ attributes.maximumScore =
3586
+ beatmap.maxDroidScore(playableBeatmap.mods) +
3587
+ DroidScoreUtils.calculateMaximumSpinnerBonus(beatmap, playableBeatmap);
3477
3588
  this.populateAimAttributes(attributes, skills, objects);
3478
3589
  this.populateTapAttributes(attributes, skills, objects);
3479
3590
  this.populateRhythmAttributes(attributes, skills);
@@ -4525,9 +4636,14 @@ class OsuSpeedEvaluator {
4525
4636
  if (current.object instanceof osuBase.Spinner) {
4526
4637
  return 0;
4527
4638
  }
4528
- let strainTime = current.strainTime;
4529
- // Nerf doubletappable doubles.
4530
4639
  const doubletapness = 1 - current.getDoubletapness(current.next(0));
4640
+ let difficulty = osuBase.MathUtils.millisecondsToBPM(current.strainTime);
4641
+ difficulty *= this.calculateSpeedBonus(current);
4642
+ // Apply penalty if there's doubletappable doubles
4643
+ return difficulty * doubletapness;
4644
+ }
4645
+ static calculateSpeedBonus(current) {
4646
+ let { strainTime } = current;
4531
4647
  // Cap deltatime to the OD 300 hitwindow.
4532
4648
  // 0.93 is derived from making sure 260 BPM 1/4 OD8 streams aren't nerfed harshly, whilst 0.92 limits the effect of the cap.
4533
4649
  strainTime /= osuBase.MathUtils.clamp(strainTime / current.hitWindowFor(osuBase.HitResult.Great) / 0.93, 0.92, 1);
@@ -4541,14 +4657,7 @@ class OsuSpeedEvaluator {
4541
4657
  strainTime) /
4542
4658
  40, 2);
4543
4659
  }
4544
- // Base difficulty with all bonuses
4545
- let difficulty = ((1 + speedBonus) * 1000) / strainTime;
4546
- difficulty *= this.highBpmBonus(current.strainTime);
4547
- // Apply penalty if there's doubletappable doubles
4548
- return difficulty * doubletapness;
4549
- }
4550
- static highBpmBonus(ms) {
4551
- return 1 / (1 - Math.pow(0.3, ms / 1000));
4660
+ return (1 + speedBonus) / strainTime;
4552
4661
  }
4553
4662
  }
4554
4663
  // ~200 1/4 BPM streams
@@ -4852,7 +4961,7 @@ class OsuSpeed extends HarmonicSkill {
4852
4961
  this.harmonicScale = 20;
4853
4962
  this.currentDifficulty = 0;
4854
4963
  this.currentRhythm = 0;
4855
- this.skillMultiplier = 1.16;
4964
+ this.skillMultiplier = 66.2;
4856
4965
  this.strainDecayBase = 0.3;
4857
4966
  this.sliderDifficulties = [];
4858
4967
  this.maxDifficulty = 0;
@@ -5048,7 +5157,7 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
5048
5157
  1.3 +
5049
5158
  this.totalHits *
5050
5159
  (0.0016 / (1 + 2 * this._effectiveMissCount)) *
5051
- Math.pow(this.computedAccuracy.value(), 16) *
5160
+ Math.pow(this.computedAccuracy.value, 16) *
5052
5161
  (1 -
5053
5162
  0.003 *
5054
5163
  Math.pow(this.difficultyAttributes.drainRate, 2));
@@ -5059,7 +5168,7 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
5059
5168
  this.calculateTraceableBonus(this.difficultyAttributes.sliderFactor);
5060
5169
  }
5061
5170
  // Scale the aim value with accuracy.
5062
- aimValue *= this.computedAccuracy.value();
5171
+ aimValue *= this.computedAccuracy.value;
5063
5172
  return aimValue;
5064
5173
  }
5065
5174
  /**
@@ -5070,7 +5179,8 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
5070
5179
  this.speedDeviation === Number.POSITIVE_INFINITY) {
5071
5180
  return 0;
5072
5181
  }
5073
- let speedValue = OsuSpeed.difficultyToPerformance(this.difficultyAttributes.speedDifficulty);
5182
+ const speedDifficulty = this.difficultyAttributes.speedDifficulty * this.calculateSpeedHighDeviationNerf();
5183
+ let speedValue = OsuSpeed.difficultyToPerformance(speedDifficulty);
5074
5184
  if (this._effectiveMissCount > 0) {
5075
5185
  const speedEstimatedSliderBreaks = this.calculateEstimatedSliderBreaks(this.difficultyAttributes.speedTopWeightedSliderFactor);
5076
5186
  const relevantMissCount = Math.min(this._effectiveMissCount + speedEstimatedSliderBreaks, this.totalImperfectHits + this.sliderTicksMissed);
@@ -5080,10 +5190,9 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
5080
5190
  // Increasing the speed value by object count for Blinds is not ideal, so the minimum buff is given.
5081
5191
  speedValue *= 1.12;
5082
5192
  }
5083
- speedValue *= this.calculateSpeedHighDeviationNerf();
5084
5193
  // An effective hit window is created based on the speed SR. The higher the speed difficulty, the shorter the hit window.
5085
5194
  // For example, a speed SR of 4 leads to an effective hit window of 20ms, which is OD 10.
5086
- const effectiveHitWindow = 20 * Math.pow(4 / this.difficultyAttributes.speedDifficulty, 0.35);
5195
+ const effectiveHitWindow = 20 * Math.pow(4 / speedDifficulty, 0.35);
5087
5196
  // Find the proportion of 300s on speed notes assuming the hit window was the effective hit window.
5088
5197
  const effectiveAccuracy = osuBase.ErrorFunction.erf(effectiveHitWindow / this.speedDeviation);
5089
5198
  // Scale speed value by normalized accuracy.
@@ -5108,7 +5217,7 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
5108
5217
  // Considering to use derivation from perfect accuracy in a probabilistic manner - assume normal distribution
5109
5218
  let accuracyValue = Math.pow(1.52163, this.overallDifficulty) *
5110
5219
  // It is possible to reach a negative accuracy with this formula. Cap it at zero - zero points.
5111
- Math.pow(realAccuracy.n300 < 0 ? 0 : realAccuracy.value(), 24) *
5220
+ Math.pow(realAccuracy.n300 < 0 ? 0 : realAccuracy.value, 24) *
5112
5221
  2.83;
5113
5222
  // Bonus for many hitcircles - it's harder to keep good accuracy up for longer.
5114
5223
  accuracyValue *= Math.pow(ncircles / 1000, ncircles < 1000 ? 0.3 : 0.1);
@@ -5142,7 +5251,7 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
5142
5251
  Math.pow(this.effectiveMissCount / this.totalHits, 0.775), Math.pow(this.effectiveMissCount, 0.875));
5143
5252
  }
5144
5253
  // Scale the flashlight value with accuracy slightly.
5145
- flashlightValue *= 0.5 + this.computedAccuracy.value() / 2;
5254
+ flashlightValue *= 0.5 + this.computedAccuracy.value / 2;
5146
5255
  return flashlightValue;
5147
5256
  }
5148
5257
  /**
@@ -5155,7 +5264,7 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
5155
5264
  readingValue *= this.calculateMissPenalty(this.effectiveMissCount + aimEstimatedSliderBreaks, this.difficultyAttributes.readingDifficultNoteCount);
5156
5265
  }
5157
5266
  // Scale the reading value with accuracy _harshly_.
5158
- readingValue *= Math.pow(this.computedAccuracy.value(), 3);
5267
+ readingValue *= Math.pow(this.computedAccuracy.value, 3);
5159
5268
  return readingValue;
5160
5269
  }
5161
5270
  /**
@@ -5255,21 +5364,22 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
5255
5364
  if (this.speedDeviation == Number.POSITIVE_INFINITY) {
5256
5365
  return 0;
5257
5366
  }
5258
- const speedValue = OsuSpeed.difficultyToPerformance(this.difficultyAttributes.speedDifficulty);
5259
- // Decide a point where the PP value achieved compared to the speed deviation is assumed to be tapped
5260
- // improperly. Any PP above this point is considered "excess" speed difficulty. This is used to cause
5261
- // PP above the cutoff to scale logarithmically towards the original speed value thus nerfing the value.
5262
- const excessSpeedDifficultyCutoff = 100 + 220 * Math.pow(22 / this.speedDeviation, 6.5);
5263
- if (speedValue <= excessSpeedDifficultyCutoff) {
5367
+ const { speedDifficulty } = this.difficultyAttributes;
5368
+ // Decides a point where the difficulty played compared to the speed deviation is assumed to be tapped improperly.
5369
+ // Any difficulty above this point is considered "excess" speed difficulty.
5370
+ // This is used to cause difficulty above the cutoff to scale logarithmically towards the original speed value thus
5371
+ // nerfing the value.
5372
+ const excessSpeedDifficultyCutoff = 2.9 + 1.45 * Math.pow(22 / this.speedDeviation, 5);
5373
+ if (speedDifficulty <= excessSpeedDifficultyCutoff) {
5264
5374
  return 1;
5265
5375
  }
5266
- const scale = 50;
5267
- const adjustedSpeedValue = scale *
5268
- (Math.log((speedValue - excessSpeedDifficultyCutoff) / scale + 1) +
5376
+ const scale = 0.45;
5377
+ const adjustedSpeedDifficulty = scale *
5378
+ (Math.log((speedDifficulty - excessSpeedDifficultyCutoff) / scale + 1) +
5269
5379
  excessSpeedDifficultyCutoff / scale);
5270
5380
  // 220 UR and less are considered tapped correctly to ensure that normal scores will be punished as little as possible
5271
5381
  const t = 1 - osuBase.Interpolation.reverseLerp(this.speedDeviation, 22, 27);
5272
- return (osuBase.Interpolation.lerp(adjustedSpeedValue, speedValue, t) / speedValue);
5382
+ return (osuBase.Interpolation.lerp(adjustedSpeedDifficulty, speedDifficulty, t) / speedDifficulty);
5273
5383
  }
5274
5384
  calculateEstimatedSliderBreaks(topWeightedSliderFactor) {
5275
5385
  const nonMissMistakes = this.computedAccuracy.n100 + this.computedAccuracy.n50;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rian8337/osu-rebalance-difficulty-calculator",
3
- "version": "4.0.0-beta.96",
3
+ "version": "4.0.0-beta.98",
4
4
  "description": "A module for calculating osu!standard beatmap difficulty and performance value with respect to the latest osu!lazer difficulty and performance algorithm.",
5
5
  "keywords": [
6
6
  "osu",
@@ -33,10 +33,10 @@
33
33
  "url": "https://github.com/Rian8337/osu-droid-module/issues"
34
34
  },
35
35
  "dependencies": {
36
- "@rian8337/osu-base": "4.0.0-beta.96"
36
+ "@rian8337/osu-base": "4.0.0-beta.98"
37
37
  },
38
38
  "publishConfig": {
39
39
  "access": "public"
40
40
  },
41
- "gitHead": "13af8d35ad74141c270c6b985941b5f2a14e248b"
41
+ "gitHead": "0d1f9256f0caee5123379cf5a8b3c92d1dcfa7bf"
42
42
  }
@@ -450,6 +450,34 @@ declare abstract class Skill {
450
450
  protected abstract processInternal(current: DifficultyHitObject): number;
451
451
  }
452
452
 
453
+ /**
454
+ * Wraps a `DifficultyAttributes` object and adds a time value for which the attribute is valid.
455
+ *
456
+ * Output by `DifficultyCalculator.calculateTimed` methods.
457
+ */
458
+ interface TimedDifficultyAttributes<TAttributes extends DifficultyAttributes> {
459
+ /**
460
+ * The non-clock-adjusted time value at which the attributes take effect.
461
+ */
462
+ readonly time: number;
463
+ /**
464
+ * The attributes.
465
+ */
466
+ readonly attributes: TAttributes;
467
+ /**
468
+ * The number of sliders in the beatmap up to this point.
469
+ */
470
+ readonly sliderCount: number;
471
+ /**
472
+ * The number of slider ticks in the beatmap up to this point.
473
+ */
474
+ readonly sliderTickCount: number;
475
+ /**
476
+ * The number of slider repeats in the beatmap up to this point.
477
+ */
478
+ readonly sliderRepeatCount: number;
479
+ }
480
+
453
481
  /**
454
482
  * The base of a difficulty calculator.
455
483
  */
@@ -488,6 +516,15 @@ declare abstract class DifficultyCalculator<TBeatmap extends PlayableBeatmap, TH
488
516
  * @returns The strain peaks of the `Beatmap`.
489
517
  */
490
518
  calculateStrainPeaks(beatmap: Beatmap, mods?: ModMap): StrainPeaks;
519
+ /**
520
+ * Calculates the difficulty of a `Beatmap` with specific `Mod`s and returns a set of
521
+ * `TimedDifficultyAttributes` representing the difficulty at every relevant time value in the `Beatmap`.
522
+ *
523
+ * @param beatmap The `Beatmap` whose difficulty is to be calculated.
524
+ * @param mods The `Mod`s to apply to the `Beatmap`.
525
+ * @return The set of `TimedDifficultyAttributes`.
526
+ */
527
+ calculateTimed(beatmap: Beatmap, mods?: ModMap): TimedDifficultyAttributes<TAttributes>[];
491
528
  /**
492
529
  * Creates the `Skill`s to calculate the difficulty of a `PlayableBeatmap`.
493
530
  *
@@ -1162,7 +1199,7 @@ declare abstract class DroidTapEvaluator {
1162
1199
  * @param considerCheesability Whether to consider cheesability.
1163
1200
  */
1164
1201
  static evaluateDifficultyOf(current: DroidDifficultyHitObject, considerCheesability: boolean): number;
1165
- private static highBpmBonus;
1202
+ private static calculateSpeedBonus;
1166
1203
  }
1167
1204
 
1168
1205
  /**
@@ -1353,7 +1390,7 @@ declare abstract class OsuSpeedEvaluator {
1353
1390
  * @param current The current object.
1354
1391
  */
1355
1392
  static evaluateDifficultyOf(current: OsuDifficultyHitObject): number;
1356
- private static highBpmBonus;
1393
+ private static calculateSpeedBonus;
1357
1394
  }
1358
1395
 
1359
1396
  /**
@@ -2049,4 +2086,4 @@ declare class OsuSpeed extends HarmonicSkill {
2049
2086
  }
2050
2087
 
2051
2088
  export { DifficultyAttributes, DifficultyCalculator, DifficultyHitObject, DroidAgilityEvaluator, DroidAim, DroidDifficultyAttributes, DroidDifficultyCalculator, DroidDifficultyHitObject, DroidFlashlight, DroidFlashlightEvaluator, DroidFlowAimEvaluator, DroidPerformanceCalculator, DroidReading, DroidReadingEvaluator, DroidRhythm, DroidRhythmEvaluator, DroidSnapAimEvaluator, DroidTap, DroidTapEvaluator, ExtendedDroidDifficultyAttributes, OsuAgilityEvaluator, OsuAim, OsuDifficultyAttributes, OsuDifficultyCalculator, OsuDifficultyHitObject, OsuFlashlight, OsuFlashlightEvaluator, OsuFlowAimEvaluator, OsuPerformanceCalculator, OsuReading, OsuReadingEvaluator, OsuRhythmEvaluator, OsuSnapAimEvaluator, OsuSpeed, OsuSpeedEvaluator, PerformanceCalculator };
2052
- export type { CacheableDifficultyAttributes, DifficultSlider, HighStrainSection, IDifficultyAttributes, IDroidDifficultyAttributes, IExtendedDroidDifficultyAttributes, IOsuDifficultyAttributes, PerformanceCalculationOptions, StrainPeaks, TimedStrainPeak };
2089
+ export type { CacheableDifficultyAttributes, DifficultSlider, HighStrainSection, IDifficultyAttributes, IDroidDifficultyAttributes, IExtendedDroidDifficultyAttributes, IOsuDifficultyAttributes, PerformanceCalculationOptions, StrainPeaks, TimedDifficultyAttributes, TimedStrainPeak };