mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-03-07 14:36:13 +01:00
Changed to keep the original Cone function
This commit is contained in:
parent
9454fe0525
commit
2a72c8ac83
4 changed files with 88 additions and 42 deletions
|
|
@ -56,7 +56,6 @@ Hooks.once('init', () => {
|
||||||
|
|
||||||
CONFIG.Dice.rolls = [...CONFIG.Dice.rolls, ...[DHRoll, DualityRoll, D20Roll, DamageRoll]];
|
CONFIG.Dice.rolls = [...CONFIG.Dice.rolls, ...[DHRoll, DualityRoll, D20Roll, DamageRoll]];
|
||||||
CONFIG.MeasuredTemplate.objectClass = placeables.DhMeasuredTemplate;
|
CONFIG.MeasuredTemplate.objectClass = placeables.DhMeasuredTemplate;
|
||||||
CONFIG.MeasuredTemplate.defaults.angle = 180;
|
|
||||||
|
|
||||||
CONFIG.Item.documentClass = documents.DHItem;
|
CONFIG.Item.documentClass = documents.DHItem;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
export default class DhTemplateLayer extends TemplateLayer {
|
export default class DhTemplateLayer extends foundry.canvas.layers.TemplateLayer {
|
||||||
static prepareSceneControls() {
|
static prepareSceneControls() {
|
||||||
const sc = SceneControls;
|
const sc = foundry.applications.ui.SceneControls;
|
||||||
return {
|
return {
|
||||||
name: 'templates',
|
name: 'templates',
|
||||||
order: 2,
|
order: 2,
|
||||||
|
|
@ -26,6 +26,17 @@ export default class DhTemplateLayer extends TemplateLayer {
|
||||||
cone: {
|
cone: {
|
||||||
name: 'cone',
|
name: 'cone',
|
||||||
order: 2,
|
order: 2,
|
||||||
|
title: 'CONTROLS.MeasureCone',
|
||||||
|
icon: 'fa-solid fa-angle-left',
|
||||||
|
toolclip: {
|
||||||
|
src: 'toolclips/tools/measure-cone.webm',
|
||||||
|
heading: 'CONTROLS.MeasureCone',
|
||||||
|
items: sc.buildToolclipItems(['create', 'move', 'edit', 'hide', 'delete', 'rotate'])
|
||||||
|
}
|
||||||
|
},
|
||||||
|
inFront: {
|
||||||
|
name: 'inFront',
|
||||||
|
order: 3,
|
||||||
title: 'CONTROLS.inFront',
|
title: 'CONTROLS.inFront',
|
||||||
icon: 'fa-solid fa-eye',
|
icon: 'fa-solid fa-eye',
|
||||||
toolclip: {
|
toolclip: {
|
||||||
|
|
@ -36,7 +47,7 @@ export default class DhTemplateLayer extends TemplateLayer {
|
||||||
},
|
},
|
||||||
rect: {
|
rect: {
|
||||||
name: 'rect',
|
name: 'rect',
|
||||||
order: 3,
|
order: 4,
|
||||||
title: 'CONTROLS.MeasureRect',
|
title: 'CONTROLS.MeasureRect',
|
||||||
icon: 'fa-regular fa-square',
|
icon: 'fa-regular fa-square',
|
||||||
toolclip: {
|
toolclip: {
|
||||||
|
|
@ -47,7 +58,7 @@ export default class DhTemplateLayer extends TemplateLayer {
|
||||||
},
|
},
|
||||||
ray: {
|
ray: {
|
||||||
name: 'ray',
|
name: 'ray',
|
||||||
order: 4,
|
order: 5,
|
||||||
title: 'CONTROLS.MeasureRay',
|
title: 'CONTROLS.MeasureRay',
|
||||||
icon: 'fa-solid fa-up-down',
|
icon: 'fa-solid fa-up-down',
|
||||||
toolclip: {
|
toolclip: {
|
||||||
|
|
@ -58,7 +69,7 @@ export default class DhTemplateLayer extends TemplateLayer {
|
||||||
},
|
},
|
||||||
clear: {
|
clear: {
|
||||||
name: 'clear',
|
name: 'clear',
|
||||||
order: 5,
|
order: 6,
|
||||||
title: 'CONTROLS.MeasureClear',
|
title: 'CONTROLS.MeasureClear',
|
||||||
icon: 'fa-solid fa-trash',
|
icon: 'fa-solid fa-trash',
|
||||||
visible: game.user.isGM,
|
visible: game.user.isGM,
|
||||||
|
|
@ -69,4 +80,37 @@ export default class DhTemplateLayer extends TemplateLayer {
|
||||||
activeTool: 'circle'
|
activeTool: 'circle'
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_onDragLeftStart(event) {
|
||||||
|
const interaction = event.interactionData;
|
||||||
|
|
||||||
|
// Snap the origin to the grid
|
||||||
|
if (!event.shiftKey) interaction.origin = this.getSnappedPoint(interaction.origin);
|
||||||
|
|
||||||
|
// Create a pending MeasuredTemplateDocument
|
||||||
|
const tool = game.activeTool === 'inFront' ? 'cone' : game.activeTool;
|
||||||
|
const previewData = {
|
||||||
|
user: game.user.id,
|
||||||
|
t: tool,
|
||||||
|
x: interaction.origin.x,
|
||||||
|
y: interaction.origin.y,
|
||||||
|
sort: Math.max(this.getMaxSort() + 1, 0),
|
||||||
|
distance: 1,
|
||||||
|
direction: 0,
|
||||||
|
fillColor: game.user.color || '#FF0000',
|
||||||
|
hidden: event.altKey
|
||||||
|
};
|
||||||
|
const defaults = CONFIG.MeasuredTemplate.defaults;
|
||||||
|
if (game.activeTool === 'cone') previewData.angle = defaults.angle;
|
||||||
|
else if (game.activeTool === 'inFront') previewData.angle = 180;
|
||||||
|
else if (game.activeTool === 'ray') previewData.width = defaults.width * canvas.dimensions.distance;
|
||||||
|
const cls = foundry.utils.getDocumentClass('MeasuredTemplate');
|
||||||
|
const doc = new cls(previewData, { parent: canvas.scene });
|
||||||
|
|
||||||
|
// Create a preview MeasuredTemplate object
|
||||||
|
const template = new this.constructor.placeableClass(doc);
|
||||||
|
doc._object = template;
|
||||||
|
interaction.preview = this.preview.addChild(template);
|
||||||
|
template.draw();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import { burden } from '../../config/generalConfig.mjs';
|
import { burden } from '../../config/generalConfig.mjs';
|
||||||
import ActionField from '../fields/actionField.mjs';
|
|
||||||
import ForeignDocumentUUIDField from '../fields/foreignDocumentUUIDField.mjs';
|
import ForeignDocumentUUIDField from '../fields/foreignDocumentUUIDField.mjs';
|
||||||
import DhLevelData from '../levelData.mjs';
|
import DhLevelData from '../levelData.mjs';
|
||||||
import BaseDataActor from './base.mjs';
|
import BaseDataActor from './base.mjs';
|
||||||
|
|
@ -29,7 +28,7 @@ export default class DhCharacter extends BaseDataActor {
|
||||||
return foundry.utils.mergeObject(super.metadata, {
|
return foundry.utils.mergeObject(super.metadata, {
|
||||||
label: 'TYPES.Actor.character',
|
label: 'TYPES.Actor.character',
|
||||||
type: 'character',
|
type: 'character',
|
||||||
isNPC: false,
|
isNPC: false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,13 @@ import { LevelOptionType } from '../data/levelTier.mjs';
|
||||||
import DHFeature from '../data/item/feature.mjs';
|
import DHFeature from '../data/item/feature.mjs';
|
||||||
|
|
||||||
export default class DhpActor extends Actor {
|
export default class DhpActor extends Actor {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the first Actor active owner.
|
* Return the first Actor active owner.
|
||||||
*/
|
*/
|
||||||
get owner() {
|
get owner() {
|
||||||
const user = this.hasPlayerOwner && game.users.players.find(u => this.testUserPermission(u, "OWNER") && u.active);;
|
const user =
|
||||||
if(!user) return game.user.isGM ? game.user : null;
|
this.hasPlayerOwner && game.users.players.find(u => this.testUserPermission(u, 'OWNER') && u.active);
|
||||||
|
if (!user) return game.user.isGM ? game.user : null;
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -153,7 +153,6 @@ export default class DhpActor extends Actor {
|
||||||
}
|
}
|
||||||
|
|
||||||
async levelUp(levelupData) {
|
async levelUp(levelupData) {
|
||||||
const actions = [];
|
|
||||||
const levelups = {};
|
const levelups = {};
|
||||||
for (var levelKey of Object.keys(levelupData)) {
|
for (var levelKey of Object.keys(levelupData)) {
|
||||||
const level = levelupData[levelKey];
|
const level = levelupData[levelKey];
|
||||||
|
|
@ -317,7 +316,6 @@ export default class DhpActor extends Actor {
|
||||||
|
|
||||||
await this.update({
|
await this.update({
|
||||||
system: {
|
system: {
|
||||||
actions: [...this.system.actions, ...actions],
|
|
||||||
levelData: {
|
levelData: {
|
||||||
level: {
|
level: {
|
||||||
current: this.system.levelData.level.changed
|
current: this.system.levelData.level.changed
|
||||||
|
|
@ -369,16 +367,16 @@ export default class DhpActor extends Actor {
|
||||||
const modifier = roll.modifier !== null ? Number.parseInt(roll.modifier) : null;
|
const modifier = roll.modifier !== null ? Number.parseInt(roll.modifier) : null;
|
||||||
return modifier !== null
|
return modifier !== null
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
value: modifier,
|
value: modifier,
|
||||||
label: roll.label
|
label: roll.label
|
||||||
? modifier >= 0
|
? modifier >= 0
|
||||||
? `${roll.label} +${modifier}`
|
? `${roll.label} +${modifier}`
|
||||||
: `${roll.label} ${modifier}`
|
: `${roll.label} ${modifier}`
|
||||||
: null,
|
: null,
|
||||||
title: roll.label
|
title: roll.label
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
: [];
|
: [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -460,7 +458,7 @@ export default class DhpActor extends Actor {
|
||||||
|
|
||||||
if (Hooks.call(`${CONFIG.DH.id}.postDamageTreshold`, this, hpDamage, damage, type) === false) return null;
|
if (Hooks.call(`${CONFIG.DH.id}.postDamageTreshold`, this, hpDamage, damage, type) === false) return null;
|
||||||
|
|
||||||
if(!hpDamage) return;
|
if (!hpDamage) return;
|
||||||
|
|
||||||
const updates = [{ value: hpDamage, type: 'hitPoints' }];
|
const updates = [{ value: hpDamage, type: 'hitPoints' }];
|
||||||
|
|
||||||
|
|
@ -469,8 +467,8 @@ export default class DhpActor extends Actor {
|
||||||
this.system.armor &&
|
this.system.armor &&
|
||||||
this.system.armor.system.marks.value < this.system.armorScore
|
this.system.armor.system.marks.value < this.system.armorScore
|
||||||
) {
|
) {
|
||||||
const armorStackResult = await this.owner.query('armorStack', {actorId: this.uuid, damage: hpDamage});
|
const armorStackResult = await this.owner.query('armorStack', { actorId: this.uuid, damage: hpDamage });
|
||||||
if(armorStackResult) {
|
if (armorStackResult) {
|
||||||
const { modifiedDamage, armorSpent, stressSpent } = armorStackResult;
|
const { modifiedDamage, armorSpent, stressSpent } = armorStackResult;
|
||||||
updates.find(u => u.type === 'hitPoints').value = modifiedDamage;
|
updates.find(u => u.type === 'hitPoints').value = modifiedDamage;
|
||||||
updates.push(
|
updates.push(
|
||||||
|
|
@ -479,7 +477,7 @@ export default class DhpActor extends Actor {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.modifyResource(updates);
|
await this.modifyResource(updates);
|
||||||
|
|
||||||
if (Hooks.call(`${CONFIG.DH.id}.postTakeDamage`, this, damage, type) === false) return null;
|
if (Hooks.call(`${CONFIG.DH.id}.postTakeDamage`, this, damage, type) === false) return null;
|
||||||
|
|
@ -493,7 +491,7 @@ export default class DhpActor extends Actor {
|
||||||
async modifyResource(resources) {
|
async modifyResource(resources) {
|
||||||
if (!resources.length) return;
|
if (!resources.length) return;
|
||||||
|
|
||||||
if(resources.find(r => r.type === 'stress')) this.convertStressDamageToHP(resources);
|
if (resources.find(r => r.type === 'stress')) this.convertStressDamageToHP(resources);
|
||||||
let updates = { actor: { target: this, resources: {} }, armor: { target: this.system.armor, resources: {} } };
|
let updates = { actor: { target: this, resources: {} }, armor: { target: this.system.armor, resources: {} } };
|
||||||
resources.forEach(r => {
|
resources.forEach(r => {
|
||||||
switch (r.type) {
|
switch (r.type) {
|
||||||
|
|
@ -521,7 +519,12 @@ export default class DhpActor extends Actor {
|
||||||
});
|
});
|
||||||
Object.values(updates).forEach(async u => {
|
Object.values(updates).forEach(async u => {
|
||||||
if (Object.keys(u.resources).length > 0) {
|
if (Object.keys(u.resources).length > 0) {
|
||||||
await emitAsGM(GMUpdateEvent.UpdateDocument, u.target.update.bind(u.target), u.resources, u.target.uuid);
|
await emitAsGM(
|
||||||
|
GMUpdateEvent.UpdateDocument,
|
||||||
|
u.target.update.bind(u.target),
|
||||||
|
u.resources,
|
||||||
|
u.target.uuid
|
||||||
|
);
|
||||||
/* if (game.user.isGM) {
|
/* if (game.user.isGM) {
|
||||||
await u.target.update(u.resources);
|
await u.target.update(u.resources);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -540,27 +543,28 @@ export default class DhpActor extends Actor {
|
||||||
|
|
||||||
convertDamageToThreshold(damage) {
|
convertDamageToThreshold(damage) {
|
||||||
return damage >= this.system.damageThresholds.severe
|
return damage >= this.system.damageThresholds.severe
|
||||||
? 3
|
? 3
|
||||||
: damage >= this.system.damageThresholds.major
|
: damage >= this.system.damageThresholds.major
|
||||||
? 2
|
? 2
|
||||||
: damage >= this.system.damageThresholds.minor
|
: damage >= this.system.damageThresholds.minor
|
||||||
? 1
|
? 1
|
||||||
: 0;
|
: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
convertStressDamageToHP(resources) {
|
convertStressDamageToHP(resources) {
|
||||||
const stressDamage = resources.find(r => r.type === 'stress'),
|
const stressDamage = resources.find(r => r.type === 'stress'),
|
||||||
newValue = this.system.resources.stress.value + stressDamage.value;
|
newValue = this.system.resources.stress.value + stressDamage.value;
|
||||||
if(newValue <= this.system.resources.stress.maxTotal) return;
|
if (newValue <= this.system.resources.stress.maxTotal) return;
|
||||||
const hpDamage = resources.find(r => r.type === 'hitPoints');
|
const hpDamage = resources.find(r => r.type === 'hitPoints');
|
||||||
if(hpDamage) hpDamage.value++;
|
if (hpDamage) hpDamage.value++;
|
||||||
else resources.push({
|
else
|
||||||
type: 'hitPoints',
|
resources.push({
|
||||||
value: 1
|
type: 'hitPoints',
|
||||||
})
|
value: 1
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const registerDHActorHooks = () => {
|
export const registerDHActorHooks = () => {
|
||||||
CONFIG.queries.armorStack = DamageReductionDialog.armorStackQuery;
|
CONFIG.queries.armorStack = DamageReductionDialog.armorStackQuery;
|
||||||
}
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue