forked from Kuenaimaku/lancer-bar-brawl-configs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BB_Bolts_v11.js
80 lines (75 loc) · 2.26 KB
/
BB_Bolts_v11.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
// Run this as a script macro in a world to set up the barbrawl defaults for that world, reset all actors' bars to that and set all places tokens to the new bars.
const bars = {
bar1: {
id: "bar1",
attribute: "hp",
ignoreMin: true,
ignoreMax: false,
mincolor: "#FF0000",
maxcolor: "#80FF00",
position: "bottom-inner",
ownerVisibility: CONST.TOKEN_DISPLAY_MODES.ALWAYS,
otherVisibility: CONST.TOKEN_DISPLAY_MODES.OWNER,
},
bar2: {
id: "bar2",
attribute: "heat",
ignoreMax: true,
ignoreMin: false,
mincolor: "#700000",
maxcolor: "#ff0000",
position: "bottom-outer",
ownerVisibility: CONST.TOKEN_DISPLAY_MODES.ALWAYS,
otherVisibility: CONST.TOKEN_DISPLAY_MODES.OWNER,
},
burn: {
id: "burn",
attribute: "burn",
ignoreMax: true,
ignoreMin: false,
style: "none",
hideCombat: true,
hideNoCombat: true,
mincolor: "#992222",
maxcolor: "#992222",
position: "top-outer",
ownerVisibility: CONST.TOKEN_DISPLAY_MODES.ALWAYS,
otherVisibility: CONST.TOKEN_DISPLAY_MODES.OWNER
},
overshield: {
id: "overshield",
attribute: "overshield.value",
ignoreMax: true,
ignoreMin: false,
style: "none",
hideCombat: true,
hideNoCombat: true,
mincolor: "#222299",
maxcolor: "#222299",
position: "top-outer",
ownerVisibility: CONST.TOKEN_DISPLAY_MODES.ALWAYS,
otherVisibility: CONST.TOKEN_DISPLAY_MODES.OWNER
}
};
const barConfig = game.settings.get("barbrawl", "defaultTypeResources") ?? {};
barConfig['mech'] = bars;
barConfig['npc'] = bars;
barConfig['pilot'] = bars;
barConfig['deployable'] = bars;
await game.settings.set("barbrawl", "defaultTypeResources", barConfig);
// :warning: Reset all actors' prototype token bars
await Promise.all(game.actors.map(a => a.update({ "token.flags.barbrawl.resourceBars": bars }, {'diff': false, 'recursive': false})));
// Reset the bars on all existing tokens
await Promise.all(
game.scenes.map(s => {
const updates = s.tokens.filter(t => t.actor).map(t => {
return {
_id: t.id,
"flags.barbrawl.resourceBars": bars,
};
});
return s.updateEmbeddedDocuments("Token", updates, {'diff': false, 'recursive': false});
})
);
ui.notifications.info("Done");
// vim:ft=javascript: