From cdf6e7fdd0db9edf357ac165c2904d92368b89cb Mon Sep 17 00:00:00 2001 From: WBHarry <89362246+WBHarry@users.noreply.github.com> Date: Thu, 2 Jul 2026 01:00:36 +0200 Subject: [PATCH] [Feature] ActiveEffect Auras (#2049) * Added Attached type to action areas * Added functionality to Elemental Aura --- lang/en.json | 7 +- module/canvas/placeables/regionLayer.mjs | 9 +- module/config/actionConfig.mjs | 6 +- module/data/fields/action/areasField.mjs | 4 + module/documents/chatMessage.mjs | 13 +- module/enrichers/TemplateEnricher.mjs | 5 +- ...ature_Elemental_Aura_2JH9NaOh69yN80Gw.json | 265 +++++++++++------- styles/less/global/elements.less | 11 + templates/actionTypes/areas.hbs | 7 +- 9 files changed, 213 insertions(+), 114 deletions(-) diff --git a/lang/en.json b/lang/en.json index 3f21f5eb..0180b085 100755 --- a/lang/en.json +++ b/lang/en.json @@ -113,7 +113,8 @@ "area": { "sectionTitle": "Areas", "shape": "Shape", - "size": "Size" + "size": "Size", + "hasHole": "Area Hole" }, "displayInChat": "Display in chat", "deleteTriggerTitle": "Delete Trigger", @@ -870,6 +871,10 @@ "bruiser": "for each Bruiser adversary.", "solo": "for each Solo adversary." }, + "AreaTypes": { + "attached": { "label": "Attached To Token" }, + "placed": { "label": "Placed In Scene" } + }, "ArmorInteraction": { "none": { "label": "Ignores Armor" }, "active": { "label": "Active w/ Armor" }, diff --git a/module/canvas/placeables/regionLayer.mjs b/module/canvas/placeables/regionLayer.mjs index 684fdd5e..b71ccc3f 100644 --- a/module/canvas/placeables/regionLayer.mjs +++ b/module/canvas/placeables/regionLayer.mjs @@ -96,7 +96,7 @@ export default class DhRegionLayer extends foundry.canvas.layers.RegionLayer { return inBounds.length === 1 ? inBounds[0] : null; } - static getTemplateShape({ type, angle, range, direction } = {}) { + static getTemplateShape({ shapeType, angle, range, direction, hasHole } = {}) { const { line, rectangle, inFront, cone, circle, emanation } = CONFIG.DH.GENERAL.templateTypes; /* Length calculation */ @@ -112,11 +112,11 @@ export default class DhRegionLayer extends foundry.canvas.layers.RegionLayer { const shapeData = { ...canvas.mousePosition, - type: type, + type: shapeType, direction: direction ?? 0 }; - switch (type) { + switch (shapeType) { case rectangle.id: shapeData.width = length; shapeData.height = length; @@ -145,7 +145,8 @@ export default class DhRegionLayer extends foundry.canvas.layers.RegionLayer { y: 0, width: 1, height: 1, - shape: game.canvas.grid.isHexagonal ? CONST.TOKEN_SHAPES.ELLIPSE_1 : CONST.TOKEN_SHAPES.RECTANGLE_1 + shape: game.canvas.grid.isHexagonal ? CONST.TOKEN_SHAPES.ELLIPSE_1 : CONST.TOKEN_SHAPES.RECTANGLE_1, + hole: hasHole }; break; } diff --git a/module/config/actionConfig.mjs b/module/config/actionConfig.mjs index a6c04e18..e413a828 100644 --- a/module/config/actionConfig.mjs +++ b/module/config/actionConfig.mjs @@ -119,6 +119,10 @@ export const advantageState = { export const areaTypes = { placed: { id: 'placed', - label: 'Placed Area' + label: 'DAGGERHEART.CONFIG.AreaTypes.placed.label' + }, + attached: { + id: 'attached', + label: 'DAGGERHEART.CONFIG.AreaTypes.attached.label' } }; diff --git a/module/data/fields/action/areasField.mjs b/module/data/fields/action/areasField.mjs index 52110045..a4180101 100644 --- a/module/data/fields/action/areasField.mjs +++ b/module/data/fields/action/areasField.mjs @@ -33,6 +33,10 @@ export default class AreasField extends fields.ArrayField { initial: CONFIG.DH.GENERAL.range.veryClose.id, label: 'DAGGERHEART.ACTIONS.Config.area.size' }), + hasHole: new fields.BooleanField({ + initial: false, + label: 'DAGGERHEART.ACTIONS.Config.area.hasHole' + }), effects: new fields.ArrayField(new fields.DocumentIdField()) }); super(element, options, context); diff --git a/module/documents/chatMessage.mjs b/module/documents/chatMessage.mjs index b555dfca..fd68997c 100644 --- a/module/documents/chatMessage.mjs +++ b/module/documents/chatMessage.mjs @@ -276,8 +276,12 @@ export default class DhpChatMessage extends foundry.documents.ChatMessage { async onCreateAreas(event) { const createArea = async selectedArea => { const effects = selectedArea.effects.map(effect => this.system.action.item.effects.get(effect).uuid); - const { shape: type, size: range } = selectedArea; - const shapeData = CONFIG.Canvas.layers.regions.layerClass.getTemplateShape({ type, range }); + const { shape: shapeType, size: range, hasHole } = selectedArea; + const shapeData = CONFIG.Canvas.layers.regions.layerClass.getTemplateShape({ + shapeType, + range, + hasHole + }); const scene = game.scenes.get(game.user.viewedScene); const level = scene.levels.find(x => x.isView); @@ -305,7 +309,10 @@ export default class DhpChatMessage extends foundry.documents.ChatMessage { visibility: CONST.REGION_VISIBILITY.ALWAYS }; const placeRegion = data => { - canvas.regions.placeRegion(data, { create: true }); + canvas.regions.placeRegion(data, { + create: true, + attachToToken: selectedArea.type === CONFIG.DH.ACTIONS.areaTypes.attached.id + }); }; // Regions with effects must be placed by the GM diff --git a/module/enrichers/TemplateEnricher.mjs b/module/enrichers/TemplateEnricher.mjs index bbe93b17..4478ea14 100644 --- a/module/enrichers/TemplateEnricher.mjs +++ b/module/enrichers/TemplateEnricher.mjs @@ -58,10 +58,11 @@ export const renderMeasuredTemplate = async event => { if (!type || !range || !game.canvas.scene) return; const shapeData = CONFIG.Canvas.layers.regions.layerClass.getTemplateShape({ - type, + shapetype: type, angle, range, - direction + direction, + hasHole: false }); await canvas.regions.placeRegion( diff --git a/src/packs/subclasses/feature_Elemental_Aura_2JH9NaOh69yN80Gw.json b/src/packs/subclasses/feature_Elemental_Aura_2JH9NaOh69yN80Gw.json index 7a3ebd91..e0476a56 100644 --- a/src/packs/subclasses/feature_Elemental_Aura_2JH9NaOh69yN80Gw.json +++ b/src/packs/subclasses/feature_Elemental_Aura_2JH9NaOh69yN80Gw.json @@ -52,7 +52,7 @@ "includeBase": false }, "target": { - "type": "hostile", + "type": "", "amount": 1 }, "effects": [ @@ -63,13 +63,23 @@ ], "name": "Fire", "img": "icons/magic/fire/barrier-wall-explosion-orange.webp", - "range": "close" + "range": "", + "areas": [ + { + "name": "Elemental Aura: Fire", + "type": "attached", + "shape": "emanation", + "size": "close", + "hasHole": false, + "effects": [] + } + ] }, "xDBLH5TWidvrYF7z": { "type": "effect", "_id": "xDBLH5TWidvrYF7z", "systemPath": "actions", - "description": "
When an adversary marks 1 or more Hit Points, they must also mark a Stress.
", + "description": "Your allies gain a +1 bonus to Strength.
", "chatDisplay": true, "actionType": "action", "cost": [], @@ -78,19 +88,26 @@ "max": "", "recovery": null }, - "effects": [ - { - "_id": "WRuijfHxmUscAa69", - "onSave": false - } - ], + "effects": [], "target": { - "type": "friendly", + "type": "", "amount": null }, "name": "Earth", "img": "icons/magic/control/buff-strength-muscle-damage-red.webp", - "range": "close" + "range": "", + "areas": [ + { + "name": "Elemental Aura: Earth", + "type": "attached", + "shape": "emanation", + "size": "close", + "hasHole": true, + "effects": [ + "yvpWNCNobg0LLjey" + ] + } + ] }, "S4t5HlgxWlHwaBDw": { "type": "effect", @@ -112,12 +129,22 @@ } ], "target": { - "type": "hostile", + "type": "self", "amount": null }, "name": "Water", "img": "icons/magic/water/vortex-water-whirlpool.webp", - "range": "close" + "range": "self", + "areas": [ + { + "name": "Elemental Aura: Water", + "type": "attached", + "shape": "emanation", + "size": "close", + "hasHole": false, + "effects": [] + } + ] }, "hAsKFFewtTqd1gg9": { "type": "attack", @@ -138,15 +165,10 @@ "includeBase": false }, "target": { - "type": "any", + "type": "self", "amount": null }, - "effects": [ - { - "_id": "mJBA2QTyM9SM5NVS", - "onSave": false - } - ], + "effects": [], "roll": { "type": "diceSet", "trait": null, @@ -169,7 +191,19 @@ }, "name": "Air", "img": "icons/magic/air/air-burst-spiral-blue-gray.webp", - "range": "" + "range": "self", + "areas": [ + { + "name": "Elemental Aura: Air", + "type": "attached", + "shape": "emanation", + "size": "close", + "hasHole": false, + "effects": [ + "vnKV5hsO4DVjURAl" + ] + } + ] } }, "originItemType": null, @@ -181,49 +215,6 @@ } }, "effects": [ - { - "name": "Elemental Aura (Earth)", - "img": "icons/magic/control/buff-strength-muscle-damage-orange.webp", - "origin": "Compendium.daggerheart.subclasses.Item.2JH9NaOh69yN80Gw", - "transfer": false, - "_id": "WRuijfHxmUscAa69", - "type": "base", - "system": { - "rangeDependence": { - "enabled": false, - "type": "withinRange", - "target": "hostile", - "range": "melee" - } - }, - "changes": [ - { - "key": "system.traits.strength.value", - "mode": 2, - "value": "1", - "priority": null - } - ], - "disabled": false, - "duration": { - "startTime": null, - "combat": null, - "seconds": null, - "rounds": null, - "turns": null, - "startRound": null, - "startTurn": null - }, - "description": "", - "tint": "#ffffff", - "statuses": [], - "sort": 0, - "flags": {}, - "_stats": { - "compendiumSource": null - }, - "_key": "!items.effects!2JH9NaOh69yN80Gw.WRuijfHxmUscAa69" - }, { "name": "Elemental Aura (Water)", "img": "icons/magic/water/vortex-water-whirlpool.webp", @@ -237,18 +228,15 @@ "type": "withinRange", "target": "hostile", "range": "melee" - } + }, + "changes": [] }, - "changes": [], "disabled": false, "duration": { - "startTime": null, - "combat": null, - "seconds": null, - "rounds": null, - "turns": null, - "startRound": null, - "startTurn": null + "value": null, + "units": "seconds", + "expiry": null, + "expired": false }, "description": "", "tint": "#ffffff", @@ -258,6 +246,9 @@ "_stats": { "compendiumSource": null }, + "start": null, + "showIcon": 1, + "folder": null, "_key": "!items.effects!2JH9NaOh69yN80Gw.H7W52ps5d3UGmaFr" }, { @@ -273,18 +264,15 @@ "type": "withinRange", "target": "hostile", "range": "melee" - } + }, + "changes": [] }, - "changes": [], "disabled": false, "duration": { - "startTime": null, - "combat": null, - "seconds": null, - "rounds": null, - "turns": null, - "startRound": null, - "startTurn": null + "value": null, + "units": "seconds", + "expiry": null, + "expired": false }, "description": "", "tint": "#ffffff", @@ -294,43 +282,120 @@ "_stats": { "compendiumSource": null }, + "start": null, + "showIcon": 1, + "folder": null, "_key": "!items.effects!2JH9NaOh69yN80Gw.WX5AMEpmUAutB9Hm" }, { - "name": "Elemental Aura (Air)", - "img": "icons/magic/air/air-burst-spiral-blue-gray.webp", - "origin": "Compendium.daggerheart.subclasses.Item.2JH9NaOh69yN80Gw", + "name": "Elemental Aura: Earth", + "disabled": false, + "img": "icons/magic/control/buff-strength-muscle-damage-red.webp", + "description": "Your allies gain a +1 bonus to Strength.
", "transfer": false, - "_id": "mJBA2QTyM9SM5NVS", - "type": "base", + "statuses": [], "system": { "rangeDependence": { "enabled": false, "type": "withinRange", "target": "hostile", "range": "melee" - } + }, + "changes": [ + { + "key": "system.traits.strength.value", + "type": "add", + "value": 1, + "priority": null, + "phase": "initial" + } + ], + "duration": { + "description": "", + "type": "" + }, + "stacking": null, + "targetDispositions": [ + 1 + ] }, - "changes": [], - "disabled": false, - "duration": { - "startTime": null, + "_id": "yvpWNCNobg0LLjey", + "type": "base", + "start": { + "time": 0, "combat": null, - "seconds": null, - "rounds": null, - "turns": null, - "startRound": null, - "startTurn": null + "combatant": null, + "initiative": null, + "round": null, + "turn": null }, - "description": "", + "duration": { + "value": null, + "units": "seconds", + "expiry": null, + "expired": false + }, + "origin": null, "tint": "#ffffff", - "statuses": [], + "showIcon": 1, + "folder": null, "sort": 0, "flags": {}, "_stats": { "compendiumSource": null }, - "_key": "!items.effects!2JH9NaOh69yN80Gw.mJBA2QTyM9SM5NVS" + "_key": "!items.effects!2JH9NaOh69yN80Gw.yvpWNCNobg0LLjey" + }, + { + "name": "Elemental Aura: Air", + "disabled": false, + "img": "icons/magic/air/air-burst-spiral-blue-gray.webp", + "description": "When you or an ally takes damage from an attack beyond Melee range, reduce the damage by 1d8.
", + "transfer": false, + "statuses": [], + "system": { + "rangeDependence": { + "enabled": false, + "type": "withinRange", + "target": "hostile", + "range": "melee" + }, + "changes": [], + "duration": { + "description": "", + "type": "" + }, + "stacking": null, + "targetDispositions": [ + 1 + ] + }, + "_id": "vnKV5hsO4DVjURAl", + "type": "base", + "start": { + "time": 0, + "combat": null, + "combatant": null, + "initiative": null, + "round": null, + "turn": null + }, + "duration": { + "value": null, + "units": "seconds", + "expiry": null, + "expired": false + }, + "origin": null, + "tint": "#ffffff", + "showIcon": 1, + "folder": null, + "sort": 0, + "flags": {}, + "_stats": { + "compendiumSource": null + }, + "_key": "!items.effects!2JH9NaOh69yN80Gw.vnKV5hsO4DVjURAl" } ], "sort": 100000, diff --git a/styles/less/global/elements.less b/styles/less/global/elements.less index e57ba50d..df12eda4 100755 --- a/styles/less/global/elements.less +++ b/styles/less/global/elements.less @@ -384,6 +384,10 @@ justify-content: space-between; } + label { + white-space: nowrap; + } + .btn { padding-top: 15px; } @@ -399,6 +403,13 @@ > .checkbox { align-self: end; } + + .auto-sized { + width: auto; + display: flex; + flex-direction: column; + align-items: center; + } } .form-group { diff --git a/templates/actionTypes/areas.hbs b/templates/actionTypes/areas.hbs index 2e010c72..662716f5 100644 --- a/templates/actionTypes/areas.hbs +++ b/templates/actionTypes/areas.hbs @@ -11,9 +11,10 @@