Última actividad 1702333702

high-variance-dice.json Sin formato
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 Sin formato
1const table = game.tables.getName("High Variance");
2const roll = await table.roll();
3const result = roll.results[0];
4const mod = actor.data.data.abilities[actor.data.data.attributes.spellcasting].mod;
5const pb = actor.data.data.attributes.prof;
6const resultNum = />?(\d+)<?/.exec(result.text)[1]
7const finalNum = parseInt(resultNum) + mod + pb;
8let finalText = finalNum;
9if (resultNum === "1") finalText = `<span style="color:red">${finalNum}</span>`;
10if (resultNum === "20") finalText = `<span style="color:green">${finalNum}</span>`;
11
12AudioHelper.play({src: "sounds/dice.wav"});
13
14ChatMessage.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`});