-
Notifications
You must be signed in to change notification settings - Fork 2
/
scenario_59_border.lua
executable file
·15849 lines (15838 loc) · 649 KB
/
scenario_59_border.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: Borderline Fever
-- Description: War temperature rises along the border between Human Navy space and Kraylor space. The treaty holds for now, but the diplomats and intelligence operatives fear the Kraylors are about to break the treaty. We must maintain the treaty despite provocation until war is formally declared.
---
--- Version 5
-- Type: Replayable Mission
-- Variation[Easy]: Easy goals and/or enemies
-- Variation[Hard]: Hard goals and/or enemies
-- Variation[Quixotic]: Practically insurmountable goals and/or enemies
-- Variation[Timed]: Victory if some human navy stations and player ships survive for 30 minutes
-- Variation[Timed Easy]: Victory if some human navy stations and player ships survive for 30 minutes, Easy goals and/or enemies
-- Variation[Timed Hard]: Victory if some human navy stations and player ships survive for 30 minutes, Hard goals and/or enemies
-- Variation[Timed Quixotic]: Victory if some human navy stations and player ships survive for 30 minutes, Practically insurmountable goals and/or enemies
-- to do items:
-- Station warning of enemies in area (helpful warnings - shuffle stations)
require("utils.lua")
--------------------
-- Initialization --
--------------------
function init()
popupGMDebug = "once"
scenario_version = "5.1.0"
print(string.format(" ----- Scenario: Borderline Fever ----- Version %s -----",scenario_version))
print(_VERSION)
game_state = "paused"
stored_fixed_names = { --change table name to predefined_player_ships to default to fixed names
{name = "Phoenix", control_code = "VULCAN515"},
{name = "Callisto", control_code = "GALILEO678"},
{name = "Charybdis", control_code = "ROYALE777"},
{name = "Sentinel", control_code = "NOG345"},
}
-- Make the createPlayerShip... functions accessible from other scripts (including exec.lua)
local scenario = {}
scenario.createPlayerShipBlazon = createPlayerShipBlazon
scenario.createPlayerShipHeadhunter = createPlayerShipHeadhunter
scenario.createPlayerShipNarsil = createPlayerShipNarsil
scenario.createPlayerShipSimian = createPlayerShipSimian
scenario.createPlayerShipSpinstar = createPlayerShipSpinstar
scenario.createPlayerShipSpyder = createPlayerShipSpyder
scenario.createPlayerShipSting = createPlayerShipSting
scenario.gatherStats = gatherStats
print("Example of calling a function via http API, assuming you start EE with parameter httpserver=8080 (or it's in options.ini):")
print('curl --data "getScriptStorage().scenario.createPlayerShipSting()" http://localhost:8080/exec.lua')
local storage = getScriptStorage()
storage.scenario = scenario
-- starryUtil v2
starryUtil={
math={
-- linear interpolation
-- mostly intended as an aid to make code more readable
lerp=function(a,b,t)
assert(type(a)=="number")
assert(type(b)=="number")
assert(type(t)=="number")
return a + t * (b - a);
end
},
debug={
-- get a multi-line string for the number of objects at the current time
-- intended to be used via addGMMessage or print, but there may be other uses
-- it may be worth considering adding a function which would return an array rather than a string
getNumberOfObjectsString=function()
local all_objects=getAllObjects()
local object_counts={}
--first up we accumulate the number of each type of object
for i=1,#all_objects do
local object_type=all_objects[i].typeName
local current_count=object_counts[object_type]
if current_count==nil then
current_count=0
end
object_counts[object_type]=current_count+1
end
-- we want the ordering to be stable so we build a key list
local sorted_counts={}
for type in pairs(object_counts) do
table.insert(sorted_counts, type)
end
table.sort(sorted_counts)
--lastly we build the output
local output=""
for _,object_type in ipairs(sorted_counts) do
output=output..string.format("%s: %i\n",object_type,object_counts[object_type])
end
return output..string.format("\nTotal: %i",#all_objects)
end
},
}
banner = {}
banner["number_of_players"] = 0
banner["player_strength"] = 0
banner["player"] = {}
banner["Human Navy"] = {}
banner["Kraylor"] = {}
defaultGameTimeLimitInMinutes = 30 --final: 30 (lowered for test)
rawKraylorShipStrength = 0
rawHumanShipStrength = 0
prefix_length = 0
suffix_index = 0
--These random range values are in seconds, not minutes
--Place in variables to facilitate testing and tinkering
--random range 1 final: 120, 300 (lowered for test) initial attack, pincer attack, vengence
lrr1 = 120 --lower random range
urr1 = 300 --upper random range
--random range 2 final: 120, 500 (lowered for test) initial attack, pincer attack, vengence
lrr2 = 120 --lower random range
urr2 = 500 --upper random range
--random range 3 final: 120, 180 (lowered for test) initial attack, pincer attack, vengence
lrr3 = 120 --lower random range
urr3 = 180 --upper random range
--random range 4 final: 30, 300 (lowered for test) treaty for timed game
lrr4 = 30
urr4 = 300
--random range 4 final: 240, 540 (lowered for test) treaty for game with no time limit
lrr5 = 240
urr5 = 540
--end of game victory/defeat values
enemyDestructionVictoryCondition = 70 --final: 70
friendlyDestructionDefeatCondition = 50 --final: 50
destructionDifferenceEndCondition = 20 --final: 20
--enemy strength evaluation; ratio of stations to ships. Must add up to 1
enemyStationComponentWeight = .65
enemyShipComponentWeight = .35
--friendly strength evaluation; ratio of friendly stations, neutral stations and friendly ships. Must add up to 1
friendlyStationComponentWeight = .5
neutralStationComponentWeight = .1
friendlyShipComponentWeight = .4
repeatExitBoundary = 100
setVariations()
initDiagnostic = false
diagnostic = false
muckDiagnostic = false
stationCommsDiagnostic = false
shipCommsDiagnostic = false
optionalMissionDiagnostic = false
paDiagnostic = false
plot3diagnostic = false
plot1Diagnostic = false
updateDiagnostic = false
healthDiagnostic = false
plot2diagnostic = false
endStatDiagnostic = false
printDetailedStats = true
change_enemy_order_diagnostic = false
distance_diagnostic = false
setConstants() --missle type names, template names and scores, deployment directions, player ship names, etc.
repeat
setGossipSnippets()
populateStationPool()
setBorderZones() --establish neutral border zone and other zones
buildStationsPlus() --put stations and other things in and out of the neutral border zone
if initDiagnostic then print("weird zone adjustment count: " .. wzac) end
--be sure initial spawn point (0,0) is inside the inner zone defining human territory
spawnInInnerZone = false
spawnMarker = VisualAsteroid():setPosition(0,0)
spawnInInnerZone = innerZone:isInside(spawnMarker)
spawnMarker:destroy()
--be sure each side has at least a minimal number of stations
if wzac > 0 or #kraylorStationList < 5 or #humanStationList < 5 or not spawnInInnerZone then
resetStationsPlus()
end
until(wzac < 1 and #kraylorStationList >= 5 and #humanStationList >= 5 and spawnInInnerZone)
if not diagnostic then --get rid of temporary set up zones
for i=1,#innerZoneList do
innerZoneList[i]:destroy()
end
for i=1,#outerZoneList do
outerZoneList[i]:destroy()
end
end
setFleets() --give each side some ships
setEnemyStationDefenses() --give enemy stations defensive mechanisms
setOptionalMissions() --scatter upgrade missions around the stations
setCharacterNames() --add decoy character names to stations
plot1 = treatyHolds --start main plot with the treaty in place
treaty = true
initialAssetsEvaluated = false
plotSW = stationWarning
plotC = autoCoolant --enable buttons for turning on and off automated cooling
plotCI = cargoInventory --manage button on relay/operations to show cargo inventory
plotH = healthCheck --Damage to ship can kill repair crew members
healthCheckTimer = 5
healthCheckTimerInterval = 5
plotPB = playerBorderCheck --monitor players positions relative to neutral border zone
plotPWC = playerWarCrimeCheck --be sure players do not commit war crimes
plotED = enemyDefenseCheck
plotEB = enemyBorderCheck
plotER = enemyReinforcements
plotMF = muckAndFlies
enemyEverDetected = false
enemyBorderCheckInterval = 3
enemyBorderCheckTimer = enemyBorderCheckInterval
plotKT = kraylorTransportPlot
kraylorTransportList = {}
kraylorTransportSpawnDelay = 20
plotIT = independentTransportPlot
independentTransportList = {}
independentTransportSpawnDelay = 20
plotFT = friendlyTransportPlot
friendlyTransportList = {}
friendlyTransportSpawnDelay = 20
plotEW = endWar
endWarTimerInterval = 3
endWarTimer = endWarTimerInterval
plotDGM = dynamicGameMasterButtons
plotPA = personalAmbush
plotCN = coolantNebulae
plotSS = spinalShip
plotExDk = expediteDockCheck
plotShowPlayerInfo = showPlayerInfoOnConsole
plotMining = checkForMining
enemyVesselDestroyedNameList = {}
enemyVesselDestroyedType = {}
enemyVesselDestroyedValue = {}
friendlyVesselDestroyedNameList = {}
friendlyVesselDestroyedType = {}
friendlyVesselDestroyedValue = {}
friendlyStationDestroyedNameList = {}
friendlyStationDestroyedValue = {}
enemyStationDestroyedNameList = {}
enemyStationDestroyedValue = {}
neutralStationDestroyedNameList = {}
neutralStationDestroyedValue = {}
enemy_reverts = {}
revert_timer_interval = 7
revert_timer = revert_timer_interval
plotRevert = revertWait
primaryOrders = ""
secondaryOrders = ""
optionalOrders = ""
mainGMButtons()
end
function setVariations()
if string.find(getScenarioVariation(),"Easy") then
difficulty = .5
adverseEffect = .999
coolant_loss = .99999
coolant_gain = .01
ersAdj = 10
enemyDestructionVictoryCondition = enemyDestructionVictoryCondition*1.1
friendlyDestructionDefeatCondition = friendlyDestructionDefeatCondition*.9
destructionDifferenceEndCondition = destructionDifferenceEndCondition*1.1
elseif string.find(getScenarioVariation(),"Hard") then
difficulty = 2
adverseEffect = .99
coolant_loss = .9999
coolant_gain = .0001
ersAdj = -5
enemyDestructionVictoryCondition = enemyDestructionVictoryCondition*.9
friendlyDestructionDefeatCondition = friendlyDestructionDefeatCondition*1.1
destructionDifferenceEndCondition = destructionDifferenceEndCondition*.9
elseif string.find(getScenarioVariation(),"Quixotic") then
difficulty = 5
adverseEffect = .9
coolant_loss = .999
coolant_gain = .0001
ersAdj = -10
enemyDestructionVictoryCondition = enemyDestructionVictoryCondition*.8
friendlyDestructionDefeatCondition = friendlyDestructionDefeatCondition*1.2
destructionDifferenceEndCondition = destructionDifferenceEndCondition*.8
else
difficulty = 1 --default (normal)
adverseEffect = .995
coolant_loss = .99995
coolant_gain = .001
ersAdj = 0
end
if string.find(getScenarioVariation(),"Timed") then
playWithTimeLimit = true
gameTimeLimit = defaultGameTimeLimitInMinutes*60
plot2 = timedGame
else
gameTimeLimit = 0
playWithTimeLimit = false
end
end
function setConstants()
missile_types = {'Homing', 'Nuke', 'Mine', 'EMP', 'HVLI'}
pool_selectivity = "full"
template_pool_size = 5
ship_template = { --ordered by relative strength
["Gnat"] = {strength = 2, create = gnat},
["Lite Drone"] = {strength = 3, create = droneLite},
["Jacket Drone"] = {strength = 4, create = droneJacket},
["Ktlitan Drone"] = {strength = 4, create = stockTemplate},
["Heavy Drone"] = {strength = 5, create = droneHeavy},
["MT52 Hornet"] = {strength = 5, create = stockTemplate},
["MU52 Hornet"] = {strength = 5, create = stockTemplate},
["MV52 Hornet"] = {strength = 6, create = hornetMV52},
["Adder 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},
["Phobos R2"] = {strength = 13, create = phobosR2},
["Missile Cruiser"] = {strength = 14, create = stockTemplate},
["Waddle 5"] = {strength = 15, create = waddle5},
["Jade 5"] = {strength = 15, create = jade5},
["Phobos T3"] = {strength = 15, create = stockTemplate},
["Piranha F8"] = {strength = 15, create = stockTemplate},
["Piranha F12"] = {strength = 15, create = stockTemplate},
["Piranha F12.M"] = {strength = 16, create = stockTemplate},
["Phobos M3"] = {strength = 16, create = stockTemplate},
["Karnack"] = {strength = 17, create = stockTemplate},
["Gunship"] = {strength = 17, create = stockTemplate},
["Cruiser"] = {strength = 18, create = stockTemplate},
["Nirvana R5"] = {strength = 19, create = stockTemplate},
["Nirvana R5A"] = {strength = 20, create = stockTemplate},
["Adv. Gunship"] = {strength = 20, create = stockTemplate},
["Ktlitan Worker"] = {strength = 21, create = stockTemplate},
["Storm"] = {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},
["Tempest"] = {strength = 30, create = tempest},
["Strikeship"] = {strength = 30, create = stockTemplate},
["Cucaracha"] = {strength = 36, create = cucaracha},
["Predator"] = {strength = 42, create = predator},
["Ktlitan Breaker"] = {strength = 45, create = stockTemplate},
["Hurricane"] = {strength = 46, create = hurricane},
["Ktlitan Feeder"] = {strength = 48, create = stockTemplate},
["Atlantis X23"] = {strength = 50, create = stockTemplate},
["K2 Breaker"] = {strength = 55, create = k2breaker},
["Ktlitan Destroyer"] = {strength = 50, create = stockTemplate},
["Atlantis Y42"] = {strength = 60, create = atlantisY42},
["Blockade Runner"] = {strength = 65, create = stockTemplate},
["Starhammer II"] = {strength = 70, create = stockTemplate},
["Enforcer"] = {strength = 75, create = enforcer},
["Dreadnought"] = {strength = 80, create = stockTemplate},
["Starhammer III"] = {strength = 85, create = starhammerIII},
["Starhammer V"] = {strength = 90, create = starhammerV},
["Battlestation"] = {strength = 100, create = stockTemplate},
["Tyr"] = {strength = 150, create = tyr},
["Odin"] = {strength = 250, create = stockTemplate},
}
formation_delta = {
["square"] = {
x = {0,1,0,-1, 0,1,-1, 1,-1,2,0,-2, 0,2,-2, 2,-2,2, 2,-2,-2,1,-1, 1,-1,0, 0,3,-3,1, 1,3,-3,-1,-1, 3,-3,2, 2,3,-3,-2,-2, 3,-3,3, 3,-3,-3,4,0,-4, 0,4,-4, 4,-4,-4,-4,-4,-4,-4,-4,4, 4,4, 4,4, 4, 1,-1, 2,-2, 3,-3,1,-1,2,-2,3,-3,5,-5,0, 0,5, 5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,5, 5,5, 5,5, 5,5, 5, 1,-1, 2,-2, 3,-3, 4,-4,1,-1,2,-2,3,-3,4,-4},
y = {0,0,1, 0,-1,1,-1,-1, 1,0,2, 0,-2,2,-2,-2, 2,1,-1, 1,-1,2, 2,-2,-2,3,-3,0, 0,3,-3,1, 1, 3,-3,-1,-1,3,-3,2, 2, 3,-3,-2,-2,3,-3, 3,-3,0,4, 0,-4,4,-4,-4, 4, 1,-1, 2,-2, 3,-3,1,-1,2,-2,3,-3,-4,-4,-4,-4,-4,-4,4, 4,4, 4,4, 4,0, 0,5,-5,5,-5, 5,-5, 1,-1, 2,-2, 3,-3, 4,-4,1,-1,2,-2,3,-3,4,-4,-5,-5,-5,-5,-5,-5,-5,-5,5, 5,5, 5,5, 5,5, 5},
},
["hexagonal"] = {
x = {0,2,-2,1,-1, 1,-1,4,-4,0, 0,2,-2,-2, 2,3,-3, 3,-3,6,-6,1,-1, 1,-1,3,-3, 3,-3,4,-4, 4,-4,5,-5, 5,-5,8,-8,4,-4, 4,-4,5,5 ,-5,-5,2, 2,-2,-2,0, 0,6, 6,-6,-6,7, 7,-7,-7,10,-10,5, 5,-5,-5,6, 6,-6,-6,7, 7,-7,-7,8, 8,-8,-8,9, 9,-9,-9,3, 3,-3,-3,1, 1,-1,-1,12,-12,6,-6, 6,-6,7,-7, 7,-7,8,-8, 8,-8,9,-9, 9,-9,10,-10,10,-10,11,-11,11,-11,4,-4, 4,-4,2,-2, 2,-2,0, 0},
y = {0,0, 0,1, 1,-1,-1,0, 0,2,-2,2,-2, 2,-2,1,-1,-1, 1,0, 0,3, 3,-3,-3,3,-3,-3, 3,2,-2,-2, 2,1,-1,-1, 1,0, 0,4,-4,-4, 4,3,-3, 3,-3,4,-4, 4,-4,4,-4,2,-2, 2,-2,1,-1, 1,-1, 0, 0,5,-5, 5,-5,4,-4, 4,-4,3,-3, 3,-7,2,-2, 2,-2,1,-1, 1,-1,5,-5, 5,-5,5,-5, 5,-5, 0, 0,6, 6,-6,-6,5, 5,-5,-5,4, 4,-4,-4,3, 3,-3,-3, 2, 2,-2, -2, 1, 1,-1, -1,6, 6,-6,-6,6, 6,-6,-6,6,-6},
},
["pyramid"] = {
[1] = {
{angle = 0, distance = 0},
},
[2] = {
{angle = -1, distance = 1},
{angle = 1, distance = 1},
},
[3] = {
{angle = 0, distance = 0},
{angle = -1, distance = 1},
{angle = 1, distance = 1},
},
[4] = {
{angle = 0, distance = 0},
{angle = -1, distance = 1},
{angle = 1, distance = 1},
{angle = 0, distance = 2},
},
[5] = {
{angle = 0, distance = 0},
{angle = -1, distance = 1},
{angle = 1, distance = 1},
{angle = -2, distance = 2},
{angle = 2, distance = 2},
},
[6] = {
{angle = 0, distance = 0},
{angle = -1, distance = 1},
{angle = 1, distance = 1},
{angle = -2, distance = 2},
{angle = 2, distance = 2},
{angle = 0, distance = 2},
},
[7] = {
{angle = 0, distance = 0},
{angle = -1, distance = 1},
{angle = 1, distance = 1},
{angle = -2, distance = 2},
{angle = 2, distance = 2},
{angle = -3, distance = 3},
{angle = 3, distance = 3},
},
[8] = {
{angle = 0, distance = 0},
{angle = -1, distance = 1},
{angle = 1, distance = 1},
{angle = -2, distance = 2},
{angle = 2, distance = 2},
{angle = 0, distance = 2},
{angle = -3, distance = 3},
{angle = 3, distance = 3},
},
[9] = {
{angle = 0, distance = 0},
{angle = -1, distance = 1},
{angle = 1, distance = 1},
{angle = -2, distance = 2},
{angle = 2, distance = 2},
{angle = -3, distance = 3},
{angle = 3, distance = 3},
{angle = -4, distance = 4},
{angle = 4, distance = 4},
},
[10] = {
{angle = 0, distance = 0},
{angle = -1, distance = 1},
{angle = 1, distance = 1},
{angle = -2, distance = 2},
{angle = 2, distance = 2},
{angle = 0, distance = 2},
{angle = -3, distance = 3},
{angle = 3, distance = 3},
{angle = -2, distance = 3},
{angle = 2, distance = 3},
},
[11] = {
{angle = 0, distance = 0},
{angle = -1, distance = 1},
{angle = 1, distance = 1},
{angle = -2, distance = 2},
{angle = 2, distance = 2},
{angle = -3, distance = 3},
{angle = 3, distance = 3},
{angle = -4, distance = 4},
{angle = 4, distance = 4},
{angle = -3, distance = 4},
{angle = 3, distance = 4},
},
[12] = {
{angle = 0, distance = 0},
{angle = -1, distance = 1},
{angle = 1, distance = 1},
{angle = -2, distance = 2},
{angle = 2, distance = 2},
{angle = 0, distance = 2},
{angle = -3, distance = 3},
{angle = 3, distance = 3},
{angle = -2, distance = 3},
{angle = 2, distance = 3},
{angle = -1, distance = 3},
{angle = 1, distance = 3},
},
[13] = {
{angle = 0, distance = 0},
{angle = -1, distance = 1},
{angle = 1, distance = 1},
{angle = -2, distance = 2},
{angle = 2, distance = 2},
{angle = -3, distance = 3},
{angle = 3, distance = 3},
{angle = 0, distance = 3},
{angle = -2, distance = 4},
{angle = 2, distance = 4},
{angle = -1, distance = 5},
{angle = 1, distance = 5},
{angle = 0, distance = 6},
},
[14] = {
{angle = 0, distance = 0},
{angle = -1, distance = 1},
{angle = 1, distance = 1},
{angle = -2, distance = 2},
{angle = 2, distance = 2},
{angle = 0, distance = 2},
{angle = -3, distance = 3},
{angle = 3, distance = 3},
{angle = 0, distance = 4},
{angle = -2, distance = 4},
{angle = 2, distance = 4},
{angle = -1, distance = 5},
{angle = 1, distance = 5},
{angle = 0, distance = 6},
},
[15] = {
{angle = 0, distance = 0},
{angle = -1, distance = 1},
{angle = 1, distance = 1},
{angle = -2, distance = 2},
{angle = 2, distance = 2},
{angle = 0, distance = 2},
{angle = -3, distance = 3},
{angle = 3, distance = 3},
{angle = 0, distance = 3},
{angle = 0, distance = 4},
{angle = -2, distance = 4},
{angle = 2, distance = 4},
{angle = -1, distance = 5},
{angle = 1, distance = 5},
{angle = 0, distance = 6},
},
},
}
max_pyramid_tier = 15
playerShipStats = { ["MP52 Hornet"] = { strength = 7, cargo = 3, distance = 100, long_range_radar = 18000, short_range_radar = 4000, tractor = false, mining = false },
["Piranha"] = { strength = 16, cargo = 8, distance = 200, long_range_radar = 25000, short_range_radar = 6000, tractor = false, mining = false },
["Flavia P.Falcon"] = { strength = 13, cargo = 15, distance = 200, long_range_radar = 40000, short_range_radar = 5000, tractor = true, mining = true },
["Phobos M3P"] = { strength = 19, cargo = 10, distance = 200, long_range_radar = 25000, short_range_radar = 5000, tractor = true, mining = false },
["Atlantis"] = { strength = 52, cargo = 6, distance = 400, long_range_radar = 30000, short_range_radar = 5000, tractor = true, mining = true },
["Player Cruiser"] = { strength = 40, cargo = 6, distance = 400, long_range_radar = 30000, short_range_radar = 5000, tractor = false, mining = false },
["Player Missile Cr."] = { strength = 45, cargo = 8, distance = 200, long_range_radar = 35000, short_range_radar = 6000, tractor = false, mining = false },
["Player Fighter"] = { strength = 7, cargo = 3, distance = 100, long_range_radar = 15000, short_range_radar = 4500, tractor = false, mining = false },
["Benedict"] = { strength = 10, cargo = 9, distance = 400, long_range_radar = 30000, short_range_radar = 5000, tractor = true, mining = true },
["Kiriya"] = { strength = 10, cargo = 9, distance = 400, long_range_radar = 35000, short_range_radar = 5000, tractor = true, mining = true },
["Striker"] = { strength = 8, cargo = 4, distance = 200, long_range_radar = 35000, short_range_radar = 5000, tractor = false, mining = false },
["ZX-Lindworm"] = { strength = 8, cargo = 3, distance = 100, long_range_radar = 18000, short_range_radar = 5500, tractor = false, mining = false },
["Repulse"] = { strength = 14, cargo = 12, distance = 200, long_range_radar = 38000, short_range_radar = 5000, tractor = true, mining = false },
["Ender"] = { strength = 100, cargo = 20, distance = 2000,long_range_radar = 45000, short_range_radar = 7000, tractor = true, mining = false },
["Nautilus"] = { strength = 12, cargo = 7, distance = 200, long_range_radar = 22000, short_range_radar = 4000, tractor = false, mining = false },
["Hathcock"] = { strength = 30, cargo = 6, distance = 200, long_range_radar = 35000, short_range_radar = 6000, tractor = false, mining = true },
["Maverick"] = { strength = 45, cargo = 5, distance = 200, long_range_radar = 20000, short_range_radar = 4000, tractor = false, mining = true },
["Crucible"] = { strength = 45, cargo = 5, distance = 200, long_range_radar = 20000, short_range_radar = 6000, tractor = false, mining = false },
["Proto-Atlantis"] = { strength = 40, cargo = 4, distance = 400, long_range_radar = 30000, short_range_radar = 4500, tractor = false, mining = true },
["Stricken"] = { strength = 40, cargo = 4, distance = 200, long_range_radar = 20000, short_range_radar = 4000, tractor = false, mining = false },
["Surkov"] = { strength = 35, cargo = 6, distance = 200, long_range_radar = 35000, short_range_radar = 6000, tractor = false, mining = false },
["Redhook"] = { strength = 11, cargo = 8, distance = 200, long_range_radar = 20000, short_range_radar = 6000, tractor = false, mining = false },
["Pacu"] = { strength = 18, cargo = 7, distance = 200, long_range_radar = 20000, short_range_radar = 6000, tractor = false, mining = false },
["Phobos T2"] = { strength = 19, cargo = 9, distance = 200, long_range_radar = 25000, short_range_radar = 5000, tractor = true, mining = false },
["Wombat"] = { strength = 13, cargo = 3, distance = 100, long_range_radar = 18000, short_range_radar = 6000, tractor = false, mining = false },
["Holmes"] = { strength = 35, cargo = 6, distance = 200, long_range_radar = 35000, short_range_radar = 4000, tractor = true, mining = false },
["Focus"] = { strength = 35, cargo = 4, distance = 200, long_range_radar = 32000, short_range_radar = 5000, tractor = false, mining = true },
["Flavia 2C"] = { strength = 25, cargo = 12, distance = 200, long_range_radar = 30000, short_range_radar = 5000, tractor = false, mining = true },
["Destroyer IV"] = { strength = 25, cargo = 5, distance = 400, long_range_radar = 30000, short_range_radar = 5000, tractor = false, mining = false },
["Destroyer III"] = { strength = 25, cargo = 7, distance = 200, long_range_radar = 30000, short_range_radar = 5000, tractor = false, mining = false },
["MX-Lindworm"] = { strength = 10, cargo = 3, distance = 100, long_range_radar = 30000, short_range_radar = 5000, tractor = false, mining = false },
["Striker LX"] = { strength = 16, cargo = 4, distance = 200, long_range_radar = 20000, short_range_radar = 4000, tractor = false, mining = false },
["Maverick XP"] = { strength = 23, cargo = 5, distance = 200, long_range_radar = 25000, short_range_radar = 7000, tractor = true, mining = false },
["Era"] = { strength = 14, cargo = 14, distance = 200, long_range_radar = 50000, short_range_radar = 5000, tractor = true, mining = true },
["Squid"] = { strength = 14, cargo = 8, distance = 200, long_range_radar = 25000, short_range_radar = 5000, tractor = false, mining = false },
["Atlantis II"] = { strength = 60, cargo = 6, distance = 400, long_range_radar = 30000, short_range_radar = 5000, tractor = true, mining = true },
}
--Player ship name lists to supplant standard randomized call sign generation
playerShipNamesFor = {}
-- TODO switch to spelling with space or dash matching the type name
playerShipNamesFor["MP52 Hornet"] = {"Dragonfly","Scarab","Mantis","Yellow Jacket","Jimminy","Flik","Thorny","Buzz"}
playerShipNamesFor["Piranha"] = {"Razor","Biter","Ripper","Voracious","Carnivorous","Characid","Vulture","Predator"}
playerShipNamesFor["Flavia P.Falcon"] = {"Ladyhawke","Hunter","Seeker","Gyrefalcon","Kestrel","Magpie","Bandit","Buccaneer"}
playerShipNamesFor["Phobos M3P"] = {"Blinder","Shadow","Distortion","Diemos","Ganymede","Castillo","Thebe","Retrograde"}
playerShipNamesFor["Atlantis"] = {"Excaliber","Thrasher","Punisher","Vorpal","Protang","Drummond","Parchim","Coronado"}
playerShipNamesFor["Player Cruiser"] = {"Excelsior","Velociraptor","Thunder","Kona","Encounter","Perth","Aspern","Panther"}
playerShipNamesFor["Player Missile Cr."] = {"Projectus","Hurlmeister","Flinger","Ovod","Amatola","Nakhimov","Antigone"}
playerShipNamesFor["Player Fighter"] = {"Buzzer","Flitter","Zippiticus","Hopper","Molt","Stinger","Stripe"}
playerShipNamesFor["Benedict"] = {"Elizabeth","Ford","Vikramaditya","Liaoning","Avenger","Naruebet","Washington","Lincoln","Garibaldi","Eisenhower"}
playerShipNamesFor["Kiriya"] = {"Cavour","Reagan","Gaulle","Paulo","Truman","Stennis","Kuznetsov","Roosevelt","Vinson","Old Salt"}
playerShipNamesFor["Striker"] = {"Sparrow","Sizzle","Squawk","Crow","Phoenix","Snowbird","Hawk"}
playerShipNamesFor["ZX-Lindworm"] = {"Seagull","Catapult","Blowhard","Flapper","Nixie","Pixie","Tinkerbell"}
playerShipNamesFor["Repulse"] = {"Fiddler","Brinks","Loomis","Mowag","Patria","Pandur","Terrex","Komatsu","Eitan"}
playerShipNamesFor["Ender"] = {"Mongo","Godzilla","Leviathan","Kraken","Jupiter","Saturn"}
playerShipNamesFor["Nautilus"] = {"October", "Abdiel", "Manxman", "Newcon", "Nusret", "Pluton", "Amiral", "Amur", "Heinkel", "Dornier"}
playerShipNamesFor["Hathcock"] = {"Hayha", "Waldron", "Plunkett", "Mawhinney", "Furlong", "Zaytsev", "Pavlichenko", "Pegahmagabow", "Fett", "Hawkeye", "Hanzo"}
playerShipNamesFor["Proto-Atlantis"] = {"Narsil", "Blade", "Decapitator", "Trisect", "Sabre"}
playerShipNamesFor["Maverick"] = {"Angel", "Thunderbird", "Roaster", "Magnifier", "Hedge"}
playerShipNamesFor["Crucible"] = {"Sling", "Stark", "Torrid", "Kicker", "Flummox"}
playerShipNamesFor["Surkov"] = {"Sting", "Sneak", "Bingo", "Thrill", "Vivisect"}
playerShipNamesFor["Stricken"] = {"Blazon", "Streaker", "Pinto", "Spear", "Javelin"}
playerShipNamesFor["Atlantis II"] = {"Spyder", "Shelob", "Tarantula", "Aragog", "Charlotte"}
playerShipNamesFor["Redhook"] = {"Headhunter", "Thud", "Troll", "Scalper", "Shark"}
playerShipNamesFor["Destroyer III"] = {"Trebuchet", "Pitcher", "Mutant", "Gronk", "Methuselah"}
playerShipNamesFor["Leftovers"] = {"Foregone","Righteous","Masher"}
commonGoods = {"food","medicine","nickel","platinum","gold","dilithium","tritanium","luxury","cobalt","impulse","warp","shield","tractor","repulsor","beam","optic","robotic","filament","transporter","sensor","communication","autodoc","lifter","android","nanites","software","circuit","battery"}
componentGoods = {"impulse","warp","shield","tractor","repulsor","beam","optic","robotic","filament","transporter","sensor","communication","autodoc","lifter","android","nanites","software","circuit","battery"}
mineralGoods = {"nickel","platinum","gold","dilithium","tritanium","cobalt"}
vapor_goods = {"gold pressed latinum","unobtanium","eludium","impossibrium"}
characterNames = {"Frank Brown",
"Joyce Miller",
"Harry Jones",
"Emma Davis",
"Zhang Wei Chen",
"Yu Yan Li",
"Li Wei Wang",
"Li Na Zhao",
"Sai Laghari",
"Anaya Khatri",
"Vihaan Reddy",
"Trisha Varma",
"Henry Gunawan",
"Putri Febrian",
"Stanley Hartono",
"Citra Mulyadi",
"Bashir Pitafi",
"Hania Kohli",
"Gohar Lehri",
"Sohelia Lau",
"Gabriel Santos",
"Ana Melo",
"Lucas Barbosa",
"Juliana Rocha",
"Habib Oni",
"Chinara Adebayo",
"Tanimu Ali",
"Naija Bello",
"Shamim Khan",
"Barsha Tripura",
"Sumon Das",
"Farah Munsi",
"Denis Popov",
"Pasha Sokolov",
"Burian Ivanov",
"Radka Vasiliev",
"Jose Hernandez",
"Victoria Garcia",
"Miguel Lopez",
"Renata Rodriguez"}
hitZonePermutations = {
{"warp","beamweapons","reactor"},
{"jumpdrive","beamweapons","reactor"},
{"impulse","beamweapons","reactor"},
{"warp","missilesystem","reactor"},
{"jumpdrive","missilesystem","reactor"},
{"impulse","missilesystem","reactor"},
{"warp","beamweapons","maneuver"},
{"jumpdrive","beamweapons","maneuver"},
{"impulse","beamweapons","maneuver"},
{"warp","missilesystem","maneuver"},
{"jumpdrive","missilesystem","maneuver"},
{"impulse","missilesystem","maneuver"},
{"warp","beamweapons","frontshield"},
{"jumpdrive","beamweapons","frontshield"},
{"impulse","beamweapons","frontshield"},
{"warp","missilesystem","frontshield"},
{"jumpdrive","missilesystem","frontshield"},
{"impulse","missilesystem","frontshield"},
{"warp","beamweapons","rearshield"},
{"jumpdrive","beamweapons","rearshield"},
{"impulse","beamweapons","rearshield"},
{"warp","missilesystem","rearshield"},
{"jumpdrive","missilesystem","rearshield"},
{"impulse","missilesystem","rearshield"},
{"warp","reactor","maneuver"},
{"jumpdrive","reactor","maneuver"},
{"impulse","reactor","maneuver"},
{"warp","reactor","frontshield"},
{"jumpdrive","reactor","frontshield"},
{"impulse","reactor","frontshield"},
{"warp","reactor","rearshield"},
{"jumpdrive","reactor","rearshield"},
{"impulse","reactor","rearshield"},
{"warp","maneuver","frontshield"},
{"jumpdrive","maneuver","frontshield"},
{"impulse","maneuver","frontshield"},
{"warp","maneuver","rearshield"},
{"jumpdrive","maneuver","rearshield"},
{"impulse","maneuver","rearshield"},
{"beamweapons","beamweapons","maneuver"},
{"missilesystem","beamweapons","maneuver"},
{"beamweapons","beamweapons","frontshield"},
{"missilesystem","beamweapons","frontshield"},
{"beamweapons","beamweapons","rearshield"},
{"missilesystem","beamweapons","rearshield"},
{"beamweapons","maneuver","frontshield"},
{"missilesystem","maneuver","frontshield"},
{"beamweapons","maneuver","rearshield"},
{"missilesystem","maneuver","rearshield"},
{"reactor","maneuver","frontshield"},
{"reactor","maneuver","rearshield"}
}
--minutes and danger
enemyReinforcementSchedule = {
{30, 1},
{20, 1},
{15, 2},
{12, 2},
{15, 3},
{15, 3},
{20, 4}
}
show_player_info = true
show_only_player_name = true
info_choice = 0
info_choice_max = 5
mining_beam_string = {
"beam_orange.png",
"beam_yellow.png",
"fire_sphere_texture.png"
}
mining_drain = .00025 * difficulty
end
function setGossipSnippets()
gossipSnippets = {}
table.insert(gossipSnippets,"I hear the head of operations has a thing for his administrative assistant") --1
table.insert(gossipSnippets,"My mining friends tell me Krak or Kruk is about to strike it rich") --2
table.insert(gossipSnippets,"Did you know you can usually hire replacement repair crew cheaper at friendly stations?") --3
table.insert(gossipSnippets,"Under their uniforms, the Kraylors have an extra appendage. I wonder what they use it for") --4
table.insert(gossipSnippets,"The Kraylors may be human navy enemies, but they make some mighty fine BBQ Mynock") --5
table.insert(gossipSnippets,"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,"Docking bay 7 has interesting mind altering substances for sale, but they're monitored between 1900 and 2300") --7
table.insert(gossipSnippets,"Watch the sky tonight in quadrant J around 2243. It should be spectacular") --8
table.insert(gossipSnippets,"I think the shuttle pilot has a tame miniature Ktlitan caged in his quarters. Sometimes I hear it at night") --9
table.insert(gossipSnippets,"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,"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
end
function setCharacterNames()
for i=1,#humanStationList do
curStation = humanStationList[i]
if curStation.comms_data.character == nil then
if #characterNames > 0 then
nameChoice = math.random(1,#characterNames)
curStation.comms_data.character = characterNames[nameChoice]
table.remove(characterNames,nameChoice)
end
end
end
end
-- Terrain and environment creation functions
function setBorderZones()
local borderStartAngle = random(0,360) --gross orientation of default spawn point to neutral border zone
local borderStartX, borderStartY = vectorFromAngle(borderStartAngle,random(3500,4900))
local halfLength = random(8000,15000)
local zoneLimit = 150000
borderZone = {}
innerZoneList = {}
outerZoneList = {}
local bzi = 1 --border zone index
--Note: "left" and "right" refer to someone standing on the 2D board at the spawn point (0,0) looking at the zones being added;
-- "inner" means closer to the spawn point, "outer" means further away from the spawn point
local borderZoneLeftInnerX = {}
local borderZoneLeftInnerY = {}
local borderZoneRightInnerX = {}
local borderZoneRightInnerY = {}
local borderZoneLeftOuterX = {}
local borderZoneLeftOuterY = {}
local borderZoneRightOuterX = {}
local borderZoneRightOuterY = {}
local bzsx, bzsy = vectorFromAngle(borderStartAngle+270,halfLength) --border zone start x and y coordinates
table.insert(borderZoneLeftInnerX, borderStartX+bzsx)
table.insert(borderZoneLeftInnerY, borderStartY+bzsy)
bzsx, bzsy = vectorFromAngle(borderStartAngle+90,halfLength) --border sone start x and y coordinates
table.insert(borderZoneRightInnerX, borderStartX+bzsx)
table.insert(borderZoneRightInnerY, borderStartY+bzsy)
local bendAngle = random(1,30) --inner and outer edges are parallel, connecting edges are bent
local negativeBendCount = 0
local positiveBendCount = 0
if random(1,100) < 50 then
negativeBendCount = negativeBendCount + bendAngle
bendAngle = -1*bendAngle
else
positiveBendCount = positiveBendCount + bendAngle
end
bendAngle = borderStartAngle + bendAngle
if bendAngle < 0 then
bendAngle = bendAngle + 360
end
local borderZoneWidth = random(10000,15000)
bzsx, bzsy = vectorFromAngle(bendAngle,borderZoneWidth) --border zone start x and y coordinates
table.insert(borderZoneLeftOuterX,borderZoneLeftInnerX[bzi]+bzsx)
table.insert(borderZoneLeftOuterY,borderZoneLeftInnerY[bzi]+bzsy)
table.insert(borderZoneRightOuterX,borderZoneRightInnerX[bzi]+bzsx)
table.insert(borderZoneRightOuterY,borderZoneRightInnerY[bzi]+bzsy)
local cbz = Zone():setPoints(borderZoneLeftInnerX[bzi],borderZoneLeftInnerY[bzi], --current border zone
borderZoneLeftOuterX[bzi],borderZoneLeftOuterY[bzi],
borderZoneRightOuterX[bzi],borderZoneRightOuterY[bzi],
borderZoneRightInnerX[bzi],borderZoneRightInnerY[bzi])
cbz:setColor(0,0,255)
cbz.detect = 0
table.insert(borderZone,cbz)
intelGatherArtifacts = {}
local igax, igay = vectorFromAngle(borderStartAngle+180,borderZoneWidth*2+random(1,30000))
local iga = Artifact():setPosition(borderStartX+igax,borderStartY+igay):setScanningParameters(difficulty*2,difficulty*2):setRadarSignatureInfo(random(0,1),random(0,1),random(0,1)):setModel("SensorBuoyMKIII"):setCallSign("Sensor Buoy"):setFaction("Human Navy")
table.insert(intelGatherArtifacts,iga)
local ilx, ily = vectorFromAngle(borderStartAngle+210,zoneLimit) --inner left x and y coordinates
local irx, iry = vectorFromAngle(borderStartAngle+150,zoneLimit) --inner right x and y coordinates
local ciz = Zone():setPoints(borderZoneLeftInnerX[bzi],borderZoneLeftInnerY[bzi], --current inner zone
borderZoneRightInnerX[bzi],borderZoneRightInnerY[bzi],
borderZoneRightInnerX[bzi]+irx,borderZoneRightInnerY[bzi]+iry,
borderZoneLeftInnerX[bzi]+ilx,borderZoneLeftInnerY[bzi]+ily)
if initDiagnostic then ciz:setColor(50,50,50) end
table.insert(innerZoneList,ciz)
local olx, oly = vectorFromAngle(borderStartAngle+330,zoneLimit) --outer left x and y coordinates
local orx, ory = vectorFromAngle(borderStartAngle+30,zoneLimit) --outer right x and y coordinates
local coz = Zone():setPoints(borderZoneRightOuterX[bzi],borderZoneRightOuterY[bzi], --current outer zone
borderZoneLeftOuterX[bzi],borderZoneLeftOuterY[bzi],
borderZoneLeftOuterX[bzi]+olx,borderZoneLeftOuterY[bzi]+oly,
borderZoneRightOuterX[bzi]+orx,borderZoneRightOuterY[bzi]+ory)
if initDiagnostic then coz:setColor(0,128,0) end
table.insert(outerZoneList,coz)
--new zone on the left
bzi = bzi + 1
table.insert(borderZoneRightInnerX,borderZoneLeftInnerX[bzi-1])
table.insert(borderZoneRightInnerY,borderZoneLeftInnerY[bzi-1])
table.insert(borderZoneRightOuterX,borderZoneLeftOuterX[bzi-1])
table.insert(borderZoneRightOuterY,borderZoneLeftOuterY[bzi-1])
local bzx, bzy = vectorFromAngle(bendAngle+270,random(20000,30000)) --border zone x and y corrdinates
table.insert(borderZoneLeftInnerX,borderZoneRightInnerX[bzi]+bzx)
table.insert(borderZoneLeftInnerY,borderZoneRightInnerY[bzi]+bzy)
local upBound = 2 + negativeBendCount + positiveBendCount
local cutOff = math.min(positiveBendCount,negativeBendCount)
local newBend = random(1,30)
if negativeBendCount < positiveBendCount then
if random(1,upBound) <= cutOff then
negativeBendCount = negativeBendCount + newBend
newBend = -1*newBend
else
positiveBendCount = positiveBendCount + newBend
end
else
if random(1,upBound) <= cutOff then
positiveBendCount = positiveBendCount + newBend
else
newBend = -1*newBend
negativeBendCount = negativeBendCount + newBend
end
end
newBend = bendAngle + newBend
if newBend < 0 then
newBend = newBend + 360
end
bzx, bzy = vectorFromAngle(newBend,borderZoneWidth)
table.insert(borderZoneLeftOuterX,borderZoneLeftInnerX[bzi]+bzx)
table.insert(borderZoneLeftOuterY,borderZoneLeftInnerY[bzi]+bzy)
--new zone on the right
table.insert(borderZoneLeftInnerX,borderZoneRightInnerX[bzi-1])
table.insert(borderZoneLeftInnerY,borderZoneRightInnerY[bzi-1])
table.insert(borderZoneLeftOuterX,borderZoneRightOuterX[bzi-1])
table.insert(borderZoneLeftOuterY,borderZoneRightOuterY[bzi-1])
bzx, bzy = vectorFromAngle(bendAngle+90,random(20000,30000))
table.insert(borderZoneRightInnerX,borderZoneRightInnerX[bzi-1]+bzx)
table.insert(borderZoneRightInnerY,borderZoneRightInnerY[bzi-1]+bzy)
bzx, bzy = vectorFromAngle(newBend,borderZoneWidth)
table.insert(borderZoneRightOuterX,borderZoneRightInnerX[bzi+1]+bzx)
table.insert(borderZoneRightOuterY,borderZoneRightInnerY[bzi+1]+bzy)
--establish current border zone (cbz)
cbz = Zone():setPoints(borderZoneLeftInnerX[bzi],borderZoneLeftInnerY[bzi],
borderZoneLeftOuterX[bzi],borderZoneLeftOuterY[bzi],
borderZoneRightOuterX[bzi],borderZoneRightOuterY[bzi],
borderZoneRightInnerX[bzi],borderZoneRightInnerY[bzi])
cbz:setColor(0,0,255)
cbz.detect = 0
table.insert(borderZone,cbz)
igax, igay = vectorFromAngle(bendAngle+180,borderZoneWidth*2+random(1,30000))
iga = Artifact():setPosition((borderZoneLeftInnerX[2]+borderZoneRightInnerX[2])/2+igax,(borderZoneLeftInnerY[2]+borderZoneRightInnerY[2])/2+igay):setScanningParameters(difficulty*2,difficulty*2):setRadarSignatureInfo(random(0,1),random(0,1),random(0,1)):setModel("SensorBuoyMKIII"):setCallSign("Sensor Buoy"):setFaction("Human Navy")
table.insert(intelGatherArtifacts,iga)
ilx, ily = vectorFromAngle(bendAngle+210,zoneLimit)
irx, iry = vectorFromAngle(bendAngle+150,zoneLimit)
ciz = Zone():setPoints(borderZoneLeftInnerX[bzi],borderZoneLeftInnerY[bzi],
borderZoneRightInnerX[bzi],borderZoneRightInnerY[bzi],
borderZoneRightInnerX[bzi]+irx,borderZoneRightInnerY[bzi]+iry,
borderZoneLeftInnerX[bzi]+ilx,borderZoneLeftInnerY[bzi]+ily)
if initDiagnostic then ciz:setColor(100,100,100) end
table.insert(innerZoneList,ciz)
olx, oly = vectorFromAngle(bendAngle+330,zoneLimit)
orx, ory = vectorFromAngle(bendAngle+30,zoneLimit)
coz = Zone():setPoints(borderZoneRightOuterX[bzi],borderZoneRightOuterY[bzi],
borderZoneLeftOuterX[bzi],borderZoneLeftOuterY[bzi],
borderZoneLeftOuterX[bzi]+olx,borderZoneLeftOuterY[bzi]+oly,
borderZoneRightOuterX[bzi]+orx,borderZoneRightOuterY[bzi]+ory)
if initDiagnostic then coz:setColor(0,192,0) end
table.insert(outerZoneList,coz)
bzi = bzi + 1
cbz = Zone():setPoints(borderZoneLeftInnerX[bzi],borderZoneLeftInnerY[bzi],
borderZoneLeftOuterX[bzi],borderZoneLeftOuterY[bzi],
borderZoneRightOuterX[bzi],borderZoneRightOuterY[bzi],
borderZoneRightInnerX[bzi],borderZoneRightInnerY[bzi])
cbz:setColor(0,0,255)
cbz.detect = 0
table.insert(borderZone,cbz)
igax, igay = vectorFromAngle(bendAngle+180,borderZoneWidth*2+random(1,30000))
iga = Artifact():setPosition((borderZoneLeftInnerX[3]+borderZoneRightInnerX[3])/2+igax,(borderZoneLeftInnerY[3]+borderZoneRightInnerY[3])/2+igay):setScanningParameters(difficulty*2,difficulty*2):setRadarSignatureInfo(random(0,1),random(0,1),random(0,1)):setModel("SensorBuoyMKIII"):setCallSign("Sensor Buoy"):setFaction("Human Navy")
table.insert(intelGatherArtifacts,iga)
ilx, ily = vectorFromAngle(bendAngle+210,zoneLimit)
irx, iry = vectorFromAngle(bendAngle+150,zoneLimit)
ciz = Zone():setPoints(borderZoneLeftInnerX[bzi],borderZoneLeftInnerY[bzi],
borderZoneRightInnerX[bzi],borderZoneRightInnerY[bzi],
borderZoneRightInnerX[bzi]+irx,borderZoneRightInnerY[bzi]+iry,
borderZoneLeftInnerX[bzi]+ilx,borderZoneLeftInnerY[bzi]+ily)
if initDiagnostic then ciz:setColor(150,150,150) end
table.insert(innerZoneList,ciz)
olx, oly = vectorFromAngle(bendAngle+330,zoneLimit)
orx, ory = vectorFromAngle(bendAngle+30,zoneLimit)
coz = Zone():setPoints(borderZoneRightOuterX[bzi],borderZoneRightOuterY[bzi],
borderZoneLeftOuterX[bzi],borderZoneLeftOuterY[bzi],
borderZoneLeftOuterX[bzi]+olx,borderZoneLeftOuterY[bzi]+oly,
borderZoneRightOuterX[bzi]+orx,borderZoneRightOuterY[bzi]+ory)
if initDiagnostic then coz:setColor(0,255,0) end
table.insert(outerZoneList,coz)
for i=1,20 do
bendAngle = newBend
--new bend applies to both left and right zones to be added
upBound = 2 + negativeBendCount + positiveBendCount
cutOff = math.max(positiveBendCount,negativeBendCount)
newBend = random(1,30)
if negativeBendCount < positiveBendCount then
if random(1,upBound) <= cutOff then
negativeBendCount = negativeBendCount + newBend
newBend = -1*newBend
else
positiveBendCount = positiveBendCount + newBend
end
else
if random(1,upBound) <= cutOff then
positiveBendCount = positiveBendCount + newBend
else
negativeBendCount = negativeBendCount + newBend
newBend = -1*newBend
end
end
newBend = bendAngle + newBend
if newBend < 0 then
newBend = newBend + 360
end
if initDiagnostic then print(string.format("i: %i, bend angle: %.1f, new bend angle: %.1f, upBound: %.1f, pos: %.1f, neg: %.1f, cutoff: %.1f",i,bendAngle,newBend,upBound,positiveBendCount,negativeBendCount,cutOff)) end
--new zone on the left
table.insert(borderZoneRightInnerX,borderZoneLeftInnerX[bzi-1])
table.insert(borderZoneRightInnerY,borderZoneLeftInnerY[bzi-1])
table.insert(borderZoneRightOuterX,borderZoneLeftOuterX[bzi-1])
table.insert(borderZoneRightOuterY,borderZoneLeftOuterY[bzi-1])
bzx, bzy = vectorFromAngle(bendAngle+270,random(20000,30000))
table.insert(borderZoneLeftInnerX,borderZoneRightInnerX[bzi+1]+bzx)
table.insert(borderZoneLeftInnerY,borderZoneRightInnerY[bzi+1]+bzy)
bzx, bzy = vectorFromAngle(newBend,borderZoneWidth)
table.insert(borderZoneLeftOuterX,borderZoneLeftInnerX[bzi+1]+bzx)
table.insert(borderZoneLeftOuterY,borderZoneLeftInnerY[bzi+1]+bzy)
bzi = bzi + 1
cbz = Zone():setPoints(borderZoneLeftInnerX[bzi],borderZoneLeftInnerY[bzi],
borderZoneLeftOuterX[bzi],borderZoneLeftOuterY[bzi],
borderZoneRightOuterX[bzi],borderZoneRightOuterY[bzi],
borderZoneRightInnerX[bzi],borderZoneRightInnerY[bzi])
cbz:setColor(0,0,255)
cbz.detect = 0
table.insert(borderZone,cbz)
if i == 1 then
igax, igay = vectorFromAngle(bendAngle+180,borderZoneWidth*2+random(1,30000))
iga = Artifact():setPosition((borderZoneLeftInnerX[4]+borderZoneRightInnerX[4])/2+igax,(borderZoneLeftInnerY[4]+borderZoneRightInnerY[4])/2+igay):setScanningParameters(difficulty*2,difficulty*2):setRadarSignatureInfo(random(0,1),random(0,1),random(0,1)):setModel("SensorBuoyMKIII"):setCallSign("Sensor Buoy"):setFaction("Human Navy")
table.insert(intelGatherArtifacts,iga)
end
if i == 2 then
igax, igay = vectorFromAngle(bendAngle+180,borderZoneWidth*2+random(1,30000))
iga = Artifact():setPosition((borderZoneLeftInnerX[5]+borderZoneRightInnerX[5])/2+igax,(borderZoneLeftInnerY[5]+borderZoneRightInnerY[5])/2+igay):setScanningParameters(difficulty*2,difficulty*2):setRadarSignatureInfo(random(0,1),random(0,1),random(0,1)):setModel("SensorBuoyMKIII"):setCallSign("Sensor Buoy"):setFaction("Human Navy")
table.insert(intelGatherArtifacts,iga)
end
if i < 3 then
ilx, ily = vectorFromAngle(bendAngle+210,100000)
irx, iry = vectorFromAngle(bendAngle+150,100000)
ciz = Zone():setPoints(borderZoneLeftInnerX[bzi],borderZoneLeftInnerY[bzi],
borderZoneRightInnerX[bzi],borderZoneRightInnerY[bzi],
borderZoneRightInnerX[bzi]+irx,borderZoneRightInnerY[bzi]+iry,
borderZoneLeftInnerX[bzi]+ilx,borderZoneLeftInnerY[bzi]+ily)
if initDiagnostic then ciz:setColor(50,50,50) end
table.insert(innerZoneList,ciz)
olx, oly = vectorFromAngle(bendAngle+330,100000)
orx, ory = vectorFromAngle(bendAngle+30,100000)
coz = Zone():setPoints(borderZoneRightOuterX[bzi],borderZoneRightOuterY[bzi],
borderZoneLeftOuterX[bzi],borderZoneLeftOuterY[bzi],
borderZoneLeftOuterX[bzi]+olx,borderZoneLeftOuterY[bzi]+oly,
borderZoneRightOuterX[bzi]+orx,borderZoneRightOuterY[bzi]+ory)
if initDiagnostic then coz:setColor(0,128,0) end
table.insert(outerZoneList,coz)
end
--new zone on the right
table.insert(borderZoneLeftInnerX,borderZoneRightInnerX[bzi-1])
table.insert(borderZoneLeftInnerY,borderZoneRightInnerY[bzi-1])
table.insert(borderZoneLeftOuterX,borderZoneRightOuterX[bzi-1])
table.insert(borderZoneLeftOuterY,borderZoneRightOuterY[bzi-1])
bzx, bzy = vectorFromAngle(bendAngle+90,random(20000,30000))
table.insert(borderZoneRightInnerX,borderZoneRightInnerX[bzi-1]+bzx)
table.insert(borderZoneRightInnerY,borderZoneRightInnerY[bzi-1]+bzy)
bzx, bzy = vectorFromAngle(newBend,borderZoneWidth)
table.insert(borderZoneRightOuterX,borderZoneRightInnerX[bzi+1]+bzx)
table.insert(borderZoneRightOuterY,borderZoneRightInnerY[bzi+1]+bzy)
bzi = bzi + 1
cbz = Zone():setPoints(borderZoneLeftInnerX[bzi],borderZoneLeftInnerY[bzi],
borderZoneLeftOuterX[bzi],borderZoneLeftOuterY[bzi],
borderZoneRightOuterX[bzi],borderZoneRightOuterY[bzi],
borderZoneRightInnerX[bzi],borderZoneRightInnerY[bzi])
cbz:setColor(0,0,255)
cbz.detect = 0
table.insert(borderZone,cbz)
if i < 3 then
ilx, ily = vectorFromAngle(bendAngle+210,100000)
irx, iry = vectorFromAngle(bendAngle+150,100000)
ciz = Zone():setPoints(borderZoneLeftInnerX[bzi],borderZoneLeftInnerY[bzi],
borderZoneRightInnerX[bzi],borderZoneRightInnerY[bzi],
borderZoneRightInnerX[bzi]+irx,borderZoneRightInnerY[bzi]+iry,
borderZoneLeftInnerX[bzi]+ilx,borderZoneLeftInnerY[bzi]+ily)
if initDiagnostic then ciz:setColor(50,50,50) end
table.insert(innerZoneList,ciz)
olx, oly = vectorFromAngle(bendAngle+330,100000)
orx, ory = vectorFromAngle(bendAngle+30,100000)
coz = Zone():setPoints(borderZoneRightOuterX[bzi],borderZoneRightOuterY[bzi],
borderZoneLeftOuterX[bzi],borderZoneLeftOuterY[bzi],
borderZoneLeftOuterX[bzi]+olx,borderZoneLeftOuterY[bzi]+oly,
borderZoneRightOuterX[bzi]+orx,borderZoneRightOuterY[bzi]+ory)
if initDiagnostic then coz:setColor(0,128,0) end
table.insert(outerZoneList,coz)
end
end
if initDiagnostic then print(string.format("border zones created: %i",bzi)) end