From b84f34d5602e3e35a4025eeb9adc58802db27916 Mon Sep 17 00:00:00 2001 From: sladecraven Date: Tue, 23 Aug 2022 08:21:20 +0200 Subject: [PATCH] Fix range attack --- modules/crucible-actor.js | 10 ++++++++-- system.json | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/crucible-actor.js b/modules/crucible-actor.js index 2cb578d..f44dbfe 100644 --- a/modules/crucible-actor.js +++ b/modules/crucible-actor.js @@ -560,11 +560,17 @@ export class CrucibleActor extends Actor { let defender = defenderToken.actor // Distance management - if ( this.token) { - const ray = new Ray(this.token.object.center, defenderToken.center) + let token = this.token + if ( !token) { + let tokens =this.getActiveTokens() + token = tokens[0] + } + if ( token ) { + const ray = new Ray(token.object?.center || token.center, defenderToken.center) rollData.tokensDistance = canvas.grid.measureDistances([{ray}], {gridSpaces:false})[0] / canvas.grid.grid.options.dimensions.distance } else { ui.notifications.info("No token connected to this actor, unable to compute distance.") + return } if (defender ) { rollData.forceAdvantage = defender.isAttackerAdvantage() diff --git a/system.json b/system.json index ea9a66e..8f6441b 100644 --- a/system.json +++ b/system.json @@ -199,7 +199,7 @@ "styles": [ "styles/simple.css" ], - "version": "10.0.4", + "version": "10.0.5", "compatibility": { "minimum": "10", "verified": "10.278", @@ -207,7 +207,7 @@ }, "title": "Crucible RPG", "manifest": "https://www.uberwald.me/gitea/public/fvtt-crucible-rpg/raw/master/system.json", - "download": "https://www.uberwald.me/gitea/public/fvtt-crucible-rpg/archive/fvtt-crucible-rpg-v10.0.4.zip", + "download": "https://www.uberwald.me/gitea/public/fvtt-crucible-rpg/archive/fvtt-crucible-rpg-v10.0.5.zip", "url": "https://www.uberwald.me/gitea/public/fvtt-crucible-rpg", "background": "images/ui/crucible_welcome_page.webp", "id": "fvtt-crucible-rpg"