diff --git a/Changelog.md b/Changelog.md index 2ebbfd2..cd1f335 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,6 @@ +## v11.315331.3 +- Handle items without short and long range set more gracefully. Closes [#156](https://github.com/thatlonelybugbear/automated-conditions-5e/issues/156) +- ## v11.315331.2 - Added French translation, with [#154](https://github.com/thatlonelybugbear/automated-conditions-5e/pull/154) thanks to @CaosFR diff --git a/module.json b/module.json index 9c5f61d..a143ba7 100644 --- a/module.json +++ b/module.json @@ -2,7 +2,7 @@ "id": "automated-conditions-5e", "title": "Automated Conditions 5e", "description": "A small module for Foundry VTT that tries to automate some rolling aspects of the common 5e Conditions.", - "version": "11.315331.2", + "version": "11.315331.3", "authors": [ { "name": "thatlonelybugbear", @@ -68,6 +68,6 @@ "url": "https://github.com/thatlonelybugbear/automated-conditions-5e", "license": "https://raw.githubusercontent.com/thatlonelybugbear/automated-conditions-5e/main/LICENSE", "manifest": "https://github.com/thatlonelybugbear/automated-conditions-5e/releases/latest/download/module.json", - "download": "https://github.com/thatlonelybugbear/automated-conditions-5e/releases/download/v11.315331.2/module.zip", + "download": "https://github.com/thatlonelybugbear/automated-conditions-5e/releases/download/v11.315331.3/module.zip", "changelog": "https://raw.githubusercontent.com/thatlonelybugbear/automated-conditions-5e/main/Changelog.md" } diff --git a/scripts/ac5e-helpers.mjs b/scripts/ac5e-helpers.mjs index 14f2b92..a0fbc61 100644 --- a/scripts/ac5e-helpers.mjs +++ b/scripts/ac5e-helpers.mjs @@ -214,22 +214,20 @@ export function _autoRanged(item, token, target) { range: { value: short, long }, } = item.system; const flags = token.actor?.flags?.[Constants.MODULE_ID]; - const sharpShooter = - flags?.sharpShooter || _hasItem(item.actor, 'sharpshooter'); + const sharpShooter = flags?.sharpShooter || _hasItem(item.actor, 'sharpshooter'); if (sharpShooter && long && actionType == 'rwak') short = long; - const crossbowExpert = - flags?.crossbowExpert || _hasItem(item.actor, 'crossbow expert'); + const crossbowExpert = flags?.crossbowExpert || _hasItem(item.actor, 'crossbow expert'); const distance = target ? _getDistance(token, target) : undefined; const nearbyFoe = settings.autoRangedNearbyFoe && ['rwak', 'rsak'].includes(actionType) && - _findNearby(token, 'opposite', 5, 1) && //hostile vs friendly disposition only + _findNearby(token, 'opposite', 5, 1) && //hostile vs friendly disposition only !crossbowExpert; - const inRange = - distance <= short ? 'short' : distance <= long ? 'long' : false; + const inRange = (!short && !long) || distance <= short ? 'short' : distance <= long ? 'long' : false; //expect short and long being null for some items, and handle these cases as in short range. return { inRange: !!inRange, range: inRange, distance, nearbyFoe }; } + export function _hasItem(actor, itemName) { return actor?.items.some((item) => item?.name