Skip to content

Instantly share code, notes, and snippets.

@nickelpro
Created November 29, 2021 18:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickelpro/160e4d358b5952158c637aa549e7083e to your computer and use it in GitHub Desktop.
Save nickelpro/160e4d358b5952158c637aa549e7083e to your computer and use it in GitHub Desktop.
const lastArg = args[args.length - 1]
let act = await fromUuid(lastArg.actorUuid)
let calmData = {
"changes": [{ "key": "macro.itemMacro", "mode": 0, "value": 0, "priority": 20 }],
"origin": lastArg.origin,
"icon": "systems/dnd5e/icons/skills/red_02.jpg",
"label": "Berserker Calm",
"transfer": true,
"flags": {
"dae": {
"stackable": "none",
"macroRepeat": "none",
"specialDuration": [
"isDamaged"
],
"transfer": true
}
}
}
let rageData = {
"changes": [{ "key": "macro.itemMacro", "mode": 0, "value": 0, "priority": 20 }],
"label": "Berserker Rage",
"origin": lastArg.origin,
"flags": {
"core": {
"statusId": "berserk"
}
},
"icon": "systems/dnd5e/icons/skills/red_01.jpg"
}
if (args[0] === "off") {
let item = await fromUuid(lastArg.origin)
if (!item.data.data.equipped) {
await act.createEmbeddedDocuments("ActiveEffect", [lastArg.efData])
} else if (lastArg.efData.label === "Berserker Calm") {
let roll = await act.rollAbilitySave("wis")
if (roll.total < 15) {
await act.createEmbeddedDocuments("ActiveEffect", [rageData])
} else {
await act.createEmbeddedDocuments("ActiveEffect", [calmData])
}
} else {
await act.createEmbeddedDocuments("ActiveEffect", [calmData])
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment