-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTwilight Sanctuary.js
More file actions
36 lines (31 loc) · 948 Bytes
/
Copy pathTwilight Sanctuary.js
File metadata and controls
36 lines (31 loc) · 948 Bytes
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
// 2022-MAR-22
// For Foundry V9
const tokens = canvas.tokens.controlled;
if (tokens.length > 0)
{
await tokens.forEach(UpdateTempHP);
}
else
{
ui.notifications.warn("No Tokens are selected!");
}
async function UpdateTempHP(token)
{
let current_tempHP = token.actor.data.data?.attributes?.hp?.temp;
let cleric = game.actors.getName("ClericName");
// Roll Twilight Sanctuary temporary hit points
let healRoll = new Roll('1d6 + @classes.cleric.levels', cleric.getRollData()).evaluate({async: false});
healRoll.toMessage({
user: game.user._id,
speaker: ChatMessage.getSpeaker(),
flavor: `Twilight Sanctuary - Temporary Hit Points`
});
// Check if new roll is higher than old temp HP
console.log(healRoll);
let new_tempHP = parseInt(healRoll.total);
if (current_tempHP > new_tempHP)
{
new_tempHP = current_tempHP;
}
await token.actor.update({'data.attributes.hp.temp': new_tempHP});
}