-
Notifications
You must be signed in to change notification settings - Fork 6
/
scenario_45_rescue.lua
2023 lines (1958 loc) · 93.4 KB
/
scenario_45_rescue.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: Rescue Us!
-- Description: Rescue people off a research station near a star that is going to go nova. GM controls the spawning of enemies and starting the nova countdown on the GM screen.
---
--- May be configured to run with one to six player ships.
---
--- Version 1
-- Type: Mission
-- Author: Kilted Klingon, Xansta
-- Setting[Players]: Determine the number of player ships that will participate in this scenario. The default is 1 Atlantis
-- Players[One|Default]: One player ship Excalibur, Atlantis class
-- Players[Two]: Two player ships: Excalibur (Atlantis), Gyrefalcon (Flavia P. Falcon)
-- Players[Three]: Three player ships: Excalibur (Atlantis), Gyrefalcon (Flavia P. Falcon), Terrex (Repulse)
-- Players[Four]: Four player ships: Excalibur, Discovery (both Atlantis), Gyrefalcon, Kestrel (both Flavia P. Falcon)
-- Players[Five]: Five player ships: Excalibur, Discovery (both Atlantis), Gyrefalcon, Kestrel (both Flavia P. Falcon), Terrex (Repulse)
-- Players[Six]: Six player ships: Excalibur, Discovery (both Atlantis), Gyrefalcon, Kestrel (both Flavia P. Falcon), Terrex, Endeavor (Repulse)
-- Setting[FTL]: Are warp drives bolted on to the player ships? Default: bolt a warp drive onto each player ship
-- FTL[Warp|Default]: A warp drive will be installed on each player ship
-- FTL[Stock]: The stock drive (warp, jump, etc.) will be what's on each player ship
-- Setting[Capacity]: Determines the safe haven capacity. Default: Enough
-- Capacity[Enough|Default]: There is just enough safe haven capacity to rescue everyone
-- Capacity[Excess]: There is more than enough capacity to rescue everyone
-- Setting[Calculating]: Determines if the numbers (evacuees, capacities, etc.) are round for easy planning or not.
-- Calculating[Round|Default]: People numbers (evacuees, capacities, etc.) are evenly divisible by 5 or 10
-- Calculating[Spiky]: People numbers (evacuees, capacities, etc.) vary and may not be evenly divisible
-- Setting[Beams]: Sets the player's beam weapons characteristics
-- Beams[Normal|Default]: Player ships have normal beam capability
-- Beams[Faster]: Player ships' beam weapons recharge faster between shots
-- Beams[Stronger]: Player ships' beam weapons deliver more damage
-- Beams[Faster and Stronger]: Player ships' beam weapons recharge faster and deliver more damage
-- Version History Summary:
-- see dev notebook for details, but this is a sparse summary of the versions
-- v 1.4: fix stats that print from GM screen button
-- v 1.3: selectable number of player ships and other configuration choices
-- v 1.2: retailored to a 3 ship configuration explicitly for Orlando Exec event
-- v 1.1: tailored down to 4 ships explicitly for PdM LTS team event; included a 'dump stats' GM button/function to show in-game stats (turns out this function might have a bug that needs to be fixed):
-- v 1.0: reorganized the script for easier maintenance; completely revamped the far side "terrain" map to include lots of orbital mechanics; disabled the 'planet crash test algorithm'
-- v 0.5 was the initial playable version first used in Aug '19; no frills, just kinda bare-bones functionality
require("utils.lua")
require("place_station_scenario_utility.lua")
function init()
scenario_version = "1.5"
ee_version = "2023.06.17"
print(string.format(" ---- Scenario: Rescue Us! ---- Version %s ---- Tested with EE version %s ----",scenario_version,ee_version))
print(_VERSION)
stationList = {} --friendly and neutral stations
friendlyStationList = {}
enemyStationList = {}
briefing_message = Artifact():setCallSign("Regional Headquarters"):setCommsScript(""):setCommsFunction(briefingComms):setPosition(-500000,-500000)
-- GLOBAL VARIABLES
-- Variables that may be modified before game start to adjust game play
--Player ship passenger capacities
atlantisCapacity = 30
flaviaCapacity = 80
repulseCapacity = 60
--Station personnel capacities; Note: These are human navy capacities. Independent safe stations will take half of these capacities
hugeStationCapacity = 400 -- originally 500, but decreased to 400 temporarily
largeStationCapacity = 200
mediumStationCapacity = 100
smallStationCapacity = 50
--Player ship starting coordinates:
--player index 1 2 3 4 5 6
--ship type Atlantis Atlantis Flavia Flavia Repulse Repulse
--names Excalibur Discovery Gyrefalcon Kestrel Terrex Endeavor
playerStartX = { 45500, 24000, 43500, 22000, 43500, 22000}
playerStartY = { -11000, -31000, -10000, -30000, -12000, -32000}
stevx = 9000 --stellar event locus x coordinate
stevy = 9000 --stellar event locus y coordinate
stevRadius = 7000 --stellar event effect radius
auto_end = true --game will automatically declare victory once all have been removed from planet in peril
--Station(s) requiring evacuation due to proximity to imminent stellar event
--stn. danger index 1 2
-- stationDangerX = {3000, 5000} -- original
-- stationDangerY = {3000, 5000} -- original
stationDangerX = {570000} -- wormhole variant mod
stationDangerY = {-30000} -- wormhole variant mod
danger_station_is_orbiting = true -- set this to true if you want the space station in danger to be orbiting the exploding star in the 'far side' area; set to false to not orbit and make easier
danger_station_orbit_time = 54000 -- this is the amount of time it takes the space station to orbit the exploding star, measured in 'game tics'; approx 60 game tics/sec
--Stations a safe distance from imminent stellar event
--stn. safe index 1 2 3 4 5 6 7 8 9
stationSafeX = {-55000, -52000, -50000, -47000, -148000, -144500, -130000, -110000, -68000}
stationSafeY = { 19500, 19500, 19500, 19500, 10500, 10500, 53000, 86000, 128000}
-- items for the exploding star
exploding_star_x_location = 560000
exploding_star_y_location = 0
exploding_star_radius = 12000
lethal_blast_radius = exploding_star_radius * 3.0
exploding_star_is_orbiting = true -- set this to true if you want the exploding star to be orbiting the black hole in the 'far side' area; set to false to not orbit and make easier
exploding_star_orbit_time = 2400 -- this is the amount of time it takes the star to orbit the black hole, measured in real-time seconds
explosive_nebula = 250 -- this means the individual number of nebula that will be in the explosion; -- be careul here!! -- 500 seems to be about the max before server crashes; seems to handle 250 ok
nebula_min_velocity = 20 -- for the super nova 'ejecta'
nebula_max_velocity = 100 -- for the super nova 'ejecta'
-- very important! set the distance from the explosion center you'd like the nebula "chunks" to be removed from the game, otherwise they'll continue on forever and forever.... ;]
clean_up_distance = 101000
-- EXPLOSION OPTIONS: CHOOSE ONLY ONE OF THE FOLLOWING TO BE 'TRUE'
explosion_option_1 = false -- this has the stellar ejecta continuing to expand until they go past the clean up distance and then they're removed from the map
explosion_option_2 = true -- this has the stellar ejecta stopping at a calculated distance from the star center and remaining on the map
-- items for far side black hole and accretion disc
black_hole_location_x = 620000
black_hole_location_y = 30000
blackHoleAccretionDiscGassesList = {}
black_hole_accretion_disc_gasses_are_on = true -- set this to true if you want the far side black hole to have an orbiting accretion disc of gasses (nebulea)
black_hole_accretion_disc_gasses_distance = 15000 -- from the location of the far side black hole; gasses will be at a uniform distance
black_hole_accretion_disc_gasses_density = 16 -- the number of nebulea that form the accretion disc;
black_hole_accretion_disc_gasses_orbit_time = 3600 -- this is the amount of time it takes a single nebula to orbit the black hole, measured in 'game tics'; approx 60 game tics/sec
blackHoleAccretionDiscAsteroidsList = {}
black_hole_accretion_disc_asteroids_are_on = true -- set this to true if you want the far side black hole to have an orbiting accretion disc of asteroids (that can travel very fast, and be very deadly....)
black_hole_accretion_disc_asteroids_density = 100 -- the number of asteroids that help form the accretion disc... traveling at lethal velocity, of course... ;]
black_hole_accretion_disc_asteroids_min_distance = black_hole_accretion_disc_gasses_distance - 1500
black_hole_accretion_disc_asteroids_max_distance = black_hole_accretion_disc_gasses_distance + 1500
black_hole_accretion_disc_asteroids_min_velocity = black_hole_accretion_disc_gasses_orbit_time * 4
black_hole_accretion_disc_asteroids_max_velocity = black_hole_accretion_disc_gasses_orbit_time
-- Variables and structures that *!MUST NOT!* be modified; these are necessary for managing game play
wfv = "nowhere" --wolf fence value - used for debugging
playerShips = {}
stationDangerList = {}
stationSafeList = {}
total_passengers_killed = 0 -- some passengers may be killed while being transported, so we keep a tally of them here
-- items for the exploding star
exploding_star = Planet()
countdown_active = false
exploding_now = false
remaining_number_of_nebula = 0
explosiveNebulaList = {}
explosion_location_x = nil
explosion_location_y = nil
blast_wave_radius_marker = 0
objects_in_initial_lethal_blast_radius = {}
-- for AI transport management (mostly provides background movement and activity)
transportList = {}
transportTargetStationList = {}
spawn_delay = 0 -- for transports
-- elements for gathering statistics; these were brought in from "Limited Resources" and "Earn Your Wings", and have not been fully implemented here yet
friendlyTalliedKilledList = {}
friendlyStationsDestoyedList = {}
total_enemy_ships_spawned = 0
total_enemy_ships_crashed_into_planets = 0
total_enemy_ships_destroyed_by_players = 0
total_transport_ships_spawned = 0
total_transport_ships_crashed_into_planets = 0
total_transport_ships_destroyed_by_enemy_ships = 0
-- a separate list for the decoy stations; it is populated when the stations are created, but nothing actively done with it yet
decoyStationList = {}
-- lists for planet collision calculations
planetList = {} -- brought forward from EYW and Limited Resources to enable ship/planet collision management
planetKillRadius = {} -- brought forward from EYW and Limited Resources to enable ship/planet collision management
-- not sure how these globals matter to the "Rescue" scenario, but keep for now because they were included (perhaps a hold-over from another variant, but now irrelevant?)
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}
-- functions that establish and build the scenario
-- those written by Xansta
setVariations() -- this is where all the logic is called to setup the "Rescue" player ships depending on the scenario variation chosen at startup
-- buildNonMissionStations() -- this function is an elaborate construct to add a variable number of stations to the map in a mostly random setup; not used for this variant as I am building a specifically designed layout
-- those written by Kilted Klingon
createWormholes() -- specifically for the "Rescue" variant
createLocalAreaSpace() -- specifically for the "Rescue" variant, sets up the spatial terrain in the "local" area on the near side of the wormhole
createFarSideSpace() -- specifically for the "Rescue" varient, sets up the spatial terrain on the far side of the wormhole
arrangeMissionStations() -- this is more or less a manual re-arrangement function to place stations after they've been (somewhat randomly) generated and place into a list
simpleAndDirectGenericStationPlacement() -- tailored specifically for this variant to make it simple to add "clutter" / "decoy" stations in the mix without the overhead complexity of the other script code
createGMButtons()
debugInitDataDump() -- debug init data dump for inspection purposes; comment out when not needed
end
-- MISC UTILITIES SECTION
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 availableForComms(p)
if not p:isCommsInactive() then
return false
end
if p:isCommsOpening() then
return false
end
if p:isCommsBeingHailed() then
return false
end
if p:isCommsBeingHailedByGM() then
return false
end
if p:isCommsChatOpen() then
return false
end
if p:isCommsChatOpenToGM() then
return false
end
if p:isCommsChatOpenToPlayer() then
return
end
if p:isCommsScriptOpen() then
return false
end
return true
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 showStats()
local statistic_object = {
atlantis_capacity = atlantisCapacity,
flavia_capacity = flaviaCapacity,
repulse_capacity = repulseCapacity
}
return statistic_object
end
function createGMButtons()
clearGMFunctions()
-- this button activates the star explosion countdown and builds the array with all the nebula that will explode
addGMFunction("Countdown!",
function()
-- populate the nebula list (priming the exposion)
for i=1,explosive_nebula do
explosiveNebulaList[i] = Nebula() --:setPosition(exploding_star_x_location, exploding_star_y_location)
explosiveNebulaList[i].explosion_heading_direction = math.random(1, 360)
explosiveNebulaList[i].velocity = math.random(nebula_min_velocity, nebula_max_velocity)
explosiveNebulaList[i].stopping_distance = explosiveNebulaList[i].velocity * 1000
end
countdown_active = true
if countdown_trigger == nil then
countdown_trigger = getScenarioTime() + 5
end
remaining_number_of_nebula = explosive_nebula
objects_in_initial_lethal_blast_radius = exploding_star:getObjectsInRange(lethal_blast_radius)
print(" number of objects within initial lethal blast radius: " .. #objects_in_initial_lethal_blast_radius)
print(">>>>> Explosion matrix initiated with " .. #explosiveNebulaList .. " nebula!")
print(">>>>> Five second countdown underway....")
print(">>>>> We're in trouble now!!")
end)
addGMFunction("Print Stats",
function()
print(" ")
print(">>>>>>>>>>>>>> CURRENT PAX EVAC STATS <<<<<<<<<<<<<< ")
local remaining_to_evacuate = 0
-- check status of table: stationDangerList
local danger_list_count = string.format(" The stationDangerList (table) has: %i stations. Details:",#stationDangerList)
local out = string.format("Current Statistics:\n%s",danger_list_count)
print(danger_list_count)
for i, station in ipairs(stationDangerList) do
local danger_station_stats = string.format(" %s in %s: %i",stationDangerList[i]:getCallSign(),stationDangerList[i]:getSectorName(),stationDangerList[i].people)
print(danger_station_stats)
out = string.format("%s\n%s",out,danger_station_stats)
remaining_to_evacuate = remaining_to_evacuate + station.people
end
local people_remaining = string.format(" People remaining to evacuate: %i",remaining_to_evacuate)
print(people_remaining)
out = string.format("%s\n%s\n Stations accepting refugees and the space each has available:",out,people_remaining)
for i=1,#stationSafeList do
local safe_station_stats = string.format(" %s %s in %s: %i",stationSafeList[i]:getFaction(),stationSafeList[i]:getCallSign(),stationSafeList[i]:getSectorName(),stationSafeList[i].maxPeople - stationSafeList[i].people)
print(safe_station_stats)
out = string.format("%s\n%s",out,safe_station_stats)
end
-- go through playerShips table and print passengers enroute
local start_players = string.format(" There were %i player ships at the start",#playerShips)
print(start_players)
out = string.format("%s\n%s",out,start_players)
print(" Current # of passengers in transit on remaining ships:")
out = string.format("%s\n Current # of passengers in transit on remaining ships:",out)
for idx, player_ship in ipairs(playerShips) do
local ship_line = ""
if player_ship:isValid() then
ship_line = string.format(" %s: %s - passengers currently on board: %s",idx,player_ship:getCallSign(),player_ship.passenger)
else
ship_line = string.format(" %s: (ship destroyed)",idx)
end
print(ship_line)
out = string.format("%s\n%s",out,ship_line)
end
local killed_line = string.format(" Passengers killed while in transit: %i",total_passengers_killed)
print(killed_line)
out = string.format("%s\n%s",out,killed_line)
addGMMessage(out)
print(">>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<< ")
end)
addGMFunction("Main Screen Stats",function()
local out = mainScreenStats()
addGMMessage(string.format("This message was sent to the players' main screens:\n%s",out))
end)
local button_label = "Auto end N->Y"
if auto_end then
button_label = "Auto end Y->N"
end
addGMFunction(button_label,function()
if auto_end then
auto_end = false
addGMMessage("Auto end is now set to No. When all the people in danger have been removed from the stations in peril, the game will not automatically declare victory. This gives you the GM the opportunity to make it go supernova so everyone can watch.")
else
auto_end = true
addGMMessage("Auto end is now set to Yes. When all the people in danger have been removed from the stations in peril, the game will put up the victory screen and end.")
end
createGMButtons()
end)
end
function mainScreenStats()
local remaining_to_evacuate = 0
for idx, station in ipairs(stationDangerList) do
remaining_to_evacuate = remaining_to_evacuate + station.people
end
local out = string.format("Endangered:%s",remaining_to_evacuate)
local in_transit = 0
for i,p in ipairs(getActivePlayerShips()) do
if p.passenger ~= nil then
in_transit = in_transit + p.passenger
end
end
if in_transit > 0 then
out = string.format("%s In Transit:%s",out,in_transit)
end
local rescued_people = 0
for i, station in ipairs(stationSafeList) do
if station ~= nil and station:isValid() then
if station.people ~= nil then
rescued_people = rescued_people + station.people
end
end
end
if rescued_people > 0 then
out = string.format("%s\nRescued:%s",out,math.floor(rescued_people))
end
if total_passengers_killed > 0 then
out = string.format("%s Perished:%s",out,total_passengers_killed)
end
globalMessage(out)
setBanner(out)
return out
end
-- FOUNDATIONAL OPTIONS INIT SECTION
-- The set of functions below elaborates and directly supports the init() funciton
function setVariations()
player_ship_start_stats = {
["Excalibur"] = {template = "Atlantis", x = 45500, y = -11000, capacity = 30, warp = 300, lrs = 30000},
["Discovery"] = {template = "Atlantis", x = 24000, y = -31000, capacity = 30, warp = 300, lrs = 35000},
["Gyrefalcon"] = {template = "Flavia P.Falcon", x = 43500, y = -10000, capacity = 80, warp = 500, lrs = 20000},
["Kestrel"] = {template = "Flavia P.Falcon", x = 22000, y = -30000, capacity = 80, warp = 500, lrs = 25000},
["Terrex"] = {template = "Repulse", x = 43500, y = -12000, capacity = 60, warp = 400, lrs = 40000},
["Endeavor"] = {template = "Repulse", x = 22000, y = -32000, capacity = 60, warp = 400, lrs = 45000},
}
local player_ship_config = {
["Six"] = {"Excalibur","Discovery", "Gyrefalcon","Kestrel","Terrex","Endeavor"},
["Five"] = {"Excalibur","Discovery", "Gyrefalcon","Kestrel","Terrex"},
["Four"] = {"Excalibur","Discovery", "Gyrefalcon","Kestrel"},
["Three"] = {"Excalibur","Gyrefalcon","Terrex"},
["Two"] = {"Excalibur","Gyrefalcon"},
["One"] = {"Excalibur"},
}
local mission_station_config = {
["Six"] = {
{status = "danger", size = "Huge", faction = "Human Navy"}, --500 total 500
{status = "safe", size = "Large", faction = "Human Navy"}, --200 total 500
{status = "safe", size = "Medium", faction = "Human Navy"}, --100
{status = "safe", size = "Small", faction = "Human Navy"}, -- 50
{status = "safe", size = "Medium", faction = "Independent"}, -- 50
{status = "safe", size = "Small", faction = "Independent"}, -- 25
{status = "safe", size = "Small", faction = "Independent"}, -- 25
{status = "safe", size = "Small", faction = "Independent"}, -- 25
{status = "safe", size = "Small", faction = "Independent"}, -- 25
},
["Five"] = {
{status = "danger", size = "Huge", faction = "Human Navy"}, --500 total 500
{status = "safe", size = "Large", faction = "Human Navy"}, --200 total 500
{status = "safe", size = "Medium", faction = "Human Navy"}, --100
{status = "safe", size = "Small", faction = "Human Navy"}, -- 50
{status = "safe", size = "Small", faction = "Human Navy"}, -- 50
{status = "safe", size = "Medium", faction = "Independent"}, -- 50
{status = "safe", size = "Small", faction = "Independent"}, -- 25
{status = "safe", size = "Small", faction = "Independent"}, -- 25
},
["Four"] = {
{status = "danger", size = "Huge", faction = "Human Navy"}, --500 total 500
{status = "safe", size = "Large", faction = "Human Navy"}, --200 total 500
{status = "safe", size = "Medium", faction = "Human Navy"}, --100
{status = "safe", size = "Small", faction = "Human Navy"}, -- 50
{status = "safe", size = "Small", faction = "Human Navy"}, -- 50
{status = "safe", size = "Medium", faction = "Independent"}, -- 50
{status = "safe", size = "Medium", faction = "Independent"}, -- 50
},
["Three"] = {
{status = "danger", size = "Huge", faction = "Human Navy"}, --500 total 500
{status = "safe", size = "Large", faction = "Human Navy"}, --200 total 500
{status = "safe", size = "Medium", faction = "Human Navy"}, --100
{status = "safe", size = "Small", faction = "Human Navy"}, -- 50
{status = "safe", size = "Large", faction = "Independent"}, --100
{status = "safe", size = "Medium", faction = "Independent"}, -- 50
},
["Two"] = {
{status = "danger", size = "Large", faction = "Human Navy"}, --200 total 200
{status = "safe", size = "Medium", faction = "Human Navy"}, --100 total 200
{status = "safe", size = "Small", faction = "Human Navy"}, -- 50
{status = "safe", size = "Small", faction = "Independent"}, -- 25
{status = "safe", size = "Small", faction = "Independent"}, -- 25
},
["One"] = {
{status = "danger", size = "Large", faction = "Human Navy"}, --200 total 200
{status = "safe", size = "Medium", faction = "Human Navy"}, --100 total 200
{status = "safe", size = "Small", faction = "Human Navy"}, -- 50
{status = "safe", size = "Medium", faction = "Independent"}, -- 50
},
}
station_capacity = { --Human Navy capacity. Independent is half of the value
["Huge"] = 500,
["Large"] = 200,
["Medium"] = 100,
["Small"] = 50
}
local player_ship_config_ship_names = player_ship_config[getScenarioSetting("Players")]
local warp_me = getScenarioSetting("FTL")
rescue_capacity = getScenarioSetting("Capacity")
calc_round = true
if getScenarioSetting("Calculating") == "Spiky" then
calc_round = false
end
local player_beams = getScenarioSetting("Beams")
for i,name in ipairs(player_ship_config_ship_names) do
local p = PlayerSpaceship():setTemplate(player_ship_start_stats[name].template):setCallSign(name):setFaction("Human Navy"):setPosition(player_ship_start_stats[name].x,player_ship_start_stats[name].y)
p.passenger = 0
p.maxPassenger = player_ship_start_stats[name].capacity
if not calc_round then
p.maxPassenger = p.maxPassenger + math.random(1,9)
end
if warp_me == "Warp" then
p:setWarpDrive(true)
p:setWarpSpeed(player_ship_start_stats[name].warp)
end
p:addReputationPoints(40):onDestruction(playerDestroyed)
if player_ship_start_stats[name].template == "Atlantis" then
p:setWeaponTubeDirection(1,90):setWeaponTubeDirection(2,0):setWeaponTubeDirection(3,0)
p:setTubeSize(2,"small"):setTubeSize(3,"small")
p:setTubeLoadTime(2,4):setTubeLoadTime(3,4):setTubeLoadTime(4,12)
p:setBeamWeapon(2,60,-90,1500,6,8):setBeamWeapon(3,60,90,1500,6,8)
end
if player_ship_start_stats[name].template == "Flavia P.Falcon" then
p:setImpulseMaxSpeed(70)
end
if player_ship_start_stats[name].template == "Repulse" then
p:setImpulseMaxSpeed(80)
end
if player_beams ~= "Normal" then
if string.find("Faster",player_beams) then
for i=0,15 do
local rng = p:getBeamWeaponRange(i)
if rng > 1 then
local arc = p:getBeamWeaponArc(i)
local dir = p:getBeamWeaponDirection(i)
local cyc = p:getBeamWeaponCycleTime(i)
local dmg = p:getBeamWeaponDamage(i)
p:setBeamWeapon(i,arc,dir,rng,cyc/2,dmg)
end
end
end
if string.find("Stronger",player_beams) then
for i=0,15 do
local rng = p:getBeamWeaponRange(i)
if rng > 1 then
local arc = p:getBeamWeaponArc(i)
local dir = p:getBeamWeaponDirection(i)
local cyc = p:getBeamWeaponCycleTime(i)
local dmg = p:getBeamWeaponDamage(i)
p:setBeamWeapon(i,arc,dir,rng,cyc,dmg*2)
end
end
end
end
p:setLongRangeRadarRange(player_ship_start_stats[name].lrs)
p.initialized = true
table.insert(playerShips,p)
end
onNewPlayerShip(setNewlySpawnedPlayerShipStats)
local mission_stations = mission_station_config[getScenarioSetting("Players")]
for i,mission_station in ipairs(mission_stations) do
placeMissionStation(mission_station.status,mission_station.size,mission_station.faction)
end
if not calc_round then
local additional_people = 0
for i,station in ipairs(stationDangerList) do
local bonus = #stationSafeList + math.random(1,30)
station.people = station.people + bonus
additional_people = additional_people + bonus
end
for i=1,additional_people do
local station = stationSafeList[math.random(1,#stationSafeList)]
station.maxPeople = station.maxPeople + 1
end
end
end
function debugInitDataDump()
-- just as the name implies, this function is to produce a data dump after the init() function to see what the initial state of the important data/tracking structures before execution updates begin
print(" ")
print(" -------------- Debug Initial Data Dump -------------------")
-- check status of table: planetList
print(" The planetList (table) has: " .. #planetList .. " elements")
--[[ for idx, planet in ipairs(planetList) do
print(" " .. idx .. ": " .. planetList:getCallSign())
end --]]
-- check status of table: stationDangerList
print(" The stationDangerList (table) has: " .. #stationDangerList .. " elements")
for idx, station in ipairs(stationDangerList) do
print(" " .. idx .. ": " .. station:getCallSign())
end
-- check status of table: stationSafeList
print(" The stationSafeList (table) has: " .. #stationSafeList .. " elements")
for idx, station in ipairs(stationSafeList) do
print(" " .. idx .. ": " .. station:getCallSign() .. " Type: " .. station:getTypeName())
end
-- check status of table: playerShips
print(" The playerShips list (table) has: " .. #playerShips .. " elements")
for idx, player_ship in ipairs(playerShips) do
print(" " .. idx .. ": " .. player_ship:getCallSign())
end
--[[ check exploding star flags
print(" Exploding star flags:")
if countdown_active then
print(" countdown_active: true")
else
print(" countdown_active: false")
end
if explosion_in_progress then
print(" explosion_in_progress: true")
else
print(" explosion_in_progress: false")
end --]]
-- check exploding star flags
print(" Exploding star flags:")
if countdown_active then
print(" countdown_active: true")
else
print(" countdown_active: false")
end
if exploding_now then
print(" exploding_now: true")
else
print(" exploding_now: false")
end --]]
print(" ------------------------ end -----------------------------")
end
-- Player ship respawn creation and player ship destruction functions
function setNewlySpawnedPlayerShipStats(p)
if not p.initialized then
local player_ship_template = p:getTypeName()
local start_stats = {
["Atlantis"] = {x = 45500, y = -11000, capacity = 30, warp = 300, lrs = 30000},
["Flavia P.Falcon"] = {x = 43500, y = -10000, capacity = 80, warp = 500, lrs = 20000},
["Repulse"] = {x = 43500, y = -12000, capacity = 60, warp = 400, lrs = 40000},
}
if start_stats[player_ship_template].x ~= nil then
p:setPosition(start_stats[player_ship_template].x,start_stats[player_ship_template].y)
else
p:setPosition(44500,-10500)
end
if ship_names == nil or #ship_names < 1 then
ship_names = {"Substitute","Replacement","Latecomer","Expendable","Newbie","Fresh Meat"}
end
p:setCallSign(tableRemoveRandom(ship_names))
p.passenger = 0
if start_stats[player_ship_template].capacity ~= nil then
p.maxPassenger = start_stats[player_ship_template].capacity
else
p.maxPassenger = 20
end
if getScenarioSetting("FTL") == "Warp" then
p:setWarpDrive(true)
if start_stats[player_ship_template].warp ~= nil then
p:setWarpSpeed(start_stats[player_ship_template].warp)
else
p:setWarpSpeed(250)
end
end
p:onDestruction(playerDestroyed)
if player_ship_template == "Atlantis" then
p:setWeaponTubeDirection(1,90):setWeaponTubeDirection(2,0):setWeaponTubeDirection(3,0)
p:setTubeSize(2,"small"):setTubeSize(3,"small")
p:setTubeLoadTime(2,4):setTubeLoadTime(3,4):setTubeLoadTime(4,12)
p:setBeamWeapon(2,60,-90,1500,6,8):setBeamWeapon(3,60,90,1500,6,8)
end
if player_ship_template == "Flavia P.Falcon" then
p:setImpulseMaxSpeed(70)
end
if player_ship_template == "Repulse" then
p:setImpulseMaxSpeed(80)
end
if start_stats[player_ship_template].lrs ~= nil then
p:setLongRangeRadarRange(start_stats[player_ship_template].lrs)
else
p:setLongRangeRadarRange(20000)
end
p.initialized = true
table.insert(playerShips,p)
end
end
function playerDestroyed(victim, attacker)
print(" ")
print(" !!! Player ship " .. victim:getCallSign() .. " has been destroyed!!")
if victim.passenger == 0 then
print(" Thankfully no passengers were on board at the time.")
else
print(" !!! " .. victim.passenger .. " Passengers killed in transit!!")
end
total_passengers_killed = total_passengers_killed + victim.passenger
end
-- TERRAIN SECTION
-- The set of functions below establishes the different terrains
function createLocalAreaSpace()
-- this function draws out all the spatial bodies for the local "home" area that will also contain all the target stations for evacuees
-- first, general variables
no_atmosphere_padding = 250 -- current estimate is extra 250 distance is necessary for planet with NO atmosphere; don't think the size of the planet matters
atmosphere_padding = 500 -- current estimate is extra 500 distance is necessary for planet WITH atmosphere; don't think the size of the planet matters
medium_planet_padding = 750
jumbo_planet_padding = 1250 -- trial and error amount for extra distance necessary for jumbo planets
-- the center object:
origin_X = 0
origin_Y = 0
-- set up big central star
central_star_radius = 10000 -- set via variable so to use calculation elsewhere
central_star = Planet():setPosition(origin_X, origin_Y)
:setPlanetRadius(central_star_radius)
:setDistanceFromMovementPlane(0)
-- :setPlanetSurfaceTexture("planets/planet-2.png")
:setPlanetAtmosphereTexture("planets/star-1.png")
:setPlanetAtmosphereColor(1,0.6,0.6)
table.insert(planetList, central_star)
table.insert(planetKillRadius, 10000 + jumbo_planet_padding) -- why is the extra needed? not sure, just is
-- set up ring of asteroids with variable distance and speed around the central star, inbetween the orbits of the two space stations
central_star_asteroid_ring_1 = {}
cs_ring1_min_radius = 24000 -- from the center of the star being orbited
cs_ring1_max_radius = 29000 -- from the center of the star being orbited
number_of_asteroids_in_ring = 300
asteroid_min_orbit_speed = 360/(60 * 360) -- this equates to the number of degrees traversed for each update call if one complete orbit takes 240 seconds
asteroid_max_orbit_speed = 360/(60 * 240) -- this equates to the number of degrees traversed for each update call if one complete orbit takes 120 seconds
for i=1,number_of_asteroids_in_ring do
-- the ring will be a nested table (multi-dimensional array)
-- 1st position on the inner array will be the asteroid object
-- 2nd position on the inner array will be the current angle of the asteroid in relation to the blackhole center
-- 3rd position on the inner array will be the radius distance from the blackhole center, randomly generated in a band range
-- 4th position on the inner array will be the orbital speed of the asteroid, expressed as a delta of angle change per update cycle, randomly generated
central_star_asteroid_ring_1[i] = {}
central_star_asteroid_ring_1[i][1] = Asteroid()
central_star_asteroid_ring_1[i][2] = math.random(1, 360)
central_star_asteroid_ring_1[i][3] = math.random(cs_ring1_min_radius, cs_ring1_max_radius)
central_star_asteroid_ring_1[i][4] = random(asteroid_min_orbit_speed, asteroid_max_orbit_speed)
setCirclePos(central_star_asteroid_ring_1[i][1], origin_X, origin_Y, central_star_asteroid_ring_1[i][2], central_star_asteroid_ring_1[i][3])
end
-- planetary orbital sub-system, to the 'north' of the center star
cs_main_planet1 = Planet():setPosition(origin_X, origin_Y-80000)
:setPlanetRadius(5000)
:setDistanceFromMovementPlane(0)
:setAxialRotationTime(30)
:setPlanetSurfaceTexture("planets/gas-1.png")
:setPlanetAtmosphereColor(0.0,0.7,0.5)
table.insert(planetList, cs_main_planet1)
table.insert(planetKillRadius, 5000 + medium_planet_padding)
setCirclePos(cs_main_planet1, origin_X, origin_Y, 225, 80000) -- used for testing purposes
cs_main_planet1:setOrbit(central_star, 7200) -- orbit rate of 7200 secs ~= 2 hrs
-- build a boundary ring of nebula
for i=1,360,5 do
new_nebula = Nebula()
setCirclePos(new_nebula, origin_X, origin_Y, i, math.random(95000, 105000))
end
-- throw in a bunch of random asteroids in a band that doesn't have orbitals, but these are stationary
for i=1,500 do
new_asteroid = Asteroid()
setCirclePos(new_asteroid, origin_X, origin_Y, math.random(1, 360), math.random(45000, 65000))
end
end
function createFarSideSpace()
-- this is on the far side of the wormhole; note this is for planets, stars, nebula, blackholes, etc, and not stations; they go in a separate function
far_side_blackhole = BlackHole():setPosition(black_hole_location_x, black_hole_location_y):setCallSign("Nemesis")
exploding_star:setPosition(exploding_star_x_location, exploding_star_y_location)
:setPlanetRadius(exploding_star_radius)
:setDistanceFromMovementPlane(0)
:setPlanetAtmosphereTexture("planets/star-1.png")
:setPlanetAtmosphereColor(1,1,1)
:setCallSign("Pandora")
if exploding_star_is_orbiting then
exploding_star:setOrbit(far_side_blackhole, exploding_star_orbit_time)
end
table.insert(planetList, exploding_star)
table.insert(planetKillRadius, 12000 + jumbo_planet_padding) -- why is the extra needed? not sure, just is
-- it's really ugly, but just for now, cram this in here; the initial setup if the station in danger is orbiting the (to be) exploding star
if danger_station_is_orbiting then
stationDangerList[1].orbit_distance = distance(exploding_star, stationDangerList[1])
stationDangerList[1].orbit_velocity = 360/danger_station_orbit_time -- the amount of circumference arc to travel each game tic in order to complete one orbit in the given orbit time
stationDangerList[1].current_angle_from_origin = 180 -- 325 -- an initial angle placement
end
-- if selected, create the accretion disc gasses (nebulea)
if black_hole_accretion_disc_gasses_are_on then
for i=1,black_hole_accretion_disc_gasses_density do
blackHoleAccretionDiscGassesList[i] = Nebula()
blackHoleAccretionDiscGassesList[i].orbit_distance = black_hole_accretion_disc_gasses_distance
blackHoleAccretionDiscGassesList[i].current_angle_from_origin = (i-1)*(360/black_hole_accretion_disc_gasses_density)
blackHoleAccretionDiscGassesList[i].orbit_velocity = 360/black_hole_accretion_disc_gasses_orbit_time
setCirclePos(blackHoleAccretionDiscGassesList[i], black_hole_location_x, black_hole_location_y, blackHoleAccretionDiscGassesList[i].current_angle_from_origin, blackHoleAccretionDiscGassesList[i].orbit_distance)
end
end
-- if selected, create the accretion disc asteroids
if black_hole_accretion_disc_asteroids_are_on then
for i=1,black_hole_accretion_disc_asteroids_density do
blackHoleAccretionDiscAsteroidsList[i] = Asteroid()
blackHoleAccretionDiscAsteroidsList[i].orbit_distance = math.random(black_hole_accretion_disc_asteroids_min_distance, black_hole_accretion_disc_asteroids_max_distance)
blackHoleAccretionDiscAsteroidsList[i].current_angle_from_origin = math.random(1, 360)
blackHoleAccretionDiscAsteroidsList[i].orbit_velocity = 360/(math.random(black_hole_accretion_disc_asteroids_max_velocity, black_hole_accretion_disc_asteroids_min_velocity))
setCirclePos(blackHoleAccretionDiscAsteroidsList[i], black_hole_location_x, black_hole_location_y, blackHoleAccretionDiscAsteroidsList[1].current_angle_from_origin, blackHoleAccretionDiscAsteroidsList[1].orbit_distance)
end
end
-- build a boundary ring of nebula
for i=1,360,3 do
local new_nebula = Nebula()
setCirclePos(new_nebula, black_hole_location_x, black_hole_location_y, i, math.random(95000, 105000))
end
end
function createWormholes()
--local area "entry"
WormHole():setPosition(50000, -30000):setTargetPosition(598181, 6855)
-- distant area "exit"
WormHole():setPosition(597284, 11066):setTargetPosition(46000, -30000)
end
-- STATION CREATION/PLACEMENT SECTION
-- The set of functions below creates and places the different stations
function arrangeMissionStations()
local arranged_stations = {
{orbit_object = central_star, angle_from_origin = 90, orbit_radius = 36500, orbit_speed = 360/(60*3000), transport = false},
{orbit_object = cs_main_planet1, angle_from_origin = 330, orbit_radius = 10000, orbit_speed = 360/(60*500), transport = false},
{orbit_object = central_star, angle_from_origin = 330, orbit_radius = 17500, orbit_speed = 360/(60*1200), transport = false},
{orbit_object = central_star, angle_from_origin = 150, orbit_radius = 50000, orbit_speed = 0, transport = true},
{orbit_object = central_star, angle_from_origin = 225, orbit_radius = 32000, orbit_speed = 0, transport = true},
{orbit_object = central_star, angle_from_origin = 45, orbit_radius = 50000, orbit_speed = 0, transport = true},
{orbit_object = central_star, angle_from_origin = random(0,360), orbit_radius = 150000, orbit_speed = 0, transport = true},
{orbit_object = central_star, angle_from_origin = random(0,360), orbit_radius = 145000, orbit_speed = 0, transport = true},
}
for i,station in ipairs(stationSafeList) do
if arranged_stations[i] ~= nil then
local a_station = arranged_stations[i]
local center_x, center_y = a_station.orbit_object:getPosition()
station.current_angle_from_origin = a_station.angle_from_origin
station.orbit_radius = a_station.orbit_radius
station.orbit_speed = a_station.orbit_speed
setCirclePos(station,center_x,center_y,station.current_angle_from_origin,station.orbit_radius)
if a_station.transport then
table.insert(transportTargetStationList,station)
end
else
table.insert(transportTargetStationList,station)
end
end
end
function simpleAndDirectGenericStationPlacement()
-- note that this first station is explicitly placed next to the wormhole on the near side so that Human Navy forces have automatic scanning of the wormhold area
station_wormhole_near = placeStation(46650,-31900,"RandomHumanNeutral","Human Navy","Small Station")
station_wormhole_near:setDescription("Wormhole Gateway")
station_wormhole_near.general = "Monitoring gateway station for the wormhole to the Delta Quadrant"
table.insert(friendlyStationList,station_wormhole_near)
-- note that this second station is explicitly placed next to the wormhole on the far side so that Human Navy forces have automatic scanning of the wormhold area
station_wormhole_far = placeStation(600886, 9062,"RandomHumanNeutral","Human Navy","Small Station")
station_wormhole_far:setDescription("Wormhole Gateway")
station_wormhole_far.general = "Monitoring gateway station for the wormhole back to the Alpha Quadrant"
table.insert(friendlyStationList,station_wormhole_far)
local decoy_stations = {
{lo = 45000, hi = 65000, name = "Research Station Zulu", desc = "Classified Research", general = "Sorry, nothing to see here. Move along."},
{lo = 45000, hi = 65000, name = "Mrs. Gillerlain's Apothacary", desc = "Medicines", general = "If you're feelin' blue, we're sure to have something for you!"},
{lo = 45000, hi = 65000, name = "Mr. Evans' Parts", desc = "Spaceship Parts", general = "If it's busted -- we've got your parts!"},
{lo = 94000, hi = 95000, name = "Deep Space 4", desc = "Monitoring Station", general = "Shhhhh.... we're listening for little green men... "},
{lo = 94000, hi = 95000, name = "Urapentay", desc = "Maximum Security Prison", general = "Please present 8 valid forms of identification"},
{lo = 45000, hi = 65000, name = "Joe's Pizza", desc = "Pizza Parlor", general = "18 decks of the best pizza in the galaxy!"},
}
for i,decoy in ipairs(decoy_stations) do
local station = placeStation(-300000,-300000,"RandomHumanNeutral","Human Navy")
station:setCallSign(decoy.name):setDescription(decoy.desc)
setCirclePos(station, origin_X, origin_Y, random(0,360), random(decoy.lo,decoy.hi))
station.general = decoy.general
table.insert(transportTargetStationList,station)
table.insert(decoyStationList,station)
end
end
function placeMissionStation(typeStation, sizeStation, factionStation)
if typeStation == nil then
print("No value for typeStation. Valid values are 'safe' and 'danger' Assuming safe")
typeStation = "safe"
end
if typeStation ~= "danger" and typeStation ~= "safe" then
print("Invalid value for typeStation. Valid values are 'safe' and 'danger' Assuming safe")
typeStation = "safe"
end
if typeStation == "danger" then
stationChoice = math.random(1,#stationDangerX)
psx = stationDangerX[stationChoice]
psy = stationDangerY[stationChoice]
table.remove(stationDangerX,stationChoice)
table.remove(stationDangerY,stationChoice)
else
stationChoice = math.random(1,#stationSafeX)
psx = stationSafeX[stationChoice]
psy = stationSafeY[stationChoice]
table.remove(stationSafeX,stationChoice)
table.remove(stationSafeY,stationChoice)
end
if sizeStation == nil then
print("No value for sizeStation. Valid values are 'Huge' 'Large' 'Medium' and 'Small' Assuming Medium")
sizeStation = "Medium"
end
if sizeStation ~= "Huge" and sizeStation ~= "Large" and sizeStation ~= "Medium" and sizeStation ~= "Small" then
print("Invalid value for sizeStation. Valid values are 'Huge' 'Large' 'Medium' and 'Small' Assuming Medium")
sizeStation = "Medium"
end
if sizeStation == "Small" then
stationSize = "Small Station"
elseif sizeStation == "Medium" then
stationSize = "Medium Station"
elseif sizeStation == "Large" then
stationSize = "Large Station"
else
stationSize = "Huge Station"
end
if factionStation == nil then
print("No value for factionStation. Valid values are 'Human Navy and 'Independent' Assuming Independent")
factionStation = "Independent"
end
if factionStation ~= "Human Navy" and factionStation ~= "Independent" then
print("Invalid value for factionStation. Valid values are 'Human Navy and 'Independent' Assuming Independent")
factionStation = "Independent"
end
if factionStation == "Human Navy" then
stationFaction = "Human Navy"
else
stationFaction = "Independent"
end
local pStation = placeStation(psx,psy,"RandomHumanNeutral",stationFaction,stationSize)
table.insert(stationList,pStation) --save station in general station list
if stationFaction == "Human Navy" then
table.insert(friendlyStationList,pStation) --save station in friendly station list
end
if typeStation == "danger" then
table.insert(stationDangerList,pStation)
pStation.evacuate = true
pStation.people = station_capacity[sizeStation]
else --safe station
table.insert(stationSafeList,pStation)
pStation.evacuees = true
pStation.people = 0
if stationFaction == "Human Navy" then
if rescue_capacity == "Enough" then
pStation.maxPeople = station_capacity[sizeStation]
else
pStation.maxPeople = station_capacity[sizeStation] * 1.2
end
else --independent
if rescue_capacity == "Enough" then
pStation.maxPeople = station_capacity[sizeStation]/2
else
pStation.maxPeople = station_capacity[sizeStation]/2*1.2
end
end
end
end
function randomStation()
idx = math.floor(random(1, #transportTargetStationList + 0.99))
return transportTargetStationList[idx]
end
function buildNonMissionStations()
stationFaction = "Human Navy"
stationSize = nil
local pStation = nil
for i=1,10 do
repeat
candidateQualify = true
bandChoice = random(1,100)
if bandChoice < 50 then
outerRange = 25000
elseif bandChoice < 70 then
outerRange = 50000
elseif bandChoice < 90 then
outerRange = 100000
else
outerRange = 150000
end
ivx, ivy = vectorFromAngle(random(0,360),random(stevRadius,outerRange))
psx = stevx+ivx
psy = stevy+ivy
for j=1,#stationList do
if distance(stationList[j],psx,psy) < 4500 then
candidateQualify = false
break
end
end
until(candidateQualify)
pStation = placeStation(psx,psy,"RandomHumanNeutral",stationFaction)
table.insert(stationList,pStation) --save station in general station list
table.insert(friendlyStationList,pStation)
end
stationFaction = "Independent"
for i=1,25 do
repeat
candidateQualify = true
bandChoice = random(1,100)
if bandChoice < 50 then
outerRange = 25000
elseif bandChoice < 70 then
outerRange = 50000
elseif bandChoice < 90 then
outerRange = 100000
else
outerRange = 150000
end
ivx, ivy = vectorFromAngle(random(0,360),random(stevRadius,outerRange))
psx = stevx+ivx
psy = stevy+ivy
for j=1,#stationList do
if distance(stationList[j],psx,psy) < 4500 then
candidateQualify = false
break
end
end
until(candidateQualify)