#thread for this

1 messages ยท Page 1 of 1 (latest)

urban pasture
#

Starting a thread to stop cluttering the main channel.

let actor = game.actors.get(args[0].actorId);
This line is also wrong. There's already an actor variable passed in to the macro, as well. It's the actor casting the spell

#

Are you looking for a single buff, or "all of the buffs"?

ember rune
#

all the buffs. Sorry for the delay, I am busy with my players

urban pasture
#

I had a meeting to run to. This might be a bit cleaner

if (game.user.targets.size !== 1) {
  ui.notifications.error("You must target exactly one token to use this spell");
  return shared.reject = true;
}

const target = [...game.user.targets][0];

const specificItems = {
  "Shell": { level: 1 },
  "Protect": { level: 1 },
  "Shell II": { level: 3 },
  "Shellra": { level: 3 },
  "Protect II": { level: 3 },
  "Protectra": { level: 3 },
  "Shell III": { level: 5 },
  "Shellra II": { level: 5 },
  "Protect III": { level: 5 },
  "Protectra II": { level: 5 },
  "Shell IV": { level: 7 },
  "Shellra III": { level: 7 },
  "Protect IV": { level: 7 },
  "Protectra III": { level: 7 },
  "Shell V": { level: 9 },
  "Shellra IV": { level: 9 },
  "Protect V": { level: 9 },
  "Protectra IV": { level: 9 },
};

const found = target.actor.items
  .filter((item) => item.type === 'buff' && Object.keys(specificItems).includes(item.name))
  .map((item) => specificItems[item.name]);

if (!found.length) {
  ui.notifications.error("Target has none of the necessary buffs.");
}

const foundNames = found.join(', ');
const diceToRoll = found.reduce((acc, b) => acc + b.level, 0);
ChatMessage.create({
  content: `${target.name} has the following items:\n${foundNames}\nTotal level: ${diceToRoll}\nRoll ${diceToRoll}d6!`
});```
#

How exactly are you executing this macro? This shouldn't be a thing

ember rune
#

I'm running this as a global script macro. I don't really understand sorry ๐Ÿ˜…

And I've tested the macro but there is no message output

urban pasture
#

Is this not for a specific spell cast by actor1, but by any spell cast by anyone?

#

If it's for a specific spell from a specific actor, then you should just need to have an Use script call

ember rune
#

To be more specific, it's a class ability for some homebrew. And yes, the text stipulates that any effect placed by anyone or anything can be dispelled in order to heal for the calculated amount of d6

ember rune
#

I've done an Use Script call on the class ability instead, as you suggested, and here's what the console told me afterwards

urban pasture
#

And yes, the text stipulates that any effect placed by anyone or anything can be dispelled
That's not what I meant. I meant that the only reason to have it in a world script is if you need this macro to fire off for whenever any spell is cast. If you need it for a specific spell, then you want it in the use script for that specific spell

ember rune
#

it works !

#

thanks a lot !

urban pasture
#

No problem, sorry I missed that part yesterday.

ember rune
#

no worries, thank you very much, I'm not that much in a hurry, my players are lvl 2 and that's an ability for 13th level. I wanted some help since i've never used javascript and ChatGPT doing the work for me is not perfect