-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBless.js
82 lines (79 loc) · 2.13 KB
/
Bless.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// new build for bless macro by Penguin#0949 with help from Kotetsushin#7680
// 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 blessIconPath = 'icons/svg/regen.svg';
let blessMsg = ' is Blessed!';
let endblessMsg = ' is no longer Blessed';
//fixed declarations DO NOT MODIFY
let macroActor = token.actor;
let chatMsg = '';
let Blessd = macroActor.effects.find(i => i.data.label === "Blessed")
let bless = {
changes: [
{
key: "data.bonuses.mwak.attack",
mode: 2,
priority: 20,
value: "+1d4",
},
{
key: "data.bonuses.rwak.attack",
mode: 2,
priority: 20,
value: "+1d4",
},
{
key: "data.bonuses.msak.attack",
mode: 2,
priority: 20,
value: "+1d4",
},
{
key: "mdata.bonuses.rsak.attack",
mode: 2,
priority: 20,
value: "+1d4",
},
{
key: "data.bonuses.abilities.save",
mode: 2,
priority: 20,
value: "+1d4",
},
],
duration: {
"seconds": 6,
},
icon: blessIconPath,
label: "Blessed"
}
//identify token
if (macroActor === undefined || macroActor === null) {
ui.notifications.warn("Please select a token first.");
}
else {
// If already bless
if (Blessd) {
macroActor.deleteEmbeddedEntity("ActiveEffect", Blessd.id)
// anounce to chat
chatMsg = `${macroActor.name} ${endblessMsg}`;
}
// if not already bless
else {
macroActor.createEmbeddedEntity("ActiveEffect", bless)
// anounce to chat
chatMsg = `${macroActor.name} ${blessMsg}`;
}
// write to chat if needed:
if (chatMsg !== '') {
let chatData = {
user: game.user._id,
speaker: ChatMessage.getSpeaker(),
content: chatMsg
};
ChatMessage.create(chatData, {});
}
}