-
Notifications
You must be signed in to change notification settings - Fork 9
/
chances.html
3557 lines (3005 loc) · 147 KB
/
chances.html
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
<html>
<head>
<title>Fallout 76 Drop Chances</title>
<style>
* {
font-family: sans-serif;
font-size: 20px;
}
td {
padding: 2px;
}
table.infoTable {
border: 1px solid black;
border-collapse: collapse;
}
table.infoTable td {
border: 1px solid black;
}
.picker {
border:1px dotted green;
text-decoration: none;
font-weight: bold;
background-color: #E0FFFF;
padding-left: 3px;
padding-right: 3px;
box-shadow: 2px 2px #888888;
}
.pickerOn {
border:1px dotted black;
text-decoration: none;
font-weight: bold;
background-color: #A0FFA0;
padding-left: 3px;
padding-right: 3px;
box-shadow: 2px 2px #888888;
}
.monospaced {
font-family: monospace;
}
</style>
<meta name="keywords" content="Fallout,Fallout 76,RNG,Random,Chances,Leveled,Leveled List,LVLI,Datamine">
</head>
<body>
<center>
<span style="font-size: 36px; font-weight: bold;">Fallout 76 Drop Chances (0.4.0)</span><br/>
<a href='leveledlist' target='_blank'>How does it work?</a>
<br/>
<br/>
<span style="font-size: 32px; font-weight: bold;">I can no longer maintain this website.<br/>
<a href='https://chrzaszczykkamil.github.io/rng-76/chances.html'>Continued by chrzaszczykkamil in their fork.</a>
</span>
<br/>
<hr>
<br/>
Select version:
<select id='versionselect'>
<option value='P45'>Update 45: 18th July, 2023</option>
<option value='P46'>Update 46: 22nd August, 2023</option>
<option value='P47'>Update 47: 10th October, 2023</option>
<option value='P48'>Update 48: 10th October, 2023</option>
<option value='P49'>Update 49: 30th January, 2024</option>
<option value='P50'>Update 50: 26th March, 2024</option>
<option value='P51'>Update 51: 30th April, 2024</option>
<option value='P52'>Update 52: 12th June, 2024</option>
<option value='P53'>Update 53: 23rd July, 2024</option>
<option value='P54'>Update 54: 3rd September, 2024</option>
<option value='P55'>Update 55: 22nd October, 2024</option>
</select>
<button id='loadversion'>Load</button>
<button id='resetPage'>Reset</button>
<!-- (Note that the site downloads up to 3MB of data for the selected version!) -->
<hr>
<table>
<tr>
<td id='listsearchtip'>
</td>
<td>
<input id='listsearchterm' name='listsearchterm' type='text' style='width: 300px;' value='' autocomplete="on"> <button id='listsearchbtn'>Find</button>
</td>
<td style='width: 30px;'></td>
<td id='itemsearchtip'>
</td>
<td>
<input id='itemsearchterm' name='itemsearchterm' type='text' style='width: 300px;' value='' autocomplete="on"> <button id='itemsearchbtn'>Find</button>
</td>
<td style='padding-left: 30px'>
<button id='clearResults'>Clear results</button>
</td>
<td>
<input type='checkbox' id="FindSpecial" checked><label for="FindSpecial">Special search options</label>
</td>
</tr>
<tr id='FindSpecialRow'>
<td colspan='7' style='text-align: center;'>
<button id='SpecialAllMax0' title='Lists with Flags=all and Max=0'>All/Max=0</button>
<button id='SpecialAllMax1' title='Lists with Flags=all and Max=1'>All/Max=1</button>
<button id='SpecialAllMax2' title='Lists with Flags=all and Max>1'>All/Max>1</button>
<button id='SpecialAllMaxGlobal' title='Lists with flags=all and Max=Global value'>All/Max=Global</button>
<button id='SpecialFirst' title='Lists with flags=first-match-all-conditions'>First</button>
<button id='SpecialFirstSub' title='Lists with flags=first-match-all-conditions and having sublists'>First+Sublist</button>
<button id='SpecialForEach' title='Lists with flags=for-each'>ForEach</button>
<button id='SpecialPickRandom' title='Lists with flags=not all and not for-each'>PickRandom</button>
<button id='SpecialListChanceNone' title='Lists which have Chance None nonzero'>ListChanceNone > 0</button>
<button id='SpecialGetRandomPercent' title='Lists which have conditions with GetRandomPercent'>GetRandomPercent</button>
<button id='SpecialBugged1' title='Lists which are defined Flags=all and Max=1, but they only ever return their first entries'>All/Max=1 always first</button>
<button id='SpecialBugged2' title='Lists which are defined Flags=0 and having conditions on entries'>Random/Conditioned</button>
<button id='SpecialSelfTest' title='Lists testing the calculations'>Self-test lists</button>
</td>
</tr>
<tr>
<td colspan='7' style='text-align: center;'>
<input type='checkbox' id='IncludeATX' checked><label for='IncludeATX'>Include Atom Shop</label>
<input type='checkbox' id='IncludeCut'><label for='IncludeCut'>Include cut content</label>
<input type='checkbox' id='IncludeDebug'><label for='IncludeDebug'>Include debug content</label>
<input type='checkbox' id='SortByEditorID' checked><label for='SortByEditorID'>Sort by EditorID</label>
</td>
</tr>
</table>
<hr>
<table id='searchresults'>
</table>
<hr>
<span id='tablelinks'>
</span>
<br/><br/>
<input type='checkbox' id='Coalesce' checked><label for='Coalesce'>Coalesce duplicate entries</label>
<input type='checkbox' id='ShowFailedConditions' checked><label for='ShowFailedConditions'>Show entries with failed conditions</label>
<br/><br/>
<span id='settingstoggle' style='border: 1px solid black; font-family: monospace; cursor: pointer;'> - </span> <b>List settings:</b>
<table id='settings' style='border-collapse: collapse; margin-top: 5px;'>
<tr>
<td style='border: 1px solid gray; vertical-align: top;'>
<div id="settingsCheckboxes" style='overflow-y: scroll; height: 150px;'>
</div>
</td>
<td style='border: 1px solid gray; vertical-align: top;'>
<div id="settingsComboboxes" style='overflow-y: scroll; height: 150px;'>
</div>
</td>
<td style='border: 1px solid gray; vertical-align: top;'>
<div id="settingsGlobals" style='overflow-y: scroll; height: 150px;'>
</div>
</td>
</tr>
</table>
<table id='listtable' style='margin-top: 15px;'>
</table>
<br>
<br>
<input id='simulate' type='checkbox'><label for='simulate'>Generate drops via simulation :</label>
<input type="number" id='simulateRolls' value="100000" min="1" /> (rolls)
<button id='rollagain'>Roll again!</button>
<br>
<br>
<span style="font-size: 24px; font-weight: bold;">Item probabilities</span><br/>
<table id='itemtable' style='margin-top: 15px;'>
</table>
</center>
<script>
// property key is the FormID, property value is the Group string (4chars) concatenated with the EditorID
var edids = {};
// property key is the FormID, property value is the global float
var globals = {};
// property key is the FormID, property value is the leveled list object
var leveledLists = {};
// property key is the FormID, property value is an array of objects with the form { "x": 0, "y" : 0 }
var curves = {};
var downloadDone = 0;
// the currently shown chain of formids
var currentFormIDs = [];
// up to how many list items to consider for the formula evaluations
var formulaLimit = 20;
// how many runs to do for the monte-carlo simulation
var monteCarloCount = 1 << 18;
// if a number > 0 but less than epsilon, it is treated as zero.
var epsilon = 0.000001;
var vsel = document.getElementById("versionselect");
var vsop = vsel.options[vsel.options.length - 1];
vsop.selected = true;
vsop.text = vsop.text + " (latest)";
function allDownloaded() {
document.getElementById("loadversion").disabled = false;
/*
console.log(Object.keys(edids).length);
console.log(Object.keys(globals).length);
console.log(Object.keys(leveledLists).length);
console.log(Object.keys(curves).length);
*/
createTestLists();
// find cross references
for (var listID in leveledLists) {
var lvli = leveledLists[listID];
if (lvli.Entries !== undefined) {
for (var entry of lvli.Entries) {
var refList = leveledLists[entry.Object];
if (refList !== undefined) {
if (refList.Parents === undefined) {
refList.Parents = [];
}
if (!refList.Parents.includes(listID)) {
refList.Parents.push(listID);
}
}
}
}
}
// gatherFunctionNames();
// findMixedConditions();
var q = location.search;
if (q.includes("formids=")) {
var idx = q.indexOf("formids=");
var jdx = q.indexOf("&", idx + 8);
if (jdx < 0) {
jdx = q.length;
}
var ids = q.substring(idx + 8, jdx).split("-");
showChain(ids);
}
if (q.includes("itemsearchterm=")) {
var idx = q.indexOf("itemsearchterm=");
var jdx = q.indexOf("&", idx + 15);
if (jdx < 0) {
jdx = q.length;
}
document.getElementById("itemsearchterm").value = q.substring(idx + 15, jdx);
searchItems();
}
}
function createTestLists() {
// An All/Max=1 list with two entries
leveledLists["A0000001"] = {
LVLF: 4,
LVMV: 1,
Entries: [
{
Object: "A0000002",
LVIV: 6,
LVOV: 50
},
{
Object: "AA000001"
}
]
};
leveledLists["A0000002"] = {
LVLF: 3,
Entries: [
{
Object: "A0000003"
}
]
};
leveledLists["A0000003"] = {
LVLF: 4,
LVMV: 1,
Entries: [
{
Object: "AA000002",
LVOV: 20
},
{
Object: "AA000003",
LVOV: 0
}
]
}
edids["A0000001"] = "LVLITestList_A1 All/Max=1 list with two entries";
edids["A0000002"] = "LVLITestList_A2 forEach list with one entry";
edids["A0000003"] = "LVLITestList_A3 All/Max=1 list with two entries";
edids["AA000001"] = "MISCTest_Entry_1 Test Entry 1";
edids["AA000002"] = "MISCTest_Entry_2 Test Entry 2";
edids["AA000003"] = "MISCTest_Entry_3 Test Entry 3";
edids["AA000004"] = "MISCTest_Entry_4 Test Entry 4";
edids["AA000005"] = "MISCTest_Entry_5 Test Entry 5";
// Create test list for foreach+condition entries
leveledLists["A0000004"] = {
LVLF: 3,
Entries: [
{
Object: "AA000001"
},
{
Object: "AA000002",
Conditions: [
{
"Operator": 0,
"Value": 1.0,
"Function": 4955,
"FunctionName": "HasEntitlement",
"Param1Ref": "005ACF95",
"Param1Value": 8.339661E-39,
"Param2Ref": "00000000",
"Param2Value": 0.0,
"RunOn": "Subject"
}
]
},
{
Object: "AA000003"
}
]
};
leveledLists["A0000005"] = {
LVLF: 0,
Entries: [
{
Object: "AA000001"
},
{
Object: "AA000002",
Conditions: [
{
"Operator": 0,
"Value": 1.0,
"Function": 4955,
"FunctionName": "HasEntitlement",
"Param1Ref": "005ACF95",
"Param1Value": 8.339661E-39,
"Param2Ref": "00000000",
"Param2Value": 0.0,
"RunOn": "Subject"
}
]
},
{
Object: "AA000003"
}
]
}
edids["A0000004"] = "LVLITestList_A4 for-each + condition entries";
edids["A0000005"] = "LVLITestList_A4 one-random + condition entries";
}
function findMixedConditions() {
var formIDs = new Map();
for (var listID in leveledLists) {
var lvli = leveledLists[listID];
if (lvli.Conditions !== undefined) {
var logic = 0;
for (var cond of lvli.Conditions) {
if ((cond.Operator & 1) == 0) {
logic |= 1;
} else {
logic |= 2;
}
}
if (logic == 3) {
formIDs.set(listID, listID);
}
}
if (lvli.Entries !== undefined) {
for (var entry of lvli.Entries) {
if (entry.Conditions !== undefined) {
var logic = 0;
for (var cond of entry.Conditions) {
if ((cond.Operator & 1) == 0) {
logic |= 1;
} else {
logic |= 2;
}
}
if (logic == 3) {
formIDs.set(listID, listID);
}
}
}
}
}
for (var fn of formIDs.values()) {
console.log(fn);
}
}
function gatherFunctionNames() {
// TEMPORARY: dump unique "FunctionName"s
/*
var functionNames = new Map();
for (var listID in leveledLists) {
var lvli = leveledLists[listID];
if (lvli.Conditions !== undefined) {
for (var cond of lvli.Conditions) {
functionNames.set(cond.FunctionName, cond.FunctionName);
}
}
if (lvli.Entries !== undefined) {
for (var entry of lvli.Entries) {
if (entry.Conditions !== undefined) {
for (var cond of entry.Conditions) {
functionNames.set(cond.FunctionName, cond.FunctionName);
}
}
}
}
}
for (var fn of functionNames) {
console.log(fn);
}
*/
}
function loadScript(src, callback) {
var r = false;
var s = document.createElement('script');
s.type = 'text/javascript';
s.src = src;
s.onload = s.onreadystatechange = function() {
//console.log( this.readyState ); //uncomment this line to see which ready states are called.
if ( !r && (!this.readyState || this.readyState == 'complete') ) {
r = true;
callback(s);
}
};
var t = document.getElementsByTagName('script')[0];
t.parentNode.insertBefore(s, t);
}
function doLoad() {
document.getElementById("loadversion").disabled = true;
var versionSelect = document.getElementById("versionselect");
if (versionSelect.selectedIndex >= 0) {
downloadDone = 4;
var patchPrefix =
// "https://akarnokd.github.com/rng-76/" +
versionSelect.options[versionSelect.selectedIndex].value + "_";
loadScript("data/" + patchPrefix + "SeventySix_EDIDs.js", node => {
if (--downloadDone == 0) {
allDownloaded();
}
});
loadScript("data/" + patchPrefix + "SeventySix_GLOBs.js", node => {
if (--downloadDone == 0) {
allDownloaded();
}
});
loadScript("data/" + patchPrefix + "SeventySix_LVLIs.js", node => {
if (--downloadDone == 0) {
allDownloaded();
}
});
loadScript("data/" + patchPrefix + "SeventySix_CURVs.js", node => {
if (--downloadDone == 0) {
allDownloaded();
}
});
}
}
document.getElementById("loadversion").onclick = doLoad;
var infoMap = new Map();
infoMap.set("ListSearch",
"Enter the FormID (leading zeros can be omitted) or Editor ID of the leveled list to find."
+ "<br>Use * to indicate a wildcard (e.g., *Fasnacht*)."
+ "<br>Use commas to list alternative options."
+ "<br>Spaces and capitalization are ignored."
);
infoMap.set("ItemSearch",
"Enter the FormID (leading zeros can be omitted) or Editor ID of the item you want to locate in the leveled lists."
+ "<br>Use * to indicate a wildcard (e.g., *Fixer*)."
+ "<br>Use commas to list alternative options."
+ "<br>Spaces between words are considered (e.g., *long coat*)."
+ "<br>Capitalization is ignored."
);
// add HTML explanation marker
function info(name) {
return " <sup><a href='#' style='font-size: 14; font-weight: bold;' onclick='showinfo(this, \"" + name + "\"); return false;'>Tip</a></sup>";
}
// popup for explanation
function showinfo(target, name) {
var div = document.getElementById("InfoDiv" + name);
if (div == null) {
var div = document.createElement("div");
div.style.border = "1px solid black";
div.style.padding = "3px";
div.style.position = "absolute";
div.style.backgroundColor = "#FFFFD0";
div.style.zIndex = 99;
div.id = "InfoDiv" + name;
var txt = infoMap.get(name);
if (txt == null) {
txt = "??? " + name + " ???";
}
txt += "<hr><font style='font-size: 14px'>Click to close.</font>";
div.innerHTML = txt;
target.parentElement.appendChild(div);
div.onclick = function() {
target.parentElement.removeChild(div);
}
} else {
target.parentElement.removeChild(div);
}
}
document.getElementById("listsearchtip").innerHTML = "Search leveled list " + info("ListSearch");
document.getElementById("itemsearchtip").innerHTML = "Search item in lists " + info("ItemSearch");
// paging support
var searchResults = [];
function parseSearchText(text) {
var result = text.split(",");
for (var i = 0; i < result.length; i++) {
// remove spaces
var entry = result[i].trim();
entry = entry.replace(" ", "\\s");;
entry = entry.replace(/\*/g, ".*");
entry = entry.replace(/^0+/, "");
entry = entry.toLowerCase();
result[i] = new RegExp("^" + entry + "$");
}
return result;
}
function getEditorID(formID) {
var result = edids[formID];
if (result !== undefined) {
var idx = result.indexOf(" ", 4);
if (idx < 0) {
return result.substring(4);
}
return result.substring(4, idx);
}
return "";
}
function getDescription(formID) {
var result = edids[formID];
if (result !== undefined) {
var idx = result.indexOf(" ", 4);
if (idx > 0) {
return result.substring(idx + 1);
}
}
return "";
}
function getGroupID(formID) {
var result = edids[formID];
if (result !== undefined) {
return result.substring(0, 4);
}
return "";
}
function createListLink(formID, text) {
return "<a href='#' onclick='showList(\"" + formID + "\"); return false;'>" + text + "</a>";
}
function interpolate(curveTable, x) {
var first = curveTable[0];
if (x <= first.x) {
return first.y;
}
var last = curveTable[curveTable.length - 1];
if (last <= x) {
return last.y;
}
for (var i = 0; i < curveTable.length - 1; i++) {
var curr = curveTable[i];
var next = curveTable[i + 1];
if (curr.x <= x && x < next.x) {
var step = next.x - curr.x;
var raise = next.y - curr.y;
var xrate = (x - curr.x) / step;
var yrate = curr.y + raise * xrate;
return yrate;
}
}
return NaN;
}
function decodeValue(entry, keyDirect, keyGlobal, keyCurve) {
var curveID = entry[keyCurve];
var globalID = entry[keyGlobal];
if (curveID !== undefined) {
var curveTable = curves[curveID];
if (curveTable !== undefined) {
if (globalID !== undefined) {
var x = getSettingsValue(globalID);
if (x === undefined) {
x = globals[globalID];
}
if (x !== undefined) {
var v = interpolate(curveTable, x);
return {
type: "Curve",
id: curveID,
g: globalID,
x: x,
value: v
};
}
return {
type: "Curve",
id: curveID,
x: globalID,
error: "Global value not found"
};
}
return {
type: "Curve",
id: curveID,
error: "Global reference entry missing"
}
}
return {
type: "Curve",
id: curveID,
error: "Curve table not found."
}
}
if (globalID !== undefined) {
var x = getSettingsValue(globalID);
if (x === undefined) {
x = globals[globalID];
}
if (x !== undefined) {
return {
type: "Global",
id: globalID,
value: x
};
}
return {
type: "Global",
id: globalID,
error: "Global value not found"
}
}
var direct = entry[keyDirect];
if (direct === undefined) {
direct = 0;
}
return {
type: "Constant",
value: direct
};
}
function createNukaLink(formID) {
return "<a href='https://nukacrypt.com/database/json/" + formID + "' target='_blank' title='"
+ getDescription(formID) + ". "
+ "Click to see the Nukacrypt data.'>☢ "
+ getGroupID(formID) + ":" + formID + " <" + getEditorID(formID) + ">"
+ "</a>";
}
function pickComboSettings(key, entry) {
var input = settingsMap.get(key);
if (input !== undefined) {
if (input.selectedIndex !== undefined) {
for (var i = 0; i < input.options.length; i++) {
var opt = input.options[i];
if (opt.value == entry) {
if (opt.selected) {
opt.selected = false;
input.options[0].selected = true;
} else {
opt.selected = true;
}
input.dispatchEvent(new Event('input'));
break;
}
}
}
}
return false;
}
function isComboSelected(key, entry) {
var input = settingsMap.get(key);
if (input !== undefined) {
if (input.selectedIndex !== undefined) {
for (var i = 0; i < input.options.length; i++) {
var opt = input.options[i];
if (opt.value == entry && opt.selected) {
return true;
}
}
}
}
return false;
}
function toggleCheckBoxSettings(key) {
var input = settingsMap.get(key);
if (input !== undefined) {
input.checked = !input.checked;
input.dispatchEvent(new Event('input'));
}
}
function isCheckBoxSelected(key) {
var input = settingsMap.get(key);
return input !== undefined && input.checked;
}
function buildConditionEntry(parent, entry, maxCols) {
if (entry.Conditions !== undefined) {
n = parent.rows.length;
row = parent.insertRow(n);
cll = row.insertCell(row.cells.length);
cll.colSpan = maxCols;
cll.style.paddingLeft = "60px";
var innerTbl = document.createElement("table");
innerTbl.style.width = "100%";
cll.appendChild(innerTbl);
row = innerTbl.insertRow(0);
cll = row.insertCell(0);
var checkTxt = "";
if (evaluateConditions(entry.Conditions)) {
checkTxt = "<span style='color: green; font-weight: bold'>[ 👍 PASS ]</span>";
} else {
checkTxt = "<span style='color: red; font-weight: bold'>[ ❌ FAIL ]</span>";
}
cll.innerHTML = "Conditions (" + entry.Conditions.length + ") " + checkTxt;
cll.style.backgroundColor = "#FFC0FF";
cll.style.fontWeight = "bold";
buildConditionItem(innerTbl, entry);
}
}
var functionMap = new Map();
// displayFunction: function(fn, cond) : string
// settingsFunction: function(fn, cond) : void
// evalFunction: function(fn, cond) : object
function addFunction(name, displayFunction, settingsFunction, evalFunction) {
var rec = {
display: displayFunction,
settings: settingsFunction,
evaluate: evalFunction
};
functionMap.set(name, rec);
return rec;
}
var animSteps = 10;
var animTime = 250;
var currentAnim = undefined;
var currentObj = undefined;
function findTextBox(id) {
var o = document.getElementById(id);
o.scrollIntoView();
flash(o, 0);
}
function flash(obj, n) {
if (n == 0) {
if (currentAnim) {
clearTimeout(currentAnim);
currentObj.style.backgroundColor = "";
}
currentObj = obj;
}
if (n < animSteps && currentObj == obj) {
currentAnim = setTimeout(() => {
if ((n % 2) == 0) {
obj.style.backgroundColor = "#FFFF00"
} else {
obj.style.backgroundColor = "";
}
flash(obj, n + 1);
}, animTime);
} else {
obj.style.backgroundColor = "";
}
}
var displayOneLinkFunc = function(fn, cond) {
return "(" + createNukaLink(cond.Param1Ref) + ")"
;
};
var displayOneLinkCheckFunc = function(fn, cond) {
var clazz = "picker";
var key = fn + "_" + cond.Param1Ref;
if (isCheckBoxSelected(key)) {
clazz = "pickerOn";
}
return "(" + createNukaLink(cond.Param1Ref) + ")"
+ " <a href='#' onclick='javascript:toggleCheckBoxSettings(\"" + key
+ "\"); return false;' title='Toggle this condition' "
+ "class='" + clazz + "'>←</a>"
;
};
var displayNoneCheckFunc = function(fn, cond) {
var clazz = "picker";
var key = fn;
if (isCheckBoxSelected(key)) {
clazz = "pickerOn";
}
return " <a href='#' onclick='javascript:toggleCheckBoxSettings(\"" + fn
+ "\"); return false;' title='Toggle this condition' "
+ "class='" + clazz + "'>←</a>"
;
};
var displayFindBox = function(fn, cond) {
var clazz = "picker";
var key = fn;
return " <a href='#' onclick='javascript:findTextBox(\"" + fn
+ "\"); return false;' title='Find this texbox' "
+ "class='" + clazz + "'>#</a>"
;
};
var displayOneLinkPickFunc = function(fn, cond) {
var clazz = "picker";
if (isComboSelected(fn, cond.Param1Ref)) {
clazz = "pickerOn"
}
return "(" + createNukaLink(cond.Param1Ref) + ")"
+ " <a href='#' onclick='javascript:pickComboSettings(\"" + fn + "\", \"" + cond.Param1Ref
+ "\"); return false;' title='Use this in the settings. Click again to select N/A.' "
+ "class='" + clazz + "'>←</a>"
;
};
var displayPickDayOfWeekFunc = function(fn, cond) {
return " <a href='#' onclick='javascript:pickComboSettings(\"" + fn + "\", \"" + cond.Value
+ "\"); return false;' title='Use this day of week' "
+ "class='picker'>←</a>"
;
};
var displayTwoLinksFunc = function(fn, cond) {
return "("
+ createNukaLink(cond.Param1Ref)
+ ", "
+ createNukaLink(cond.Param2Ref)
+ ")";
};
var displayLinkAndIntFunc = function(fn, cond) {
return "("
+ createNukaLink(cond.Param1Ref)
+ ", "
+ parseInt(cond.Param2Ref, 16)
+ ")";
};
// Checkboxes
// ==========
var addCheckBoxFunc = function(fn, cond) {
appendCheckBox(fn, cond.Param1Ref);
};
var addCheckBoxValue = function(fn, cond) {
appendCheckBoxValue(fn);
};
var addCheckBoxRefIntFunc = function(fn, cond) {
appendCheckBoxRefInt(fn, cond);
};
// Comboboxes
// ==========
var addComboBoxFunc = function(fn, cond) {
appendComboBox(fn, cond.Param1Ref);
};
var addComboBoxParam2IntFunc = function(fn, cond) {
appendComboBoxParam2Int(fn, cond.Param1Ref, parseInt(cond.Param2Ref, 16));
};
var dayOfWeekComboBoxFunc = function(fn, cond) {
appendComboBoxDayOfWeek(fn);
}
// Texboxes
// ========
var addTextBoxFunc = function(fn, cond) {
appendTextBox(cond, "Param1Ref", true);
};
var addTextBoxValueFunc = function(fn, cond) {
appendTextBoxValue(fn);
};
var addTextBoxParamFunc = function(fn, cond) {
appendTextBoxParam(fn, cond.Param1Ref, false);
};
var addTextBoxParamFunc2 = function(fn, cond) {
appendTextBoxParam2(fn, cond.Param1Ref, cond.Param2Ref);
};
var addTextBoxNameParamFunc = function(fn, cond) {
appendTextBoxParam(fn, cond.Param1Ref, true);
};
// oooooooooooooooooooooooooooooooooooooo
var evalCheckBoxFunc = function(fn, cond) {
return getSettingsValue(fn + "_" + cond.Param1Ref);
};
var evalCheckBoxValue = function(fn, cond) {
return getSettingsValue(fn);
};
var evalComboBoxFunc = function(fn, cond) {
var selectOption = getSettingsValue(fn);
return selectOption == cond.Param1Ref;
};
var evalTextBox = function(fn, cond) {
return getSettingsValue(cond.Param1Ref);
};
var evalTextBoxValue = function(fn, cond) {
return getSettingsValue(fn);
};
var evalTextBoxRefRef = function(fn, cond) {
return getSettingsValue(cond.Param1Ref + "_" + cond.Param2Ref);
};
var evalCheckBoxFuncRefRef = function(fn, cond) {
return getSettingsValue(fn + "_" + cond.Param1Ref + "_" + cond.Param2Ref);
};
// Presence/absence based on a key by reference
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
addFunction("HasLearnedRecipe", displayOneLinkCheckFunc, addCheckBoxFunc, evalCheckBoxFunc);
addFunction("EditorLocationHasKeyword", displayOneLinkCheckFunc, addCheckBoxFunc, evalCheckBoxFunc);
addFunction("GetQuestCompleted", displayOneLinkCheckFunc, addCheckBoxFunc, evalCheckBoxFunc);
addFunction("HasEntitlement", displayOneLinkCheckFunc, addCheckBoxFunc, evalCheckBoxFunc);
addFunction("WornHasKeyword", displayOneLinkCheckFunc, addCheckBoxFunc, evalCheckBoxFunc);
addFunction("IsTrueForConditionForm", displayOneLinkCheckFunc, addCheckBoxFunc, evalCheckBoxFunc);
addFunction("HasPerk", displayOneLinkCheckFunc, addCheckBoxFunc, evalCheckBoxFunc);
addFunction("HasKeyword", displayOneLinkCheckFunc, addCheckBoxFunc, evalCheckBoxFunc);
addFunction("HasActiveMagicEffect", displayOneLinkCheckFunc, addCheckBoxFunc, evalCheckBoxFunc);
addFunction("GetEquipped", displayOneLinkCheckFunc, addCheckBoxFunc, evalCheckBoxFunc);
addFunction("PlayerHasQuest", displayOneLinkCheckFunc, addCheckBoxFunc, evalCheckBoxFunc);
// A global value keyed by its ID
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
addFunction("GetGlobalValue", displayOneLinkFunc, addTextBoxFunc, evalTextBox);
// Direct numeric value on subject/target
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
addFunction("GetStage", displayFindBox, addTextBoxValueFunc, evalTextBoxValue);