Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
Bump version to 0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
stwlam committed Nov 6, 2022
1 parent 3baddad commit 2852a67
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 17 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Changelog

## Version 0.1.0
* Add echolocation as a detection mode
* Add devil's sight as a separate detection mode to visually distinguish it from See Invisibility
* Change See Invisibility to be unaffected by the blind status

## Version 0.0.6
* Extend actor-sense link support to NPCs
* Handle Active Effect updates (in addition to creates/deletes)

Expand Down
2 changes: 1 addition & 1 deletion module.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"scripts": [
"script.js"
],
"version": "0.0.6",
"version": "0.1.0",
"compatibility": {
"minimum": "10",
"verified": "10.288"
Expand Down
36 changes: 20 additions & 16 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ function updateTokens(actor, { force = false } = {}) {
const { sight, detectionModes } = token;
const canSeeInDark = ["darkvision", "devilsSight", "truesight"].some((m) => !!modes[m]);

// Devil's sight and darkvision
// VISION MODES

if (modes.devilsSight && (sight.visionMode !== "devilsSight" || sight.range !== modes.devilsSight)) {
const defaults = CONFIG.Canvas.visionModes.devilsSight.vision.defaults;
updates.sight = { visionMode: "devilsSight", ...defaults };
Expand All @@ -149,6 +150,8 @@ function updateTokens(actor, { force = false } = {}) {
updates.sight = { visionMode: "basic", contrast: 0, brightness: 0, saturation: 0, range: null };
}

// DETECTION MODES

// Devil's sight
if (modes.devilsSight) {
updates.detectionModes ??= [];
Expand Down Expand Up @@ -202,7 +205,7 @@ function testAngle(visionSource, point) {
if (dx * dx + dy * dy > externalRadius * externalRadius) {
const aMin = rotation + 90 - angle / 2;
const a = Math.toDegrees(Math.atan2(dy, dx));
if (((a - aMin) % 360 + 360) % 360 > angle) {
if ((((a - aMin) % 360) + 360) % 360 > angle) {
return false;
}
}
Expand Down Expand Up @@ -285,15 +288,18 @@ class EcholocationDetectionMode extends DetectionMode {
// Echolocation is directional and therefore limited by the vision angle.
if (!testAngle(visionSource, test.point)) return false;
// Echolocation is blocked by total cover and sound restrictions.
return !(CONFIG.Canvas.losBackend.testCollision(
{ x: visionSource.x, y: visionSource.y },
test.point,
{ type: "move", mode: "any", source: visionSource }
) || CONFIG.Canvas.losBackend.testCollision(
{ x: visionSource.x, y: visionSource.y },
test.point,
{ type: "sound", mode: "any", source: visionSource }
));
return !(
CONFIG.Canvas.losBackend.testCollision({ x: visionSource.x, y: visionSource.y }, test.point, {
type: "move",
mode: "any",
source: visionSource,
}) ||
CONFIG.Canvas.losBackend.testCollision({ x: visionSource.x, y: visionSource.y }, test.point, {
type: "sound",
mode: "any",
source: visionSource,
})
);
}
}

Expand All @@ -315,10 +321,7 @@ class InvisibilityDetectionMode extends DetectionMode {
/** @override */
_canDetect(visionSource, target) {
// Only invisible tokens can be detected
return (
target instanceof Token &&
target.document.hasStatusEffect(CONFIG.specialStatusEffects.INVISIBLE)
);
return target instanceof Token && target.document.hasStatusEffect(CONFIG.specialStatusEffects.INVISIBLE);
}

/** @override */
Expand All @@ -335,7 +338,8 @@ class InvisibilityDetectionMode extends DetectionMode {
if (source instanceof Token) {
detectionModes = source.document.detectionModes;
source.document.detectionModes = detectionModes.filter(
(m) => CONFIG.Canvas.detectionModes[m.id]?.type === DetectionMode.DETECTION_TYPES.SIGHT);
(m) => CONFIG.Canvas.detectionModes[m.id]?.type === DetectionMode.DETECTION_TYPES.SIGHT
);
}

// Temporarily remove the invisible status effect from the target (see TokenDocument#hasStatusEffect)
Expand Down

0 comments on commit 2852a67

Please sign in to comment.