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