mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-03-07 06:26:13 +01:00
Added vulnerable condition automation
This commit is contained in:
parent
3267f3f531
commit
c5cf2d8801
6 changed files with 67 additions and 2 deletions
|
|
@ -1031,7 +1031,8 @@
|
||||||
},
|
},
|
||||||
"vulnerable": {
|
"vulnerable": {
|
||||||
"name": "Vulnerable",
|
"name": "Vulnerable",
|
||||||
"description": "While a creature is Vulnerable, all rolls targeting them have advantage.\nA creature who is already Vulnerable can’t be made to take the condition again."
|
"description": "While a creature is Vulnerable, all rolls targeting them have advantage.\nA creature who is already Vulnerable can’t be made to take the condition again.",
|
||||||
|
"autoAppliedByLabel": "Max Stress"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"CountdownType": {
|
"CountdownType": {
|
||||||
|
|
@ -2556,6 +2557,10 @@
|
||||||
"gm": { "label": "GM" },
|
"gm": { "label": "GM" },
|
||||||
"players": { "label": "Players" }
|
"players": { "label": "Players" }
|
||||||
},
|
},
|
||||||
|
"vulnerableAutomation": {
|
||||||
|
"label": "Vulnerable Automation",
|
||||||
|
"hint": "Automatically apply the Vulnerable condition when a actor reaches max stress"
|
||||||
|
},
|
||||||
"countdownAutomation": {
|
"countdownAutomation": {
|
||||||
"label": "Countdown Automation",
|
"label": "Countdown Automation",
|
||||||
"hint": "Automatically progress countdowns based on their progression settings"
|
"hint": "Automatically progress countdowns based on their progression settings"
|
||||||
|
|
|
||||||
|
|
@ -202,7 +202,8 @@ export const conditions = () => ({
|
||||||
id: 'vulnerable',
|
id: 'vulnerable',
|
||||||
name: 'DAGGERHEART.CONFIG.Condition.vulnerable.name',
|
name: 'DAGGERHEART.CONFIG.Condition.vulnerable.name',
|
||||||
img: 'icons/magic/control/silhouette-fall-slip-prone.webp',
|
img: 'icons/magic/control/silhouette-fall-slip-prone.webp',
|
||||||
description: 'DAGGERHEART.CONFIG.Condition.vulnerable.description'
|
description: 'DAGGERHEART.CONFIG.Condition.vulnerable.description',
|
||||||
|
autoApplyFlagId: 'auto-vulnerable'
|
||||||
},
|
},
|
||||||
hidden: {
|
hidden: {
|
||||||
id: 'hidden',
|
id: 'hidden',
|
||||||
|
|
|
||||||
|
|
@ -17,4 +17,45 @@ export default class DhCreature extends BaseDataActor {
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get isAutoVulnerableActive() {
|
||||||
|
const vulnerableAppliedByOther = this.parent.effects.some(
|
||||||
|
x => x.statuses.has('vulnerable') && !x.flags.daggerheart?.autoApplyFlagId
|
||||||
|
);
|
||||||
|
return !vulnerableAppliedByOther;
|
||||||
|
}
|
||||||
|
|
||||||
|
async _preUpdate(changes, options, userId) {
|
||||||
|
const allowed = await super._preUpdate(changes, options, userId);
|
||||||
|
if (allowed === false) return;
|
||||||
|
|
||||||
|
const automationSettings = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Automation);
|
||||||
|
if (
|
||||||
|
automationSettings.vulnerableAutomation &&
|
||||||
|
this.parent.type !== 'companion' &&
|
||||||
|
changes.system?.resources?.stress?.value
|
||||||
|
) {
|
||||||
|
const { name, description, img, autoApplyFlagId } = CONFIG.DH.GENERAL.conditions().vulnerable;
|
||||||
|
const autoEffects = this.parent.effects.filter(
|
||||||
|
x => x.flags.daggerheart?.autoApplyFlagId === autoApplyFlagId
|
||||||
|
);
|
||||||
|
if (changes.system.resources.stress.value >= this.resources.stress.max) {
|
||||||
|
if (!autoEffects.length)
|
||||||
|
this.parent.createEmbeddedDocuments('ActiveEffect', [
|
||||||
|
{
|
||||||
|
name: game.i18n.localize(name),
|
||||||
|
description: game.i18n.localize(description),
|
||||||
|
img: img,
|
||||||
|
statuses: ['vulnerable'],
|
||||||
|
flags: { daggerheart: { autoApplyFlagId } }
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
} else if (this.resources.stress.value >= this.resources.stress.max) {
|
||||||
|
this.parent.deleteEmbeddedDocuments(
|
||||||
|
'ActiveEffect',
|
||||||
|
autoEffects.map(x => x.id)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,10 @@ export default class DhAutomation extends foundry.abstract.DataModel {
|
||||||
label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.hopeFear.players.label'
|
label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.hopeFear.players.label'
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
|
vulnerableAutomation: new fields.BooleanField({
|
||||||
|
initial: true,
|
||||||
|
label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.vulnerableAutomation.label'
|
||||||
|
}),
|
||||||
countdownAutomation: new fields.BooleanField({
|
countdownAutomation: new fields.BooleanField({
|
||||||
required: true,
|
required: true,
|
||||||
initial: true,
|
initial: true,
|
||||||
|
|
|
||||||
|
|
@ -934,10 +934,23 @@ export default class DhpActor extends Actor {
|
||||||
|
|
||||||
/** Get active effects */
|
/** Get active effects */
|
||||||
getActiveEffects() {
|
getActiveEffects() {
|
||||||
|
const conditions = CONFIG.DH.GENERAL.conditions();
|
||||||
const statusMap = new Map(foundry.CONFIG.statusEffects.map(status => [status.id, status]));
|
const statusMap = new Map(foundry.CONFIG.statusEffects.map(status => [status.id, status]));
|
||||||
|
const autoVulnerableActive = this.system.isAutoVulnerableActive;
|
||||||
return this.effects
|
return this.effects
|
||||||
.filter(x => !x.disabled)
|
.filter(x => !x.disabled)
|
||||||
.reduce((acc, effect) => {
|
.reduce((acc, effect) => {
|
||||||
|
/* Could be generalized if needed. Currently just related to Vulnerable */
|
||||||
|
const isAutoVulnerableEffect =
|
||||||
|
effect.flags.daggerheart?.autoApplyFlagId === conditions.vulnerable.autoApplyFlagId;
|
||||||
|
if (isAutoVulnerableEffect) {
|
||||||
|
if (!autoVulnerableActive) return acc;
|
||||||
|
|
||||||
|
effect.appliedBy = game.i18n.localize('DAGGERHEART.CONFIG.Condition.vulnerable.autoAppliedByLabel');
|
||||||
|
effect.isLockedCondition = true;
|
||||||
|
effect.condition = 'vulnerable';
|
||||||
|
}
|
||||||
|
|
||||||
acc.push(effect);
|
acc.push(effect);
|
||||||
|
|
||||||
const currentStatusActiveEffects = acc.filter(
|
const currentStatusActiveEffects = acc.filter(
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@
|
||||||
{{formGroup settingFields.schema.fields.summaryMessages.fields.effects value=settingFields._source.summaryMessages.effects localize=true}}
|
{{formGroup settingFields.schema.fields.summaryMessages.fields.effects value=settingFields._source.summaryMessages.effects localize=true}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{{formGroup settingFields.schema.fields.vulnerableAutomation value=settingFields._source.vulnerableAutomation localize=true}}
|
||||||
{{formGroup settingFields.schema.fields.countdownAutomation value=settingFields._source.countdownAutomation localize=true}}
|
{{formGroup settingFields.schema.fields.countdownAutomation value=settingFields._source.countdownAutomation localize=true}}
|
||||||
{{formGroup settingFields.schema.fields.actionPoints value=settingFields._source.actionPoints localize=true}}
|
{{formGroup settingFields.schema.fields.actionPoints value=settingFields._source.actionPoints localize=true}}
|
||||||
{{formGroup settingFields.schema.fields.hordeDamage value=settingFields._source.hordeDamage localize=true}}
|
{{formGroup settingFields.schema.fields.hordeDamage value=settingFields._source.hordeDamage localize=true}}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue