-
Notifications
You must be signed in to change notification settings - Fork 6
/
scenario_68_shakedown.lua
executable file
·5602 lines (5597 loc) · 291 KB
/
scenario_68_shakedown.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: Shakedown Cruise
-- Description: The shipyard with permission from Human Navy Command has placed a green crew on a new ship type. The mission is to evaluate the ship type Chavez along with the new crew.
---
--- Mission designed as a first time mission for new players.
--- The broad outlines of the mission are the same each time,
--- but some of the specifics vary for each mission run.
---
--- Duration: 1.5 - 2 hours to reach the choice between mission completion and continuation.
--- If you continue, add another hour or so.
---
--- Version 0
-- Type: Replayable Mission
-- Setting[Enemies]: Configures strength and/or number of enemies in this scenario
-- Enemies[Easy]: Fewer or weaker enemies
-- Enemies[Normal|Default]: Normal number or strength of enemies
-- Enemies[Hard]: More or stronger enemies
-- Enemies[Extreme]: Much stronger, many more enemies
-- Enemies[Quixotic]: Insanely strong and/or inordinately large numbers of 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")
require("cpu_ship_diversification_scenario_utility.lua")
require("generate_call_sign_scenario_utility.lua")
require("spawn_ships_scenario_utility.lua")
require("control_code_scenario_utility.lua")
--------------------
-- Initialization --
--------------------
function init()
scenario_version = "0.0.4"
ee_version = "2023.06.17"
print(string.format(" ---- Scenario: Shakedown ---- Version %s ---- Tested with EE version %s ----",scenario_version,ee_version))
print(_VERSION)
setVariations()
setConstants() --missle type names, template names and scores, deployment directions, player ship names, etc.
constructEnvironment()
mainPlot = trackFreighterPlot
pod_scanned = false
finalize_player_ship_work = false
technician_vacation = true
vacation_notification = false
primaryOrders = _("orders-comms","Evaluate Chavez class ship. Train officers. Protect ships if necessary")
secondaryOrders = ""
optionalOrders = ""
mainGMButtons()
end
function setPlayer(p)
if p == nil then
return
end
p:setTemplate("Hathcock")
p:setTypeName("Chavez")
p:setJumpDrive(false)
p:setImpulseMaxSpeed(70)
p:setCanCombatManeuver(false)
p:setRotationMaxSpeed(20) --faster spin (vs 15)
p:setAcceleration(10) --faster (vs 8)
-- Arc, Dir, Range,Cyc,Dmg
p:setBeamWeapon(0, 30, 0, 1000, 6, 6)
p:setBeamWeapon(1, 0, 0, 0, 0, 0)
p:setBeamWeapon(2, 0, 0, 0, 0, 0)
p:setBeamWeapon(3, 0, 0, 0, 0, 0)
p:setWeaponTubeCount(1)
p:setWeaponTubeDirection(0, 0)
p:setWeaponTubeExclusiveFor(0,"Homing")
p:setWeaponStorageMax("Homing", 6)
p:setWeaponStorage("Homing", 6)
p:setWeaponStorageMax("Nuke", 0)
p:setWeaponStorage("Nuke", 0)
p:setWeaponStorageMax("Mine", 0)
p:setWeaponStorage("Mine", 0)
p:setWeaponStorageMax("EMP", 0)
p:setWeaponStorage("EMP", 0)
p:setWeaponStorageMax("HVLI", 0)
p:setWeaponStorage("HVLI", 0)
p:setCanSelfDestruct(false)
p:setCanScan(false)
p:setCanHack(false)
p:setCanLaunchProbe(false)
p:setCanDock(false)
p:setRepairCrewCount(5)
p.maxRepairCrew = p:getRepairCrewCount()
p.shipScore = playerShipStats["Chavez"].strength
p.maxCargo = playerShipStats["Chavez"].cargo
p.cargo = p.maxCargo
p.initialCoolant = p:getMaxCoolant()
p:setLongRangeRadarRange(playerShipStats["Chavez"].long_range_radar)
p:setShortRangeRadarRange(playerShipStats["Chavez"].short_range_radar)
p.tractor = playerShipStats["Chavez"].tractor
p.mining = playerShipStats["Chavez"].mining
local name = tableRemoveRandom(player_ship_names)
if name ~= nil then
p:setCallSign(name)
end
if finalize_player_ship_work then
p:setJumpDrive(true)
p.max_jump_range = 25000
p.min_jump_range = 2500
p:setJumpDriveRange(comms_source.min_jump_range,comms_source.max_jump_range)
p:setJumpDriveCharge(comms_source.max_jump_range)
if p:hasPlayerAtPosition("Engineering") then
p.restart_engine_message = "restart_engine_message"
p:addCustomMessage("Engineering",p.restart_engine_message,_("msgEngineer","You took the initiative and activated minimal jump drive capability"))
end
if p:hasPlayerAtPosition("Engineering+") then
p.restart_engine_message_plus = "restart_engine_message_plus"
p:addCustomMessage("Engineering+",p.restart_engine_message_plus,_("msgEngineer","You took the initiative and activated minimal jump drive capability"))
end
if p:hasPlayerAtPosition("PowerManagement") then
p.restart_engine_message_pm = "restart_engine_message_pm"
p:addCustomMessage("PowerManagement",p.restart_engine_message_pm,_("msgPowerManagement","You took the initiative and activated minimal jump drive capability"))
end
if p:hasPlayerAtPosition("DamageControl") then
p.restart_engine_message_dmg = "restart_engine_message_dmg"
p:addCustomMessage("DamageControl",p.restart_engine_message_dmg,_("msgDamageControl","You took the initiative and activated minimal jump drive capability"))
end
p:setCanDock(true)
else
for index, system in ipairs(system_list) do
p:setSystemPower(system, .25)
p:commandSetSystemPowerRequest(system, .25)
end
end
p:addToShipLog(string.format(_("goal-shipLog","Mission: This is a shakedown cruise for %s, a %s class vessel recently launched from the shipyards of station %s. Be sure to train officers at each station. You should also protect ships in need if necessary."),p:getCallSign(),p:getTypeName(),shipyard_station:getCallSign()),"Magenta")
end
function setVariations()
if getScenarioSetting == nil then
difficulty = 1
enemy_power = 1
else
local enemy_config = {
["Easy"] = {number = .5},
["Normal"] = {number = 1},
["Hard"] = {number = 2},
["Extreme"] = {number = 3},
["Quixotic"] = {number = 5},
}
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
end
function setConstants()
fully_functional_player_ship = false
healthCheckTimerInterval = 8
healthCheckTimer = healthCheckTimerInterval
repeatExitBoundary = 100
prefix_length = 0
suffix_index = 0
system_list = {
"reactor",
"beamweapons",
"missilesystem",
"maneuver",
"impulse",
"warp",
"jumpdrive",
"frontshield",
"rearshield",
}
player_ship_names = {
"Throck",
"Thumb",
"Knight",
"Chalk",
"Strack",
"Thrust",
"Shirk",
"Flack",
"Fright",
"Clash",
"Shorn",
"Crush",
"Portent",
"Sluff",
"Trivet",
"Strive",
"Blight",
"Brink",
"Grendel",
}
rescue_freighter_names = {
"Navigator",
"Sault",
"Acavus",
"Argus",
"Adula",
"Bovic",
"Calumet",
"Deplhic",
"Edith",
"Finima",
"Golfito",
"Hydrus",
"Jindal",
"Nuria",
"Osaka",
"Quinquereme",
"Regina",
"Suavic",
"Torben",
"Vedic",
}
missile_types = {'Homing', 'Nuke', 'Mine', 'EMP', 'HVLI'}
pool_selectivity = "full"
template_pool_size = 5
ship_template = { --ordered by relative strength
["Gnat"] = {strength = 2, create = gnat},
["Lite Drone"] = {strength = 3, create = droneLite},
["Jacket Drone"] = {strength = 4, create = droneJacket},
["Ktlitan Drone"] = {strength = 4, create = stockTemplate},
["Heavy Drone"] = {strength = 5, create = droneHeavy},
["MT52 Hornet"] = {strength = 5, create = stockTemplate},
["MU52 Hornet"] = {strength = 5, create = stockTemplate},
["MV52 Hornet"] = {strength = 6, create = hornetMV52},
["Adder MK3"] = {strength = 5, create = stockTemplate},
["Adder MK4"] = {strength = 6, create = stockTemplate},
["Fighter"] = {strength = 6, create = stockTemplate},
["Ktlitan Fighter"] = {strength = 6, create = stockTemplate},
["K2 Fighter"] = {strength = 7, create = k2fighter},
["Adder MK5"] = {strength = 7, create = stockTemplate},
["WX-Lindworm"] = {strength = 7, create = stockTemplate},
["K3 Fighter"] = {strength = 8, create = k3fighter},
["Adder MK6"] = {strength = 8, create = stockTemplate},
["Ktlitan Scout"] = {strength = 8, create = stockTemplate},
["WZ-Lindworm"] = {strength = 9, create = wzLindworm},
["Adder MK7"] = {strength = 9, create = stockTemplate},
["Adder MK8"] = {strength = 10, create = stockTemplate},
["Adder MK9"] = {strength = 11, create = stockTemplate},
["Phobos R2"] = {strength = 13, create = phobosR2},
["Missile Cruiser"] = {strength = 14, create = stockTemplate},
["Waddle 5"] = {strength = 15, create = waddle5},
["Jade 5"] = {strength = 15, create = jade5},
["Phobos T3"] = {strength = 15, create = stockTemplate},
["Piranha F8"] = {strength = 15, create = stockTemplate},
["Piranha F12"] = {strength = 15, create = stockTemplate},
["Piranha F12.M"] = {strength = 16, create = stockTemplate},
["Phobos M3"] = {strength = 16, create = stockTemplate},
["Farco 3"] = {strength = 16, create = farco3},
["Farco 5"] = {strength = 16, create = farco5},
["Karnack"] = {strength = 17, create = stockTemplate},
["Gunship"] = {strength = 17, create = stockTemplate},
["Phobos T4"] = {strength = 18, create = phobosT4},
["Cruiser"] = {strength = 18, create = stockTemplate},
["Nirvana R5"] = {strength = 19, create = stockTemplate},
["Farco 8"] = {strength = 19, create = farco8},
["Nirvana R5A"] = {strength = 20, create = stockTemplate},
["Adv. Gunship"] = {strength = 20, create = stockTemplate},
["Ktlitan Worker"] = {strength = 21, create = stockTemplate},
["Farco 11"] = {strength = 21, create = farco11},
["Storm"] = {strength = 22, create = stockTemplate},
["Stalker R5"] = {strength = 22, create = stockTemplate},
["Stalker Q5"] = {strength = 22, create = stockTemplate},
["Farco 13"] = {strength = 24, create = farco13},
["Ranus U"] = {strength = 25, create = stockTemplate},
["Stalker Q7"] = {strength = 25, create = stockTemplate},
["Stalker R7"] = {strength = 25, create = stockTemplate},
["Whirlwind"] = {strength = 26, create = whirlwind},
["Adv. Striker"] = {strength = 27, create = stockTemplate},
["Elara P2"] = {strength = 28, create = stockTemplate},
["Tempest"] = {strength = 30, create = tempest},
["Strikeship"] = {strength = 30, create = stockTemplate},
["Fiend G3"] = {strength = 33, create = stockTemplate},
["Fiend G4"] = {strength = 35, create = stockTemplate},
["Cucaracha"] = {strength = 36, create = cucaracha},
["Fiend G5"] = {strength = 37, create = stockTemplate},
["Fiend G6"] = {strength = 39, create = stockTemplate},
["Predator"] = {strength = 42, create = predator},
["Ktlitan Breaker"] = {strength = 45, create = stockTemplate},
["Hurricane"] = {strength = 46, create = hurricane},
["Ktlitan Feeder"] = {strength = 48, create = stockTemplate},
["Atlantis X23"] = {strength = 50, create = stockTemplate},
["K2 Breaker"] = {strength = 55, create = k2breaker},
["Ktlitan Destroyer"] = {strength = 50, create = stockTemplate},
["Atlantis Y42"] = {strength = 60, create = atlantisY42},
["Blockade Runner"] = {strength = 65, create = stockTemplate},
["Starhammer II"] = {strength = 70, create = stockTemplate},
["Enforcer"] = {strength = 75, create = enforcer},
["Dreadnought"] = {strength = 80, create = stockTemplate},
["Starhammer III"] = {strength = 85, create = starhammerIII},
["Starhammer V"] = {strength = 90, create = starhammerV},
["Battlestation"] = {strength = 100, create = stockTemplate},
["Tyr"] = {strength = 150, create = tyr},
["Odin"] = {strength = 250, create = stockTemplate},
}
formation_delta = {
["square"] = {
x = {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,0, 0,3,-3,1, 1,3,-3,-1,-1, 3,-3,2, 2,3,-3,-2,-2, 3,-3,3, 3,-3,-3,4,0,-4, 0,4,-4, 4,-4,-4,-4,-4,-4,-4,-4,4, 4,4, 4,4, 4, 1,-1, 2,-2, 3,-3,1,-1,2,-2,3,-3,5,-5,0, 0,5, 5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,5, 5,5, 5,5, 5,5, 5, 1,-1, 2,-2, 3,-3, 4,-4,1,-1,2,-2,3,-3,4,-4},
y = {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,3,-3,0, 0,3,-3,1, 1, 3,-3,-1,-1,3,-3,2, 2, 3,-3,-2,-2,3,-3, 3,-3,0,4, 0,-4,4,-4,-4, 4, 1,-1, 2,-2, 3,-3,1,-1,2,-2,3,-3,-4,-4,-4,-4,-4,-4,4, 4,4, 4,4, 4,0, 0,5,-5,5,-5, 5,-5, 1,-1, 2,-2, 3,-3, 4,-4,1,-1,2,-2,3,-3,4,-4,-5,-5,-5,-5,-5,-5,-5,-5,5, 5,5, 5,5, 5,5, 5},
},
["hexagonal"] = {
x = {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,8,-8,4,-4, 4,-4,5,5 ,-5,-5,2, 2,-2,-2,0, 0,6, 6,-6,-6,7, 7,-7,-7,10,-10,5, 5,-5,-5,6, 6,-6,-6,7, 7,-7,-7,8, 8,-8,-8,9, 9,-9,-9,3, 3,-3,-3,1, 1,-1,-1,12,-12,6,-6, 6,-6,7,-7, 7,-7,8,-8, 8,-8,9,-9, 9,-9,10,-10,10,-10,11,-11,11,-11,4,-4, 4,-4,2,-2, 2,-2,0, 0},
y = {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,0, 0,4,-4,-4, 4,3,-3, 3,-3,4,-4, 4,-4,4,-4,2,-2, 2,-2,1,-1, 1,-1, 0, 0,5,-5, 5,-5,4,-4, 4,-4,3,-3, 3,-7,2,-2, 2,-2,1,-1, 1,-1,5,-5, 5,-5,5,-5, 5,-5, 0, 0,6, 6,-6,-6,5, 5,-5,-5,4, 4,-4,-4,3, 3,-3,-3, 2, 2,-2, -2, 1, 1,-1, -1,6, 6,-6,-6,6, 6,-6,-6,6,-6},
},
["pyramid"] = {
[1] = {
{angle = 0, distance = 0},
},
[2] = {
{angle = -1, distance = 1},
{angle = 1, distance = 1},
},
[3] = {
{angle = 0, distance = 0},
{angle = -1, distance = 1},
{angle = 1, distance = 1},
},
[4] = {
{angle = 0, distance = 0},
{angle = -1, distance = 1},
{angle = 1, distance = 1},
{angle = 0, distance = 2},
},
[5] = {
{angle = 0, distance = 0},
{angle = -1, distance = 1},
{angle = 1, distance = 1},
{angle = -2, distance = 2},
{angle = 2, distance = 2},
},
[6] = {
{angle = 0, distance = 0},
{angle = -1, distance = 1},
{angle = 1, distance = 1},
{angle = -2, distance = 2},
{angle = 2, distance = 2},
{angle = 0, distance = 2},
},
[7] = {
{angle = 0, distance = 0},
{angle = -1, distance = 1},
{angle = 1, distance = 1},
{angle = -2, distance = 2},
{angle = 2, distance = 2},
{angle = -3, distance = 3},
{angle = 3, distance = 3},
},
[8] = {
{angle = 0, distance = 0},
{angle = -1, distance = 1},
{angle = 1, distance = 1},
{angle = -2, distance = 2},
{angle = 2, distance = 2},
{angle = 0, distance = 2},
{angle = -3, distance = 3},
{angle = 3, distance = 3},
},
[9] = {
{angle = 0, distance = 0},
{angle = -1, distance = 1},
{angle = 1, distance = 1},
{angle = -2, distance = 2},
{angle = 2, distance = 2},
{angle = -3, distance = 3},
{angle = 3, distance = 3},
{angle = -4, distance = 4},
{angle = 4, distance = 4},
},
[10] = {
{angle = 0, distance = 0},
{angle = -1, distance = 1},
{angle = 1, distance = 1},
{angle = -2, distance = 2},
{angle = 2, distance = 2},
{angle = 0, distance = 2},
{angle = -3, distance = 3},
{angle = 3, distance = 3},
{angle = -2, distance = 3},
{angle = 2, distance = 3},
},
[11] = {
{angle = 0, distance = 0},
{angle = -1, distance = 1},
{angle = 1, distance = 1},
{angle = -2, distance = 2},
{angle = 2, distance = 2},
{angle = -3, distance = 3},
{angle = 3, distance = 3},
{angle = -4, distance = 4},
{angle = 4, distance = 4},
{angle = -3, distance = 4},
{angle = 3, distance = 4},
},
[12] = {
{angle = 0, distance = 0},
{angle = -1, distance = 1},
{angle = 1, distance = 1},
{angle = -2, distance = 2},
{angle = 2, distance = 2},
{angle = 0, distance = 2},
{angle = -3, distance = 3},
{angle = 3, distance = 3},
{angle = -2, distance = 3},
{angle = 2, distance = 3},
{angle = -1, distance = 3},
{angle = 1, distance = 3},
},
[13] = {
{angle = 0, distance = 0},
{angle = -1, distance = 1},
{angle = 1, distance = 1},
{angle = -2, distance = 2},
{angle = 2, distance = 2},
{angle = -3, distance = 3},
{angle = 3, distance = 3},
{angle = 0, distance = 3},
{angle = -2, distance = 4},
{angle = 2, distance = 4},
{angle = -1, distance = 5},
{angle = 1, distance = 5},
{angle = 0, distance = 6},
},
[14] = {
{angle = 0, distance = 0},
{angle = -1, distance = 1},
{angle = 1, distance = 1},
{angle = -2, distance = 2},
{angle = 2, distance = 2},
{angle = 0, distance = 2},
{angle = -3, distance = 3},
{angle = 3, distance = 3},
{angle = 0, distance = 4},
{angle = -2, distance = 4},
{angle = 2, distance = 4},
{angle = -1, distance = 5},
{angle = 1, distance = 5},
{angle = 0, distance = 6},
},
[15] = {
{angle = 0, distance = 0},
{angle = -1, distance = 1},
{angle = 1, distance = 1},
{angle = -2, distance = 2},
{angle = 2, distance = 2},
{angle = 0, distance = 2},
{angle = -3, distance = 3},
{angle = 3, distance = 3},
{angle = 0, distance = 3},
{angle = 0, distance = 4},
{angle = -2, distance = 4},
{angle = 2, distance = 4},
{angle = -1, distance = 5},
{angle = 1, distance = 5},
{angle = 0, distance = 6},
},
},
}
max_pyramid_tier = 15
playerShipStats = {
["MP52 Hornet"] = { strength = 7, cargo = 3, distance = 100, long_range_radar = 18000, short_range_radar = 4000, tractor = false, mining = false },
["Piranha"] = { strength = 16, cargo = 8, distance = 200, long_range_radar = 25000, short_range_radar = 6000, tractor = false, mining = false },
["Flavia P.Falcon"] = { strength = 13, cargo = 15, distance = 200, long_range_radar = 40000, short_range_radar = 5000, tractor = true, mining = true },
["Phobos M3P"] = { strength = 19, cargo = 10, distance = 200, long_range_radar = 25000, short_range_radar = 5000, tractor = true, mining = false },
["Atlantis"] = { strength = 52, cargo = 6, distance = 400, long_range_radar = 30000, short_range_radar = 5000, tractor = true, mining = true },
["Player Cruiser"] = { strength = 40, cargo = 6, distance = 400, long_range_radar = 30000, short_range_radar = 5000, tractor = false, mining = false },
["Player Missile Cr."] = { strength = 45, cargo = 8, distance = 200, long_range_radar = 35000, short_range_radar = 6000, tractor = false, mining = false },
["Player Fighter"] = { strength = 7, cargo = 3, distance = 100, long_range_radar = 15000, short_range_radar = 4500, tractor = false, mining = false },
["Benedict"] = { strength = 10, cargo = 9, distance = 400, long_range_radar = 30000, short_range_radar = 5000, tractor = true, mining = true },
["Kiriya"] = { strength = 10, cargo = 9, distance = 400, long_range_radar = 35000, short_range_radar = 5000, tractor = true, mining = true },
["Striker"] = { strength = 8, cargo = 4, distance = 200, long_range_radar = 35000, short_range_radar = 5000, tractor = false, mining = false },
["ZX-Lindworm"] = { strength = 8, cargo = 3, distance = 100, long_range_radar = 18000, short_range_radar = 5500, tractor = false, mining = false },
["Repulse"] = { strength = 14, cargo = 12, distance = 200, long_range_radar = 38000, short_range_radar = 5000, tractor = true, mining = false },
["Ender"] = { strength = 100, cargo = 20, distance = 2000,long_range_radar = 45000, short_range_radar = 7000, tractor = true, mining = false },
["Nautilus"] = { strength = 12, cargo = 7, distance = 200, long_range_radar = 22000, short_range_radar = 4000, tractor = false, mining = false },
["Hathcock"] = { strength = 30, cargo = 6, distance = 200, long_range_radar = 35000, short_range_radar = 6000, tractor = false, mining = true },
["Maverick"] = { strength = 45, cargo = 5, distance = 200, long_range_radar = 20000, short_range_radar = 4000, tractor = false, mining = true },
["Crucible"] = { strength = 45, cargo = 5, distance = 200, long_range_radar = 20000, short_range_radar = 6000, tractor = false, mining = false },
["Proto-Atlantis"] = { strength = 40, cargo = 4, distance = 400, long_range_radar = 30000, short_range_radar = 4500, tractor = false, mining = true },
["Stricken"] = { strength = 40, cargo = 4, distance = 200, long_range_radar = 20000, short_range_radar = 4000, tractor = false, mining = false },
["Surkov"] = { strength = 35, cargo = 6, distance = 200, long_range_radar = 35000, short_range_radar = 6000, tractor = false, mining = false },
["Redhook"] = { strength = 11, cargo = 8, distance = 200, long_range_radar = 20000, short_range_radar = 6000, tractor = false, mining = false },
["Pacu"] = { strength = 18, cargo = 7, distance = 200, long_range_radar = 20000, short_range_radar = 6000, tractor = false, mining = false },
["Phobos T2"] = { strength = 19, cargo = 9, distance = 200, long_range_radar = 25000, short_range_radar = 5000, tractor = true, mining = false },
["Wombat"] = { strength = 13, cargo = 3, distance = 100, long_range_radar = 18000, short_range_radar = 6000, tractor = false, mining = false },
["Holmes"] = { strength = 35, cargo = 6, distance = 200, long_range_radar = 35000, short_range_radar = 4000, tractor = true, mining = false },
["Focus"] = { strength = 35, cargo = 4, distance = 200, long_range_radar = 32000, short_range_radar = 5000, tractor = false, mining = true },
["Flavia 2C"] = { strength = 25, cargo = 12, distance = 200, long_range_radar = 30000, short_range_radar = 5000, tractor = false, mining = true },
["Destroyer IV"] = { strength = 25, cargo = 5, distance = 400, long_range_radar = 30000, short_range_radar = 5000, tractor = false, mining = false },
["Destroyer III"] = { strength = 25, cargo = 7, distance = 200, long_range_radar = 30000, short_range_radar = 5000, tractor = false, mining = false },
["MX-Lindworm"] = { strength = 10, cargo = 3, distance = 100, long_range_radar = 30000, short_range_radar = 5000, tractor = false, mining = false },
["Striker LX"] = { strength = 16, cargo = 4, distance = 200, long_range_radar = 20000, short_range_radar = 4000, tractor = false, mining = false },
["Maverick XP"] = { strength = 23, cargo = 5, distance = 200, long_range_radar = 25000, short_range_radar = 7000, tractor = true, mining = false },
["Era"] = { strength = 14, cargo = 14, distance = 200, long_range_radar = 50000, short_range_radar = 5000, tractor = true, mining = true },
["Squid"] = { strength = 14, cargo = 8, distance = 200, long_range_radar = 25000, short_range_radar = 5000, tractor = false, mining = false },
["Atlantis II"] = { strength = 60, cargo = 6, distance = 400, long_range_radar = 30000, short_range_radar = 5000, tractor = true, mining = true },
["Chavez"] = { strength = 8, cargo = 6, distance = 200, long_range_radar = 20000, short_range_radar = 4500, tractor = true, mining = true },
}
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"}
vapor_goods = {"gold pressed latinum","unobtanium","eludium","impossibrium"}
show_player_info = true
show_only_player_name = true
info_choice = 0
info_choice_max = 5
enemy_reverts = {}
spelunk_where = false
spelunk_what = false
spelunk_danger = false
spelunk_why = false
end
function constructEnvironment()
friendly_neutral_stations = {}
-- Spawn shipyard station (will be placed later)
shipyard_station = placeStationPlus(100000,100000,"RandomHumanNeutral","Human Navy","Large Station")
shipyard_station.name = shipyard_station:getCallSign()
-- Spawn player
local p = PlayerSpaceship():setTemplate("Hathcock")
p.pidx = 1
setPlayer(p)
allowNewPlayerShips(false)
p:onDestruction(playerDestroyed)
-- Spawn freighter to be rescued
rescue_angle = random(0,360)
rescue_distance = random(12000,18000)
local rf_x, rf_y = vectorFromAngleNorth(rescue_angle,rescue_distance)
rescue_freighter = CpuShip():setTemplate("Fuel Freighter 3"):setCallSign(tableRemoveRandom(rescue_freighter_names))
rescue_freighter:setPosition(rf_x, rf_y):setFaction("Human Navy"):setScanned(true):setCommsScript(""):setCommsFunction(commsShip)
rescue_freighter.name = rescue_freighter:getCallSign()
rescue_freighter.timer = 90
rescue_freighter.distance_from_player = distance(p,rescue_freighter)
rescue_freighter.contacted_by_player = false
-- Spawn station where freighter is headed
integral_offset = random(50,100)
integral_angle = (rescue_angle + integral_offset) % 360
integral_distance = random(22000,30000)
local is_x, is_y = vectorFromAngleNorth(integral_angle,integral_distance)
integral_station = placeStationPlus(is_x,is_y,"RandomHumanNeutral","Independent","Medium Station")
table.insert(friendly_neutral_stations,integral_station)
rescue_freighter:orderDock(integral_station)
rescue_freighter.mission = "dock with integral station"
-- local current_order = comms_target:getOrder()
--Possible order strings returned:
--Roaming
--Fly towards
--Attack
--Stand Ground
--Idle
--Defend Location
--Defend Target
--Fly Formation (?)
--Fly towards (ignore all)
--Dock
--[[
if current_order == "Attack" or current_order == "Dock" or current_order == "Defend Target" then
local original_target = comms_target:getOrderTarget()
if taunt_diagnostic then print("Target of orders before taunt:",original_target,original_target:getCallSign()) end
comms_target.original_target = original_target
end
--]]
-- Place shipyard station
local ss_x, ss_y = vectorFromAngleNorth((rescue_angle + 120) % 360,30000)
shipyard_station:setPosition(ss_x, ss_y)
shipyard_station.comms_data.weapon_available.Homing = true
shipyard_station.comms_data.weapon_cost = {Homing = math.random(2,4), HVLI = math.random(1,3), Mine = math.random(2,5), Nuke = 12, EMP = 9}
table.insert(friendly_neutral_stations,shipyard_station)
-- add a decorative planet
local planet_list = {
{
name = {"Biju","Aldea","Bersallis"},
texture = {
surface = "planets/gas-1.png"
},
},
{
name = {"Farius Prime","Deneb","Mordan"},
texture = {
surface = "planets/gas-2.png"
},
},
{
name = {"Kepler-7b","Alpha Omicron","Nelvana"},
texture = {
surface = "planets/gas-3.png"
},
},
{
name = {"Alderaan","Dagobah","Dantooine","Rigel"},
color = {
red = random(0,0.2),
green = random(0,0.2),
blue = random(0.8,1)
},
texture = {
surface = "planets/planet-1.png",
cloud = "planets/clouds-1.png",
atmosphere = "planets/atmosphere.png"
},
},
{
name = {"Pahvo","Penthara","Scalos"},
color = {
red = random(0,0.2),
green = random(0,0.2),
blue = random(0.8,1)
},
texture = {
surface = "planets/planet-4.png",
cloud = "planets/clouds-3.png",
atmosphere = "planets/atmosphere.png"
},
},
{
name = {"Tanuga","Vacca","Terlina","Timor"},
color = {
red = random(0,0.2),
green = random(0,0.2),
blue = random(0.8,1)
},
texture = {
surface = "planets/planet-5.png",
cloud = "planets/clouds-2.png",
atmosphere = "planets/atmosphere.png"
},
},
}
local selected_planet = tableRemoveRandom(planet_list)
local planet_x, planet_y = vectorFromAngleNorth(rescue_angle + random(345,355),random(40000,50000))
deco_planet = Planet():setPlanetRadius(8000):setPosition(planet_x,planet_y)
deco_planet:setCallSign(selected_planet.name[math.random(1,#selected_planet.name)])
deco_planet:setPlanetSurfaceTexture(selected_planet.texture.surface)
if selected_planet.texture.atmosphere ~= nil then
deco_planet:setPlanetAtmosphereTexture(selected_planet.texture.atmosphere)
end
if selected_planet.texture.cloud ~= nil then
deco_planet:setPlanetCloudTexture(selected_planet.texture.cloud)
end
if selected_planet.color ~= nil then
deco_planet:setPlanetAtmosphereColor(selected_planet.color.red, selected_planet.color.green, selected_planet.color.blue)
end
deco_planet:setAxialRotationTime(random(350,500)):setDistanceFromMovementPlane(-2500)
-- Asteroids between integral and shipyard stations
local afc_x = (is_x + ss_x) / 2
local afc_y = (is_y + ss_y) / 2
afc_x = afc_x + random(-5000,5000)
afc_y = afc_y + random(-5000,5000)
local max_dist = math.min(distance(shipyard_station,afc_x,afc_y),distance(integral_station,afc_x,afc_y))
trav_asteroids = placeRandomListAroundPoint(Asteroid, math.random(40,75), 500, max_dist*.8, afc_x, afc_y)
for i,ast in ipairs(trav_asteroids) do
local size = random(3,150)+random(3,150)+random(3,150)
ast:setSize(size)
local ax, ay = ast:getPosition()
local angle = random(0,360)
local v_size = random(3,150)+random(3,150)+random(3,150)
local vx, vy = vectorFromAngleNorth(angle,random(size,size + v_size + 100))
VisualAsteroid():setSize(v_size):setPosition(ax + vx, ay + vy)
angle = (angle + random(120,240)) % 360
v_size = random(3,150)+random(3,150)+random(3,150)
local vx, vy = vectorFromAngleNorth(angle,random(size,size + v_size + 100))
VisualAsteroid():setSize(v_size):setPosition(ax + vx, ay + vy)
end
asteroid_station = placeStationPlus(afc_x,afc_y,"RandomHumanNeutral","Independent","Small Station")
table.insert(friendly_neutral_stations,asteroid_station)
if not integral_station:getRestocksScanProbes() and
not shipyard_station:getRestocksScanProbes() and
not asteroid_station:getRestocksScanProbes() then
shipyard_station:setRestocksScanProbes(true)
end
if not integral_station:getSharesEnergyWithDocked() and
not shipyard_station:getSharesEnergyWithDocked() and
not asteroid_station:getSharesEnergyWithDocked() then
shipyard_station:setSharesEnergyWithDocked(true)
end
if not integral_station:getRepairDocked() and
not shipyard_station:getRepairDocked() and
not asteroid_station:getRepairDocked() then
shipyard_station:setRepairDocked(true)
end
-- Pirate Kraylor pirate station
primary_pirate_angle = angleFromVectorNorth(ss_x, ss_y, is_x, is_y)
local secondary_pirate_angle = primary_pirate_angle + random(-25,25)
if secondary_pirate_angle > 360 then
secondary_pirate_angle = secondary_pirate_angle - 360
end
if secondary_pirate_angle < 0 then
secondary_pirate_angle = secondary_pirate_angle + 360
end
local pirate_base_distance = random(50000,80000)
local pb_x, pb_y = vectorFromAngleNorth(secondary_pirate_angle,pirate_base_distance)
pb_x = pb_x + ss_x
pb_y = pb_y + ss_y
pirate_station = placeStationPlus(pb_x, pb_y,"Sinister","Kraylor","Medium Station")
pirate_station.name = pirate_station:getCallSign()
-- Pirate base defense fleet
pirate_base_defense_fleet = {}
local f_space = random(500,1000)
local position_index = 1
local enemy = CpuShip():setTemplate("Starhammer II"):setFaction("Kraylor")
enemy:setCallSign(generateCallSign(nil,"Kraylor"))
enemy:setTypeName("Starhammer IX")
enemy:setImpulseMaxSpeed(75) --faster impulse (vs 30)
enemy:setRotationMaxSpeed(10) -- up from default of 6
enemy:setBeamWeapon(2, 90, 200, 1500, 6, 8)
enemy:setBeamWeapon(3, 90, 160, 1500, 6, 8)
enemy:weaponTubeDisallowMissle(0,"Nuke")
enemy:setWeaponStorageMax("Homing",16) --more (vs 4)
enemy:setWeaponStorage("Homing", 16)
enemy:setWeaponStorageMax("EMP",6) --more (vs 2)
enemy:setWeaponStorage("EMP", 6)
enemy:setWeaponStorageMax("Nuke",4) --more (vs 0)
enemy:setWeaponStorage("Nuke", 4)
enemy:setPosition(pb_x + formation_delta.square.x[position_index]*f_space,pb_y + formation_delta.square.y[position_index]*f_space)
enemy:orderDefendTarget(pirate_station):setCommsScript(""):setCommsFunction(commsShip)
table.insert(pirate_base_defense_fleet,enemy)
for i=1,1+(enemy_power*2) do
position_index = position_index + 1
enemy = CpuShip():setTemplate("MT52 Hornet"):setFaction("Kraylor")
enemy:setCallSign(generateCallSign(nil,"Kraylor"))
enemy:setPosition(pb_x + formation_delta.square.x[position_index]*f_space,pb_y + formation_delta.square.y[position_index]*f_space)
enemy:orderDefendTarget(pirate_station):setCommsScript(""):setCommsFunction(commsShip)
table.insert(pirate_base_defense_fleet,enemy)
position_index = position_index + 1
enemy = CpuShip():setTemplate("MU52 Hornet"):setFaction("Kraylor")
enemy:setCallSign(generateCallSign(nil,"Kraylor"))
enemy:setPosition(pb_x + formation_delta.square.x[position_index]*f_space,pb_y + formation_delta.square.y[position_index]*f_space)
enemy:orderDefendTarget(pirate_station):setCommsScript(""):setCommsFunction(commsShip)
table.insert(pirate_base_defense_fleet,enemy)
position_index = position_index + 1
enemy = CpuShip():setTemplate("Adder MK9"):setFaction("Kraylor")
enemy:setCallSign(generateCallSign(nil,"Kraylor"))
enemy:setPosition(pb_x + formation_delta.square.x[position_index]*f_space,pb_y + formation_delta.square.y[position_index]*f_space)
enemy:orderDefendTarget(pirate_station):setCommsScript(""):setCommsFunction(commsShip)
table.insert(pirate_base_defense_fleet,enemy)
position_index = position_index + 1
enemy = CpuShip():setTemplate("Phobos T3"):setFaction("Kraylor")
enemy:setCallSign(generateCallSign(nil,"Kraylor"))
enemy:setPosition(pb_x + formation_delta.square.x[position_index]*f_space,pb_y + formation_delta.square.y[position_index]*f_space)
enemy:orderDefendTarget(pirate_station):setCommsScript(""):setCommsFunction(commsShip)
table.insert(pirate_base_defense_fleet,enemy)
position_index = position_index + 1
enemy = CpuShip():setTemplate("Elara P2"):setFaction("Kraylor")
enemy:setCallSign(generateCallSign(nil,"Kraylor"))
enemy:setPosition(pb_x + formation_delta.square.x[position_index]*f_space,pb_y + formation_delta.square.y[position_index]*f_space)
enemy:orderDefendTarget(pirate_station):setCommsScript(""):setCommsFunction(commsShip)
table.insert(pirate_base_defense_fleet,enemy)
end
-- Spawn nebulae
local cn_x, cn_y = vectorFromAngleNorth(secondary_pirate_angle,pirate_base_distance + 1000)
cn_x = cn_x + ss_x
cn_y = cn_y + ss_y
Nebula():setPosition(cn_x,cn_y)
local ec_angle = random(0,360)
local ec_x, ec_y = vectorFromAngleNorth(ec_angle,random(7000,9000))
Nebula():setPosition(cn_x+ec_x,cn_y+ec_y)
ec_x, ec_y = vectorFromAngleNorth((ec_angle + random(140,210))%360,random(7000,9000))
Nebula():setPosition(cn_x+ec_x,cn_y+ec_y)
nebula_band = random(10000,40000)
local start_arc = secondary_pirate_angle - random(60,90)
if start_arc < 360 then
start_arc = start_arc + 360
end
if start_arc > 360 then
start_arc = start_arc - 360
end
local finish_arc = (secondary_pirate_angle + random(60,90))%360
local neb_blob_count = math.random(6,14)
local neb_list = createRandomAlongArc(Nebula,neb_blob_count,is_x,is_y,pirate_base_distance+distance(integral_station,shipyard_station)-nebula_band/2,start_arc,finish_arc,nebula_band)
full_neb_list = {}
for i=1,neb_blob_count do
table.insert(full_neb_list,neb_list[i])
local size_choice = math.random(1,3)
if size_choice > 1 then
local nx, ny = neb_list[i]:getPosition()
ec_angle = random(0,360)
ec_x, ec_y = vectorFromAngleNorth(ec_angle,random(7000,9000))
table.insert(full_neb_list,Nebula():setPosition(nx+ec_x,ny+ec_y))
if size_choice > 2 then
ec_x, ec_y = vectorFromAngleNorth((ec_angle + random(140,210))%360,random(7000,9000))
table.insert(full_neb_list,Nebula():setPosition(nx+ec_x,ny+ec_y))
end
end
end
local station_neb = tableRemoveRandom(full_neb_list)
local snx, sny = station_neb:getPosition()
nebula_station = placeStationPlus(snx, sny,"RandomHumanNeutral","Independent")
table.insert(friendly_neutral_stations,nebula_station)
local inside_list = createRandomAlongArc(Asteroid,2,is_x,is_y,pirate_base_distance+distance(integral_station,shipyard_station)-(nebula_band)/2,start_arc,finish_arc,nebula_band)
for i,ast in ipairs(inside_list) do
local ax, ay = ast:getPosition()
local angle = random(0,360)
local v_size = random(3,150)+random(3,150)+random(3,150)
local size = ast:getSize()
local vx, vy = vectorFromAngleNorth(angle,random(size,size + v_size + 100))
VisualAsteroid():setSize(v_size):setPosition(ax + vx, ay + vy)
angle = (angle + random(120,240)) % 360
v_size = random(3,150)+random(3,150)+random(3,150)
local vx, vy = vectorFromAngleNorth(angle,random(size,size + v_size + 100))
VisualAsteroid():setSize(v_size):setPosition(ax + vx, ay + vy)
end
snx, sny = inside_list[1]:getPosition()
inside_list[1]:destroy()
inside_human_station = placeStationPlus(snx, sny,"RandomHumanNeutral","Human Navy")
table.insert(friendly_neutral_stations,inside_human_station)
snx, sny = inside_list[2]:getPosition()
inside_list[2]:destroy()
inside_independent_station = placeStationPlus(snx, sny,"RandomHumanNeutral","Independent")
table.insert(friendly_neutral_stations,inside_independent_station)
local outside_list = createRandomAlongArc(Asteroid,5,is_x,is_y,pirate_base_distance+distance(integral_station,shipyard_station)-(nebula_band)/2,finish_arc,start_arc,nebula_band)
outside_stations = {}
for index, out_asteroid in ipairs(outside_list) do
local ax, ay = out_asteroid:getPosition()
local angle = random(0,360)
local v_size = random(3,150)+random(3,150)+random(3,150)
local size = out_asteroid:getSize()
local vx, vy = vectorFromAngleNorth(angle,random(size,size + v_size + 100))
VisualAsteroid():setSize(v_size):setPosition(ax + vx, ay + vy)
angle = (angle + random(120,240)) % 360
v_size = random(3,150)+random(3,150)+random(3,150)
local vx, vy = vectorFromAngleNorth(angle,random(size,size + v_size + 100))
VisualAsteroid():setSize(v_size):setPosition(ax + vx, ay + vy)
snx, sny = out_asteroid:getPosition()
out_asteroid:destroy()
local station_faction = "Independent"
if random(1,5) <= 1 then
station_faction = "Human Navy"
end
local outside_station = placeStationPlus(snx, sny,"RandomHumanNeutral",station_faction)
table.insert(friendly_neutral_stations,outside_station)
table.insert(outside_stations,outside_station)
end
local scatter_list = createRandomAlongArc(Asteroid,math.random(50,200),is_x,is_y,pirate_base_distance+distance(integral_station,shipyard_station)-(nebula_band+5000)/2,start_arc,finish_arc,nebula_band+5000)
for index, scatter in ipairs(scatter_list) do
local size = random(1,100)
for i=1,math.random(1,5) do
size = size + random(3,500)
end
scatter:setSize(size)
local ax, ay = scatter:getPosition()
local angle = random(0,360)
local v_size = random(3,150)+random(3,150)+random(3,150)
local vx, vy = vectorFromAngleNorth(angle,random(size,size + v_size + 100))
VisualAsteroid():setSize(v_size):setPosition(ax + vx, ay + vy)
angle = (angle + random(120,240)) % 360
v_size = random(3,150)+random(3,150)+random(3,150)
local vx, vy = vectorFromAngleNorth(angle,random(size,size + v_size + 100))
VisualAsteroid():setSize(v_size):setPosition(ax + vx, ay + vy)
end
end
-- Main plot functions
function playerDestroyed(self,instigator)
globalMessage(_("msgMainscreen","Either the ship or the crew is not quite ready yet"))
victory("Kraylor")
end
function trackFreighterPlot(delta)
local start_rescue = false
local p = getPlayerShip(-1)
if p ~= nil and p:isValid() then
if p.tracking_message == nil then
p:addToShipLog(string.format(_("goal-shipLog","You've been tracking the friendly freighter, %s, as part of your training exercise"),rescue_freighter:getCallSign()),"Magenta")
p.tracking_message = "sent"
end
if distance(p,0,0) > 1000 then
start_rescue = true
end
if distance(p,rescue_freighter) > (rescue_freighter.distance_from_player + 1000) then
start_rescue = true
end
end
rescue_freighter.timer = rescue_freighter.timer - delta
if rescue_freighter.timer < 0 then
start_rescue = true
end
if start_rescue or rescue_freighter.contacted_by_player then
mainPlot = rescueFreighterPlot
end
end
function rescueFreighterPlot(delta)
if rescue_freighter_pirates == nil then
rescue_freighter_pirates = {}
local rfp_angle = (rescue_angle + integral_offset / 2) % 360
local rfp_distance = (rescue_distance + integral_distance) / 2
local ef_x, ef_y = vectorFromAngleNorth(rfp_angle,rfp_distance)
local f_space = random(500,1000)
local position_index = 1
local enemy = CpuShip():setTemplate("MT52 Hornet"):setFaction("Kraylor")
enemy:setCallSign(generateCallSign(nil,"Kraylor"))
enemy:setPosition(ef_x + formation_delta.square.x[position_index]*f_space,ef_y + formation_delta.square.y[position_index]*f_space)
enemy:orderRoaming():setCommsScript(""):setCommsFunction(commsShip)
table.insert(rescue_freighter_pirates,enemy)
position_index = position_index + 1
enemy = CpuShip():setTemplate("MT52 Hornet"):setFaction("Kraylor")
enemy:setCallSign(generateCallSign(nil,"Kraylor"))
enemy:setPosition(ef_x + formation_delta.square.x[position_index]*f_space,ef_y + formation_delta.square.y[position_index]*f_space)
enemy:orderRoaming():setCommsScript(""):setCommsFunction(commsShip)
table.insert(rescue_freighter_pirates,enemy)
position_index = position_index + 1
enemy = CpuShip():setTemplate("Adder MK5"):setFaction("Kraylor")
enemy:setCallSign(generateCallSign(nil,"Kraylor"))
enemy:setPosition(ef_x + formation_delta.square.x[position_index]*f_space,ef_y + formation_delta.square.y[position_index]*f_space)
enemy:orderRoaming():setCommsScript(""):setCommsFunction(commsShip)
table.insert(rescue_freighter_pirates,enemy)
if enemy_power >= 1 then
position_index = position_index + 1
enemy = CpuShip():setTemplate("MU52 Hornet"):setFaction("Kraylor")
enemy:setCallSign(generateCallSign(nil,"Kraylor"))
enemy:setPosition(ef_x + formation_delta.square.x[position_index]*f_space,ef_y + formation_delta.square.y[position_index]*f_space)
enemy:orderRoaming():setCommsScript(""):setCommsFunction(commsShip)
table.insert(rescue_freighter_pirates,enemy)
end
if enemy_power >= 2 then
position_index = position_index + 1
enemy = CpuShip():setTemplate("MU52 Hornet"):setFaction("Kraylor")
enemy:setCallSign(generateCallSign(nil,"Kraylor"))
enemy:setPosition(ef_x + formation_delta.square.x[position_index]*f_space,ef_y + formation_delta.square.y[position_index]*f_space)
enemy:orderRoaming():setCommsScript(""):setCommsFunction(commsShip)
table.insert(rescue_freighter_pirates,enemy)
end
rescue_freighter.agree_to_rescue = false
if not rescue_freighter.contacted_by_player then
local p = getPlayerShip(-1)
if p ~= nil and p:isValid() then
rescue_freighter:sendCommsMessage(p,string.format(_("goal-incCall","[Automated Emergency System] Please contact %s as soon as possible"),rescue_freighter:getCallSign()))
end
end
end
if rescue_freighter ~= nil and rescue_freighter:isValid() then
if rescue_freighter.agree_to_rescue then
transportPlot = plotTransport
for index, enemy in ipairs(rescue_freighter_pirates) do
if enemy ~= nil and enemy:isValid() then
enemy:setScanned(true)
end
end
local shield_freq = rescue_freighter_pirates[3]:getShieldsFrequency()
local adder_name = rescue_freighter_pirates[3]:getCallSign()
local p = getPlayerShip(-1)
if p ~= nil and p:isValid() then
if p.science_tactical_data_message == nil then
--check freq for nil, give players opportunity to undo a command to the freighter to go to a waypoint
if shield_freq ~= nil and adder_name ~= nil then
local tactical_frequency_message = string.format(_("msgScience&Operations"," Now that %s has provided detailed scan data on the Kraylor, you can help improve ship combat performance by providing beam and shield frequency data to the weapons officer.\n For example, %s, the Kraylor Adder MK5 has its shields tuned to %i THz (terahertz), the lowest and reddest part of the 'Damage with Your Beams' graph.\n You should tell the weapons officer to adjust beams to around %i THz, closer to the highest and greenest part of the graph, to maximize beam damage against %s. The inverted caret (^) marks your ship's current beam frequency"),rescue_freighter:getCallSign(),adder_name,shield_freq*20+400,(shield_freq + 10)%20*20+400,adder_name)
if p:hasPlayerAtPosition("Science") then
p.tactical_frequency_message = "tactical_frequency_message"
p:addCustomMessage("Science",p.tactical_frequency_message,tactical_frequency_message)
end
if p:hasPlayerAtPosition("Operations") then
p.tactical_frequency_message_ops = "tactical_frequency_message_ops"
p:addCustomMessage("Operations",p.tactical_frequency_message_ops,tactical_frequency_message)
end
end
p.science_tactical_data_message = "sent"
end
if p.weapons_beam_adjust_message == nil then
if p:hasPlayerAtPosition("Weapons") then
p.adjust_beam_frequency = "adjust_beam_frequency"
p:addCustomMessage("Weapons",p.adjust_beam_frequency,_("msgWeapons","The science officer *may* ask you to adjust the beam frequency to maximize damage against one or more of the Kraylor enemy ships. The button just above the shield toggle button in the lower right hand corner adjusts the beam frequency. The buttons below the shield toggle button deal with the shield frequency.\n\n*Important*\nThe shields must remain down while they are being calibrated. This makes the ship more vulnerable to attack during shield calibration."))
end
if p:hasPlayerAtPosition("Tactical") then
p.adjust_beam_frequency_tac = "adjust_beam_frequency_tac"
p:addCustomMessage("Tactical",p.adjust_beam_frequency_tac,_("msgTactical","The science officer *may* ask you to adjust the beam frequency to maximize damage against one or more of the Kraylor enemy ships. The button along the bottom edge just to the right of the 'BEAMS' banner adjusts the beam frequency."))
end
p.weapons_beam_adjust_message = "sent"
end
if p.low_power_test_message == nil then
local low_power = true
for index, system in ipairs(system_list) do
if p:getSystemPower(system) > .25 then
low_power = false
break
end
end
if low_power then
p.low_power_test_message = "sent"
local power_message = _("msgEngineer&Engineer+&PowerManagement","The engineering technicians just completed a 1/4 power test diagnostic suite, so all systems are still at low power. If you are about to enter combat, you probably want to raise all power levels to at least 100%. In combat, systems like engines, shields and weapons may need more power and correspondingly more coolant.\n\nWill set all systems to 100% power upon acknowledgement of this message.")
if p:hasPlayerAtPosition("Engineering") then
p.power_message = "power_message"
p:addCustomMessageWithCallback("Engineering",p.power_message,power_message,function()
string.format("") --need global context for serious proton
for index, system in ipairs(system_list) do
p:commandSetSystemPowerRequest(system, 1)
end
end)
end
if p:hasPlayerAtPosition("Engineering+") then
p.power_message_plus = "power_message_plus"
p:addCustomMessageWithCallback("Engineering+",p.power_message_plus,power_message,function()
string.format("") --need global context for serious proton
for index, system in ipairs(system_list) do
p:commandSetSystemPowerRequest(system, 1)
end
end)
end
if p:hasPlayerAtPosition("PowerManagement") then
p.power_message_pm = "power_message_pm"
p:addCustomMessageWithCallback("PowerManagement",p.power_message_pm,power_message,function()
string.format("") --need global context for serious proton
for index, system in ipairs(system_list) do
p:commandSetSystemPowerRequest(system, 1)
end
end)
end