Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement thoughtsense detection mode #17014

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packs/ancestryfeatures/empathic-sense.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@
"selector": "perception",
"type": "circumstance",
"value": 2
},
{
"acuity": "imprecise",
"key": "Sense",
"range": 15,
"selector": "thoughtsense"
}
],
"traits": {
Expand Down
2 changes: 1 addition & 1 deletion packs/pathfinder-monster-core/rhu-chalik.json
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@
{
"acuity": "precise",
"range": 60,
"type": "tremorsense"
"type": "thoughtsense"
}
]
},
Expand Down
48 changes: 48 additions & 0 deletions src/module/canvas/perception/modes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,60 @@ class DetectionModeTremorPF2e extends DetectionModeTremor {
}
}

class ThoughtsDetectionMode extends DetectionMode {
constructor() {
super({
id: "senseThoughts",
label: "PF2E.Actor.Creature.Sense.Type.Thoughtsense",
type: DetectionMode.DETECTION_TYPES.OTHER,
angle: false,
});
}

static override getDetectionFilter(): OutlineOverlayFilter {
const filter = (this._detectionFilter ??= OutlineOverlayFilter.create({
wave: true,
knockout: false,
outlineColor: [0, 1, 0, 1],
}));
filter.thickness = 1;
return filter;
}

protected override _canDetect(visionSource: PointVisionSourcePF2e, target: PlaceableObject): boolean {
// Not if the target isn't a token
if (!(target instanceof TokenPF2e)) return false;
const token: TokenPF2e = target;
if (!token.actor) return false;

// Not if the token is GM-hidden
if (token.document.hidden) return false;

// Detection only works on creatures
if (!token.actor.isOfType("creature")) return false;

// Detection cails on mindless creatures
if (token.actor.system.traits.value.includes("mindless")) return false;

// Detection fails if target is immune to mental
if (token.actor.attributes.immunities.some((i) => i.type === "mental")) return false;

return super._canDetect(visionSource, target);
}
}

declare namespace ThoughtsDetectionMode {
// eslint-disable-next-line no-var
var _detectionFilter: OutlineOverlayFilter | undefined;
}

function setPerceptionModes(): void {
CONFIG.Canvas.visionModes.darkvision = darkvision;
CONFIG.Canvas.detectionModes.basicSight = new VisionDetectionMode();
CONFIG.Canvas.detectionModes.lightPerception = new LightPerceptionMode();
CONFIG.Canvas.detectionModes.hearing = new HearingDetectionMode();
CONFIG.Canvas.detectionModes.feelTremor = new DetectionModeTremorPF2e();
CONFIG.Canvas.detectionModes.senseThoughts = new ThoughtsDetectionMode();
}

export { setPerceptionModes };
5 changes: 5 additions & 0 deletions src/module/scene/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ function computeSightAndDetectionForRBV(token: TokenDocumentPF2e | PrototypeToke
const range = scene?.flags.pf2e.hearingRange ?? null;
token.detectionModes.push({ id: "hearing", enabled: true, range });
}

const thoughtsense = actor.perception.senses.get("thoughtsense");
if (thoughtsense && thoughtsense.acuity !== "vague") {
token.detectionModes.push({ id: "senseThoughts", enabled: true, range: thoughtsense.range });
}
}

/** Returns true if this token has the default actor image or the default image for its actor type */
Expand Down
Loading