-
Notifications
You must be signed in to change notification settings - Fork 6
/
scenario_55_defenderHunter.lua
6454 lines (6446 loc) · 256 KB
/
scenario_55_defenderHunter.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: Defender Hunter
-- Description: Defend home station and hunt down enemies
---
--- Initially, you're tasked with defending your home base. Over time, you'll discover more about the enemies harassing you and you'll be ordered to find and destroy the enemies responsible. There may be various missions given along the way, but the enemy harassment will continue. You must balance your two missions.
---
--- Designed for any number of cooperating player ships. Randomization makes many details different for each game, but the primary goals remain the same. Untimed variations can take an hour or longer for full mission completion. Different sub-missions may be chosen by the players or will be chosen at random. Achieving victory in a timed hunter variation is quite a challenge. Like the Waves scenario, the enemies get harder over time.
---
--- Version 11
---
--- USN Discord: https://discord.gg/PntGG3a where you can join a game online. There's one almost every weekend. All experience levels are welcome.
-- Type: Replayable Mission
-- Setting[Enemies]: Configures the number and type of enemies
-- Enemies[Easy]: Fewer and/or weaker enemy ships
-- Enemies[Normal|Default]: Normal difficulty
-- Enemies[Hard]: More and/or stronger enemy ships
-- Enemies[Extreme]: Many more or much stronger enemy ships
-- Enemies[Quixotic]: Enemies likely to overwhelm you
-- Setting[Time]: Sets the length of time for the scenario
-- Time[Unlimited|Default]: No time limit. Protect home station and hunt and destroy designated enemy station.
-- Time[30min]: Scenario ends in 30 minutes
-- Time[35min]: Scenario ends in 35 minutes
-- Time[40min]: Scenario ends in 40 minutes
-- Time[45min]: Scenario ends in 45 minutes
-- Time[50min]: Scenario ends in 50 minutes
-- Time[55min]: Scenario ends in 55 minutes
-- Time[60min]: Scenario ends in 60 minutes
-- Setting[Goal]: Sets primary goal. Pertinent to timed scenario
-- Goal[Defender|Default]: Protect home station. If timed scenario, victory after time runs out if home station survives.
-- Goal[Hunter]: Protect home station and hunt down designated enemy station. If timed scenario, defeat after time runs out if designated enemy station survives.
-- 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
-- typical colors used in ship log
-- "Red" Red Enemies spotted
-- "Blue" Blue
-- "Yellow" Yellow Maria Shrivner
-- "Magenta" Magenta Headquarters
-- "Green" Green
-- "Cyan" Cyan
-- "Black" Black
-- "#555555" Dark gray "55,55,55"
-- "#ff4500" Orange red "255,69,0" HMS Bounty
-- "#ff7f50" Coral "255,127,80"
-- "#5f9ea0" Cadet blue "95,158,160" Paul Straight
-- "#4169e1" Royal blue "65,105,225"
-- "#8a2be2" Blue violet "138,43,226"
-- "#ba55d3" Medium orchid "186,85,211" Maria's station
-- "#a0522d" Sienna "160,82,45"
-- "#b29650" Arbitrary "178,150,80"
-- "#556b2f" Dark olive green "85,107,47" Home station
-- "#228b22" Forest green "34,139,34"
-- "#b22222" Firebrick "178,34,34"
require("utils.lua")
require("generate_call_sign_scenario_utility.lua")
require("place_station_scenario_utility.lua")
require("cpu_ship_diversification_scenario_utility.lua")
-------------------------------
-- Initialization routines --
-------------------------------
function init()
wfv = "nowhere" --wolf fence value - used for debugging
scenario_version = "11.0.0"
print(string.format(" ---- Scenario: Defender Hunter ---- Version %s ---- EE version: %s ----",scenario_version,getEEVersion()))
if _VERSION ~= nil then
print(_VERSION)
end
plot_1_diagnostic = false
plot_2_diagnostic = false
setVariations()
setMovingAsteroids()
setMovingNebulae()
setWormArt()
setConstants()
setGlobals()
diagnostic = false
helpfulWarningDiagnostic = false
GMDiagnosticOn = _("buttonGM", "Turn On Diagnostic")
addGMFunction(GMDiagnosticOn,turnOnDiagnostic)
default_interwave_interval = 280
interWave = default_interwave_interval
GMDelayNormalToSlow = _("buttonGM", "Delay normal to slow")
GMDelaySlowToFast = _("buttonGM", "Delay slow to fast")
GMDelayFastToNormal = _("buttonGM", "Delay fast to normal")
addGMFunction(GMDelayNormalToSlow,delayNormalToSlow)
buildStations()
wfv = "end of init"
end
function setVariations()
--translate variations into a numeric difficulty value
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, adverse = .999, lose_coolant = .99999, gain_coolant = .005},
["Normal"] = {number = 1, adverse = .995, lose_coolant = .99995, gain_coolant = .001},
["Hard"] = {number = 2, adverse = .99, lose_coolant = .9999, gain_coolant = .0001},
}
difficulty = murphy_config[getScenarioSetting("Murphy")].number
adverseEffect = murphy_config[getScenarioSetting("Murphy")].adverse
coolant_loss = murphy_config[getScenarioSetting("Murphy")].lose_coolant
coolant_gain = murphy_config[getScenarioSetting("Murphy")].gain_coolant
local time_config = {
["Unlimited"] = {interval = 300, limit = false, time = 0, plot = nil },
["30min"] = {interval = 200, limit = true, time = 30 * 60, plot = timedGame },
["35min"] = {interval = 215, limit = true, time = 35 * 60, plot = timedGame },
["40min"] = {interval = 230, limit = true, time = 40 * 60, plot = timedGame },
["45min"] = {interval = 245, limit = true, time = 45 * 60, plot = timedGame },
["50min"] = {interval = 260, limit = true, time = 50 * 60, plot = timedGame },
["55min"] = {interval = 275, limit = true, time = 55 * 60, plot = timedGame },
["60min"] = {interval = 290, limit = true, time = 60 * 60, plot = timedGame },
}
timedIntelligenceInterval = time_config[getScenarioSetting("Time")].interval
playWithTimeLimit = time_config[getScenarioSetting("Time")].limit
gameTimeLimit = time_config[getScenarioSetting("Time")].time
plot6 = time_config[getScenarioSetting("Time")].plot
end
function setGlobals()
--list of goods available to buy, sell or trade (sell still under development)
goodsList = {
{"food",0},
{"medicine",0},
{"nickel",0},
{"platinum",0},
{"gold",0},
{"dilithium",0},
{"tritanium",0},
{"luxury",0},
{"cobalt",0},
{"impulse",0},
{"warp",0},
{"shield",0},
{"tractor",0},
{"repulsor",0},
{"beam",0},
{"optic",0},
{"robotic",0},
{"filament",0},
{"transporter",0},
{"sensor",0},
{"communication",0},
{"autodoc",0},
{"lifter",0},
{"android",0},
{"nanites",0},
{"software",0},
{"circuit",0},
{"battery",0}
}
goods = {} --overall tracking of goods
stationList = {} --friendly and neutral stations
friendlyStationList = {}
enemyStationList = {}
tradeFood = {} --stations that will trade food for other goods
tradeLuxury = {} --stations that will trade luxury for other goods
tradeMedicine = {} --stations that will trade medicine for other goods
totalStations = 0
friendlyStations = 0
neutralStations = 0
--gossip will have meaning for a future mission addition. Right now, it's just color
gossipSnippets = {}
table.insert(gossipSnippets,_("gossip-comms", "I hear the head of operations has a thing for his administrative assistant")) --1
table.insert(gossipSnippets,_("gossip-comms", "My mining friends tell me Krak or Kruk is about to strike it rich")) --2
table.insert(gossipSnippets,_("gossip-comms", "Did you know you can usually hire replacement repair crew cheaper at friendly stations?")) --3
table.insert(gossipSnippets,_("gossip-comms", "Under their uniforms, the Kraylors have an extra appendage. I wonder what they use it for")) --4
table.insert(gossipSnippets,_("gossip-comms", "The Kraylors may be human navy enemies, but they make some mighty fine BBQ Mynock")) --5
table.insert(gossipSnippets,_("gossip-comms", "The Kraylors and the Ktlitans may be nearing a cease fire from what I hear. That'd be bad news for us")) --6
table.insert(gossipSnippets,_("gossip-comms", "Docking bay 7 has interesting mind altering substances for sale, but they're monitored between 1900 and 2300")) --7
table.insert(gossipSnippets,_("gossip-comms", "Watch the sky tonight in quadrant J around 2243. It should be spectacular")) --8
table.insert(gossipSnippets,_("gossip-comms", "I think the shuttle pilot has a tame miniature Ktlitan caged in his quarters. Sometimes I hear it at night")) --9
table.insert(gossipSnippets,_("gossip-comms", "Did you hear the screaming chase in the corridors on level 4 last night? Three Kraylors were captured and put in the brig")) --10
table.insert(gossipSnippets,_("gossip-comms", "Rumor has it that the two Lichten brothers are on the verge of a new discovery. And it's not another wine flavor either")) --11
--Player ship name lists to supplant standard randomized call sign generation
player_ship_names = {
["Atlantis"] = {"Excaliber","Thrasher","Punisher","Vorpal","Protang","Drummond","Parchim","Coronado"},
["Benedict"] = {"Elizabeth","Ford","Vikramaditya","Liaoning","Avenger","Naruebet","Washington","Lincoln","Garibaldi","Eisenhower"},
["Crucible"] = {"Sling", "Stark", "Torrid", "Kicker", "Flummox"},
["Ender"] = {"Mongo","Godzilla","Leviathan","Kraken","Jupiter","Saturn"},
["Flavia P.Falcon"] = {"Ladyhawke","Hunter","Seeker","Gyrefalcon","Kestrel","Magpie","Bandit","Buccaneer"},
["Hathcock"] = {"Hayha", "Waldron", "Plunkett", "Mawhinney", "Furlong", "Zaytsev", "Pavlichenko", "Pegahmagabow", "Fett", "Hawkeye", "Hanzo"},
["Kiriya"] = {"Cavour","Reagan","Gaulle","Paulo","Truman","Stennis","Kuznetsov","Roosevelt","Vinson","Old Salt"},
["MP52 Hornet"] = {"Dragonfly","Scarab","Mantis","Yellow Jacket","Jimminy","Flik","Thorny","Buzz"},
["Maverick"] = {"Festoon", "Earp", "Schwartz", "Tentacular", "Prickly", "Thunderbird", "Hickok", "Clifton", "Fett", "Holliday", "Sundance"},
["Nautilus"] = {"October", "Abdiel", "Manxman", "Newcon", "Nusret", "Pluton", "Amiral", "Amur", "Heinkel", "Dornier"},
["Phobos M3P"] = {"Blinder","Shadow","Distortion","Diemos","Ganymede","Castillo","Thebe","Retrograde"},
["Piranha"] = {"Razor","Biter","Ripper","Voracious","Carnivorous","Characid","Vulture","Predator"},
["Repulse"] = {"Fiddler","Brinks","Loomis","Mowag","Patria","Pandur","Terrex","Komatsu","Eitan"},
["Saipan"] = {"Atlas", "Bernard", "Alexander", "Retribution", "Sulaco", "Conestoga", "Saratoga", "Pegasus"},
["Striker"] = {"Sparrow","Sizzle","Squawk","Crow","Phoenix","Snowbird","Hawk"},
["ZX-Lindworm"] = {"Seagull","Catapult","Blowhard","Flapper","Nixie","Pixie","Tinkerbell"},
["Player Cruiser"] = {"Excelsior","Velociraptor","Thunder","Kona","Encounter","Perth","Aspern","Panther"},
["Player Missile Cr."] ={"Projectus","Hurlmeister","Flinger","Ovod","Amatola","Nakhimov","Antigone"},
["Player Fighter"] = {"Buzzer","Flitter","Zippiticus","Hopper","Molt","Stinger","Stripe"},
["Leftovers"] = {"Foregone","Righteous","Masher"},
}
highestConcurrentPlayerCount = 0
setConcurrentPlayerCount = 0
primaryOrders = ""
secondaryOrders = ""
optionalOrders = ""
transportList = {}
homeDelivery = false
infoPromised = false
baseIntelligenceAvailable = false
spinUpgradeAvailable = false
hullUpgradeAvailable = false
rotateUpgradeAvailable = false
beamTimeUpgradeAvailable = false
missionLength = 1
initialOrderTimer = 3
plot1 = initialOrders
transportSpawnDelay = 10
healthCheckTimer = 5
healthCheckTimerInterval = 5
healthCheckCount = 0
plot4choices = {}
table.insert(plot4choices,stationShieldDelay)
table.insert(plot4choices,repairBountyDelay)
table.insert(plot4choices,insertAgentDelay)
end
function setConstants()
player_ship_stats = { --ordered by name
["Atlantis"] = { strength = 52, cargo = 6, distance = 400, long_range_radar = 30000, short_range_radar = 5000},
["Benedict"] = { strength = 10, cargo = 9, distance = 400, long_range_radar = 30000, short_range_radar = 5000},
["Crucible"] = { strength = 45, cargo = 5, distance = 200, long_range_radar = 20000, short_range_radar = 6000},
["Ender"] = { strength = 100, cargo = 20, distance = 2000,long_range_radar = 45000, short_range_radar = 7000},
["Flavia P.Falcon"] = { strength = 13, cargo = 15, distance = 200, long_range_radar = 40000, short_range_radar = 5000},
["Hathcock"] = { strength = 30, cargo = 6, distance = 200, long_range_radar = 35000, short_range_radar = 6000},
["Kiriya"] = { strength = 10, cargo = 9, distance = 400, long_range_radar = 35000, short_range_radar = 5000},
["Maverick"] = { strength = 45, cargo = 5, distance = 200, long_range_radar = 20000, short_range_radar = 4000},
["MP52 Hornet"] = { strength = 7, cargo = 3, distance = 100, long_range_radar = 18000, short_range_radar = 4000},
["Nautilus"] = { strength = 12, cargo = 7, distance = 200, long_range_radar = 22000, short_range_radar = 4000},
["Phobos M3P"] = { strength = 19, cargo = 10, distance = 200, long_range_radar = 25000, short_range_radar = 5000},
["Piranha"] = { strength = 16, cargo = 8, distance = 200, long_range_radar = 25000, short_range_radar = 6000},
["Player Cruiser"] = { strength = 40, cargo = 6, distance = 400, long_range_radar = 30000, short_range_radar = 5000},
["Player Fighter"] = { strength = 7, cargo = 3, distance = 100, long_range_radar = 15000, short_range_radar = 4500},
["Player Missile Cr."] = { strength = 45, cargo = 8, distance = 200, long_range_radar = 35000, short_range_radar = 6000},
["Repulse"] = { strength = 14, cargo = 12, distance = 200, long_range_radar = 38000, short_range_radar = 5000},
["Striker"] = { strength = 8, cargo = 4, distance = 200, long_range_radar = 35000, short_range_radar = 5000},
["ZX-Lindworm"] = { strength = 8, cargo = 3, distance = 100, long_range_radar = 18000, short_range_radar = 5500},
}
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},
["Adder MK3"] = {strength = 5, create = adderMk3},
["MT52 Hornet"] = {strength = 5, create = stockTemplate},
["MU52 Hornet"] = {strength = 5, create = stockTemplate},
["MV52 Hornet"] = {strength = 6, create = hornetMV52},
["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},
["Nirvana R3"] = {strength = 12, 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},
["Phobos M3"] = {strength = 16, create = stockTemplate},
["Cruiser"] = {strength = 18, create = stockTemplate},
["Nirvana R5A"] = {strength = 20, create = stockTemplate},
["Ktlitan Worker"] = {strength = 21, create = stockTemplate},
["Storm"] = {strength = 22, create = stockTemplate},
["Stalker R5"] = {strength = 22, create = stockTemplate},
["Stalker Q5"] = {strength = 22, create = stockTemplate},
["Ranus U"] = {strength = 25, create = stockTemplate},
["Stalker Q7"] = {strength = 25, create = stockTemplate},
["Stalker R7"] = {strength = 25, create = stockTemplate},
["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 = fiendG3},
["Fiend G4"] = {strength = 35, create = fiendG4},
["Fiend G5"] = {strength = 37, create = fiendG5},
["Fiend G6"] = {strength = 39, create = fiendG6},
["Predator"] = {strength = 42, create = predator},
["Ktlitan Breaker"] = {strength = 45, create = stockTemplate},
["Ktlitan Feeder"] = {strength = 48, create = stockTemplate},
["Atlantis X23"] = {strength = 50, create = stockTemplate},
["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 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},
},
},
}
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"}
end
function GMSpawnsEnemies()
-- Let the GM spawn a random group of enemies to attack a player
local gmPlayer = nil
local gmSelect = getGMSelection()
for idx, obj in ipairs(gmSelect) do
if obj.typeName == "PlayerSpaceship" then
gmPlayer = obj
break
end
end
if gmPlayer == nil then
gmPlayer = closestPlayerTo(targetEnemyStation)
end
local px, py = gmPlayer:getPosition()
local sx, sy = vectorFromAngle(random(0,360),random(20000,30000))
ntf = spawnEnemies(px+sx,py+sy,dangerValue,targetEnemyStation:getFaction())
for idx, enemy in ipairs(ntf) do
enemy:orderAttack(gmPlayer)
end
end
function turnOnDiagnostic()
-- Diagnostic enable/disable buttons on GM screen
diagnostic = true
removeGMFunction(GMDiagnosticOn)
addGMFunction(_("buttonGM", "Turn Off Diagnostic"),turnOffDiagnostic)
end
function turnOffDiagnostic()
diagnostic = false
removeGMFunction(GMDiagnosticOff)
addGMFunction(_("buttonGM", "Turn On Diagnostic"),turnOnDiagnostic)
end
------- In game GM buttons to change the delay between waves -------
-- Default is normal, so the fist button switches from a normal delay to a slow delay.
-- The slow delay is used for typical mission testing when the tester does not wish to
-- spend all their time fighting off enemies.
-- The second button switches from slow to fast. This facilitates testing the enemy
-- spawning routines. The third button goes from fast to normal.
function delayNormalToSlow()
interWave = 600
removeGMFunction(GMDelayNormalToSlow)
addGMFunction(GMDelaySlowToFast,delaySlowToFast)
end
function delaySlowToFast()
interwave = 20
removeGMFunction(GMDelaySlowToFast)
addGMFunction(GMDelayFastToNormal,delayFastToNormal)
end
function delayFastToNormal()
interwave = default_interwave_interval
removeGMFunction(GMDelayFastToNormal)
addGMFunction(GMDelayNormalToSlow,delayNormalToSlow)
end
-- dynamic universe functions: asteroids and nebulae in motion
function setMovingNebulae()
movingNebulae = {}
local upperNeb = math.random(5,10)
for nidx=1,upperNeb do
local xNeb = random(-100000,100000)
local yNeb = random(-100000,100000)
local mNeb = Nebula():setPosition(xNeb, yNeb)
mNeb.angle = random(0,360)
mNeb.travel = random(1,100)
table.insert(movingNebulae,mNeb)
end
plotN = moveNebulae
end
function moveNebulae(delta)
for nidx=1,#movingNebulae do
local mnx, mny = movingNebulae[nidx]:getPosition()
if mnx ~= nil and mny ~= nil then
local angleChange = false
if mnx < -100000 then
angleChange = true
movingNebulae[nidx].angle = random(0,180) + 270
end
if mnx > 100000 then
angleChange = true
movingNebulae[nidx].angle = random(90,270)
end
if mny < -100000 then
angleChange = true
movingNebulae[nidx].angle = random(0,180)
end
if mny > 100000 then
angleChange = true
movingNebulae[nidx].angle = random(180,360)
end
local deltaNebx, deltaNeby = vectorFromAngle(movingNebulae[nidx].angle, movingNebulae[nidx].travel/10)
if angleChange then
deltaNebx, deltaNeby = vectorFromAngle(movingNebulae[nidx].angle, movingNebulae[nidx].travel/10+20)
movingNebulae.travel = random(1,100)
end
movingNebulae[nidx]:setPosition(mnx+deltaNebx, mny+deltaNeby)
end
end
end
function setMovingAsteroids()
movingAsteroidList = {}
for aidx=1,30 do
local xAst = random(-100000,100000)
local yAst = random(-100000,100000)
local outRange = true
local players = getActivePlayerShips()
for pidx, p2obj in ipairs(players) do
if p2obj ~= nil and p2obj:isValid() then
if distance(p2obj,xAst,yAst) < 30000 then
outRange = false
end
end
end
if outRange then
local asteroid_size = random(1,75) + random(1,50) + random(1,50) + random(1,20) + random(1,20) + random(1,20) + random(1,20) + random(1,20) + random(1,20) + random(1,20)
local mAst = Asteroid():setPosition(xAst,yAst):setSize(asteroid_size)
mAst.angle = random(0,360)
mAst.travel = random(40,220)
if random(1,100) < 50 then
mAst.curve = 0
else
mAst.curve = math.random()*.16 - .08
end
table.insert(movingAsteroidList,mAst)
end
end
plotA = moveAsteroids
end
function moveAsteroids(delta)
local movingAsteroidCount = 0
for aidx, aObj in ipairs(movingAsteroidList) do
if aObj:isValid() then
movingAsteroidCount = movingAsteroidCount + 1
local mAstx, mAsty = aObj:getPosition()
if mAstx < -150000 or mAstx > 150000 or mAsty < -150000 or mAsty > 150000 then
aObj.angle = random(0,360)
if random(1,100) < 50 then
curve = 0
else
curve = math.random()*.08
end
if aObj.angle < 90 then
aObj:setPosition(random(-150000,-100000),random(-150000,-100000))
if aObj.angle < 45 then
aObj.curve = curve
else
aObj.curve = -curve
end
elseif aObj.angle < 180 then
aObj:setPosition(random(100000,150000),random(-150000,-100000))
if aObj.angle < 135 then
aObj.curve = curve
else
aObj.curve = -curve
end
elseif aObj.angle < 270 then
aObj:setPosition(random(100000,150000),random(100000,150000))
if aObj.angle < 225 then
aObj.curve = curve
else
aObj.curve = -curve
end
else
aObj:setPosition(random(-150000,-100000),random(100000,150000))
if aObj.angle < 315 then
aObj.curve = curve
else
aObj.curve = -curve
end
end
else
local deltaAstx, deltaAsty = vectorFromAngle(aObj.angle,aObj.travel)
aObj:setPosition(mAstx+deltaAstx,mAsty+deltaAsty)
aObj.angle = aObj.angle + aObj.curve
end
end
end
if movingAsteroidCount < 1 then
setMovingAsteroids()
end
end
-- Organically (simulated asymetrically) grow stations from a central grid location
-- Order of creation: friendlies, planet, neutrals, black hole, generic enemies, leading enemies
-- Statistically, the enemy stations typically end up on the edge, a fair distance away, but not always
function buildStations()
gbLow = 1 --grid boundary low
gbHigh = 500 --grid boundary high
grid = {} --grid - positional model
for i=gbLow,gbHigh do
grid[i] = {}
end
gx = gbHigh/2 --grid coordinate x
gy = gbHigh/2 --grid coordinate y
gp = 1 --grid position list index
gSize = random(6000,8000) --grid cell size in positional units
adjList = {} --adjacent space on grid location list
--place friendly stations
stationFaction = "Human Navy"
for j=1,12 do
tSize = math.random(2,5) --tack on to region size (3-6 since first is outside loop)
grid[gx][gy] = gp --set current grid location to grid position list index
gRegion = {} --grow region
table.insert(gRegion,{gx,gy})
for i=1,tSize do
adjList = getAdjacentGridLocations(gx,gy)
if #adjList < 1 then --exit loop if there are no more adjacent spaces available
break
end
rd = math.random(1,#adjList) --random direction to grow from adjacent list
grid[adjList[rd][1]][adjList[rd][2]] = gp
table.insert(gRegion,{adjList[rd][1],adjList[rd][2]})
end
--get adjacent list after done growing region
adjList = getAdjacentGridLocations(gx,gy)
if #adjList < 1 then
adjList = getAllAdjacentGridLocations(gx,gy)
else
if random(1,5) >= 2 then
adjList = getAllAdjacentGridLocations(gx,gy)
end
end
sri = math.random(1,#gRegion) --select station random region index
psx = (gRegion[sri][1] - (gbHigh/2))*gSize + random(-gSize/2*.95,gSize/2*.95) --place station x coordinate
psy = (gRegion[sri][2] - (gbHigh/2))*gSize + random(-gSize/2*.95,gSize/2*.95) --place station y coordinate
pStation = placeDHStation(psx,psy,"RandomHumanNeutral","Human Navy")
pStation.comms_data.goods.food = {quantity = math.random(5,10), cost = 1}
if random(1,10) <= 9 then pStation.comms_data.goods.medicine = {quantity = math.random(5,10), cost = 5} end
table.insert(stationList,pStation) --save station in general station list
table.insert(friendlyStationList,pStation) --save station in friendly station list
if j == 1 then --identify first station as home station
homeStation = pStation
homeStation.comms_data.probe_launch_repair = true
homeStation.comms_data.scan_repair = true
homeStation.comms_data.hack_repair = true
homeStation.comms_data.combat_maneuver_repair = true
homeStation:setRestocksScanProbes(true)
homeStation:setRepairDocked(true)
homeStation:setSharesEnergyWithDocked(true)
end
if #gossipSnippets > 0 then
if gp % 2 == 0 then
ni = math.random(1,#gossipSnippets)
pStation.gossip = gossipSnippets[ni]
table.remove(gossipSnippets,ni)
end
end
gp = gp + 1 --set next station number
rn = math.random(1,#adjList) --random next station start location
gx = adjList[rn][1]
gy = adjList[rn][2]
end
--insert a planet
tSize = 7
grid[gx][gy] = gp
gRegion = {}
table.insert(gRegion,{gx,gy})
for i=1,tSize do
adjList = getAdjacentGridLocations(gx,gy)
if #adjList < 1 then
break
end
rd = math.random(1,#adjList)
grid[adjList[rd][1]][adjList[rd][2]] = gp
table.insert(gRegion,{adjList[rd][1],adjList[rd][2]})
end
adjList = getAdjacentGridLocations(gx,gy)
if #adjList < 1 then
adjList = getAllAdjacentGridLocations(gx,gy)
else
if random(1,5) >= 2 then
adjList = getAllAdjacentGridLocations(gx,gy)
end
end
sri = math.random(1,#gRegion)
aldx = (gRegion[sri][1] - (gbHigh/2))*gSize
aldy = (gRegion[sri][2] - (gbHigh/2))*gSize
alderaan= Planet():setPosition(aldx,aldy):setPlanetRadius(3000):setDistanceFromMovementPlane(-2000):setCallSign("Alderaan")
alderaan:setPlanetSurfaceTexture("planets/planet-1.png"):setPlanetCloudTexture("planets/clouds-1.png")
alderaan:setPlanetAtmosphereTexture("planets/atmosphere.png"):setPlanetAtmosphereColor(0.2,0.2,1.0)
alderaan:setAxialRotationTime(400.0):setDescription(_("scienceDescription-planet", "Lush planet with only mild seasonal variations"))
stationAnet = SpaceStation():setTemplate("Small Station"):setFaction("Independent")
stationAnet:setPosition(aldx,aldy+3000):setCallSign("ANet"):setDescription(_("scienceDescription-station", "Alderaan communications network hub"))
stationAnet.angle = 90
gp = gp + 1
rn = math.random(1,#adjList)
gx = adjList[rn][1]
gy = adjList[rn][2]
--place independent stations
stationFaction = "Independent"
fb = gp --set faction boundary (between friendly and neutral)
for j=1,30 do
tSize = math.random(2,5) --tack on to region size
grid[gx][gy] = gp
gRegion = {} --grow region
table.insert(gRegion,{gx,gy})
for i=1,tSize do
adjList = getAdjacentGridLocations(gx,gy)
if #adjList < 1 then
break
end
rd = math.random(1,#adjList) --random direction to grow from adjacent list
grid[adjList[rd][1]][adjList[rd][2]] = gp
table.insert(gRegion,{adjList[rd][1],adjList[rd][2]})
end
--get list after done growing region
adjList = getAdjacentGridLocations(gx,gy)
if #adjList < 1 then
adjList = getFactionAdjacentGridLocations(gx,gy)
if #adjList < 1 then
adjList = getAllAdjacentGridLocations(gx,gy)
end
else
nextStationChoice = random(1,5)
if nextStationChoice >= 3 then
adjList = getFactionAdjacentGridLocations(gx,gy)
if #adjList < 1 then
adjList = getAllAdjacentGridLocations(gx,gy)
end
elseif nextStationChoice <= 2 then
adjList = getAllAdjacentGridLocations(gx,gy)
end
end
sri = math.random(1,#gRegion) --select station random region index
psx = (gRegion[sri][1] - (gbHigh/2))*gSize + random(-gSize/2*.95,gSize/2*.95) --place station x coordinate
psy = (gRegion[sri][2] - (gbHigh/2))*gSize + random(-gSize/2*.95,gSize/2*.95) --place station y coordinate
pStation = placeDHStation(psx,psy,"RandomHumanNeutral","Independent")
table.insert(stationList,pStation)
gp = gp + 1 --set next station number
rn = math.random(1,#adjList) --random next station start location
gx = adjList[rn][1]
gy = adjList[rn][2]
end
--insert a black hole
tSize = 7
grid[gx][gy] = gp
gRegion = {}
table.insert(gRegion,{gx,gy})
for i=1,tSize do
adjList = getAdjacentGridLocations(gx,gy)
if #adjList < 1 then
break
end
rd = math.random(1,#adjList)
grid[adjList[rd][1]][adjList[rd][2]] = gp
table.insert(gRegion,{adjList[rd][1],adjList[rd][2]})
end
adjList = getAdjacentGridLocations(gx,gy)
if #adjList < 1 then
adjList = getAllAdjacentGridLocations(gx,gy)
else
if random(1,5) >= 2 then
adjList = getAllAdjacentGridLocations(gx,gy)
end
end
sri = math.random(1,#gRegion)
bhx = (gRegion[sri][1] - (gbHigh/2))*gSize
bhy = (gRegion[sri][2] - (gbHigh/2))*gSize
BlackHole():setPosition(bhx,bhy)
gp = gp + 1
rn = math.random(1,#adjList)
gx = adjList[rn][1]
gy = adjList[rn][2]
--place enemy stations (from generic pool)
stationFaction = "Kraylor"
fb = gp --set faction boundary (between neutral and enemy)
for j=1,5 do
tSize = math.random(3,6) --tack on to region size
grid[gx][gy] = gp
gRegion = {} --grow region
table.insert(gRegion,{gx,gy})
for i=1,tSize do
adjList = getAdjacentGridLocations(gx,gy)
if #adjList < 1 then
break
end
rd = math.random(1,#adjList) --random direction to grow from adjacent list
grid[adjList[rd][1]][adjList[rd][2]] = gp
table.insert(gRegion,{adjList[rd][1],adjList[rd][2]})
end
--get list after done growing region
adjList = getAdjacentGridLocations(gx,gy)
if #adjList < 1 then
adjList = getFactionAdjacentGridLocations(gx,gy)
if #adjList < 1 then
adjList = getAllAdjacentGridLocations(gx,gy)
end
else
if random(1,5) >= 3 then
adjList = getFactionAdjacentGridLocations(gx,gy)
if #adjList < 1 then
adjList = getAllAdjacentGridLocations(gx,gy)
end
end
end
sri = math.random(1,#gRegion) --select station random region index
psx = (gRegion[sri][1] - (gbHigh/2))*gSize + random(-gSize/2*.95,gSize/2*.95) --place station x coordinate
psy = (gRegion[sri][2] - (gbHigh/2))*gSize + random(-gSize/2*.95,gSize/2*.95) --place station y coordinate
pStation = placeDHStation(psx,psy,"RandomGenericSinister","Kraylor")
if diagnostic then
pStation:setCallSign(pStation:getCallSign() .. string.format(" %i",j))
end
table.insert(enemyStationList,pStation)
gp = gp + 1 --set next station number
rn = math.random(1,#adjList) --random next station start location
gx = adjList[rn][1]
gy = adjList[rn][2]
end
--place enemy stations (from enemy pool)
stationFaction = "Kraylor"
fb = gp --set faction boundary (between enemy and enemy leadership)
for j=1,2 do
tSize = math.random(4,6) --tack on to region size
grid[gx][gy] = gp
gRegion = {} --grow region
table.insert(gRegion,{gx,gy})
for i=1,tSize do
adjList = getAdjacentGridLocations(gx,gy)
if #adjList < 1 then
break
end
rd = math.random(1,#adjList) --random direction to grow from adjacent list
grid[adjList[rd][1]][adjList[rd][2]] = gp
table.insert(gRegion,{adjList[rd][1],adjList[rd][2]})
end
--get list after done growing region
adjList = getAdjacentGridLocations(gx,gy)
if #adjList < 1 then
adjList = getFactionAdjacentGridLocations(gx,gy)
if #adjList < 1 then
adjList = getAllAdjacentGridLocations(gx,gy)
end
else
if random(1,5) >= 3 then
adjList = getFactionAdjacentGridLocations(gx,gy)
if #adjList < 1 then
adjList = getAllAdjacentGridLocations(gx,gy)
end
end
end
sri = math.random(1,#gRegion) --select station random region index
psx = (gRegion[sri][1] - (gbHigh/2))*gSize + random(-gSize/2*.95,gSize/2*.95) --place station x coordinate
psy = (gRegion[sri][2] - (gbHigh/2))*gSize + random(-gSize/2*.95,gSize/2*.95) --place station y coordinate
pStation = placeDHStation(psx,psy,"Sinister","Kraylor")
table.insert(enemyStationList,pStation)
if j == 2 then --identify last placed enemy station as target enemy station
targetEnemyStation = pStation
if diagnostic then
pStation:setCallSign(pStation:getCallSign() .. " Target")
end
end
gp = gp + 1 --set next station number
rn = math.random(1,#adjList) --random next station start location
gx = adjList[rn][1]
gy = adjList[rn][2]
end
--show adjacent list with a bunch of small stations for testing result purposes
--[[--
if #adjList >= 1 then
for i=1,#adjList do
tsix = adjList[i][1]
tsiy = adjList[i][2]
tsx = (tsix - 250)*gSize
tsy = (tsiy - 250)*gSize
SpaceStation():setTemplate("Small Station"):setCallSign(string.format("%i i:%i x:%i y:%i",sPool,i,tsix,tsiy)):setPosition(tsx,tsy)
end
end
--]]--
if not diagnostic then
--placeRandomAroundPoint(Nebula,math.random(10,30),1,150000,0,0)
local nebula_count = math.random(10,30)
local nebula_list = placeRandomListAroundPoint(Nebula,nebula_count,1,150000,0,0)
local nebula_index = 0
for i=1,#nebula_list do
nebula_list[i].lose = false
nebula_list[i].gain = false
end
coolant_nebula = {}
for i=1,math.random(math.floor(nebula_count/2)) do
nebula_index = math.random(1,#nebula_list)
table.insert(coolant_nebula,nebula_list[nebula_index])
table.remove(nebula_list,nebula_index)
if math.random(1,100) < 50 then
coolant_nebula[#coolant_nebula].lose = true
else
coolant_nebula[#coolant_nebula].gain = true
end
end
nebula_list = {}
for i=1,#movingNebulae do
movingNebulae[i].lose = false
movingNebulae[i].gain = false
table.insert(nebula_list,movingNebulae[i])
end
for i=1,math.random(math.floor(#nebula_list/2)) do
nebula_index = math.random(1,#nebula_list)
table.insert(coolant_nebula,nebula_list[nebula_index])
table.remove(nebula_list,nebula_index)
if math.random(1,100) < 50 then
coolant_nebula[#coolant_nebula].lose = true
else
coolant_nebula[#coolant_nebula].gain = true
end
end
end
fx, fy = homeStation:getPosition()
ex, ey = targetEnemyStation:getPosition()
mnx = (fx+ex)/2
mny = (fy+ey)/2
Nebula():setPosition(mnx,mny)
startingFriendlyStations = #friendlyStationList
startingNeutralStations = #stationList - #friendlyStationList
startingEnemyStations = #enemyStationList
originalStationList = stationList --save for statistics
end
function placeDHStation(x,y,name,faction,size)
if faction == nil then
if stationFaction ~= nil then
faction = stationFaction
else
faction = "Independent"
end
end
station_template_chance = {
["Small Station"] = 0,