Skip to content

Commit

Permalink
Add Ghostly Gaze
Browse files Browse the repository at this point in the history
  • Loading branch information
dev7355608 committed May 7, 2023
1 parent 256f18e commit aa33e0b
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 6 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ The following vision/detection modes are included.
- _Note: You need the [Vision Limitation]() module for magical darkness._
- **Echolocation**
- Detects the same things Blindsight does but doesn't work while deafened.
- **Ghostly Gaze**
- Detects anything Darkvision would but isn't blocked by walls.
- **Hearing**
- Detects all creatures that do not have the _inaudible_ status effect and are not behind a sound-blocking walls. If the token is deafened, it cannot hear anything of course.
- **See Invisibility**
Expand All @@ -53,6 +55,7 @@ A token gains ...
- _Detect Thoughts_ if the actor has an active effect with the name `Detect Thoughts`.
- _Devil's Sight_ if the actor has an active effect with the name `Devil's Sight`.
- _Note: Remove the effect that gives 120 feet Darkvision if it exists: Devil's Sight doesn't increase the range of Darkvision._
- _Ghostly Gaze_ if the actor has an active effect with the name `Ghostly Gaze`.
- _See Invisibility_ if the actor has an active effect with the name `See Invisibility`.

By default all tokens have hearing range of 30 feet.
Expand Down
1 change: 1 addition & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"VISION5E.DetectThoughts": "Detect Thoughts",
"VISION5E.DevilsSight": "Devil's Sight",
"VISION5E.Echolocation": "Echolocation",
"VISION5E.GhostlyGaze": "Ghostly Gaze",
"VISION5E.Hearing": "Hearing",
"VISION5E.Inaudible": "Inaudible",
"VISION5E.LightPerception": "Light Perception",
Expand Down
6 changes: 3 additions & 3 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"email": "[email protected]"
}
],
"version": "1.0.0",
"version": "1.1.0",
"compatibility": {
"minimum": "11",
"verified": "11"
Expand Down Expand Up @@ -41,8 +41,8 @@
},
"url": "https://github.com/dev7355608/vision-5e",
"manifest": "https://github.com/dev7355608/vision-5e/releases/latest/download/module.json",
"download": "https://github.com/dev7355608/vision-5e/releases/download/v1.0.0/module.zip",
"changelog": "https://github.com/dev7355608/vision-5e/releases/tag/v1.0.0",
"download": "https://github.com/dev7355608/vision-5e/releases/download/v1.1.0/module.zip",
"changelog": "https://github.com/dev7355608/vision-5e/releases/tag/v1.1.0",
"bugs": "https://github.com/dev7355608/vision-5e/issues",
"readme": "https://raw.githubusercontent.com/dev7355608/vision-5e/main/README.md",
"license": "https://raw.githubusercontent.com/dev7355608/vision-5e/main/LICENSE"
Expand Down
10 changes: 10 additions & 0 deletions scripts/automation.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,16 @@ Hooks.once("i18nInit", () => {
});
}

for (const name of [
"Ghostly Gaze",
game.i18n.localize("VISION5E.GhostlyGaze")
]) {
effectMapping.set(name, {
id: "ghostlyGaze",
range: 30
});
}

for (const name of [
"See Invisibility",
game.i18n.localize("VISION5E.SeeInvisibility")
Expand Down
4 changes: 4 additions & 0 deletions scripts/config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { DetectionModeDetectPoisonAndDisease } from "./detection-modes/detect-po
import { DetectionModeDetectThoughts } from "./detection-modes/detect-thoughts.mjs";
import { DetectionModeDevilsSight } from "./detection-modes/devils-sight.mjs";
import { DetectionModeEcholocation } from "./detection-modes/echolocation.mjs";
import { DetectionModeGhostlyGaze } from "./detection-modes/ghostly-gaze.mjs";
import { DetectionModeHearing } from "./detection-modes/hearing.mjs";
import { DetectionModeSeeInvisibility } from "./detection-modes/see-invisibility.mjs";
import { DetectionModeTremorsense } from "./detection-modes/tremorsense.mjs";
Expand All @@ -17,6 +18,7 @@ import { VisionModeDetectPoisonAndDisease } from "./vision-modes/detect-poison-a
import { VisionModeDetectThoughts } from "./vision-modes/detect-thoughts.mjs";
import { VisionModeDevilsSight } from "./vision-modes/devils-sight.mjs";
import { VisionModeEcholocation } from "./vision-modes/echolocation.mjs";
import { VisionModeGhostlyGaze } from "./vision-modes/ghostly-gaze.mjs";
import { VisionModeTremorsense } from "./vision-modes/tremorsense.mjs";
import { VisionModeTruesight } from "./vision-modes/truesight.mjs";

Expand Down Expand Up @@ -70,6 +72,7 @@ Hooks.once("init", () => {
registerDetectionMode(new DetectionModeDetectThoughts());
registerDetectionMode(new DetectionModeDevilsSight());
registerDetectionMode(new DetectionModeEcholocation());
registerDetectionMode(new DetectionModeGhostlyGaze());
registerDetectionMode(new DetectionModeHearing());
registerDetectionMode(new DetectionModeTremorsense());
registerDetectionMode(new DetectionModeTruesight());
Expand All @@ -84,6 +87,7 @@ Hooks.once("init", () => {
registerVisionMode(new VisionModeDetectThoughts());
registerVisionMode(new VisionModeDevilsSight());
registerVisionMode(new VisionModeEcholocation());
registerVisionMode(new VisionModeGhostlyGaze());
registerVisionMode(new VisionModeTremorsense());
registerVisionMode(new VisionModeTruesight());

Expand Down
6 changes: 3 additions & 3 deletions scripts/detection-modes/darkvision.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
* The detection mode for Darkvision.
*/
export class DetectionModeDarkvision extends DetectionModeBasicSight {
constructor() {
super({
constructor(data = {}, options = {}) {
super(foundry.utils.mergeObject({
id: DetectionMode.BASIC_MODE_ID,
label: "DND5E.SenseDarkvision",
type: DetectionMode.DETECTION_TYPES.SIGHT,
walls: true
});
}, data), options);
}

/** @override */
Expand Down
53 changes: 53 additions & 0 deletions scripts/detection-modes/ghostly-gaze.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { DetectionModeDarkvision } from "./darkvision.mjs";

/**
* The detection mode for Ghostly Gaze.
*/
export class DetectionModeGhostlyGaze extends DetectionModeDarkvision {
constructor() {
super({
id: "ghostlyGaze",
label: "VISION5E.GhostlyGaze",
walls: false
});
}

/** @override */
static getDetectionFilter(revealed) {
if (revealed) return false;
return this._detectionFilter ??= GlowOverlayFilter.create({
glowColor: [1, 0.4, 1, 1]
});
}

/** @override */
_testLOS(visionSource, mode, target, test) {
return this.#testAngle(visionSource, test.point);
}

/**
* Test whether the point is inside the vision cone.
* @param {VisionSource} visionSource
* @param {PIXI.Point} point
* @returns {boolean}
*/
#testAngle(visionSource, point) {
const { angle, rotation, externalRadius } = visionSource.data;

if (angle !== 360) {
const dx = point.x - visionSource.x;
const dy = point.y - visionSource.y;

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) {
return false;
}
}
}

return true;
}
}
1 change: 1 addition & 0 deletions scripts/hud.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Hooks.on("renderTokenHUD", (hud, html) => {
"detectThoughts",
"devilsSight",
"echolocation",
"ghostlyGaze",
"tremorsense",
"truesight"
]) {
Expand Down
27 changes: 27 additions & 0 deletions scripts/vision-modes/ghostly-gaze.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* The vision mode for Ghostly Gaze.
*/
export class VisionModeGhostlyGaze extends VisionMode {
detectionMode = "ghostlyGaze";

constructor() {
super({
id: "ghostlyGaze",
label: "VISION5E.GhostlyGaze",
canvas: {
shader: ColorAdjustmentsSamplerShader,
uniforms: { contrast: 0, saturation: -1.0, brightness: 0 }
},
lighting: {
levels: {
[VisionMode.LIGHTING_LEVELS.DIM]: VisionMode.LIGHTING_LEVELS.BRIGHT
},
background: { visibility: VisionMode.LIGHTING_VISIBILITY.REQUIRED }
},
vision: {
darkness: { adaptive: false },
defaults: { attenuation: 0, contrast: 0, saturation: -1.0, brightness: 0 }
}
});
}
}

0 comments on commit aa33e0b

Please sign in to comment.