Automatically add compromised condition when strife goes beyond max and remove...

This commit is contained in:
Putty
2025-09-06 07:38:10 +00:00
committed by GitLab
parent 7c3ef81dec
commit 7fed2f0a98
6 changed files with 23 additions and 9 deletions

View File

@@ -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) {

View File

@@ -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) {