diff --git a/system/scripts/actor.js b/system/scripts/actor.js index 05e842a..fe0cec0 100644 --- a/system/scripts/actor.js +++ b/system/scripts/actor.js @@ -125,6 +125,17 @@ export class ActorL5r5e extends Actor { }); } + /** @inheritDoc */ + async _preUpdate(changes, options, user) { + if (this.isCharacterType) { + // apply compromised condition if strife goes beyond max + const strife = changes.system?.strife?.value ?? this.system.strife.value; + const maxStrife = changes.system?.strife?.max ?? this.system.strife.max; + const isCompromised = strife > maxStrife; + await this.toggleStatusEffect('compromised', {active: isCompromised}); + } + } + /** @override */ prepareData() { super.prepareData(); @@ -137,13 +148,16 @@ export class ActorL5r5e extends Actor { ActorL5r5e.computeDerivedAttributes(system); } + const isAfflicted = this.statuses.has("afflicted"); + const isCompromised = this.statuses.has("compromised"); + // Attributes bars system.fatigue.max = system.endurance; system.strife.max = system.composure; system.void_points.max = system.rings.void; - // if compromise, vigilance = 1 - system.is_compromised = system.strife.value > system.strife.max; + // if compromised or afflicted, vigilance = 1 + system.is_afflicted_or_compromised = isAfflicted || isCompromised; // Make sure void points are never greater than max if (system.void_points.value > system.void_points.max) { diff --git a/system/scripts/combat.js b/system/scripts/combat.js index cb4fefd..fdd6739 100644 --- a/system/scripts/combat.js +++ b/system/scripts/combat.js @@ -62,7 +62,7 @@ export class CombatL5r5e extends Combat { // If the character was unprepared (such as when surprised), their base initiative value is their vigilance attribute. // Minion NPCs can generate initiative value without a check, using their focus or vigilance attribute let initiative = - isPrepared === "true" ? actorSystem.focus : actorSystem.is_compromised ? 1 : actorSystem.vigilance; + isPrepared === "true" ? actorSystem.focus : actorSystem.is_afflicted_or_compromised ? 1 : actorSystem.vigilance; // Roll only for PC and Adversary if (isPc || combatant.actor.isAdversary) { diff --git a/system/templates/actors/character/attributes.html b/system/templates/actors/character/attributes.html index 7d0db22..ed3bf0c 100644 --- a/system/templates/actors/character/attributes.html +++ b/system/templates/actors/character/attributes.html @@ -36,10 +36,10 @@
{{localize 'l5r5e.attributes.focustip'}}
-{{localize 'l5r5e.attributes.focustip'}}