Created
November 29, 2021 18:00
-
-
Save nickelpro/160e4d358b5952158c637aa549e7083e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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