-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTreasureHoard.js
1922 lines (1838 loc) · 171 KB
/
TreasureHoard.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//Takes in an array of options and returns one randomly.
function select_random(choices) {
return choices[RandomInt(choices.length)-1]
}
function RandomInt(m) {
var max = m;
var min = 1 ;
var d = max - min + 1; // distribution range
return Math.floor(Math.random() * d + min);
}
//Chooses a set of armor based of of utility, which is AC (-1 for stealth disadvantage)
//Generally, the higher an armor's AC, the less likely it is to be chosen
function choose_armor(type) {
armor_value_total = 0
armor_result = []
for(amt_armors = armor.length; amt_armors > 0; amt_armors--, armor_value_total = armor_value_total + armor_value) {
if(type == 'mithral' && armor[Math.floor(amt_armors - 1)][2] == 'light') {armor_value = 0}
else if(type == 'mithral' && armor[Math.floor(amt_armors - 1)][0] == 'hide') {armor_value = 0}
else {armor_value = armor[Math.floor(amt_armors - 1)][1]}
}
//sendChat(msg.who, "/w gm Armor value total is " + armor_value_total) /* DEBUG */
for(amt_armors = armor.length, armor_low = 1; amt_armors > 0; amt_armors--) {
//armor_name = armor[Math.floor(amt_armors - 1)][0]
if(type == 'mithral' && armor[Math.floor(amt_armors - 1)][2] == 'light') {}
else if(type == 'mithral' && armor[Math.floor(amt_armors - 1)][0] == 'hide') {}
else {armor[Math.floor(amt_armors - 1)][3] = armor_low
armor_high = armor_low + Math.floor(armor_value_total / armor[Math.floor(amt_armors - 1)][1])
armor[Math.floor(amt_armors - 1)][4] = armor_high
armor_low = armor_high + 1
}
//sendChat(msg.who, "/w gm " + armor_name + " armor low has been set to " + armor[Math.floor(amt_armors - 1)][3] + " and high has been set to " + armor[Math.floor(amt_armors - 1)][4]) /* DEBUG */
}
armor_roll = RandomInt(armor_high)
//sendChat(msg.who, "/w gm Armor roll is [[" + armor_roll + "]] (d" + armor_high + ")") /* DEBUG */
for(amt_armors = armor.length; amt_armors > 0; amt_armors--) {
if(type == 'mithral' && armor[Math.floor(amt_armors - 1)][2] == 'light') {}
else if(type == 'mithral' && armor[Math.floor(amt_armors - 1)][0] == 'hide') {}
else if(armor_roll >= armor[Math.floor(amt_armors - 1)][3] && armor_roll <= armor[Math.floor(amt_armors - 1)][4]) {
armor_result = armor[Math.floor(amt_armors - 1)]
}
}
return armor_result
}
function choose_weapon(type) {
weapon_utility_total = 0
weapon_result = 0
for(amt_weapons = weapons.length; amt_weapons > 0; amt_weapons--, weapon_utility_total = weapon_utility_total + weapon_utility) {
if(type == 'sword' && weapons[Math.floor(amt_weapons - 1)][3] != 'sword') {weapon_utility = 0}
else if(type == 'axe' && weapons[Math.floor(amt_weapons - 1)][3] != 'axe') {weapon_utility = 0}
else if(type == 'slashing' && weapons[Math.floor(amt_weapons - 1)][2] != 'slashing') {weapon_utility = 0}
else{weapon_utility = weapons[Math.floor(amt_weapons - 1)][1]}
}
for(amt_weapons = weapons.length, weapon_low = 1; amt_weapons > 0; amt_weapons--) {
if(type == 'sword' && weapons[Math.floor(amt_weapons - 1)][3] != 'sword') {}
else if(type == 'axe' && weapons[Math.floor(amt_weapons - 1)][3] != 'axe') {}
else if(type == 'slashing' && weapons[Math.floor(amt_weapons - 1)][2] != 'slashing') {}
else {weapons[Math.floor(amt_weapons - 1)][4] = weapon_low
weapon_high = weapon_low + Math.floor(weapon_utility_total / weapons[Math.floor(amt_weapons - 1)][1])
weapons[Math.floor(amt_weapons - 1)][5] = weapon_high
weapon_low = weapon_high + 1
}
}
weapon_roll = RandomInt(weapon_high)
for(amt_weapons = weapons.length; amt_weapons > 0; amt_weapons--) {
if(type == 'sword' && weapons[Math.floor(amt_weapons - 1)][3] != 'sword') {}
else if(type == 'axe' && weapons[Math.floor(amt_weapons - 1)][3] != 'axe') {}
else if(type == 'slashing' && weapons[Math.floor(amt_weapons - 1)][2] != 'slashing') {}
else if(weapon_roll >= weapons[Math.floor(amt_weapons - 1)][4] && weapon_roll <= weapons[Math.floor(amt_weapons - 1)][5]) {
weapon_result = weapons[Math.floor(amt_weapons - 1)]
}
}
return weapon_result
}
function resistance_type() {
resistance_roll = RandomInt(10)
resistance_result = 0
if(resistance_roll == 1) {resistance_result = 'acid'}
if(resistance_roll == 2) {resistance_result = 'cold'}
if(resistance_roll == 3) {resistance_result = 'fire'}
if(resistance_roll == 4) {resistance_result = 'force'}
if(resistance_roll == 5) {resistance_result = 'lightning'}
if(resistance_roll == 6) {resistance_result = 'necrotic'}
if(resistance_roll == 7) {resistance_result = 'poison'}
if(resistance_roll == 8) {resistance_result = 'psychic'}
if(resistance_roll == 9) {resistance_result = 'radiant'}
if(resistance_roll == 10) {resistance_result = 'thunder'}
return resistance_result
}
function scroll_spell(lvl) {
spell_name = 0
if(lvl != 'cantrip') {lvl_roll = RandomInt(lvl) - 1}
if(lvl == 'cantrip') {
spell_name = cantrips[Math.floor(Math.random() * cantrips.length)]
}
else {spell_name = spells[lvl_roll][Math.floor(Math.random() * spells[lvl_roll].length)]}
return spell_name
}
on("chat:message", function(msg) {
var loot = ""
//set Teasure Hoard Challenge Level with !mtt [level]
if(msg.type == "api" && msg.content.indexOf("!mtt ") !== -1) {
treasure_table_level = msg.content.replace("!mtt ", "")
//Roll the d100 that determines amount of gems, art and magic items
treasure_hoard_d100 = RandomInt(100)
//Roll result only goes to the GM
// sendChat(msg.who, "/w gm You roll " + treasure_hoard_d100 + " (d100).")
sendChat(msg.who, "/w gm Started Treasure generation")
//Define some variables
treasure_hoard_variables = [
treasure_hoard_cp = 0,
treasure_hoard_sp = 0,
treasure_hoard_ep = 0,
treasure_hoard_gp = 0,
treasure_hoard_pp = 0,
gems = [
amt_10_gp_gems = 0,
amt_50_gp_gems = 0,
amt_100_gp_gems = 0,
amt_500_gp_gems = 0,
amt_1000_gp_gems = 0,
amt_5000_gp_gems = 0
],
art = [
amt_25_gp_art = 0,
amt_250_gp_art = 0,
amt_750_gp_art = 0,
amt_2500_gp_art = 0,
amt_7500_gp_art = 0
],
mit = [
amt_mit_a = 0,
amt_mit_b = 0,
amt_mit_c = 0,
amt_mit_d = 0,
amt_mit_e = 0,
amt_mit_f = 0,
amt_mit_g = 0,
amt_mit_h = 0,
amt_mit_i = 0
],
cantrips = [
'Acid Splash',
'Blade Ward',
'Chill Touch',
'Dancing Lights',
'Druidcraft',
'Eldritch Blast',
'Fire Bolt',
'Friends',
'Guidance',
'Light',
'Mage Hand',
'Mending',
'Message',
'Minor Illusion',
'Poison Spray',
'Prestidigitation',
'Produce Flame',
'Ray of Frost',
'Resistance',
'Sacred Flame',
'Shillelagh',
'Shocking Grasp',
'Spare the Dying',
'Thaumaturgy',
'Thorn Whip',
'True Strike',
'Vicious Mockery'
],
spells = [
spells_1 = [
'Alarm',
'Animal Friendship',
'Armor of Agathys',
'Arms of Hadar',
'Bane',
'Bless',
'Burning Hands',
'Charm Person',
'Chromatic Orb',
'Color Spray',
'Command',
'Compelled Duel',
'Comprehend Languages',
'Create or Destroy Water',
'Cure Wounds',
'Detect Evil and Good',
'Detect Magic',
'Detect Poison and Disease',
'Disguise Self',
'Dissonant Whispers',
'Divine Favor',
'Ensnaring Strike',
'Entangle',
'Expeditious Retreat',
'Faerie Fire',
'False Life',
'Feather Fall',
'Find Familiar',
'Fog Cloud',
'Goodberry',
'Grease',
'Guiding Bolt',
'Hail of Thorns',
'Healing Word',
'Hellish Rebuke',
'Heroism',
'Hex',
'Hunters Mark',
'Identify',
'Illusory Script',
'Inflict Wounds',
'Jump',
'Longstrider',
'Mage Armor',
'Magic Missile',
'Protection from Evil and Good',
'Purify Food and Drink',
'Ray of Sickness',
'Sanctuary',
'Searing Flame',
'Shield',
'Shield of Faith',
'Silent Image',
'Sleep',
'Speak with Animals',
'Tashas Hideous Laughter',
'Tensers Floating Orb',
'Thunderous Smite',
'Thunderwave',
'Unseen Servant',
'Witch Bolt',
'Wrathful Smite'
],
spells_2 = [
'Aid',
'Alter Self',
'Animal Messenger',
'Arcane Lock',
'Barkskin',
'Beast Sense',
'Blindness/Deafness',
'Blur',
'Branding Smite',
'Calm Emotions',
'Cloud of Daggers',
'Continual Flame',
'Cordon of Arrows',
'Crown of Madness',
'Darkness',
'Darkvision',
'Detect Thoughts',
'Enhance Ability',
'Enlarge/Reduce',
'Enthrall',
'Find Steed',
'Find Traps',
'Flame Blade',
'Flaming Sphere',
'Gentle Repose',
'Gust of Wind',
'Heat Metal',
'Hold Person',
'Invisibility',
'Knock',
'Lesser Restoration',
'Levitate',
'Locate Animals or Plants',
'Locate Object',
'Magic Mouth',
'Magic Weapon',
'Melfs Acid Arrow',
'Mirror Image',
'Misty Step',
'Moonbeam',
'Nystuls Magic Aura',
'Pass Without Trace',
'Phantasmal Force',
'Prayer of Healing',
'Protection from Poison',
'Ray of Enfeeblement',
'Rope Trick',
'Scorching Ray',
'See Invisibility',
'Shatter',
'Silence',
'Spider Climb',
'Spike Growth',
'Spiritual Weapon',
'Suggestion',
'Warding Bond',
'Web',
'Zone of Truth',
],
spells_3 = [
'Animate Dead',
'Aura of Vitality',
'Beacon of Hope',
'Bestow Curse',
'Blinding Smite',
'Blink',
'Call Lightning',
'Clairvoyance',
'Conjure Animals',
'Conjura Barrage',
'Counterspell',
'Create Food and Water',
'Crusaders Mantle',
'Daylight',
'Dispel Magic',
'Elemental Weapon',
'Fear',
'Feign Death',
'Fireball',
'Fly',
'Gaseous Form',
'Glyph of Warding',
'Haste',
'Hunger of Hadar',
'Hypnotic Pattern',
'Leomunds Tiny Hut',
'Lightning Arrow',
'Lightning Bolt',
'Magic Circle',
'Major Image',
'Mass Healing Ward',
'Meld Into Stone',
'Nondetection',
'Phantom Steed',
'Plant Growth',
'Protection from Energy',
'Remove Curse',
'Revivify',
'Sending',
'Sleet Storm',
'Slow',
'Speak with Dead',
'Speak with Plants',
'Spirit Guardians',
'Stinking Cloud',
'Tongues',
'Vampiric Touch',
'Water Breathing',
'Water Walk',
'Wind Wall',
],
spells_4 = [
'Arcane Eye',
'Aura of Life',
'Aura of Purity',
'Banishment',
'Blight',
'Compulsion',
'Confusion',
'Conjure Minor Elementals',
'Conjure Woodland Beings',
'Control Water',
'Death Ward',
'Dimension Door',
'Divination',
'Dominate Beast',
'Evards Black Tentacles',
'Fabricate',
'Fire Shield',
'Freedom of Movement',
'Giant Insect',
'Grasping Vines',
'Greater Invisibility',
'Guardians of Faith',
'Hallucinatory Terrain',
'Ice Storm',
'Leomunds Secret Chest',
'Locate Creature',
'Mordenkainens Faithful Hound',
'Mordenkainens Private Sanctum',
'Otilukes Resilient Sphere',
'Phantasmal Killer',
'Polymorph',
'Staggering Smite',
'Stone Shape',
'Stoneskin',
'Wall of Fire',
],
spells_5 = [
'Animate Objects',
'Antilife Shell',
'Awaken',
'Banishing Smite',
'Bigbys Hand',
'Circle of Power',
'Cloudkill',
'Commune',
'Commune with Nature',
'Cone of Cold',
'Conjure Elemental',
'Conjure Volley',
'Contact Other Plane',
'Contagion',
'Creation',
'Destructive Smite',
'Dispel Evil and Good',
'Dominate Person',
'Dream',
'Flame Strike',
'Geas',
'Greater Restoration',
'Hallow',
'Hold Monster',
'Insect Plague',
'Legend Lore',
'Mass Cure Wounds',
'Mislead',
'Modify Memory',
'Passwall',
'Planar Binding',
'Raise Dead',
'Rarys Telepathic Bond',
'Reincarnate',
'Scrying',
'Seeming',
'Swift Quiver',
'Telekinesis',
'Teleportation Circle',
'Tree Stride',
'Wall of Force',
'Wall of Stone',
],
],
ammo = [
'arrow',
'blowgun needle',
'crossbow bolt',
'sling bullet',
],
armor = [
//For each, ['name', utility, 'type', weight]
//Utility is AC
armor_padded = ['padded', 11, 'light', 8],
armor_leather = ['leather', 11, 'light', 10],
armor_studded_leather = ['studded leather', 12, 'light', 13],
armor_hide = ['hide', 12, 'medium', 12],
armor_chain_shirt = ['chain shirt', 13, 'medium', 20],
armor_scale_mail = ['scale mail', 14, 'medium', 45],
armor_breastplate = ['breastplate', 14, 'medium', 20],
armor_half_plate = ['half plate', 15, 'medium', 40],
armor_ring_mail = ['ring mail', 14, 'heavy', 40],
armor_chain_mail = ['chain mail', 16, 'heavy', 55],
armor_splint = ['splint', 17, 'heavy', 60],
armor_plate = ['plate', 18, 'heavy', 65],
],
weapons = [
//For each, ['name', utility, 'damage type', 'weapon type', 'damage', 'weight', 'properties', 'modifiers']
//Utility is calculated by the following:
//max damage + min damage
//+ 1 each for reach, finesse, versatile, thrown, light
//- 1 each for heavy, two-handed, loading0
weapon_club = ['club', 6, 'bludgeoning', 'club', '1d4', '2', 'Light', 'Item Type: Melee Weapon, Damage: 1d4, Damage Type: bludgeoning'],
weapon_dagger = ['dagger', 8, 'piercing', 'dagger', '1d4', '1', 'Finesse, light, thrown (range 20/60)', 'Item Type: Melee Weapon, Damage: 1d4, Damage Type: Piercing, Range: 20/60'],
weapon_greatclub = ['greatclub', 8, 'bludgeoning', 'club', '1d8', '10', 'Two-handed', 'Item Type: Melee Weapon, Damage: 1d8, Damage Type: bludgeoning'],
weapon_handaxe = ['handaxe', 9, 'slashing', 'axe', '1d6', '2', 'Light, thrown (range 20/60)', 'Item Type: Melee Weapon, Damage: 1d6, Damage Type: slashing, Range: 20/60'],
weapon_javelin = ['javelin', 8, 'piercing', 'javelin', '1d6', '2', 'Thrown (range 30/120)', 'Item Type: Melee Weapon, Damage: 1d6, Damage Type: piercing, Range: 30/120'],
weapon_light_hammer = ['light hammer', 7, 'bludgeoning', 'hammer', '1d4', '2', 'Light, thrown (range 20/60)', 'Item Type: Melee Weapon, Damage: 1d4, Damage Type: bludgeoning, Range: 20/60'],
weapon_mace = ['mace', 7, 'bludgeoning', 'mace', '1d6', '4', '', 'Item Type: Melee Weapon, Damage: 1d6, Damage Type: bludgeoning'],
weapon_quarterstaff = ['quarterstaff', 8, 'bludgeoning', 'staff', '1d6', '4', 'Versatile (1d8)', 'Item Type: Melee Weapon, Damage: 1d6, Damage Type: bludgeoning'],
weapon_sickle = ['sickle', 6, 'slashing', 'sickle', '1d4', '2', 'Light', 'Item Type: Melee Weapon, Damage: 1d4, Damage Type: slashing'],
weapon_spear = ['spear', 9, 'piercing', 'spear', '1d6', '3', 'Thrown (range 20/60), versatile (1d8)', 'Item Type: Melee Weapon, Damage: 1d6, Damage Type: piercing, Range: 20/60'],
weapon_crossbow_light = ['light crossbow', 7, 'piercing', 'crossbow', '1d8', '5', 'Ammunition (range 80/320), loading, two-handed', 'Item Type: Ranged Weapon, Damage: 1d8, Damage Type: piercing, Range: 80/320'],
weapon_dart = ['dart', 7, 'piercing', 'dart', '1d4', '0.25', 'Finesse, thrown (range 20/60)', 'Item Type: Ranged Weapon, Damage: 1d4, Damage Type: piercing, Range: 20/60'],
weapon_shortbow = ['shortbow', 6, 'piercing', 'bow', '1d6', '2', 'Ammunition (range 80/320), two-handed', 'Item Type: Ranged Weapon, Damage: 1d6, Damage Type: piercing, Range: 80/320'],
weapon_sling = ['sling', 5, 'bludgeoning', 'sling', '1d4', '0', 'Ammunition (range 30/120)', 'Item Type: Ranged Weapon, Damage: 1d8, Damage Type: bludgeoning, Range: 30/120'],
weapon_battleaxe = ['battleaxe', 10, 'slashing', 'axe', '1d8', '4', 'Versatile (1d10)', 'Item Type: Melee Weapon, Damage: 1d8, Damage Type: slashing'],
weapon_flail = ['flail', 9, 'bludgeoning', 'flail', '1d8', '2', '', 'Item Type: Melee Weapon, Damage: 1d8, Damage Type: bludgeoning'],
weapon_glaive = ['glaive', 10, 'slashing', 'polearm', '1d10', '6', 'Heavy, reach, two-handed', 'Item Type: Melee Weapon, Damage: 1d10, Damage Type: slashing'],
weapon_greataxe = ['greataxe', 11, 'slashing', 'axe', '1d12', '7', 'Heavy, two-handed', 'Item Type: Melee Weapon, Damage: 1d12, Damage Type: slashing'],
weapon_greatsword = ['greatsword', 12, 'slashing', 'sword', '2d6', '6', 'Heavy, two-handed', 'Item Type: Melee Weapon, Damage: 2d6, Damage Type: slashing'],
weapon_halberd = ['halberd', 10, 'slashing', 'polearm', '1d10', '6', 'Heavy, reach, two-handed', 'Item Type: Melee Weapon, Damage: 1d10, Damage Type: slashing'],
weapon_lance = ['lance', 10, 'piercing', 'lance', '1d12', '6', 'Reach, special', 'Item Type: Melee Weapon, Damage: 1d12, Damage Type: piercing'],
weapon_longsword = ['longsword', 10, 'slashing', 'sword', '1d8', '3', 'Versatile (1d10)', 'Item Type: Melee Weapon, Damage: 1d8, Damage Type: slashing'],
weapon_maul = ['maul', 12, 'bludgeoning', 'maul', '2d6', '10', 'Heavy, two-handed', 'Item Type: Melee Weapon, Damage: 2d6, Damage Type: bludgeoning'],
weapon_morningstar = ['morningstar', 10, 'piercing', 'morningstar', '1d8', '4', '', 'Item Type: Melee Weapon, Damage: 1d8, Damage Type: piercing'],
weapon_pike = ['pike', 10, 'piercing', 'polearm', '1d10', '18', 'Heavy, reach, two-handed', 'Item Type: Melee Weapon, Damage: 1d10, Damage Type: piercing'],
weapon_rapier = ['rapier', 10, 'piercing', 'sword', '1d8', '2', 'Finesse', 'Item Type: Melee Weapon, Damage: 1d8, Damage Type: piercing'],
weapon_scimitar = ['scimitar', 9, 'slashing', 'sword', '1d6', '3', 'Finesse, light', 'Item Type: Melee Weapon, Damage: 1d6, Damage Type: slashing'],
weapon_shortsword = ['shortsword', 9, 'piercing', 'sword', '1d6', '2', 'Finesse, light', 'Item Type: Melee Weapon, Damage: 1d6, Damage Type: piercing'],
weapon_trident = ['trident', 9, 'piercing', 'trident', '1d6', '4', 'Thrown (range 20/60), versatile (1d8)', 'Item Type: Melee Weapon, Damage: 1d6, Damage Type: piercing, Range: 20/60'],
weapon_war_pick = ['war pick', 9, 'piercing', 'war pick', '1d8', '2', '', 'Item Type: Melee Weapon, Damage: 1d8, Damage Type: piercing'],
weapon_warhammer = ['warhammer', 10, 'bludgeoning', 'hammer', '1d8', '2', 'Versatile (1d10)', 'Item Type: Melee Weapon, Damage: 1d8, Damage Type: bludgeoning'],
weapon_whip = ['whip', 7, 'slashing', 'whip', '1d4', '3', 'Finesse, reach', 'Item Type: Melee Weapon, Damage: 1d4, Damage Type: slashing'],
weapon_blowgun = ['blowgun', 3, 'piercing', 'blowgun', '1', '1', 'Ammunition (range 25/100), loading', 'Item Type: Ranged Weapon, Damage: 1, Damage Type: piercing, Range: 25/100'],
weapon_crossbow_hand = ['hand crossbow', 8, 'piercing', 'crossbow', '1d6', '3', 'Ammunition (range 30/120), light, loading', 'Item Type: Ranged Weapon, Damage: 1d6, Damage Type: piercing, Range: 30/120'],
weapon_crossbow_heavy = ['heavy crossbow', 8, 'piercing', 'crossbow', '1d10', '18', 'Ammunition (range 100/400), heavy, loading, two-handed', 'Item Type: Ranged Weapon, Damage: 1d10, Damage Type: piercing, Range: 100/400'],
weapon_longbow = ['longbow', 8, 'piercing', 'bow', '1d8', '2', 'Ammunition (range 150/600), heavy, two-handed', 'Item Type: Ranged Weapon, Damage: 1d8, Damage Type: piercing, Range: 150/600'],
],
]
//Return error if level is < 0
if(treasure_table_level < 0) {
//sendChat(msg.who, "/w gm ERROR: The value must be a positive integer")
treasure_table_level = 0
return;
}
//Roll from Treasure Hoard: Challenge 0-4
if(treasure_table_level < 5) {
//sendChat(msg.who, "/w gm Rolling from Treasure Hoard: Challenge 0-4")
//calculte currency reward from Treasure Hoard: Challenge 0-4
treasure_hoard_cp = Math.floor((RandomInt(6) + RandomInt(6) + RandomInt(6) + RandomInt(6) + RandomInt(6) + RandomInt(6)) * 100)
treasure_hoard_sp = Math.floor((RandomInt(6) + RandomInt(6) + RandomInt(6)) * 100)
treasure_hoard_gp = Math.floor((RandomInt(6) + RandomInt(6)) * 10)
//determine gems, art objects and magic item rewards based off of the d100 roll
if(treasure_hoard_d100 < 7) {}
else if(treasure_hoard_d100 < 17) {amt_10_gp_gems = Math.floor(RandomInt(6) + RandomInt(6))}
else if(treasure_hoard_d100 < 27) {amt_25_gp_art = Math.floor(RandomInt(4) + RandomInt(4))}
else if(treasure_hoard_d100 < 37) {amt_50_gp_gems = Math.floor(RandomInt(6) + RandomInt(6))}
else if(treasure_hoard_d100 < 45) {
amt_10_gp_gems = Math.floor(RandomInt(6) + RandomInt(6))
amt_mit_a = RandomInt(6)}
else if(treasure_hoard_d100 < 53) {
amt_25_gp_art = Math.floor(RandomInt(4) + RandomInt(4))
amt_mit_a = RandomInt(6)}
else if(treasure_hoard_d100 < 61) {
amt_50_gp_gems = Math.floor(RandomInt(6) + RandomInt(6))
amt_mit_a = RandomInt(6)}
else if(treasure_hoard_d100 < 66) {
amt_10_gp_gems = Math.floor(RandomInt(6) + RandomInt(6))
amt_mit_b = RandomInt(4)}
else if(treasure_hoard_d100 < 71) {
amt_25_gp_art = Math.floor(RandomInt(4) + RandomInt(4))
amt_mit_b = RandomInt(4)}
else if(treasure_hoard_d100 < 76) {
amt_50_gp_gems = Math.floor(RandomInt(6) + RandomInt(6))
amt_mit_b = RandomInt(4)}
else if(treasure_hoard_d100 < 79) {
amt_10_gp_gems = Math.floor(RandomInt(6) + RandomInt(6))
amt_mit_c = RandomInt(4)}
else if(treasure_hoard_d100 < 81) {
amt_25_gp_art = Math.floor(RandomInt(4) + RandomInt(4))
amt_mit_c = RandomInt(4)}
else if(treasure_hoard_d100 < 86) {
amt_50_gp_gems = Math.floor(RandomInt(6) + RandomInt(6))
amt_mit_c = RandomInt(4)}
else if(treasure_hoard_d100 < 93) {
amt_25_gp_art = Math.floor(RandomInt(4) + RandomInt(4))
amt_mit_f = RandomInt(4)}
else if(treasure_hoard_d100 < 98) {
amt_50_gp_gems = Math.floor(RandomInt(6) + RandomInt(6))
amt_mit_f = RandomInt(4)}
else if(treasure_hoard_d100 < 100) {
amt_25_gp_art = Math.floor(RandomInt(4) + RandomInt(4))
amt_mit_g = 1}
else if(treasure_hoard_d100 == 100) {
amt_50_gp_gems = Math.floor(RandomInt(6) + RandomInt(6))
amt_mit_g = 1}
}
//Roll from Treasure Hoard: Challenge 5-10
else if(treasure_table_level < 11) {
//sendChat(msg.who, "/w gm Rolling from Treasure Hoard: Challenge 5-10")
//calculte currency reward from Treasure Hoard: Challenge 5-10
treasure_hoard_cp = Math.floor((RandomInt(6) + RandomInt(6)) * 100)
treasure_hoard_sp = Math.floor((RandomInt(6) + RandomInt(6)) * 1000)
treasure_hoard_gp = Math.floor((RandomInt(6) + RandomInt(6) + RandomInt(6)
+ RandomInt(6) + RandomInt(6) + RandomInt(6)) * 100)
treasure_hoard_pp = Math.floor((RandomInt(6) + RandomInt(6) + RandomInt(6)) * 10)
if(treasure_hoard_d100 < 5) {}
else if(treasure_hoard_d100 < 11) {amt_25_gp_art = Math.floor(RandomInt(4) + RandomInt(4))}
}
//Determine type and amount of gemstones, then print to chat
//10 gp Gemstones
if(amt_10_gp_gems > 0) {
//sendChat(msg.who, "/w gm " + amt_10_gp_gems + " beautiful gemstone(s).")
gems_azurite = 0; gems_banded_agate = 0; gems_blue_quartz = 0; gems_eye_agate = 0
gems_hematite = 0; gems_lapis_lazuli = 0; gems_malachite = 0; gems_moss_agate = 0
gems_obsidian = 0; gems_rhodochrosite = 0; gems_tiger_eye = 0; gems_turquoise = 0
for(gems_type = RandomInt(12); amt_10_gp_gems > 0; amt_10_gp_gems--, gems_type = RandomInt(12)) {
if(gems_type == 1) {gems_azurite++} else if(gems_type == 2) {gems_banded_agate++}
else if(gems_type == 3) {gems_blue_quartz++} else if(gems_type == 4) {gems_eye_agate++}
else if(gems_type == 5) {gems_hematite++} else if(gems_type == 6) {gems_lapis_lazuli++}
else if(gems_type == 7) {gems_malachite++} else if(gems_type == 8) {gems_moss_agate++}
else if(gems_type == 9) {gems_obsidian++} else if(gems_type == 10) {gems_rhodochrosite++}
else if(gems_type == 11) {gems_tiger_eye++} else if(gems_type == 12) {gems_turquoise++}
}
//Display results in chat
if(gems_azurite > 0) {loot = loot + "{\"itemcount\": \"" + gems_azurite + "\", \"itemname\": \"azurite gemstone\", \"itemcontent\": \"(10 gp each)\"};"}
if(gems_banded_agate > 0) {loot = loot + "{\"itemcount\": \"" + gems_banded_agate + "\", \"itemname\": \"banded agate gemstone(s)\", \"itemcontent\": \"(10 gp each)\"};"}
if(gems_blue_quartz > 0) {loot = loot + "{\"itemcount\": \"" + gems_blue_quartz + "\", \"itemname\": \"blue quartz gemstone(s)\", \"itemcontent\": \"(10 gp each)\"};"}
if(gems_eye_agate > 0) {loot = loot + "{\"itemcount\": \"" + gems_eye_agate + "\", \"itemname\": \"eye agate gemstone(s)\", \"itemcontent\": \"(10 gp each)\"};"}
if(gems_hematite > 0) {loot = loot + "{\"itemcount\": \"" + gems_hematite + "\", \"itemname\": \"hematite gemstone(s)\", \"itemcontent\": \"(10 gp each)\"};"}
if(gems_lapis_lazuli > 0) {loot = loot + "{\"itemcount\": \"" + gems_lapis_lazuli + "\", \"itemname\": \"lapis lazuli gemstone(s)\", \"itemcontent\": \"(10 gp each)\"};"}
if(gems_malachite > 0) {loot = loot + "{\"itemcount\": \"" + gems_malachite + "\", \"itemname\": \"malachite gemstone(s)\", \"itemcontent\": \"(10 gp each)\"};"}
if(gems_moss_agate > 0) {loot = loot + "{\"itemcount\": \"" + gems_moss_agate + "\", \"itemname\": \"moss agate gemstone(s)\", \"itemcontent\": \"(10 gp each)\"};"}
if(gems_obsidian > 0) {loot = loot + "{\"itemcount\": \"" + gems_obsidian + "\", \"itemname\": \"obsidian gemstone(s)\", \"itemcontent\": \"(10 gp each)\"};"}
if(gems_rhodochrosite > 0) {loot = loot + "{\"itemcount\": \"" + gems_rhodochrosite + "\", \"itemname\": \"rhodochrosite gemstone(s)\", \"itemcontent\": \"(10 gp each)\"};"}
if(gems_tiger_eye > 0) {loot = loot + "{\"itemcount\": \"" + gems_tiger_eye + "\", \"itemname\": \"tiger eye gemstone(s)\", \"itemcontent\": \"(10 gp each)\"};"}
if(gems_turquoise > 0) {loot = loot + "{\"itemcount\": \"" + gems_turquoise + "\", \"itemname\": \"turquoise gemstone(s)\", \"itemcontent\": \"(10 gp each)\"};"}
}
//50 gp Gemstones
if(amt_50_gp_gems > 0) {
// sendChat(msg.who, "/w gm " + amt_50_gp_gems + " beautiful gemstone(s).")
gems_bloodstone = 0; gems_carnelian = 0; gems_chalcedony = 0; gems_chrysoprase = 0
gems_citrine = 0; gems_jasper = 0; gems_moonstone = 0; gems_onyx = 0
gems_quartz = 0; gems_sardonyx = 0; gems_star_rose_quartz = 0; gems_zircon = 0
for(gems_type = RandomInt(12); amt_50_gp_gems > 0; amt_50_gp_gems--, gems_type = RandomInt(12)) {
if(gems_type == 1) {gems_bloodstone++} else if(gems_type == 2) {gems_carnelian++}
else if(gems_type == 3) {gems_chalcedony++} else if(gems_type == 4) {gems_chrysoprase++}
else if(gems_type == 5) {gems_citrine++} else if(gems_type == 6) {gems_jasper++}
else if(gems_type == 7) {gems_moonstone++} else if(gems_type == 8) {gems_onyx++}
else if(gems_type == 9) {gems_quartz++} else if(gems_type == 10) {gems_sardonyx++}
else if(gems_type == 11) {gems_star_rose_quartz++} else if(gems_type == 12) {gems_zircon++}
}
//Display results in chat
if(gems_bloodstone > 0) {loot = loot + "{\"itemcount\": \"" + gems_bloodstone + "\", \"itemname\": \" bloodstone gemstone(s)\", \"itemcontent\": \"(50 gp each)\"};"}
if(gems_carnelian > 0) {loot = loot + "{\"itemcount\": \"" + gems_carnelian + "\", \"itemname\": \" carnelian gemstone(s)\", \"itemcontent\": \"(50 gp each)\"};"}
if(gems_chalcedony > 0) {loot = loot + "{\"itemcount\": \"" + gems_chalcedony + "\", \"itemname\": \" chalcedony gemstone(s)\", \"itemcontent\": \"(50 gp each)\"};"}
if(gems_chrysoprase > 0) {loot = loot + "{\"itemcount\": \"" + gems_chrysoprase + "\", \"itemname\": \" chrysoprase gemstone(s)\", \"itemcontent\": \"(50 gp each)\"};"}
if(gems_citrine > 0) {loot = loot + "{\"itemcount\": \"" + gems_citrine + "\", \"itemname\": \" citrine gemstone(s)\", \"itemcontent\": \"(50 gp each)\"};"}
if(gems_jasper > 0) {loot = loot + "{\"itemcount\": \"" + gems_jasper + "\", \"itemname\": \" jasper gemstone(s)\", \"itemcontent\": \"(50 gp each)\"};"}
if(gems_moonstone > 0) {loot = loot + "{\"itemcount\": \"" + gems_moonstone + "\", \"itemname\": \" moonstone gemstone(s)\", \"itemcontent\": \"(50 gp each)\"};"}
if(gems_onyx > 0) {loot = loot + "{\"itemcount\": \"" + gems_onyx + "\", \"itemname\": \" onyx gemstone(s)\", \"itemcontent\": \"(50 gp each)\"};"}
if(gems_quartz > 0) {loot = loot + "{\"itemcount\": \"" + gems_quartz + "\", \"itemname\": \" quartz gemstone(s)\", \"itemcontent\": \"(50 gp each)\"};"}
if(gems_sardonyx > 0) {loot = loot + "{\"itemcount\": \"" + gems_sardonyx + "\", \"itemname\": \" sardonyx gemstone(s)\", \"itemcontent\": \"(50 gp each)\"};"}
if(gems_star_rose_quartz > 0) {loot = loot + "{\"itemcount\": \"" + gems_star_rose_quartz + "\", \"itemname\": \" star rose quartz gemstone(s)\", \"itemcontent\": \"(50 gp each)\"};"}
if(gems_zircon > 0) {loot = loot + "{\"itemcount\": \"" + gems_zircon + "\", \"itemname\": \" zircon gemstone(s)\", \"itemcontent\": \"(50 gp each)\"};"}
}
//100 gp Gemstones
if(amt_100_gp_gems > 0) {
gems_amber = 0; gems_amethyst = 0; gems_chrysoberyl = 0; gems_coral = 0
gems_garnet = 0; gems_jade = 0; gems_jet = 0; gems_pearl = 0
gems_spinel = 0; gems_tourmaline = 0
for(gems_type = RandomInt(10); amt_100_gp_gems > 0; amt_100_gp_gems--, gems_type = RandomInt(10)) {
if(gems_type == 1) {gems_amber++} else if(gems_type == 2) {gems_amethyst++}
else if(gems_type == 3) {gems_chrysoberyl++} else if(gems_type == 4) {gems_coral++}
else if(gems_type == 5) {gems_garnet++} else if(gems_type == 6) {gems_jade++}
else if(gems_type == 7) {gems_jet++} else if(gems_type == 8) {gems_pearl++}
else if(gems_type == 9) {gems_spinel++} else if(gems_type == 10) {gems_tourmaline++}
}
//Display results in chat
if(gems_amber > 0) {loot = loot + "{\"itemcount\": \"" + gems_amber + "\", \"itemname\": \" Amber (" + select_random(['transparent watery gold', 'rich gold']) + ")\", \"itemcontent\": \"(100 gp each)\"};"}
if(gems_amethyst > 0) {loot = loot + "{\"itemcount\": \"" + gems_amethyst + "\", \"itemname\": \" Amethyst (transparent deep purple)\", \"itemcontent\": \"(100 gp each)\"};"}
if(gems_chrysoberyl > 0) {loot = loot + "{\"itemcount\": \"" + gems_chrysoberyl + "\", \"itemname\": \" Chrysoberyl (" + select_random(['transparent yellow-green', 'pale green']) + ")\", \"itemcontent\": \"(100 gp each)\"};"}
if(gems_coral > 0) {loot = loot + "{\"itemcount\": \"" + gems_coral + "\", \"itemname\": \" Coral (opaque crimson)\", \"itemcontent\": \"(100 gp each)\"};"}
if(gems_garnet > 0) {loot = loot + "{\"itemcount\": \"" + gems_garnet + "\", \"itemname\": \" Garnet (" + select_random(['transparent red', 'brown-green', 'violet']) + ")\", \"itemcontent\": \"(100 gp each)\"};"}
if(gems_jade > 0) {loot = loot + "{\"itemcount\": \"" + gems_jade + "\", \"itemname\": \" jade (" + select_random(['translucent light green', 'deep green' , 'white']) + ")\", \"itemcontent\": \"(100 gp each)\"};"}
if(gems_jet > 0) {loot = loot + "{\"itemcount\": \"" + gems_jet + "\", \"itemname\": \" Jet (opaque deep black)\", \"itemcontent\": \"(100 gp each)\"};"}
if(gems_pearl > 0) {loot = loot + "{\"itemcount\": \"" + gems_pearl + "\", \"itemname\": \" Pearl (" + select_random(['opaque lustrous white' , 'yellow', 'pink']) + ")\", \"itemcontent\": \"(100 gp each)\"};"}
if(gems_spinel > 0) {loot = loot + "{\"itemcount\": \"" + gems_spinel + "\", \"itemname\": \" Spinel (" + select_random(['transparent red', 'red-brown', 'deep green']) + ")\", \"itemcontent\": \"(100 gp each)\"};"}
if(gems_tourmaline > 0) {loot = loot + "{\"itemcount\": \"" + gems_tourmaline + "\", \"itemname\": \" Tourmaline (" + select_random(['transparent pale green' , 'blue', 'brown' , 'red']) + ")\", \"itemcontent\": \"(100 gp each)\"};"}
}
//500 gp Gemstones
if(amt_500_gp_gems > 0) {
gems_alexandrite = 0; gems_aquamarine = 0; gems_black_pearl = 0; gems_blue_spinel = 0
gems_peridot = 0; gems_topaz = 0
for(gems_type = RandomInt(6); amt_500_gp_gems > 0; amt_500_gp_gems--, gems_type = RandomInt(6)) {
if(gems_type == 1) {gems_alexandrite++} else if(gems_type == 2) {gems_aquamarine++}
else if(gems_type == 3) {gems_black_pearl++} else if(gems_type == 4) {gems_blue_spinel++}
else if(gems_type == 5) {gems_peridot++} else if(gems_type == 6) {gems_topaz++}
}
//Display results in chat
if(gems_alexandrite > 0) {loot = loot + "{\"itemcount\": \"" + gems_alexandrite + "\", \"itemname\": \"Alexandrite (transparent dark green)\", \"itemcontent\": \"(500 gp each)\"};"}
if(gems_aquamarine > 0) {loot = loot + "{\"itemcount\": \"" + gems_aquamarine + "\", \"itemname\": \"Aquamarine (transparent pale blue-green)\", \"itemcontent\": \"(500 gp each)\"};"}
if(gems_black_pearl > 0) {loot = loot + "{\"itemcount\": \"" + gems_black_pearl + "\", \"itemname\": \"Black pearl (opaque pure black)\", \"itemcontent\": \"(500 gp each)\"};"}
if(gems_blue_spinel > 0) {loot = loot + "{\"itemcount\": \"" + gems_blue_spinel + "\", \"itemname\": \"Blue spinel (transparent deep blue)\", \"itemcontent\": \"(500 gp each)\"};"}
if(gems_peridot > 0) {loot = loot + "{\"itemcount\": \"" + gems_peridot + "\", \"itemname\": \"Peridot (transparent rich olive green))\", \"itemcontent\": \"(500 gp each)\"};"}
if(gems_topaz > 0) {loot = loot + "{\"itemcount\": \"" + gems_topaz + "\", \"itemname\": \"Topaz (transparent golden yellow)\", \"itemcontent\": \"(500 gp each)\"};"}
}
//1000 gp Gemstones
if(amt_1000_gp_gems > 0) {
gems_black_opal = 0; gems_blue_sapphire = 0; gems_emerald = 0; gems_fire_opal = 0
gems_opal = 0; gems_star_ruby = 0; gems_star_sapphire = 0; gems_yellow_sapphire = 0
for(gems_type = RandomInt(8); amt_1000_gp_gems > 0; amt_1000_gp_gems--, gems_type = RandomInt(8)) {
if(gems_type == 1) {gems_black_opal++} else if(gems_type == 2) {gems_blue_sapphire++}
else if(gems_type == 3) {gems_emerald++} else if(gems_type == 4) {gems_fire_opal++}
else if(gems_type == 5) {gems_opal++} else if(gems_type == 6) {gems_star_ruby++}
else if(gems_type == 7) {gems_star_sapphire++} else if(gems_type == 8) {gems_yellow_sapphire++}
}
//Display results in chat
if(gems_black_opal > 0) {loot = loot + "{\"itemcount\": \"" + gems_black_opal + "\", \"itemname\": \"Black opal (translucent dark green with black mottling and golden flecks)\", \"itemcontent\": \"(1000 gp each)\"};"}
if(gems_blue_sapphire > 0) {loot = loot + "{\"itemcount\": \"" + gems_blue_sapphire + "\", \"itemname\": \"Blue sapphire (" + select_random(['transparent blue-white' , 'medium blue']) + ")\", \"itemcontent\": \"(1000 gp each)\"};"}
if(gems_emerald > 0) {loot = loot + "{\"itemcount\": \"" + gems_emerald + "\", \"itemname\": \"Emerald (transparent deep bright green)\", \"itemcontent\": \"(1000 gp each)\"};"}
if(gems_fire_opal > 0) {loot = loot + "{\"itemcount\": \"" + gems_fire_opal + "\", \"itemname\": \"Fire opal (translucent fiery red)\", \"itemcontent\": \"(1000 gp each)\"};"}
if(gems_opal > 0) {loot = loot + "{\"itemcount\": \"" + gems_opal + "\", \"itemname\": \"Opal (translucent pale blue with green and golden mottling)\", \"itemcontent\": \"(1000 gp each)\"};"}
if(gems_star_ruby > 0) {loot = loot + "{\"itemcount\": \"" + gems_star_ruby + "\", \"itemname\": \"Star ruby (translucent ruby with white star-shaped center)\", \"itemcontent\": \"(1000 gp each)\"};"}
if(gems_star_sapphire > 0) {loot = loot + "{\"itemcount\": \"" + gems_star_sapphire + "\", \"itemname\": \"Star sapphire (translucent blue sapphire with white star-shaped center)\", \"itemcontent\": \"(1000 gp each)\"};"}
if(gems_yellow_sapphire > 0) {loot = loot + "{\"itemcount\": \"" + gems_yellow_sapphire + "\", \"itemname\": \"Yellow sapphire (" + select_random(['transparent fiery yellow' , 'yellow·green']) + ")\", \"itemcontent\": \"(1000 gp each)\"};"}
}
//5000 gp Gemstones
if(amt_5000_gp_gems > 0) {
gems_black_sapphire = 0; gems_diamond = 0; gems_jacinth = 0; gems_ruby = 0
for(gems_type = RandomInt(8); amt_5000_gp_gems > 0; amt_5000_gp_gems--, gems_type = RandomInt(8)) {
if(gems_type == 1) {gems_black_sapphire++} else if(gems_type == 2) {gems_diamond++}
else if(gems_type == 3) {gems_jacinth++} else if(gems_type == 4) {gems_ruby++}
}
//Display results in chat
if(gems_black_sapphire > 0) {loot = loot + "{\"itemcount\": \"" + gems_black_sapphire + "\", \"itemname\": \"Black sapphire (translucent lustrous black with glowing highlights)\", \"itemcontent\": \"(5000 gp each)\"};"}
if(gems_diamond > 0) {loot = loot + "{\"itemcount\": \"" + gems_diamond + "\", \"itemname\": \"Diamond (" + select_random(['transparent blue-white' , 'canary', 'pink', 'brown', 'blue']) + ")\", \"itemcontent\": \"(5000 gp each)\"};"}
if(gems_jacinth > 0) {loot = loot + "{\"itemcount\": \"" + gems_jacinth + "\", \"itemname\": \"jacinth (transparent fiery orange)\", \"itemcontent\": \"(5000 gp each)\"};"}
if(gems_ruby > 0) {loot = loot + "{\"itemcount\": \"" + gems_ruby + "\", \"itemname\": \"Ruby (" + select_random(['transparent clear red' , 'deep crimson']) + ")\", \"itemcontent\": \"(5000 gp each)\"};"}
}
//Determine type and amount of art objects, then print to chat
//25 gp art objects
if(amt_25_gp_art > 0) {
art_silver_ewer = 0
art_bone_statuette = 0
art_small_gold_bracelet = 0
art_cloth_of_gold_vestments = 0
art_black_velvet_mask = 0
art_copper_chalice = 0
art_bone_dice = 0
art_small_mirror = 0
art_silk_handkerchief = 0
art_gold_locket = 0
for(art_type = RandomInt(10); amt_25_gp_art > 0; amt_25_gp_art--, art_type = RandomInt(10)) {
if(art_type == 1) {art_silver_ewer++} else if(art_type == 2) {art_bone_statuette++}
else if(art_type == 3) {art_small_gold_bracelet++} else if(art_type == 4) {art_cloth_of_gold_vestments++}
else if(art_type == 5) {art_black_velvet_mask++} else if(art_type == 6) {art_copper_chalice++}
else if(art_type == 7) {art_bone_dice++} else if(art_type == 8) {art_small_mirror++}
else if(art_type == 9) {art_silk_handkerchief++} else if(art_type == 10) {art_gold_locket++}
}
//Display results in chat
if(art_silver_ewer > 0) {loot = loot + "{\"itemcount\": \"" + art_silver_ewer + "\", \"itemname\": \"silver ewer(s)\", \"itemcontent\": \"(25 gp each)\"};"}
if(art_bone_statuette > 0) {loot = loot + "{\"itemcount\": \"" + art_bone_statuette + "\", \"itemname\": \"carved bone statuette(s)\", \"itemcontent\": \"(25 gp each)\"};"}
if(art_small_gold_bracelet > 0) {loot = loot + "{\"itemcount\": \"" + art_small_gold_bracelet + "\", \"itemname\": \"small gold bracelet(s)\", \"itemcontent\": \"(25 gp each)\"};"}
if(art_cloth_of_gold_vestments > 0) {loot = loot + "{\"itemcount\": \"" + art_cloth_of_gold_vestments + "\", \"itemname\": \"cloth-of-gold vestment(s)\", \"itemcontent\": \"(25 gp each)\"};"}
if(art_black_velvet_mask > 0) {loot = loot + "{\"itemcount\": \"" + art_black_velvet_mask + "\", \"itemname\": \"black velvet mask(s) stitched with a silver thread\", \"itemcontent\": \"(25 gp each)\"};"}
if(art_copper_chalice > 0) {loot = loot + "{\"itemcount\": \"" + art_copper_chalice + "\", \"itemname\": \"copper chalice(s) with a silver figure\", \"itemcontent\": \"(25 gp each)\"};"}
if(art_bone_dice > 0) {loot = loot + "{\"itemcount\": \"" + art_bone_dice + "\", \"itemname\": \"pair(s) of engraved bone dice\", \"itemcontent\": \"(25 gp each)\"};"}
if(art_small_mirror > 0) {loot = loot + "{\"itemcount\": \"" + art_small_mirror + "\", \"itemname\": \"small mirror(s) set in a painted wood frame\", \"itemcontent\": \"(25 gp each)\"};"}
if(art_silk_handkerchief > 0) {loot = loot + "{\"itemcount\": \"" + art_silk_handkerchief + "\", \"itemname\": \"embroidered silk handkerchief(s)\", \"itemcontent\": \"(25 gp each)\"};"}
if(art_gold_locket > 0) {loot = loot + "{\"itemcount\": \"" + art_gold_locket + "\", \"itemname\": \"gold locket(s) with a painted portrait inside\", \"itemcontent\": \"(25 gp each)\"};"}
}
//250 gp art objects
if(amt_250_gp_art > 0) {
art_gold_ring = 0
art_ivory_statuette = 0
art_large_gold_bracelet = 0
art_silver_necklace = 0
art_bronze_crown = 0
art_silk_robe = 0
art_large_tapestry = 0
art_brass_mug = 0
art_animal_figurines = 0
art_gold_cage = 0
for(art_type = RandomInt(10); amt_250_gp_art > 0; amt_250_gp_art--, art_type = RandomInt(10)) {
if(art_type == 1) {art_gold_ring++} else if(art_type == 2) {art_ivory_statuette++}
else if(art_type == 3) {art_large_gold_bracelet++} else if(art_type == 4) {art_silver_necklace++}
else if(art_type == 5) {art_bronze_crown++} else if(art_type == 6) {art_silk_robe++}
else if(art_type == 7) {art_large_tapestry++} else if(art_type == 8) {art_brass_mug++}
else if(art_type == 9) {art_animal_figurines++} else if(art_type == 10) {art_gold_cage++}
}
//Display results in chat
if(art_gold_ring > 0) {loot = loot + "{\"itemcount\": \"" + art_gold_ring + "\", \"itemname\": \"Gold ring(s) set with bloodstones\", \"itemcontent\": \"(250 gp each)\"};"}
if(art_ivory_statuette > 0) {loot = loot + "{\"itemcount\": \"" + art_ivory_statuette + "\", \"itemname\": \"Carved ivory statuette(s)\", \"itemcontent\": \"(250 gp each)\"};"}
if(art_large_gold_bracelet > 0) {loot = loot + "{\"itemcount\": \"" + art_large_gold_bracelet + "\", \"itemname\": \"Large gold bracelet(s)\", \"itemcontent\": \"(250 gp each)\"};"}
if(art_silver_necklace > 0) {loot = loot + "{\"itemcount\": \"" + art_silver_necklace + "\", \"itemname\": \"Silver necklace with a gemstone pendant(s)\", \"itemcontent\": \"(250 gp each)\"};"}
if(art_bronze_crown > 0) {loot = loot + "{\"itemcount\": \"" + art_bronze_crown + "\", \"itemname\": \"Bronze crown(s)\", \"itemcontent\": \"(250 gp each)\"};"}
if(art_silk_robe > 0) {loot = loot + "{\"itemcount\": \"" + art_silk_robe + "\", \"itemname\": \"Silk robe(s) with gold embroidery\", \"itemcontent\": \"(250 gp each)\"};"}
if(art_large_tapestry > 0) {loot = loot + "{\"itemcount\": \"" + art_large_tapestry + "\", \"itemname\": \"Large well-made tapestry\", \"itemcontent\": \"(250 gp each)\"};"}
if(art_brass_mug > 0) {loot = loot + "{\"itemcount\": \"" + art_brass_mug + "\", \"itemname\": \"Brass mug with jade inlay\", \"itemcontent\": \"(250 gp each)\"};"}
if(art_animal_figurines > 0) {loot = loot + "{\"itemcount\": \"" + art_animal_figurines + "\", \"itemname\": \"Box(es) of turquoise animal figurines\", \"itemcontent\": \"(250 gp each)\"};"}
if(art_gold_cage > 0) {loot = loot + "{\"itemcount\": \"" + art_gold_cage + "\", \"itemname\": \"Gold bird cage(s) with electrum filigree\", \"itemcontent\": \"(250 gp each)\"};"}
}
//750 gp art objects
if(amt_750_gp_art > 0) {
art_silver_chalice = 0
art_silver_sword = 0
art_carved_harps = 0
art_gold_idol = 0
art_gold_comb = 0
art_bottle_stopper = 0
art_ceremonial_dagger = 0
art_silver_brooch = 0
art_obsidian_statuette = 0
art_gold_mask = 0
for(art_type = RandomInt(10); amt_750_gp_art > 0; amt_750_gp_art--, art_type = RandomInt(10)) {
if(art_type == 1) {art_silver_chalice++} else if(art_type == 2) {art_silver_sword++}
else if(art_type == 3) {art_carved_harps++} else if(art_type == 4) {art_gold_idol++}
else if(art_type == 5) {art_gold_comb++} else if(art_type == 6) {art_bottle_stopper++}
else if(art_type == 7) {art_ceremonial_dagger++} else if(art_type == 8) {art_silver_brooch++}
else if(art_type == 9) {art_obsidian_statuette++} else if(art_type == 10) {art_gold_mask++}
}
//Display results in chat
if(art_silver_chalice > 0) {loot = loot + "{\"itemcount\": \"" + art_silver_chalice + "\", \"itemname\": \"Silver chalice(s) set with moonstones\", \"itemcontent\": \"(750 gp each)\"};"}
if(art_silver_sword > 0) {loot = loot + "{\"itemcount\": \"" + art_silver_sword + "\", \"itemname\": \"Silver-plated steel longsword(s) with jet set in hilt\", \"itemcontent\": \"(750 gp each)\"};"}
if(art_carved_harps > 0) {loot = loot + "{\"itemcount\": \"" + art_carved_harps + "\", \"itemname\": \"Carved harp(s) of exotic wood with ivory inlay and zircon gems\", \"itemcontent\": \"(750 gp each)\"};"}
if(art_gold_idol > 0) {loot = loot + "{\"itemcount\": \"" + art_gold_idol + "\", \"itemname\": \"Small gold idol(s)\", \"itemcontent\": \"(750 gp each)\"};"}
if(art_gold_comb > 0) {loot = loot + "{\"itemcount\": \"" + art_gold_comb + "\", \"itemname\": \"Gold dragon comb(s) set with red garnets as eyes\", \"itemcontent\": \"(750 gp each)\"};"}
if(art_bottle_stopper > 0) {loot = loot + "{\"itemcount\": \"" + art_bottle_stopper + "\", \"itemname\": \"Bottle stopper cork(s) embossed with gold leaf and set with amethysts\", \"itemcontent\": \"(750 gp each)\"};"}
if(art_ceremonial_dagger > 0) {loot = loot + "{\"itemcount\": \"" + art_ceremonial_dagger + "\", \"itemname\": \"Ceremonial electrum dagger with a black pearl in the pommel\", \"itemcontent\": \"(750 gp each)\"};"}
if(art_silver_brooch > 0) {loot = loot + "{\"itemcount\": \"" + art_silver_brooch + "\", \"itemname\": \"Silver and gold brooch\", \"itemcontent\": \"(750 gp each)\"};"}
if(art_obsidian_statuette > 0) {loot = loot + "{\"itemcount\": \"" + art_obsidian_statuette + "\", \"itemname\": \"Obsidian statuette(s) with gold fittings and inlay\", \"itemcontent\": \"(750 gp each)\"};"}
if(art_gold_mask > 0) {loot = loot + "{\"itemcount\": \"" + art_gold_mask + "\", \"itemname\": \"Painted gold war mask(s)\", \"itemcontent\": \"(750 gp each)\"};"}
}
//2500 gp art objects
if(amt_2500_gp_art > 0) {
art_gold_chain = 0
art_old_painting = 0
art_silk_mantle = 0
art_platinum_bracelet = 0
art_glove_set = 0
art_jeweled_anklet = 0
art_gold_box = 0
art_gold_circlet = 0
art_eye_patch = 0
art_string_pearls = 0
for(art_type = RandomInt(10); amt_2500_gp_art > 0; amt_2500_gp_art--, art_type = RandomInt(10)) {
if(art_type == 1) {art_gold_chain++} else if(art_type == 2) {art_old_painting++}
else if(art_type == 3) {art_silk_mantle++} else if(art_type == 4) {art_platinum_bracelet++}
else if(art_type == 5) {art_glove_set++} else if(art_type == 6) {art_jeweled_anklet++}
else if(art_type == 7) {art_gold_box++} else if(art_type == 8) {art_gold_circlet++}
else if(art_type == 9) {art_eye_patch++} else if(art_type == 10) {art_string_pearls++}
}
//Display results in chat
if(art_gold_chain > 0) {loot = loot + "{\"itemcount\": \"" + art_gold_chain + "\", \"itemname\": \"Fine gold chain(s) set with a fire opal\", \"itemcontent\": \"(2500 gp each)\"};"}
if(art_old_painting > 0) {loot = loot + "{\"itemcount\": \"" + art_old_painting + "\", \"itemname\": \"Old masterpiece painting(s)\", \"itemcontent\": \"(2500 gp each)\"};"}
if(art_silk_mantle > 0) {loot = loot + "{\"itemcount\": \"" + art_silk_mantle + "\", \"itemname\": \"Embroidered silk and velvet mantle(s) set with numerous moonstones\", \"itemcontent\": \"(2500 gp each)\"};"}
if(art_platinum_bracelet > 0) {loot = loot + "{\"itemcount\": \"" + art_platinum_bracelet + "\", \"itemname\": \"Platinum bracelet(s) set with a sapphire\", \"itemcontent\": \"(2500 gp each)\"};"}
if(art_glove_set > 0) {loot = loot + "{\"itemcount\": \"" + art_glove_set + "\", \"itemname\": \"Embroidered glove set(s) with jewel chips\", \"itemcontent\": \"(2500 gp each)\"};"}
if(art_jeweled_anklet > 0) {loot = loot + "{\"itemcount\": \"" + art_jeweled_anklet + "\", \"itemname\": \"jeweled anklet(s)\", \"itemcontent\": \"(2500 gp each)\"};"}
if(art_gold_box > 0) {loot = loot + "{\"itemcount\": \"" + art_gold_box + "\", \"itemname\": \"Gold music box(es)\", \"itemcontent\": \"(2500 gp each)\"};"}
if(art_gold_circlet > 0) {loot = loot + "{\"itemcount\": \"" + art_gold_circlet + "\", \"itemname\": \"Gold circlet set(s) with four aquamarines\", \"itemcontent\": \"(2500 gp each)\"};"}
if(art_eye_patch > 0) {loot = loot + "{\"itemcount\": \"" + art_eye_patch + "\", \"itemname\": \"Eye patch with a mock eye set in blue sapphire and moonstone\", \"itemcontent\": \"(2500 gp each)\"};"}
if(art_string_pearls > 0) {loot = loot + "{\"itemcount\": \"" + art_string_pearls + "\", \"itemname\": \"A necklace string of small pink pearls\", \"itemcontent\": \"(2500 gp each)\"};"}
}
//7500 gp art objects
if(amt_7500_gp_art > 0) {
art_gold_crown = 0
art_platinum_ring = 0
art_gold_statuette = 0
art_gold_cups = 0
art_jewelery_box = 0
art_gold_sarcophagus = 0
art_jade_board = 0
art_ivory_horn = 0
for(art_type = RandomInt(10); amt_7500_gp_art > 0; amt_7500_gp_art--, art_type = RandomInt(10)) {
if(art_type == 1) {art_gold_crown++} else if(art_type == 2) {art_platinum_ring++}
else if(art_type == 3) {art_gold_statuette++} else if(art_type == 4) {art_gold_cups++}
else if(art_type == 5) {art_jewelery_box++} else if(art_type == 6) {art_gold_sarcophagus++}
else if(art_type == 7) {art_jade_board++} else if(art_type == 8) {art_ivory_horn++}
}
//Display results in chat
if(art_gold_crown > 0) {loot = loot + "{\"itemcount\": \"" + art_gold_crown + "\", \"itemname\": \"Jeweled gold crown\", \"itemcontent\": \"(7500 gp each)\"};"}
if(art_platinum_ring > 0) {loot = loot + "{\"itemcount\": \"" + art_platinum_ring + "\", \"itemname\": \"jeweled platinum ring\", \"itemcontent\": \"(7500 gp each)\"};"}
if(art_gold_statuette > 0) {loot = loot + "{\"itemcount\": \"" + art_gold_statuette + "\", \"itemname\": \"Small gold statuette set with rubies\", \"itemcontent\": \"(7500 gp each)\"};"}
if(art_gold_cups > 0) {loot = loot + "{\"itemcount\": \"" + art_gold_cups + "\", \"itemname\": \"Gold cup set with emeralds\", \"itemcontent\": \"(7500 gp each)\"};"}
if(art_jewelery_box > 0) {loot = loot + "{\"itemcount\": \"" + art_jewelery_box + "\", \"itemname\": \"Gold jewelry box with platinum filigree\", \"itemcontent\": \"(7500 gp each)\"};"}
if(art_gold_sarcophagus > 0) {loot = loot + "{\"itemcount\": \"" + art_gold_sarcophagus + "\", \"itemname\": \"Painted gold child's sarcophagus\", \"itemcontent\": \"(7500 gp each)\"};"}
if(art_jade_board > 0) {loot = loot + "{\"itemcount\": \"" + art_jade_board + "\", \"itemname\": \"jade game board with solid gold playing pieces\", \"itemcontent\": \"(7500 gp each)\"};"}
if(art_ivory_horn > 0) {loot = loot + "{\"itemcount\": \"" + art_ivory_horn + "\", \"itemname\": \"Bejeweled ivory drinking horn with gold filigree\", \"itemcontent\": \"(7500 gp each)\"};"}
}
//Determine magic items, then whisper to GM
//Magic Item Table A
if(amt_mit_a > 0) {
// sendChat(msg.who, "/w gm " + amt_mit_a + " magical items (table A)")
amt_pot_healing = 0
amt_ss_can = 0
amt_pot_climbing = 0
amt_ss_1 = 0
amt_ss_2 = 0
amt_pot_greater_healing = 0
amt_bag_of_holding = 0
amt_driftglobe = 0
for (mit_d100 = RandomInt(100); amt_mit_a > 0; amt_mit_a--, mit_d100 = RandomInt(100)) {
// sendChat(msg.who, "/w gm Rolled a " + mit_d100)
if(mit_d100 < 51) {amt_pot_healing++}
else if(mit_d100 < 61) {amt_ss_can++}
else if(mit_d100 < 71) {amt_pot_climbing++}
else if(mit_d100 < 91) {amt_ss_1++}
else if(mit_d100 < 95) {amt_ss_2++}
else if(mit_d100 < 99) {amt_pot_greater_healing++}
else if(mit_d100 == 99) {amt_bag_of_holding++}
else if(mit_d100 == 100) {amt_driftglobe++}
}
//Display results in chat
if(amt_pot_healing > 0) {loot = loot + "{\"itemcount\": \"" + amt_pot_healing + "\", \"itemname\": \"potion(s) of healing\"};"}
for (;amt_ss_can > 0; amt_ss_can--) {loot = loot + "{\"itemcount\": \"1\", \"itemname\": \"" + "Spell scroll of " + scroll_spell('cantrip') + " (cantrip)\"};"}
if(amt_pot_climbing > 0) {loot = loot + "{\"itemcount\": \"" + amt_pot_climbing + "\", \"itemname\": \"potion(s) of climbing\"};"}
for (;amt_ss_1 > 0; amt_ss_1--) {loot = loot + "{\"itemcount\": \"1\", \"itemname\": \"" + "Spell scroll of " + scroll_spell(1) + " (lvl 1)\"};"}
for (;amt_ss_2 > 0; amt_ss_2--) {loot = loot + "{\"itemcount\": \"1\", \"itemname\": \"" + "Spell scroll of " + scroll_spell(2) + " (lvl 2)\"};"}
if(amt_pot_greater_healing > 0) {loot = loot + "{\"itemcount\": \"" + amt_pot_greater_healing + "\", \"itemname\": \"potion(s) of greater healing\"};"}
if(amt_bag_of_holding > 0) {loot = loot + "{\"itemcount\": \"" + amt_bag_of_holding + "\", \"itemname\": \"bag(s) of holding\"};"}
if(amt_driftglobe > 0) {loot = loot + "{\"itemcount\": \"" + amt_driftglobe + "\", \"itemname\": \"driftglobe(s)\"};"}
}
//Magic Item Table B
if(amt_mit_b > 0) {
// sendChat(msg.who, "/w gm " + amt_mit_b + " magical items (table B)")
/* 01-15 */ amt_pot_greater_healing = 0
/* 16-22 */ amt_pot_fire_breath = 0
/* 23-29 */ amt_pot_resistance = 0
/* 30-34 */ amt_ammo_1 = 0
/* 35-39 */ amt_pot_animal_friendship = 0
/* 40-44 */ amt_pot_hill_giant_str = 0
/* 45-49 */ amt_pot_growth = 0
/* 50-54 */ amt_pot_water_breathing = 0
/* 55-59 */ amt_ss_2 = 0
/* 60-64 */ amt_ss_3 = 0
/* 65-67 */ amt_bag_of_holding = 0
/* 68-70 */ amt_keoghtoms_ointment = 0
/* 71-73 */ amt_oil_slipperiness = 0
/* 74-75 */ amt_dust_disappearance = 0
/* 76-77 */ amt_dust_dryness = 0
/* 78-79 */ amt_dust_sneezing_choking = 0
/* 80-81 */ amt_elemental_gem = 0
/* 82-83 */ amt_philter_love = 0
/* 84 */ amt_alchemy_jug = 0
/* 85 */ amt_cap_water_breathing = 0
/* 86 */ amt_cloak_manta_ray = 0
/* 87 */ amt_driftglobe = 0
/* 88 */ amt_goggles_night = 0
/* 89 */ amt_helm_comprehending_languages = 0
/* 90 */ amt_immovable_rod = 0
/* 91 */ amt_lantern_revealing = 0
/* 92 */ amt_mariners_armor = 0
/* 93 */ amt_mithral_armor = 0
/* 94 */ amt_potion_poison = 0
/* 95 */ amt_ring_swimming = 0
/* 96 */ amt_robe_useful_items = 0
/* 97 */ amt_rope_climbing = 0
/* 98 */ amt_saddle_cavalier = 0
/* 99 */ amt_wand_magic_detection = 0
/* 100 */ amt_wand_secrets = 0
for(mit_d100 = RandomInt(100); amt_mit_b > 0; amt_mit_b--, mit_d100 = RandomInt(100)) {
// sendChat(msg.who, "/w gm Rolled a " + mit_d100)
if(mit_d100 < 16) {amt_pot_greater_healing++}
else if(mit_d100 < 23) {amt_pot_fire_breath++}
else if(mit_d100 < 30) {amt_pot_resistance++}
else if(mit_d100 < 35) {amt_ammo_1++}
else if(mit_d100 < 40) {amt_pot_animal_friendship++}
else if(mit_d100 < 45) {amt_pot_hill_giant_str++}
else if(mit_d100 < 50) {amt_pot_growth++}
else if(mit_d100 < 55) {amt_pot_water_breathing++}
else if(mit_d100 < 60) {amt_ss_2++}
else if(mit_d100 < 65) {amt_ss_3++}
else if(mit_d100 < 68) {amt_bag_of_holding++}
else if(mit_d100 < 71) {amt_keoghtoms_ointment++}
else if(mit_d100 < 74) {amt_oil_slipperiness++}
else if(mit_d100 < 76) {amt_dust_disappearance++}
else if(mit_d100 < 78) {amt_dust_dryness++}
else if(mit_d100 < 80) {amt_dust_sneezing_choking++}
else if(mit_d100 < 82) {amt_elemental_gem++}
else if(mit_d100 < 84) {amt_philter_love++}
else if(mit_d100 == 84) {amt_alchemy_jug++}
else if(mit_d100 == 85) {amt_cap_water_breathing++}
else if(mit_d100 == 86) {amt_cloak_manta_ray++}
else if(mit_d100 == 87) {amt_driftglobe++}
else if(mit_d100 == 88) {amt_goggles_night++}
else if(mit_d100 == 89) {amt_helm_comprehending_languages++}
else if(mit_d100 == 90) {amt_immovable_rod++}
else if(mit_d100 == 91) {amt_lantern_revealing++}
else if(mit_d100 == 92) {amt_mariners_armor++}
else if(mit_d100 == 93) {amt_mithral_armor++}
else if(mit_d100 == 94) {amt_potion_poison++}