direct damage (#873)

This commit is contained in:
Dapoulp 2025-08-12 18:37:16 +02:00 committed by GitHub
parent 6e747e67ee
commit 06184773b9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 37 additions and 14 deletions

View file

@ -177,6 +177,7 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
hasDamage: this.damage?.parts?.length && this.type !== 'healing',
hasHealing: this.damage?.parts?.length && this.type === 'healing',
hasEffect: !!this.effects?.length,
isDirect: !!this.damage?.direct,
hasSave: this.hasSave,
selectedRollMode: game.settings.get('core', 'rollMode'),
isFastForward: event.shiftKey,

View file

@ -29,6 +29,7 @@ export default class DHActorRoll extends foundry.abstract.TypeDataModel {
hasEffect: new fields.BooleanField({ initial: false }),
hasSave: new fields.BooleanField({ initial: false }),
hasTarget: new fields.BooleanField({ initial: false }),
isDirect: new fields.BooleanField({ initial: false }),
isCritical: new fields.BooleanField({ initial: false }),
onSave: new fields.StringField(),
source: new fields.SchemaField({

View file

@ -9,7 +9,8 @@ export default class DamageField extends fields.SchemaField {
includeBase: new fields.BooleanField({
initial: false,
label: 'DAGGERHEART.ACTIONS.Settings.includeBase.label'
})
}),
direct: new fields.BooleanField({ initial: false, label: "DAGGERHEART.CONFIG.DamageType.direct.name" })
};
super(damageFields, options, context);
}

View file

@ -517,7 +517,7 @@ export default class DhpActor extends Actor {
return canUseArmor || canUseStress;
}
async takeDamage(damages) {
async takeDamage(damages, isDirect = false) {
if (Hooks.call(`${CONFIG.DH.id}.preTakeDamage`, this, damages) === false) return null;
if (this.type === 'companion') {
@ -548,6 +548,7 @@ export default class DhpActor extends Actor {
hpDamage.value = this.convertDamageToThreshold(hpDamage.value);
if (
this.type === 'character' &&
!isDirect &&
this.system.armor &&
this.#canReduceDamage(hpDamage.value, hpDamage.damageTypes)
) {

View file

@ -138,7 +138,7 @@ export default class DhpChatMessage extends foundry.documents.ChatMessage {
this.consumeOnSuccess();
if (this.system.hasHealing) target.actor.takeHealing(damages);
else target.actor.takeDamage(damages);
else target.actor.takeDamage(damages, this.system.isDirect);
}
}