Damage Types

This commit is contained in:
Dapoolp 2025-07-11 17:26:11 +02:00
parent 081ebf5bb3
commit 4246e3c9b5
19 changed files with 112 additions and 34 deletions

View file

@ -99,13 +99,24 @@ export class DHDamageData extends foundry.abstract.DataModel {
return {
// ...super.defineSchema(),
base: new fields.BooleanField({ initial: false, readonly: true, label: 'Base' }),
type: new fields.StringField({
/* type: new fields.StringField({
choices: CONFIG.DH.GENERAL.damageTypes,
initial: 'physical',
label: 'Type',
nullable: false,
required: true
}),
}), */
type: new fields.SetField(
new fields.StringField({
choices: CONFIG.DH.GENERAL.damageTypes,
initial: 'physical',
nullable: false,
required: true
}),
{
label: 'Type'
}
),
resultBased: new fields.BooleanField({
initial: false,
label: 'DAGGERHEART.ACTIONS.Settings.resultBased.label'

View file

@ -180,7 +180,7 @@ export default class DHBaseAction extends foundry.abstract.DataModel {
const actorData = this.actor.getRollData(false);
// Remove when included directly in Actor getRollData
actorData.prof = actorData.proficiency?.value ?? 1;
actorData.prof = actorData.proficiency?.total ?? 1;
actorData.cast = actorData.spellcast?.value ?? 1;
actorData.result = data.roll?.total ?? 1;
/* actorData.scale = data.costs?.length

View file

@ -10,8 +10,9 @@ export default class DHDamageAction extends DHBaseAction {
}
async rollDamage(event, data) {
let formula = this.damage.parts.map(p => this.getFormulaValue(p, data).getFormula(this.actor)).join(' + ');
let formula = this.damage.parts.map(p => this.getFormulaValue(p, data).getFormula(this.actor)).join(' + '),
damageTypes = [...new Set(this.damage.parts.reduce((a,c) => a.concat([...c.type]), []))];
if (!formula || formula == '') return;
let roll = { formula: formula, total: formula },
bonusDamage = [];
@ -25,6 +26,7 @@ export default class DHDamageAction extends DHBaseAction {
hasSave: this.hasSave,
isCritical: data.system?.roll?.isCritical ?? false,
source: data.system?.source,
damageTypes,
event
};
if (this.hasSave) config.onSave = this.save.damageMod;
@ -32,7 +34,7 @@ export default class DHDamageAction extends DHBaseAction {
config.source.message = data._id;
config.directDamage = false;
}
roll = CONFIG.Dice.daggerheart.DamageRoll.build(config);
}
}

View file

@ -64,6 +64,7 @@ export default class DhpAdversary extends BaseDataActor {
damage: {
parts: [
{
type: ['physical'],
value: {
multiplier: 'flat'
}

View file

@ -3,7 +3,8 @@ import DHBaseActorSettings from "../../applications/sheets/api/actor-setting.mjs
const resistanceField = () =>
new foundry.data.fields.SchemaField({
resistance: new foundry.data.fields.BooleanField({ initial: false }),
immunity: new foundry.data.fields.BooleanField({ initial: false })
immunity: new foundry.data.fields.BooleanField({ initial: false }),
reduction: new foundry.data.fields.NumberField({ integer: true, initial: 0 })
});
/**
@ -41,8 +42,7 @@ export default class BaseDataActor extends foundry.abstract.TypeDataModel {
if(this.metadata.hasResistances)
schema.resistance = new fields.SchemaField({
physical: resistanceField(),
magical: resistanceField(),
resistance: new fields.NumberField({ integer: true, initial: 0 })
magical: resistanceField()
})
return schema;
}

View file

@ -67,7 +67,7 @@ export default class DhCompanion extends BaseDataActor {
damage: {
parts: [
{
multiplier: 'flat',
type: ['physical'],
value: {
dice: 'd6',
multiplier: 'flat'

View file

@ -56,6 +56,7 @@ export default class DHWeapon extends BaseDataItem {
damage: {
parts: [
{
type: ['physical'],
value: {
multiplier: 'prof',
dice: 'd8'