-
Notifications
You must be signed in to change notification settings - Fork 6
/
scenario_53_escape.lua
3899 lines (3895 loc) · 177 KB
/
scenario_53_escape.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
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
-- Name: Escape
-- Description: Escape imprisonment and return home.
--- Mission consists of one ship with a full crew. Engineer and Science will be busy.
--- Version 5 switches to the max health system, preserves some sensor data in the final phase
--- and uses the place station scenario utility.
--- USN Discord: https://discord.gg/PntGG3a where you can join a game online. There's one every weekend. All experience levels are welcome.
-- Type: Replayable Mission
-- Author: Xansta
-- Setting[Enemies]: Configures the amount/strength of enemies spawned in the scenario.
-- Enemies[Easy]: Weaker/fewer enemies.
-- Enemies[Normal|Default]: Normal enemies.
-- Enemies[Hard]: Stronger/more enemies.
-- Setting[Murphy]: Configures the perversity of the universe according to Murphy's law
-- Murphy[Easy]: Random factors are more in your favor
-- Murphy[Normal|Default]: Random factors are normal
-- Murphy[Hard]: Random factors are more against you
require("utils.lua")
require("place_station_scenario_utility.lua")
-------------------------------
-- Initialization routines --
-------------------------------
function init()
scenario_version = "5.0.2"
print(string.format(" ----- Scenario: Escape ----- Version %s -----",scenario_version))
print(_VERSION)
wfv = "nowhere" --wolf fence value - used for debugging
setSettings()
addRepulseToDatabase()
missile_types = {'Homing', 'Nuke', 'Mine', 'EMP', 'HVLI'}
--Ship Template Name List
stnl = {"MT52 Hornet","MU52 Hornet","Adder MK5","Adder MK4","WX-Lindworm","Adder MK6","Phobos T3","Phobos M3","Piranha F8","Piranha F12","Ranus U","Nirvana R5A","Stalker Q7","Stalker R7","Atlantis X23","Starhammer II","Odin","Fighter","Cruiser","Missile Cruiser","Strikeship","Adv. Striker","Dreadnought","Battlestation","Blockade Runner","Ktlitan Fighter","Ktlitan Breaker","Ktlitan Worker","Ktlitan Drone","Ktlitan Feeder","Ktlitan Scout","Ktlitan Destroyer","Storm"}
--Ship Template Score List
stsl = {5 ,5 ,7 ,6 ,7 ,8 ,15 ,16 ,15 ,15 ,25 ,20 ,25 ,25 ,50 ,70 ,250 ,6 ,18 ,14 ,30 ,27 ,80 ,100 ,65 ,6 ,45 ,40 ,4 ,48 ,8 ,50 ,22}
-- square grid deployment
fleetPosDelta1x = {0,1,0,-1, 0,1,-1, 1,-1,2,0,-2, 0,2,-2, 2,-2,2, 2,-2,-2,1,-1, 1,-1}
fleetPosDelta1y = {0,0,1, 0,-1,1,-1,-1, 1,0,2, 0,-2,2,-2,-2, 2,1,-1, 1,-1,2, 2,-2,-2}
-- rough hexagonal deployment
fleetPosDelta2x = {0,2,-2,1,-1, 1, 1,4,-4,0, 0,2,-2,-2, 2,3,-3, 3,-3,6,-6,1,-1, 1,-1,3,-3, 3,-3,4,-4, 4,-4,5,-5, 5,-5}
fleetPosDelta2y = {0,0, 0,1, 1,-1,-1,0, 0,2,-2,2,-2, 2,-2,1,-1,-1, 1,0, 0,3, 3,-3,-3,3,-3,-3, 3,2,-2,-2, 2,1,-1,-1, 1}
commonGoods = {"food","medicine","nickel","platinum","gold","dilithium","tritanium","luxury","cobalt","impulse","warp","shield","tractor","repulsor","beam","optic","robotic","filament","transporter","sensor","communication","autodoc","lifter","android","nanites","software","circuit","battery"}
componentGoods = {"impulse","warp","shield","tractor","repulsor","beam","optic","robotic","filament","transporter","sensor","communication","autodoc","lifter","android","nanites","software","circuit","battery"}
mineralGoods = {"nickel","platinum","gold","dilithium","tritanium","cobalt"}
diagnostic = false
GMDiagnosticOn = _("buttonGM", "Turn On Diagnostic")
addGMFunction(GMDiagnosticOn,turnOnDiagnostic)
independentTransportSpawnDelay = 20
independentTransportList = {}
kraylorTransportSpawnDelay = 40
kraylorTransportList = {}
kraylorPatrolSpawnDelay = 60
kraylorPatrolList = {}
kGroup = 0
kraylorPatrolGroupList = {}
goods = {} --overall tracking of goods
stationList = {} --friendly and neutral stations
friendlyStationList = {}
enemyStationList = {}
tradeFood = {} --stations that will trade food for other goods
tradeLuxury = {} --stations that will trade luxury for other goods
tradeMedicine = {} --stations that will trade medicine for other goods
totalStations = 0
friendlyStations = 0
neutralStations = 0
brigStation = SpaceStation():setTemplate("Small Station"):setFaction("Kraylor"):setCallSign("DS23"):setPosition(912787, 148301)
table.insert(enemyStationList,brigStation)
buildNearbyStations()
--Player ship name lists to supplant standard randomized call sign generation
playerShipNamesForMP52Hornet = {"Dragonfly","Scarab","Mantis","Yellow Jacket","Jimminy","Flik","Thorny","Buzz"}
playerShipNamesForPiranha = {"Razor","Biter","Ripper","Voracious","Carnivorous","Characid","Vulture","Predator"}
playerShipNamesForFlaviaPFalcon = {"Ladyhawke","Hunter","Seeker","Gyrefalcon","Kestrel","Magpie","Bandit","Buccaneer"}
playerShipNamesForPhobosM3P = {"Blinder","Shadow","Distortion","Diemos","Ganymede","Castillo","Thebe","Retrograde"}
playerShipNamesForAtlantis = {"Excaliber","Thrasher","Punisher","Vorpal","Protang","Drummond","Parchim","Coronado"}
playerShipNamesForCruiser = {"Excelsior","Velociraptor","Thunder","Kona","Encounter","Perth","Aspern","Panther"}
playerShipNamesForMissileCruiser = {"Projectus","Hurlmeister","Flinger","Ovod","Amatola","Nakhimov","Antigone"}
playerShipNamesForFighter = {"Buzzer","Flitter","Zippiticus","Hopper","Molt","Stinger","Stripe"}
playerShipNamesForBenedict = {"Elizabeth","Ford","Vikramaditya","Liaoning","Avenger","Naruebet","Washington","Lincoln","Garibaldi","Eisenhower"}
playerShipNamesForKiriya = {"Cavour","Reagan","Gaulle","Paulo","Truman","Stennis","Kuznetsov","Roosevelt","Vinson","Old Salt"}
playerShipNamesForStriker = {"Sparrow","Sizzle","Squawk","Crow","Phoenix","Snowbird","Hawk"}
playerShipNamesForLindworm = {"Seagull","Catapult","Blowhard","Flapper","Nixie","Pixie","Tinkerbell"}
playerShipNamesForRepulse = {"Fiddler","Brinks","Loomis","Mowag","Patria","Pandur","Terrex","Komatsu","Eitan"}
playerShipNamesForEnder = {"Mongo","Godzilla","Leviathan","Kraken","Jupiter","Saturn"}
playerShipNamesForNautilus = {"October", "Abdiel", "Manxman", "Newcon", "Nusret", "Pluton", "Amiral", "Amur", "Heinkel", "Dornier"}
playerShipNamesForHathcock = {"Hayha", "Waldron", "Plunkett", "Mawhinney", "Furlong", "Zaytsev", "Pavlichenko", "Pegahmagabow", "Fett", "Hawkeye", "Hanzo"}
playerShipNamesForLeftovers = {"Foregone","Righteous","Masher"}
placeRandomAroundPoint(Nebula,math.random(10,30),1,120000,brigx,brigy)
--Junk Yard M50 area
Asteroid():setPosition(909643, 152314)
Asteroid():setPosition(908697, 151087)
Asteroid():setPosition(911713, 153208)
Asteroid():setPosition(911918, 150729)
Asteroid():setPosition(912046, 149758)
Asteroid():setPosition(913036, 152491)
Asteroid():setPosition(913696, 151396)
Asteroid():setPosition(908036, 151340)
Asteroid():setPosition(906375, 149283)
Asteroid():setPosition(905979, 148528)
Asteroid():setPosition(906281, 147698)
Asteroid():setPosition(911413, 148623)
Asteroid():setPosition(910262, 147944)
Asteroid():setPosition(909903, 147302)
Asteroid():setPosition(906130, 150170)
Asteroid():setPosition(907961, 148916)
Asteroid():setPosition(908696, 148182)
Asteroid():setPosition(910870, 151302)
--Debris
junkYardDebrisX = {908020, 910705, 907503}
junkYardDebrisY = {150504, 150317, 148005}
debrisx, debrisy = pickCoordinate(junkYardDebrisX,junkYardDebrisY)
debris1 = Artifact():setPosition(debrisx, debrisy):setModel("ammo_box"):allowPickup(true):setScanningParameters(2,1):onPickUp(function(debris, pGrab) string.format("");pGrab.debris1 = true end)
debris1:setDescriptions(_("scienceDescription-debris", "Debris"),_("scienceDescription-debris", "Debris: Various broken ship components. Possibly useful for engine or weapons systems repair"))
debrisx, debrisy = pickCoordinate(junkYardDebrisX,junkYardDebrisY)
debris2 = Artifact():setPosition(debrisx, debrisy):setModel("ammo_box"):allowPickup(true):setScanningParameters(1,3):onPickUp(function(debris, pGrab) string.format("");pGrab.debris2 = true end)
debris2:setDescriptions(_("scienceDescription-debris", "Debris"),_("scienceDescription-debris", "Debris: Various broken ship components. Possibly useful for shield or beam systems repair"))
debrisx, debrisy = pickCoordinate(junkYardDebrisX,junkYardDebrisY)
debris3 = Artifact():setPosition(debrisx, debrisy):setModel("ammo_box"):allowPickup(true):setScanningParameters(2,1):onPickUp(function(debris, pGrab) string.format("");pGrab.debris3 = true end)
debris3:setDescriptions(_("scienceDescription-debris", "Debris"),_("scienceDescription-debris", "Debris: Various broken ship components. Possibly useful for hull or reactor systems repair"))
--Signs
junkYardSignX = {914126, 905479, 910303}
junkYardSignY = {151100, 148728, 147102}
junkZone = Zone():setPoints(905479, 148728, 906490, 146843, 910303, 147102, 914126, 151100, 912635, 154012, 905801, 151274)
signx, signy = pickCoordinate(junkYardSignX, junkYardSignY)
Sign1 = Artifact():setPosition(signx, signy):setModel("SensorBuoyMKI"):allowPickup(false):setScanningParameters(1,1)
Sign1:setDescriptions(_("scienceDescription-buoy", "Space Message Buoy"),_("scienceDescription-buoy", "Space Message Buoy reading 'Welcome to the Boris Junk Yard and Emporium' in the Kraylor language"))
signx, signy = pickCoordinate(junkYardSignX, junkYardSignY)
Sign2 = Artifact():setPosition(signx, signy):setModel("SensorBuoyMKI"):allowPickup(false):setScanningParameters(1,1)
Sign2:setDescriptions(_("scienceDescription-buoy", "Space Message Buoy"),_("scienceDescription-buoy", "Space Message Buoy reading 'Boris Junk Yard: Browse for parts, take home an asteroid for the kids' in the Kraylor language"))
signx, signy = pickCoordinate(junkYardSignX, junkYardSignY)
Sign3 = Artifact():setPosition(signx, signy):setModel("SensorBuoyMKI"):allowPickup(false):setScanningParameters(1,1)
Sign3:setDescriptions(_("scienceDescription-buoy", "Space Message Buoy"),_("scienceDescription-buoy", "Space Message Buoy reading 'Boris Junk Yard: Best prices in 20 sectors' in the Kraylor language"))
plotSign = billboardUpdate
--Initial player ship
scrag_system_health = {
["reactor"] = {initial = .01, max = .5, msg = _("repair-msgEngineer&+", "Reached maximum repair on reactor"), },
["beamweapons"] = {initial = -1, max = random(-.7,-.2), msg = _("repair-msgEngineer&+", "Reached maximum repair on beam weapons"), },
["maneuver"] = {initial = .05, max = .5, msg = _("repair-msgEngineer&+", "Reached maximum repair on maneuver"), },
["missilesystem"] = {initial = -1, },
["impulse"] = {initial = -.5, max = .2, msg = _("repair-msgEngineer&+", "Reached maximum repair on impulse engines"), },
["warp"] = {initial = -1, },
["jumpdrive"] = {initial = -1, },
["frontshield"] = {initial = .1, max = .25, msg = _("repair-msgEngineer&+", "Reached maximum repair on shields"), },
["rearshield"] = {initial = .1, },
}
playerFighter = PlayerSpaceship():setFaction("Human Navy"):setTemplate("MP52 Hornet"):setCallSign("Scrag"):setPosition(912035, 152062)
allowNewPlayerShips(false)
for system,health in pairs(scrag_system_health) do
playerFighter:setSystemHealth(system,health.initial)
if health.max ~= nil then
playerFighter:setSystemHealthMax(system,health.max)
end
end
playerFighter:onDestruction(function()
globalMessage(_("defeat-msgMainscreen","You were destroyed. The Human Navy did not receive your Kraylor intel."))
victory("Kraylor")
end)
playerFighter:setScanProbeCount(1):setEnergy(50):setHull(5):setShields(5)
playerFighter.maxCargo = 3
playerFighter.cargo = playerFighter.maxCargo
playerFighter.shipScore = 5
player = playerFighter
junkShips = {}
local ship_spots = {
{x = 909594, y = 148578}, --1
{x = 910129, y = 150090}, --2
{x = 909490, y = 149528}, --3
{x = 910461, y = 151061}, --4
{x = 910716, y = 149068}, --5
{x = 911023, y = 151854}, --6
{x = 913356, y = 151717}, --7
{x = 906866, y = 148094}, --8
{x = 911356, y = 150167}, --9
{x = 910998, y = 153234}, --10
{x = 907356, y = 150170}, --11
{x = 913243, y = 150698}, --12
{x = 908569, y = 149988}, --13
{x = 912413, y = 152981}, --14
{x = 907149, y = 149132}, --15
}
local ship_spot = tableRemoveRandom(ship_spots)
junkRepulse = CpuShip():setFaction("Independent"):setTemplate("Repulse"):setPosition(ship_spot.x, ship_spot.y):orderIdle():setHull(14):setShields(0.00,2.00):setWeaponStorage("HVLI",0):setWeaponStorage("Homing",1)
table.insert(junkShips,junkRepulse)
ship_spot = tableRemoveRandom(ship_spots)
junkAdder = CpuShip():setFaction("Kraylor"):setTemplate("Adder MK4"):setPosition(ship_spot.x, ship_spot.y):orderIdle():setHull(9):setShields(0.00):setWeaponStorage("HVLI", 1)
table.insert(junkShips,junkAdder)
ship_spot = tableRemoveRandom(ship_spots)
junkFreighter1 = CpuShip():setFaction("Kraylor"):setTemplate("Fuel Freighter 1"):setPosition(ship_spot.x, ship_spot.y):orderIdle():setHull(6):setShields(1.00, 0.00)
table.insert(junkShips,junkFreighter1)
ship_spot = tableRemoveRandom(ship_spots)
junkFreighter2 = CpuShip():setFaction("Independent"):setTemplate("Goods Freighter 3"):setPosition(ship_spot.x, ship_spot.y):orderIdle():setHull(7):setShields(14.00, 0.00)
table.insert(junkShips,junkFreighter2)
ship_spot = tableRemoveRandom(ship_spots)
junkDrone1 = CpuShip():setFaction("Ktlitans"):setTemplate("Ktlitan Drone"):setPosition(ship_spot.x, ship_spot.y):orderIdle():setHull(2)
table.insert(junkShips,junkDrone1)
ship_spot = tableRemoveRandom(ship_spots)
junkDrone2 = CpuShip():setFaction("Ktlitans"):setTemplate("Ktlitan Drone"):setPosition(ship_spot.x, ship_spot.y):orderIdle():setHull(6)
table.insert(junkShips,junkDrone2)
ship_spot = tableRemoveRandom(ship_spots)
junkDrone3 = CpuShip():setFaction("Kraylor"):setTemplate("Ktlitan Drone"):setPosition(ship_spot.x, ship_spot.y):orderIdle():setHull(2)
table.insert(junkShips,junkDrone3)
ship_spot = tableRemoveRandom(ship_spots)
junkDrone4 = CpuShip():setFaction("Ktlitans"):setTemplate("Ktlitan Drone"):setPosition(ship_spot.x, ship_spot.y):orderIdle():setHull(7)
table.insert(junkShips,junkDrone4)
ship_spot = tableRemoveRandom(ship_spots)
junkHornet1 = CpuShip():setFaction("Exuari"):setTemplate("MT52 Hornet"):setPosition(ship_spot.x, ship_spot.y):orderIdle():setHull(2):setShields(0.00)
table.insert(junkShips,junkHornet1)
ship_spot = tableRemoveRandom(ship_spots)
junkHornet2 = CpuShip():setFaction("Ghosts"):setTemplate("MT52 Hornet"):setPosition(ship_spot.x, ship_spot.y):orderIdle():setHull(2):setShields(0.00)
table.insert(junkShips,junkHornet2)
ship_spot = tableRemoveRandom(ship_spots)
junkHornet3 = CpuShip():setFaction("Arlenians"):setTemplate("MT52 Hornet"):setPosition(ship_spot.x, ship_spot.y):orderIdle():setHull(1):setShields(1.00)
table.insert(junkShips,junkHornet3)
ship_spot = tableRemoveRandom(ship_spots)
junkHornet4 = CpuShip():setFaction("Kraylor"):setTemplate("MU52 Hornet"):setPosition(ship_spot.x, ship_spot.y):orderIdle():setHull(2):setShields(0.00)
table.insert(junkShips,junkHornet4)
ship_spot = tableRemoveRandom(ship_spots)
junkPhobos = CpuShip():setFaction("Kraylor"):setTemplate("Phobos M3"):setPosition(ship_spot.x, ship_spot.y):orderIdle():setHull(4):setShields(2.00, 1.00):setWeaponStorage("Homing", 1)
table.insert(junkShips,junkPhobos)
ship_spot = tableRemoveRandom(ship_spots)
junkStrikeship = CpuShip():setFaction("Kraylor"):setTemplate("Strikeship"):setPosition(ship_spot.x, ship_spot.y):orderIdle():setHull(0):setShields(4.00, 0.00, 30.00, 30.00)
table.insert(junkShips,junkStrikeship)
ship_spot = tableRemoveRandom(ship_spots)
junkScout = CpuShip():setFaction("Ktlitans"):setTemplate("Ktlitan Scout"):setPosition(ship_spot.x, ship_spot.y):orderIdle():setHull(4)
table.insert(junkShips,junkScout)
local systems = {"reactor","beamweapons","maneuver","missilesystem","impulse","warp","jumpdrive","frontshield","rearshield"}
for i,ship in ipairs(junkShips) do
for j,system in ipairs(systems) do
ship:setSystemHealth(system,random(-.9,-.1))
ship:setSystemHealthMax(system,ship:getSystemHealth(system))
end
end
plunder_system_health = {
["reactor"] = {max = .4, msg = _("repair-msgEngineer", "Reached maximum repair on reactor"), },
["beamweapons"] = {max = .8, msg = _("repair-msgEngineer", "Reached maximum repair on beam weapons"), },
["maneuver"] = {max = nil},
["missilesystem"] = {max = -.1, msg = _("repair-msgEngineer", "Reached maximum repair on missile weapons"), },
["impulse"] = {max = .4, msg = _("repair-msgEngineer", "Reached maximum repair on impulse engines"), },
["warp"] = {max = -.1, msg = _("repair-msgEngineer", "Reached maximum repair on warp drive"), },
["jumpdrive"] = {max = -.1, msg = _("repair-msgEngineer", "Reached maximum repair on jump drive"), },
["frontshield"] = {max = .3, msg = _("repair-msgEngineer", "Reached maximum repair on front shields"), },
["rearshield"] = {max = .3, msg = _("repair-msgEngineer", "Reached maximum repair on rear shield"), },
}
junkRepulse:setSystemHealth("jumpdrive",-1):setBeamWeapon(1,0,0,0,0,0)
junkRepulse:setSystemHealthMax("jumpdrive",.5)
junkSupply = SupplyDrop():setFaction("Independent"):setPosition(909362, 151445):setEnergy(500):setWeaponStorage("Homing", 1):setWeaponStorage("Nuke", 0):setWeaponStorage("Mine", 0):setWeaponStorage("EMP", 0)
playerShipHealth = scragHealth --set function to constrain player ship health
playerFighter:addToShipLog(string.format(_("goal-shipLog", "You escaped the brig of station %s and transported yourselves onto one of the spaceship hulks in a nearby holding area for junked spacecraft. You carry critical information for the Human Navy regarding Kraylor activity in this area. You need to make good your escape and dock with a Human Navy space station"), brigStation:getCallSign()),"Magenta")
plot1 = scanRepulse --enable first plot mission goal
--print("end of init")
end
function tableRemoveRandom(array)
-- Remove random element from array and return it.
-- Returns nil if the array is empty,
-- analogous to `table.remove`.
local array_item_count = #array
if array_item_count == 0 then
return nil
end
local selected_item = math.random(array_item_count)
local temp = array[selected_item]
array[selected_item] = array[array_item_count]
array[array_item_count] = temp
return table.remove(array)
end
function pickCoordinate(coordinateArrayX,coordinateArrayY)
--pick a coordinate at random from the passed table
--remove selected coordinates and return selected coordinates
if #coordinateArrayX > 1 then
choice = math.random(1,#coordinateArrayX)
rx = coordinateArrayX[choice]
ry = coordinateArrayY[choice]
table.remove(coordinateArrayX,choice)
table.remove(coordinateArrayY,choice)
else
rx = coordinateArrayX[1]
ry = coordinateArrayY[1]
table.remove(coordinateArrayX,1)
table.remove(coordinateArrayY,1)
end
return rx, ry
end
function setSettings()
local enemy_config = {
["Easy"] = {number = .5},
["Normal"] = {number = 1},
["Hard"] = {number = 2},
}
enemy_power = enemy_config[getScenarioSetting("Enemies")].number
local murphy_config = {
["Easy"] = {number = .5, },
["Normal"] = {number = 1, },
["Hard"] = {number = 2, },
}
difficulty = murphy_config[getScenarioSetting("Murphy")].number
end
function addRepulseToDatabase()
--------------------------------------------------------------------------------------
-- Generic station descriptions: text and details from shipTemplates_stations.lua --
--------------------------------------------------------------------------------------
local station_key = _("scienceDB","Stations")
local station_db = queryScienceDatabase(station_key)
local class_key = _("scienceDB","Class")
local size_key = _("scienceDB","Size")
local shield_key = _("scienceDB","Shield")
local hull_key = _("scienceDB","Hull")
if station_db == nil then
station_db = ScienceDatabase():setName(station_key)
station_db:setLongDescription(_("scienceDB","Stations are places for ships to dock, get repaired and replenished, interact with station personnel, etc. They are like oases, service stations, villages, towns, cities, etc."))
local small_station_key = _("scienceDB","Small Station")
station_db:addEntry(small_station_key)
local small_station_db = queryScienceDatabase(station_key,small_station_key)
small_station_db:setLongDescription(_("scienceDB","Stations of this size are often used as research outposts, listening stations, and security checkpoints. Crews turn over frequently in a small station's cramped accommodatations, but they are small enough to look like ships on many long-range sensors, and organized raiders sometimes take advantage of this by placing small stations in nebulae to serve as raiding bases. They are lightly shielded and vulnerable to swarming assaults."))
small_station_db:setImage("radar/smallstation.png")
small_station_db:setKeyValue(class_key,_("scienceDB","Small"))
small_station_db:setKeyValue(size_key,300)
small_station_db:setKeyValue(shield_key,300)
small_station_db:setKeyValue(hull_key,150)
small_station_db:setModelDataName("space_station_4")
local medium_station_key = _("scienceDB","Medium Station")
station_db:addEntry(medium_station_key)
local medium_station_db = queryScienceDatabase(station_key,medium_station_key)
medium_station_db:setLongDescription(_("scienceDB","Large enough to accommodate small crews for extended periods of times, stations of this size are often trading posts, refuelling bases, mining operations, and forward military bases. While their shields are strong, concerted attacks by many ships can bring them down quickly."))
medium_station_db:setImage("radar/mediumstation.png")
medium_station_db:setKeyValue(class_key,_("scienceDB","Medium"))
medium_station_db:setKeyValue(size_key,1000)
medium_station_db:setKeyValue(shield_key,800)
medium_station_db:setKeyValue(hull_key,400)
medium_station_db:setModelDataName("space_station_3")
local large_station_key = _("scienceDB","Large Station")
station_db:addEntry(large_station_key)
local large_station_db = queryScienceDatabase(station_key,large_station_key)
large_station_db:setLongDescription(_("scienceDB","These spaceborne communities often represent permanent bases in a sector. Stations of this size can be military installations, commercial hubs, deep-space settlements, and small shipyards. Only a concentrated attack can penetrate a large station's shields, and its hull can withstand all but the most powerful weaponry."))
large_station_db:setImage("radar/largestation.png")
large_station_db:setKeyValue(class_key,_("scienceDB","Large"))
large_station_db:setKeyValue(size_key,1300)
large_station_db:setKeyValue(shield_key,"1000/1000/1000")
large_station_db:setKeyValue(hull_key,500)
large_station_db:setModelDataName("space_station_2")
local huge_station_key = _("scienceDB","Huge Station")
station_db:addEntry(huge_station_key)
local huge_station_db = queryScienceDatabase(station_key,huge_station_key)
huge_station_db:setLongDescription(_("scienceDB","The size of a sprawling town, stations at this scale represent a faction's center of spaceborne power in a region. They serve many functions at once and represent an extensive investment of time, money, and labor. A huge station's shields and thick hull can keep it intact long enough for reinforcements to arrive, even when faced with an ongoing siege or massive, perfectly coordinated assault."))
huge_station_db:setImage("radar/hugestation.png")
huge_station_db:setKeyValue(class_key,_("scienceDB","Huge"))
huge_station_db:setKeyValue(size_key,1500)
huge_station_db:setKeyValue(shield_key,"1200/1200/1200/1200")
huge_station_db:setKeyValue(hull_key,800)
huge_station_db:setModelDataName("space_station_1")
end
-----------------------------------------------------------------------------------
-- Template ship category descriptions: text from other shipTemplates... files --
-----------------------------------------------------------------------------------
local ships_key = _("scienceDB","Ships")
local ships_db = queryScienceDatabase(ships_key)
local starfighter_key = _("scienceDB","Starfighter")
local fighter_db = queryScienceDatabase(ships_key,starfighter_key)
if fighter_db ~= nil then
fighter_db:setLongDescription(_("scienceDB","Starfighters are single to 3 person small ships. These are most commonly used as light firepower roles.\nThey are common in larger groups, and need a close by station or support ship, as they lack long time life support.\nIt's rare to see starfighters with more then one shield section.\n\nOne of the most well known starfighters is the X-Wing.\n\nStarfighters come in 3 subclasses:\n* Interceptors: Fast, low on firepower, high on manouverability\n* Gunship: Equipped with more weapons, but trades in manouverability because of it.\n* Bomber: Slowest of all starfighters, but pack a large punch in a small package. Usually come without any lasers, but the largers bombers have been known to deliver nukes."))
end
local frigate_key = _("scienceDB","Frigate")
local frigate_db = queryScienceDatabase(ships_key,frigate_key)
if frigate_db ~= nil then
frigate_db:setLongDescription(_("scienceDB","Frigates are one size up from starfighters. They require a crew from 3 to 20 people.\nThink, Firefly, millennium falcon, slave I (Boba fett's ship).\n\nThey generally have 2 or more shield sections, but hardly ever more than 4.\n\nThis class of ships is normally not fitted with jump or warp drives. But in some cases ships are modified to include these, or for certain roles it is built in.\n\nThey are divided in 3 different sub-classes:\n* Cruiser: Weaponized frigates, focused on combat. These come in various roles.\n* Light transport: Small transports, like transporting up to 50 soldiers in spartan conditions or a few diplomats in luxury. Depending on the role it can have some weaponry.\n* Support: Support types come in many varieties. They are simply a frigate hull fitted with whatever was needed. Anything from mine-layers to science vessels."))
end
local corvette_key = _("scienceDB","Corvette")
local corvette_db = queryScienceDatabase(ships_key,corvette_key)
if corvette_db ~= nil then
corvette_db:setLongDescription(_("scienceDB","Corvettes are the common large ships. Larger then a frigate, smaller then a dreadnaught.\nThey generally have 4 or more shield sections. Run with a crew of 20 to 250.\nThis class generally has jumpdrives or warpdrives. But lack the maneuverability that is seen in frigates.\n\nThey come in 3 different subclasses:\n* Destroyer: Combat oriented ships. No science, no transport. Just death in a large package.\n* Support: Large scale support roles. Drone carriers fall in this category, as well as mobile repair centers.\n* Freighter: Large scale transport ships. Most common here are the jump freighters, using specialized jumpdrives to cross large distances with large amounts of cargo."))
end
local dreadnought_key = _("scienceDB","Dreadnought")
local dreadnought_db = queryScienceDatabase(ships_key,dreadnought_key)
if dreadnought_db ~= nil then
dreadnought_db:setLongDescription(_("scienceDB","Dreadnoughts are the largest ships.\nThey are so large and uncommon that every type is pretty much their own subclass.\nThey usually come with 6 or more shield sections, require a crew of 250+ to operate.\n\nThink: Stardestroyer."))
end
---------------------------------------------------------------------
-- Cruiser (identified as Karnack MK2 in stock science database) --
---------------------------------------------------------------------
local cruiser_key = _("scienceDB","Cruiser")
local cruiser_db = queryScienceDatabase(ships_key,frigate_key,cruiser_key)
local subclass_key = _("scienceDB","Sub-class")
local move_speed_key = _("scienceDB","Move speed")
local turn_speed_key = _("scienceDB","Turn speed")
if cruiser_db == nil then
frigate_db:addEntry(cruiser_key)
cruiser_db = queryScienceDatabase(ships_key,frigate_key,cruiser_key)
cruiser_db:setLongDescription(_("scienceDB","Fabricated by: Repulse shipyards. The Cruiser, sometimes known as the Karnack Cruiser Mark 2, is the sucessor to the widly sucesfull mark I Karnack cruiser. This ship has several notable improvements over the original ship, including better armor, slightly improved weaponry and customization by the shipyards. The latter improvement was the most requested feature by several factions once they realized that their old surplus mark I ships were used for less savoury purposes."))
cruiser_db:setKeyValue(class_key,frigate_key)
cruiser_db:setKeyValue(subclass_key,cruiser_key)
cruiser_db:setKeyValue(size_key,"100")
cruiser_db:setKeyValue(shield_key,"40/40")
cruiser_db:setKeyValue(hull_key,"70")
cruiser_db:setKeyValue(move_speed_key,_("scienceDB","3.6 U/min")) --60
cruiser_db:setKeyValue(turn_speed_key,_("scienceDB","6 deg/sec"))
cruiser_db:setKeyValue(_("scienceDB","Beam weapon 345:90"),_("scienceDB","Rng:1 Dmg:6 Cyc:6"))
cruiser_db:setKeyValue(_("scienceDB","Beam weapon 15:90"),_("scienceDB","Rng:1 Dmg:6 Cyc:6"))
cruiser_db:setImage("radar/cruiser.png")
cruiser_db:setModelDataName("small_frigate_4")
end
--------------------------
-- Stock player ships --
--------------------------
local mainstream_key = _("scienceDB","Mainstream")
local stock_db = ships_db:addEntry(mainstream_key)
stock_db = queryScienceDatabase(ships_key,mainstream_key)
stock_db:setLongDescription(_("scienceDB","Mainstream ships are those ship types that are commonly available to CUF crews serving on the front lines or in well established areas under the protection of the Human Navy more generally."))
---- Frigates
local frigate_stock_db = stock_db:addEntry(frigate_key)
frigate_stock_db:setLongDescription(_("scienceDB","Frigates are one size up from starfighters. They require a crew from 3 to 20 people.\nThink, Firefly, millennium falcon, slave I (Boba fett's ship).\n\nThey generally have 2 or more shield sections, but hardly ever more than 4.\n\nThis class of ships is normally not fitted with jump or warp drives. But in some cases ships are modified to include these, or for certain roles it is built in.\n\nThey are divided in 3 different sub-classes:\n* Cruiser: Weaponized frigates, focused on combat. These come in various roles.\n* Light transport: Small transports, like transporting up to 50 soldiers in spartan conditions or a few diplomats in luxury. Depending on the role it can have some weaponry.\n* Support: Support types come in many varieties. They are simply a frigate hull fitted with whatever was needed. Anything from mine-layers to science vessels."))
-- Repulse
local repulse_key = _("scienceDB","Repulse")
frigate_stock_db:addEntry(repulse_key)
local repulse_db = queryScienceDatabase(ships_key,mainstream_key,frigate_key,repulse_key)
repulse_db:setLongDescription(_("scienceDB","A Flavia P. Falcon with better hull and shields, a jump drive, two turreted beams covering both sides and a forward and rear tube. The nukes and mines are gone"))
repulse_db:setKeyValue(class_key,frigate_key)
repulse_db:setKeyValue(subclass_key,_("scienceDB","Cruiser: Armored Transport"))
repulse_db:setKeyValue(size_key,"80")
repulse_db:setKeyValue(shield_key,"80/80")
repulse_db:setKeyValue(hull_key,"120")
repulse_db:setKeyValue(_("scienceDB","Repair Crew"),8)
repulse_db:setKeyValue(_("scienceDB","Jump Range"),_("scienceDB","5 - 50 U"))
repulse_db:setKeyValue(_("scienceDB","Sensor Ranges"),_("scienceDB","Long: 38 U / Short: 5 U"))
repulse_db:setKeyValue(move_speed_key,_("scienceDB","3.3 U/min")) --55
repulse_db:setKeyValue(turn_speed_key,_("scienceDB","9 deg/sec"))
repulse_db:setKeyValue(_("scienceDB","Beam weapon 90:200"),_("scienceDB","Rng:1.2 Dmg:5 Cyc:6"))
repulse_db:setKeyValue(_("scienceDB","Beam weapon 270:200"),_("scienceDB","Rng:1.2 Dmg:5 Cyc:6"))
repulse_db:setKeyValue(_("scienceDB","Tube 0"),_("scienceDB","20 sec"))
repulse_db:setKeyValue(_("scienceDB","Tube 180"),_("scienceDB","20 sec"))
repulse_db:setKeyValue(_("scienceDB","Storage Homing"),"4")
repulse_db:setKeyValue(_("scienceDB","Storage HVLI"),"6")
repulse_db:setImage("radar/tug.png")
repulse_db:setModelDataName("LightCorvetteRed")
end
function createRandomAlongArc(object_type, amount, x, y, distance, startArc, endArcClockwise, randomize)
-- Create amount of objects of type object_type along arc
-- Center defined by x and y
-- Radius defined by distance
-- Start of arc between 0 and 360 (startArc), end arc: endArcClockwise
-- Use randomize to vary the distance from the center point. Omit to keep distance constant
-- Example:
-- createRandomAlongArc(Asteroid, 100, 500, 3000, 65, 120, 450)
if randomize == nil then randomize = 0 end
if amount == nil then amount = 1 end
arcLen = endArcClockwise - startArc
if startArc > endArcClockwise then
endArcClockwise = endArcClockwise + 360
arcLen = arcLen + 360
end
if amount > arcLen then
for ndex=1,arcLen do
radialPoint = startArc+ndex
pointDist = distance + random(-randomize,randomize)
object_type():setPosition(x + math.cos(radialPoint / 180 * math.pi) * pointDist, y + math.sin(radialPoint / 180 * math.pi) * pointDist)
end
for ndex=1,amount-arcLen do
radialPoint = random(startArc,endArcClockwise)
pointDist = distance + random(-randomize,randomize)
object_type():setPosition(x + math.cos(radialPoint / 180 * math.pi) * pointDist, y + math.sin(radialPoint / 180 * math.pi) * pointDist)
end
else
for ndex=1,amount do
radialPoint = random(startArc,endArcClockwise)
pointDist = distance + random(-randomize,randomize)
object_type():setPosition(x + math.cos(radialPoint / 180 * math.pi) * pointDist, y + math.sin(radialPoint / 180 * math.pi) * pointDist)
end
end
end
function placeRandomAsteroidsAroundPoint(object_type, amount, dist_min, dist_max, x0, y0)
for n=1,amount do
local r = random(0, 360)
local distance = random(dist_min, dist_max)
local x = x0 + math.cos(r / 180 * math.pi) * distance
local y = y0 + math.sin(r / 180 * math.pi) * distance
local obj = object_type():setPosition(x, y)
if obj.typeName == "Asteroid" or obj.typeName == "VisualAsteroid" then
obj:setSize(random(1,100) + random(1,75) + random(1,75) + random(1,20) + random(1,20) + random(1,20) + random(1,20) + random(1,20) + random(1,20) + random(1,20))
end
end
end
function createRandomAsteroidAlongArc(amount, x, y, distance, startArc, endArcClockwise, randomize)
-- Create amount of asteroids along arc
-- Center defined by x and y
-- Radius defined by distance
-- Start of arc between 0 and 360 (startArc), end arc: endArcClockwise
-- Use randomize to vary the distance from the center point. Omit to keep distance constant
-- Example:
-- createRandomAsteroidAlongArc(100, 500, 3000, 65, 120, 450)
if randomize == nil then randomize = 0 end
if amount == nil then amount = 1 end
local arcLen = endArcClockwise - startArc
if startArc > endArcClockwise then
endArcClockwise = endArcClockwise + 360
arcLen = arcLen + 360
end
local asteroid_size = random(1,100) + random(1,75) + random(1,75) + random(1,20) + random(1,20) + random(1,20) + random(1,20) + random(1,20) + random(1,20) + random(1,20)
if amount > arcLen then
for ndex=1,arcLen do
local radialPoint = startArc+ndex
local pointDist = distance + random(-randomize,randomize)
asteroid_size = random(1,100) + random(1,75) + random(1,75) + random(1,20) + random(1,20) + random(1,20) + random(1,20) + random(1,20) + random(1,20) + random(1,20)
Asteroid():setPosition(x + math.cos(radialPoint / 180 * math.pi) * pointDist, y + math.sin(radialPoint / 180 * math.pi) * pointDist):setSize(asteroid_size)
end
for ndex=1,amount-arcLen do
radialPoint = random(startArc,endArcClockwise)
pointDist = distance + random(-randomize,randomize)
asteroid_size = random(1,100) + random(1,75) + random(1,75) + random(1,20) + random(1,20) + random(1,20) + random(1,20) + random(1,20) + random(1,20) + random(1,20)
Asteroid():setPosition(x + math.cos(radialPoint / 180 * math.pi) * pointDist, y + math.sin(radialPoint / 180 * math.pi) * pointDist):setSize(asteroid_size)
end
else
for ndex=1,amount do
radialPoint = random(startArc,endArcClockwise)
pointDist = distance + random(-randomize,randomize)
asteroid_size = random(1,100) + random(1,75) + random(1,75) + random(1,20) + random(1,20) + random(1,20) + random(1,20) + random(1,20) + random(1,20) + random(1,20)
Asteroid():setPosition(x + math.cos(radialPoint / 180 * math.pi) * pointDist, y + math.sin(radialPoint / 180 * math.pi) * pointDist):setSize(asteroid_size)
end
end
end
function buildNearbyStations()
-- Organically (simulated asymetrically) grow stations from a central grid location
-- Order of creation: enemy stations, planet, enemy stations, planet,
-- independent stations, black hole, independent stations, black hole
-- Human Navy stations (friendly stations) come later in the game after the communications get repaired.
brigx, brigy = brigStation:getPosition()
gbLow = 1 --grid boundary low
gbHigh = 500 --grid boundary high
grid = {} --grid - positional model
for i=gbLow,gbHigh do
grid[i] = {}
end
gx = gbHigh/2 --grid coordinate x
gy = gbHigh/2 --grid coordinate y
gp = 1 --grid position list index
gSize = random(6000,8000) --grid cell size in positional units
adjList = {} --adjacent space on grid location list
--place enemy stations
stationFaction = "Kraylor"
for i=gx-2,gx+1 do --reserve space for the junk yard
for j=gy-1,gy+2 do
grid[i][j] = gp
end
end
adjList = getAdjacentGridLocations(gx,gy)
ral = math.random(1,#adjList) --random adjacent location
gx = adjList[ral][1]
gy = adjList[ral][2]
gp = 2
for j=1,5 do --add enemy bases nearby
addEnemyStations()
end
--insert a planet
tSize = 11
grid[gx][gy] = gp
gRegion = {}
table.insert(gRegion,{gx,gy})
for i=1,tSize do
adjList = getAdjacentGridLocations(gx,gy)
if #adjList < 1 then
break
end
rd = math.random(1,#adjList)
grid[adjList[rd][1]][adjList[rd][2]] = gp
table.insert(gRegion,{adjList[rd][1],adjList[rd][2]})
end
adjList = getAdjacentGridLocations(gx,gy)
if #adjList < 1 then
adjList = getAllAdjacentGridLocations(gx,gy)
end
sri = math.random(1,#gRegion)
bwx = brigx + (gRegion[sri][1] - (gbHigh/2))*gSize
bwy = brigy + (gRegion[sri][2] - (gbHigh/2))*gSize
planetBaldwin = Planet():setPosition(bwx,bwy):setPlanetRadius(3000):setDistanceFromMovementPlane(-2000):setCallSign("Baldwin")
planetBaldwin:setPlanetSurfaceTexture("planets/gas-1.png"):setAxialRotationTime(300):setDescription(_("scienceDescription-planet", "Mining and heavy industry"))
stationWig = SpaceStation():setTemplate("Small Station"):setFaction("Kraylor")
stationWig:setPosition(bwx, bwy+3000):setCallSign("BOBS"):setDescription(_("scienceDescription-station", "Baldwin Observatory"))
stationWig.angle = 90
gp = gp + 1
rn = math.random(1,#adjList)
gx = adjList[rn][1]
gy = adjList[rn][2]
for j=1,6 do --add more enemy bases nearby
addEnemyStations()
end
--insert a planet
tSize = 11
grid[gx][gy] = gp
gRegion = {}
table.insert(gRegion,{gx,gy})
for i=1,tSize do
adjList = getAdjacentGridLocations(gx,gy)
if #adjList < 1 then
break
end
rd = math.random(1,#adjList)
grid[adjList[rd][1]][adjList[rd][2]] = gp
table.insert(gRegion,{adjList[rd][1],adjList[rd][2]})
end
adjList = getAdjacentGridLocations(gx,gy)
if #adjList < 1 then
adjList = getAllAdjacentGridLocations(gx,gy)
end
sri = math.random(1,#gRegion)
msx = brigx + (gRegion[sri][1] - (gbHigh/2))*gSize
msy = brigy + (gRegion[sri][2] - (gbHigh/2))*gSize
planetMal = Planet():setPosition(msx,msy):setPlanetRadius(3000):setDistanceFromMovementPlane(-2000):setCallSign("Malastare")
planetMal:setPlanetSurfaceTexture("planets/planet-1.png"):setPlanetCloudTexture("planets/clouds-1.png")
planetMal:setPlanetAtmosphereTexture("planets/atmosphere.png"):setPlanetAtmosphereColor(0.2,0.2,1.0)
planetMal:setAxialRotationTime(400.0):setDescription(_("scienceDescription-planet", "M class planet"))
stationMal = SpaceStation():setTemplate("Small Station"):setFaction("Independent")
stationMal:setPosition(msx,msy+3000):setCallSign("MalNet"):setDescription(_("scienceDescription-station", "Malastare communications network hub"))
stationMal.angle = 90
gp = gp + 1
rn = math.random(1,#adjList)
gx = adjList[rn][1]
gy = adjList[rn][2]
--place independent stations
stationFaction = "Independent"
fb = gp --set faction boundary (between enemy and neutral)
for j=1,15 do
addIndependentStations()
end
addBlackHole()
for j=1,15 do
addIndependentStations()
end
addBlackHole()
end
function addEnemyStations()
tSize = math.random(2,5) --tack on to region size (3-6 since first is outside loop)
grid[gx][gy] = gp --set current grid location to grid position list index
gRegion = {} --grow region
table.insert(gRegion,{gx,gy})
for i=1,tSize do
adjList = getAdjacentGridLocations(gx,gy)
if #adjList < 1 then --exit loop if there are no more adjacent spaces available
break
end
rd = math.random(1,#adjList) --random direction to grow from adjacent list
grid[adjList[rd][1]][adjList[rd][2]] = gp
table.insert(gRegion,{adjList[rd][1],adjList[rd][2]})
end
--get adjacent list after done growing region
adjList = getAdjacentGridLocations(gx,gy)
if #adjList < 1 then
adjList = getAllAdjacentGridLocations(gx,gy)
else
if random(1,100) >= 17 then
adjList = getAllAdjacentGridLocations(gx,gy)
end
end
sri = math.random(1,#gRegion) --select station random region index
psx = brigx + (gRegion[sri][1] - (gbHigh/2))*gSize + random(-gSize/2*.95,gSize/2*.95) --place station x coordinate
psy = brigy + (gRegion[sri][2] - (gbHigh/2))*gSize + random(-gSize/2*.95,gSize/2*.95) --place station y coordinate
pStation = placeEStation(psx,psy,"RandomGenericSinister",stationFaction)
table.insert(enemyStationList,pStation) --save station in general station list
gp = gp + 1 --set next station number
rn = math.random(1,#adjList) --random next station start location
gx = adjList[rn][1]
gy = adjList[rn][2]
end
function placeEStation(x,y,name,faction)
faction_station_service_chance = {
["Human Navy"] = 20,
["Kraylor"] = 0,
["Independent"] = 0,
["Arlenians"] = 0,
["Ghosts"] = 0,
["Ktlitans"] = 0,
["Exuari"] = 0,
["TSN"] = 10,
["USN"] = 10,
["CUF"] = 10,
}
local station = placeStation(x,y,name,faction)
local station_name = station:getCallSign()
local chosen_goods = random(1,100)
if station_name == "Grasberg" or station_name == "Impala" or station_name == "Outpost-15" or station_name == "Outpost-21" then
placeRandomAsteroidsAroundPoint(Asteroid,15,1,15000,x,y)
placeRandomAsteroidsAroundPoint(VisualAsteroid,30,1,15000,x,y)
if chosen_goods < 20 then
station.comms_data.goods.gold = {quantity = 5, cost = 25}
station.comms_data.goods.cobalt = {quantity = 4, cost = 50}
elseif chosen_goods < 40 then
station.comms_data.goods.gold = {quantity = 5, cost = 25}
elseif chosen_goods < 60 then
station.comms_data.goods.cobalt = {quantity = 4, cost = 50}
else
if station_name == "Grasberg" then
station.comms_data.goods.nickel = {quantity = 5, cost = math.random(40,50)}
elseif station_name == "Outpost-15" then
station.comms_data.goods.platinum = {quantity = 5, cost = math.random(40,50)}
elseif station_name == "Outpost-21" then
station.comms_data.goods.dilithium = {quantity = 5, cost = math.random(40,50)}
else --Impala
station.comms_data.goods.tritanium = {quantity = 5, cost = math.random(40,50)}
end
end
elseif station_name == "Jabba" or station_name == "Lando" or station_name == "Maverick" or station_name == "Okun" or station_name == "Outpost-8" or station_name == "Prada" or station_name == "Research-11" or station_name == "Research-19" or station_name == "Science-2" or station_name == "Science-4" or station_name == "Spot" or station_name == "Starnet" or station_name == "Tandon" then
if chosen_goods < 33 then
if station_name == "Jabba" then
station.comms_data.goods.cobalt = {quantity = 5, cost = math.random(68,81)}
elseif station_name == "Okun" or station_name == "Spot" then
station.comms_data.goods.optic = {quantity = 5, cost = math.random(68,81)}
elseif station_name == "Outpost-8" then
station.comms_data.goods.impulse = {quantity = 5, cost = math.random(68,81)}
elseif station_name == "Research-11" then
station.comms_data.goods.warp = {quantity = 5, cost = math.random(68,81)}
elseif station_name == "Research-19" then
station.comms_data.goods.transporter = {quantity = 5, cost = math.random(68,81)}
elseif station_name == "Science-2" or station_name == "Tandon" then
station.comms_data.goods.autodoc = {quantity = 5, cost = math.random(68,81)}
elseif station_name == "Science-4" then
station.comms_data.goods.software = {quantity = 5, cost = math.random(68,81)}
elseif station_name == "Starnet" then
station.comms_data.goods.shield = {quantity = 5, cost = math.random(68,81)}
else
station.comms_data.goods.luxury = {quantity = 5, cost = math.random(68,81)}
end
elseif chosen_goods < 66 then
if station_name == "Okun" then
station.comms_data.goods.filament = {quantity = 5, cost = math.random(61,77)}
elseif station_name == "Outpost-8" then
station.comms_data.goods.tractor = {quantity = 5, cost = math.random(61,77)}
elseif station_name == "Prada" then
station.comms_data.goods.cobalt = {quantity = 5, cost = math.random(61,77)}
elseif station_name == "Research-11" then
station.comms_data.goods.repulsor = {quantity = 5, cost = math.random(61,77)}
elseif station_name == "Research-19" or station_name == "Spot" then
station.comms_data.goods.sensor = {quantity = 5, cost = math.random(61,77)}
elseif station_name == "Science-2" or station_name == "Tandon" then
station.comms_data.goods.android = {quantity = 5, cost = math.random(61,77)}
elseif station_name == "Science-4" then
station.comms_data.goods.circuit = {quantity = 5, cost = math.random(61,77)}
elseif station_name == "Starnet" then
station.comms_data.goods.lifter = {quantity = 5, cost = math.random(61,77)}
else
station.comms_data.goods.gold = {quantity = 5, cost = math.random(61,77)}
end
else
if station_name == "Okun" then
station.comms_data.goods.lifter = {quantity = 5, cost = math.random(61,77)}
elseif station_name == "Outpost-8" or station_name == "Starnet" then
station.comms_data.goods.beam = {quantity = 5, cost = math.random(61,77)}
elseif station_name == "Prada" then
station.comms_data.goods.dilithium = {quantity = 5, cost = math.random(61,77)}
elseif station_name == "Research-11" then
station.comms_data.goods.robotic = {quantity = 5, cost = math.random(61,77)}
elseif station_name == "Research-19" then
station.comms_data.goods.communication = {quantity = 5, cost = math.random(61,77)}
elseif station_name == "Science-2" then
station.comms_data.goods.nanites = {quantity = 5, cost = math.random(61,77)}
elseif station_name == "Science-4" then
station.comms_data.goods.battery = {quantity = 5, cost = math.random(61,77)}
elseif station_name == "Spot" then
station.comms_data.goods.software = {quantity = 5, cost = math.random(61,77)}
elseif station_name == "Tandon" then
station.comms_data.goods.robotic = {quantity = 5, cost = math.random(61,77)}
else
station.comms_data.goods.platinum = {quantity = 5, cost = math.random(65,79)}
end
end
elseif station_name == "Krak" or station_name == "Kruk" or station_name == "Krik" then
if chosen_goods < 10 then
station.comms_data.goods.platinum = {quantity = 5, cost = math.random(65,75)}
station.comms_data.goods.tritanium = {quantity = 5, cost = math.random(45,55)}
station.comms_data.goods.dilithium = {quantity = 5, cost = math.random(45,55)}
elseif chosen_goods < 20 then
station.comms_data.goods.platinum = {quantity = 5, cost = math.random(65,75)}
station.comms_data.goods.tritanium = {quantity = 5, cost = math.random(45,55)}
elseif chosen_goods < 30 then
station.comms_data.goods.platinum = {quantity = 5, cost = math.random(65,75)}
station.comms_data.goods.dilithium = {quantity = 5, cost = math.random(45,55)}
elseif chosen_goods < 40 then
station.comms_data.goods.tritanium = {quantity = 5, cost = math.random(45,55)}
station.comms_data.goods.dilithium = {quantity = 5, cost = math.random(45,55)}
elseif chosen_goods < 50 then
station.comms_data.goods.dilithium = {quantity = 5, cost = math.random(45,55)}
elseif chosen_goods < 60 then
station.comms_data.goods.platinum = {quantity = 5, cost = math.random(65,75)}
elseif chosen_goods < 70 then
station.comms_data.goods.tritanium = {quantity = 5, cost = math.random(45,55)}
elseif chosen_goods < 80 then
if station_name == "Krik" then
station.comms_data.goods.cobalt = {quantity = 5, cost = math.random(55,65)}
else
station.comms_data.goods.gold = {quantity = 5, cost = math.random(45,55)}
station.comms_data.goods.tritanium = {quantity = 5, cost = math.random(45,55)}
end
elseif chosen_goods < 90 then
if station_name == "Krik" then
station.comms_data.goods.cobalt = {quantity = 5, cost = math.random(55,65)}
station.comms_data.goods.dilithium = {quantity = 5, cost = math.random(45,55)}
else
station.comms_data.goods.gold = {quantity = 5, cost = math.random(45,55)}
station.comms_data.goods.dilithium = {quantity = 5, cost = math.random(45,55)}
end
else
if station_name == "Krik" then
station.comms_data.goods.cobalt = {quantity = 5, cost = math.random(55,65)}
station.comms_data.goods.dilithium = {quantity = 5, cost = math.random(45,55)}
else
station.comms_data.goods.gold = {quantity = 5, cost = math.random(45,55)}
end
end
local posAxisKrak = random(0,360)
local posKrak = random(10000,60000)
local negKrak = random(10000,60000)
local spreadKrak = random(4000,7000)
local negAxisKrak = posAxisKrak + 180
local xPosAngleKrak, yPosAngleKrak = vectorFromAngle(posAxisKrak, posKrak)
local posKrakEnd = random(30,70)
local negKrakEnd = random(40,80)
if station_name == "Krik" then
posKrak = random(30000,80000)
negKrak = random(20000,60000)
spreadKrak = random(5000,8000)
posKrakEnd = random(40,90)
negKrakEnd = random(30,60)
end
createRandomAlongArc(Asteroid,30+posKrakEnd, x+xPosAngleKrak, y+yPosAngleKrak, posKrak, negAxisKrak, negAxisKrak+posKrakEnd, spreadKrak)
createRandomAlongArc(VisualAsteroid,(30+posKrakEnd)*2, x+xPosAngleKrak, y+yPosAngleKrak, posKrak, negAxisKrak, negAxisKrak+posKrakEnd, spreadKrak)
local xNegAngleKrak, yNegAngleKrak = vectorFromAngle(negAxisKrak, negKrak)
createRandomAlongArc(Asteroid,30+negKrakEnd, x+xNegAngleKrak, y+yNegAngleKrak, negKrak, posAxisKrak, posAxisKrak+negKrakEnd, spreadKrak)
createRandomAlongArc(VisualAsteroid,(30+negKrakEnd)*2, x+xNegAngleKrak, y+yNegAngleKrak, negKrak, posAxisKrak, posAxisKrak+negKrakEnd, spreadKrak)
end
if station_name == "Tokra" or station_name == "Cavor" then
local what_trade = random(1,100)
if what_trade < 33 then
station.comms_data.trade.food = true
elseif what_trade > 66 then
station.comms_data.trade.medicine = true
else
station.comms_data.trade.luxury = true
end
end
return station
end
function addIndependentStations()
tSize = math.random(2,5) --tack on to region size
grid[gx][gy] = gp
gRegion = {} --grow region
table.insert(gRegion,{gx,gy})
for i=1,tSize do
adjList = getAdjacentGridLocations(gx,gy)
if #adjList < 1 then
break
end
rd = math.random(1,#adjList) --random direction to grow from adjacent list
grid[adjList[rd][1]][adjList[rd][2]] = gp
table.insert(gRegion,{adjList[rd][1],adjList[rd][2]})
end
--get list after done growing region
adjList = getAdjacentGridLocations(gx,gy)
if #adjList < 1 then
adjList = getFactionAdjacentGridLocations(gx,gy)
if #adjList < 1 then
adjList = getAllAdjacentGridLocations(gx,gy)
end
else
nextStationChoice = random(1,100)
if nextStationChoice >= 56 then
adjList = getFactionAdjacentGridLocations(gx,gy)
if #adjList < 1 then
adjList = getAllAdjacentGridLocations(gx,gy)
end
elseif nextStationChoice <= 22 then
adjList = getAllAdjacentGridLocations(gx,gy)
end
end
sri = math.random(1,#gRegion) --select station random region index
psx = brigx + (gRegion[sri][1] - (gbHigh/2))*gSize + random(-gSize/2*.95,gSize/2*.95) --place station x coordinate
psy = brigy + (gRegion[sri][2] - (gbHigh/2))*gSize + random(-gSize/2*.95,gSize/2*.95) --place station y coordinate
pStation = placeEStation(psx,psy,"RandomHumanNeutral",stationFaction)
table.insert(stationList,pStation)
gp = gp + 1 --set next station number
rn = math.random(1,#adjList) --random next station start location
gx = adjList[rn][1]
gy = adjList[rn][2]
end
function addBlackHole()
--insert a black hole
tSize = 15
grid[gx][gy] = gp
gRegion = {}
table.insert(gRegion,{gx,gy})
for i=1,tSize do
adjList = getAdjacentGridLocations(gx,gy)
if #adjList < 1 then
break
end
rd = math.random(1,#adjList)
grid[adjList[rd][1]][adjList[rd][2]] = gp
table.insert(gRegion,{adjList[rd][1],adjList[rd][2]})
end
adjList = getAdjacentGridLocations(gx,gy)
if #adjList < 1 then
adjList = getAllAdjacentGridLocations(gx,gy)
else
if random(1,100) >= 35 then
adjList = getAllAdjacentGridLocations(gx,gy)
end
end
sri = math.random(1,#gRegion)
bhx = brigx + (gRegion[sri][1] - (gbHigh/2))*gSize
bhy = brigy + (gRegion[sri][2] - (gbHigh/2))*gSize
BlackHole():setPosition(bhx,bhy)
gp = gp + 1
rn = math.random(1,#adjList)
gx = adjList[rn][1]
gy = adjList[rn][2]
end
function getAdjacentGridLocations(lx,ly)
--adjacent empty grid locations around the most recently placed item
tempGrid = {}
for i=gbLow,gbHigh do
tempGrid[i] = {}
end
tempGrid[lx][ly] = 1
ol = {}
-- check left
if lx-1 >= gbLow then
if tempGrid[lx-1][ly] == nil then
tempGrid[lx-1][ly] = 1
if grid[lx-1][ly] == nil then
table.insert(ol,{lx-1,ly})
elseif grid[lx-1][ly] == gp then
--case 1: traveling left, skip right check
getAdjacentGridLocationsSkip(1,lx-1,ly)
end
end
end
--check up
if ly-1 >= gbLow then
if tempGrid[lx][ly-1] == nil then
tempGrid[lx][ly-1] = 1
if grid[lx][ly-1] == nil then
table.insert(ol,{lx,ly-1})
elseif grid[lx][ly-1] == gp then
--case 2: traveling up, skip down check
getAdjacentGridLocationsSkip(2,lx,ly-1)
end
end
end
--check right
if lx+1 <= gbHigh then
if tempGrid[lx+1][ly] == nil then
tempGrid[lx+1][ly] = 1
if grid[lx+1][ly] == nil then
table.insert(ol,{lx+1,ly})
elseif grid[lx+1][ly] == gp then
--case 3: traveling right, skip left check
getAdjacentGridLocationsSkip(3,lx+1,ly)
end
end
end
--check down
if ly+1 <= gbHigh then
if tempGrid[lx][ly+1] == nil then
tempGrid[lx][ly+1] = 1
if grid[lx][ly+1] == nil then
table.insert(ol,{lx,ly+1})
elseif grid[lx][ly+1] == gp then
--case 4: traveling down, skip up check
getAdjacentGridLocationsSkip(4,lx,ly+1)
end
end
end
return ol
end
function getAdjacentGridLocationsSkip(dSkip,lx,ly)
--adjacent empty grid locations around the most recently placed item, skip as requested
tempGrid[lx][ly] = 1
if dSkip ~= 3 then
--check left
if lx-1 >= gbLow then
if tempGrid[lx-1][ly] == nil then
tempGrid[lx-1][ly] = 1
if grid[lx-1][ly] == nil then
table.insert(ol,{lx-1,ly})
elseif grid[lx-1][ly] == gp then
--case 1: traveling left, skip right check
getAdjacentGridLocationsSkip(1,lx-1,ly)
end
end
end
end
if dSkip ~= 4 then
--check up
if ly-1 >= gbLow then
if tempGrid[lx][ly-1] == nil then
tempGrid[lx][ly-1] = 1
if grid[lx][ly-1] == nil then
table.insert(ol,{lx,ly-1})
elseif grid[lx][ly-1] == gp then
--case 2: traveling up, skip down check
getAdjacentGridLocationsSkip(2,lx,ly-1)
end
end
end
end
if dSkip ~= 1 then
--check right