-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGuidance.js
58 lines (55 loc) · 1.61 KB
/
Guidance.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// new build for guidance macro by Mr.White and Penguin#0949 and with no help all of Kotetsushin#7680 trust me
// version beta 4.2.0
// user notes
// this macro is inteded for use by the recipient of the bless spell in D&D 5e on Forge VTT
// N.B. every recipient will need to use this macro independantly on their own Actor/token.
//user modifiable declarations CHANGE AT YOUR OWN RISK
const GuidIconPath = 'icons/svg/windmill.svg';
let GuideMsg = ' is guided!';
let endGuideMsg = ' is no longer guided.';
//fixed declarations DO NOT MODIFY
let chatMsg = '';
let macroActor = token.actor;
let Guided = macroActor.effects.find(i => i.data.label === "Guided")
let Guide = {
changes: [
{
key: "data.bonuses.abilities.check",
mode: 2,
priority: 20,
value: "+1d4",
},
],
duration: {
"seconds": 6,
},
icon: GuidIconPath,
label: "Guided"
}
//identify token
if (macroActor === undefined || macroActor === null) {
ui.notifications.warn("Please select a token first.");
}
else {
// If already guided
if (Guided) {
macroActor.deleteEmbeddedEntity("ActiveEffect", Guided.id)
// anounce to chat
chatMsg = `${macroActor.name} ${endGuideMsg}`;
}
// if not already guided
else {
macroActor.createEmbeddedEntity("ActiveEffect", Guide)
// anounce to chat
chatMsg = `${macroActor.name} ${GuideMsg}`;
}
// write to chat if needed:
if (chatMsg !== '') {
let chatData = {
user: game.user._id,
speaker: ChatMessage.getSpeaker(),
content: chatMsg
};
ChatMessage.create(chatData, {});
}
}