Added Aura type to action areas

This commit is contained in:
WBHarry 2026-06-30 16:19:05 +02:00
parent 329d820aab
commit ab4fb6970f
8 changed files with 45 additions and 11 deletions

View file

@ -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": {
"aura": { "label": "Aura" },
"placed": { "label": "Placed Area" }
},
"ArmorInteraction": {
"none": { "label": "Ignores Armor" },
"active": { "label": "Active w/ Armor" },

View file

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

View file

@ -119,6 +119,10 @@ export const advantageState = {
export const areaTypes = {
placed: {
id: 'placed',
label: 'Placed Area'
label: 'DAGGERHEART.CONFIG.AreaTypes.placed.label'
},
aura: {
id: 'aura',
label: 'DAGGERHEART.CONFIG.AreaTypes.aura.label'
}
};

View file

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

View file

@ -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.aura.id
});
};
// Regions with effects must be placed by the GM

View file

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

View file

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

View file

@ -14,6 +14,7 @@
{{formField ../fields.type value=area.type name=(concat "areas." index ".type") localize=true}}
{{formField ../fields.shape value=area.shape name=(concat "areas." index ".shape") localize=true}}
{{formField ../fields.size value=area.size name=(concat "areas." index ".size") localize=true}}
{{formField ../fields.hasHole value=area.hasHole name=(concat "areas." index ".hasHole") localize=true classes="auto-sized" }}
</div>
<div class="sub-section-header">