high-variance-dice.json
Исходник
{
"name": "High Variance",
"img": "icons/svg/d20-highlight.svg",
"description": "",
"results": [
{
"type": 0,
"weight": 1,
"range": [
1,
3
],
"drawn": false,
"_id": "CNDpsKRWfy1MEL3r",
"text": "<span style=\"color:red\">1</span>",
"documentId": null,
"flags": {},
"img": "icons/svg/d20-black.svg"
},
{
"type": 0,
"weight": 1,
"range": [
4,
5
],
"drawn": false,
"_id": "NeXBHaTGorZGuyok",
"text": "2",
"documentId": null,
"flags": {},
"img": "icons/svg/d20-black.svg"
},
{
"type": 0,
"weight": 1,
"range": [
6,
7
],
"drawn": false,
"_id": "vAtM8PcTGaJ4Qm36",
"text": "3",
"documentId": null,
"flags": {},
"img": "icons/svg/d20-black.svg"
},
{
"type": 0,
"weight": 1,
"range": [
8,
8
],
"drawn": false,
"_id": "Tf7jLYlASY0IXJmG",
"text": "4",
"documentId": null,
"flags": {},
"img": "icons/svg/d20-black.svg"
},
{
"type": 0,
"weight": 1,
"range": [
9,
9
],
"drawn": false,
"_id": "0EyF4w8Mdq50bkUU",
"text": "5",
"documentId": null,
"flags": {},
"img": "icons/svg/d20-black.svg"
},
{
"type": 0,
"weight": 1,
"range": [
10,
10
],
"drawn": false,
"_id": "XVm06G7ALw7VxwyW",
"text": "6",
"documentId": null,
"flags": {},
"img": "icons/svg/d20-black.svg"
},
{
"type": 0,
"weight": 1,
"range": [
11,
11
],
"drawn": false,
"_id": "4RJKBewwniqO5vBz",
"text": "15",
"documentId": null,
"flags": {},
"img": "icons/svg/d20-black.svg"
},
{
"type": 0,
"weight": 1,
"range": [
12,
12
],
"drawn": false,
"_id": "PLjGTLyCMmyVAUOF",
"text": "16",
"documentId": null,
"flags": {},
"img": "icons/svg/d20-black.svg"
},
{
"type": 0,
"weight": 1,
"range": [
13,
13
],
"drawn": false,
"_id": "aqRC9SAKseB3kc24",
"text": "17",
"documentId": null,
"flags": {},
"img": "icons/svg/d20-black.svg"
},
{
"type": 0,
"weight": 1,
"range": [
14,
15
],
"drawn": false,
"_id": "5AgxhHsvtPRdXPme",
"text": "18",
"documentId": null,
"flags": {},
"img": "icons/svg/d20-black.svg"
},
{
"type": 0,
"weight": 1,
"range": [
16,
17
],
"drawn": false,
"_id": "CkxRAfMKLVESQh8B",
"text": "19",
"documentId": null,
"flags": {},
"img": "icons/svg/d20-black.svg"
},
{
"type": 0,
"weight": 1,
"range": [
18,
20
],
"drawn": false,
"_id": "Rgx3fX4e4BWTaEr6",
"text": "<span style=\"color:green\">20</span>",
"documentId": null,
"flags": {},
"img": "icons/svg/d20-black.svg"
}
],
"replacement": true,
"displayRoll": false,
"folder": null,
"flags": {
"exportSource": {
"world": "hotbed",
"system": "dnd5e",
"coreVersion": "11.315",
"systemVersion": "2.4.1"
}
},
"_stats": {
"systemId": "dnd5e",
"systemVersion": "2.4.1",
"coreVersion": "11.315",
"createdTime": 1702319249667,
"modifiedTime": 1702321974523,
"lastModifiedBy": "ecDJcA6q1LI8LxNv"
},
"formula": "1d20"
}
1 | { |
2 | "name": "High Variance", |
3 | "img": "icons/svg/d20-highlight.svg", |
4 | "description": "", |
5 | "results": [ |
6 | { |
7 | "type": 0, |
8 | "weight": 1, |
9 | "range": [ |
10 | 1, |
11 | 3 |
12 | ], |
13 | "drawn": false, |
14 | "_id": "CNDpsKRWfy1MEL3r", |
15 | "text": "<span style=\"color:red\">1</span>", |
16 | "documentId": null, |
17 | "flags": {}, |
18 | "img": "icons/svg/d20-black.svg" |
19 | }, |
20 | { |
21 | "type": 0, |
22 | "weight": 1, |
23 | "range": [ |
24 | 4, |
25 | 5 |
26 | ], |
27 | "drawn": false, |
28 | "_id": "NeXBHaTGorZGuyok", |
29 | "text": "2", |
30 | "documentId": null, |
31 | "flags": {}, |
32 | "img": "icons/svg/d20-black.svg" |
33 | }, |
34 | { |
35 | "type": 0, |
36 | "weight": 1, |
37 | "range": [ |
38 | 6, |
39 | 7 |
40 | ], |
41 | "drawn": false, |
42 | "_id": "vAtM8PcTGaJ4Qm36", |
43 | "text": "3", |
44 | "documentId": null, |
45 | "flags": {}, |
46 | "img": "icons/svg/d20-black.svg" |
47 | }, |
48 | { |
49 | "type": 0, |
50 | "weight": 1, |
51 | "range": [ |
52 | 8, |
53 | 8 |
54 | ], |
55 | "drawn": false, |
56 | "_id": "Tf7jLYlASY0IXJmG", |
57 | "text": "4", |
58 | "documentId": null, |
59 | "flags": {}, |
60 | "img": "icons/svg/d20-black.svg" |
61 | }, |
62 | { |
63 | "type": 0, |
64 | "weight": 1, |
65 | "range": [ |
66 | 9, |
67 | 9 |
68 | ], |
69 | "drawn": false, |
70 | "_id": "0EyF4w8Mdq50bkUU", |
71 | "text": "5", |
72 | "documentId": null, |
73 | "flags": {}, |
74 | "img": "icons/svg/d20-black.svg" |
75 | }, |
76 | { |
77 | "type": 0, |
78 | "weight": 1, |
79 | "range": [ |
80 | 10, |
81 | 10 |
82 | ], |
83 | "drawn": false, |
84 | "_id": "XVm06G7ALw7VxwyW", |
85 | "text": "6", |
86 | "documentId": null, |
87 | "flags": {}, |
88 | "img": "icons/svg/d20-black.svg" |
89 | }, |
90 | { |
91 | "type": 0, |
92 | "weight": 1, |
93 | "range": [ |
94 | 11, |
95 | 11 |
96 | ], |
97 | "drawn": false, |
98 | "_id": "4RJKBewwniqO5vBz", |
99 | "text": "15", |
100 | "documentId": null, |
101 | "flags": {}, |
102 | "img": "icons/svg/d20-black.svg" |
103 | }, |
104 | { |
105 | "type": 0, |
106 | "weight": 1, |
107 | "range": [ |
108 | 12, |
109 | 12 |
110 | ], |
111 | "drawn": false, |
112 | "_id": "PLjGTLyCMmyVAUOF", |
113 | "text": "16", |
114 | "documentId": null, |
115 | "flags": {}, |
116 | "img": "icons/svg/d20-black.svg" |
117 | }, |
118 | { |
119 | "type": 0, |
120 | "weight": 1, |
121 | "range": [ |
122 | 13, |
123 | 13 |
124 | ], |
125 | "drawn": false, |
126 | "_id": "aqRC9SAKseB3kc24", |
127 | "text": "17", |
128 | "documentId": null, |
129 | "flags": {}, |
130 | "img": "icons/svg/d20-black.svg" |
131 | }, |
132 | { |
133 | "type": 0, |
134 | "weight": 1, |
135 | "range": [ |
136 | 14, |
137 | 15 |
138 | ], |
139 | "drawn": false, |
140 | "_id": "5AgxhHsvtPRdXPme", |
141 | "text": "18", |
142 | "documentId": null, |
143 | "flags": {}, |
144 | "img": "icons/svg/d20-black.svg" |
145 | }, |
146 | { |
147 | "type": 0, |
148 | "weight": 1, |
149 | "range": [ |
150 | 16, |
151 | 17 |
152 | ], |
153 | "drawn": false, |
154 | "_id": "CkxRAfMKLVESQh8B", |
155 | "text": "19", |
156 | "documentId": null, |
157 | "flags": {}, |
158 | "img": "icons/svg/d20-black.svg" |
159 | }, |
160 | { |
161 | "type": 0, |
162 | "weight": 1, |
163 | "range": [ |
164 | 18, |
165 | 20 |
166 | ], |
167 | "drawn": false, |
168 | "_id": "Rgx3fX4e4BWTaEr6", |
169 | "text": "<span style=\"color:green\">20</span>", |
170 | "documentId": null, |
171 | "flags": {}, |
172 | "img": "icons/svg/d20-black.svg" |
173 | } |
174 | ], |
175 | "replacement": true, |
176 | "displayRoll": false, |
177 | "folder": null, |
178 | "flags": { |
179 | "exportSource": { |
180 | "world": "hotbed", |
181 | "system": "dnd5e", |
182 | "coreVersion": "11.315", |
183 | "systemVersion": "2.4.1" |
184 | } |
185 | }, |
186 | "_stats": { |
187 | "systemId": "dnd5e", |
188 | "systemVersion": "2.4.1", |
189 | "coreVersion": "11.315", |
190 | "createdTime": 1702319249667, |
191 | "modifiedTime": 1702321974523, |
192 | "lastModifiedBy": "ecDJcA6q1LI8LxNv" |
193 | }, |
194 | "formula": "1d20" |
195 | } |
macro.js
Исходник
const table = game.tables.getName("High Variance");
const roll = await table.roll();
const result = roll.results[0];
const mod = actor.data.data.abilities[actor.data.data.attributes.spellcasting].mod;
const pb = actor.data.data.attributes.prof;
const resultNum = />?(\d+)<?/.exec(result.text)[1]
const finalNum = parseInt(resultNum) + mod + pb;
let finalText = finalNum;
if (resultNum === "1") finalText = `<span style="color:red">${finalNum}</span>`;
if (resultNum === "20") finalText = `<span style="color:green">${finalNum}</span>`;
AudioHelper.play({src: "sounds/dice.wav"});
ChatMessage.create({flavor: "Attack Roll", content: `
<div class="dice-roll">
<div class="dice-result">
<div class="dice-formula">1d[High Variance] + ${mod} + ${pb}</div>
<div class="dice-tooltip" style="display: none;">
<section class="tooltip-part">
<div class="dice">
<header class="part-header flexrow">
<span class="part-formula">1d[High Variance]</span>
<span class="part-total">${result.text}</span>
</header>
<ol class="dice-rolls">
<li class="roll die High Variance">${result.text}</li>
</ol>
</div>
</section>
</div>
<h4 class="dice-total">${finalText}</h4>
</div>
</div>
`});
1 | const table = game.tables.getName("High Variance"); |
2 | const roll = await table.roll(); |
3 | const result = roll.results[0]; |
4 | const mod = actor.data.data.abilities[actor.data.data.attributes.spellcasting].mod; |
5 | const pb = actor.data.data.attributes.prof; |
6 | const resultNum = />?(\d+)<?/.exec(result.text)[1] |
7 | const finalNum = parseInt(resultNum) + mod + pb; |
8 | let finalText = finalNum; |
9 | if (resultNum === "1") finalText = `<span style="color:red">${finalNum}</span>`; |
10 | if (resultNum === "20") finalText = `<span style="color:green">${finalNum}</span>`; |
11 | |
12 | AudioHelper.play({src: "sounds/dice.wav"}); |
13 | |
14 | ChatMessage.create({flavor: "Attack Roll", content: ` |
15 | <div class="dice-roll"> |
16 | <div class="dice-result"> |
17 | <div class="dice-formula">1d[High Variance] + ${mod} + ${pb}</div> |
18 | <div class="dice-tooltip" style="display: none;"> |
19 | <section class="tooltip-part"> |
20 | <div class="dice"> |
21 | <header class="part-header flexrow"> |
22 | <span class="part-formula">1d[High Variance]</span> |
23 | <span class="part-total">${result.text}</span> |
24 | </header> |
25 | <ol class="dice-rolls"> |
26 | <li class="roll die High Variance">${result.text}</li> |
27 | </ol> |
28 | </div> |
29 | </section> |
30 | </div> |
31 | <h4 class="dice-total">${finalText}</h4> |
32 | </div> |
33 | </div> |
34 | `}); |