Skip to content

Commit

Permalink
Modify characteristics as appropriate when OIHID changed dmdorman#232
Browse files Browse the repository at this point in the history
  • Loading branch information
aeauseth committed Nov 11, 2024
1 parent 6a2e388 commit 2a0d38e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 42 deletions.
39 changes: 0 additions & 39 deletions module/actor/actor-sheet.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -268,14 +268,6 @@ export class HeroSystemActorSheet extends ActorSheet {
);
await pdAttack._postUpload();

let {
defenseValue: _defenseValuePD,
resistantValue: _resistantValuePD /*impenetrableValue*/,
//damageReductionValue: _damageReductionValuePD,
//damageNegationValue: _damageNegationValuePD /*knockbackResistance*/,
// defenseTags: defenseTagsP,
} = determineDefense(this.actor, pdAttack, { suppressDeprecationWarn: true });

// New PD
const {
defenseValue: defenseValuePD,
Expand All @@ -284,12 +276,6 @@ export class HeroSystemActorSheet extends ActorSheet {
damageNegationValue: damageNegationValuePD,
defenseTags: defenseTagsPD,
} = getActorDefensesVsAttack(this.actor, pdAttack);
if (_defenseValuePD != defenseValuePD) {
console.warn("PD Defense mismatch", _defenseValuePD, defenseValuePD);
}
if (_resistantValuePD != resistantValuePD) {
console.warn("rPD Defense mismatch", _resistantValuePD, resistantValuePD);
}
defense.PD = defenseValuePD;
for (const tag of defenseTagsPD.filter((o) => o.operation === "add" && !o.options?.resistant)) {
defense.PDtags = `${defense.PDtags || ""}${tag.value.signedString()} ${tag.name} ${tag.shortDesc}\n`;
Expand Down Expand Up @@ -318,14 +304,6 @@ export class HeroSystemActorSheet extends ActorSheet {
);
await edAttack._postUpload();

let {
defenseValue: _defenseValueED,
resistantValue: _resistantValueED /* impenetrableValueE */,
//damageReductionValue: _damageReductionValueED,
//damageNegationValue: _damageNegationValueED /* knockbackResistanceE */,
// defenseTags: _defenseTagsE,
} = determineDefense(this.actor, edAttack, { suppressDeprecationWarn: true });

// New ED
const {
defenseValue: defenseValueED,
Expand All @@ -334,12 +312,6 @@ export class HeroSystemActorSheet extends ActorSheet {
damageNegationValue: damageNegationValueED,
defenseTags: defenseTagsED,
} = getActorDefensesVsAttack(this.actor, edAttack);
if (_defenseValueED != defenseValueED) {
console.warn("ED Defense mismatch", _defenseValueED, defenseValueED);
}
if (_resistantValueED != resistantValueED) {
console.warn("rED Defense mismatch", _defenseValueED, defenseValueED);
}
defense.ED = defenseValueED;
for (const tag of defenseTagsED.filter((o) => o.operation === "add" && !o.options?.resistant)) {
defense.EDtags = `${defense.EDtags || ""}${tag.value.signedString()} ${tag.name} ${tag.shortDesc}\n`;
Expand Down Expand Up @@ -369,14 +341,6 @@ export class HeroSystemActorSheet extends ActorSheet {
);
await mdAttack._postUpload();

let {
defenseValue: _defenseValueMD,
//resistantValue: _resistantValueMD /*impenetrableValueM*/,
//damageReductionValue: _damageReductionValueMD,
//damageNegationValue: _damageNegationValueMD /*knockbackResistanceM*/,
defenseTags: _defenseTagsMD,
} = determineDefense(this.actor, mdAttack, { suppressDeprecationWarn: true });

// New MD
const {
defenseValue: defenseValueMD,
Expand All @@ -385,9 +349,6 @@ export class HeroSystemActorSheet extends ActorSheet {
damageNegationValue: damageNegationValueMD,
defenseTags: defenseTagsMD,
} = getActorDefensesVsAttack(this.actor, mdAttack);
if (_defenseValueMD != defenseValueMD) {
console.warn("MD Defense mismatch", _defenseValueMD, defenseValueMD, _defenseTagsMD);
}
defense.MD = defenseValueMD;
for (const tag of defenseTagsMD.filter((o) => o.operation === "add" && !o.options?.resistant)) {
defense.MDtags = `${defense.MDtags || ""}${tag.value.signedString()} ${tag.name} ${tag.shortDesc}\n`;
Expand Down
24 changes: 21 additions & 3 deletions module/actor/actor.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,27 @@ export class HeroSystem6eActor extends Actor {
if (item.findModsByXmlid("OIHID")) {
await ae.update({ disabled: !data.system.heroicIdentity });

//TODO: Any characteristic bonuses likely remain.
//Need to simulate a toggle off, without actually toggling the power off.
//Similar when turn AE back on.
// Modify characteristics as appropriate
for (const change of ae.changes) {
if (change.key.match(/max$/) && change.mode === 2 && change.value > 0) {
const valueKey = change.key.replace(/.max$/, ".value");
let max = this;
valueKey.split(".").forEach((subPath) => {
max = max[subPath] || null;
});
if (parseInt(max || 0) > 0) {
if (ae.disabled) {
await this.update({
[valueKey]: max - parseInt(change.value),
});
} else {
await this.update({
[valueKey]: max + parseInt(change.value),
});
}
}
}
}
}
}
}
Expand Down

0 comments on commit 2a0d38e

Please sign in to comment.