This repository has been archived by the owner on Jan 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlistener.js
1631 lines (1548 loc) · 70.9 KB
/
listener.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
/**Author: Argagarg
* Source: https://github.com/Argagarg/RT2sheet
* About: This script serves as a wrapper for the 40k scripts: it captures the !skill40k, !ranged40k, !melee40k, and !psy40k commands
**/
var Wrapper40k = Wrapper40k || (function () {
handleInput = function (msg_orig) {
var msg = _.clone(msg_orig),
args, cmds, ids = [],
ignoreSelected = false,
pageRestriction = [],
modlist = {
flip: [],
on: [],
off: [],
set: {},
order: []
};
try {
var cmdName;
var msgTxt = msg.content;
var paramList;
var result = '';
var player_obj = getObj("player", msg.playerid);
var mode;
var outputmode;
if (msg.type !== "api") return;
args = msg.content;
cmdName = msg.content.split(" ", 1)[0];
paramList = msgTxt.slice(cmdName.length);
var paramArray = paramList.split(',');
switch (cmdName) {
case '!skill40k':
if (paramArray.length < 4) {
result = ' must specify 4 comma-separated parameters for !skill40k command.';
sendChat(msg.who, result);
} else {
//trim strings and set optional mode parameter
_.each(paramArray, function (current, i) {
if (i == 5) {
mode = trimString(current);
}
});
//create skill check instance
let Skill = new SkillCheck(paramArray[0],paramArray[1],paramArray[2], paramArray[3], paramArray[4]);
Skill.Calc();
Skill.buildStr("skill");
//Chose output mode
if (mode == 'normal') {
outputmode = '';
} else if (mode == 'secret') {
outputmode = '--whisper|self,gm';
} else if (mode == 'hidden') {
outputmode = '--whisper|gm';
if (msg.who != '') {
sendChat(msg.who, '/w ' + msg.who + ' sent a secret ' + Skill.skillname + ' roll to the GM.');
}
} else {
outputmode = '';
}
//build output str and send to PC
msg.content = "!power {{ " + mode + " --format|skill --titlefontshadow|none --name|" + outputmode + " --leftsub|" + Skill.skillname + " Check --rightsub| " + Skill.diff + " Diff. --Roll:|[! " + Skill.roll + " !] vs [! " + Skill.checkTarget + " !] --Result:|" + Skill.hitStr + Skill.talStr + " }}";
//msg.content = "!power {{ " + outputmode + " --format|skill --titlefontshadow|none --name|" + Skill.name + " --leftsub|" + Skill.skillname + " Check --rightsub| " + Skill.diff + " Diff. --Roll:|[! " + Skill.roll + " !] vs [! " + Skill.checkTarget + " !] --Result:|" + Skill.hitStr + Skill.talStr + " }}";
msg.who = msg.who.replace(" (GM)", "");
msg.content = msg.content.replace(/<br\/>\n/g, ' ').replace(/({{(.*?)}})/g, " $2 ");
PowerCard.Process(msg, player_obj);
}
break;
case '!ranged40k':
if (paramArray.length < 22) {
result = ' must specify 22 comma-separated parameters for !ranged40k command.';
} else {
var curToken, attribute, range, shotsel, single, semi, full, numdice, dice, dmg, pen, modifier, special, quality, talents, wpnname, type, ammo, mod1, mod2, mod3, effects, wpncat;
_.each(paramArray, function (current, i) {
if (i == 0) {
curToken = current;
} else if (i == 1) {
attribute = current;
} else if (i == 2) {
range = current;
} else if (i == 3) {
shotsel = current;
} else if (i == 4) {
single = current;
} else if (i == 5) {
semi = current;
} else if (i == 6) {
full = current;
} else if (i == 7) {
numdice = current;
} else if (i == 8) {
dice = current;
} else if (i == 9) {
dmg = current;
} else if (i == 10) {
pen = current;
} else if (i == 11) {
modifier = current;
} else if (i == 12) {
special = current;
} else if (i == 13) {
quality = current;
} else if (i == 14) {
talents = current;
} else if (i == 15) {
wpnname = current;
} else if (i == 16) {
type = current;
} else if (i == 17) {
ammo = current;
} else if (i == 18) {
mod1 = current;
} else if (i == 19) {
mod2 = current;
} else if (i == 20) {
mod3 = current;
} else if (i == 21) {
effects = current;
} else if (i == 22) {
wpncat = current;
}
});
result = ranged40kNamespace.rollResult(curToken, attribute, range, shotsel, single, semi, full, numdice, dice, dmg, pen, modifier, special, quality, talents, wpnname, type, ammo, mod1, mod2, mod3, effects, wpncat, msg);
}
sendChat(msg.who, result);
break;
case '!melee40k':
if (paramArray.length < 19) {
result = ' must specify 19 comma-separated parameters for !melee40k command.';
} else {
var curToken, attribute, shotsel, numdice, dice, dmg, pen, str, modifier, special, quality, talents, wpnname, type, psy, mod1, mod2, mod3, effects, wpncat;
_.each(paramArray, function (current, i) {
if (i == 0) {
curToken = current(current);
} else if (i == 1) {
attribute = current(current);
} else if (i == 2) {
shotsel = current(current);
} else if (i == 3) {
numdice = current(current);
} else if (i == 4) {
dice = current(current);
} else if (i == 5) {
dmg = current(current);
} else if (i == 6) {
pen = current(current);
} else if (i == 7) {
str = current(current);
} else if (i == 8) {
modifier = current(current);
} else if (i == 9) {
special = current;
} else if (i == 10) {
quality = current(current);
} else if (i == 11) {
talents = current(current);
} else if (i == 12) {
wpnname = current(current);
} else if (i == 13) {
type = current(current);
} else if (i == 14) {
psy = current(current);
} else if (i == 15) {
mod1 = current(current);
} else if (i == 16) {
mod2 = current(current);
} else if (i == 17) {
mod3 = current(current);
} else if (i == 18) {
effects = current(current);
} else if (i == 19) {
wpncat = current(current);
}
});
result = melee40kNamespace.rollResult(curToken, attribute, shotsel, numdice, dice, dmg, pen, str, modifier, special, quality, talents, wpnname, type, psy, mod1, mod2, mod3, effects, wpncat, msg);
}
sendChat(msg.who, result);
break;
case '!psy40k':
if (paramArray.length < 16) {
result = ' must specify 16 comma-separated parameters for !psy40k command.';
} else {
var curToken, attribute, psychoice, psymod, psy, psyname, numdice, dmgstat, psydmg, psypen, psypenpr, psydmgtype, atktype, focusmod, atkspecial, effects, talents;
_.each(paramArray, function (current, i) {
if (i == 0) {
curToken = current(current);
} else if (i == 1) {
attribute = current(current);
} else if (i == 2) {
psychoice = current(current);
} else if (i == 3) {
psymod = current(current);
} else if (i == 4) {
psy = current(current);
} else if (i == 5) {
psyname = current(current);
} else if (i == 6) {
numdice = current(current);
} else if (i == 7) {
dmgstat = current(current);
} else if (i == 8) {
psydmg = current(current);
} else if (i == 9) {
psypen = current(current);
} else if (i == 10) {
psypenpr = current(current);
} else if (i == 11) {
psydmgtype = current(current);
} else if (i == 12) {
atktype = current(current);
} else if (i == 13) {
focusmod = current(current);
} else if (i == 14) {
atkspecial = current(current);
} else if (i == 15) {
effects = current(current);
} else if (i == 16) {
talents = current(current);
}
});
result = psy40kNamespace.rollResult(curToken, attribute, psychoice, psymod, psy, psyname, numdice, dmgstat, psydmg, psypen, psypenpr, psydmgtype, atktype, focusmod, atkspecial, effects, talents, msg);
}
sendChat(msg.who, result);
break;
}
} catch (e) {
let who = (getObj('player', msg_orig.playerid) || {
get: () => 'API'
}).get('_displayname');
sendChat('40kScript', `/w "${who}" ` +
`<div style="border:1px solid black; background-color: #ffeeee; padding: .2em; border-radius:.4em;" >` +
`<div>There was an error while trying to run your command:</div>` +
`<div style="margin: .1em 1em 1em 1em;"><code>${msg_orig.content}</code></div>` +
`<div>Please <a class="showtip tipsy" title="The Aaron's profile on Roll20." style="color:blue; text-decoration: underline;" href="https://app.roll20.net/users/104025/the-aaron">send me this information</a> so I can make sure this doesn't happen again (triple click for easy select in most browsers.):</div>` +
`<div style="font-size: .6em; line-height: 1em;margin:.1em .1em .1em 1em; padding: .1em .3em; color: #666666; border: 1px solid #999999; border-radius: .2em; background-color: white;">` +
JSON.stringify({
msg: msg_orig,
stack: e.stack
}) +
`</div>` +
`</div>`
);
}
}
registerEventHandlers = function () {
on('chat:message', handleInput);
};
trimString = function (src) {
return src.replace(/^\s+|\s+$/g, '');
};
class Check {
constructor(name, attrval, modifier, talentStr) {
this.name = name;
this.attrval=attrval;
this.modifier=modifier;
this.degOfSuc=0;
this.roll=0;
this.checkTarget=0;
this.diff=0;
this.talStr='';
this.hitStr='';
this.talentArray = {
"adamantiumfaith": false,
"aegisofcontempt": false,
"ambassadorimp": false,
"ambidexterous": false,
"archivator": false,
"armormonger": false,
"assassinstrike": false,
"bastionironwill": false,
"battlerage": false,
"blademaster": false,
"blindfighting": false,
"bodyguard": false,
"bulgingbiceps": false,
"bulwarkoffaith": false,
"catfall": false,
"cluesfromcrowds": false,
"combatmaster": false,
"constantvigilance": false,
"contact network": false,
"coordinatedinterrogation": false,
"counterattack": false,
"coverup": false,
"crushingblow": false,
"daemonhunter": false,
"daemonicdisrupt": false,
"daemonologist": false,
"darksoul": false,
"deathdealer": false,
"delicateinterrogation": false,
"denythewitch": false,
"devastatingassault": false,
"diehard": false,
"disarm": false,
"divineprotection": false,
"doubletap": false,
"doudbleteam": false,
"enemy": false,
"eyeofvengeance": false,
"faceinacrowd": false,
"favoredbywarp": false,
"ferricsummons": false,
"fieldvivi": false,
"flagellant": false,
"flashofinsight": false,
"frenzy": false,
"grenadier": false,
"haloofcommand": false,
"hammerblow": false,
"hardenedsoul": false,
"hardtarget": false,
"hardy": false,
"hatred": false,
"hipshooting": false,
"hotshotpilot": false,
"hulldown": false,
"independenttargeting": false,
"indomitableconv": false,
"inescapableattack": false,
"infusedknowledge": false,
"inspiringaura": false,
"instrumentofhiswill": false,
"intothejaws": false,
"ironfaith": false,
"ironjaw": false,
"ironresolve": false,
"jaded": false,
"keenintuition": false,
"killingstrike": false,
"leapingdodge": false,
"leapup": false,
"lightningattack": false,
"luminenblast": false,
"luminenshock": false,
"maglevtrans": false,
"marksman": false,
"mastery": false,
"mechadendrite": false,
"mightyshot": false,
"mountedwarrior": false,
"neverdie": false,
"nowheretohide": false,
"oneonone": false,
"peer": false,
"penitentpsy": false,
"precisionkiller": false,
"preturnaturalspeed": false,
"prosanguine": false,
"purityofhatred": false,
"pushthelimit": false,
"quickdraw": false,
"rapidreload": false,
"resistance": false,
"riteofbanish": false,
"sancticpurity": false,
"shieldwall": false,
"skilledrider": false,
"soundcon": false,
"sprint": false,
"stepaside": false,
"strongminded": false,
"superiorchi": false,
"swiftattack": false,
"taintedpsy": false,
"takedown": false,
"targetselection": false,
"technicalknock": false,
"thundercharge": false,
"truegrit": false,
"twowpnmstr": false,
"twowpnwld": false,
"unarmedspec": false,
"warpconduit": false,
"warplock": false,
"warpsense": false,
"weaponintuition": false,
"weapontech": false,
"whirlwindofdeath": false,
"witchfinder": false,
"xenosavant": false,
"amorphous": false, //traits
"amphibious": false,
"autostabilized": false,
"banefulpres": -1,
"bestial": false,
"blind": false,
"brutalcharge": -1,
"burrower": -1,
"cranialcircuitry": false,
"crawler": false,
"cybermantle": false,
"daemonic": -1,
"darksight": false,
"deadlynatural": false,
"electrograft": false,
"electooinductors": false,
"fear": -1,
"flyer": -1,
"frombeyond": false,
"hoverer": -1,
"incorporeal": false,
"machine": -1,
"mindlock": false,
"multiplearms": -1,
"naturalarmor": -1,
"naturalweapons": false,
"potentiacoil": false,
"phase": false,
"psyker": false,
"quadruped": false,
"regeneration": -1,
"sanctioned": false,
"size": -1,
"sonarsense": false,
"soulbound": false,
"stampede": false,
"stuffofnightmares": false,
"sturdy": false,
"touchedbythefates": -1,
"toxic": -1,
"undying": false,
"unnaturalsenses": false,
"warpinstability": false,
"warpweapons": false,
"abyssalterror": false, //Elite Advances
"adrenalrecovery": false,
"advancedbattlesuittraining": false,
"allyofthexenos": false,
"apotheosisdelayed": false,
"attackmytarget": false,
"baneofthedaemon": false,
"battlefieldtechnician": false,
"bestofthebest": false,
"blessedmartyrdom": false,
"blessingoftheethereals": false,
"bondingritual": false,
"boundtothehighest": false,
"braceforimpact": false,
"burytheknife": false,
"ceaselesscrusader": false,
"cleanseandpurify": false,
"cleansewithfire": false,
"cogswithincogs": false,
"coldreading": false,
"coldtrader": false,
"combatflair": false,
"completecontrol": false,
"corruptedcharge": false,
"coverandadvance": false,
"daemonicaffinity": false,
"daemonicanathema": false,
"daemonicdomination": false,
"daemonicemergence": false,
"damagecontrol": false,
"despoiler": false,
"discipleofkauyon": false,
"discipleofmontka": false,
"dispassionatedispatch": false,
"divineministration": false,
"divinesymbol": false,
"divinevengeance": false,
"emperorsguidance": false,
"envoyofthegreatergood": false,
"exemplaroftheselflesscause": false,
"fated": false,
"favoreditem": false,
"feelnopain": false,
"firebrandscall": false,
"firesupport": false,
"flamesoffaith": false,
"fleshwarp": false,
"furiousfusillade": false,
"furiouszeal": false,
"greaterthanthesun": false,
"holdfast": false,
"honorguard": false,
"hunkerdown": false,
"inspiredintuition": false,
"jackofalltrades": false,
"killerseye": false,
"legendary": false,
"legendaryarmament": false,
"lostokenhancement": false,
"luminenbarrier": false,
"luminendesecration": false,
"luminenflare": false,
"luminenshield": false,
"luminensurge": false,
"marauder": false,
"martyrsgift": false,
"masterofalltrades": false,
"masteroftechnology": false,
"metalfatigue": false,
"mightoftheemperor": false,
"mindsight": false,
"mindtrap": false,
"mortalglamour": false,
"newallies": false,
"nullfield": false,
"operativeconditioning": false,
"panxenoist": false,
"personalequipment": false,
"priorityfire": false,
"psychicnull": false,
"purgetheunclean": false,
"renownedwarrant": false,
"resurrection": false,
"riteofawe": false,
"riteoffear": false,
"riteofpurethought": false,
"secondsight": false,
"sharedestiny": false,
"shieldingfaith": false,
"shieldofcontempt": false,
"shipmaster": false,
"snapshot": false,
"soullessaura": false,
"soulstorm": false,
"soulward": false,
"spiritofthemartyr": false,
"squadmode": false,
"strengththroughconviction": false,
"strengththroughunity": false,
"subversiveprogramming": false,
"suffertheflesh": false,
"superiorsupplychain": false,
"supportingfire": false,
"supremetelepath": false,
"swarmprotocols": false,
"tacticalflexibility": false,
"tacticalwithdrawal": false,
"takethemalive": false,
"technologicalinsight": false,
"technologytriumphant": false,
"tempestofmonkua": false,
"theemperorprotects": false,
"thepowerbeyond": false,
"thepowerwithin": false,
"throughunitydevastation": false,
"undyingwarrior": false,
"unfalteringredemption": false,
"unhalloweddiscovery": false,
"unholyinsight": false,
"unorthodoxrites": false,
"veteran's reflexes": false,
"voidsavant": false,
"warpanathema": false,
"warpawareness": false,
"warpbane": false,
"warpdisruption": false,
"warpforge": false,
"watchfulforbetrayal": false,
"whispersfrombeyond": false,
"whispersofsamadhi": false,
"willoftheinquisitor": false,
"wrathoftherighteous": false,
"xenoarcheologist": false,
"xenosaugmentation": false,
"xenosfamiliarity": false,
"xenoshybridization": false,
"zealotspassion": false,
"coldsoul": false, //traits from EAs
"lostokaugmentation": false,
"masteryofaugurs": false,
"masteryofgunnery": false,
"masteryofsmallcraft": false,
"masteryofspace": false,
"possessed": false,
"purefaith": false,
"rigormentis": false,
"temperament": false,
"untouchable": false,
"xenophilia": false
};
this.configArray(talentStr,this.talentArray);
this.hit=false;
this.err=false;
this.errStr='';
}
//PUBLIC: Bound the modifier to +/-60 and create the target value
setCheckThreshold(){
if (this.modifier > 60) {
this.modifier = 60;
} else if (this.modifier < -60) {
this.modifier = -60;
}
this.checkTarget = parseInt(this.attrval) + parseInt(this.modifier);
}
//PUBLIC: Calculate DoS and Hit/Miss
detDoS(){
if (this.roll <= this.checkTarget) {
this.hit=true;
this.degOfSuc = (Math.floor(this.checkTarget / 10) - Math.floor(this.roll / 10)) + 1;
} else {
this.hit=false;
this.degOfSuc = (Math.floor(this.roll / 10) - Math.floor(this.checkTarget / 10)) + 1;
}
}
//PUBLIC: perform the basic calculations required for a check
Calc(){
this.roll=randomInteger(100);
this.setCheckThreshold();
this.detDoS();
}
//PUBLIC: Prepare parts of the output message based on the calc results
buildStr(){
if (this.hit=true) {
this.hitStr = '<span style="color:green">' + this.name + ' succeeds by <B>' + this.degOfSuc + ' degree(s)</B>.</span> ';
} else {
this.hitStr = '<span style="color:red">' + this.name + ' fails by <B>' + this.degOfSuc + ' degree(s)</B></span>. ';
}
}
//PRIVATE: use a period-separated string to set a given data array
configArray(inputString, dataArray){
var tempvar, current, i, j;
var tempArray = inputString.split('.');
for (i = 0, j = tempArray.length; i < j; i++) {
tempArray[i] = tempArray[i].replace(/^\s+|\s+$/g, ''); //remove whitespace
tempvar = tempArray[i].match(/\d/); //find any numbers in parentheses
tempArray[i] = tempArray[i].replace(/\(([^)]+)\)/g, ''); //remove parentheses and anything inside
current = tempArray[i];
if (tempvar != null) { //if there was a number in parentheses, set the array location equal to that number, otherwise set it as true
dataArray[current] = tempvar;
} else {
dataArray[current] = true;
}
}
}
get attrval() {
return this._attrval;
}
get modifier() {
return this._modifier;
}
get diff() {
return this._diff;
}
get name() {
return this._name;
}
get talentArray() {
return this._talentArray;
}
get err(){
return this._err;
}
get errStr(){
return this._errStr;
}
set attrval(value) {
if(value >= 0 && value <= 100){
this._attrval=value;
} else if (value > 100){
this._attrval=100;
this.err=true;
this.errStr += "Attr out of range |";
} else{
this._attrval=0;
this.err=true;
this.errStr += "Attr out of range |";
}
}
set modifier(value) {
if(value >= -200 && value <= 200){
this._modifier=value;
} else if (value > 200){
this._modifier=200;
this.err=true;
this.errStr += "Modifier out of range |";
} else if (value < -200){
this._modifier=-200;
this.err=true;
this.errStr += "Modifier out of range |";
}
}
set diff(value){
if (value == 0) {
this._diff = "Challenging"
} else if (value == 30) {
this._diff = "Easy"
} else if (value == 20) {
this._diff = "Routine"
} else if (value == 10) {
this._diff = "Ordinary"
} else if (value == -10) {
this._diff = "Difficult"
} else if (value == -20) {
this._diff = "Hard"
} else if (value == -30) {
this._diff = "Very Hard"
} else if (value == -40) {
this._diff = "Arduous"
} else if (value == -50) {
this._diff = "Punishing"
} else if (value == -60) {
this._diff = "Hellish"
} else {
this._diff = 'Other';
}
}
set name(value) {
if (typeof value === 'string' || value instanceof String){
this._name=value;
} else{
this._name="Unknown Name";
this.err=true;
this.errStr += "Invalid Name |"
}
}
set talentArray(value) {
this._talentArray=value;
}
set err(value){
this._err=value;
}
set errStr(value){
this._errStr=value;
}
}
class SkillCheck extends Check {
constructor(name, attrval, modifier, skillname, talentStr) {
super(name, attrval, modifier, talentStr);
this.skillname=skillname;
}
Calc(){
//Add bonuses for specific talents
if (this.talentArray['coordinatedinterrogation'] == true && this.skillname == "Interrogation") {
this.modifier = parseInt(this.modifier) + 10;
}
if (this.talentArray['superiorchirurgeon'] == true && this.skillname == "Medicae") {
this.modifier = parseInt(this.modifier) + 20;
}
//perform the standard check calculations
super.Calc();
}
buildStr(){
//prepare the basic check info
super.buildStr();
//prepare the skill-specific addendi
if (this.talentArray['bulgingbiceps'] == true && this.skillname == "Athletics") {
this.talStr = this.talStr + " --BulgingBiceps | Grants +20 to the Heft use of the Athletics skill";
}
if (this.talentArray['catfall'] == true && this.skillname == "Acrobatics") {
this.talStr = this.talStr + " --Catfall | Grants +20 to the Jump use of Acrobatics";
}
if (this.talentArray['coordinatedinterrogation'] == true && this.skillname == "Interrogation") {
this.talStr = this.talStr + " --CoordinatedInterrogation | Grants +10 to all interrogation tests (inc) and +5 for each additional ally with this talent";
}
if (this.talentArray['delicateinterrogation'] == true && this.skillname == "Interrogation") {
this.talStr = this.talStr + " --DelicateInterrogation | Subtlety loss from Interrogation reduced by 1d5 (min 1)";
}
if (this.talentArray['enemy'] == true && (this.skillname == "Charm" || this.skillname == "Deceive" || this.skillname == "Command" || this.skillname == "Inquiry")) {
this.talStr = this.talStr + " --Enemy | -10 to interaction tests with the selected group(not included)";
}
if (this.talentArray['faceinacrowd'] == true && this.skillname == "Stealth") {
this.talStr = this.talStr + " --FaceinaCrowd | Can use Fellowship instead of Agility when using the Shadowing ability of the Stealth skill";
}
if (this.talentArray['haloofcommand'] == true && (this.skillname == "Charm" || this.skillname == "Deceive" || this.skillname == "Command" || this.skillname == "Inquiry" || this.skillname == "Intimidate")) {
this.talStr = this.talStr + " --HaloofCommand | Can affect targets within 100 x FB meters rather than 10";
}
if (this.roll <= this.modifier && this.skillname == "Awareness" && this.talentArray['keenintuition'] == true) {
this.talStr = this.talStr + " --KeenIntuition | After failing an awareness check the this can reroll with a -10";
}
if (this.roll > this.modifier && this.skillname == "Awareness" && this.talentArray['keenintuition'] == true) {
var reroll = randomInteger(100);
var checkTarget2 = parseInt(this.checkTarget) - 10;
var degOfSuc2=0;
var tempStr='';
this.talStr = this.talStr + " --KeenIntuition | After failing an awareness check the this can reroll with a -10";
if (reroll <= checkTarget2) {
degOfSuc2 = (Math.floor(checkTarget2 / 10) - Math.floor(reroll / 10)) + 1;
tempStr = '<span style="color:green">' + this.name + ' succeeds by <B>' + degOfSuc2 + ' degree(s)</B>.</span> ';
} else {
degOfSuc2 = (Math.floor(reroll / 10) - Math.floor(checkTarget2 / 10)) + 1;
tempStr = '<span style="color:red">' + this.name + ' fails by <B>' + degOfSuc2 + ' degree(s)</B></span>. ';
}
this.talStr = this.talStr + " --Reroll:|[! " + reroll + " !] vs [! " + checkTarget2 + " !] --FinalOutput:|" + tempStr;
}
if (this.talentArray['mastery'] == true) {
this.talStr = this.talStr + " --Mastery | Can spend a FP to auto-pass a test with your chosen skill when final modifier is challenging or easier. Counts as DoS equal to ability modifier.";
}
if (this.talentArray['peer'] == true && (this.skillname == "Charm" || this.skillname == "Deceive" || this.skillname == "Command" || this.skillname == "Inquiry")) {
this.talStr = this.talStr + " --Peer | +10 to interaction tests with the selected group (not included)";
}
if (this.talentArray['superiorchirurgeon'] == true && this.skillname == "Medicae") {
this.talStr = this.talStr + " --SuperiorChir | +20 to Medicae and ignores Heavily Damaged penalty and suffers only a -10 for Critical Damage";
}
//NOT WORKING
if (this.talentArray['infusedknowledge'] == true && (this.skillname == "Common Lore" || this.skillname == "Scholastic Lore")) {
this.talStr = this.talStr + " --InfusedKnowledge | +1 DoS on successful CL and SL tests";
}
}
get skillname() {
return this._skillname;
}
set skillname(value) {
if (typeof value === 'string' || value instanceof String){
this._skillname=value;
}else{
this._skillname='Unknown Skill';
this.err=true;
this.errStr +="Invalid Skillname |";
}
}
}
class RangedAtkCheck extends Check {
constructor(name, attrval, range, shotsel, single, semi, full, numdice, dice, dmg, pen, modifier, attributeStr, quality, talentStr, wpnname, type, ammo, mod1, mod2, mod3, effects, wpncat) {
super(name, attrval, modifier, talentStr);
this.range=range;
this.shotsel=shotsel;
this.single=single;
this.semi=semi;
this.full=full;
this.numdice=numdice;
this.dice=dice;
this.dmg=dmg;
this.pen=pen;
this.attributeArray = {
"Accurate": false,
"Balanced": false,
"Blast": -1,
"Concussive": -1,
"Corrosive": false,
"Crippling": -1,
"Daemonbane": false,
"Defensive": false,
"Felling": -1,
"Flame": false,
"Flexible": false,
"Force": false,
"Graviton": false,
"Hallucinogenic": -1,
"Haywire": -1,
"HaywireMod": 0,
"Inaccurate": false,
"Indirect": -1,
"Lance": false,
"Maximal": false,
"Melta": false,
"Overheats": false,
"PowerField": false,
"Primitive": -1,
"Proven": -1,
"RazorSharp": false,
"Recharge": false,
"Reliable": false,
"Sanctified": false,
"Scatter": false,
"Shocking": false,
"Smoke": -1,
"Snare": -1,
"Spray": false,
"Storm": false,
"Tainted": false,
"Tearing": false,
"Toxic": -1,
"Twin-Linked": false,
"Unbalanced": false,
"Unreliable": false,
"Unwieldy": false,
"Vengeful": 10, //Daemon wpn attributes
"Voidchill": false,
"Howling": false,
"Wounding": -1,
"Vicious": false,
"Accursed": false,
"Bloodlust": false,
"Thirsting": false,
"Null": false,
"Fury": false,
"Skulltaker": false,
"Illusory": false,
"MindEater": false,
"Spellbound": false,
"WarpFlame": false,
"SorcerousForce": -1,
"Bile-Quenched": false,
"Enfeebling": false,
"PlagueCarrier": false,
"StreamofCorruption": -1,
"PestilentStench": -1,
"Envenomed": -1,
"Lashing": -1,
"Swiftness": -1,
"Sophorific Musk": false,
"Enticing": false,
"Vulgar": false,
"Jealous": false,
"Prideful": false,
"Vindictive": false,
"Overbearing": false,
"Thrown": false, //Wpn can be thrown as ranged atk
"Multiplier": -1, //Multiplier to attribute damage
"Precision": -1, //+X damage per DoS
"Weighty": -1, //requires SB(X) to fire
"Intangible": false, //doesn't add attribute to melee damage
"Imposing": false,
"Compact": false,
"Steady": false,
"Potent": false,
"SwirlingEnergy": false,
"IncalculablePrecision": false,
"Indestructible": false,
"Ramshackle": false,
"PeerlessElegance": false,
"InnovativeDesign": false,
"RemnantoftheEndless": false,
"DeathsDreamFragment": false,
"Surly": false,
"Cruel": false,
"Patient": false,
"Unpredictable": false,
"Respendent": false,
"Vanishing": false,
"Trusty": false,
"Zealous": false,
"Dogged": false,
"Lucky": false
};
this.configArray(attributeStr,this.attributeArray);
this.quality=quality;
this.wpnname=wpnname;
this.type=type;
this.ammo=ammo;
this.modStr=mod1 + "."+ mod2 + "." + mod3; //TODO: build this into a single string in the character sheet
this.modArray = {
"na": false,
"auxilliary": false,
"backpack": false,
"compact": false,
"grip": false,
"deactivated": false,
"expanded": false,
"exterminator": false,
"selector": false,
"fluid": false,
"melee": false,
"stock": false,
"mono": false,
"motion": false,
"omni": false,
"photo": false,
"pistol": false,
"preysense": false,
"quick": false,
"reddot": false,
"reinforced": false,
"sacred": false,
"silencer": false,
"suspensors": false,
"targeter": false,
"telescopic": false,
"tox": false,
"tripod": false,
"truesilver": false,
"weaving": false,
"warpleech": false,
"vox": false,
"stabilitydampener": false, //custom mods
"extendedbarrel": false,
"driverscope": false,
"ultralight": false,
"extendeddrivermagazine": false,
"impeller": false,
"drivergrip": false,
"bulkbuild": false,
};
this.configArray(modStr,this.modArray);
this.effects=effects;