@rian8337/osu-rebalance-difficulty-calculator 4.0.0-beta.46 → 4.0.0-beta.47

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
@@ -832,14 +832,6 @@ class DroidAimEvaluator extends AimEvaluator {
832
832
  // Reward sliders based on velocity.
833
833
  sliderBonus = last.travelDistance / last.travelTime;
834
834
  }
835
- // Reduce snap aim difficulty for low spacing as the player is more likely to perform
836
- // a flowing movement instead of snapping to the object. This also prevents the weird
837
- // scenario of awarding flow aim difficulty in snap aim.
838
- const flowBonus = Math.pow(last.minimumJumpDistance / this.singleSpacingThreshold, 3.5);
839
- if (flowBonus < 1) {
840
- strain *= 0.5 * (1 + Math.sqrt(flowBonus));
841
- wideAngleBonus *= 0.5 * (1 + Math.sqrt(flowBonus));
842
- }
843
835
  strain += wiggleBonus * this.wiggleMultiplier;
844
836
  // Add in acute angle bonus or wide angle bonus + velocity change bonus, whichever is larger.
845
837
  strain += Math.max(acuteAngleBonus * this.acuteAngleMultiplier, wideAngleBonus * this.wideAngleMultiplier +
@@ -1043,12 +1035,11 @@ class DroidAim extends DroidSkill {
1043
1035
  if (this.sliderStrains.length === 0) {
1044
1036
  return 0;
1045
1037
  }
1046
- const sortedStrains = this.sliderStrains.sort((a, b) => b - a);
1047
- const maxSliderStrain = sortedStrains[0];
1038
+ const maxSliderStrain = Math.max(...this.sliderStrains);
1048
1039
  if (maxSliderStrain === 0) {
1049
1040
  return 0;
1050
1041
  }
1051
- return sortedStrains.reduce((total, strain) => total +
1042
+ return this.sliderStrains.reduce((total, strain) => total +
1052
1043
  1 / (1 + Math.exp(-((strain / maxSliderStrain) * 12 - 6))), 0);
1053
1044
  }
1054
1045
  strainValueAt(current) {
@@ -1401,8 +1392,9 @@ class DroidRhythmEvaluator {
1401
1392
  * with historic data of the current object.
1402
1393
  *
1403
1394
  * @param current The current object.
1395
+ * @param useSliderAccuracy Whether to use slider accuracy.
1404
1396
  */
1405
- static evaluateDifficultyOf(current) {
1397
+ static evaluateDifficultyOf(current, useSliderAccuracy) {
1406
1398
  if (current.object instanceof osuBase.Spinner) {
1407
1399
  return 1;
1408
1400
  }
@@ -1464,15 +1456,17 @@ class DroidRhythmEvaluator {
1464
1456
  island.addDelta(currentDelta);
1465
1457
  }
1466
1458
  else {
1467
- // BPM change is into slider, this is easy acc window.
1468
- if (currentObject.object instanceof osuBase.Slider) {
1469
- effectiveRatio /= 8;
1470
- }
1471
- // BPM change was from a slider, this is easier typically than circle -> circle.
1472
- // Unintentional side effect is that bursts with kicksliders at the ends might have lower difficulty
1473
- // than bursts without sliders.
1474
- if (prevObject.object instanceof osuBase.Slider) {
1475
- effectiveRatio *= 0.3;
1459
+ if (!useSliderAccuracy) {
1460
+ // BPM change is into slider, this is easy acc window.
1461
+ if (currentObject.object instanceof osuBase.Slider) {
1462
+ effectiveRatio /= 8;
1463
+ }
1464
+ // BPM change was from a slider, this is easier typically than circle -> circle.
1465
+ // Unintentional side effect is that bursts with kicksliders at the ends might have lower difficulty
1466
+ // than bursts without sliders.
1467
+ if (prevObject.object instanceof osuBase.Slider) {
1468
+ effectiveRatio *= 0.3;
1469
+ }
1476
1470
  }
1477
1471
  // Repeated island polarity (2 -> 4, 3 -> 5).
1478
1472
  if (island.isSimilarPolarity(previousIsland)) {
@@ -1555,18 +1549,19 @@ DroidRhythmEvaluator.rhythmRatioMultiplier = 12;
1555
1549
  * Represents the skill required to properly follow a beatmap's rhythm.
1556
1550
  */
1557
1551
  class DroidRhythm extends DroidSkill {
1558
- constructor() {
1559
- super(...arguments);
1552
+ constructor(mods) {
1553
+ super(mods);
1560
1554
  this.reducedSectionCount = 5;
1561
1555
  this.reducedSectionBaseline = 0.75;
1562
1556
  this.strainDecayBase = 0.3;
1563
1557
  this.starsPerDouble = 1.75;
1564
1558
  this.currentRhythmStrain = 0;
1565
1559
  this.currentRhythmMultiplier = 1;
1560
+ this.useSliderAccuracy = mods.some((m) => m instanceof osuBase.ModScoreV2);
1566
1561
  }
1567
1562
  strainValueAt(current) {
1568
1563
  this.currentRhythmMultiplier =
1569
- DroidRhythmEvaluator.evaluateDifficultyOf(current);
1564
+ DroidRhythmEvaluator.evaluateDifficultyOf(current, this.useSliderAccuracy);
1570
1565
  this.currentRhythmStrain *= this.strainDecay(current.deltaTime);
1571
1566
  this.currentRhythmStrain += this.currentRhythmMultiplier - 1;
1572
1567
  return this.currentRhythmStrain;
@@ -2159,12 +2154,10 @@ class PerformanceCalculator {
2159
2154
  * Nerf factor used for nerfing beatmaps with very likely dropped sliderends.
2160
2155
  */
2161
2156
  this.sliderNerfFactor = 1;
2162
- if (this.isCacheableAttribute(difficultyAttributes)) {
2163
- this.difficultyAttributes = Object.assign(Object.assign({}, difficultyAttributes), { mods: osuBase.ModUtil.pcStringToMods(difficultyAttributes.mods) });
2164
- }
2165
- else {
2166
- this.difficultyAttributes = osuBase.Utils.deepCopy(difficultyAttributes);
2167
- }
2157
+ this.difficultyAttributes = difficultyAttributes;
2158
+ this.mods = this.isCacheableAttribute(difficultyAttributes)
2159
+ ? osuBase.ModUtil.pcStringToMods(difficultyAttributes.mods)
2160
+ : difficultyAttributes.mods;
2168
2161
  }
2169
2162
  /**
2170
2163
  * Calculates the performance points of the beatmap.
@@ -2239,15 +2232,15 @@ class PerformanceCalculator {
2239
2232
  });
2240
2233
  }
2241
2234
  this.effectiveMissCount = this.calculateEffectiveMissCount(combo, maxCombo);
2242
- if (this.difficultyAttributes.mods.some((m) => m instanceof osuBase.ModNoFail)) {
2235
+ if (this.mods.some((m) => m instanceof osuBase.ModNoFail)) {
2243
2236
  this.finalMultiplier *= Math.max(0.9, 1 - 0.02 * this.effectiveMissCount);
2244
2237
  }
2245
- if (this.difficultyAttributes.mods.some((m) => m instanceof osuBase.ModSpunOut)) {
2238
+ if (this.mods.some((m) => m instanceof osuBase.ModSpunOut)) {
2246
2239
  this.finalMultiplier *=
2247
2240
  1 -
2248
2241
  Math.pow(this.difficultyAttributes.spinnerCount / this.totalHits, 0.85);
2249
2242
  }
2250
- if (this.difficultyAttributes.mods.some((m) => m instanceof osuBase.ModRelax)) {
2243
+ if (this.mods.some((m) => m instanceof osuBase.ModRelax)) {
2251
2244
  // Graph: https://www.desmos.com/calculator/bc9eybdthb
2252
2245
  // We use OD13.3 as maximum since it's the value at which great hit window becomes 0.
2253
2246
  const n100Multiplier = Math.max(0, this.difficultyAttributes.overallDifficulty > 0
@@ -2584,12 +2577,12 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
2584
2577
  * Calculates the accuracy performance value of the beatmap.
2585
2578
  */
2586
2579
  calculateAccuracyValue() {
2587
- if (this.difficultyAttributes.mods.some((m) => m instanceof osuBase.ModRelax) ||
2580
+ if (this.mods.some((m) => m instanceof osuBase.ModRelax) ||
2588
2581
  this.totalSuccessfulHits === 0) {
2589
2582
  return 0;
2590
2583
  }
2591
2584
  let accuracyValue = 650 * Math.exp(-0.1 * this._deviation);
2592
- const ncircles = this.difficultyAttributes.mods.some((m) => m instanceof osuBase.ModScoreV2)
2585
+ const ncircles = this.mods.some((m) => m instanceof osuBase.ModScoreV2)
2593
2586
  ? this.totalHits - this.difficultyAttributes.spinnerCount
2594
2587
  : this.difficultyAttributes.hitCircleCount;
2595
2588
  // Bonus for many hitcircles - it's harder to keep good accuracy up for longer.
@@ -2601,7 +2594,7 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
2601
2594
  Math.exp(-(this.difficultyAttributes.rhythmDifficulty - 1) / 2));
2602
2595
  // Penalize accuracy pp after the first miss.
2603
2596
  accuracyValue *= Math.pow(0.97, Math.max(0, this.effectiveMissCount - 1));
2604
- if (this.difficultyAttributes.mods.some((m) => m instanceof osuBase.ModFlashlight)) {
2597
+ if (this.mods.some((m) => m instanceof osuBase.ModFlashlight)) {
2605
2598
  accuracyValue *= 1.02;
2606
2599
  }
2607
2600
  return accuracyValue;
@@ -2610,7 +2603,7 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
2610
2603
  * Calculates the flashlight performance value of the beatmap.
2611
2604
  */
2612
2605
  calculateFlashlightValue() {
2613
- if (!this.difficultyAttributes.mods.some((m) => m instanceof osuBase.ModFlashlight)) {
2606
+ if (!this.mods.some((m) => m instanceof osuBase.ModFlashlight)) {
2614
2607
  return 0;
2615
2608
  }
2616
2609
  let flashlightValue = Math.pow(this.difficultyAttributes.flashlightDifficulty, 1.6) * 25;
@@ -2833,7 +2826,7 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
2833
2826
  }
2834
2827
  getConvertedHitWindow() {
2835
2828
  const hitWindow300 = new osuBase.OsuHitWindow(this.difficultyAttributes.overallDifficulty).greatWindow;
2836
- if (this.difficultyAttributes.mods.some((m) => m instanceof osuBase.ModPrecise)) {
2829
+ if (this.mods.some((m) => m instanceof osuBase.ModPrecise)) {
2837
2830
  return new osuBase.PreciseDroidHitWindow(osuBase.PreciseDroidHitWindow.greatWindowToOD(hitWindow300 * this.difficultyAttributes.clockRate));
2838
2831
  }
2839
2832
  else {
@@ -3714,7 +3707,7 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
3714
3707
  * Calculates the aim performance value of the beatmap.
3715
3708
  */
3716
3709
  calculateAimValue() {
3717
- if (this.difficultyAttributes.mods.some((m) => m instanceof osuBase.ModAutopilot)) {
3710
+ if (this.mods.some((m) => m instanceof osuBase.ModAutopilot)) {
3718
3711
  return 0;
3719
3712
  }
3720
3713
  let aimValue = this.baseValue(this.difficultyAttributes.aimDifficulty);
@@ -3734,7 +3727,7 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
3734
3727
  }
3735
3728
  aimValue *= this.calculateStrainBasedMissPenalty(this.difficultyAttributes.aimDifficultStrainCount);
3736
3729
  const calculatedAR = this.difficultyAttributes.approachRate;
3737
- if (!this.difficultyAttributes.mods.some((m) => m instanceof osuBase.ModRelax)) {
3730
+ if (!this.mods.some((m) => m instanceof osuBase.ModRelax)) {
3738
3731
  // AR scaling
3739
3732
  let arFactor = 0;
3740
3733
  if (calculatedAR > 10.33) {
@@ -3747,7 +3740,7 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
3747
3740
  aimValue *= 1 + arFactor * lengthBonus;
3748
3741
  }
3749
3742
  // We want to give more reward for lower AR when it comes to aim and HD. This nerfs high AR and buffs lower AR.
3750
- if (this.difficultyAttributes.mods.some((m) => m instanceof osuBase.ModHidden)) {
3743
+ if (this.mods.some((m) => m instanceof osuBase.ModHidden)) {
3751
3744
  aimValue *= 1 + 0.04 * (12 - calculatedAR);
3752
3745
  }
3753
3746
  // Scale the aim value with slider factor to nerf very likely dropped sliderends.
@@ -3763,7 +3756,7 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
3763
3756
  * Calculates the speed performance value of the beatmap.
3764
3757
  */
3765
3758
  calculateSpeedValue() {
3766
- if (this.difficultyAttributes.mods.some((m) => m instanceof osuBase.ModRelax)) {
3759
+ if (this.mods.some((m) => m instanceof osuBase.ModRelax)) {
3767
3760
  return 0;
3768
3761
  }
3769
3762
  let speedValue = this.baseValue(this.difficultyAttributes.speedDifficulty);
@@ -3777,11 +3770,11 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
3777
3770
  // AR scaling
3778
3771
  const calculatedAR = this.difficultyAttributes.approachRate;
3779
3772
  if (calculatedAR > 10.33 &&
3780
- !this.difficultyAttributes.mods.some((m) => m instanceof osuBase.ModAutopilot)) {
3773
+ !this.mods.some((m) => m instanceof osuBase.ModAutopilot)) {
3781
3774
  // Buff for longer maps with high AR.
3782
3775
  speedValue *= 1 + 0.3 * (calculatedAR - 10.33) * lengthBonus;
3783
3776
  }
3784
- if (this.difficultyAttributes.mods.some((m) => m instanceof osuBase.ModHidden)) {
3777
+ if (this.mods.some((m) => m instanceof osuBase.ModHidden)) {
3785
3778
  speedValue *= 1 + 0.04 * (12 - calculatedAR);
3786
3779
  }
3787
3780
  // Calculate accuracy assuming the worst case scenario.
@@ -3814,10 +3807,10 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
3814
3807
  * Calculates the accuracy performance value of the beatmap.
3815
3808
  */
3816
3809
  calculateAccuracyValue() {
3817
- if (this.difficultyAttributes.mods.some((m) => m instanceof osuBase.ModRelax)) {
3810
+ if (this.mods.some((m) => m instanceof osuBase.ModRelax)) {
3818
3811
  return 0;
3819
3812
  }
3820
- const ncircles = this.difficultyAttributes.mods.some((m) => m instanceof osuBase.ModScoreV2)
3813
+ const ncircles = this.mods.some((m) => m instanceof osuBase.ModScoreV2)
3821
3814
  ? this.totalHits - this.difficultyAttributes.spinnerCount
3822
3815
  : this.difficultyAttributes.hitCircleCount;
3823
3816
  if (ncircles === 0) {
@@ -3832,10 +3825,10 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
3832
3825
  2.83;
3833
3826
  // Bonus for many hitcircles - it's harder to keep good accuracy up for longer
3834
3827
  accuracyValue *= Math.min(1.15, Math.pow(ncircles / 1000, 0.3));
3835
- if (this.difficultyAttributes.mods.some((m) => m instanceof osuBase.ModHidden)) {
3828
+ if (this.mods.some((m) => m instanceof osuBase.ModHidden)) {
3836
3829
  accuracyValue *= 1.08;
3837
3830
  }
3838
- if (this.difficultyAttributes.mods.some((m) => m instanceof osuBase.ModFlashlight)) {
3831
+ if (this.mods.some((m) => m instanceof osuBase.ModFlashlight)) {
3839
3832
  accuracyValue *= 1.02;
3840
3833
  }
3841
3834
  return accuracyValue;
@@ -3844,7 +3837,7 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
3844
3837
  * Calculates the flashlight performance value of the beatmap.
3845
3838
  */
3846
3839
  calculateFlashlightValue() {
3847
- if (!this.difficultyAttributes.mods.some((m) => m instanceof osuBase.ModFlashlight)) {
3840
+ if (!this.mods.some((m) => m instanceof osuBase.ModFlashlight)) {
3848
3841
  return 0;
3849
3842
  }
3850
3843
  let flashlightValue = Math.pow(this.difficultyAttributes.flashlightDifficulty, 2) * 25;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rian8337/osu-rebalance-difficulty-calculator",
3
- "version": "4.0.0-beta.46",
3
+ "version": "4.0.0-beta.47",
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.44"
36
+ "@rian8337/osu-base": "^4.0.0-beta.47"
37
37
  },
38
38
  "publishConfig": {
39
39
  "access": "public"
40
40
  },
41
- "gitHead": "efe2ba882932f2de27ec1228a4931385049d0fb6"
41
+ "gitHead": "5d907d19c542a636041ed9a29c5a74c4f4c5501d"
42
42
  }
@@ -1026,7 +1026,11 @@ declare abstract class PerformanceCalculator<T extends DifficultyAttributes> {
1026
1026
  /**
1027
1027
  * The difficulty attributes that is being calculated.
1028
1028
  */
1029
- readonly difficultyAttributes: T;
1029
+ readonly difficultyAttributes: T | CacheableDifficultyAttributes<T>;
1030
+ /**
1031
+ * The mods that were used.
1032
+ */
1033
+ protected readonly mods: Mod[];
1030
1034
  /**
1031
1035
  * The global multiplier to be applied to the final performance value.
1032
1036
  *
@@ -1278,8 +1282,10 @@ declare class DroidRhythm extends DroidSkill {
1278
1282
  protected readonly reducedSectionBaseline = 0.75;
1279
1283
  protected readonly strainDecayBase = 0.3;
1280
1284
  protected readonly starsPerDouble = 1.75;
1285
+ private readonly useSliderAccuracy;
1281
1286
  private currentRhythmStrain;
1282
1287
  private currentRhythmMultiplier;
1288
+ constructor(mods: Mod[]);
1283
1289
  protected strainValueAt(current: DroidDifficultyHitObject): number;
1284
1290
  protected calculateInitialStrain(time: number, current: DroidDifficultyHitObject): number;
1285
1291
  protected getObjectStrain(): number;
@@ -1299,8 +1305,9 @@ declare abstract class DroidRhythmEvaluator {
1299
1305
  * with historic data of the current object.
1300
1306
  *
1301
1307
  * @param current The current object.
1308
+ * @param useSliderAccuracy Whether to use slider accuracy.
1302
1309
  */
1303
- static evaluateDifficultyOf(current: DroidDifficultyHitObject): number;
1310
+ static evaluateDifficultyOf(current: DroidDifficultyHitObject, useSliderAccuracy: boolean): number;
1304
1311
  }
1305
1312
 
1306
1313
  /**