If it's a token that I've marked as a drawing, it works just fine. If it's something drawn with one of the drawing tools such as draw shape or freehand, nothing happens. I assume that since regular drawings have no tokenid, it simply ignores them. EDIT: Here's the most recent version with all of the 5e conditions plus bless and haste: function RollRight (whoPC)
{
var character = findObjs({type: 'character',controlledby: whoPC})[0];
return character;
}
class Condition
{
constructor(cmd, chatForm, token)
{
this.cmd = cmd;
this.chatForm = chatForm;
this.token = token;
}
}
const Bless = new Condition("!bless ", "blessed", "status_angel-outfit");
const Blind = new Condition("!blind ", "blinded", "status_pummeled");
const Charm = new Condition("!charm ", "charmed", "status_broken-heart");
const Deaf = new Condition("!deaf ", "deafened", "status_interdiction");
const Fright = new Condition("!fright ", "frightened", "status_screaming");
const Grapple = new Condition("!grapple ", "grappled", "status_fishing-net");
const Haste = new Condition("!haste ", "hasted", "status_fluffy-wing");
const Incap = new Condition("!incap ", "incapacitated", "status_arrowed");
const Invis = new Condition("!invis ", "invisible", "status_ninja-mask");
const Paral = new Condition("!paral ", "paralyzed", "status_aura");
const Petrif = new Condition("!petrif ", "petrified", "status_frozen-orb");
const Poison = new Condition("!poison ", "poisoned", "status_drink-me");
const Prone = new Condition("!prone ", "prone", "status_back-pain");
const Restrain = new Condition("!restrain ", "restrained", "status_cobweb");
const Stun = new Condition("!stun ", "stunned", "status_lightning-helix");
const Uncon = new Condition("!uncon ", "unconscious", "status_sleepy");
on("chat:message", function(msg)
{
if(msg.type == "api" && msg.who != "Bot")
{
var cond;
if (msg.content.indexOf(Bless.cmd) !== -1)
cond = Bless;
else if (msg.content.indexOf(Blind.cmd) !== -1)
cond = Blind;
else if (msg.content.indexOf(Charm.cmd) !== -1)
cond = Charm;
else if (msg.content.indexOf(Deaf.cmd) !== -1)
cond = Deaf;
else if (msg.content.indexOf(Fright.cmd) !== -1)
cond = Fright;
else if (msg.content.indexOf(Grapple.cmd) !== -1)
cond = Grapple;
else if (msg.content.indexOf(Haste.cmd) !== -1)
cond = Haste;
else if (msg.content.indexOf(Incap.cmd) !== -1)
cond = Incap;
else if (msg.content.indexOf(Invis.cmd) !== -1)
cond = Invis;
else if (msg.content.indexOf(Paral.cmd) !== -1)
cond = Paral;
else if (msg.content.indexOf(Petrif.cmd) !== -1)
cond = Petrif;
else if (msg.content.indexOf(Poison.cmd) !== -1)
cond = Poison;
else if (msg.content.indexOf(Prone.cmd) !== -1)
cond = Prone;
else if (msg.content.indexOf(Restrain.cmd) !== -1)
cond = Restrain;
else if (msg.content.indexOf(Stun.cmd) !== -1)
cond = Stun;
else if (msg.content.indexOf(Uncon.cmd) !== -1)
cond = Uncon;
if (cond)
{
var str = msg.content.replace(cond.cmd, "");
var tokenid = str.split(" ")[0];
var rounds = str.split(" ")[1];
var token = findObjs({_type: 'graphic',_subtype: 'token',_id:tokenid})[0];
if (token)
{
var cWho = findObjs({_type: 'character',name: msg.who})[0];
if (!cWho && msg.who.indexOf("(GM)") == -1)
{
cWho = RollRight(msg.playerid);
msg.who = cWho.get("name");
}
if (rounds != "indef")
{
token.set(cond.token, rounds);
sendChat("Bot", msg.who + " is " + cond.chatForm + " for " + rounds + " rounds!");
}
else
{
token.set(cond.token);
sendChat("Bot", msg.who + " is " + cond.chatForm + "!");
}
}
}
}
});
on("change:campaign:turnorder", function(obj)
{
if(!obj.get("turnorder")) return;
var turnorder = JSON.parse(obj.get("turnorder"));
if (!turnorder.length) return;
if (turnorder[turnorder.length - 1].id == -1) return;
var token = getObj("graphic", turnorder[turnorder.length - 1].id);
if (token.get(Bless.token) > 1)
token.set(Bless.token, token.get(Bless.token) - 1);
else if (token.get(Bless.token) == 1)
token.set(Bless.token, false);
if (token.get(Blind.token) > 1)
token.set(Blind.token, token.get(Blind.token) - 1);
else if (token.get(Blind.token) == 1)
token.set(Blind.token, false);
if (token.get(Charm.token) > 1)
token.set(Charm.token, token.get(Charm.token) - 1);
else if (token.get(Charm.token) == 1)
token.set(Charm.token, false);
if (token.get(Deaf.token) > 1)
token.set(Deaf.token, token.get(Deaf.token) - 1);
else if (token.get(Deaf.token) == 1)
token.set(Deaf.token, false);
if (token.get(Fright.token) > 1)
token.set(Fright.token, token.get(Fright.token) - 1);
else if (token.get(Fright.token) == 1)
token.set(Fright.token, false);
if (token.get(Grapple.token) > 1)
token.set(Grapple.token, token.get(Grapple.token) - 1);
else if (token.get(Grapple.token) == 1)
token.set(Grapple.token, false);
if (token.get(Haste.token) > 1)
token.set(Haste.token, token.get(Haste.token) - 1);
else if (token.get(Haste.token) == 1)
token.set(Haste.token, false);
if (token.get(Incap.token) > 1)
token.set(Incap.token, token.get(Incap.token) - 1);
else if (token.get(Incap.token) == 1)
token.set(Incap.token, false);
if (token.get(Invis.token) > 1)
token.set(Invis.token, token.get(Invis.token) - 1);
else if (token.get(Invis.token) == 1)
token.set(Invis.token, false);
if (token.get(Paral.token) > 1)
token.set(Paral.token, token.get(Paral.token) - 1);
else if (token.get(Paral.token) == 1)
token.set(Paral.token, false);
if (token.get(Petrif.token) > 1)
token.set(Petrif.token, token.get(Petrif.token) - 1);
else if (token.get(Petrif.token) == 1)
token.set(Petrif.token, false);
if (token.get(Poison.token) > 1)
token.set(Poison.token, token.get(Poison.token) - 1);
else if (token.get(Poison.token) == 1)
token.set(Poison.token, false);
if (token.get(Prone.token) > 1)
token.set(Prone.token, token.get(Prone.token) - 1);
else if (token.get(Prone.token) == 1)
token.set(Prone.token, false);
if (token.get(Restrain.token) > 1)
token.set(Restrain.token, token.get(Restrain.token) - 1);
else if (token.get(Restrain.token) == 1)
token.set(Restrain.token, false);
if (token.get(Stun.token) > 1)
token.set(Stun.token, token.get(Stun.token) - 1);
else if (token.get(Stun.token) == 1)
token.set(Stun.token, false);
if (token.get(Uncon.token) > 1)
token.set(Uncon.token, token.get(Uncon.token) - 1);
else if (token.get(Uncon.token) == 1)
token.set(Uncon.token, false);
});