forked from hermannm/foundry-macros
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsword_damage.js
55 lines (55 loc) · 1.81 KB
/
sword_damage.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
const weapon = "Bastard Sword";
const effectToConsume = {
name: "Weapon Surge",
modifier: {
stat: "attack",
},
damageDice: {
selector: "damage",
},
iconPath: "systems/pf2e/icons/spells/weapon-surge.jpg",
};
(async () => {
if (!event.shiftKey) {
if (!event.altKey) {
(actor.data.data.actions ?? [])
.filter((action) => action.type === "strike")
.find((strike) => strike.name === weapon)
?.damage(event, ["", "two-handed"]);
} else {
(actor.data.data.actions ?? [])
.filter((action) => action.type === "strike")
.find((strike) => strike.name === weapon)
?.critical(event, ["", "two-handed"]);
}
} else {
if (!event.altKey) {
(actor.data.data.actions ?? [])
.filter((action) => action.type === "strike")
.find((strike) => strike.name === weapon)
?.damage(event);
} else {
(actor.data.data.actions ?? [])
.filter((action) => action.type === "strike")
.find((strike) => strike.name === weapon)
?.critical(event);
}
}
if (
(
actor.data.data.customModifiers[effectToConsume.modifier.stat] || []
).some((customModifier) => customModifier.name === effectToConsume.name)
) {
if (token.data.effects.includes(effectToConsume.iconPath)) {
await token.toggleEffect(effectToConsume.iconPath);
}
await actor.removeCustomModifier(
effectToConsume.modifier.stat,
effectToConsume.name
);
await actor.removeDamageDice(
effectToConsume.damageDice.selector,
effectToConsume.name
);
}
})();