forked from randomqwerty/gflmaps
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.js
More file actions
3498 lines (3196 loc) · 156 KB
/
Copy pathmain.js
File metadata and controls
3498 lines (3196 loc) · 156 KB
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
(function(){
var config = {
langCode: "en",
dataSource: "ch",
shouldLoadChibis: true,
};
let loadedImageAssets = {};
// TODO add TC, KR, JP
var fontList = "Noto Sans, Noto Sans SC, Arial";
var data;
var Enemy_team, Enemy_team_map;
var Enemy_in_team, Enemy_in_team_by_team_id;
var Enemy_standard_attribute;
var Spot;
var Theater_area;
var Mission, Mission_map;
var Enemy_charater_type, Enemy_character_type_by_id;
var Ally_team;
var Gun, Gun_by_id;
var Gun_in_ally;
var Sangvis;
var Sangvis_in_ally;
var equip_in_ally_info;
var trial_info;
var Building, BuildingMap;
var Team_ai;
var Mission_targettrain_enemy;
var Mission_event_prize_info;
var Fairy;
var Item;
var Gift_item;
var Prize;
var Daily_mission_group;
var Mission_win_type_config;
var Mission_txt, Mission_cn_txt;
var Enemy_charater_type_txt, Enemy_charater_type_cn_txt;
var Ally_team_txt, Ally_team_cn_txt;
var Building_txt, Building_cn_txt;
var Equip_txt, Equip_cn_txt;
var Gun_txt, Gun_cn_txt;
var Sangvis_txt, Sangvis_cn_txt;
var Team_ai_txt;
var Mission_targettrain_enemy_txt, Mission_targettrain_enemy_cn_txt;
var Special_spot_config_txt, Special_spot_config_cn_txt;
var Fairy_txt, Fairy_cn_txt;
var Item_txt, Item_cn_txt;
var Gift_item_txt, Gift_item_cn_txt;
var Mission_win_type_config_txt, Mission_win_type_config_cn_txt;
var UI_TEXT = {};
var INSTRUCTIONS = "";
const spotPaths = [
"random_belong0.png",
"random_belong1.png",
"random_belong2.png",
"random_belong3.png",
"random_belong99.png",
"spot1_belong1.png",
"spot1_belong0.png",
"spot1_belong2.png",
"spot1_belong3.png",
"spot1_belong99.png",
"spot2_belong0.png",
"spot2_belong1.png",
"spot2_belong2.png",
"spot2_belong3.png",
"spot2_belong99.png",
"spot3_belong0.png",
"spot3_belong0_closed.png",
"spot3_belong1.png",
"spot3_belong1_closed.png",
"spot3_belong2.png",
"spot3_belong2_closed.png",
"spot3_belong3.png",
"spot3_belong3_closed.png",
"spot3_belong99.png",
"spot3_belong99_closed.png",
"spot4_belong0.png",
"spot4_belong1.png",
"spot4_belong2.png",
"spot4_belong3.png",
"spot4_belong99.png",
"spot5_belong0.png",
"spot5_belong1.png",
"spot5_belong2.png",
"spot5_belong3.png",
"spot5_belong99.png",
"spot6_belong0.png",
"spot6_belong1.png",
"spot6_belong2.png",
"spot6_belong3.png",
"spot6_belong99.png",
"spot7_belong0.png",
"spot7_belong0_closed.png",
"spot7_belong1.png",
"spot7_belong1_closed.png",
"spot7_belong2.png",
"spot7_belong2_closed.png",
"spot7_belong3.png",
"spot7_belong3_closed.png",
"spot7_belong99.png",
"spot7_belong99_closed.png",
"spot8_belong0.png",
"spot8_belong1.png",
"spot8_belong2.png",
"spot8_belong3.png",
"spot8_belong99.png",
];
// As of DR/Division/MS (up to client 2.07), if an allied team is controllable,
// then its "ai" field's second part looks like "2010" or "2001:4,8".
// Each digit after the initial "2" can be "0" or "1", and indicates a separate
// attribute about the team. The digits are:
// * The second digit indicates whether or not the allied team can be retreated.
// No controllable allied team in DR/Division/MS has this set to true.
// * The third digit indicates whether or not the allied team can be repaired.
// * The fourth digit indicates whether or not the allied team can be resupplied.
// If this is set to zero, then the allied team has infinite ammo/MRE.
// If this is set to one, then there are two numbers after this digit and a colon.
// Those two numbers are the ammo count (out of 5) and MRE count (out of 10).
const controllableAllyTeamRegex = /2([01])([01])(0|1:(\d+),(\d+))/;
let missionIdToSuspectedSpawns = {};
let theaterAreaToLevelAdjustments = {};
let defDrillTeamsToLevels = {};
const wellKnownEnemyCodes = new Set([
"Nyto_Black_SMG",
"Nyto_Black_Hammer",
"Nyto_Black_RF",
"Nyto_White_Commander",
"Cerynitis_Deutsch",
"Hydra_Deutsch",
"Coeus_Deutsch",
"AA02_Mini_Deutsch",
"Chariot_Military_Deutsch",
"Aegis_GA_Deutsch",
]);
// CHANGES FROM GFWIKI: For most data, if the asset text file does not contain a name or the name is blank,
// then just use the table ID (i.e. "[mission-10000125]" for 13-1). This is so that names don't appear blank
// when using dataSource=CN and langCode=EN.
function trans() {
for (i in Building) {
var namestr = Building_txt[Building[i].name] ? Building_txt[Building[i].name].trim().replace("//c", UI_TEXT["comma"]) : null;
if (namestr && !namestr.match(/(?:don't|do not) translate/i)) {
Building[i].name = namestr;
} else {
const fallback_match = Building_cn_txt[Building[i]];
Building[i].name = fallback_match ? `[${Building[i].code}] ${fallback_match[1]}` : `[${Building[i].code}]`;
};
}
for (i in Mission) {
var namestr = Mission_txt[Mission[i].name] ? Mission_txt[Mission[i].name].trim().replace("//c", UI_TEXT["comma"]) : null;
if (namestr && !namestr.match(/(?:don't|do not) translate/i)) {
Mission[i].name = namestr;
} else {
const fallback_match = Mission_cn_txt[Mission[i].name];
Mission[i].name = fallback_match ? `[${Mission[i].name}] ` + fallback_match : `[${Mission[i].name}]`;
}
}
for(i in Enemy_charater_type) {
var namestr = Enemy_charater_type_txt[Enemy_charater_type[i].name] ? Enemy_charater_type_txt[Enemy_charater_type[i].name].trim().replace("//c", UI_TEXT["comma"]) : null;
if (namestr) {
Enemy_charater_type[i].name = namestr;
if (wellKnownEnemyCodes.has(Enemy_charater_type[i].code)) {
// Certain enemies are known by their codes longer than their localized names, so their codes are
// added back for clarification.
//Enemy_charater_type[i].name = `[${Enemy_charater_type[i].code}] ${namestr}`;
// 09-27-2025: shortened enemy list and only using the codes instead of both the code and localized name
Enemy_charater_type[i].name = `${Enemy_charater_type[i].code}`;
} else if (Enemy_charater_type[i].code.match(/swap/i) && !Enemy_charater_type[i].name.match(/swap/i)) {
// Add " [SWAP]" at the end of the name if the enemy code contains "SWAP" but the name does not.
// This is because the official English localization sometimes just omits this qualifier...
Enemy_charater_type[i].name += " [SWAP]";
}
} else {
let prefix = "";
const fallback_match = Enemy_charater_type_cn_txt[Enemy_charater_type[i]];
if (Enemy_charater_type[i].code) {
// CHANGE FROM GFWIKI: When dataSource=CN and langCode=EN, for enemy characters without names,
// if they have a codename, then display the codename in square brackets.
prefix = `[${Enemy_charater_type[i].code}]`;
} else {
prefix = `[${Enemy_charater_type[i].name}]`;
}
Enemy_charater_type[i].name = fallback_match ? `${prefix} ${fallback_match[1]}` : prefix;
}
}
for (i in Ally_team) {
var namestr = Ally_team_txt[Ally_team[i].name] ? Ally_team_txt[Ally_team[i].name].trim().replace("//c", UI_TEXT["comma"]) : null;
if (namestr) {
Ally_team[i].name = namestr;
Ally_team[i].controllableAlliedTeamName = namestr;
} else {
// CHANGE FROM GFWIKI: Team names have table IDs in the format of "ally_team-10000026", even though these
// teams can be enemies to the player. If the map just displayed "[ally_team-10000026]" as a placeholder,
// that might confuse people who assume that that team is allied with them. Here, we just truncate the "ally_"
// part and display "[team-10000026]".
const teamname_match = Ally_team[i].name.match(/team-\d+/);
const prefix = teamname_match.length ? `[${teamname_match[0]}]` : `[${Ally_team[i].name}]`;
const fallback_match = Ally_team_cn_txt[Ally_team[i].name];
Ally_team[i].name = fallback_match ? `${prefix} ${fallback_match[1]}` : prefix;
Ally_team[i].controllableAlliedTeamName = fallback_match ? fallback_match[1] : prefix;
}
}
for (i in Team_ai) {
var namestr = Team_ai_txt[Team_ai[i].name] ? Team_ai_txt[Team_ai[i].name].trim().replace("//c", UI_TEXT["comma"]) : null;
if (namestr) {
Team_ai[i].name = namestr;
} else {
Team_ai[i].name = `[${Team_ai[i].name}]`;
}
}
for (i in Mission_targettrain_enemy) {
var namestr = Mission_targettrain_enemy_txt[Mission_targettrain_enemy[i].name] ? Mission_targettrain_enemy_txt[Mission_targettrain_enemy[i].name].trim().replace("//c", UI_TEXT["comma"]) : null;
if (namestr) {
Mission_targettrain_enemy[i].name = namestr;
} else {
const fallback_match = Mission_targettrain_enemy_cn_txt[Mission_targettrain_enemy[i].name];
Mission_targettrain_enemy[i].name = fallback_match ? `[${Mission_targettrain_enemy[i].name}] ${fallback_match[1]}` : `[${Mission_targettrain_enemy[i].name}]`;
}
const desc_match = Mission_targettrain_enemy_txt[Mission_targettrain_enemy[i].des];
const desc_fallback_match = Mission_targettrain_enemy_cn_txt[Mission_targettrain_enemy[i].des];
Mission_targettrain_enemy[i].des = (desc_match || desc_fallback_match || ["", ""])[1].replace("//c", UI_TEXT["comma"]);
}
}
// Create a map of mission IDs to enemy teams that are not initial spawns, but
// are next to teams that are initial spawns for those mission IDs. The idea
// behind this is that enemy teams for a particular mission are usually listed
// next to each other.
const calculateSuspectedSpawns = () => {
missionIdToSuspectedSpawns = {};
let enemyTeamIdToMissionId = {};
Spot.forEach((spot) => {
let enemyTeamId = spot.enemy_team_id;
if (spot.ally_team_id) {
const allyTeam = Ally_team.find((allyTeam) => allyTeam.id === spot.ally_team_id);
if (!allyTeam) {
return;
}
enemyTeamId = allyTeam.enemy_team_id;
}
if (enemyTeamId && !(enemyTeamId in enemyTeamIdToMissionId)) {
enemyTeamIdToMissionId[enemyTeamId] = spot.mission_id;
}
});
let lastMissionId = null;
Enemy_team.forEach((enemyTeam) => {
if ((enemyTeam.id >= 700000 && enemyTeam.id < 770000) || (enemyTeam.id > 770099 && enemyTeam.id < 800000)) {
return;
}
if (enemyTeam.id >= 800000 && enemyTeam.id < 820000) {
return;
}
if (enemyTeam.id >= 1000110 && enemyTeam.id < 1000150) {
return;
}
if (enemyTeam.id in enemyTeamIdToMissionId) {
lastMissionId = enemyTeamIdToMissionId[enemyTeam.id];
} else if (lastMissionId && (enemyTeam.id < 1051100 || enemyTeam.id >= 1200000)) {
if (!(lastMissionId in missionIdToSuspectedSpawns)) {
missionIdToSuspectedSpawns[lastMissionId] = [];
}
missionIdToSuspectedSpawns[lastMissionId].push(enemyTeam.id);
}
});
// Silent Sandbox bandaid fix
if (missionIdToSuspectedSpawns[11946]) {
missionIdToSuspectedSpawns[11946] = missionIdToSuspectedSpawns[11946].filter(n => Math.floor(n / 100) === 7700);
}
// Steel Rain Salute bandaid fix
missionIdToSuspectedSpawns[11988] = [...new Set([
...(missionIdToSuspectedSpawns[11988] || []),
800201,800202,800203,800204,800205,800214,800215,800216,800217,800218,800219,800220,800221,800222,800223,800224,800225,800226,800227,800228,800229,800230,800231,800232,800233,800234,800235,800236,800237,800238,800239,800240,800241,800242,800243,800244,800245,800246,800247,800248,800249,800250
])];
// AW+ spawns.
missionIdToSuspectedSpawns[10105] = [...new Set([
...(missionIdToSuspectedSpawns[10105] || []),
2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035,2141,2142,2143,2144,2145,2146
])];
// Coalition Drill Combat Reports
missionIdToSuspectedSpawns[1601] = [...new Set([
...(missionIdToSuspectedSpawns[1601] || []),
940001,940002,940003,940004,940005
])];
// Coalition Drill Petri Dishes
missionIdToSuspectedSpawns[1602] = [...new Set([
...(missionIdToSuspectedSpawns[1602] || []),
940006,940007,940008,940009,940010
])];
// Coalition Drill Data
missionIdToSuspectedSpawns[1603] = [...new Set([
...(missionIdToSuspectedSpawns[1603] || []),
940011,940012,940013,940014,940015
])];
};
const calculateTheaterLevelAdjustments = () => {
theaterAreaToLevelAdjustments = {};
Theater_area.forEach((area) => {
eval(`levelsMatch = [${area.enemy_lv}];`)
// const levelsMatch = area.enemy_lv.match(/^(-?\d+),.*,(-?\d+)$/);
const teamMatch = area.enemy_group.matchAll(/(?:^|,)(\d+)-/g);
if (levelsMatch) {
theaterAreaToLevelAdjustments[area.id] = {
min: Math.min.apply(null, levelsMatch),
max: Math.max.apply(null, levelsMatch),
levels: levelsMatch,
enemyTeamIds: [...teamMatch].map((match) => Number(match[1])),
};
}
});
//console.log(theaterAreaToLevelAdjustments);
};
const calculateDefDrillTeamLevels = () => {
defDrillTeamsToLevels = {};
trial_info
.map(({enemy_team_id, enemy_level}) => ({enemy_team_id: Number(enemy_team_id), enemy_level: Number(enemy_level)}))
.forEach(({enemy_team_id, enemy_level}) => {
if (!(enemy_team_id in defDrillTeamsToLevels)) {
defDrillTeamsToLevels[enemy_team_id] = {min: enemy_level, max: enemy_level};
}
if (defDrillTeamsToLevels[enemy_team_id].min > enemy_level) {
defDrillTeamsToLevels[enemy_team_id].min = enemy_level;
}
if (defDrillTeamsToLevels[enemy_team_id].max < enemy_level) {
defDrillTeamsToLevels[enemy_team_id].max = enemy_level;
}
});
//console.log(defDrillTeamsToLevels);
};
firstcreat();
const loadImageAsset = (path, fallbackPath = undefined) => {
if (path in loadedImageAssets) {
return Promise.resolve(loadedImageAssets[path]);
}
return new Promise((resolve, reject) => {
const img = new Image();
img.onload = () => {
if (!(path in loadedImageAssets)) {
loadedImageAssets[path] = img;
}
resolve(loadedImageAssets[path]);
};
img.onerror = () => {
if (fallbackPath) {
img.onerror = null; // Prevent infinite loop if fallback also fails
img.src = `./images/${fallbackPath}`;
console.log("Could not find chibi, using fallback " + path);
} else {
reject();
}
};
img.src = `./images/${path}`;
});
};
const isRanking = (mission) => (
mission.endless_mode === 1 || mission.endless_mode === 2
// This seems to hold for Fixed Point's maps.
|| mission.score_prize !== ""
);
const getChibiPath = (code) => `map_chibis/${code}_wait0.gif`;
const getChibi = (code) => loadedImageAssets[getChibiPath(code)];
const loadChibi = (code, redrawFunc) => {
loadImageAsset(getChibiPath(code), getChibiPath('fallback')).then(() => redrawFunc && redrawFunc());
};
const loadData = async () => {
const loadTextFile = (url) => fetch(url).then((result) => result.text());
const loadJsonFile = (url) => fetch(url).then((result) => result.json());
const loadStcFile = (file) => loadJsonFile(`https://raw.githubusercontent.com/randomqwerty/GFLData/main/${config.dataSource}/stc/${file}`);
const loadCatchFile = (file) => loadJsonFile(`https://raw.githubusercontent.com/randomqwerty/GFLData/main/${config.dataSource}/catchdata/${file}`);
const loadTextTable = (file) => loadJsonFile(`https://raw.githubusercontent.com/randomqwerty/GFLData/main/${config.langCode}/text/table/${file}`);
const loadCnTextTable = (file) => loadJsonFile(`https://raw.githubusercontent.com/randomqwerty/GFLData/main/ch/text/table/${file}`);
const loaders = {
"Spot": loadStcFile(`spot.json`).then((result) => Spot = result),
"Enemy_in_team": loadStcFile(`enemy_in_team.json`).then((result) => {
Enemy_in_team = result;
Enemy_in_team_by_team_id = {};
result.forEach((row) => {
if (!(row.enemy_team_id in Enemy_in_team_by_team_id)) {
Enemy_in_team_by_team_id[row.enemy_team_id] = [];
}
Enemy_in_team_by_team_id[row.enemy_team_id].push(row);
});
}),
"Enemy_standard_attribute": loadStcFile(`enemy_standard_attribute.json`).then((result) => Enemy_standard_attribute = result),
"Enemy_team": loadStcFile(`enemy_team.json`).then((result) => {
Enemy_team = result;
Enemy_team_map = Object.fromEntries(result.map((enemyTeam) => [enemyTeam.id, enemyTeam]));
}),
"Equip": loadStcFile(`equip.json`).then((result) => {
Equip = result;
Equip_map = Object.fromEntries(result.map((equip) => [equip.id, equip]));
}),
"Theater_area": loadStcFile(`theater_area.json`).then((result) => Theater_area = result),
"Building": loadStcFile(`building.json`).then((result) => {
Building = result;
BuildingMap = Object.fromEntries(result.map((building) => [building.id, building]));
}),
"Auto_mission": loadStcFile(`auto_mission.json`).then((result) => {
Auto_mission = result;
Auto_mission_map = Object.fromEntries(result.map((auto_mission) => [auto_mission.mission_id, auto_mission]));
}),
"Mission": loadStcFile(`mission.json`).then((result) => {
Mission = result;
Mission_map = Object.fromEntries(result.map((mission) => [mission.id, mission]));
}),
"Enemy_character_type": loadStcFile(`enemy_character_type.json`).then((result) => {
Enemy_charater_type = result;
Enemy_character_type_by_id = Object.fromEntries(result.map((enemy) => [enemy.id, enemy]));
}),
"Ally_team": loadStcFile(`ally_team.json`).then((result) => Ally_team = result),
"Gun": loadStcFile(`gun.json`).then((result) => {
Gun = result;
Gun_by_id = Object.fromEntries(result.map((gun) => [gun.id, gun]));
}),
"Gun_in_ally": loadStcFile(`gun_in_ally.json`).then((result) => Gun_in_ally = result),
"Sangvis": loadStcFile(`sangvis.json`).then((result) => Sangvis = result),
"Sangvis_in_ally": loadStcFile(`sangvis_in_ally.json`).then((result) => Sangvis_in_ally = result),
"Fairy": loadStcFile(`fairy.json`).then((result) => Fairy = result),
"Item": loadStcFile(`item.json`).then((result) => Item = result),
"Gift_item": loadStcFile(`gift_item.json`).then((result) => Gift_item = result),
"Prize": loadStcFile(`prize.json`).then((result) => Prize = result),
"Furniture": loadStcFile(`furniture.json`).then((result) => Furniture = result),
"Skin": loadStcFile(`skin.json`).then((result) => Skin = result),
"Commander_uniform": loadStcFile(`commander_uniform.json`).then((result) => Commander_uniform = result),
"Daily_mission_group": loadStcFile(`daily_mission_group.json`).then((result) => Daily_mission_group = result),
"Mission_win_type_config": loadStcFile(`mission_win_type_config.json`).then((result) => Mission_win_type_config = result),
"equip_in_ally_info": loadCatchFile(`equip_in_ally_info.json`).then((result) => equip_in_ally_info = result["equip_in_ally_info"]),
"trial_info": loadCatchFile(`trial_info.json`).then((result) => trial_info = result["trial_info"]),
"Mission_event_prize_info": loadCatchFile(`mission_event_prize_info.json`).then((result) => Mission_event_prize_info = result["mission_event_prize_info"]),
/*
"ConstructibleThings": loadJsonFile(`./data/${config.dataSource}/Recommended_formula.json`).then((result) => {
result.forEach((formula) => {
if (formula.develop_type == 1 || formula.develop_type == 2) {
[...formula.preview.matchAll(/(\d+)-0/g)].forEach((match) => ConstructibleDollIds.add(Number(match[1])));
} else if (formula.develop_type == 3) {
[...formula.preview.matchAll(/[:,](\d+)/g)].forEach((match) => ConstructibleEquipIds.add(Number(match[1])));
}
});
return {
ConstructibleDollIds: [...ConstructibleDollIds],
ConstructibleEquipIds: [...ConstructibleEquipIds],
};
}),
// */
"Team_ai": loadStcFile(`team_ai.json`).then((result) => Team_ai = result),
"Mission_targettrain_enemy": loadStcFile(`mission_targettrain_enemy.json`).then((result) => Mission_targettrain_enemy = result),
"UI_TEXT": loadJsonFile(`./text/${config.langCode}/ui_text.json`).then((result) => UI_TEXT = result),
"Building_txt": loadTextTable(`building.json`).then((result) => Building_txt = result),
"Building_cn_txt": loadCnTextTable(`building.json`).then((result) => Building_cn_txt = result),
"Equip_txt": loadTextTable(`equip.json`).then((result) => Equip_txt = result),
"Equip_cn_txt": loadCnTextTable(`equip.json`).then((result) => Equip_cn_txt = result),
"Gun_txt": loadTextTable(`gun.json`).then((result) => Gun_txt = result),
"Gun_cn_txt": loadCnTextTable(`gun.json`).then((result) => Gun_cn_txt = result),
"Sangvis_txt": loadTextTable(`sangvis.json`).then((result) => Sangvis_txt = result),
"Sangvis_cn_txt": loadCnTextTable(`sangvis.json`).then((result) => Sangvis_cn_txt = result),
"Mission_txt": loadTextTable(`mission.json`).then((result) => Mission_txt = result),
"Mission_cn_txt": loadCnTextTable(`mission.json`).then((result) => Mission_cn_txt = result),
"Enemy_charater_type_txt": loadTextTable(`enemy_character_type.json`).then((result) => Enemy_charater_type_txt = result),
"Enemy_character_type_cn_txt": loadCnTextTable(`enemy_character_type.json`).then((result) => Enemy_charater_type_cn_txt = result),
"Ally_team_txt": loadTextTable(`ally_team.json`).then((result) => Ally_team_txt = result),
"Ally_team_cn_txt": loadCnTextTable(`ally_team.json`).then((result) => Ally_team_cn_txt = result),
"Team_ai_txt": loadTextTable(`team_ai.json`).then((result) => Team_ai_txt = result),
"Mission_targettrain_enemy_txt": loadTextTable(`mission_targettrain_enemy.json`).then((result) => Mission_targettrain_enemy_txt = result),
"Mission_targettrain_enemy_cn_txt": loadCnTextTable(`mission_targettrain_enemy.json`).then((result) => Mission_targettrain_enemy_cn_txt = result),
"Special_spot_config_txt": loadTextTable(`special_spot_config.json`).then((result) => Special_spot_config_txt = result),
"Special_spot_config_cn_txt": loadCnTextTable(`special_spot_config.json`).then((result) => Special_spot_config_cn_txt = result),
"Fairy_txt": loadTextTable(`fairy.json`).then((result) => Fairy_txt = result),
"Fairy_cn_txt": loadCnTextTable(`fairy.json`).then((result) => Fairy_cn_txt = result),
"Item_txt": loadTextTable(`item.json`).then((result) => Item_txt = result),
"Item_cn_txt": loadCnTextTable(`item.json`).then((result) => Item_cn_txt = result),
"Gift_item_txt": loadTextTable(`gift_item.json`).then((result) => Gift_item_txt = result),
"Gift_item_cn_txt": loadCnTextTable(`gift_item.json`).then((result) => Gift_item_cn_txt = result),
"Furniture_txt": loadTextTable(`furniture.json`).then((result) => Furniture_txt = result),
"Furniture_cn_txt": loadCnTextTable(`furniture.json`).then((result) => Furniture_cn_txt = result),
"Skin_txt": loadTextTable(`skin.json`).then((result) => Skin_txt = result),
"Skin_cn_txt": loadCnTextTable(`skin.json`).then((result) => Skin_cn_txt = result),
"Commander_uniform_txt": loadTextTable(`commander_uniform.json`).then((result) => Commander_uniform_txt = result),
"Commander_uniform_cn_txt": loadCnTextTable(`commander_uniform.json`).then((result) => Commander_uniform_cn_txt = result),
"Mission_win_type_config_txt": loadTextTable(`mission_win_type_config.json`).then((result) => Mission_win_type_config_txt = result),
"Mission_win_type_config_cn_txt": loadCnTextTable(`mission_win_type_config.json`).then((result) => Mission_win_type_config_cn_txt = result),
"INSTRUCTIONS": loadTextFile(`./text/${config.langCode}/instructions.html`).then((result) => INSTRUCTIONS = result),
"spot_images": Promise.all(spotPaths.map((path) => loadImageAsset(`spot/${config.langCode}/${path}`))),
};
let loadProgress = 0;
const loadTotal = Object.values(loaders).length;
const updateLoadProgress = () => $("#loadtips").html(`Loading/文件加载进度: ${loadProgress} / ${loadTotal}`);
updateLoadProgress();
data = await Object.entries(loaders).reduce(async (accumulatorPromise, [key, loader]) => {
(await accumulatorPromise)[key] = await loader;
loadProgress++;
updateLoadProgress();
return await accumulatorPromise;
}, Promise.resolve({}));
//console.log(data);
calculateSuspectedSpawns();
calculateTheaterLevelAdjustments();
calculateDefDrillTeamLevels();
trans();
$("#loadtips").hide();
$("#otherthing").html(INSTRUCTIONS);
missioncreat();
mapsetcreat();
spotsigncreat();
enemyselectcreat();
updatemap();
enemydisplay(221);
}
loadData();
/*-- 地图绘制事件的全局变量 --*/
var mapwidth = 1200, mapheight = 675;
var xmove = 0, ymove = 0;
var posa={}, posb={};
var coparameter = 1;
var dragging = false;
var scale = 1;
var mspot = [];
var lspot = [];
var dspot = [];
var spotinfo = [];
var theaicontent = null;
var eteamspot = [];
/*-- 下载 sdownload 重置 sredraw 隐藏 smaphide
敌人 smapenemy 建筑 smapbuild 颜色 smapcolor 标号 smapspotn 逻辑 smapenemyai
建筑表格 sbuildtable 传送表格 sporttable 点位标记 sspotsign 同组堆叠 senemypile --*/
var setmessage = {sdownload:0, sredraw:0, smaphide:0, smapenemy:1, smapbuild:1, smapcolor:1, smapspotn:1, smapenemyai:1, smapexpandroute:0, sbuildtable:1, sporttable:1, sspotsign:0, senemypile:0, srealce:0};
// This converts the game's campaign IDs (on Mission.json) to the campaign ID
// on the campaign select (UI_TEXT["campaign"]).
function convertGameCampaignToUiCampaign(gameCampaign) {
switch (gameCampaign) {
// Cube
case -1: return 3001;
// AW
case -2:
case -3:
case -4:
case -5:
case -23: return 3002;
// Cube+
case -6:
case -7: return 3006;
// Rabbit Hunt
case -8:
case -30: return 4008;
// -9 is unused (Neptunia? Valkyria Chronicles?)
// Deep Dive
case -10:
case -11:
case -12:
case -13:
case -29: return 3010;
// Honk
case -14:
case -15: return 4014;
// Singularity
case -16:
case -17:
case -18:
case -39: return 3016;
// DJ Max
case -19:
case -20:
case -21:
case -22: return 4019;
// -23 is AW+
// CT
case -24:
case -25:
case -26:
case -27:
case -28:
case -45: return 3024;
// -29 is DD+
// -30 is Rabbit Hunt rerun
// Isomer
case -31:
case -53: return 3031;
// VA-11 HALL-A
case -32: return 4032;
// SC
case -33:
case -55: return 3033;
// Halloween mini-event 1
case -34: return 5034;
// Christmas mini-event
case -35: return 5035;
// PL
case -36:
case -60: return 3036;
// Valentine's mini-event
case -37: return 5037;
// GSG
case -38: return 4038;
// -39 is Singularity+
// Summer mini-event
case -40: return 5040;
// DR
case -41:
case -63: return 3041;
// Halloween mini-event 2
case -42: return 5042;
// The Division
case -43: return 4043;
// MS
case -44:
case -65: return 3044;
// -45 is CT+
// Jashin-chan
case -46: return 4046;
// Summer mini-event 2
case -47: return 5047;
// PR
case -48:
case -67: return 3048;
// Xmas mini-event 2
case -49: return 5049;
// FP and FP Perma Ranking
case -51: return 3051;
case -40401: return 3051;
// Valentine's mini-event 2
case -50: return 5050;
// Summer mini-event 3
case -52: return 5052;
// -53 is Iso+
// LS
case -54: return 3054;
case -40402: return 3054;
// -55 is SC+
// E&S
case -56: return 3056;
// ZLSR
case -57: return 4057;
// Slow Shock and Slow Shock Perma Ranking
case -58: return 3058;
case -40403: return 3058;
// Maze Conjecture
case -59: return 5059;
// -60 is PL+
// Mind Voyage
case -61: return 5061;
// Reloading
case -62: return 5062;
// -63 is DR1+
// GitS
case -64: return 4064;
// -65 is MS2+
// Likely Blazar Backscatter?
// case -66: return 3066;
// -67 is PR+
// 错构之泉
case -68: return 3068;
// Cartesian Theatre
case -69: return 3069;
// Zero Charge
case -70: return 3070;
// Angular Gyrus
case -71: return 3071;
// Isolation Forest
case -72: return 3072;
// Arena Breakout Collab;
case -73: return 4073
// Convolutional Kernel and Convolutional Kernel Perma Ranking;
case -74: return 3074;
case -40404: return 3074;
// Roche Limit;
case -75: return 3075;
// Virtual Pair;
case -76: return 3076;
// Silent Sandbox
case -77: return 3077;
// Quantum Fluctuation / Zero Tide
case -78: return 3078;
// Steel Rain Salute
case -79: return 3079;
// Grey Zone, edited to split GZ1-4 separately
case -4041: return 2011; // GZ1
case -4042: return 2012; // GZ2
case -4043: return 2013; // GZ3
case -4044: return 2014; // GZ4
case -404: return 2016; // All other GZ (unused, tower)
// Tutorials
case -10000:
case -10001:
case -10002:
case -10003:
case -10004:
case -10005: return 2009;
// Mobile Armor Tutorials
case -10006: return 2016;
}
}
function getMissionOptionsForCampaign(campaign) {
let missionOptions = [];
/*-- 标靶 --*/
if(campaign == 2008){
var logarray = [{name: UI_TEXT["drone_sim"], filter:"0"}];
for (i in Mission_targettrain_enemy) {
var sign = 1;
for(j in logarray) if(Mission_targettrain_enemy[i].log_fitter_id == logarray[j].filter) sign = 0;
if(sign) logarray.push({name:Mission_targettrain_enemy[i].name, filter:Mission_targettrain_enemy[i].log_fitter_id});
}
for(i in logarray){
missionOptions.push({
value: logarray[i].filter,
innerHTML: logarray[i].name
});
}
}
else if(campaign > 6000 && campaign < 7000){
var area = [0, UI_TEXT["theater_basic"], UI_TEXT["theater_intermediate"], UI_TEXT["theater_advanced"], UI_TEXT["theater_core"]];
// TODO: place should probably be generated programmatically.
var place = [
null,
[0, UI_TEXT["theater_nonboss"], UI_TEXT["theater_nonboss"], UI_TEXT["theater_nonboss"], UI_TEXT["theater_boss"], UI_TEXT["theater_nonboss"], UI_TEXT["theater_nonboss"], UI_TEXT["theater_nonboss"], UI_TEXT["theater_boss"]],
[0, UI_TEXT["theater_nonboss"], UI_TEXT["theater_nonboss"], UI_TEXT["theater_nonboss"], UI_TEXT["theater_boss"], UI_TEXT["theater_nonboss"], UI_TEXT["theater_nonboss"], UI_TEXT["theater_nonboss"], UI_TEXT["theater_boss"]],
[0, UI_TEXT["theater_nonboss"], UI_TEXT["theater_nonboss"], UI_TEXT["theater_boss"], UI_TEXT["theater_nonboss"], UI_TEXT["theater_nonboss"], UI_TEXT["theater_boss"], UI_TEXT["theater_nonboss"], UI_TEXT["theater_boss"]],
[0, UI_TEXT["theater_nonboss"], UI_TEXT["theater_nonboss"], UI_TEXT["theater_boss"], UI_TEXT["theater_nonboss"], UI_TEXT["theater_nonboss"], UI_TEXT["theater_boss"], UI_TEXT["theater_nonboss"], UI_TEXT["theater_boss"]],
];
for(var i = 1; i < 5; i++){
for(var j = 1; j < 9; j++){
missionOptions.push({
value: (campaign - 6000)*100 + i*10 + j,
innerHTML: area[i] + " " + j + " " + place[i][j]
});
}
}
}
/*-- 主线关卡 --*/
else if(campaign >= 1000 && campaign < 2000){
for (i in Mission) {
if ((Mission[i].campaign == campaign - 1000) && (Mission[i].if_emergency != 2)) {
var innerHTML = "";
if (Mission[i].campaign == 14) {
innerHTML = "A-" + Mission[i].sub;
}
else {
innerHTML = String(campaign - 1000) + "-" + Mission[i].sub;
}
innerHTML += (Mission[i].if_emergency == 1) ? "E " : (Mission[i].if_emergency == 3) ? "N " : " ";
innerHTML += Mission[i].name.replace("//n", " ");
missionOptions.push({
value: Number(Mission[i].id),
innerHTML
});
}
}
}
/*-- 模拟作战 --*/
else if(Number(campaign) === 2009){
missionOptions = Mission.filter(({campaign}) => [-10000, -10001, -10002, -10003, -10004, -10005].indexOf(campaign) !== -1).map((mission) => ({
value: Number(mission.id),
innerHTML: mission.name.replace("//n", " ")
}));
}
else if(campaign == 2010) {
missionOptions = [{
value: "defdrill_wave_1",
innerHTML: UI_TEXT["defdrill_wave_1"],
}, {
value: "defdrill_wave_110",
innerHTML: UI_TEXT["defdrill_wave_110"],
}];
}
else if(Number(campaign) >= 2011 && Number(campaign) <= 2015){
gzMissionsToDiff = [];
Daily_mission_group.forEach(i => i.mission_group.split(",").forEach(j => gzMissionsToDiff[Number(j)] = i.difficulty));
var gzDiff = Number(campaign) == 2015 ? null : Number(campaign) - 2010;
for (i in Mission) {
if ((Number(Mission[i].campaign) === -404) && (gzDiff === (gzMissionsToDiff[Mission[i].id] ?? null))) {
missionOptions.push({
value: Number(Mission[i].id),
innerHTML: Mission[i].name.replace("//n", " ")
});
}
}
// Sort GZ stages by name rather than mission ID
missionOptions.sort((a, b) => {
if (a.innerHTML < b.innerHTML) return -1;
if (a.innerHTML > b.innerHTML) return 1;
return 0;
});
}
else if(Number(campaign) === 2016){
missionOptions = Mission.filter(({campaign}) => campaign === -10006).map((mission) => ({
value: Number(mission.id),
innerHTML: mission.name.replace("//n", " ")
}));
}
else if(campaign > 2000 && campaign < 3000){
for (i in Mission) {
if ((Mission[i].duplicate_type == campaign - 2000) && (Mission[i].if_emergency == 2)) {
missionOptions.push({
value: Number(Mission[i].id),
innerHTML: Mission[i].sub + " " + Mission[i].name.replace("//n", " ")
});
}
}
}
/*-- 有多个章节的活动 --*/
else if(campaign > 3000 && campaign < 5000){
for (i in Mission) {
/*-- 去除剧情关卡 --*/
//if(Mission[i].special_type == 8 || Mission[i].special_type == 9) continue;
var camp = Number(Mission[i].campaign);
/*-- 主线活动 --*/
if (campaign != convertGameCampaignToUiCampaign(camp)) {
continue;
}
var innerHTML = "";
/*-- 秃洞复刻的识别 并区别联动和主线的基础标号 --*/
if(campaign < 4000 && ((- Number(camp) - (campaign - 3000 - 1)) > 6)) innerHTML = "";
else if(campaign > 4000 && ((- Number(camp) - (campaign - 4000 - 1)) > 6)) innerHTML = "复刻 " + Mission[i].sub + " ";
else innerHTML = String(- Number(camp) - (campaign - ((campaign > 4000) ? 4000 : 3000) - 1)) + "-" + Mission[i].sub + " ";
/*-- 秃洞的识别 无尽模式 --*/
if (isRanking(Mission[i])) innerHTML += `[${UI_TEXT["endless_map"]}] `;
innerHTML += Mission[i].name.replace("//n", " ") + (Mission[i].special_type == 8 || Mission[i].special_type == 9 ? ' (STORY)' : '');
missionOptions.push({
value: Number(Mission[i].id),
innerHTML
});
}
}
/*-- 支线活动 --*/
else if(campaign > 5000 && campaign < 6000){
for (i in Mission) {
/*-- 去除剧情关卡 --*/
//if(Mission[i].special_type == 8 || Mission[i].special_type == 9) continue;
if ((Mission[i].campaign == - (campaign - 5000)) && (Mission[i].if_emergency != 2)) {
var innerHTML = Mission[i].sub + " ";
if (isRanking(Mission[i])) innerHTML += `[${UI_TEXT["endless_map"]}] `;
innerHTML += Mission[i].name.replace("//n", " ") + (Mission[i].special_type == 8 || Mission[i].special_type == 9 ? ' (STORY)' : '');
missionOptions.push({
value: Number(Mission[i].id),
innerHTML
});
}
}
}
else if(campaign == 9999) {
for (i in Mission) {
/*-- 去除剧情关卡 --*/
//if(Mission[i].special_type == 8 || Mission[i].special_type == 9) continue;
if(Mission[i].campaign >= 0 || convertGameCampaignToUiCampaign(Mission[i].campaign) != null) continue;
missionOptions.push({
value: Number(Mission[i].id),
innerHTML: Mission[i].campaign + "-" + Mission[i].sub + " " + (isRanking(Mission[i]) ? `[${UI_TEXT["endless_map"]}] ` : "") + Mission[i].name.replace("//n", " ") + (Mission[i].special_type == 8 || Mission[i].special_type == 9 ? ' (STORY)' : '')
});
}
}
return missionOptions;
}
// The better way to implement this would be to just make a dict from Gun_txt and gun.json.
const getGunName = (gun_id, excludeIdFromCnName) => {
const enName = Gun_txt[Gun.filter(gun => gun.id == gun_id)[0].name];
const cnName = Gun_cn_txt[Gun.filter(gun => gun.id == gun_id)[0].name];
if (enName) {
return enName
}
else if (excludeIdFromCnName && cnName) {
return cnName;
}
else {
return `[gun-${gun_id}]` + (cnName ? " " + cnName : "");
}
};
const getEquipName = (equip_id, excludeIdFromCnName) => {
const enName = Equip_txt[Equip.filter(equip => equip.id == equip_id)[0].name];
const cnName = Equip_cn_txt[Equip.filter(equip => equip.id == equip_id)[0].name];
if (enName) {
return enName
}
else if (excludeIdFromCnName && cnName) {
return cnName;
}
else {
return `[equip-${equip_id}]` + (cnName ? " " + cnName : "");
}
};
const getSangvisName = (sangvis_id, excludeIdFromCnName) => {
const enName = Sangvis_txt[Sangvis.filter(sangvis => sangvis.id == sangvis_id)[0].name];
const cnName = Sangvis_cn_txt[Sangvis.filter(sangvis => sangvis.id == sangvis_id)[0].name];
if (enName) {
return enName
}
else if (excludeIdFromCnName && cnName) {
return cnName;
}
else {
return `[sangvis-${sangvis_id}]` + (cnName ? " " + cnName : "");
}
};
const dollType = {
0: 'all',
1: 'hg',
2: 'smg',
3: 'rf',
4: 'ar',
5: 'mg',
6: 'sg',
};
const getAllyGuns = (gunInAllyIds) =>
gunInAllyIds.map(gunInAllyId => {
const gunInAllyRow = Gun_in_ally.find(row => row.id == gunInAllyId);
const gun = Gun_by_id[gunInAllyRow.gun_id];
const baseStats = gfcore.api.getDollStats(dollType[gun.type], {
hp: gun.ratio_life,
pow: gun.ratio_pow,
hit: gun.ratio_hit,
dodge: gun.ratio_dodge,
speed: gun.ratio_speed,
rate: gun.ratio_rate,
armorPiercing: gun.armor_piercing,
criticalPercent: gun.crit,
armor: gun.ratio_armor,
}, gun.eat_ratio, {
level: gunInAllyRow.level,
dummyLink: gunInAllyRow.number,
favor: 50,
growth: false
});
// The stats here might have rounding errors due to the game zealously applying ceil/floor to every result
// in a specific order.
const approxStats = {
life: gunInAllyRow.life,
pow: Math.floor(0.95 * (baseStats.pow + gunInAllyRow.pow)),
rate: baseStats.rate + gunInAllyRow.rate,
hit: Math.floor(0.95 * (baseStats.hit + gunInAllyRow.hit)),
dodge: Math.floor(0.95 * (baseStats.dodge + gunInAllyRow.dodge)),
};