-
Notifications
You must be signed in to change notification settings - Fork 3
/
alter.lua
932 lines (786 loc) · 24.7 KB
/
alter.lua
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
-- increase max cached surfaces
-- for surface dense uis
sdlext.surface_cache_max = 1024
local path = GetParentPath(...)
local vanillaCorporations = { "Corp_Grass", "Corp_Desert", "Corp_Snow", "Corp_Factory" }
local difficulties = { DIFF_EASY, DIFF_NORMAL, DIFF_HARD, DIFF_UNFAIR }
local islands = { "archive", "rst", "pinnacle", "detritus" }
local islandNames = { "Archive", "R.S.T.", "Pinnacle", "Detritus" }
local tileTypes = { TERRAIN_FOREST, TERRAIN_SAND, TERRAIN_ICE, TERRAIN_ACID }
local islandShifts = { Point(14,5), Point(16,15), Point(17,12), Point(18,15), Point(0,0) }
local corporations = { "archive", "rst", "pinnacle", "detritus" }
local ceos = { "dewey", "jessica", "zenith", "vikram" }
local missionLists = corporations
local bossLists = corporations
local tilesets = { "grass", "sand", "snow", "acid", "lava", "volcano", "vine", "hologram", "debris" }
local climate = { "", "", "", "", "Scorching", "Fiery", "Lush", "Holograpic", "debris" }
local rainChance = { 0, 0, 0, 0, 0, 0, 70, 30, 10 }
local crackChance = { 0, 0, 7, 0, 0, 0, 0, 0, 2 }
local environmentChance = { 0, 0, 0, 0, 0, 0, { [TERRAIN_FOREST] = 60 }, 0, 0 }
local mechList = {
"PunchMech", "TankMech", "ArtiMech",
"JetMech", "RocketMech", "PulseMech",
"LaserMech", "ChargeMech", "ScienceMech",
"ElectricMech", "WallMech", "RockartMech",
"JudoMech", "DStrikeMech", "GravMech",
"FlameMech", "IgniteMech", "TeleMech",
"GuardMech", "MirrorMech", "IceMech",
"LeapMech", "UnstableTank", "NanoMech",
}
local UNIT_EXCLUSION = {
"Pawn",
"PawnTable",
"SlugBoss",
"SlugEgg1",
"Slug1",
"Slug2",
"Jelly_Necro1",
}
local WEAPON_EXCLUSION = {
}
local MISSION_EXCLUSION = {
"Mission",
"Mission_Test",
"Mission_Auto",
"Mission_Battle",
"Mission_Infinite",
"Mission_Tutorial",
"Mission_Critical",
"Mission_MineBase",
"Mission_Final",
"Mission_Final_Cave",
"Mission_Boss",
"Mission_Sandstorm",
"Mission_SlugBoss",
"Mission_LeaperBoss",
"Mission_DiggerBoss",
}
local STRUCTURE_EXCLUSION = {
}
local function updateMissingNames()
Jelly_Armor1.Name = "Shell Psion"
Jelly_Health1.Name = "Soldier Psion"
Jelly_Regen1.Name = "Blood Psion"
Jelly_Explode1.Name = "Blast Psion"
Jelly_Lava1.Name = "Psion Tyrant"
Jelly_Spider1.Name = "Arachnid Psion"
Jelly_Fire1.Name = "Smoldering Psion"
Jelly_Boost1.Name = "Raging Psion"
Shaman1.Name = "Plasmodia"
ShamanBoss.Name = "Plasmodia Leader"
Totem1.Name = "Spore"
BlobberBoss.Name = "Blobber Leader"
Burnbug1.Name = "Gastropod"
BurnbugBoss.Name = "Gastropod Leader"
Dung1.Name = "Tumblebug"
DungBoss.Name = "Tumblebug Leader"
Mission_BeetleBoss.Name = "Beetle Leader"
Mission_BotBoss.Name = "Bot Leader"
Mission_FireflyBoss.Name = "Firefly Leader"
Mission_BlobBoss.Name = "Large Goo"
Mission_HornetBoss.Name = "Hornet Leader"
Mission_JellyBoss.Name = "Psion Abomination"
Mission_ScorpionBoss.Name = "Scorpion Leader"
Mission_SpiderBoss.Name = "Spider Leader"
Mission_BlobberBoss.Name = "Blobber Leader"
Mission_BouncerBoss.Name = "Bouncer Leader"
Mission_BurnbugBoss.Name = "Gastropod Leader"
Mission_CentipedeBoss.Name = "Centipede Leader"
Mission_CrabBoss.Name = "Crab Leader"
Mission_DungBoss.Name = "Tumblebug Leader"
Mission_MosquitoBoss.Name = "Mosquito Leader"
Mission_ScarabBoss.Name = "Scarab Leader"
Mission_ShamanBoss.Name = "Plasmodia Leader"
Mission_StarfishBoss.Name = "Starfish Leader"
Mission_Acid.Name = "A.C.I.D."
Mission_AcidStorm.Name = "A.C.I.D. Storm"
Mission_AcidTank.Name = "A.C.I.D. Tank"
Mission_Airstrike.Name = "Airstrike"
Mission_Armored_Train.Name = "Armored Train"
Mission_Barrels.Name = "A.C.I.D. Vats"
Mission_Belt.Name = "Conveyor Belt"
Mission_BeltRandom.Name = "Conveyor Belt Random"
Mission_Bomb.Name = "Prototype Renfield Bomb"
Mission_BoomBots.Name = "Boom Bots"
Mission_BotDefense.Name = "Bot Defense"
Mission_Cataclysm.Name = "Cataclysm"
Mission_Civilians.Name = "V.I.P."
Mission_Crack.Name = "Seismic Activity"
Mission_Dam.Name = "Dam"
Mission_Disposal.Name = "Disposal Unit"
Mission_Factory.Name = "Robot Factory"
Mission_Fence.Name = "Barrier"
Mission_Filler.Name = "Earth Mover"
Mission_Force.Name = "Destruction"
Mission_ForestFire.Name = "Forest Fire"
Mission_FreezeBldg.Name = "Freeze Buildings"
Mission_FreezeBots.Name = "Freeze Tank"
Mission_FreezeMines.Name = "Cryo-Mines"
Mission_Hacking.Name = "Hacking"
Mission_Laser.Name = "Laser"
Mission_Lightning.Name = "Lightning"
Mission_Mines.Name = "Mines"
Mission_Missiles.Name = "Detritus Contraption"
Mission_NanoStorm.Name = "Nanostorm"
Mission_Piston.Name = "Trash Compactor"
Mission_Power.Name = "Power"
Mission_Reactivation.Name = "Thawing Enemies"
Mission_Repair.Name = "Repair Platforms"
Mission_Respawn.Name = "Respawning Enemies"
Mission_Shields.Name = "Shield Generator"
Mission_SnowBattle.Name = "Sentient Weapons"
Mission_SnowStorm.Name = "Snowstorm"
Mission_Solar.Name = "Solar Farms"
Mission_Stasis.Name = "Freese Bots"
Mission_Survive.Name = "Survive"
Mission_Tanks.Name = "Archive Tanks"
Mission_Teleporter.Name = "Teleporters"
Mission_Terraform.Name = "Terraformer"
Mission_Terratide.Name = "Sandstorm"
Mission_Tides.Name = "Tidal Waves"
Mission_Train.Name = "Train"
Mission_Trapped.Name = "Evacuated Buildings"
Mission_Volatile.Name = "Volatile Vek"
Mission_Wind.Name = "Windstorm"
Str_Bar.Name = "Old Earth Bar"
Str_Battery.Name = "Emergency Batteries"
Str_Clinic.Name = "Clinic"
Str_Combat.Name = "Airfield"
Str_Nimbus.Name = "Power Generator"
Str_Power.Name = "Coal Plant"
Str_Research.Name = "Defense Lab"
Str_Robotics.Name = "Robotics Lab"
Str_Shield.Name = "Shield Generator"
Str_Tower.Name = "Corporate Tower"
end
local function upper_first(str)
return str:gsub("^.", string.upper)
end
local function registerWeapon(weapon_id)
local base = _G[weapon_id]
if false
or list_contains(WEAPON_EXCLUSION, weapon_id)
or base == nil
or base.ExcludeFromEasyEdit == true
then
return
end
local weapon = easyEdit.weapons:get(weapon_id)
weapon = weapon or easyEdit.weapons:add(weapon_id)
weapon:copy(base)
weapon.__Id = weapon_id
weapon.Name = GetText(weapon_id.."_Name") or base.Name
weapon.Description = GetText(weapon_id.."_Description") or base.Description
end
local function registerWeapons()
for weapon_id, _ in pairs(modApi.weaponDeck) do
registerWeapon(weapon_id)
end
end
local units = easyEdit.units
local unitImages = easyEdit.unitImage
local isValidUnit = units._class.isValid
local function registerUnit(unit_id)
local base = _G[unit_id]
if false
or list_contains(UNIT_EXCLUSION, unit_id)
or base == nil
or base.ExcludeFromEasyEdit == true
then
return
end
local unit = units:get(unit_id)
if base.Name == "Unnamed Pawn" or base.Name == "PawnTable" then
base.Name = GetText(unit_id)
end
if isValidUnit(base) then
unit = unit or units:add(unit_id, base)
units:addSoundBase(unit)
end
unitImageId = base.Image
unitImage = unitImages:get(unitImageId)
if unitImage == nil then
unitImage = unitImages:add(unitImageId)
unitImage.Name = unitImageId
unitImage.Image = base.Image
unitImage.ImageOffset = base.ImageOffset
end
for _, weaponId in ipairs(base.SkillList) do
registerWeapon(weaponId)
end
end
local function registerUnits()
for unit_id, unit in pairs(_G) do
local isUnit = true
and type(unit) == 'table'
and type(unit.Name) == 'string'
and type(unit.Class) == 'string'
and type(unit.Image) == 'string'
and type(unit.ImageOffset) == 'number'
and type(unit.Health) == 'number'
and type(unit.MoveSpeed) == 'number'
and type(unit.SkillList) == 'table'
if isUnit then
registerUnit(unit_id)
end
end
end
local function appendMissionImage(mission_id, subpath)
local appendLoc = string.format("img/strategy/%s%s.png", subpath, mission_id)
if modApi.resource:file_exists(appendLoc) then
return
end
local filename = string.format("%simg/%s%s.png", path, subpath, mission_id)
if not modApi:fileExists(filename) then
filename = string.format("%simg/%sIcon_Missing.png", path, subpath)
end
modApi:appendAsset(appendLoc, filename)
end
local function appendMissionSmallImage(mission_id)
end
local function registerMission(mission_id)
local base = _G[mission_id]
if false
or list_contains(MISSION_EXCLUSION, mission_id)
or base == nil
or base.ExcludeFromEasyEdit == true
then
return
end
local mission = easyEdit.missions:get(mission_id)
mission = mission or easyEdit.missions:add(mission_id)
mission:copy(base)
appendMissionImage(mission_id, "mission/")
appendMissionImage(mission_id, "mission/small/")
end
local function registerMissions()
Mission_Windmill = Mission_Critical:new{
Name = "Wind Farms",
Image = "str_wind1",
FlavorBase = "Mission_Wind",
Objectives = PowerObjective("Mission_Wind_Objective", 2)
}
for i, _ in ipairs(corporations) do
local corp_id = vanillaCorporations[i]
local base = _G[corp_id]
local function addMissions(missionTable)
for _, mission_id in ipairs(missionTable) do
registerMission(mission_id)
end
end
addMissions(base.Missions_High)
addMissions(base.Missions_Low)
addMissions(base.Bosses)
addMissions(base.UniqueBosses)
end
for mission_id, mission in pairs(_G) do
local isMission = true
and type(mission) == 'table'
and type(mission.Name) == 'string'
and type(mission.MapList) == 'table'
and type(mission.MapTags) ~= 'nil'
and type(mission.MapVetoes) == 'table'
if isMission then
registerMission(mission_id)
end
end
end
local function registerStructure(structure_id)
local base = _G[structure_id]
if false
or list_contains(STRUCTURE_EXCLUSION, structure_id)
or base == nil
or base.ExcludeFromEasyEdit == true
then
return
end
local structure = easyEdit.structures:get(structure_id)
structure = structure or easyEdit.structures:add(structure_id)
structure.Name = GetText(structure_id.."_Name")
structure:copy(base)
end
local function registerStructures()
for i, _ in ipairs(corporations) do
local corp_id = vanillaCorporations[i]
local base = _G[corp_id]
local function addStructures(structureTable)
for _, structure_id in ipairs(structureTable) do
registerStructure(structure_id)
end
end
addStructures(base.PowAssets)
addStructures(base.TechAssets)
addStructures(base.RepAssets)
end
for structure_id, structure in pairs(_G) do
local isStructure = true
and type(structure) == 'table'
and type(structure.Image) == 'string'
and type(structure.Reward) == 'number'
and structure.Reward >= 0
and structure.Reward <= 2
and structure_id:find("^Mission") == nil
and structure.nonStructure ~= true
if isStructure then
registerStructure(structure_id)
end
end
end
local function registerIslands()
for i, id in ipairs(islands) do
local island = easyEdit.island:add(id)
local n = i-1
island:copyAssets({_id = tostring(n)})
island.name = islandNames[i]
island.shift = islandShifts[i]
island.magic = Island_Magic[i]
island.regionData = {}
island.network = {}
if i <= 4 then
for k = 0, 7 do
table.insert(island.regionData, Region_Data[string.format("island_%s_%s", n, k)])
end
for k = 0, 7 do
table.insert(island.network, _G["Network_Island_".. n][tostring(k)])
end
end
end
end
local function registerCorporations()
for i, id in ipairs(corporations) do
local corp = easyEdit.corporation:add(id)
local corp_id = vanillaCorporations[i]
local base = _G[corp_id]
corp:copy(base)
base.OldUniqueBosses = base.UniqueBosses
base.UniqueBosses = {}
corp.Name = GetText(corp_id.."_Name")
corp.Description = GetText(corp_id.."_Description")
end
end
local function registerCEOs()
for i, id in ipairs(ceos) do
local ceo = easyEdit.ceo:add(id)
local corp_id = vanillaCorporations[i]
local base = _G[corp_id]
ceo:copyAssets({_id = "ceo_"..corporations[i]})
ceo:copy(base)
ceo.CEO_Name = GetText(corp_id.."_CEO_Name")
end
end
local function registerTilesets()
modApi:appendAsset(
"img/strategy/corp/lava_env.png",
path.."img/env/lava_env.png")
modApi:appendAsset(
"img/strategy/corp/volcano_env.png",
path.."img/env/volcano_env.png")
modApi:appendAsset(
"img/strategy/corp/vine_env.png",
path.."img/env/vine_env.png")
modApi:appendAsset(
"img/strategy/corp/hologram_env.png",
path.."img/env/hologram_env.png")
modApi:appendAsset(
"img/strategy/corp/debris_env.png",
path.."img/env/debris_env.png")
modApi:copyAsset(
"img/combat/tiles_grass/building_sheet_vines.png",
"img/combat/tiles_vine/building_sheet.png")
modApi:copyAsset(
"img/advanced/combat/tiles_debris/building_1_tile.png",
"img/combat/tiles_debris/building_1_tile.png")
modApi:copyAsset(
"img/advanced/combat/tiles_debris/building_2_tile.png",
"img/combat/tiles_debris/building_2_tile.png")
modApi:copyAsset(
"img/advanced/combat/tiles_debris/building_3_tile.png",
"img/combat/tiles_debris/building_3_tile.png")
modApi:copyAsset(
"img/advanced/combat/tiles_debris/building_collapse.png",
"img/combat/tiles_debris/building_collapse.png")
modApi:copyAsset(
"img/advanced/combat/tiles_debris/building_sheet.png",
"img/combat/tiles_debris/building_sheet.png")
modApi:copyAsset(
"img/advanced/combat/tiles_debris/ground_0.png",
"img/combat/tiles_debris/ground_0.png")
modApi:copyAsset(
"img/advanced/combat/tiles_debris/ground_1.png",
"img/combat/tiles_debris/ground_1.png")
modApi:copyAsset(
"img/advanced/combat/tiles_debris/ground_rail.png",
"img/combat/tiles_debris/ground_rail.png")
modApi:copyAsset(
"img/advanced/combat/tiles_debris/mountain_0.png",
"img/combat/tiles_debris/mountain_0.png")
modApi:copyAsset(
"img/advanced/combat/tiles_debris/mountain_0_broken.png",
"img/combat/tiles_debris/mountain_0_broken.png")
modApi:copyAsset(
"img/advanced/combat/tiles_debris/mountain_explode.png",
"img/combat/tiles_debris/mountain_explode.png")
-- temporarily override GetRealDifficulty
-- while extracting environmentChance for
-- vanilla tilesets
local oldGetDifficulty = GetRealDifficulty
local difficulty
function GetRealDifficulty()
return difficulty
end
for i, id in ipairs(tilesets) do
local corp_id = vanillaCorporations[i]
if corp_id then
local tileset = easyEdit.tileset:add(id)
tileset.name = upper_first(id)
-- fill in missing conveyor assets
tileset:copyAssets({_id = "acid"}, false)
tileset.climate = GetText(corp_id.."_Environment")
tileset.rainChance = getRainChance(id)
tileset.crackChance = getCrackChance(id)
tileset.environmentChance = {}
for _, diff in ipairs(difficulties) do
difficulty = diff
tileset.environmentChance[diff] = {}
for _, tileType in ipairs(tileTypes) do
tileset.environmentChance[diff][tileType] = getEnvironmentChance(id, tileType)
end
end
else
local tileset = easyEdit.tileset:add(id)
tileset.name = upper_first(id)
-- set missing locations
tileset:copyAssets(tileset)
-- fill in missing assets
tileset:copyAssets({_id = "grass"}, false)
tileset:copyAssets({_id = "acid"}, false)
tileset.climate = climate[i]
tileset.rainChance = rainChance[i]
tileset.crackChance = crackChance[i]
tileset.environmentChance = environmentChance[i]
end
end
GetRealDifficulty = oldGetDifficulty
function getRainChance(sectorType)
local tileset = easyEdit.tileset:get(sectorType)
local noDataFound = not tileset or not tileset.getRainChance
if noDataFound then
return 0
end
return tileset:getRainChance()
end
function getCrackChance(sectorType)
local tileset = easyEdit.tileset:get(sectorType)
local noDataFound = not tileset or not tileset.getCrackChance
if noDataFound then
return 0
end
return tileset:getCrackChance()
end
function getEnvironmentChance(sectorType, tileType)
local tileset = easyEdit.tileset:get(sectorType)
local noDataFound = not tileset or not tileset.getEnvironmentChance
if noDataFound then
return 0
end
return tileset:getEnvironmentChance(tileType, GetDifficulty())
end
modApi.events.onTilesetChanged:subscribe(function(newTileset, oldTileset)
local oldTileset = easyEdit.tileset:get(oldTileset)
local newTileset = easyEdit.tileset:get(newTileset)
oldTileset:onDisabled()
newTileset:onEnabled()
end)
end
function pickEnemies(categories, enemies, islandNumber, timesPicked)
timesPicked = timesPicked or {}
local result = {}
local choices = {}
local excluded = {}
local function isUnlocked(unit)
local lock = IslandLocks[unit] or 0
return islandNumber == nil or islandNumber >= lock or Game:IsIslandUnlocked(lock-1)
end
local function addExclusions(unit)
for i, list in ipairs(exclusiveElements) do
if list_contains(list, unit) then
for i, excludedId in ipairs(list) do
excluded[excludedId] = true
end
end
end
--Flying Enemies
if FlyingEnemies[unit] then --If flying exclude all flying
for excludedId, _ in pairs(FlyingEnemies) do
excluded[excludedId] = true
end
end
end
local function getEnemyChoices(category)
if type(category) ~= 'string' then
return {}
end
if choices[category] and #choices[category] > 0 then
return choices[category]
end
local leastPicked = INT_MAX
choices[category] = {}
enemies[category] = enemies[category] or {}
for _, enemy in ipairs(enemies[category]) do
if isUnlocked(enemy) and not excluded[enemy] then
table.insert(choices[category], enemy)
end
end
shuffle_list(choices[category])
table.sort(choices[category], function(a,b)
return (timesPicked[a] or 0) > (timesPicked[b] or 0)
end)
return choices[category]
end
for _, category in ipairs(categories) do
local enemyChoices = getEnemyChoices(category)
local choice = "Scorpion"
for i = #enemyChoices, 1, -1 do
if not excluded[enemyChoices[i]] then
choice = enemyChoices[i]
table.remove(enemyChoices, i)
break
end
end
timesPicked[choice] = (timesPicked[choice] or 0) + 1
addExclusions(choice)
table.insert(result, choice)
end
Assert.Equals(6, #result, "Result")
return result
end
local function getNoNewBosses()
return {}
end
local function registerEnemyLists()
for i, id in ipairs(corporations) do
local enemyList = easyEdit.enemyList:add(id)
local corp_id = vanillaCorporations[i]
local base = _G[corp_id]
enemyList.name = base.Bark_Name
enemyList.enemies = getFinalEnemyLists()
end
for i, corp_id in ipairs(vanillaCorporations) do
local categories = easyEdit.enemyList:get("archive").categories
local corp = _G[corp_id]
corp.Enemies = getFinalEnemyLists()
corp.EnemyCategories = copy_table(categories)
end
function Mission:NextRobot(name_only)
local islandSlot = easyEdit:getCurrentIslandSlot()
local bots = GAME.Bots[islandSlot]
if bots == nil or #bots == 0 then
bots = EnemyLists.Bots
end
return self:NextPawn(bots, name_only or false)
end
local oldStartNewGame = startNewGame
function startNewGame()
-- Give Easy Edit full control of which bosses are added
local getNewBossesVanilla = getNewBosses
getNewBosses = getNoNewBosses
oldStartNewGame()
GAME.Bots = {}
getNewBosses = getNewBossesVanilla
local timesPicked = {}
for i, corp_id in ipairs(vanillaCorporations) do
local corp = _G[corp_id]
local enemies = corp.Enemies
local categories = corp.EnemyCategories
GAME.Enemies[i] = pickEnemies(categories, enemies, i, timesPicked)
GAME.Bots[i] = copy_table(enemies.Bots)
end
end
end
local function registerBossLists()
for i, id in ipairs(corporations) do
local bossList = easyEdit.bossList:add(id)
local corp_id = vanillaCorporations[i]
local base = _G[corp_id]
bossList:copy(base)
for _, boss in ipairs(getNewBosses()) do
bossList:addBoss(boss)
end
bossList.name = base.Bark_Name
end
end
local function registerMissionLists()
for i, id in ipairs(corporations) do
local missionList = easyEdit.missionList:add(id)
local corp_id = vanillaCorporations[i]
local base = _G[corp_id]
missionList:copy(base)
missionList.name = base.Bark_Name
end
end
local function registerStructureLists()
for i, id in ipairs(corporations) do
local corp_id = vanillaCorporations[i]
local base = _G[corp_id]
local structureList = easyEdit.structureList:add(id)
structureList:copy(Corp_Default)
structureList.name = base.Bark_Name
end
end
local function registerIslandComposites()
for i = 1, 4 do
local id = islands[i]
local islandComposite = easyEdit.islandComposite:add(id)
islandComposite.name = islandNames[i]
islandComposite.island = islands[i]
islandComposite.corporation = corporations[i]
islandComposite.ceo = ceos[i]
islandComposite.tileset = tilesets[i]
islandComposite.missionList = missionLists[i]
islandComposite.bossList = bossLists[i]
islandComposite.enemyList = corporations[i]
islandComposite.structureList = corporations[i]
end
end
local function registerIcons()
local icons = {
"delete",
"reset",
"delete_small",
"reset_small",
"warning_small",
}
for _, name in ipairs(icons) do
local appendLoc = string.format("img/ui/easyEdit/%s.png", name)
local filename = string.format("%simg/icons/%s.png", path, name)
modApi:appendAsset(appendLoc, filename)
end
end
local function registerFinalEnemyList()
local enemyList = easyEdit.enemyList:add("finale")
enemyList.name = "Finale"
enemyList.categories = { "Enemies" }
enemyList.enemies = { Enemies = {} }
enemyList:addEnemy("Firefly", "Enemies")
enemyList:addEnemy("Hornet", "Enemies")
enemyList:addEnemy("Scarab", "Enemies")
enemyList:addEnemy("Scorpion", "Enemies")
enemyList:addEnemy("Crab", "Enemies")
enemyList:addEnemy("Beetle", "Enemies")
enemyList:addEnemy("Digger", "Enemies")
enemyList:addEnemy("Blobber", "Enemies")
enemyList:addEnemy("Jelly_Lava", "Enemies") -- jelly x3
enemyList:addEnemy("Jelly_Lava", "Enemies")
enemyList:addEnemy("Jelly_Lava", "Enemies")
local oldGetSpawnList = GameObject.GetSpawnList
function GameObject:GetSpawnList(island, ...)
local result = oldGetSpawnList(self, island, ...)
if island == 5 then -- final island!
local enemyList = easyEdit.enemyList:get("finale")
result = copy_table(enemyList.enemies.Enemies)
end
return result
end
end
local function registerFinalBossList()
local bossList_phase1 = easyEdit.bossList:add("finale1")
local bossList_phase2 = easyEdit.bossList:add("finale2")
bossList_phase1.name = "Finale I"
bossList_phase2.name = "Finale II"
bossList_phase1:addBoss("Mission_ScorpionBoss")
bossList_phase1:addBoss("Mission_FireflyBoss")
bossList_phase1:addBoss("Mission_HornetBoss")
bossList_phase2:addBoss("Mission_BeetleBoss")
bossList_phase2:addBoss("Mission_FireflyBoss")
bossList_phase2:addBoss("Mission_HornetBoss")
end
local function markRegisteredAsVanilla()
local function markAsVanilla(indexedList)
for _, indexedEntry in pairs(indexedList._children) do
indexedEntry._vanilla = true
end
end
markAsVanilla(easyEdit.units)
markAsVanilla(easyEdit.unitImage)
markAsVanilla(easyEdit.weapons)
markAsVanilla(easyEdit.missions)
markAsVanilla(easyEdit.structures)
markAsVanilla(easyEdit.corporation)
markAsVanilla(easyEdit.tileset)
markAsVanilla(easyEdit.structureList)
markAsVanilla(easyEdit.enemyList)
markAsVanilla(easyEdit.bossList)
markAsVanilla(easyEdit.missionList)
markAsVanilla(easyEdit.island)
markAsVanilla(easyEdit.islandComposite)
end
local function markRegisteredAsMod(modId)
local function markAsMod(indexedList)
for _, indexedEntry in pairs(indexedList._children) do
if not indexedEntry:isVanilla() and indexedEntry.mod == nil then
indexedEntry.mod = modId
end
end
end
markAsMod(easyEdit.units)
markAsMod(easyEdit.unitImage)
markAsMod(easyEdit.weapons)
markAsMod(easyEdit.missions)
markAsMod(easyEdit.structures)
markAsMod(easyEdit.corporation)
markAsMod(easyEdit.tileset)
markAsMod(easyEdit.structureList)
markAsMod(easyEdit.enemyList)
markAsMod(easyEdit.bossList)
markAsMod(easyEdit.missionList)
markAsMod(easyEdit.island)
markAsMod(easyEdit.islandComposite)
end
local function lockEverything()
local function lockChildren(indexedList)
for _, indexedEntry in pairs(indexedList._children) do
indexedEntry:lock()
end
end
lockChildren(easyEdit.ceo)
lockChildren(easyEdit.corporation)
lockChildren(easyEdit.units)
lockChildren(easyEdit.tileset)
lockChildren(easyEdit.island)
lockChildren(easyEdit.islandComposite)
lockChildren(easyEdit.structureList)
lockChildren(easyEdit.enemyList)
lockChildren(easyEdit.bossList)
lockChildren(easyEdit.missionList)
end
local function onModInitialized(modId)
registerUnits()
registerWeapons()
registerMissions()
registerStructures()
markRegisteredAsMod(modId)
end
local function onModsInitialized()
lockEverything()
easyEdit.savedata:init()
end
updateMissingNames()
registerUnits()
registerWeapons()
registerMissions()
registerStructures()
registerIslands()
registerCorporations()
registerCEOs()
registerTilesets()
registerEnemyLists()
registerBossLists()
registerMissionLists()
registerStructureLists()
registerIslandComposites()
registerIcons()
registerFinalEnemyList()
registerFinalBossList()
markRegisteredAsVanilla()
modApi.events.onModInitialized:subscribe(onModInitialized)
modApi.events.onModsInitialized:subscribe(onModsInitialized)