Skip to content

Commit

Permalink
Fix minBaseDamage input and healingmodel
Browse files Browse the repository at this point in the history
  • Loading branch information
1337LutZ committed Aug 20, 2024
1 parent bad483b commit ac9cb0d
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 12 deletions.
6 changes: 6 additions & 0 deletions proto/common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,12 @@ message Cooldowns {
}

message HealingModel {
// Proto version at the time these healing settings were saved. If you
// make any changes to this proto that will break saved browser data or
// old sim links, then make sure to increment the current_version_number
// option within the ProtoVersion message at the top of this file, and
// also modify the updateHealingModelProtoVersion() method of ui/core/player.ts.
int32 api_version = 6;
// Healing per second to apply.
double hps = 1;
// How often healing is applied.
Expand Down
16 changes: 8 additions & 8 deletions ui/core/components/encounter_picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ class TargetPicker extends Input<Encounter, TargetProto> {
this.statPickers = ALL_TARGET_STATS.map(statData => {
const stat = statData.stat;
return new NumberPicker(section2, null, {
id: `target-picker-stats-${statData.stat}`,
id: `target-${this.targetIndex}-picker-stats-${statData.stat}`,
inline: true,
extraCssClasses: statData.extraCssClasses,
label: getStatName(stat),
Expand All @@ -399,7 +399,7 @@ class TargetPicker extends Input<Encounter, TargetProto> {
});

this.swingSpeedPicker = new NumberPicker(section3, null, {
id: 'target-picker-swing-speed',
id: `target-${this.targetIndex}-picker-swing-speed`,
label: 'Swing Speed',
labelTooltip: 'Time in seconds between auto attacks. Set to 0 to disable auto attacks.',
float: true,
Expand All @@ -411,7 +411,7 @@ class TargetPicker extends Input<Encounter, TargetProto> {
},
});
this.minBaseDamagePicker = new NumberPicker(section3, null, {
id: 'target-picker-min-base-damage',
id: `target-${this.targetIndex}-picker-min-base-damage`,
label: 'Min Base Damage',
labelTooltip: 'Base damage for auto attacks, i.e. lowest roll with 0 AP against a 0-armor Player.',
changedEvent: () => encounter.targetsChangeEmitter,
Expand All @@ -422,7 +422,7 @@ class TargetPicker extends Input<Encounter, TargetProto> {
},
});
this.damageSpreadPicker = new NumberPicker(section3, null, {
id: 'target-picker-damage-spread',
id: `target-${this.targetIndex}-picker-damage-spread`,
label: 'Damage Spread',
labelTooltip: 'Fractional spread between the minimum and maximum auto-attack damage from this enemy at 0 Attack Power.',
float: true,
Expand All @@ -434,7 +434,7 @@ class TargetPicker extends Input<Encounter, TargetProto> {
},
});
this.dualWieldPicker = new BooleanPicker(section3, null, {
id: 'target-picker-dual-wield',
id: `target-${this.targetIndex}-picker-dual-wield`,
label: 'Dual Wield',
labelTooltip: 'Uses 2 separate weapons to attack.',
inline: true,
Expand All @@ -447,7 +447,7 @@ class TargetPicker extends Input<Encounter, TargetProto> {
},
});
this.dwMissPenaltyPicker = new BooleanPicker(section3, null, {
id: 'target-picker-dw-miss-penalty',
id: `target-${this.targetIndex}-picker-dw-miss-penalty`,
label: 'DW Miss Penalty',
labelTooltip:
'Enables the Dual Wield Miss Penalty (+19% chance to miss) if dual wielding. Bosses in Hyjal/BT/SWP usually have this disabled to stop tanks from avoidance stacking.',
Expand All @@ -462,7 +462,7 @@ class TargetPicker extends Input<Encounter, TargetProto> {
enableWhen: () => this.getTarget().dualWield,
});
this.parryHastePicker = new BooleanPicker(section3, null, {
id: 'target-picker-parry-haste',
id: `target-${this.targetIndex}-picker-parry-haste`,
label: 'Parry Haste',
labelTooltip: 'Whether this enemy will gain parry haste when parrying attacks.',
inline: true,
Expand All @@ -475,7 +475,7 @@ class TargetPicker extends Input<Encounter, TargetProto> {
},
});
this.spellSchoolPicker = new EnumPicker<null>(section3, null, {
id: 'target-picker-spell-school',
id: `target-${this.targetIndex}-picker-spell-school`,
label: 'Spell School',
labelTooltip: 'Type of damage caused by auto attacks. This is usually Physical, but some enemies have elemental attacks.',
values: [
Expand Down
8 changes: 4 additions & 4 deletions ui/core/encounter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class Encounter {
}

get primaryTarget(): TargetProto {
return TargetProto.clone(this.targets[0]);
return this.targets[0];
}

getDurationVariation(): number {
Expand Down Expand Up @@ -200,11 +200,11 @@ export class Encounter {

static updateProtoVersion(proto: EncounterProto) {
let showOutOfDateEncounterTargetWarning = false;
proto.targets.forEach(target => {
proto.targets.forEach((target, index) => {
// If the old target is detected return the
// new default target without needing to migrate the stats
if (target.minBaseDamage === 65000) {
target = Encounter.defaultTargetProto();
proto.targets[index] = Encounter.defaultTargetProto();
showOutOfDateEncounterTargetWarning = true;
return;
}
Expand All @@ -222,7 +222,7 @@ export class Encounter {
new Toast({
delay: 5000,
variant: 'info',
body: 'We detected an out-of-date encounter target with WOTLK settings. It has been updated it to the latest version.',
body: 'We detected an out-of-date encounter target with WOTLK settings. Encounter settings have been updated the latest defaults.',
});
}
}
15 changes: 15 additions & 0 deletions ui/core/player.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Toast from './components/toast';
import * as Mechanics from './constants/mechanics';
import { CURRENT_API_VERSION } from './constants/other';
import { MAX_PARTY_SIZE, Party } from './party';
import { PlayerClass } from './player_class';
import { PlayerSpec } from './player_spec';
Expand Down Expand Up @@ -1505,6 +1506,11 @@ export class Player<SpecType extends Spec> {
fromProto(eventID: EventID, proto: PlayerProto, includeCategories?: Array<SimSettingCategories>) {
const loadCategory = (cat: SimSettingCategories) => !includeCategories || includeCategories.length == 0 || includeCategories.includes(cat);

// Fix out-of-date protos before importing
if (proto.healingModel && proto.healingModel.apiVersion < CURRENT_API_VERSION) {
Player.updateHealingModelProtoVersion(proto);
}

TypedEvent.freezeAllAndDo(() => {
if (loadCategory(SimSettingCategories.Gear)) {
this.setGear(eventID, proto.equipment ? this.sim.db.lookupEquipmentSpec(proto.equipment) : new Gear({}));
Expand Down Expand Up @@ -1548,6 +1554,15 @@ export class Player<SpecType extends Spec> {
});
}

static updateHealingModelProtoVersion(proto: PlayerProto) {
// API version null -> 3: Added new encounter target defaults
// This means we should reset the healing model to prevent incorrect behavior
// due to automatic defaults being calculated based on encounter target stats.
if (proto.healingModel && proto.healingModel.apiVersion < 3) {
proto.healingModel = HealingModel.create();
}
}

clone(eventID: EventID): Player<SpecType> {
const newPlayer = new Player<SpecType>(this.playerSpec, this.sim);
newPlayer.fromProto(eventID, this.toProto());
Expand Down

0 comments on commit ac9cb0d

Please sign in to comment.