@rian8337/osu-rebalance-difficulty-calculator 4.0.0-beta.92 → 4.0.0-beta.93

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
@@ -223,8 +223,17 @@ class Skill {
223
223
  get objectDifficulties() {
224
224
  return this._objectDifficulties;
225
225
  }
226
+ /**
227
+ * The start times of {@link DifficultyHitObject}s, populated by {@link Skill.process}.
228
+ *
229
+ * Indices correspond to {@link objectDifficulties}.
230
+ */
231
+ get objectTimes() {
232
+ return this._objectTimes;
233
+ }
226
234
  constructor(mods) {
227
235
  this._objectDifficulties = [];
236
+ this._objectTimes = [];
228
237
  this.mods = mods;
229
238
  }
230
239
  /**
@@ -240,6 +249,7 @@ class Skill {
240
249
  const difficultyValue = this.processInternal(current);
241
250
  this.saveToHitObject(current, difficultyValue);
242
251
  this._objectDifficulties.push(difficultyValue);
252
+ this._objectTimes.push(current.startTime);
243
253
  }
244
254
  /**
245
255
  * Saves the calculated difficulty to a {@link DifficultyHitObject}.
@@ -276,6 +286,12 @@ class VariableLengthStrainSkill extends Skill {
276
286
  this.currentSectionEnd = 0;
277
287
  this.totalLength = 0;
278
288
  this.strainPeaks = [];
289
+ /**
290
+ * The peaks of this skill in chronological order, used for graphing purposes.
291
+ *
292
+ * Unlike {@link strainPeaks}, this is never trimmed, as it does not contribute to {@link difficultyValue}.
293
+ */
294
+ this.chronologicalPeaks = [];
279
295
  /**
280
296
  * Stores previous strains so that, if a difficult {@link DifficultyHitObject} is followed by an easier
281
297
  * {@link DifficultyHitObject}, the difficult one gets a full strain instead of being cut short.
@@ -294,7 +310,10 @@ class VariableLengthStrainSkill extends Skill {
294
310
  return 11 / (1 - this.decayWeight);
295
311
  }
296
312
  get peaks() {
297
- return this.currentStrainPeaks.map((s) => s.value);
313
+ return this.chronologicalPeaks.concat({
314
+ time: this.currentSectionEnd,
315
+ value: this.currentSectionPeak,
316
+ });
298
317
  }
299
318
  static difficultyToPerformance(difficulty) {
300
319
  return 4 * Math.pow(difficulty, 3);
@@ -442,6 +461,10 @@ class VariableLengthStrainSkill extends Skill {
442
461
  */
443
462
  saveCurrentPeak(sectionLength) {
444
463
  this.addStrainPeakInPlace(new StrainPeak(this.currentSectionPeak, sectionLength));
464
+ this.chronologicalPeaks.push({
465
+ time: this.currentSectionBegin + sectionLength,
466
+ value: this.currentSectionPeak,
467
+ });
445
468
  this.totalLength += sectionLength;
446
469
  // Remove from the front of our strain peaks if there is any which are too deep to contribute to difficulty.
447
470
  // `maxStoredSections` dictates for us how many sections will preserve at least 99.999% of difficulty.
@@ -1095,6 +1118,7 @@ class StrainSkill extends Skill {
1095
1118
  this.reducedSectionBaseline = 0.75;
1096
1119
  this._objectStrains = [];
1097
1120
  this.strainPeaks = [];
1121
+ this.strainPeakTimes = [];
1098
1122
  this.sectionLength = 400;
1099
1123
  this.currentStrain = 0;
1100
1124
  this.currentSectionPeak = 0;
@@ -1107,7 +1131,9 @@ class StrainSkill extends Skill {
1107
1131
  return this._objectStrains;
1108
1132
  }
1109
1133
  get peaks() {
1110
- return this.currentStrainPeaks;
1134
+ return this.strainPeaks
1135
+ .map((value, i) => ({ time: this.strainPeakTimes[i], value }))
1136
+ .concat({ time: this.currentSectionEnd, value: this.currentSectionPeak });
1111
1137
  }
1112
1138
  /**
1113
1139
  * Converts a difficulty value to a performance value.
@@ -1175,6 +1201,7 @@ class StrainSkill extends Skill {
1175
1201
  */
1176
1202
  saveCurrentPeak() {
1177
1203
  this.strainPeaks.push(this.currentSectionPeak);
1204
+ this.strainPeakTimes.push(this.currentSectionEnd);
1178
1205
  }
1179
1206
  /**
1180
1207
  * Sets the initial strain level for a new section.
@@ -1273,7 +1300,7 @@ class DroidFlashlight extends DroidSkill {
1273
1300
  return sum;
1274
1301
  }
1275
1302
  calculateAdjustedDifficulty(current) {
1276
- let difficulty = Math.pow(DroidFlashlightEvaluator.evaluateDifficultyOf(current, this.mods), 0.8);
1303
+ let difficulty = Math.pow(DroidFlashlightEvaluator.evaluateDifficultyOf(current, this.mods), 0.9);
1277
1304
  if (this.mods.has(osuBase.ModRelax)) {
1278
1305
  difficulty *= 0.7;
1279
1306
  }
@@ -1317,7 +1344,10 @@ class HarmonicSkill extends Skill {
1317
1344
  return this._noteWeightSum;
1318
1345
  }
1319
1346
  get peaks() {
1320
- return this.objectDifficulties;
1347
+ return this.objectDifficulties.map((value, i) => ({
1348
+ time: this.objectTimes[i],
1349
+ value,
1350
+ }));
1321
1351
  }
1322
1352
  static difficultyToPerformance(difficulty) {
1323
1353
  return 4 * Math.pow(difficulty, 3);
@@ -2451,12 +2481,6 @@ class DifficultyHitObject {
2451
2481
  get angle() {
2452
2482
  return this.angleSigned !== null ? Math.abs(this.angleSigned) : null;
2453
2483
  }
2454
- /**
2455
- * This {@link DifficultyHitObject}'s immediate overall difficulty value calculated from the raw hitwindow.
2456
- */
2457
- get overallDifficulty() {
2458
- return this.rawHitWindow.overallDifficulty;
2459
- }
2460
2484
  /**
2461
2485
  * The normalized diameter of the hitobject.
2462
2486
  */
@@ -2876,6 +2900,16 @@ class DroidDifficultyHitObject extends DifficultyHitObject {
2876
2900
  this.normalizedRadius = 50;
2877
2901
  this.mode = osuBase.Modes.Droid;
2878
2902
  }
2903
+ get overallDifficulty() {
2904
+ const { rawHitWindow } = this;
2905
+ const greatWindow = rawHitWindow.greatWindow / this.clockRate;
2906
+ if (rawHitWindow instanceof osuBase.PreciseDroidHitWindow) {
2907
+ return osuBase.PreciseDroidHitWindow.greatWindowToOD(greatWindow);
2908
+ }
2909
+ else {
2910
+ return osuBase.DroidHitWindow.greatWindowToOD(greatWindow);
2911
+ }
2912
+ }
2879
2913
  get maximumSliderRadius() {
2880
2914
  return this.normalizedRadius * 2;
2881
2915
  }
@@ -3129,9 +3163,15 @@ class DroidRhythmEvaluator {
3129
3163
  // Scale down the difficulty if the object is doubletappable.
3130
3164
  effectiveRatio *=
3131
3165
  1 - prevObject.getDoubletapness(currentObject) * 0.75;
3132
- rhythmComplexitySum +=
3133
- Math.sqrt(effectiveRatio * startRatio) *
3134
- currentHistoricalDecay;
3166
+ if (island.deltaCount > 1) {
3167
+ rhythmComplexitySum +=
3168
+ Math.sqrt(effectiveRatio * startRatio) *
3169
+ currentHistoricalDecay;
3170
+ }
3171
+ else {
3172
+ // Constant difficulty for single-note islands.
3173
+ rhythmComplexitySum += 0.7 * currentHistoricalDecay;
3174
+ }
3135
3175
  startRatio = effectiveRatio;
3136
3176
  previousIsland = island;
3137
3177
  if (prevDelta + deltaDifferenceEpsilon < currentDelta) {
@@ -3390,9 +3430,10 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
3390
3430
  attributes.sliderCount = playableBeatmap.hitObjects.sliders;
3391
3431
  attributes.spinnerCount = playableBeatmap.hitObjects.spinners;
3392
3432
  attributes.overallDifficulty = playableBeatmap.difficulty.od;
3393
- attributes.maximumScore =
3394
- beatmap.maxDroidScore(playableBeatmap.mods) +
3395
- DroidScoreUtils.calculateMaximumSpinnerBonus(playableBeatmap);
3433
+ // Cap at 32-bit signed integer since that's the maximum score that can be submitted
3434
+ // to the game's leaderboards.
3435
+ attributes.maximumScore = Math.min(beatmap.maxDroidScore(playableBeatmap.mods) +
3436
+ DroidScoreUtils.calculateMaximumSpinnerBonus(playableBeatmap), 2147483647);
3396
3437
  this.populateAimAttributes(attributes, skills, objects);
3397
3438
  this.populateTapAttributes(attributes, skills, objects);
3398
3439
  this.populateRhythmAttributes(attributes, skills);
@@ -3465,8 +3506,9 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
3465
3506
  attributes.aimDifficultSliderCount = aim.countDifficultSliders();
3466
3507
  attributes.aimDifficultStrainCount =
3467
3508
  aim.countTopWeightedStrains(aimDifficultyValue);
3468
- const aimNoSliderTopWeightedSliderCount = aimNoSlider.countTopWeightedSliders(aimDifficultyValue);
3469
- const aimNoSliderDifficultStrainCount = aimNoSlider.countTopWeightedStrains(aimDifficultyValue);
3509
+ const aimNoSliderDifficultyValue = aimNoSlider.difficultyValue();
3510
+ const aimNoSliderTopWeightedSliderCount = aimNoSlider.countTopWeightedSliders(aimNoSliderDifficultyValue);
3511
+ const aimNoSliderDifficultStrainCount = aimNoSlider.countTopWeightedStrains(aimNoSliderDifficultyValue);
3470
3512
  attributes.aimTopWeightedSliderFactor =
3471
3513
  aimNoSliderTopWeightedSliderCount /
3472
3514
  Math.max(1, aimNoSliderDifficultStrainCount -
@@ -3501,7 +3543,8 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
3501
3543
  }
3502
3544
  if (attributes.aimDifficulty > 0) {
3503
3545
  attributes.sliderFactor =
3504
- this.calculateAimDifficultyRating(aimNoSlider.difficultyValue()) / this.calculateAimDifficultyRating(aimDifficultyValue);
3546
+ this.calculateAimDifficultyRating(aimNoSliderDifficultyValue) /
3547
+ this.calculateAimDifficultyRating(aimDifficultyValue);
3505
3548
  }
3506
3549
  else {
3507
3550
  attributes.sliderFactor = 1;
@@ -4362,9 +4405,15 @@ class OsuRhythmEvaluator {
4362
4405
  // Scale down the difficulty if the object is doubletappable.
4363
4406
  effectiveRatio *=
4364
4407
  1 - prevObject.getDoubletapness(currentObject) * 0.75;
4365
- rhythmComplexitySum +=
4366
- Math.sqrt(effectiveRatio * startRatio) *
4367
- currentHistoricalDecay;
4408
+ if (island.deltaCount > 1) {
4409
+ rhythmComplexitySum +=
4410
+ Math.sqrt(effectiveRatio * startRatio) *
4411
+ currentHistoricalDecay;
4412
+ }
4413
+ else {
4414
+ // Constant difficulty for single-note islands.
4415
+ rhythmComplexitySum += 0.7 * currentHistoricalDecay;
4416
+ }
4368
4417
  startRatio = effectiveRatio;
4369
4418
  previousIsland = island;
4370
4419
  if (prevDelta + deltaDifferenceEpsilon < currentDelta) {
@@ -4804,6 +4853,7 @@ class OsuSpeed extends HarmonicSkill {
4804
4853
  this.skillMultiplier;
4805
4854
  this.currentRhythm = OsuRhythmEvaluator.evaluateDifficultyOf(current);
4806
4855
  const difficulty = this.currentDifficulty * this.currentRhythm;
4856
+ this.maxDifficulty = Math.max(this.maxDifficulty, difficulty);
4807
4857
  if (current.object instanceof osuBase.Slider) {
4808
4858
  this.sliderDifficulties.push(difficulty);
4809
4859
  }
@@ -4979,15 +5029,10 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
4979
5029
  const relevantMissCount = Math.min(this._effectiveMissCount + speedEstimatedSliderBreaks, this.totalImperfectHits + this.sliderTicksMissed);
4980
5030
  speedValue *= this.calculateMissPenalty(relevantMissCount, this.difficultyAttributes.speedDifficultStrainCount);
4981
5031
  }
4982
- // Traceable bonuses are excluded when Blinds is present, as the increased visual difficulty is
4983
- // redundant when notes cannot be seen.
4984
5032
  if (this.mods.has(osuBase.ModBlinds)) {
4985
5033
  // Increasing the speed value by object count for Blinds is not ideal, so the minimum buff is given.
4986
5034
  speedValue *= 1.12;
4987
5035
  }
4988
- else if (this.mods.has(osuBase.ModTraceable)) {
4989
- speedValue *= 1 + this.calculateTraceableBonus();
4990
- }
4991
5036
  speedValue *= this.calculateSpeedHighDeviationNerf();
4992
5037
  // An effective hit window is created based on the speed SR. The higher the speed difficulty, the shorter the hit window.
4993
5038
  // For example, a speed SR of 4 leads to an effective hit window of 20ms, which is OD 10.
@@ -5005,7 +5050,7 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
5005
5050
  if (this.mods.has(osuBase.ModRelax)) {
5006
5051
  return 0;
5007
5052
  }
5008
- const ncircles = this.mods.has(osuBase.ModScoreV2)
5053
+ const ncircles = !this.usingClassicSliderAccuracy || this.mods.has(osuBase.ModScoreV2)
5009
5054
  ? this.totalHits - this.difficultyAttributes.spinnerCount
5010
5055
  : this.difficultyAttributes.hitCircleCount;
5011
5056
  if (ncircles === 0) {
@@ -5314,6 +5359,10 @@ class OsuDifficultyHitObject extends DifficultyHitObject {
5314
5359
  get smallCircleBonus() {
5315
5360
  return Math.max(1, 1 + (30 - this.object.radius) / 70);
5316
5361
  }
5362
+ get overallDifficulty() {
5363
+ const hitWindowGreat = this.hitWindowFor(osuBase.HitResult.Great) / 2;
5364
+ return (79.5 - hitWindowGreat) / 6;
5365
+ }
5317
5366
  }
5318
5367
 
5319
5368
  /**
@@ -5401,7 +5450,7 @@ class OsuFlashlight extends OsuSkill {
5401
5450
  calculateAdjustedDifficulty(current) {
5402
5451
  let difficulty = OsuFlashlightEvaluator.evaluateDifficultyOf(current, this.mods);
5403
5452
  if (this.mods.has(osuBase.ModTouchDevice)) {
5404
- difficulty = Math.pow(difficulty, 0.8);
5453
+ difficulty = Math.pow(difficulty, 0.9);
5405
5454
  }
5406
5455
  if (this.mods.has(osuBase.ModMagnetised)) {
5407
5456
  const magnetisedStrength = this.mods.get(osuBase.ModMagnetised).attractionStrength.value;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rian8337/osu-rebalance-difficulty-calculator",
3
- "version": "4.0.0-beta.92",
3
+ "version": "4.0.0-beta.93",
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",
@@ -38,5 +38,5 @@
38
38
  "publishConfig": {
39
39
  "access": "public"
40
40
  },
41
- "gitHead": "102e7baf7e9179caf6b0e81cafb53d6e3a561184"
41
+ "gitHead": "9eee7ed61799bd3d1a9510e0491e7433932ba190"
42
42
  }
@@ -135,9 +135,10 @@ declare abstract class DifficultyHitObject {
135
135
  */
136
136
  abstract get smallCircleBonus(): number;
137
137
  /**
138
- * This {@link DifficultyHitObject}'s immediate overall difficulty value calculated from the raw hitwindow.
138
+ * This {@link DifficultyHitObject}'s immediate clock-rate adjusted overall difficulty
139
+ * value.
139
140
  */
140
- get overallDifficulty(): number;
141
+ abstract get overallDifficulty(): number;
141
142
  /**
142
143
  * Other hitobjects in the beatmap, including this hitobject.
143
144
  */
@@ -359,6 +360,20 @@ declare abstract class DifficultyAttributes implements IDifficultyAttributes {
359
360
  toString(): string;
360
361
  }
361
362
 
363
+ /**
364
+ * Represents a strain peak at a specific point in time.
365
+ */
366
+ interface TimedStrainPeak {
367
+ /**
368
+ * The time at which this peak occurs, in milliseconds.
369
+ */
370
+ readonly time: number;
371
+ /**
372
+ * The strain value of this peak.
373
+ */
374
+ readonly value: number;
375
+ }
376
+
362
377
  /**
363
378
  * Represents the strain peaks of various calculated difficulties.
364
379
  */
@@ -366,19 +381,19 @@ interface StrainPeaks {
366
381
  /**
367
382
  * The strain peaks of aim difficulty if sliders are considered.
368
383
  */
369
- aimWithSliders: readonly number[];
384
+ aimWithSliders: readonly TimedStrainPeak[];
370
385
  /**
371
386
  * The strain peaks of aim difficulty if sliders are not considered.
372
387
  */
373
- aimWithoutSliders: readonly number[];
388
+ aimWithoutSliders: readonly TimedStrainPeak[];
374
389
  /**
375
390
  * The strain peaks of speed difficulty.
376
391
  */
377
- speed: readonly number[];
392
+ speed: readonly TimedStrainPeak[];
378
393
  /**
379
394
  * The strain peaks of flashlight difficulty.
380
395
  */
381
- flashlight: readonly number[];
396
+ flashlight: readonly TimedStrainPeak[];
382
397
  }
383
398
 
384
399
  /**
@@ -386,9 +401,9 @@ interface StrainPeaks {
386
401
  */
387
402
  interface IHasPeakDifficulty {
388
403
  /**
389
- * The peak difficulties calculated by this `Skill`.
404
+ * The peak difficulties calculated by this `Skill`, in chronological order.
390
405
  */
391
- get peaks(): readonly number[];
406
+ get peaks(): readonly TimedStrainPeak[];
392
407
  }
393
408
 
394
409
  /**
@@ -400,10 +415,17 @@ declare abstract class Skill {
400
415
  */
401
416
  protected readonly mods: ModMap;
402
417
  private _objectDifficulties;
418
+ private _objectTimes;
403
419
  /**
404
420
  * The difficulties of {@link DifficultyHitObject}s, populated by {@link Skill.process}.
405
421
  */
406
422
  protected get objectDifficulties(): readonly number[];
423
+ /**
424
+ * The start times of {@link DifficultyHitObject}s, populated by {@link Skill.process}.
425
+ *
426
+ * Indices correspond to {@link objectDifficulties}.
427
+ */
428
+ protected get objectTimes(): readonly number[];
407
429
  constructor(mods: ModMap);
408
430
  /**
409
431
  * Calculates the strain value of a hitobject and stores the value in it.
@@ -655,6 +677,7 @@ declare class DroidDifficultyHitObject extends DifficultyHitObject {
655
677
  * The rhythm difficulty generated by the hitobject.
656
678
  */
657
679
  rhythmDifficulty: number;
680
+ get overallDifficulty(): number;
658
681
  readonly normalizedRadius = 50;
659
682
  protected readonly mode = Modes.Droid;
660
683
  protected get maximumSliderRadius(): number;
@@ -1154,6 +1177,7 @@ declare class OsuDifficultyHitObject extends DifficultyHitObject {
1154
1177
  */
1155
1178
  speedStrain: number;
1156
1179
  get smallCircleBonus(): number;
1180
+ get overallDifficulty(): number;
1157
1181
  readonly normalizedRadius = 50;
1158
1182
  protected readonly mode = Modes.Osu;
1159
1183
  }
@@ -1532,7 +1556,13 @@ declare abstract class VariableLengthStrainSkill extends Skill implements IHasPe
1532
1556
  private currentSectionEnd;
1533
1557
  private totalLength;
1534
1558
  private readonly strainPeaks;
1535
- get peaks(): readonly number[];
1559
+ /**
1560
+ * The peaks of this skill in chronological order, used for graphing purposes.
1561
+ *
1562
+ * Unlike {@link strainPeaks}, this is never trimmed, as it does not contribute to {@link difficultyValue}.
1563
+ */
1564
+ private readonly chronologicalPeaks;
1565
+ get peaks(): readonly TimedStrainPeak[];
1536
1566
  /**
1537
1567
  * Stores previous strains so that, if a difficult {@link DifficultyHitObject} is followed by an easier
1538
1568
  * {@link DifficultyHitObject}, the difficult one gets a full strain instead of being cut short.
@@ -1660,7 +1690,8 @@ declare abstract class StrainSkill extends Skill implements IHasPeakDifficulty {
1660
1690
  */
1661
1691
  get objectStrains(): readonly number[];
1662
1692
  private readonly strainPeaks;
1663
- get peaks(): readonly number[];
1693
+ private readonly strainPeakTimes;
1694
+ get peaks(): readonly TimedStrainPeak[];
1664
1695
  private readonly sectionLength;
1665
1696
  private currentStrain;
1666
1697
  private currentSectionPeak;
@@ -1785,7 +1816,7 @@ declare abstract class HarmonicSkill extends Skill implements IHasPeakDifficulty
1785
1816
  * Values closer to 1 decay faster, whilst lower values give more weight to easier {@link DifficultyHitObject}s.
1786
1817
  */
1787
1818
  protected readonly decayExponent: number;
1788
- get peaks(): readonly number[];
1819
+ get peaks(): readonly TimedStrainPeak[];
1789
1820
  static difficultyToPerformance(difficulty: number): number;
1790
1821
  difficultyValue(): number;
1791
1822
  /**
@@ -2013,4 +2044,4 @@ declare class OsuSpeed extends HarmonicSkill {
2013
2044
  }
2014
2045
 
2015
2046
  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 };
2016
- export type { CacheableDifficultyAttributes, DifficultSlider, HighStrainSection, IDifficultyAttributes, IDroidDifficultyAttributes, IExtendedDroidDifficultyAttributes, IOsuDifficultyAttributes, PerformanceCalculationOptions, StrainPeaks };
2047
+ export type { CacheableDifficultyAttributes, DifficultSlider, HighStrainSection, IDifficultyAttributes, IDroidDifficultyAttributes, IExtendedDroidDifficultyAttributes, IOsuDifficultyAttributes, PerformanceCalculationOptions, StrainPeaks, TimedStrainPeak };