forked from casusscribere/RT2sheet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmelee40k
1399 lines (1341 loc) · 61.5 KB
/
melee40k
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
/**
* This script rolls a d100 and computes and outputs the success results based
* on Dark Heresy Second Edition RPG criteria.
*
* The following commands is used:
* !ranged40k
**/
//Rolls a d100 and calculates the success or fail results to the chat window.
var melee40kNamespace = melee40kNamespace || {};
melee40kNamespace.rollResult = function(token, attribute, shotsel, numdice, dice, dmg, pen, str, modifier, special, quality, talents, wpnname, type, psy, mod1, mod2, mod3, effects, wpncat, msg) {
if (typeof token === 'undefined' || typeof token != 'string' ) token = 'generic';
if (typeof attribute === 'undefined' || Number.isInteger(parseInt(attribute))==false) attribute = 0;
if (typeof wpnname === 'undefined' || typeof wpnname != 'string' ) wpnname = 'generic';
if (typeof shotsel === 'undefined' || Number.isInteger(parseInt(shotsel))==false) shotsel = 0;
if (typeof numdice === 'undefined' || Number.isInteger(parseInt(numdice))==false) numdice = 1;
if (typeof dice === 'undefined' || Number.isInteger(parseInt(dice))==false) dice = 10;
if (typeof dmg === 'undefined' || Number.isInteger(parseInt(dmg))==false) dmg = 0;
if (typeof type === 'undefined' || typeof type != 'string' ) type = '';
if (typeof pen === 'undefined' || Number.isInteger(parseInt(pen))==false) pen = 0;
if (typeof modifier === 'undefined' || Number.isInteger(parseInt(modifier))==false) modifier = 0;
if (typeof quality === 'undefined' || typeof quality != 'string' ) quality = '';
if (typeof special === 'undefined' || typeof special != 'string' ) special = '';
//var special2 = "Flame, Indirect(4), Sanctified, Twin-Linked"; //test string
var player_obj = getObj("player", msg.playerid);
var roll = randomInteger(100);
var i, j, k, cur, temp, temp2; //loop control and temporary variables
var error=false;
var errortext="ERROR: GENERIC";
var hit=false;
var damage=false;
var parry=false;
var boundmod=0;
var modTarget = 0;
var degOfSuc =0;
var numhits = 0;
var swiftcalc=0;
var dmgroll=null;
var prvdmg=0;
var lowest=0;
var prvrf=false;
var output='';
var dmgstring='';
var dmgsubstring='';
var dmgendstring='';
var qualstring='';
var rfstring='';
var talstring='';
var ammomodstring='';
var specialArray = special.split('.');
var talentArray = talents.split('.');
var superUnreliable=false;
var 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": false,
"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
};
var ttArray = {
"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
};
var 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
};
// Flags values in the special array to values in the attribute array
for (i = 0, j = specialArray.length; i < j; i++) {
specialArray[i] = specialArray[i].replace(/^\s+|\s+$/g, ''); //remove whitespace
sub = specialArray[i].match(/\d/); //find any numbers in parentheses
specialArray[i] = specialArray[i].replace(/\(([^)]+)\)/g, ''); //remove parentheses and anything inside
cur = specialArray[i];
if(sub != null){ //if there was a number in parentheses, set the array location equal to that number, otherwise set it as true
attributeArray[cur] = sub;
} else {
attributeArray[cur] = true;
}
}
// Flags values in the talent array to values in the tt array
for (i = 0, j = talentArray.length; i < j; i++) {
talentArray[i] = talentArray[i].replace(/^\s+|\s+$/g, ''); //remove whitespace
sub = talentArray[i].match(/\d/); //find any numbers in parentheses
talentArray[i] = talentArray[i].replace(/\(([^)]+)\)/g, ''); //remove parentheses and anything inside
cur = talentArray[i];
if(sub != null){ //if there was a number in parentheses, set the array location equal to that number, otherwise set it as true
ttArray[cur] = sub;
} else {
ttArray[cur] = true;
}
}
// Flags the mods used
if(mod1 != null){modArray[mod1] = true;}
if(mod2 != null){modArray[mod2] = true;}
if(mod3 != null){modArray[mod3] = true;}
//Add adjustments for weapon mods
if(modArray['mono']==true && attributeArray['PowerField']==false){pen=parseInt(pen)+2; attributeArray['Primitive']=-1;}
if(modArray['tox']==true && attributeArray['Toxic']<2){attributeArray['Toxic']=2;}
//Account for attributes that add other attributes (typically SoI and Daemon wpn traits)
if(attributeArray['Wounding'] > -1 ){
if(attributeArray['Crippling'] < attributeArray['Wounding']) {attributeArray['Crippling']=attributeArray['Wounding'];}
}
if(attributeArray['Vicious'] ==true){
if(attributeArray['Tearing']==true){attributeArray['RazorSharp']=true;}
else{attributeArray['Tearing']=true;}
}
if(attributeArray['Accursed']==true){
numdice=parseInt(numdice)+1;
if(attributeArray['Felling']< 4){attributeArray['Felling']=4;}
}
if(attributeArray['Fury']==true){boundmod=parseInt(boundmod)+10;}
if(attributeArray['Skulltaker']==true && shotsel == 4){
if(attributeArray['Vengeful']>8){attributeArray['Vengeful']=8;}
}
if(attributeArray['Warpflame']==true){attributeArray['Flame']=true; ttArray['WarpWeapons']=true;}
if(attributeArray['Envenomed'] > -1){
if(attributeArray['Toxic']<(parseInt(attributeArray['Envenomed'])/2)){attributeArray['Toxic']=(parseInt(attributeArray['Envenomed'])/2);}
}
if(attributeArray['Lashing'] > -1){
attributeArray['Flexible']=true;
//range = Daemon's WPB meters
}
if(attributeArray['Steady']==true){
if(attributeArray['Unwieldy'] == false && attributeArray['Unbalanced'] == false){attributeArray['Balanced']=true;}
else {pen=parseInt(pen)+3;}
}
if(attributeArray['Potent']==true){
dmg=parseInt(dmg)+4;
if(attributeArray['Vengeful']>9){attributeArray['Vengeful']=9;}
}
if(attributeArray['SwirlingEnergy']==true){
dmg=parseInt(dmg)+2;
pen=parseInt(pen)+2;
attributeArray['Shocking']=true;
//dmg type becomes energy
}
if(attributeArray['Indestructible']==true){
dmg=parseInt(dmg)+2;
pen=parseInt(pen)+2;
}
if(attributeArray['Ramshackle']==true){
dmg=parseInt(dmg)+4;
//Double weight
if(attributeArray['PowerField']==true){attributeArray['PowerField']=false; attributeArray['Shocking']=true}
}
if(attributeArray['PeerlessElegance']==true){
dmg=parseInt(dmg)+2;
pen=parseInt(pen)+2;
//Weight/2
if(attributeArray['Unwieldy'] != false){attributeArray['Unwieldy']=false; attributeArray['Unbalanced']=true;}
else if(attributeArray['Unbalanced'] != false){attributeArray['Unbalanced']=false;}
else if(shotsel==8){boundmod=parseInt(boundmod)+5;}
}
if(attributeArray['InnovativeDesign']==true){
dmg=parseInt(dmg)-1;
//Weight/2
}
if(attributeArray['RemnantoftheEndless']==true){
attributeArray['PowerField']=true;
pen=parseInt(pen)+2;
type='E';
}
if(attributeArray['DeathsDreamFragment']==true){
dmg=parseInt(dmg)+2;
}
if(attributeArray['Multiplier'] > -1){str=parseInt(str)*attributeArray['Multiplier'];}
if(attributeArray['Intangible']==true){str=0;}
//Shot selection modifier adjustment
if(shotsel==0){
//If the user selected Standard Attack
boundmod += 10;
} else if (shotsel == 1 && ttArray['swiftattack']==true){
//If the user selected Swift Attack
boundmod += 0;
} else if (shotsel == 2 && ttArray['lightningattack']==true && attributeArray['Unwieldy'] == false && attributeArray['Unbalanced'] == false){
//If the user selected Lightning Attack
boundmod += -10;
} else if (shotsel == 3){
//If the user selected All-Out Attack
boundmod += 30;
} else if (shotsel == 4){
//If the user selected Called Strike
if(ttArray['precisionkiller']==true){boundmod +=0;}
if(ttArray['precisionkiller']==false){boundmod +=-20;}
} else if (shotsel == 5){
//If the user selected Charge
boundmod += 20;
} else if (shotsel == 6){
//If the user selected Feint
boundmod += 0;
} else if (shotsel == 7){
//If the user selected Stun
if(ttArray['takedown']==true){boundmod +=0;}
if(ttArray['takedown']==false){boundmod +=-20;}
} else if (shotsel == 8 && attributeArray['Unwieldy'] == false){
//If the user selected Parry
boundmod += 0;
} else if (shotsel == 9 && ttArray['disarm']==true){
//If the user selected Disarm
boundmod += 0;
} else{
error=true;
errortext="ERROR: Invalid Combat Action Selection"
}
if(attributeArray['Balanced']==true &&shotsel==8){boundmod = boundmod+10;}
if(attributeArray['Defensive']==true&&shotsel==8){boundmod = boundmod+15;}
if(attributeArray['Defensive']==true&&shotsel!=8){boundmod = boundmod-10;}
if(attributeArray['Unbalanced']==true&&shotsel==8){boundmod = boundmod-10;}
//Add the modifier to the fire selection and range bonuses
boundmod = parseInt(boundmod) + parseInt(modifier);
//Increase for wpn grip
if(modArray['grip']==true){boundmod = parseInt(boundmod)+5;}
//Adjust +hit based on quality
if(quality=='poor'){boundmod=parseInt(boundmod)-10;}
if(quality=='good' ){boundmod=parseInt(boundmod)+5;}
if(quality=="best"){boundmod=parseInt(boundmod)+10;}
//insert upper and lower bounds for modifiers
if(boundmod>=60){boundmod=60;}
else if (boundmod <=-60){boundmod=-60;}
//Sum the Check + bound modifier
modTarget = parseInt(attribute) + parseInt(boundmod);
//Calculate Hit/Miss & DoS/DoF
if(roll <= modTarget) {
degOfSuc = (Math.floor(modTarget/10) - Math.floor(roll/10)) + 1;
if(shotsel==8){
parry=true;
output = '<span style="color:green">' + token + ' successfully Parries with <B>' + degOfSuc + ' degree(s)</B>.</span> ';
}
else if(shotsel==6){output = '<span style="color:green">' + token + ' feints with <B>' + degOfSuc + ' degree(s)</B>.</span> ';}
else if(shotsel==7){
hit=true;
damage=false;
output = '<span style="color:green">' + token + ' hits with <B>' + degOfSuc + ' degree(s)</B>.</span> ';
}
else{
hit=true;
damage=true;
output = '<span style="color:green">' + token + ' hits with <B>' + degOfSuc + ' degree(s)</B>.</span> ';
}
} else if(roll > modTarget){
degOfSuc = (Math.floor(roll/10) - Math.floor(modTarget/10)) + 1;
output = '<span style="color:red">' + token + ' fails by <B>' + degOfSuc + ' degree(s)</B></span>. ';
hit=false;
}else{
error=true;
errortext="ERROR: Failed DoS Calculation"
}
//adjust for the "roll 100" edge case
if(roll==100){
degOfSuc = (Math.floor(roll/10) - Math.floor(modTarget/10)) + 1;
output = '<span style="color:red">' + token + ' fails automatically by <B>' + degOfSuc + ' degree(s)</B></span>. ';
hit=false;
}
//Adding DoS from weapon attributes/qualities/whatever
if(attributeArray['IncalculablePrecision']==true && hit==true){
degOfSuc=parseInt(degOfSuc)+2;
}
if(attributeArray['Patient']==true && hit==true){
degOfSuc=parseInt(degOfSuc)+1;
}
if(attributeArray['Unpredictible']==true && hit==true){
degOfSuc=parseInt(degOfSuc)+1;
}
if(attributeArray['Unpredictible']==true && hit==false){
degOfSuc=parseInt(degOfSuc)-2;
}
//Determine # of damage rolls required
swiftcalc = Math.floor((degOfSuc -1)/2)+1;
if( (shotsel == 0 || shotsel==3 || shotsel==4 || shotsel==5)&& hit==true && error==false) {
//If the user selected Standard Attack (or others) and hits
numhits = 1;
} else if ( shotsel==1 && hit==true && error==false){
//If the user selected Swift Attack and hit
numhits = swiftcalc;
} else if ( shotsel==2 && hit==true && error==false){
//If the user selected Lightning Attack and hit
numhits=degOfSuc;
} else if ( (shotsel==6||shotsel==7||shotsel==8) && error==false){
//If the user selected Stun, Parry, of Feint
numhits=0;
} else if (error==false){
//If the user missed
numhits=0;
}else{
error=true;
errortext="ERROR: INVALID COMBAT MODE (Numhits)";
numhits=0;
}
//Determine Initial Hit Location
temp = Math.floor(roll/10); //Store 10s place
temp2 = roll - temp*10; //Store 1s place
temp = temp2*10+temp; //swap 10s and 1s place
if(shotsel==4) {var hitloc = ["chosen location", "chosen location", "chosen location"];}
else if(temp <= 10) {var hitloc = ["Head","Head","Left Arm","Body","Right Arm","Body","Body","Body","Body","Body"];}
else if(10 < temp && temp <= 20) {var hitloc = ["Right Arm","Right Arm","Body","Head","Body","Left Arm","Left Arm","Left Arm","Left Arm","Left Arm"];}
else if(20 < temp && temp <= 30) {var hitloc = ["Left Arm","Left Arm","Body","Head","Body","Right Arm","Right Arm","Right Arm","Right Arm","Right Arm"];}
else if(30 < temp && temp <= 70) {var hitloc = ["Body","Body","Right Arm","Head","Left Arm","Body","Body","Body","Body","Body"];}
else if(70 < temp && temp <= 85) {var hitloc = ["Right Leg","Right Leg","Body","Right Arm","Head","Body","Body","Body","Body","Body"];}
else if(85 < temp && temp <= 100){var hitloc = ["Left Leg","Left Leg","Body","Left Arm","Head","Body","Body","Body","Body","Body"];}
else{
error=true;
errortext="ERROR: BAD HIT LOCATION";
}
//If Lance or RazorSharp:
if(attributeArray['Lance'] == true) { pen=parseInt(pen)*degOfSuc;}
if(attributeArray['RazorSharp'] == true && degOfSuc>=3) {pen =parseInt(pen)*2;}
//Increase damage for weapons with the Force quality and a Psy rating
if(attributeArray['Force']==true&&psy>0){
dmg=parseInt(dmg)+parseInt(psy);
pen=parseInt(pen)+parseInt(psy);
}
//If 'Tearing':
if(attributeArray['Tearing']==true){numdice=parseInt(numdice)+1;}
//Increase dmg for best-quality weapons
if(quality=="best"){dmg=parseInt(dmg)+1;}
//Add strength to melee damage
dmg=parseInt(dmg)+parseInt(str);
//Add damage for Crushing Blow talent
if(ttArray['crushingblow']==true){
temp=Math.floor(attribute/10);
temp=Math.ceil(temp/2);
dmg=parseInt(dmg)+parseInt(temp);
}
//Hammer Blow talent
if(ttArray['hammerblow']==true && shotsel==3){
temp=Math.ceil(str/2);
dmg=parseInt(dmg)+parseInt(temp);
if(attributeArray['Concussive']<2){attributeArray['Concussive']=2;}
}
//Increase damage by a multiple of the degrees of success
if(attributeArray['Precision'] > 1){dmg=parseInt(dmg)+parseInt(attributeArray['Precision'])*parseInt(degOfSuc);}
if(attributeArray['Tearing']==true){dmgsubstring=parseInt(numdice)+"d"+parseInt(dice)+"d1cs>"+(parseInt(attributeArray['Vengeful']))+"cf0+"+parseInt(dmg)+" ]] <B> Pen "+parseInt(pen)+" </B>";}
else {dmgsubstring=parseInt(numdice)+"d"+parseInt(dice)+"cs>"+(parseInt(attributeArray['Vengeful']))+"cf0+"+parseInt(dmg)+" ]] <B> Pen "+parseInt(pen)+" </B>";}
//dmgsubstring=parseInt(numdice)+"d"+parseInt(dice)+"cs>"+(parseInt(attributeArray['Vengeful']))+"cf0+"+parseInt(dmg)+" ]] <B> Pen "+parseInt(pen)+" </B>";
for(i=1; i <=numhits; i++){
//do separate calculations for proven/primitive, if necessary
if(attributeArray['Proven']!=-1 || attributeArray['Primitive']!=-1){
lowest=100;
prvdmg='';
prvrf=false;
for(j=1; j <= numdice; j++){
temp = randomInteger(parseInt(dice));
if(temp>=attributeArray['Vengeful']){prvrf=true;}
if(temp==9 && attributeArray['Spray']==true){prvjam=true;}
if(attributeArray['Proven']!=-1 && temp<attributeArray['Proven']){temp=attributeArray['Proven'];}
if(attributeArray['Primitive']!=-1 && temp>attributeArray['Primitive']){temp=attributeArray['Primitive'];}
if(temp<lowest){lowest=temp;}
prvdmg=prvdmg+temp+"+";
}
prvdmg=prvdmg+dmg;
if(attributeArray['Tearing']==true){prvdmg=prvdmg+"-"+lowest;}
dmgsubstring="[NH] 1d0+"+prvdmg+" ]] <B> Pen "+parseInt(pen)+" </B>";
}
//add hitloc string
dmgendstring="to the "+hitloc[i];
dmgstring = dmgstring+ " --Damage: *"+i+"|[[ [$Dmg"+i+"] "+dmgsubstring+dmgendstring;
//Compute and add RF
rfstring = " $Dmg"+i+".tens > 0";
if(attributeArray['Vengeful']<=9){rfstring = rfstring + " OR $Dmg"+i+".nines > 0";}
if(attributeArray['Vengeful']<=8){rfstring = rfstring + " OR $Dmg"+i+".eights > 0";}
if(attributeArray['Vengeful']<=7){rfstring = rfstring + " OR $Dmg"+i+".sevens > 0";}
if(attributeArray['Vengeful']<=6){rfstring = rfstring + " OR $Dmg"+i+".sixes > 0";}
if(attributeArray['Vengeful']<=5){rfstring = rfstring + " OR $Dmg"+i+".fives > 0";}
if(attributeArray['Vengeful']<=4){rfstring = rfstring + " OR $Dmg"+i+".fours > 0";}
if(attributeArray['Vengeful']<=3){rfstring = rfstring + " OR $Dmg"+i+".threes > 0";}
if(attributeArray['Vengeful']<=2){rfstring = rfstring + " OR $Dmg"+i+".twos > 0";}
if(attributeArray['Vengeful']<=1){rfstring = rfstring + " OR $Dmg"+i+".ones > 0";}
if(prvrf==true){dmgstring = dmgstring + " --!^1Righteous Fury: *"+i+"| [[ [NH] 1d5 ]] critical damage to the "+hitloc[i]+" ";}
else{dmgstring = dmgstring + " --?? "+rfstring+" ?? !^1Righteous Fury: *"+i+"| [[ [NH] 1d5 ]] critical damage to the "+hitloc[i]+" ";}
//check for 'Corrosive' Quality
if(attributeArray['Corrosive']==true){
dmgstring = dmgstring + " --!^1Corrosive: *"+i+"| [[ [$Cor"+i+"] [NH] 1d10 ]] dmg to "+hitloc[i]+" Armor ";
}
}
//Apply descriptions for the special combat modes
if(shotsel==3){
qualstring = qualstring + " --AllOutAtk: | This is a standard attack at +20, after which the user cannot use Evasion reactions until the start of his next turn";
} else if(shotsel==4){
qualstring = qualstring + " --CalledStrike: | Hard (-20) WS test that allows the attacker to select a hit location";
} else if(shotsel==5){
qualstring = qualstring + " --Charge: | The target must be at least four metres away, but still within the attacker’s Charge Move. The last four metres of the Charge must be in a straight line. Grants +20WS. If the Charging character has no weapons or other items currently readied, he can attemptto Grapple his opponent (or knock him down) instead of inflicting damage.";
} else if(shotsel==6){
qualstring = qualstring + " --Feint: | The character and his target make an Opposed Weapon Skill test. If the character wins, his next melee Standard Attack action against that same target during this turncannot be Evaded. If the character’s next action is any other action, the advantage of Feinting is lost.";
} else if(shotsel==7){
qualstring = qualstring + " --Stun: | Hard (–20) Weapon Skill test. If successful, [[ [$Stn] 1d10+"+str+"]] is compared to the target’s total of his Toughness bonus +1 per Armour point protecting his head. If the attacker’s roll is equal to or higher than this value, the target is Stunned for a number of rounds equal to the difference between the two values and gains one level of Fatigue.";
} else if(shotsel==9){
qualstring = qualstring + " --Disarm: | Opposed Weapon Skill test. If successful, the enemy drops his weapon to the ground. If >2 DoS, the character can take the enemy's weapon.";
}
//Check for Balanced quality
if(attributeArray['Balanced'] ==true && shotsel!=8){
qualstring = qualstring + " --Balanced: | This weapon grants an additional +10 to WS when Parrying";
}
if(attributeArray['Balanced'] ==true && shotsel==8){
qualstring = qualstring + " --Balanced: | This weapon is granting an additional +10 to WS while Parrying";
}
//Check for Concussive quality
if(attributeArray['Concussive'] != -1 && hit==true){
qualstring = qualstring + " --Concussive: | Target(s) must make "+parseInt(numhits)+" Toughness test(s) at -"+(10*attributeArray['Concussive'])+". If failed, the target is Stunned for 1 round per DoF";
}
//Check for 'Corrosive' quality
if(attributeArray['Corrosive']== true && hit==true){
qualstring = qualstring + " --Corrosive: *0| Armor damage is cumulative and permanent. Any damage done to Armor that reduces it below 0 AP (or if the target has no armor at that location) is dealt to the target directly, bypassing Toughness";
}
//Check for Crippling quality
if(attributeArray['Crippling'] != -1 && damage==true){
qualstring = qualstring + " --Crippled: |[+Crippled] If Target takes at least 1 wound from this wpn he is considered Crippled until end of the encounter or healed fully. If a Crippled character takes more than a half action on his turn, he suffers "+attributeArray['Crippling']+" Rending damage, not reduced by A or T.";
}
//Check for Defensive quality
if(attributeArray['Defensive'] ==true && hit==true && shotsel!=8){
qualstring = qualstring + " --Defensive: | This weapon grants an additional +15 to WS when Parrying, but is reducing WS by 10 while attacking";
}
if(attributeArray['Defensive'] ==true && hit==true && shotsel==8){
qualstring = qualstring + " --Balanced: | This weapon is granting an additional +15 to WS while Parrying, but reduces WS by 10 when attacking";
}
//Check for Felling quality
if(attributeArray['Felling'] != -1 && damage==true ){
qualstring = qualstring + " --Felling: | Target reduces their Unnatural Toughness by "+attributeArray['Felling']+" ";
}
//Check for Flame quality
if(attributeArray['Flame'] == true && hit==true){
qualstring = qualstring + " --Flame: | [+Fire] Target(s) hit must make an Agility test or be set on Fire ";
}
//Check for Flexible quality
if(attributeArray['Flexible']==true){
qualstring = qualstring + " --Flexible: | This weapon cannot be Parried; it can be used to Parry, however";
}
//Check for Force quality
if(attributeArray['Force']==true && psy>0 && damage==true){
qualstring = qualstring + " --Force: | In the hands of a psyker, this weapon deals additional damage based on Psy Rating and the damage type changes to E. In addition, whenever a psyker damages an opponent, he may take a Focus Power action (Opposed with Willpower) as a HA. Winning deals 1d10 E dmg per DoS, ignoring A/T. Force weapons cannot be destroyed with the Power Field quality.";
}
//Check for Graviton quality
if(attributeArray['Graviton'] == true && damage==true){
qualstring = qualstring + " --Graviton: | Target takes additional damage on every hit equal to his Armor Bonus ";
}
//check for 'Hallucinogenic' Quality
if(attributeArray['Hallucinogenic'] !=-1 && hit==true){
qualstring = qualstring + " --Hallucinogenic: | [+Hallucinating] Target(s) hit must make Toughness tests at "+parseInt(-10*attributeArray['Hallucinogenic'])+" or else suffer this temporary delusion: ^^[[ [TXT] [$Tbl] 1t[hallucinogenic] ]] The effects last for 1 round, +1 per DoF.";
}
//check for 'Haywire' Quality
if(attributeArray['Haywire']!=-1 && hit==true){
temp2=randomInteger(10);
temp2=parseInt(temp2)+parseInt(attributeArray['HaywireMod']);
if(temp2==1||temp2==2){temp="<b>Insignificant:</b> No noticible effect";}
else if(temp2==3||temp2==4){temp="<b>Minor Disruption:</b> All actions using tech take -10, PwrArm Mov-1";}
else if(temp2==5||temp2==6){temp="<b>Major Disruption:</b> All actions using tech take -20, PwrArm Mov-3, Melee wpns function as Primitive";}
else if(temp2==7||temp2==8){temp="<b>Dead Zone:</b> Tech ceases to function, PwrArm Mov=1, cybernetics inflict 1 fatigue/round, Melee wpn function as Primitive";}
else if(temp2>=9){temp="<b>Prolonged Dead Zone:</b> Tech ceases to function, PwrArm Mov=1, cybernetics inflict 1 fatigue/round, Melee wpn function as Primitive. Lasts for [[ [NH] 1d5 ]] rounds before lessening to Major Disruption";}
qualstring = qualstring + " --Haywire: | [+Haywire] Everything within "+attributeArray['Haywire']+"m of the point(s) hit is affected with the following effect: ^^"+temp+"^^ The field lessens 1 step in severity each round and does not stack (highest effect persists).";
}
//Check for Inaccurate quality
if(attributeArray['Inaccurate'] == true){
qualstring = qualstring + " --Inaccurate: | Cannot benefit from the Aim action using this weapon";
}
//Check for Lance quality
if(attributeArray['Lance'] == true && damage==true){
qualstring = qualstring + " --Lance: | Penetration is increased for every DoS";
}
//Check for Power Field quality
if(attributeArray['PowerField'] == true && shotsel==8 && parry==true){
dmgstring = dmgstring + " --PowerField: | When successfully parrying, you have a chance of breaking the opponent's weapon (as long as it lacks the Power Field, Natural Weapon, or Warp Weapon qualities): [[ [$pwf] 1d100cs>26 ]]";
dmgstring = dmgstring + " --?? $pwf > 25 ?? !^pfs: | You Parry the opponent's weapon and shatter it!";
dmgstring = dmgstring + " --?? $pwf < 26 ?? !^pfm: | You Parry the opponent's weapon but fail to shatter it!";
}
if(attributeArray['PowerField'] == true && shotsel==8 && parry==false){
dmgstring = dmgstring + " --PowerField: | If you successfully Parry, you have a chance of breaking the opponent's weapon (as long as it lacks the Power Field, Natural Weapon, or Warp Weapon qualities)";
}
//Check for 'Primitive' quality
if(attributeArray['Primitive'] != -1 && damage==true){
qualstring = qualstring + " --Primitive: | Any die result greater than"+attributeArray['Primitive']+" is counted as "+attributeArray['Primitive']+". Righteous Fury may still trigger as usual.";
}
//Check for 'Proven' quality
if(attributeArray['Proven'] != -1 && damage==true){
qualstring = qualstring + " --Proven: | Any die result less than"+attributeArray['Proven']+" is counted as "+attributeArray['Proven'];
}
//Check for 'RazorSharp' quality
if(attributeArray['RazorSharp'] == true && damage==true ){
qualstring = qualstring + " --Razor Sharp: | Penetration is doubled for 3+ DoS";
}
//Check for 'Recharge' quality
if(attributeArray['Recharge'] == true){
qualstring = qualstring + " --Recharge: | When used to attack, this weapon cannot attack again until the end of the next round";
}
//Check for 'Sanctified' quality
if(attributeArray['Sanctified'] == true){
qualstring = qualstring + " --Sanctified: | Any damage inflicted by this weapon counts as Holy, which can have unique effects against Daemons";
}
//Check for Shocking quality
if(attributeArray['Shocking']==true && damage==true ){
qualstring = qualstring + " --Shocking: | A target that takes at least 1 point of damage from this weapon (after A/T) must make a Challenging Toughness Test. If failed, the target gains 1 Fatigue and is Stunned for 1 round per 2 DoF (rounding up)";
}
//Check for Snare quality
if(attributeArray['Snare'] != -1 && hit==true){
qualstring = qualstring + " --Snare: | [+Helpless] Target(s) hit must make an Agility test at "+parseInt(-10*attributeArray['Snare'])+" or be Immobilized. An Immobilized target can attempt no actions other than escape; as a FuA he can make a Challenging Str test at "+parseInt(-10*attributeArray['Snare'])+". If he succeeds, he bursts free. The target is considered Helpless until he escapes.";
}
//Check for Tearing quality
if(attributeArray['Tearing']==true && hit==true){
qualstring = qualstring + " --Tearing: | This weapon rolls one extra die for damage, and the lowest roll is discarded";
}
//Check for Toxic quality
if(attributeArray['Toxic'] != -1 && damage==true){
qualstring = qualstring + " --Toxic: | Target(s) who take damage (after A/T) must make a Toughness test at "+parseInt(-10*attributeArray['Toxic'])+" or suffer [[ [$Tox] 1d10 ]] additional damage, ignoring A/T. Some Toxins have additional effects.";
}
//Check for 'Unbalanced' quality
if(attributeArray['Unbalanced'] == true){
qualstring = qualstring + " --Unbalanced: | This weapon cannot be used to Lightning Attack and suffers a -10 to Parry";
}
//Check for 'Unwieldy' quality
if(attributeArray['Unwieldy'] == true){
qualstring = qualstring + " --Unwieldy: | This weapon cannot be used to Lightning Attack or Parry";
}
//Check for 'Vengeful' quality
if(attributeArray['Vengeful'] != 10 && damage==true){
qualstring = qualstring + " --Vengeful: | Any die result greater than"+attributeArray['Vengeful']+" triggers Righteous Fury";
}
//Check for 'Voidchill' daemon quality
if(attributeArray['Voidchill'] ==true && hit==true){
qualstring = qualstring + " --Voidchill: | Each time the wpn inflicts a hit, the target suffers [[ [$Voidchill] 1d10 ]] Toughness dmg";
}