Title says it all. The API on !passives scans and reports only the current players on map passives like this. The problem is it returns all 0's for the scores. With changes from 2014 to 2024 and weekly updates as well I have no idea how to get the correct numbers. Here is the script: on('chat:message', function(msg) {
if (msg.type !== 'api') return;
// Helper: get all player tokens on the current map
function getPlayerTokens(pageId){
return findObjs({
_type: 'graphic',
_pageid: pageId,
_subtype: 'token',
layer: 'objects'
}).filter(t => t.get('represents') && getObj('character', t.get('represents')).get('controlledby'));
}
// Gather party info from tokens
function getPartyFromTokens(pageId){
let tokens = getPlayerTokens(pageId);
let list = [];
tokens.forEach(token => {
let char = getObj('character', token.get('represents'));
if(!char) return;
let pp = parseInt(getAttrByName(char.id,'passive_perception')) || 0;
let pi = parseInt(getAttrByName(char.id,'passive_investigation')) || 0;
let ins = parseInt(getAttrByName(char.id,'passive_insight')) || 0;
list.push({
name: char.get('name'),
pp: pp,
pi: pi,
ins: ins
});
});
// sort by PP highest → lowest
list.sort((a,b) => b.pp - a.pp);
return list;
}
// --- COMMAND: !passives ---
if(msg.content === '!passives'){
let pageId = Campaign().get('playerpageid');
let list = getPartyFromTokens(pageId);
if(list.length === 0){
sendChat("GM Radar","/w gm No player tokens found on this page.");
return;
}
let output = "&{template:default} {{name=Passive Sense Radar}}";
list.forEach((entry, idx) => {
let line = `PP ${entry.pp} | PI ${entry.pi} | INS ${entry.ins}`;
if(idx === 0) line = "👁️ " + line + " (Highest)";
output += `{{${entry.name}=${line}}}`;
});
sendChat("GM Radar","/w gm "+output);
}
// --- COMMAND: !noticedc X ---
if(msg.content.startsWith('!noticedc')){
let parts = msg.content.split(' ');
let dc = parseInt(parts[1]);
if(!dc){
sendChat("GM Radar","/w gm Usage: !noticedc 15");
return;
}
let pageId = Campaign().get('playerpageid');
let list = getPartyFromTokens(pageId);
if(list.length === 0){
sendChat("GM Radar","/w gm No player tokens found on this page.");
return;
}
let output = `&{template:default} {{name=Passive Perception vs DC ${dc}}}`;
list.forEach(entry => {
let result = entry.pp >= dc ? "✔ Notices" : "✖ Misses";
output += `{{${entry.name}=PP ${entry.pp} → ${result}}}`;
});
sendChat("GM Radar","/w gm "+output);
}
}); The second part is used with Send to Chat reaction to see if anyone made dc to detect trap. !noticedc # Any help would be great as I had to get AI to help me with this. Still learning and have more ideas than knowhow.