diff --git a/lang/en.json b/lang/en.json index 11afac01..e2c94509 100755 --- a/lang/en.json +++ b/lang/en.json @@ -99,6 +99,7 @@ "tier": { "label": "Tier" }, "type": { "label": "Type" } }, + "hordeDamage": "Horde Damage", "horderHp": "Horde/HP" }, "Character": { @@ -1214,6 +1215,7 @@ "damage": "Damage", "damageType": "Damage Type", "description": "Description", + "difficulty": "Difficulty", "duality": "Duality", "dualityRoll": "Duality Roll", "enabled": "Enabled", @@ -1224,7 +1226,11 @@ }, "fear": "Fear", "features": "Features", - "hitPoints": "Hit Points", + "hitPoints": { + "single": "Hit Point", + "plural": "Hit Points", + "short": "HP" + }, "hope": "Hope", "hordeHp": "Horde HP", "inactiveEffects": "Inactive Effects", @@ -1251,7 +1257,8 @@ "use": "Use", "used": "Used", "uses": "Uses", - "value": "Value" + "value": "Value", + "withThing": "With {thing}" }, "ITEMS": { "FIELDS": { diff --git a/module/data/action/damageAction.mjs b/module/data/action/damageAction.mjs index 388c5eb8..2a83f444 100644 --- a/module/data/action/damageAction.mjs +++ b/module/data/action/damageAction.mjs @@ -6,6 +6,13 @@ export default class DHDamageAction extends DHBaseAction { getFormulaValue(part, data) { let formulaValue = part.value; if (this.hasRoll && part.resultBased && data.system.roll.result.duality === -1) return part.valueAlt; + + const isAdversary = this.actor.type === 'adversary'; + if (isAdversary && this.actor.system.type === CONFIG.DH.ACTOR.adversaryTypes.horde.id) { + const halfHP = Math.ceil(this.actor.system.resources.hitPoints.max / 2); + if (this.actor.system.resources.hitPoints.value >= halfHP) return part.valueAlt; + } + return formulaValue; } @@ -21,7 +28,7 @@ export default class DHDamageAction extends DHBaseAction { bonusDamage = []; if (isNaN(formula)) formula = Roll.replaceFormulaData(formula, this.getRollData(systemData)); - + const config = { title: game.i18n.format('DAGGERHEART.UI.Chat.damageRoll.title', { damage: this.name }), roll: { formula }, diff --git a/module/data/actor/adversary.mjs b/module/data/actor/adversary.mjs index e77a4855..8a2d6d52 100644 --- a/module/data/actor/adversary.mjs +++ b/module/data/actor/adversary.mjs @@ -52,7 +52,7 @@ export default class DhpAdversary extends BaseDataActor { }) }), resources: new fields.SchemaField({ - hitPoints: resourceField(0, 'DAGGERHEART.GENERAL.hitPoints', true), + hitPoints: resourceField(0, 'DAGGERHEART.GENERAL.hitPoints.plural', true), stress: resourceField(0, 'DAGGERHEART.GENERAL.stress', true) }), attack: new ActionField({ @@ -109,4 +109,35 @@ export default class DhpAdversary extends BaseDataActor { get features() { return this.parent.items.filter(x => x.type === 'feature'); } + + async _preUpdate(changes, options, user) { + const allowed = await super._preUpdate(changes, options, user); + if (allowed === false) return false; + + if (this.type === CONFIG.DH.ACTOR.adversaryTypes.horde.id) { + if (changes.system?.resources?.hitPoints?.value) { + const halfHP = Math.ceil(this.resources.hitPoints.max / 2); + const newHitPoints = changes.system.resources.hitPoints.value; + const previouslyAboveHalf = this.resources.hitPoints.value < halfHP; + const loweredBelowHalf = previouslyAboveHalf && newHitPoints >= halfHP; + const raisedAboveHalf = !previouslyAboveHalf && newHitPoints < halfHP; + if (loweredBelowHalf) { + await this.parent.createEmbeddedDocuments('ActiveEffect', [ + { + name: game.i18n.localize('DAGGERHEART.CONFIG.AdversaryType.horde.label'), + img: 'icons/magic/movement/chevrons-down-yellow.webp' + } + ]); + } else if (raisedAboveHalf) { + const hordeEffects = this.parent.effects.filter( + x => x.name === game.i18n.localize('DAGGERHEART.CONFIG.AdversaryType.horde.label') + ); + await this.parent.deleteEmbeddedDocuments( + 'ActiveEffect', + hordeEffects.map(x => x.id) + ); + } + } + } + } } diff --git a/module/data/actor/character.mjs b/module/data/actor/character.mjs index 68901b35..804eabec 100644 --- a/module/data/actor/character.mjs +++ b/module/data/actor/character.mjs @@ -21,7 +21,7 @@ export default class DhCharacter extends BaseDataActor { return { ...super.defineSchema(), resources: new fields.SchemaField({ - hitPoints: resourceField(0, 'DAGGERHEART.GENERAL.hitPoints', true), + hitPoints: resourceField(0, 'DAGGERHEART.GENERAL.hitPoints.plural', true), stress: resourceField(6, 'DAGGERHEART.GENERAL.stress', true), hope: resourceField(6, 'DAGGERHEART.GENERAL.hope') }), diff --git a/module/data/item/class.mjs b/module/data/item/class.mjs index 4d951ed4..281b0a48 100644 --- a/module/data/item/class.mjs +++ b/module/data/item/class.mjs @@ -24,7 +24,7 @@ export default class DHClass extends BaseDataItem { integer: true, min: 1, initial: 5, - label: 'DAGGERHEART.GENERAL.hitPoints' + label: 'DAGGERHEART.GENERAL.hitPoints.plural' }), evasion: new fields.NumberField({ initial: 0, integer: true, label: 'DAGGERHEART.GENERAL.evasion' }), hopeFeatures: new ForeignDocumentUUIDArrayField({ type: 'Item' }), diff --git a/templates/actionTypes/damage.hbs b/templates/actionTypes/damage.hbs index cbd1f503..3c125bd7 100644 --- a/templates/actionTypes/damage.hbs +++ b/templates/actionTypes/damage.hbs @@ -1,7 +1,7 @@
- Damage + {{localize "DAGGERHEART.GENERAL.damage"}} {{#unless (eq path 'system.attack.')}}{{/unless}} {{#unless (or @root.isNPC path)}} @@ -23,6 +23,16 @@ {{/if}} {{formField ../fields.type value=dmg.type name=(concat ../path "damage.parts." index ".type") localize=true}} + {{#if ../horde}} +
+ {{localize "DAGGERHEART.ACTORS.Adversary.hordeDamage"}} +
+ {{formField ../fields.valueAlt.fields.flatMultiplier value=dmg.valueAlt.flatMultiplier name=(concat ../path "damage.parts." index ".valueAlt.flatMultiplier") label="Multiplier" classes="inline-child" }} + {{formField ../fields.valueAlt.fields.dice value=dmg.valueAlt.dice name=(concat ../path "damage.parts." index ".valueAlt.dice") classes="inline-child"}} + {{formField ../fields.valueAlt.fields.bonus value=dmg.valueAlt.bonus name=(concat ../path "damage.parts." index ".valueAlt.bonus") localize=true classes="inline-child"}} +
+
+ {{/if}} {{else}} {{#with (@root.getRealIndex index) as | realIndex |}}
@@ -33,11 +43,11 @@ {{#if (and (not @root.isNPC) @root.hasRoll (not dmg.base) dmg.resultBased)}}
- With Hope + {{localize "DAGGERHEART.GENERAL.withThing" thing=(localize "DAGGERHEART.GENERAL.hope")}} {{> formula fields=../../fields.value.fields type=../../fields.type dmg=dmg source=dmg.value target="value" realIndex=realIndex}}
- With Fear + {{localize "DAGGERHEART.GENERAL.withThing" thing=(localize "DAGGERHEART.GENERAL.fear")}} {{> formula fields=../../fields.valueAlt.fields type=../../fields.type dmg=dmg source=dmg.valueAlt target="valueAlt" realIndex=realIndex}}
diff --git a/templates/sheets-settings/adversary-settings/attack.hbs b/templates/sheets-settings/adversary-settings/attack.hbs index eb7183b2..6553d543 100644 --- a/templates/sheets-settings/adversary-settings/attack.hbs +++ b/templates/sheets-settings/adversary-settings/attack.hbs @@ -19,5 +19,5 @@ {{/if}} {{/if}}
- {{> 'systems/daggerheart/templates/actionTypes/damage.hbs' fields=systemFields.attack.fields.damage.fields.parts.element.fields source=document.system.attack.damage path="system.attack."}} + {{> 'systems/daggerheart/templates/actionTypes/damage.hbs' fields=systemFields.attack.fields.damage.fields.parts.element.fields source=document.system.attack.damage path="system.attack." horde=true}} \ No newline at end of file diff --git a/templates/sheets-settings/adversary-settings/details.hbs b/templates/sheets-settings/adversary-settings/details.hbs index 250d151c..2fc61e2c 100644 --- a/templates/sheets-settings/adversary-settings/details.hbs +++ b/templates/sheets-settings/adversary-settings/details.hbs @@ -19,7 +19,7 @@
- {{localize "DAGGERHEART.GENERAL.hitPoints"}} + {{localize "DAGGERHEART.GENERAL.hitPoints.plural"}} {{formGroup systemFields.resources.fields.hitPoints.fields.value value=document.system.resources.hitPoints.value label=(localize "DAGGERHEART.ACTORS.Adversary.FIELDS.resources.hitPoints.value.label")}} {{formGroup systemFields.resources.fields.hitPoints.fields.max value=document.system.resources.hitPoints.max}}
diff --git a/templates/sheets/actors/adversary/header.hbs b/templates/sheets/actors/adversary/header.hbs index 9b126f73..28c0d002 100644 --- a/templates/sheets/actors/adversary/header.hbs +++ b/templates/sheets/actors/adversary/header.hbs @@ -20,14 +20,14 @@ {{#if (eq source.system.type 'horde')}}
{{source.system.hordeHp}} - /HP + /{{localize "DAGGERHEART.GENERAL.hitPoints.short"}}
{{/if}}
- {{source.system.description}} + {{{source.system.description}}}
{{localize 'DAGGERHEART.ACTORS.Adversary.FIELDS.motivesAndTactics.label'}}: {{{source.system.motivesAndTactics}}} diff --git a/templates/sheets/actors/adversary/sidebar.hbs b/templates/sheets/actors/adversary/sidebar.hbs index 4ba2360b..5384504e 100644 --- a/templates/sheets/actors/adversary/sidebar.hbs +++ b/templates/sheets/actors/adversary/sidebar.hbs @@ -1,5 +1,5 @@
- {{source.system.description}} + {{{source.system.description}}}
{{localize 'DAGGERHEART.ACTORS.Environment.FIELDS.impulses.label'}}: {{{source.system.impulses}}} diff --git a/templates/ui/tooltip/adversary.hbs b/templates/ui/tooltip/adversary.hbs index 0c26ac29..0a95c1ac 100644 --- a/templates/ui/tooltip/adversary.hbs +++ b/templates/ui/tooltip/adversary.hbs @@ -23,7 +23,7 @@
- +
{{item.system.resources.hitPoints.max}}