@jtff/miztemplate-lib 3.4.9 → 3.4.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lua/lib/Moose_.lua +271 -274
- package/package.json +1 -1
package/lua/lib/Moose_.lua
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
env.info('*** MOOSE GITHUB Commit Hash ID: 2024-
|
|
1
|
+
env.info('*** MOOSE GITHUB Commit Hash ID: 2024-09-08T13:24:09+02:00-051286acd119752bf389e7fc1bb685ffdee767a1 ***')
|
|
2
2
|
if not MOOSE_DEVELOPMENT_FOLDER then
|
|
3
3
|
MOOSE_DEVELOPMENT_FOLDER='Scripts'
|
|
4
4
|
end
|
|
@@ -14157,6 +14157,10 @@ end
|
|
|
14157
14157
|
end
|
|
14158
14158
|
MStaticInclude=MStaticInclude and MStaticZone
|
|
14159
14159
|
end
|
|
14160
|
+
if self.Filter.Functions and MStaticInclude then
|
|
14161
|
+
local MClientFunc=self:_EvalFilterFunctions(MStatic)
|
|
14162
|
+
MStaticInclude=MStaticInclude and MClientFunc
|
|
14163
|
+
end
|
|
14160
14164
|
return MStaticInclude
|
|
14161
14165
|
end
|
|
14162
14166
|
function SET_STATIC:GetTypeNames(Delimiter)
|
|
@@ -14383,6 +14387,7 @@ if _DATABASE then
|
|
|
14383
14387
|
self:UnHandleEvent(EVENTS.Birth)
|
|
14384
14388
|
self:UnHandleEvent(EVENTS.Dead)
|
|
14385
14389
|
self:UnHandleEvent(EVENTS.Crash)
|
|
14390
|
+
self:UnHandleEvent(EVENTS.PlayerLeaveUnit)
|
|
14386
14391
|
if self.Filter.Zones and self.ZoneTimer and self.ZoneTimer:IsRunning()then
|
|
14387
14392
|
self.ZoneTimer:Stop()
|
|
14388
14393
|
end
|
|
@@ -14394,6 +14399,7 @@ if _DATABASE then
|
|
|
14394
14399
|
self:HandleEvent(EVENTS.Birth,self._EventOnBirth)
|
|
14395
14400
|
self:HandleEvent(EVENTS.Dead,self._EventOnDeadOrCrash)
|
|
14396
14401
|
self:HandleEvent(EVENTS.Crash,self._EventOnDeadOrCrash)
|
|
14402
|
+
self:HandleEvent(EVENTS.PlayerLeaveUnit,self._EventPlayerLeaveUnit)
|
|
14397
14403
|
if self.Filter.Zones then
|
|
14398
14404
|
self.ZoneTimer=TIMER:New(self._ContinousZoneFilter,self)
|
|
14399
14405
|
local timing=self.ZoneTimerInterval or 30
|
|
@@ -14416,7 +14422,7 @@ return self
|
|
|
14416
14422
|
end
|
|
14417
14423
|
function SET_CLIENT:_EventPlayerLeaveUnit(Event)
|
|
14418
14424
|
if Event.IniDCSUnit then
|
|
14419
|
-
if Event.IniObjectCategory==Object.Category.UNIT and Event.IniGroup
|
|
14425
|
+
if Event.IniObjectCategory==Object.Category.UNIT and Event.IniGroup then
|
|
14420
14426
|
local ObjectName,Object=self:FindInDatabase(Event)
|
|
14421
14427
|
if ObjectName then
|
|
14422
14428
|
self:Remove(ObjectName)
|
|
@@ -14722,6 +14728,7 @@ self:_FilterStart()
|
|
|
14722
14728
|
self:HandleEvent(EVENTS.Birth,self._EventOnBirth)
|
|
14723
14729
|
self:HandleEvent(EVENTS.Dead,self._EventOnDeadOrCrash)
|
|
14724
14730
|
self:HandleEvent(EVENTS.Crash,self._EventOnDeadOrCrash)
|
|
14731
|
+
self:HandleEvent(EVENTS.PlayerLeaveUnit,self._EventOnDeadOrCrash)
|
|
14725
14732
|
end
|
|
14726
14733
|
return self
|
|
14727
14734
|
end
|
|
@@ -14831,6 +14838,10 @@ end
|
|
|
14831
14838
|
end
|
|
14832
14839
|
MClientInclude=MClientInclude and MClientZone
|
|
14833
14840
|
end
|
|
14841
|
+
if self.Filter.Functions and MClientInclude then
|
|
14842
|
+
local MClientFunc=self:_EvalFilterFunctions(MClient)
|
|
14843
|
+
MClientInclude=MClientInclude and MClientFunc
|
|
14844
|
+
end
|
|
14834
14845
|
return MClientInclude
|
|
14835
14846
|
end
|
|
14836
14847
|
end
|
|
@@ -14988,6 +14999,10 @@ end
|
|
|
14988
14999
|
MAirbaseInclude=MAirbaseInclude and MAirbaseCategory
|
|
14989
15000
|
end
|
|
14990
15001
|
end
|
|
15002
|
+
if self.Filter.Functions and MAirbaseInclude then
|
|
15003
|
+
local MClientFunc=self:_EvalFilterFunctions(MAirbase)
|
|
15004
|
+
MAirbaseInclude=MAirbaseInclude and MClientFunc
|
|
15005
|
+
end
|
|
14991
15006
|
return MAirbaseInclude
|
|
14992
15007
|
end
|
|
14993
15008
|
end
|
|
@@ -15179,6 +15194,10 @@ end
|
|
|
15179
15194
|
MCargoInclude=MCargoInclude and MCargoPrefix
|
|
15180
15195
|
end
|
|
15181
15196
|
end
|
|
15197
|
+
if self.Filter.Functions and MCargoInclude then
|
|
15198
|
+
local MClientFunc=self:_EvalFilterFunctions(MCargo)
|
|
15199
|
+
MCargoInclude=MCargoInclude and MClientFunc
|
|
15200
|
+
end
|
|
15182
15201
|
return MCargoInclude
|
|
15183
15202
|
end
|
|
15184
15203
|
function SET_CARGO:OnEventNewCargo(EventData)
|
|
@@ -15337,6 +15356,10 @@ end
|
|
|
15337
15356
|
MZoneInclude=MZoneInclude and MZonePrefix
|
|
15338
15357
|
end
|
|
15339
15358
|
end
|
|
15359
|
+
if self.Filter.Functions and MZoneInclude then
|
|
15360
|
+
local MClientFunc=self:_EvalFilterFunctions(MZone)
|
|
15361
|
+
MZoneInclude=MZoneInclude and MClientFunc
|
|
15362
|
+
end
|
|
15340
15363
|
return MZoneInclude
|
|
15341
15364
|
end
|
|
15342
15365
|
function SET_ZONE:OnEventNewZone(EventData)
|
|
@@ -15549,6 +15572,10 @@ end
|
|
|
15549
15572
|
MZoneInclude=MZoneInclude and MZonePrefix
|
|
15550
15573
|
end
|
|
15551
15574
|
end
|
|
15575
|
+
if self.Filter.Functions and MZoneInclude then
|
|
15576
|
+
local MClientFunc=self:_EvalFilterFunctions(MZone)
|
|
15577
|
+
MZoneInclude=MZoneInclude and MClientFunc
|
|
15578
|
+
end
|
|
15552
15579
|
return MZoneInclude
|
|
15553
15580
|
end
|
|
15554
15581
|
function SET_ZONE_GOAL:OnEventNewZoneGoal(EventData)
|
|
@@ -15720,6 +15747,10 @@ end
|
|
|
15720
15747
|
MZoneInclude=MZoneInclude and MGroupCoalition
|
|
15721
15748
|
end
|
|
15722
15749
|
end
|
|
15750
|
+
if self.Filter.Functions and MZoneInclude then
|
|
15751
|
+
local MClientFunc=self:_EvalFilterFunctions(MZone)
|
|
15752
|
+
MZoneInclude=MZoneInclude and MClientFunc
|
|
15753
|
+
end
|
|
15723
15754
|
return MZoneInclude
|
|
15724
15755
|
end
|
|
15725
15756
|
function SET_OPSZONE:OnEventNewZoneGoal(EventData)
|
|
@@ -16056,6 +16087,10 @@ end
|
|
|
16056
16087
|
end
|
|
16057
16088
|
MGroupInclude=MGroupInclude and MGroupPrefix
|
|
16058
16089
|
end
|
|
16090
|
+
if self.Filter.Functions and MGroupInclude then
|
|
16091
|
+
local MClientFunc=self:_EvalFilterFunctions(MGroup)
|
|
16092
|
+
MGroupInclude=MGroupInclude and MClientFunc
|
|
16093
|
+
end
|
|
16059
16094
|
return MGroupInclude
|
|
16060
16095
|
end
|
|
16061
16096
|
end
|
|
@@ -16241,6 +16276,10 @@ end
|
|
|
16241
16276
|
MSceneryInclude=MSceneryInclude and MSceneryRole
|
|
16242
16277
|
end
|
|
16243
16278
|
end
|
|
16279
|
+
if self.Filter.Functions and MSceneryInclude then
|
|
16280
|
+
local MClientFunc=self:_EvalFilterFunctions(MScenery)
|
|
16281
|
+
MSceneryInclude=MSceneryInclude and MClientFunc
|
|
16282
|
+
end
|
|
16244
16283
|
return MSceneryInclude
|
|
16245
16284
|
end
|
|
16246
16285
|
function SET_SCENERY:FilterOnce()
|
|
@@ -16357,6 +16396,10 @@ end
|
|
|
16357
16396
|
end
|
|
16358
16397
|
DCargoInclude=DCargoInclude and DCargoZone
|
|
16359
16398
|
end
|
|
16399
|
+
if self.Filter.Functions and DCargoInclude then
|
|
16400
|
+
local MClientFunc=self:_EvalFilterFunctions(DCargo)
|
|
16401
|
+
DCargoInclude=DCargoInclude and MClientFunc
|
|
16402
|
+
end
|
|
16360
16403
|
return DCargoInclude
|
|
16361
16404
|
end
|
|
16362
16405
|
function SET_DYNAMICCARGO:FilterCoalitions(Coalitions)
|
|
@@ -19560,15 +19603,12 @@ self.SpawnInitCallSignName=string.lower(Name):gsub("^%l",string.upper)
|
|
|
19560
19603
|
return self
|
|
19561
19604
|
end
|
|
19562
19605
|
function SPAWN:InitPositionCoordinate(Coordinate)
|
|
19563
|
-
self:T2({self.SpawnTemplatePrefix,Coordinate:GetVec2()})
|
|
19564
19606
|
self:InitPositionVec2(Coordinate:GetVec2())
|
|
19565
19607
|
return self
|
|
19566
19608
|
end
|
|
19567
19609
|
function SPAWN:InitPositionVec2(Vec2)
|
|
19568
|
-
self:T2({self.SpawnTemplatePrefix,Vec2})
|
|
19569
19610
|
self.SpawnInitPosition=Vec2
|
|
19570
19611
|
self.SpawnFromNewPosition=true
|
|
19571
|
-
self:T2("MaxGroups:"..self.SpawnMaxGroups)
|
|
19572
19612
|
for SpawnGroupID=1,self.SpawnMaxGroups do
|
|
19573
19613
|
self:_SetInitialPosition(SpawnGroupID)
|
|
19574
19614
|
end
|
|
@@ -19596,7 +19636,6 @@ function SPAWN:InitCleanUp(SpawnCleanUpInterval)
|
|
|
19596
19636
|
self.SpawnCleanUpInterval=SpawnCleanUpInterval
|
|
19597
19637
|
self.SpawnCleanUpTimeStamps={}
|
|
19598
19638
|
local SpawnGroup,SpawnCursor=self:GetFirstAliveGroup()
|
|
19599
|
-
self:T2({"CleanUp Scheduler:",SpawnGroup})
|
|
19600
19639
|
self.CleanUpScheduler=SCHEDULER:New(self,self._SpawnCleanUpScheduler,{},1,SpawnCleanUpInterval,0.2)
|
|
19601
19640
|
return self
|
|
19602
19641
|
end
|
|
@@ -19607,7 +19646,6 @@ local SpawnY=0
|
|
|
19607
19646
|
local SpawnXIndex=0
|
|
19608
19647
|
local SpawnYIndex=0
|
|
19609
19648
|
for SpawnGroupID=1,self.SpawnMaxGroups do
|
|
19610
|
-
self:T2({SpawnX,SpawnY,SpawnXIndex,SpawnYIndex})
|
|
19611
19649
|
self.SpawnGroups[SpawnGroupID].Visible=true
|
|
19612
19650
|
self.SpawnGroups[SpawnGroupID].Spawned=false
|
|
19613
19651
|
SpawnXIndex=SpawnXIndex+1
|
|
@@ -19624,6 +19662,7 @@ self.SpawnGroups[SpawnGroupID].SpawnTemplate.lateActivation=true
|
|
|
19624
19662
|
self.SpawnGroups[SpawnGroupID].SpawnTemplate.visible=true
|
|
19625
19663
|
self.SpawnGroups[SpawnGroupID].Visible=true
|
|
19626
19664
|
self:HandleEvent(EVENTS.Birth,self._OnBirth)
|
|
19665
|
+
self:HandleEvent(EVENTS.Dead,self._OnDeadOrCrash)
|
|
19627
19666
|
self:HandleEvent(EVENTS.Crash,self._OnDeadOrCrash)
|
|
19628
19667
|
self:HandleEvent(EVENTS.RemoveUnit,self._OnDeadOrCrash)
|
|
19629
19668
|
self:HandleEvent(EVENTS.UnitLost,self._OnDeadOrCrash)
|
|
@@ -19723,19 +19762,6 @@ function SPAWN:SetSpawnIndex(SpawnIndex)
|
|
|
19723
19762
|
self.SpawnIndex=SpawnIndex or 0
|
|
19724
19763
|
end
|
|
19725
19764
|
function SPAWN:SpawnWithIndex(SpawnIndex,NoBirth)
|
|
19726
|
-
local set=SET_GROUP:New():FilterAlive():FilterPrefixes({self.SpawnTemplatePrefix,self.SpawnAliasPrefix}):FilterOnce()
|
|
19727
|
-
local aliveunits=0
|
|
19728
|
-
set:ForEachGroupAlive(
|
|
19729
|
-
function(grp)
|
|
19730
|
-
aliveunits=aliveunits+grp:CountAliveUnits()
|
|
19731
|
-
end
|
|
19732
|
-
)
|
|
19733
|
-
if aliveunits~=self.AliveUnits then
|
|
19734
|
-
self.AliveUnits=aliveunits
|
|
19735
|
-
self:T2("***** self.AliveUnits accounting failure! Corrected! *****")
|
|
19736
|
-
end
|
|
19737
|
-
set=nil
|
|
19738
|
-
self:T2({SpawnTemplatePrefix=self.SpawnTemplatePrefix,SpawnIndex=SpawnIndex,AliveUnits=self.AliveUnits,SpawnMaxGroups=self.SpawnMaxGroups})
|
|
19739
19765
|
if self:_GetSpawnIndex(SpawnIndex)then
|
|
19740
19766
|
if self.SpawnFromNewPosition then
|
|
19741
19767
|
self:_SetInitialPosition(SpawnIndex)
|
|
@@ -19745,10 +19771,8 @@ self.SpawnGroups[self.SpawnIndex].Group:Activate()
|
|
|
19745
19771
|
else
|
|
19746
19772
|
local SpawnTemplate=self.SpawnGroups[self.SpawnIndex].SpawnTemplate
|
|
19747
19773
|
local SpawnZone=self.SpawnGroups[self.SpawnIndex].SpawnZone
|
|
19748
|
-
self:T2(SpawnTemplate.name)
|
|
19749
19774
|
if SpawnTemplate then
|
|
19750
19775
|
local PointVec3=POINT_VEC3:New(SpawnTemplate.route.points[1].x,SpawnTemplate.route.points[1].alt,SpawnTemplate.route.points[1].y)
|
|
19751
|
-
self:T2({"Current point of ",self.SpawnTemplatePrefix,PointVec3})
|
|
19752
19776
|
if self.SpawnRandomizePosition then
|
|
19753
19777
|
local RandomVec2=PointVec3:GetRandomVec2InRadius(self.SpawnRandomizePositionOuterRadius,self.SpawnRandomizePositionInnerRadius)
|
|
19754
19778
|
local CurrentX=SpawnTemplate.units[1].x
|
|
@@ -19758,7 +19782,6 @@ SpawnTemplate.y=RandomVec2.y
|
|
|
19758
19782
|
for UnitID=1,#SpawnTemplate.units do
|
|
19759
19783
|
SpawnTemplate.units[UnitID].x=SpawnTemplate.units[UnitID].x+(RandomVec2.x-CurrentX)
|
|
19760
19784
|
SpawnTemplate.units[UnitID].y=SpawnTemplate.units[UnitID].y+(RandomVec2.y-CurrentY)
|
|
19761
|
-
self:T2('SpawnTemplate.units['..UnitID..'].x = '..SpawnTemplate.units[UnitID].x..', SpawnTemplate.units['..UnitID..'].y = '..SpawnTemplate.units[UnitID].y)
|
|
19762
19785
|
end
|
|
19763
19786
|
end
|
|
19764
19787
|
if self.SpawnRandomizeUnits then
|
|
@@ -19775,13 +19798,11 @@ inZone=SpawnZone:IsVec2InZone(RandomVec2)
|
|
|
19775
19798
|
end
|
|
19776
19799
|
end
|
|
19777
19800
|
if(not inZone)then
|
|
19778
|
-
self:T2("Could not place unit within zone and within radius!")
|
|
19779
19801
|
RandomVec2=SpawnZone:GetRandomVec2()
|
|
19780
19802
|
end
|
|
19781
19803
|
end
|
|
19782
19804
|
SpawnTemplate.units[UnitID].x=RandomVec2.x
|
|
19783
19805
|
SpawnTemplate.units[UnitID].y=RandomVec2.y
|
|
19784
|
-
self:T2('SpawnTemplate.units['..UnitID..'].x = '..SpawnTemplate.units[UnitID].x..', SpawnTemplate.units['..UnitID..'].y = '..SpawnTemplate.units[UnitID].y)
|
|
19785
19806
|
end
|
|
19786
19807
|
end
|
|
19787
19808
|
local function _Heading(courseDeg)
|
|
@@ -19935,6 +19956,11 @@ end
|
|
|
19935
19956
|
function SPAWN:SpawnScheduled(SpawnTime,SpawnTimeVariation,WithDelay)
|
|
19936
19957
|
local SpawnTime=SpawnTime or 60
|
|
19937
19958
|
local SpawnTimeVariation=SpawnTimeVariation or 0.5
|
|
19959
|
+
if SpawnTime<15 then
|
|
19960
|
+
self:E("****SPAWN SCHEDULED****\nWARNING - Setting a very low SpawnTime heavily impacts your mission performance and CPU time, it is NOT useful to check the alive state of an object every "..tostring(SpawnTime).." seconds.\nSetting to 15 second intervals.\n*****")
|
|
19961
|
+
SpawnTime=15
|
|
19962
|
+
end
|
|
19963
|
+
if SpawnTimeVariation>1 or SpawnTimeVariation<0 then SpawnTimeVariation=0.5 end
|
|
19938
19964
|
if SpawnTime~=nil and SpawnTimeVariation~=nil then
|
|
19939
19965
|
local InitialDelay=0
|
|
19940
19966
|
if WithDelay or self.DelayOnOff==true then
|
|
@@ -19962,7 +19988,6 @@ return self
|
|
|
19962
19988
|
end
|
|
19963
19989
|
function SPAWN:SpawnAtAirbase(SpawnAirbase,Takeoff,TakeoffAltitude,TerminalType,EmergencyAirSpawn,Parkingdata)
|
|
19964
19990
|
local PointVec3=SpawnAirbase:GetCoordinate()
|
|
19965
|
-
self:T2(PointVec3)
|
|
19966
19991
|
Takeoff=Takeoff or SPAWN.Takeoff.Hot
|
|
19967
19992
|
if EmergencyAirSpawn==nil then
|
|
19968
19993
|
EmergencyAirSpawn=true
|
|
@@ -19971,7 +19996,6 @@ if self:_GetSpawnIndex(self.SpawnIndex+1)then
|
|
|
19971
19996
|
local SpawnTemplate=self.SpawnGroups[self.SpawnIndex].SpawnTemplate
|
|
19972
19997
|
if SpawnTemplate then
|
|
19973
19998
|
local GroupAlive=self:GetGroupFromIndex(self.SpawnIndex)
|
|
19974
|
-
self:T2({"Current point of ",self.SpawnTemplatePrefix,SpawnAirbase})
|
|
19975
19999
|
local TemplateGroup=GROUP:FindByName(self.SpawnTemplatePrefix)
|
|
19976
20000
|
local TemplateUnit=TemplateGroup:GetUnit(1)
|
|
19977
20001
|
local group=TemplateGroup
|
|
@@ -20001,7 +20025,6 @@ SpawnPoint.alt=0
|
|
|
20001
20025
|
SpawnPoint.type=GROUPTEMPLATE.Takeoff[Takeoff][1]
|
|
20002
20026
|
SpawnPoint.action=GROUPTEMPLATE.Takeoff[Takeoff][2]
|
|
20003
20027
|
local spawnonground=not(Takeoff==SPAWN.Takeoff.Air)
|
|
20004
|
-
self:T2({spawnonground=spawnonground,TOtype=Takeoff,TOair=Takeoff==SPAWN.Takeoff.Air})
|
|
20005
20028
|
local spawnonship=false
|
|
20006
20029
|
local spawnonfarp=false
|
|
20007
20030
|
local spawnonrunway=false
|
|
@@ -20039,43 +20062,35 @@ local scanstatics=true
|
|
|
20039
20062
|
local scanscenery=false
|
|
20040
20063
|
local verysafe=false
|
|
20041
20064
|
if spawnonship or spawnonfarp or spawnonrunway then
|
|
20042
|
-
self:T2(string.format("Group %s is spawned on farp/ship/runway %s.",self.SpawnTemplatePrefix,SpawnAirbase:GetName()))
|
|
20043
20065
|
nfree=SpawnAirbase:GetFreeParkingSpotsNumber(termtype,true)
|
|
20044
20066
|
spots=SpawnAirbase:GetFreeParkingSpotsTable(termtype,true)
|
|
20045
20067
|
else
|
|
20046
20068
|
if ishelo then
|
|
20047
20069
|
if termtype==nil then
|
|
20048
|
-
self:T2(string.format("Helo group %s is at %s using terminal type %d.",self.SpawnTemplatePrefix,SpawnAirbase:GetName(),AIRBASE.TerminalType.HelicopterOnly))
|
|
20049
20070
|
spots=SpawnAirbase:FindFreeParkingSpotForAircraft(TemplateGroup,AIRBASE.TerminalType.HelicopterOnly,scanradius,scanunits,scanstatics,scanscenery,verysafe,nunits,Parkingdata)
|
|
20050
20071
|
nfree=#spots
|
|
20051
20072
|
if nfree<nunits then
|
|
20052
|
-
self:T2(string.format("Helo group %s is at %s using terminal type %d.",self.SpawnTemplatePrefix,SpawnAirbase:GetName(),AIRBASE.TerminalType.HelicopterUsable))
|
|
20053
20073
|
spots=SpawnAirbase:FindFreeParkingSpotForAircraft(TemplateGroup,AIRBASE.TerminalType.HelicopterUsable,scanradius,scanunits,scanstatics,scanscenery,verysafe,nunits,Parkingdata)
|
|
20054
20074
|
nfree=#spots
|
|
20055
20075
|
end
|
|
20056
20076
|
else
|
|
20057
|
-
self:T2(string.format("Helo group %s is at %s using terminal type %d.",self.SpawnTemplatePrefix,SpawnAirbase:GetName(),termtype))
|
|
20058
20077
|
spots=SpawnAirbase:FindFreeParkingSpotForAircraft(TemplateGroup,termtype,scanradius,scanunits,scanstatics,scanscenery,verysafe,nunits,Parkingdata)
|
|
20059
20078
|
nfree=#spots
|
|
20060
20079
|
end
|
|
20061
20080
|
else
|
|
20062
20081
|
if termtype==nil then
|
|
20063
20082
|
if isbomber or istransport or istanker or isawacs then
|
|
20064
|
-
self:T2(string.format("Transport/bomber group %s is at %s using terminal type %d.",self.SpawnTemplatePrefix,SpawnAirbase:GetName(),AIRBASE.TerminalType.OpenBig))
|
|
20065
20083
|
spots=SpawnAirbase:FindFreeParkingSpotForAircraft(TemplateGroup,AIRBASE.TerminalType.OpenBig,scanradius,scanunits,scanstatics,scanscenery,verysafe,nunits,Parkingdata)
|
|
20066
20084
|
nfree=#spots
|
|
20067
20085
|
if nfree<nunits then
|
|
20068
|
-
self:T2(string.format("Transport/bomber group %s is at %s using terminal type %d.",self.SpawnTemplatePrefix,SpawnAirbase:GetName(),AIRBASE.TerminalType.OpenMedOrBig))
|
|
20069
20086
|
spots=SpawnAirbase:FindFreeParkingSpotForAircraft(TemplateGroup,AIRBASE.TerminalType.OpenMedOrBig,scanradius,scanunits,scanstatics,scanscenery,verysafe,nunits,Parkingdata)
|
|
20070
20087
|
nfree=#spots
|
|
20071
20088
|
end
|
|
20072
20089
|
else
|
|
20073
|
-
self:T2(string.format("Fighter group %s is at %s using terminal type %d.",self.SpawnTemplatePrefix,SpawnAirbase:GetName(),AIRBASE.TerminalType.FighterAircraft))
|
|
20074
20090
|
spots=SpawnAirbase:FindFreeParkingSpotForAircraft(TemplateGroup,AIRBASE.TerminalType.FighterAircraft,scanradius,scanunits,scanstatics,scanscenery,verysafe,nunits,Parkingdata)
|
|
20075
20091
|
nfree=#spots
|
|
20076
20092
|
end
|
|
20077
20093
|
else
|
|
20078
|
-
self:T2(string.format("Plane group %s is at %s using terminal type %s.",self.SpawnTemplatePrefix,SpawnAirbase:GetName(),tostring(termtype)))
|
|
20079
20094
|
spots=SpawnAirbase:FindFreeParkingSpotForAircraft(TemplateGroup,termtype,scanradius,scanunits,scanstatics,scanscenery,verysafe,nunits,Parkingdata)
|
|
20080
20095
|
nfree=#spots
|
|
20081
20096
|
end
|
|
@@ -20138,7 +20153,6 @@ end
|
|
|
20138
20153
|
if not SpawnTemplate.parked then
|
|
20139
20154
|
SpawnTemplate.parked=true
|
|
20140
20155
|
for UnitID=1,nunits do
|
|
20141
|
-
self:T2('Before Translation SpawnTemplate.units['..UnitID..'].x = '..SpawnTemplate.units[UnitID].x..', SpawnTemplate.units['..UnitID..'].y = '..SpawnTemplate.units[UnitID].y)
|
|
20142
20156
|
local UnitTemplate=SpawnTemplate.units[UnitID]
|
|
20143
20157
|
local SX=UnitTemplate.x
|
|
20144
20158
|
local SY=UnitTemplate.y
|
|
@@ -20148,18 +20162,15 @@ local TX=PointVec3.x+(SX-BX)
|
|
|
20148
20162
|
local TY=PointVec3.z+(SY-BY)
|
|
20149
20163
|
if spawnonground then
|
|
20150
20164
|
if spawnonship or spawnonfarp or spawnonrunway then
|
|
20151
|
-
self:T2(string.format("Group %s spawning at farp, ship or runway %s.",self.SpawnTemplatePrefix,SpawnAirbase:GetName()))
|
|
20152
20165
|
SpawnTemplate.units[UnitID].x=PointVec3.x
|
|
20153
20166
|
SpawnTemplate.units[UnitID].y=PointVec3.z
|
|
20154
20167
|
SpawnTemplate.units[UnitID].alt=PointVec3.y
|
|
20155
20168
|
else
|
|
20156
|
-
self:T2(string.format("Group %s spawning at airbase %s on parking spot id %d",self.SpawnTemplatePrefix,SpawnAirbase:GetName(),parkingindex[UnitID]))
|
|
20157
20169
|
SpawnTemplate.units[UnitID].x=parkingspots[UnitID].x
|
|
20158
20170
|
SpawnTemplate.units[UnitID].y=parkingspots[UnitID].z
|
|
20159
20171
|
SpawnTemplate.units[UnitID].alt=parkingspots[UnitID].y
|
|
20160
20172
|
end
|
|
20161
20173
|
else
|
|
20162
|
-
self:T2(string.format("Group %s spawning in air at %s.",self.SpawnTemplatePrefix,SpawnAirbase:GetName()))
|
|
20163
20174
|
SpawnTemplate.units[UnitID].x=TX
|
|
20164
20175
|
SpawnTemplate.units[UnitID].y=TY
|
|
20165
20176
|
SpawnTemplate.units[UnitID].alt=PointVec3.y
|
|
@@ -20169,9 +20180,6 @@ UnitTemplate.parking_id=nil
|
|
|
20169
20180
|
if parkingindex[UnitID]then
|
|
20170
20181
|
UnitTemplate.parking=parkingindex[UnitID]
|
|
20171
20182
|
end
|
|
20172
|
-
self:T2(string.format("Group %s unit number %d: Parking = %s",self.SpawnTemplatePrefix,UnitID,tostring(UnitTemplate.parking)))
|
|
20173
|
-
self:T2(string.format("Group %s unit number %d: Parking ID = %s",self.SpawnTemplatePrefix,UnitID,tostring(UnitTemplate.parking_id)))
|
|
20174
|
-
self:T2('After Translation SpawnTemplate.units['..UnitID..'].x = '..SpawnTemplate.units[UnitID].x..', SpawnTemplate.units['..UnitID..'].y = '..SpawnTemplate.units[UnitID].y)
|
|
20175
20183
|
end
|
|
20176
20184
|
end
|
|
20177
20185
|
SpawnPoint.x=PointVec3.x
|
|
@@ -20211,9 +20219,7 @@ end
|
|
|
20211
20219
|
local Parkingdata={}
|
|
20212
20220
|
for _,TerminalID in pairs(Spots)do
|
|
20213
20221
|
local spot=Airbase:GetParkingSpotData(TerminalID)
|
|
20214
|
-
self:T2({spot=spot})
|
|
20215
20222
|
if spot and spot.Free then
|
|
20216
|
-
self:T2(string.format("Adding parking spot ID=%d TermType=%d",spot.TerminalID,spot.TerminalType))
|
|
20217
20223
|
table.insert(Parkingdata,spot)
|
|
20218
20224
|
end
|
|
20219
20225
|
end
|
|
@@ -20229,12 +20235,10 @@ return nil
|
|
|
20229
20235
|
end
|
|
20230
20236
|
function SPAWN:ParkAircraft(SpawnAirbase,TerminalType,Parkingdata,SpawnIndex)
|
|
20231
20237
|
local PointVec3=SpawnAirbase:GetCoordinate()
|
|
20232
|
-
self:T2(PointVec3)
|
|
20233
20238
|
local Takeoff=SPAWN.Takeoff.Cold
|
|
20234
20239
|
local SpawnTemplate=self.SpawnGroups[SpawnIndex].SpawnTemplate
|
|
20235
20240
|
if SpawnTemplate then
|
|
20236
20241
|
local GroupAlive=self:GetGroupFromIndex(SpawnIndex)
|
|
20237
|
-
self:T2({"Current point of ",self.SpawnTemplatePrefix,SpawnAirbase})
|
|
20238
20242
|
local TemplateGroup=GROUP:FindByName(self.SpawnTemplatePrefix)
|
|
20239
20243
|
local TemplateUnit=TemplateGroup:GetUnit(1)
|
|
20240
20244
|
local ishelo=TemplateUnit:HasAttribute("Helicopters")
|
|
@@ -20261,7 +20265,6 @@ SpawnPoint.alt=0
|
|
|
20261
20265
|
SpawnPoint.type=GROUPTEMPLATE.Takeoff[Takeoff][1]
|
|
20262
20266
|
SpawnPoint.action=GROUPTEMPLATE.Takeoff[Takeoff][2]
|
|
20263
20267
|
local spawnonground=not(Takeoff==SPAWN.Takeoff.Air)
|
|
20264
|
-
self:T2({spawnonground=spawnonground,TOtype=Takeoff,TOair=Takeoff==SPAWN.Takeoff.Air})
|
|
20265
20268
|
local spawnonship=false
|
|
20266
20269
|
local spawnonfarp=false
|
|
20267
20270
|
local spawnonrunway=false
|
|
@@ -20288,43 +20291,35 @@ local scanstatics=true
|
|
|
20288
20291
|
local scanscenery=false
|
|
20289
20292
|
local verysafe=false
|
|
20290
20293
|
if spawnonship or spawnonfarp or spawnonrunway then
|
|
20291
|
-
self:T2(string.format("Group %s is spawned on farp/ship/runway %s.",self.SpawnTemplatePrefix,SpawnAirbase:GetName()))
|
|
20292
20294
|
nfree=SpawnAirbase:GetFreeParkingSpotsNumber(termtype,true)
|
|
20293
20295
|
spots=SpawnAirbase:GetFreeParkingSpotsTable(termtype,true)
|
|
20294
20296
|
else
|
|
20295
20297
|
if ishelo then
|
|
20296
20298
|
if termtype==nil then
|
|
20297
|
-
self:T2(string.format("Helo group %s is at %s using terminal type %d.",self.SpawnTemplatePrefix,SpawnAirbase:GetName(),AIRBASE.TerminalType.HelicopterOnly))
|
|
20298
20299
|
spots=SpawnAirbase:FindFreeParkingSpotForAircraft(TemplateGroup,AIRBASE.TerminalType.HelicopterOnly,scanradius,scanunits,scanstatics,scanscenery,verysafe,nunits,Parkingdata)
|
|
20299
20300
|
nfree=#spots
|
|
20300
20301
|
if nfree<nunits then
|
|
20301
|
-
self:T2(string.format("Helo group %s is at %s using terminal type %d.",self.SpawnTemplatePrefix,SpawnAirbase:GetName(),AIRBASE.TerminalType.HelicopterUsable))
|
|
20302
20302
|
spots=SpawnAirbase:FindFreeParkingSpotForAircraft(TemplateGroup,AIRBASE.TerminalType.HelicopterUsable,scanradius,scanunits,scanstatics,scanscenery,verysafe,nunits,Parkingdata)
|
|
20303
20303
|
nfree=#spots
|
|
20304
20304
|
end
|
|
20305
20305
|
else
|
|
20306
|
-
self:T2(string.format("Helo group %s is at %s using terminal type %d.",self.SpawnTemplatePrefix,SpawnAirbase:GetName(),termtype))
|
|
20307
20306
|
spots=SpawnAirbase:FindFreeParkingSpotForAircraft(TemplateGroup,termtype,scanradius,scanunits,scanstatics,scanscenery,verysafe,nunits,Parkingdata)
|
|
20308
20307
|
nfree=#spots
|
|
20309
20308
|
end
|
|
20310
20309
|
else
|
|
20311
20310
|
if termtype==nil then
|
|
20312
20311
|
if isbomber or istransport then
|
|
20313
|
-
self:T2(string.format("Transport/bomber group %s is at %s using terminal type %d.",self.SpawnTemplatePrefix,SpawnAirbase:GetName(),AIRBASE.TerminalType.OpenBig))
|
|
20314
20312
|
spots=SpawnAirbase:FindFreeParkingSpotForAircraft(TemplateGroup,AIRBASE.TerminalType.OpenBig,scanradius,scanunits,scanstatics,scanscenery,verysafe,nunits,Parkingdata)
|
|
20315
20313
|
nfree=#spots
|
|
20316
20314
|
if nfree<nunits then
|
|
20317
|
-
self:T2(string.format("Transport/bomber group %s is at %s using terminal type %d.",self.SpawnTemplatePrefix,SpawnAirbase:GetName(),AIRBASE.TerminalType.OpenMedOrBig))
|
|
20318
20315
|
spots=SpawnAirbase:FindFreeParkingSpotForAircraft(TemplateGroup,AIRBASE.TerminalType.OpenMedOrBig,scanradius,scanunits,scanstatics,scanscenery,verysafe,nunits,Parkingdata)
|
|
20319
20316
|
nfree=#spots
|
|
20320
20317
|
end
|
|
20321
20318
|
else
|
|
20322
|
-
self:T2(string.format("Fighter group %s is at %s using terminal type %d.",self.SpawnTemplatePrefix,SpawnAirbase:GetName(),AIRBASE.TerminalType.FighterAircraft))
|
|
20323
20319
|
spots=SpawnAirbase:FindFreeParkingSpotForAircraft(TemplateGroup,AIRBASE.TerminalType.FighterAircraft,scanradius,scanunits,scanstatics,scanscenery,verysafe,nunits,Parkingdata)
|
|
20324
20320
|
nfree=#spots
|
|
20325
20321
|
end
|
|
20326
20322
|
else
|
|
20327
|
-
self:T2(string.format("Plane group %s is at %s using terminal type %s.",self.SpawnTemplatePrefix,SpawnAirbase:GetName(),tostring(termtype)))
|
|
20328
20323
|
spots=SpawnAirbase:FindFreeParkingSpotForAircraft(TemplateGroup,termtype,scanradius,scanunits,scanstatics,scanscenery,verysafe,nunits,Parkingdata)
|
|
20329
20324
|
nfree=#spots
|
|
20330
20325
|
end
|
|
@@ -20372,18 +20367,15 @@ local TX=PointVec3.x+(SX-BX)
|
|
|
20372
20367
|
local TY=PointVec3.z+(SY-BY)
|
|
20373
20368
|
if spawnonground then
|
|
20374
20369
|
if spawnonship or spawnonfarp or spawnonrunway then
|
|
20375
|
-
self:T2(string.format("Group %s spawning at farp, ship or runway %s.",self.SpawnTemplatePrefix,SpawnAirbase:GetName()))
|
|
20376
20370
|
SpawnTemplate.units[UnitID].x=PointVec3.x
|
|
20377
20371
|
SpawnTemplate.units[UnitID].y=PointVec3.z
|
|
20378
20372
|
SpawnTemplate.units[UnitID].alt=PointVec3.y
|
|
20379
20373
|
else
|
|
20380
|
-
self:T2(string.format("Group %s spawning at airbase %s on parking spot id %d",self.SpawnTemplatePrefix,SpawnAirbase:GetName(),parkingindex[UnitID]))
|
|
20381
20374
|
SpawnTemplate.units[UnitID].x=parkingspots[UnitID].x
|
|
20382
20375
|
SpawnTemplate.units[UnitID].y=parkingspots[UnitID].z
|
|
20383
20376
|
SpawnTemplate.units[UnitID].alt=parkingspots[UnitID].y
|
|
20384
20377
|
end
|
|
20385
20378
|
else
|
|
20386
|
-
self:T2(string.format("Group %s spawning in air at %s.",self.SpawnTemplatePrefix,SpawnAirbase:GetName()))
|
|
20387
20379
|
SpawnTemplate.units[UnitID].x=TX
|
|
20388
20380
|
SpawnTemplate.units[UnitID].y=TY
|
|
20389
20381
|
SpawnTemplate.units[UnitID].alt=PointVec3.y
|
|
@@ -20393,9 +20385,6 @@ UnitTemplate.parking_id=nil
|
|
|
20393
20385
|
if parkingindex[UnitID]then
|
|
20394
20386
|
UnitTemplate.parking=parkingindex[UnitID]
|
|
20395
20387
|
end
|
|
20396
|
-
self:T2(string.format("Group %s unit number %d: Parking = %s",self.SpawnTemplatePrefix,UnitID,tostring(UnitTemplate.parking)))
|
|
20397
|
-
self:T2(string.format("Group %s unit number %d: Parking ID = %s",self.SpawnTemplatePrefix,UnitID,tostring(UnitTemplate.parking_id)))
|
|
20398
|
-
self:T2('After Translation SpawnTemplate.units['..UnitID..'].x = '..SpawnTemplate.units[UnitID].x..', SpawnTemplate.units['..UnitID..'].y = '..SpawnTemplate.units[UnitID].y)
|
|
20399
20388
|
end
|
|
20400
20389
|
end
|
|
20401
20390
|
SpawnPoint.x=PointVec3.x
|
|
@@ -20425,7 +20414,6 @@ return nil
|
|
|
20425
20414
|
end
|
|
20426
20415
|
function SPAWN:SpawnFromVec3(Vec3,SpawnIndex)
|
|
20427
20416
|
local PointVec3=POINT_VEC3:NewFromVec3(Vec3)
|
|
20428
|
-
self:T2(PointVec3)
|
|
20429
20417
|
if SpawnIndex then
|
|
20430
20418
|
else
|
|
20431
20419
|
SpawnIndex=self.SpawnIndex+1
|
|
@@ -20433,7 +20421,6 @@ end
|
|
|
20433
20421
|
if self:_GetSpawnIndex(SpawnIndex)then
|
|
20434
20422
|
local SpawnTemplate=self.SpawnGroups[self.SpawnIndex].SpawnTemplate
|
|
20435
20423
|
if SpawnTemplate then
|
|
20436
|
-
self:T2({"Current point of ",self.SpawnTemplatePrefix,Vec3})
|
|
20437
20424
|
local TemplateHeight=SpawnTemplate.route and SpawnTemplate.route.points[1].alt or nil
|
|
20438
20425
|
SpawnTemplate.route=SpawnTemplate.route or{}
|
|
20439
20426
|
SpawnTemplate.route.points=SpawnTemplate.route.points or{}
|
|
@@ -20453,7 +20440,6 @@ SpawnTemplate.units[UnitID].y=TY
|
|
|
20453
20440
|
if SpawnTemplate.CategoryID~=Group.Category.SHIP then
|
|
20454
20441
|
SpawnTemplate.units[UnitID].alt=Vec3.y or TemplateHeight
|
|
20455
20442
|
end
|
|
20456
|
-
self:T2('After Translation SpawnTemplate.units['..UnitID..'].x = '..SpawnTemplate.units[UnitID].x..', SpawnTemplate.units['..UnitID..'].y = '..SpawnTemplate.units[UnitID].y)
|
|
20457
20443
|
end
|
|
20458
20444
|
SpawnTemplate.route.points[1].x=Vec3.x
|
|
20459
20445
|
SpawnTemplate.route.points[1].y=Vec3.z
|
|
@@ -20528,10 +20514,8 @@ SpawnPrefix=self.SpawnAliasPrefix
|
|
|
20528
20514
|
end
|
|
20529
20515
|
if SpawnIndex then
|
|
20530
20516
|
local SpawnName=string.format('%s#%03d',SpawnPrefix,SpawnIndex)
|
|
20531
|
-
self:T2(SpawnName)
|
|
20532
20517
|
return SpawnName
|
|
20533
20518
|
else
|
|
20534
|
-
self:T2(SpawnPrefix)
|
|
20535
20519
|
return SpawnPrefix
|
|
20536
20520
|
end
|
|
20537
20521
|
end
|
|
@@ -20707,7 +20691,6 @@ local UnitPrefix,Rest
|
|
|
20707
20691
|
if SpawnInitKeepUnitIFF==false then
|
|
20708
20692
|
UnitPrefix,Rest=string.match(SpawnTemplate.units[UnitID].name,"^([^#]+)#?"):gsub("^%s*(.-)%s*$","%1")
|
|
20709
20693
|
SpawnTemplate.units[UnitID].name=string.format('%s#%03d-%02d',UnitPrefix,SpawnIndex,UnitID)
|
|
20710
|
-
self:T2({UnitPrefix,Rest})
|
|
20711
20694
|
end
|
|
20712
20695
|
SpawnTemplate.units[UnitID].unitId=nil
|
|
20713
20696
|
end
|
|
@@ -20879,7 +20862,6 @@ end
|
|
|
20879
20862
|
else
|
|
20880
20863
|
SpawnTemplate.route.points[t].alt=nil
|
|
20881
20864
|
end
|
|
20882
|
-
self:T2('SpawnTemplate.route.points['..t..'].x = '..SpawnTemplate.route.points[t].x..', SpawnTemplate.route.points['..t..'].y = '..SpawnTemplate.route.points[t].y)
|
|
20883
20865
|
end
|
|
20884
20866
|
end
|
|
20885
20867
|
self:_RandomizeZones(SpawnIndex)
|
|
@@ -20906,21 +20888,16 @@ self:_RandomizeRoute(SpawnIndex)
|
|
|
20906
20888
|
return self
|
|
20907
20889
|
end
|
|
20908
20890
|
function SPAWN:_SetInitialPosition(SpawnIndex)
|
|
20909
|
-
self:T2({self.SpawnTemplatePrefix,SpawnIndex,self.SpawnRandomizeZones})
|
|
20910
20891
|
if self.SpawnFromNewPosition then
|
|
20911
|
-
self:T2("Preparing Spawn at Vec2 ",self.SpawnInitPosition)
|
|
20912
20892
|
local SpawnVec2=self.SpawnInitPosition
|
|
20913
|
-
self:T2({SpawnVec2=SpawnVec2})
|
|
20914
20893
|
local SpawnTemplate=self.SpawnGroups[SpawnIndex].SpawnTemplate
|
|
20915
20894
|
SpawnTemplate.route=SpawnTemplate.route or{}
|
|
20916
20895
|
SpawnTemplate.route.points=SpawnTemplate.route.points or{}
|
|
20917
20896
|
SpawnTemplate.route.points[1]=SpawnTemplate.route.points[1]or{}
|
|
20918
20897
|
SpawnTemplate.route.points[1].x=SpawnTemplate.route.points[1].x or 0
|
|
20919
20898
|
SpawnTemplate.route.points[1].y=SpawnTemplate.route.points[1].y or 0
|
|
20920
|
-
self:T2({Route=SpawnTemplate.route})
|
|
20921
20899
|
for UnitID=1,#SpawnTemplate.units do
|
|
20922
20900
|
local UnitTemplate=SpawnTemplate.units[UnitID]
|
|
20923
|
-
self:T2('Before Translation SpawnTemplate.units['..UnitID..'].x = '..UnitTemplate.x..', SpawnTemplate.units['..UnitID..'].y = '..UnitTemplate.y)
|
|
20924
20901
|
local SX=UnitTemplate.x
|
|
20925
20902
|
local SY=UnitTemplate.y
|
|
20926
20903
|
local BX=SpawnTemplate.route.points[1].x
|
|
@@ -20929,7 +20906,6 @@ local TX=SpawnVec2.x+(SX-BX)
|
|
|
20929
20906
|
local TY=SpawnVec2.y+(SY-BY)
|
|
20930
20907
|
UnitTemplate.x=TX
|
|
20931
20908
|
UnitTemplate.y=TY
|
|
20932
|
-
self:T2('After Translation SpawnTemplate.units['..UnitID..'].x = '..UnitTemplate.x..', SpawnTemplate.units['..UnitID..'].y = '..UnitTemplate.y)
|
|
20933
20909
|
end
|
|
20934
20910
|
SpawnTemplate.route.points[1].x=SpawnVec2.x
|
|
20935
20911
|
SpawnTemplate.route.points[1].y=SpawnVec2.y
|
|
@@ -20942,20 +20918,14 @@ function SPAWN:_RandomizeZones(SpawnIndex)
|
|
|
20942
20918
|
if self.SpawnRandomizeZones then
|
|
20943
20919
|
local SpawnZone=nil
|
|
20944
20920
|
while not SpawnZone do
|
|
20945
|
-
self:T2({SpawnZoneTableCount=#self.SpawnZoneTable,self.SpawnZoneTable})
|
|
20946
20921
|
local ZoneID=math.random(#self.SpawnZoneTable)
|
|
20947
|
-
self:T2(ZoneID)
|
|
20948
20922
|
SpawnZone=self.SpawnZoneTable[ZoneID]:GetZoneMaybe()
|
|
20949
20923
|
end
|
|
20950
|
-
self:T2("Preparing Spawn in Zone",SpawnZone:GetName())
|
|
20951
20924
|
local SpawnVec2=SpawnZone:GetRandomVec2()
|
|
20952
|
-
self:T2({SpawnVec2=SpawnVec2})
|
|
20953
20925
|
local SpawnTemplate=self.SpawnGroups[SpawnIndex].SpawnTemplate
|
|
20954
20926
|
self.SpawnGroups[SpawnIndex].SpawnZone=SpawnZone
|
|
20955
|
-
self:T2({Route=SpawnTemplate.route})
|
|
20956
20927
|
for UnitID=1,#SpawnTemplate.units do
|
|
20957
20928
|
local UnitTemplate=SpawnTemplate.units[UnitID]
|
|
20958
|
-
self:T2('Before Translation SpawnTemplate.units['..UnitID..'].x = '..UnitTemplate.x..', SpawnTemplate.units['..UnitID..'].y = '..UnitTemplate.y)
|
|
20959
20929
|
local SX=UnitTemplate.x
|
|
20960
20930
|
local SY=UnitTemplate.y
|
|
20961
20931
|
local BX=SpawnTemplate.route.points[1].x
|
|
@@ -20964,7 +20934,6 @@ local TX=SpawnVec2.x+(SX-BX)
|
|
|
20964
20934
|
local TY=SpawnVec2.y+(SY-BY)
|
|
20965
20935
|
UnitTemplate.x=TX
|
|
20966
20936
|
UnitTemplate.y=TY
|
|
20967
|
-
self:T2('After Translation SpawnTemplate.units['..UnitID..'].x = '..UnitTemplate.x..', SpawnTemplate.units['..UnitID..'].y = '..UnitTemplate.y)
|
|
20968
20937
|
end
|
|
20969
20938
|
SpawnTemplate.x=SpawnVec2.x
|
|
20970
20939
|
SpawnTemplate.y=SpawnVec2.y
|
|
@@ -20993,10 +20962,8 @@ end
|
|
|
20993
20962
|
return self
|
|
20994
20963
|
end
|
|
20995
20964
|
function SPAWN:_GetSpawnIndex(SpawnIndex)
|
|
20996
|
-
self:T2({template=self.SpawnTemplatePrefix,SpawnIndex=SpawnIndex,SpawnMaxGroups=self.SpawnMaxGroups,SpawnMaxUnitsAlive=self.SpawnMaxUnitsAlive,AliveUnits=self.AliveUnits,TemplateUnits=#self.SpawnTemplate.units})
|
|
20997
20965
|
if(self.SpawnMaxGroups==0)or(SpawnIndex<=self.SpawnMaxGroups)then
|
|
20998
20966
|
if(self.SpawnMaxUnitsAlive==0)or(self.AliveUnits+#self.SpawnTemplate.units<=self.SpawnMaxUnitsAlive)or self.UnControlled==true then
|
|
20999
|
-
self:T2({SpawnCount=self.SpawnCount,SpawnIndex=SpawnIndex})
|
|
21000
20967
|
if SpawnIndex and SpawnIndex>=self.SpawnCount+1 then
|
|
21001
20968
|
self.SpawnCount=self.SpawnCount+1
|
|
21002
20969
|
SpawnIndex=self.SpawnCount
|
|
@@ -21018,27 +20985,45 @@ local SpawnGroup=EventData.IniGroup
|
|
|
21018
20985
|
if SpawnGroup then
|
|
21019
20986
|
local EventPrefix=self:_GetPrefixFromGroup(SpawnGroup)
|
|
21020
20987
|
if EventPrefix then
|
|
21021
|
-
self:T2({"Birth Event:",EventPrefix,self.SpawnTemplatePrefix})
|
|
21022
20988
|
if EventPrefix==self.SpawnTemplatePrefix or(self.SpawnAliasPrefix and EventPrefix==self.SpawnAliasPrefix)then
|
|
21023
20989
|
self.AliveUnits=self.AliveUnits+1
|
|
21024
|
-
self:T2("Alive Units: "..self.AliveUnits)
|
|
21025
20990
|
end
|
|
21026
20991
|
end
|
|
21027
20992
|
end
|
|
21028
20993
|
end
|
|
20994
|
+
function SPAWN:_CountAliveUnits()
|
|
20995
|
+
local count=0
|
|
20996
|
+
if self.SpawnAliasPrefix then
|
|
20997
|
+
if not self.SpawnAliasPrefixEscaped then self.SpawnAliasPrefixEscaped=string.gsub(self.SpawnAliasPrefix,"[%p%s]",".")end
|
|
20998
|
+
local SpawnAliasPrefix=self.SpawnAliasPrefixEscaped
|
|
20999
|
+
local agroups=GROUP:FindAllByMatching(SpawnAliasPrefix)
|
|
21000
|
+
for _,_grp in pairs(agroups)do
|
|
21001
|
+
local game=self:_GetPrefixFromGroupName(_grp.GroupName)
|
|
21002
|
+
if game and game==self.SpawnAliasPrefix then
|
|
21003
|
+
count=count+_grp:CountAliveUnits()
|
|
21004
|
+
end
|
|
21005
|
+
end
|
|
21006
|
+
else
|
|
21007
|
+
if not self.SpawnTemplatePrefixEscaped then self.SpawnTemplatePrefixEscaped=string.gsub(self.SpawnTemplatePrefix,"[%p%s]",".")end
|
|
21008
|
+
local SpawnTemplatePrefix=self.SpawnTemplatePrefixEscaped
|
|
21009
|
+
local groups=GROUP:FindAllByMatching(SpawnTemplatePrefix)
|
|
21010
|
+
for _,_grp in pairs(groups)do
|
|
21011
|
+
local game=self:_GetPrefixFromGroupName(_grp.GroupName)
|
|
21012
|
+
if game and game==self.SpawnTemplatePrefix then
|
|
21013
|
+
count=count+_grp:CountAliveUnits()
|
|
21014
|
+
end
|
|
21015
|
+
end
|
|
21016
|
+
end
|
|
21017
|
+
return count
|
|
21018
|
+
end
|
|
21029
21019
|
function SPAWN:_OnDeadOrCrash(EventData)
|
|
21030
|
-
self:T2("Dead or crash event ID "..tostring(EventData.id or 0))
|
|
21031
|
-
self:T2("Dead or crash event for "..tostring(EventData.IniUnitName or"none"))
|
|
21032
21020
|
local unit=UNIT:FindByName(EventData.IniUnitName)
|
|
21033
21021
|
if unit then
|
|
21034
21022
|
local EventPrefix=self:_GetPrefixFromGroupName(unit.GroupName)
|
|
21035
21023
|
if EventPrefix then
|
|
21036
|
-
self:T2({"Dead event: "..EventPrefix})
|
|
21037
|
-
self:T2(string.format("EventPrefix = %s | SpawnAliasPrefix = %s | Old AliveUnits = %d",EventPrefix or"",self.SpawnAliasPrefix or"",self.AliveUnits or 0))
|
|
21038
21024
|
if EventPrefix==self.SpawnTemplatePrefix or(self.SpawnAliasPrefix and EventPrefix==self.SpawnAliasPrefix)and self.AliveUnits>0 then
|
|
21039
|
-
self.AliveUnits=self
|
|
21025
|
+
self.AliveUnits=self:_CountAliveUnits()
|
|
21040
21026
|
end
|
|
21041
|
-
self:T2("New Alive Units: "..self.AliveUnits)
|
|
21042
21027
|
end
|
|
21043
21028
|
end
|
|
21044
21029
|
end
|
|
@@ -21047,9 +21032,7 @@ local SpawnGroup=EventData.IniGroup
|
|
|
21047
21032
|
if SpawnGroup then
|
|
21048
21033
|
local EventPrefix=self:_GetPrefixFromGroup(SpawnGroup)
|
|
21049
21034
|
if EventPrefix then
|
|
21050
|
-
self:T2({"TakeOff event: "..EventPrefix})
|
|
21051
21035
|
if EventPrefix==self.SpawnTemplatePrefix or(self.SpawnAliasPrefix and EventPrefix==self.SpawnAliasPrefix)then
|
|
21052
|
-
self:T2("self.Landed = false")
|
|
21053
21036
|
SpawnGroup:SetState(SpawnGroup,"Spawn_Landed",false)
|
|
21054
21037
|
end
|
|
21055
21038
|
end
|
|
@@ -21060,12 +21043,10 @@ local SpawnGroup=EventData.IniGroup
|
|
|
21060
21043
|
if SpawnGroup then
|
|
21061
21044
|
local EventPrefix=self:_GetPrefixFromGroup(SpawnGroup)
|
|
21062
21045
|
if EventPrefix then
|
|
21063
|
-
self:T2({"Land event: "..EventPrefix})
|
|
21064
21046
|
if EventPrefix==self.SpawnTemplatePrefix or(self.SpawnAliasPrefix and EventPrefix==self.SpawnAliasPrefix)then
|
|
21065
21047
|
SpawnGroup:SetState(SpawnGroup,"Spawn_Landed",true)
|
|
21066
21048
|
if self.RepeatOnLanding then
|
|
21067
21049
|
local SpawnGroupIndex=self:GetSpawnIndexFromGroup(SpawnGroup)
|
|
21068
|
-
self:T2({"Landed:","ReSpawn:",SpawnGroup:GetName(),SpawnGroupIndex})
|
|
21069
21050
|
SCHEDULER:New(nil,self.ReSpawn,{self,SpawnGroupIndex},3)
|
|
21070
21051
|
end
|
|
21071
21052
|
end
|
|
@@ -21077,12 +21058,10 @@ local SpawnGroup=EventData.IniGroup
|
|
|
21077
21058
|
if SpawnGroup then
|
|
21078
21059
|
local EventPrefix=self:_GetPrefixFromGroup(SpawnGroup)
|
|
21079
21060
|
if EventPrefix then
|
|
21080
|
-
self:T2({"EngineShutdown event: "..EventPrefix})
|
|
21081
21061
|
if EventPrefix==self.SpawnTemplatePrefix or(self.SpawnAliasPrefix and EventPrefix==self.SpawnAliasPrefix)then
|
|
21082
21062
|
local Landed=SpawnGroup:GetState(SpawnGroup,"Spawn_Landed")
|
|
21083
21063
|
if Landed and self.RepeatOnEngineShutDown then
|
|
21084
21064
|
local SpawnGroupIndex=self:GetSpawnIndexFromGroup(SpawnGroup)
|
|
21085
|
-
self:T2({"EngineShutDown: ","ReSpawn:",SpawnGroup:GetName(),SpawnGroupIndex})
|
|
21086
21065
|
SCHEDULER:New(nil,self.ReSpawn,{self,SpawnGroupIndex},3)
|
|
21087
21066
|
end
|
|
21088
21067
|
end
|
|
@@ -21096,7 +21075,6 @@ return true
|
|
|
21096
21075
|
end
|
|
21097
21076
|
function SPAWN:_SpawnCleanUpScheduler()
|
|
21098
21077
|
local SpawnGroup,SpawnCursor=self:GetFirstAliveGroup()
|
|
21099
|
-
self:T2({"CleanUp Scheduler:",SpawnGroup,SpawnCursor})
|
|
21100
21078
|
local IsHelo=false
|
|
21101
21079
|
while SpawnGroup do
|
|
21102
21080
|
IsHelo=SpawnGroup:IsHelicopter()
|
|
@@ -21106,13 +21084,11 @@ local SpawnUnit=UnitData
|
|
|
21106
21084
|
local SpawnUnitName=SpawnUnit:GetName()
|
|
21107
21085
|
self.SpawnCleanUpTimeStamps[SpawnUnitName]=self.SpawnCleanUpTimeStamps[SpawnUnitName]or{}
|
|
21108
21086
|
local Stamp=self.SpawnCleanUpTimeStamps[SpawnUnitName]
|
|
21109
|
-
self:T2({SpawnUnitName,Stamp})
|
|
21110
21087
|
if Stamp.Vec2 then
|
|
21111
21088
|
if(SpawnUnit:InAir()==false and SpawnUnit:GetVelocityKMH()<1)or IsHelo then
|
|
21112
21089
|
local NewVec2=SpawnUnit:GetVec2()or{x=0,y=0}
|
|
21113
21090
|
if(Stamp.Vec2.x==NewVec2.x and Stamp.Vec2.y==NewVec2.y)or(SpawnUnit:GetLife()<=1)then
|
|
21114
21091
|
if Stamp.Time+self.SpawnCleanUpInterval<timer.getTime()then
|
|
21115
|
-
self:T2({"CleanUp Scheduler:","ReSpawning:",SpawnGroup:GetName()})
|
|
21116
21092
|
SCHEDULER:New(nil,self.ReSpawn,{self,SpawnCursor},3)
|
|
21117
21093
|
Stamp.Vec2=nil
|
|
21118
21094
|
Stamp.Time=nil
|
|
@@ -21138,7 +21114,6 @@ end
|
|
|
21138
21114
|
end
|
|
21139
21115
|
end
|
|
21140
21116
|
SpawnGroup,SpawnCursor=self:GetNextAliveGroup(SpawnCursor)
|
|
21141
|
-
self:T2({"CleanUp Scheduler:",SpawnGroup,SpawnCursor})
|
|
21142
21117
|
end
|
|
21143
21118
|
return true
|
|
21144
21119
|
end
|
|
@@ -26311,6 +26286,85 @@ PatrolGroup:Route(Route,Delay)
|
|
|
26311
26286
|
end
|
|
26312
26287
|
return self
|
|
26313
26288
|
end
|
|
26289
|
+
function CONTROLLABLE:NewIRMarker(EnableImmediately,Runtime)
|
|
26290
|
+
if self.ClassName=="GROUP"then
|
|
26291
|
+
self.IRMarkerGroup=true
|
|
26292
|
+
self.IRMarkerUnit=false
|
|
26293
|
+
elseif self.ClassName=="UNIT"then
|
|
26294
|
+
self.IRMarkerGroup=false
|
|
26295
|
+
self.IRMarkerUnit=true
|
|
26296
|
+
end
|
|
26297
|
+
self.spot=nil
|
|
26298
|
+
self.timer=nil
|
|
26299
|
+
self.stoptimer=nil
|
|
26300
|
+
if EnableImmediately and EnableImmediately==true then
|
|
26301
|
+
self:EnableIRMarker(Runtime)
|
|
26302
|
+
end
|
|
26303
|
+
return self
|
|
26304
|
+
end
|
|
26305
|
+
function CONTROLLABLE:EnableIRMarker(Runtime)
|
|
26306
|
+
if self.IRMarkerGroup==nil then
|
|
26307
|
+
self:NewIRMarker(true,Runtime)
|
|
26308
|
+
return
|
|
26309
|
+
end
|
|
26310
|
+
if(self.IRMarkerGroup==true)then
|
|
26311
|
+
self:EnableIRMarkerForGroup()
|
|
26312
|
+
return
|
|
26313
|
+
end
|
|
26314
|
+
self.timer=TIMER:New(CONTROLLABLE._MarkerBlink,self)
|
|
26315
|
+
self.timer:Start(nil,1-math.random(1,5)/10/2,Runtime)
|
|
26316
|
+
return self
|
|
26317
|
+
end
|
|
26318
|
+
function CONTROLLABLE:DisableIRMarker()
|
|
26319
|
+
if(self.IRMarkerGroup==true)then
|
|
26320
|
+
self:DisableIRMarkerForGroup()
|
|
26321
|
+
return
|
|
26322
|
+
end
|
|
26323
|
+
if self.spot then
|
|
26324
|
+
self.spot:destroy()
|
|
26325
|
+
self.spot=nil
|
|
26326
|
+
if self.timer and self.timer:IsRunning()then
|
|
26327
|
+
self.timer:Stop()
|
|
26328
|
+
self.timer=nil
|
|
26329
|
+
end
|
|
26330
|
+
end
|
|
26331
|
+
return self
|
|
26332
|
+
end
|
|
26333
|
+
function CONTROLLABLE:EnableIRMarkerForGroup()
|
|
26334
|
+
if self.ClassName=="GROUP"then
|
|
26335
|
+
local units=self:GetUnits()or{}
|
|
26336
|
+
for _,_unit in pairs(units)do
|
|
26337
|
+
_unit:EnableIRMarker()
|
|
26338
|
+
end
|
|
26339
|
+
end
|
|
26340
|
+
return self
|
|
26341
|
+
end
|
|
26342
|
+
function CONTROLLABLE:DisableIRMarkerForGroup()
|
|
26343
|
+
if self.ClassName=="GROUP"then
|
|
26344
|
+
local units=self:GetUnits()or{}
|
|
26345
|
+
for _,_unit in pairs(units)do
|
|
26346
|
+
_unit:DisableIRMarker()
|
|
26347
|
+
end
|
|
26348
|
+
end
|
|
26349
|
+
return self
|
|
26350
|
+
end
|
|
26351
|
+
function CONTROLLABLE:_MarkerBlink()
|
|
26352
|
+
if self:IsAlive()~=true then
|
|
26353
|
+
self:DisableIRMarker()
|
|
26354
|
+
return
|
|
26355
|
+
end
|
|
26356
|
+
self.timer.dT=1-(math.random(1,2)/10/2)
|
|
26357
|
+
local _,_,unitBBHeight,_=self:GetObjectSize()
|
|
26358
|
+
local unitPos=self:GetPositionVec3()
|
|
26359
|
+
self.spot=Spot.createInfraRed(
|
|
26360
|
+
self.DCSUnit,
|
|
26361
|
+
{x=0,y=(unitBBHeight+1),z=0},
|
|
26362
|
+
{x=unitPos.x,y=(unitPos.y+unitBBHeight),z=unitPos.z}
|
|
26363
|
+
)
|
|
26364
|
+
local offTimer=TIMER:New(function()if self.spot then self.spot:destroy()end end)
|
|
26365
|
+
offTimer:Start(0.5)
|
|
26366
|
+
return self
|
|
26367
|
+
end
|
|
26314
26368
|
GROUP={
|
|
26315
26369
|
ClassName="GROUP",
|
|
26316
26370
|
}
|
|
@@ -26401,35 +26455,39 @@ end
|
|
|
26401
26455
|
return GroupsFound
|
|
26402
26456
|
end
|
|
26403
26457
|
function GROUP:GetDCSObject()
|
|
26458
|
+
if(not self.LastCallDCSObject)or(self.LastCallDCSObject and timer.getTime()-self.LastCallDCSObject>1)then
|
|
26404
26459
|
local DCSGroup=Group.getByName(self.GroupName)
|
|
26405
26460
|
if DCSGroup then
|
|
26461
|
+
self.LastCallDCSObject=timer.getTime()
|
|
26462
|
+
self.DCSObject=DCSGroup
|
|
26406
26463
|
return DCSGroup
|
|
26464
|
+
else
|
|
26465
|
+
self.DCSObject=nil
|
|
26466
|
+
self.LastCallDCSObject=nil
|
|
26467
|
+
end
|
|
26468
|
+
else
|
|
26469
|
+
return self.DCSObject
|
|
26407
26470
|
end
|
|
26408
|
-
self:T2(string.format("ERROR: Could not get DCS group object of group %s because DCS object could not be found!",tostring(self.GroupName)))
|
|
26409
26471
|
return nil
|
|
26410
26472
|
end
|
|
26411
26473
|
function GROUP:GetPositionVec3()
|
|
26412
|
-
self:F2(self.PositionableName)
|
|
26413
26474
|
local DCSPositionable=self:GetDCSObject()
|
|
26414
26475
|
if DCSPositionable then
|
|
26415
26476
|
local unit=DCSPositionable:getUnits()[1]
|
|
26416
26477
|
if unit then
|
|
26417
26478
|
local PositionablePosition=unit:getPosition().p
|
|
26418
|
-
self:T3(PositionablePosition)
|
|
26419
26479
|
return PositionablePosition
|
|
26420
26480
|
end
|
|
26421
26481
|
end
|
|
26422
26482
|
return nil
|
|
26423
26483
|
end
|
|
26424
26484
|
function GROUP:IsAlive()
|
|
26425
|
-
self:F2(self.GroupName)
|
|
26426
26485
|
local DCSGroup=self:GetDCSObject()
|
|
26427
26486
|
if DCSGroup then
|
|
26428
26487
|
if DCSGroup:isExist()then
|
|
26429
26488
|
local DCSUnit=DCSGroup:getUnit(1)
|
|
26430
26489
|
if DCSUnit then
|
|
26431
26490
|
local GroupIsAlive=DCSUnit:isActive()
|
|
26432
|
-
self:T3(GroupIsAlive)
|
|
26433
26491
|
return GroupIsAlive
|
|
26434
26492
|
end
|
|
26435
26493
|
end
|
|
@@ -26437,7 +26495,6 @@ end
|
|
|
26437
26495
|
return nil
|
|
26438
26496
|
end
|
|
26439
26497
|
function GROUP:IsActive()
|
|
26440
|
-
self:F2(self.GroupName)
|
|
26441
26498
|
local DCSGroup=self:GetDCSObject()
|
|
26442
26499
|
if DCSGroup and DCSGroup:isExist()then
|
|
26443
26500
|
local unit=DCSGroup:getUnit(1)
|
|
@@ -26449,7 +26506,6 @@ end
|
|
|
26449
26506
|
return nil
|
|
26450
26507
|
end
|
|
26451
26508
|
function GROUP:Destroy(GenerateEvent,delay)
|
|
26452
|
-
self:F2(self.GroupName)
|
|
26453
26509
|
if delay and delay>0 then
|
|
26454
26510
|
self:ScheduleOnce(delay,GROUP.Destroy,self,GenerateEvent)
|
|
26455
26511
|
else
|
|
@@ -26475,17 +26531,14 @@ end
|
|
|
26475
26531
|
return nil
|
|
26476
26532
|
end
|
|
26477
26533
|
function GROUP:GetCategory()
|
|
26478
|
-
self:F2(self.GroupName)
|
|
26479
26534
|
local DCSGroup=self:GetDCSObject()
|
|
26480
26535
|
if DCSGroup then
|
|
26481
26536
|
local GroupCategory=DCSGroup:getCategory()
|
|
26482
|
-
self:T3(GroupCategory)
|
|
26483
26537
|
return GroupCategory
|
|
26484
26538
|
end
|
|
26485
26539
|
return nil
|
|
26486
26540
|
end
|
|
26487
26541
|
function GROUP:GetCategoryName()
|
|
26488
|
-
self:F2(self.GroupName)
|
|
26489
26542
|
local DCSGroup=self:GetDCSObject()
|
|
26490
26543
|
if DCSGroup then
|
|
26491
26544
|
local CategoryNames={
|
|
@@ -26496,7 +26549,6 @@ local CategoryNames={
|
|
|
26496
26549
|
[Group.Category.TRAIN]="Train",
|
|
26497
26550
|
}
|
|
26498
26551
|
local GroupCategory=DCSGroup:getCategory()
|
|
26499
|
-
self:T3(GroupCategory)
|
|
26500
26552
|
return CategoryNames[GroupCategory]
|
|
26501
26553
|
end
|
|
26502
26554
|
return nil
|
|
@@ -26515,11 +26567,9 @@ end
|
|
|
26515
26567
|
return nil
|
|
26516
26568
|
end
|
|
26517
26569
|
function GROUP:GetCountry()
|
|
26518
|
-
self:F2(self.GroupName)
|
|
26519
26570
|
local DCSGroup=self:GetDCSObject()
|
|
26520
26571
|
if DCSGroup then
|
|
26521
26572
|
local GroupCountry=DCSGroup:getUnit(1):getCountry()
|
|
26522
|
-
self:T3(GroupCountry)
|
|
26523
26573
|
return GroupCountry
|
|
26524
26574
|
end
|
|
26525
26575
|
return nil
|
|
@@ -26549,7 +26599,6 @@ end
|
|
|
26549
26599
|
return nil
|
|
26550
26600
|
end
|
|
26551
26601
|
function GROUP:GetSpeedMax()
|
|
26552
|
-
self:F2(self.GroupName)
|
|
26553
26602
|
local DCSGroup=self:GetDCSObject()
|
|
26554
26603
|
if DCSGroup then
|
|
26555
26604
|
local Units=self:GetUnits()
|
|
@@ -26566,7 +26615,6 @@ end
|
|
|
26566
26615
|
return nil
|
|
26567
26616
|
end
|
|
26568
26617
|
function GROUP:GetRange()
|
|
26569
|
-
self:F2(self.GroupName)
|
|
26570
26618
|
local DCSGroup=self:GetDCSObject()
|
|
26571
26619
|
if DCSGroup then
|
|
26572
26620
|
local Units=self:GetUnits()
|
|
@@ -26587,7 +26635,6 @@ end
|
|
|
26587
26635
|
return nil
|
|
26588
26636
|
end
|
|
26589
26637
|
function GROUP:GetUnits()
|
|
26590
|
-
self:F2({self.GroupName})
|
|
26591
26638
|
local DCSGroup=self:GetDCSObject()
|
|
26592
26639
|
if DCSGroup then
|
|
26593
26640
|
local DCSUnits=DCSGroup:getUnits()or{}
|
|
@@ -26602,13 +26649,11 @@ unit=_DATABASE:AddUnit(UnitName)
|
|
|
26602
26649
|
Units[#Units+1]=unit
|
|
26603
26650
|
end
|
|
26604
26651
|
end
|
|
26605
|
-
self:T3(Units)
|
|
26606
26652
|
return Units
|
|
26607
26653
|
end
|
|
26608
26654
|
return nil
|
|
26609
26655
|
end
|
|
26610
26656
|
function GROUP:GetPlayerUnits()
|
|
26611
|
-
self:F2({self.GroupName})
|
|
26612
26657
|
local DCSGroup=self:GetDCSObject()
|
|
26613
26658
|
if DCSGroup then
|
|
26614
26659
|
local DCSUnits=DCSGroup:getUnits()
|
|
@@ -26619,7 +26664,6 @@ if PlayerUnit:GetPlayerName()then
|
|
|
26619
26664
|
Units[#Units+1]=PlayerUnit
|
|
26620
26665
|
end
|
|
26621
26666
|
end
|
|
26622
|
-
self:T3(Units)
|
|
26623
26667
|
return Units
|
|
26624
26668
|
end
|
|
26625
26669
|
return nil
|
|
@@ -26677,7 +26721,6 @@ end
|
|
|
26677
26721
|
return nil
|
|
26678
26722
|
end
|
|
26679
26723
|
function GROUP:CountAliveUnits()
|
|
26680
|
-
self:F3({self.GroupName})
|
|
26681
26724
|
local DCSGroup=self:GetDCSObject()
|
|
26682
26725
|
if DCSGroup then
|
|
26683
26726
|
local units=self:GetUnits()
|
|
@@ -26693,7 +26736,6 @@ end
|
|
|
26693
26736
|
return 0
|
|
26694
26737
|
end
|
|
26695
26738
|
function GROUP:GetFirstUnitAlive()
|
|
26696
|
-
self:F3({self.GroupName})
|
|
26697
26739
|
local DCSGroup=self:GetDCSObject()
|
|
26698
26740
|
if DCSGroup then
|
|
26699
26741
|
local units=self:GetUnits()
|
|
@@ -26707,7 +26749,6 @@ end
|
|
|
26707
26749
|
return nil
|
|
26708
26750
|
end
|
|
26709
26751
|
function GROUP:GetFirstUnit()
|
|
26710
|
-
self:F3({self.GroupName})
|
|
26711
26752
|
local DCSGroup=self:GetDCSObject()
|
|
26712
26753
|
if DCSGroup then
|
|
26713
26754
|
local units=self:GetUnits()
|
|
@@ -26716,7 +26757,6 @@ end
|
|
|
26716
26757
|
return nil
|
|
26717
26758
|
end
|
|
26718
26759
|
function GROUP:GetVelocityVec3()
|
|
26719
|
-
self:F2(self.GroupName)
|
|
26720
26760
|
local DCSGroup=self:GetDCSObject()
|
|
26721
26761
|
if DCSGroup and DCSGroup:isExist()then
|
|
26722
26762
|
local GroupUnits=DCSGroup:getUnits()
|
|
@@ -26737,11 +26777,9 @@ BASE:E({"Cannot GetVelocityVec3",Group=self,Alive=self:IsAlive()})
|
|
|
26737
26777
|
return nil
|
|
26738
26778
|
end
|
|
26739
26779
|
function GROUP:GetAltitude(FromGround)
|
|
26740
|
-
self:F2(self.GroupName)
|
|
26741
26780
|
return self:GetHeight(FromGround)
|
|
26742
26781
|
end
|
|
26743
26782
|
function GROUP:GetHeight(FromGround)
|
|
26744
|
-
self:F2(self.GroupName)
|
|
26745
26783
|
local DCSGroup=self:GetDCSObject()
|
|
26746
26784
|
if DCSGroup then
|
|
26747
26785
|
local GroupUnits=DCSGroup:getUnits()
|
|
@@ -26761,27 +26799,22 @@ end
|
|
|
26761
26799
|
return nil
|
|
26762
26800
|
end
|
|
26763
26801
|
function GROUP:GetInitialSize()
|
|
26764
|
-
self:F3({self.GroupName})
|
|
26765
26802
|
local DCSGroup=self:GetDCSObject()
|
|
26766
26803
|
if DCSGroup then
|
|
26767
26804
|
local GroupInitialSize=DCSGroup:getInitialSize()
|
|
26768
|
-
self:T3(GroupInitialSize)
|
|
26769
26805
|
return GroupInitialSize
|
|
26770
26806
|
end
|
|
26771
26807
|
return nil
|
|
26772
26808
|
end
|
|
26773
26809
|
function GROUP:GetDCSUnits()
|
|
26774
|
-
self:F2({self.GroupName})
|
|
26775
26810
|
local DCSGroup=self:GetDCSObject()
|
|
26776
26811
|
if DCSGroup then
|
|
26777
26812
|
local DCSUnits=DCSGroup:getUnits()
|
|
26778
|
-
self:T3(DCSUnits)
|
|
26779
26813
|
return DCSUnits
|
|
26780
26814
|
end
|
|
26781
26815
|
return nil
|
|
26782
26816
|
end
|
|
26783
26817
|
function GROUP:Activate(delay)
|
|
26784
|
-
self:F2({self.GroupName})
|
|
26785
26818
|
if delay and delay>0 then
|
|
26786
26819
|
self:ScheduleOnce(delay,GROUP.Activate,self)
|
|
26787
26820
|
else
|
|
@@ -26789,42 +26822,42 @@ trigger.action.activateGroup(self:GetDCSObject())
|
|
|
26789
26822
|
end
|
|
26790
26823
|
return self
|
|
26791
26824
|
end
|
|
26825
|
+
function GROUP:Deactivate(delay)
|
|
26826
|
+
if delay and delay>0 then
|
|
26827
|
+
self:ScheduleOnce(delay,GROUP.Deactivate,self)
|
|
26828
|
+
else
|
|
26829
|
+
trigger.action.deactivateGroup(self:GetDCSObject())
|
|
26830
|
+
end
|
|
26831
|
+
return self
|
|
26832
|
+
end
|
|
26792
26833
|
function GROUP:GetTypeName()
|
|
26793
|
-
self:F2(self.GroupName)
|
|
26794
26834
|
local DCSGroup=self:GetDCSObject()
|
|
26795
26835
|
if DCSGroup then
|
|
26796
26836
|
local GroupTypeName=DCSGroup:getUnit(1):getTypeName()
|
|
26797
|
-
self:T3(GroupTypeName)
|
|
26798
26837
|
return(GroupTypeName)
|
|
26799
26838
|
end
|
|
26800
26839
|
return nil
|
|
26801
26840
|
end
|
|
26802
26841
|
function GROUP:GetNatoReportingName()
|
|
26803
|
-
self:F2(self.GroupName)
|
|
26804
26842
|
local DCSGroup=self:GetDCSObject()
|
|
26805
26843
|
if DCSGroup then
|
|
26806
26844
|
local GroupTypeName=DCSGroup:getUnit(1):getTypeName()
|
|
26807
|
-
self:T3(GroupTypeName)
|
|
26808
26845
|
return UTILS.GetReportingName(GroupTypeName)
|
|
26809
26846
|
end
|
|
26810
26847
|
return"Bogey"
|
|
26811
26848
|
end
|
|
26812
26849
|
function GROUP:GetPlayerName()
|
|
26813
|
-
self:F2(self.GroupName)
|
|
26814
26850
|
local DCSGroup=self:GetDCSObject()
|
|
26815
26851
|
if DCSGroup then
|
|
26816
26852
|
local PlayerName=DCSGroup:getUnit(1):getPlayerName()
|
|
26817
|
-
self:T3(PlayerName)
|
|
26818
26853
|
return(PlayerName)
|
|
26819
26854
|
end
|
|
26820
26855
|
return nil
|
|
26821
26856
|
end
|
|
26822
26857
|
function GROUP:GetCallsign()
|
|
26823
|
-
self:F2(self.GroupName)
|
|
26824
26858
|
local DCSGroup=self:GetDCSObject()
|
|
26825
26859
|
if DCSGroup then
|
|
26826
26860
|
local GroupCallSign=DCSGroup:getUnit(1):getCallsign()
|
|
26827
|
-
self:T3(GroupCallSign)
|
|
26828
26861
|
return GroupCallSign
|
|
26829
26862
|
end
|
|
26830
26863
|
BASE:E({"Cannot GetCallsign",Positionable=self,Alive=self:IsAlive()})
|
|
@@ -26869,11 +26902,9 @@ return self:GetVec3()
|
|
|
26869
26902
|
end
|
|
26870
26903
|
end
|
|
26871
26904
|
function GROUP:GetPointVec2()
|
|
26872
|
-
self:F2(self.GroupName)
|
|
26873
26905
|
local FirstUnit=self:GetUnit(1)
|
|
26874
26906
|
if FirstUnit then
|
|
26875
26907
|
local FirstUnitPointVec2=FirstUnit:GetPointVec2()
|
|
26876
|
-
self:T3(FirstUnitPointVec2)
|
|
26877
26908
|
return FirstUnitPointVec2
|
|
26878
26909
|
end
|
|
26879
26910
|
BASE:E({"Cannot GetPointVec2",Group=self,Alive=self:IsAlive()})
|
|
@@ -26926,19 +26957,15 @@ end
|
|
|
26926
26957
|
BASE:E({"Cannot GetCoordinate",Group=self,Alive=self:IsAlive()})
|
|
26927
26958
|
end
|
|
26928
26959
|
function GROUP:GetRandomVec3(Radius)
|
|
26929
|
-
self:F2(self.GroupName)
|
|
26930
26960
|
local FirstUnit=self:GetUnit(1)
|
|
26931
26961
|
if FirstUnit then
|
|
26932
26962
|
local FirstUnitRandomPointVec3=FirstUnit:GetRandomVec3(Radius)
|
|
26933
|
-
self:T3(FirstUnitRandomPointVec3)
|
|
26934
26963
|
return FirstUnitRandomPointVec3
|
|
26935
26964
|
end
|
|
26936
26965
|
BASE:E({"Cannot GetRandomVec3",Group=self,Alive=self:IsAlive()})
|
|
26937
26966
|
return nil
|
|
26938
26967
|
end
|
|
26939
26968
|
function GROUP:GetHeading()
|
|
26940
|
-
self:F2(self.GroupName)
|
|
26941
|
-
self:F2(self.GroupName)
|
|
26942
26969
|
local GroupSize=self:GetSize()
|
|
26943
26970
|
local HeadingAccumulator=0
|
|
26944
26971
|
local n=0
|
|
@@ -26956,7 +26983,6 @@ BASE:E({"Cannot GetHeading",Group=self,Alive=self:IsAlive()})
|
|
|
26956
26983
|
return nil
|
|
26957
26984
|
end
|
|
26958
26985
|
function GROUP:GetFuelMin()
|
|
26959
|
-
self:F3(self.ControllableName)
|
|
26960
26986
|
if not self:GetDCSObject()then
|
|
26961
26987
|
BASE:E({"Cannot GetFuel",Group=self,Alive=self:IsAlive()})
|
|
26962
26988
|
return 0
|
|
@@ -26976,7 +27002,6 @@ end
|
|
|
26976
27002
|
return min,unit
|
|
26977
27003
|
end
|
|
26978
27004
|
function GROUP:GetFuelAvg()
|
|
26979
|
-
self:F(self.ControllableName)
|
|
26980
27005
|
local DCSControllable=self:GetDCSObject()
|
|
26981
27006
|
if DCSControllable then
|
|
26982
27007
|
local GroupSize=self:GetSize()
|
|
@@ -26984,7 +27009,6 @@ local TotalFuel=0
|
|
|
26984
27009
|
for UnitID,UnitData in pairs(self:GetUnits())do
|
|
26985
27010
|
local Unit=UnitData
|
|
26986
27011
|
local UnitFuel=Unit:GetFuel()or 0
|
|
26987
|
-
self:F({Fuel=UnitFuel})
|
|
26988
27012
|
TotalFuel=TotalFuel+UnitFuel
|
|
26989
27013
|
end
|
|
26990
27014
|
local GroupFuel=TotalFuel/GroupSize
|
|
@@ -26997,7 +27021,6 @@ function GROUP:GetFuel()
|
|
|
26997
27021
|
return self:GetFuelAvg()
|
|
26998
27022
|
end
|
|
26999
27023
|
function GROUP:GetAmmunition()
|
|
27000
|
-
self:F(self.ControllableName)
|
|
27001
27024
|
local DCSControllable=self:GetDCSObject()
|
|
27002
27025
|
local Ntot=0
|
|
27003
27026
|
local Nshells=0
|
|
@@ -27037,7 +27060,6 @@ end
|
|
|
27037
27060
|
return nil
|
|
27038
27061
|
end
|
|
27039
27062
|
function GROUP:IsCompletelyInZone(Zone)
|
|
27040
|
-
self:F2({self.GroupName,Zone})
|
|
27041
27063
|
if not self:IsAlive()then return false end
|
|
27042
27064
|
for UnitID,UnitData in pairs(self:GetUnits())do
|
|
27043
27065
|
local Unit=UnitData
|
|
@@ -27049,7 +27071,6 @@ end
|
|
|
27049
27071
|
return true
|
|
27050
27072
|
end
|
|
27051
27073
|
function GROUP:IsPartlyInZone(Zone)
|
|
27052
|
-
self:F2({self.GroupName,Zone})
|
|
27053
27074
|
local IsOneUnitInZone=false
|
|
27054
27075
|
local IsOneUnitOutsideZone=false
|
|
27055
27076
|
if not self:IsAlive()then return false end
|
|
@@ -27071,7 +27092,6 @@ function GROUP:IsPartlyOrCompletelyInZone(Zone)
|
|
|
27071
27092
|
return self:IsPartlyInZone(Zone)or self:IsCompletelyInZone(Zone)
|
|
27072
27093
|
end
|
|
27073
27094
|
function GROUP:IsNotInZone(Zone)
|
|
27074
|
-
self:F2({self.GroupName,Zone})
|
|
27075
27095
|
if not self:IsAlive()then return true end
|
|
27076
27096
|
for UnitID,UnitData in pairs(self:GetUnits())do
|
|
27077
27097
|
local Unit=UnitData
|
|
@@ -27092,7 +27112,6 @@ end
|
|
|
27092
27112
|
return false
|
|
27093
27113
|
end
|
|
27094
27114
|
function GROUP:CountInZone(Zone)
|
|
27095
|
-
self:F2({self.GroupName,Zone})
|
|
27096
27115
|
local Count=0
|
|
27097
27116
|
if not self:IsAlive()then return Count end
|
|
27098
27117
|
for UnitID,UnitData in pairs(self:GetUnits())do
|
|
@@ -27104,57 +27123,46 @@ end
|
|
|
27104
27123
|
return Count
|
|
27105
27124
|
end
|
|
27106
27125
|
function GROUP:IsAir()
|
|
27107
|
-
self:F2(self.GroupName)
|
|
27108
27126
|
local DCSGroup=self:GetDCSObject()
|
|
27109
27127
|
if DCSGroup then
|
|
27110
27128
|
local IsAirResult=DCSGroup:getCategory()==Group.Category.AIRPLANE or DCSGroup:getCategory()==Group.Category.HELICOPTER
|
|
27111
|
-
self:T3(IsAirResult)
|
|
27112
27129
|
return IsAirResult
|
|
27113
27130
|
end
|
|
27114
27131
|
return nil
|
|
27115
27132
|
end
|
|
27116
27133
|
function GROUP:IsHelicopter()
|
|
27117
|
-
self:F2(self.GroupName)
|
|
27118
27134
|
local DCSGroup=self:GetDCSObject()
|
|
27119
27135
|
if DCSGroup then
|
|
27120
27136
|
local GroupCategory=DCSGroup:getCategory()
|
|
27121
|
-
self:T2(GroupCategory)
|
|
27122
27137
|
return GroupCategory==Group.Category.HELICOPTER
|
|
27123
27138
|
end
|
|
27124
27139
|
return nil
|
|
27125
27140
|
end
|
|
27126
27141
|
function GROUP:IsAirPlane()
|
|
27127
|
-
self:F2()
|
|
27128
27142
|
local DCSGroup=self:GetDCSObject()
|
|
27129
27143
|
if DCSGroup then
|
|
27130
27144
|
local GroupCategory=DCSGroup:getCategory()
|
|
27131
|
-
self:T2(GroupCategory)
|
|
27132
27145
|
return GroupCategory==Group.Category.AIRPLANE
|
|
27133
27146
|
end
|
|
27134
27147
|
return nil
|
|
27135
27148
|
end
|
|
27136
27149
|
function GROUP:IsGround()
|
|
27137
|
-
self:F2()
|
|
27138
27150
|
local DCSGroup=self:GetDCSObject()
|
|
27139
27151
|
if DCSGroup then
|
|
27140
27152
|
local GroupCategory=DCSGroup:getCategory()
|
|
27141
|
-
self:T2(GroupCategory)
|
|
27142
27153
|
return GroupCategory==Group.Category.GROUND
|
|
27143
27154
|
end
|
|
27144
27155
|
return nil
|
|
27145
27156
|
end
|
|
27146
27157
|
function GROUP:IsShip()
|
|
27147
|
-
self:F2()
|
|
27148
27158
|
local DCSGroup=self:GetDCSObject()
|
|
27149
27159
|
if DCSGroup then
|
|
27150
27160
|
local GroupCategory=DCSGroup:getCategory()
|
|
27151
|
-
self:T2(GroupCategory)
|
|
27152
27161
|
return GroupCategory==Group.Category.SHIP
|
|
27153
27162
|
end
|
|
27154
27163
|
return nil
|
|
27155
27164
|
end
|
|
27156
27165
|
function GROUP:AllOnGround()
|
|
27157
|
-
self:F2()
|
|
27158
27166
|
local DCSGroup=self:GetDCSObject()
|
|
27159
27167
|
if DCSGroup then
|
|
27160
27168
|
local AllOnGroundResult=true
|
|
@@ -27163,7 +27171,6 @@ if UnitData:inAir()then
|
|
|
27163
27171
|
AllOnGroundResult=false
|
|
27164
27172
|
end
|
|
27165
27173
|
end
|
|
27166
|
-
self:T3(AllOnGroundResult)
|
|
27167
27174
|
return AllOnGroundResult
|
|
27168
27175
|
end
|
|
27169
27176
|
return nil
|
|
@@ -27189,7 +27196,6 @@ return self:SetAIOnOff(false)
|
|
|
27189
27196
|
end
|
|
27190
27197
|
end
|
|
27191
27198
|
function GROUP:GetMaxVelocity()
|
|
27192
|
-
self:F2()
|
|
27193
27199
|
local DCSGroup=self:GetDCSObject()
|
|
27194
27200
|
if DCSGroup then
|
|
27195
27201
|
local GroupVelocityMax=0
|
|
@@ -27205,7 +27211,6 @@ end
|
|
|
27205
27211
|
return nil
|
|
27206
27212
|
end
|
|
27207
27213
|
function GROUP:GetMinHeight()
|
|
27208
|
-
self:F2()
|
|
27209
27214
|
local DCSGroup=self:GetDCSObject()
|
|
27210
27215
|
if DCSGroup then
|
|
27211
27216
|
local GroupHeightMin=999999999
|
|
@@ -27221,7 +27226,6 @@ end
|
|
|
27221
27226
|
return nil
|
|
27222
27227
|
end
|
|
27223
27228
|
function GROUP:GetMaxHeight()
|
|
27224
|
-
self:F2()
|
|
27225
27229
|
local DCSGroup=self:GetDCSObject()
|
|
27226
27230
|
if DCSGroup then
|
|
27227
27231
|
local GroupHeightMax=-999999999
|
|
@@ -27285,12 +27289,10 @@ self.InitRespawnRandomizePositionInner=InnerRadius
|
|
|
27285
27289
|
return self
|
|
27286
27290
|
end
|
|
27287
27291
|
function GROUP:InitCoordinate(coordinate)
|
|
27288
|
-
self:F({coordinate=coordinate})
|
|
27289
27292
|
self.InitCoord=coordinate
|
|
27290
27293
|
return self
|
|
27291
27294
|
end
|
|
27292
27295
|
function GROUP:InitRadioCommsOnOff(switch)
|
|
27293
|
-
self:F({switch=switch})
|
|
27294
27296
|
if switch==true or switch==nil then
|
|
27295
27297
|
self.InitRespawnRadio=true
|
|
27296
27298
|
else
|
|
@@ -27299,12 +27301,10 @@ end
|
|
|
27299
27301
|
return self
|
|
27300
27302
|
end
|
|
27301
27303
|
function GROUP:InitRadioFrequency(frequency)
|
|
27302
|
-
self:F({frequency=frequency})
|
|
27303
27304
|
self.InitRespawnFreq=frequency
|
|
27304
27305
|
return self
|
|
27305
27306
|
end
|
|
27306
27307
|
function GROUP:InitRadioModulation(modulation)
|
|
27307
|
-
self:F({modulation=modulation})
|
|
27308
27308
|
if modulation and modulation:lower()=="fm"then
|
|
27309
27309
|
self.InitRespawnModu=radio.modulation.FM
|
|
27310
27310
|
else
|
|
@@ -27313,7 +27313,6 @@ end
|
|
|
27313
27313
|
return self
|
|
27314
27314
|
end
|
|
27315
27315
|
function GROUP:InitModex(modex)
|
|
27316
|
-
self:F({modex=modex})
|
|
27317
27316
|
if modex then
|
|
27318
27317
|
self.InitRespawnModex=tonumber(modex)
|
|
27319
27318
|
end
|
|
@@ -27336,13 +27335,10 @@ local Vec3=Zone and Zone:GetVec3()or self:GetVec3()
|
|
|
27336
27335
|
local From={x=Template.x,y=Template.y}
|
|
27337
27336
|
Template.x=Vec3.x
|
|
27338
27337
|
Template.y=Vec3.z
|
|
27339
|
-
self:F(#Template.units)
|
|
27340
27338
|
if Reset==true then
|
|
27341
27339
|
for UnitID,UnitData in pairs(self:GetUnits())do
|
|
27342
27340
|
local GroupUnit=UnitData
|
|
27343
|
-
self:F(GroupUnit:GetName())
|
|
27344
27341
|
if GroupUnit:IsAlive()then
|
|
27345
|
-
self:I("FF Alive")
|
|
27346
27342
|
local GroupUnitVec3=GroupUnit:GetVec3()
|
|
27347
27343
|
if Zone then
|
|
27348
27344
|
if self.InitRespawnRandomizePositionZone then
|
|
@@ -27368,12 +27364,10 @@ Template.units[UnitID].y=GroupUnitVec3.z
|
|
|
27368
27364
|
end
|
|
27369
27365
|
Template.units[UnitID].heading=_Heading(self.InitRespawnHeading and self.InitRespawnHeading or GroupUnit:GetHeading())
|
|
27370
27366
|
Template.units[UnitID].psi=-Template.units[UnitID].heading
|
|
27371
|
-
self:F({UnitID,Template.units[UnitID],Template.units[UnitID]})
|
|
27372
27367
|
end
|
|
27373
27368
|
end
|
|
27374
27369
|
elseif Reset==false then
|
|
27375
27370
|
for UnitID,TemplateUnitData in pairs(Template.units)do
|
|
27376
|
-
self:F("Reset")
|
|
27377
27371
|
local GroupUnitVec3={x=TemplateUnitData.x,y=TemplateUnitData.alt,z=TemplateUnitData.y}
|
|
27378
27372
|
if Zone then
|
|
27379
27373
|
if self.InitRespawnRandomizePositionZone then
|
|
@@ -27393,7 +27387,6 @@ Template.units[UnitID].alt=self.InitRespawnHeight and self.InitRespawnHeight or
|
|
|
27393
27387
|
Template.units[UnitID].x=(Template.units[UnitID].x-From.x)+GroupUnitVec3.x
|
|
27394
27388
|
Template.units[UnitID].y=(Template.units[UnitID].y-From.y)+GroupUnitVec3.z
|
|
27395
27389
|
Template.units[UnitID].heading=self.InitRespawnHeading and self.InitRespawnHeading or TemplateUnitData.heading
|
|
27396
|
-
self:F({UnitID,Template.units[UnitID],Template.units[UnitID]})
|
|
27397
27390
|
end
|
|
27398
27391
|
else
|
|
27399
27392
|
local units=self:GetUnits()
|
|
@@ -27428,17 +27421,14 @@ if self.InitRespawnModu then
|
|
|
27428
27421
|
Template.modulation=self.InitRespawnModu
|
|
27429
27422
|
end
|
|
27430
27423
|
self:Destroy(false)
|
|
27431
|
-
self:T({Template=Template})
|
|
27432
27424
|
_DATABASE:Spawn(Template)
|
|
27433
27425
|
self:ResetEvents()
|
|
27434
27426
|
return self
|
|
27435
27427
|
end
|
|
27436
27428
|
function GROUP:RespawnAtCurrentAirbase(SpawnTemplate,Takeoff,Uncontrolled)
|
|
27437
|
-
self:F2({SpawnTemplate,Takeoff,Uncontrolled})
|
|
27438
27429
|
if self and self:IsAlive()then
|
|
27439
27430
|
local airbase=self:GetCoordinate():GetClosestAirbase()
|
|
27440
27431
|
if airbase then
|
|
27441
|
-
self:F2("Closest airbase = "..airbase:GetName())
|
|
27442
27432
|
else
|
|
27443
27433
|
self:E("ERROR: could not find closest airbase!")
|
|
27444
27434
|
return nil
|
|
@@ -27467,7 +27457,6 @@ local y
|
|
|
27467
27457
|
for UnitID=1,#units do
|
|
27468
27458
|
local unit=units[UnitID]
|
|
27469
27459
|
local Parkingspot,TermialID,Distance=unit:GetCoordinate():GetClosestParkingSpot(airbase)
|
|
27470
|
-
self:T2(string.format("Closest parking spot distance = %s, terminal ID=%s",tostring(Distance),tostring(TermialID)))
|
|
27471
27460
|
local uc=unit:GetCoordinate()
|
|
27472
27461
|
SpawnTemplate.units[UnitID].x=uc.x
|
|
27473
27462
|
SpawnTemplate.units[UnitID].y=uc.z
|
|
@@ -27501,15 +27490,12 @@ end
|
|
|
27501
27490
|
return nil
|
|
27502
27491
|
end
|
|
27503
27492
|
function GROUP:GetTaskMission()
|
|
27504
|
-
self:F2(self.GroupName)
|
|
27505
27493
|
return UTILS.DeepCopy(_DATABASE.Templates.Groups[self.GroupName].Template)
|
|
27506
27494
|
end
|
|
27507
27495
|
function GROUP:GetTaskRoute()
|
|
27508
|
-
self:F2(self.GroupName)
|
|
27509
27496
|
return UTILS.DeepCopy(_DATABASE.Templates.Groups[self.GroupName].Template.route.points)
|
|
27510
27497
|
end
|
|
27511
27498
|
function GROUP:CopyRoute(Begin,End,Randomize,Radius)
|
|
27512
|
-
self:F2({Begin,End})
|
|
27513
27499
|
local Points={}
|
|
27514
27500
|
local GroupName=string.match(self:GetName(),".*#")
|
|
27515
27501
|
if GroupName then
|
|
@@ -27517,7 +27503,6 @@ GroupName=GroupName:sub(1,-2)
|
|
|
27517
27503
|
else
|
|
27518
27504
|
GroupName=self:GetName()
|
|
27519
27505
|
end
|
|
27520
|
-
self:T3({GroupName})
|
|
27521
27506
|
local Template=_DATABASE.Templates.Groups[GroupName].Template
|
|
27522
27507
|
if Template then
|
|
27523
27508
|
if not Begin then
|
|
@@ -27553,7 +27538,6 @@ if ThreatLevelA2G>MaxThreatLevelA2G then
|
|
|
27553
27538
|
MaxThreatLevelA2G=ThreatLevelA2G
|
|
27554
27539
|
end
|
|
27555
27540
|
end
|
|
27556
|
-
self:T3(MaxThreatLevelA2G)
|
|
27557
27541
|
return MaxThreatLevelA2G
|
|
27558
27542
|
end
|
|
27559
27543
|
function GROUP:GetThreatLevel()
|
|
@@ -27568,20 +27552,17 @@ end
|
|
|
27568
27552
|
return threatlevelMax
|
|
27569
27553
|
end
|
|
27570
27554
|
function GROUP:InAir()
|
|
27571
|
-
self:F2(self.GroupName)
|
|
27572
27555
|
local DCSGroup=self:GetDCSObject()
|
|
27573
27556
|
if DCSGroup then
|
|
27574
27557
|
local DCSUnit=DCSGroup:getUnit(1)
|
|
27575
27558
|
if DCSUnit then
|
|
27576
27559
|
local GroupInAir=DCSGroup:getUnit(1):inAir()
|
|
27577
|
-
self:T3(GroupInAir)
|
|
27578
27560
|
return GroupInAir
|
|
27579
27561
|
end
|
|
27580
27562
|
end
|
|
27581
27563
|
return nil
|
|
27582
27564
|
end
|
|
27583
27565
|
function GROUP:IsAirborne(AllUnits)
|
|
27584
|
-
self:F2(self.GroupName)
|
|
27585
27566
|
local units=self:GetUnits()
|
|
27586
27567
|
if units then
|
|
27587
27568
|
if AllUnits then
|
|
@@ -27704,7 +27685,6 @@ return attribute
|
|
|
27704
27685
|
end
|
|
27705
27686
|
do
|
|
27706
27687
|
function GROUP:RouteRTB(RTBAirbase,Speed)
|
|
27707
|
-
self:F({RTBAirbase:GetName(),Speed})
|
|
27708
27688
|
local DCSGroup=self:GetDCSObject()
|
|
27709
27689
|
if DCSGroup then
|
|
27710
27690
|
if RTBAirbase then
|
|
@@ -27713,7 +27693,6 @@ local coord=self:GetCoordinate()
|
|
|
27713
27693
|
local PointFrom=coord:WaypointAirTurningPoint(nil,Speed)
|
|
27714
27694
|
local PointLanding=RTBAirbase:GetCoordinate():WaypointAirLanding(Speed,RTBAirbase)
|
|
27715
27695
|
local Points={PointFrom,PointLanding}
|
|
27716
|
-
self:T3(Points)
|
|
27717
27696
|
local Template=self:GetTemplate()
|
|
27718
27697
|
Template.route.points=Points
|
|
27719
27698
|
self:Respawn(Template,true)
|
|
@@ -27760,7 +27739,6 @@ HasPlayers=true
|
|
|
27760
27739
|
end
|
|
27761
27740
|
end
|
|
27762
27741
|
if HasPlayers==true then
|
|
27763
|
-
self:F2(PlayerNames)
|
|
27764
27742
|
return PlayerNames
|
|
27765
27743
|
end
|
|
27766
27744
|
return nil
|
|
@@ -27779,7 +27757,6 @@ return PlayerCount
|
|
|
27779
27757
|
end
|
|
27780
27758
|
end
|
|
27781
27759
|
function GROUP:EnableEmission(switch)
|
|
27782
|
-
self:F2(self.GroupName)
|
|
27783
27760
|
local switch=switch or false
|
|
27784
27761
|
local DCSUnit=self:GetDCSObject()
|
|
27785
27762
|
if DCSUnit then
|
|
@@ -27791,7 +27768,6 @@ function GROUP:SetCommandInvisible(switch)
|
|
|
27791
27768
|
return self:CommandSetInvisible(switch)
|
|
27792
27769
|
end
|
|
27793
27770
|
function GROUP:CommandSetInvisible(switch)
|
|
27794
|
-
self:F2(self.GroupName)
|
|
27795
27771
|
if switch==nil then
|
|
27796
27772
|
switch=false
|
|
27797
27773
|
end
|
|
@@ -27803,7 +27779,6 @@ function GROUP:SetCommandImmortal(switch)
|
|
|
27803
27779
|
return self:CommandSetImmortal(switch)
|
|
27804
27780
|
end
|
|
27805
27781
|
function GROUP:CommandSetImmortal(switch)
|
|
27806
|
-
self:F2(self.GroupName)
|
|
27807
27782
|
if switch==nil then
|
|
27808
27783
|
switch=false
|
|
27809
27784
|
end
|
|
@@ -27812,7 +27787,6 @@ self:SetCommand(SetImmortal)
|
|
|
27812
27787
|
return self
|
|
27813
27788
|
end
|
|
27814
27789
|
function GROUP:GetSkill()
|
|
27815
|
-
self:F2(self.GroupName)
|
|
27816
27790
|
local unit=self:GetUnit(1)
|
|
27817
27791
|
local name=unit:GetName()
|
|
27818
27792
|
local skill=_DATABASE.Templates.Units[name].Template.skill or"Random"
|
|
@@ -28000,14 +27974,23 @@ function UNIT:Name()
|
|
|
28000
27974
|
return self.UnitName
|
|
28001
27975
|
end
|
|
28002
27976
|
function UNIT:GetDCSObject()
|
|
27977
|
+
if(not self.LastCallDCSObject)or(self.LastCallDCSObject and timer.getTime()-self.LastCallDCSObject>1)then
|
|
28003
27978
|
local DCSUnit=Unit.getByName(self.UnitName)
|
|
28004
27979
|
if DCSUnit then
|
|
27980
|
+
self.LastCallDCSObject=timer.getTime()
|
|
27981
|
+
self.DCSObject=DCSUnit
|
|
28005
27982
|
return DCSUnit
|
|
27983
|
+
else
|
|
27984
|
+
self.DCSObject=nil
|
|
27985
|
+
self.LastCallDCSObject=nil
|
|
27986
|
+
end
|
|
27987
|
+
else
|
|
27988
|
+
return self.DCSObject
|
|
28006
27989
|
end
|
|
28007
27990
|
return nil
|
|
28008
27991
|
end
|
|
28009
27992
|
function UNIT:GetAltitude(FromGround)
|
|
28010
|
-
local DCSUnit=
|
|
27993
|
+
local DCSUnit=self:GetDCSObject()
|
|
28011
27994
|
if DCSUnit then
|
|
28012
27995
|
local altitude=0
|
|
28013
27996
|
local point=DCSUnit:getPoint()
|
|
@@ -28021,19 +28004,14 @@ end
|
|
|
28021
28004
|
return nil
|
|
28022
28005
|
end
|
|
28023
28006
|
function UNIT:ReSpawnAt(Coordinate,Heading)
|
|
28024
|
-
self:T(self:Name())
|
|
28025
28007
|
local SpawnGroupTemplate=UTILS.DeepCopy(_DATABASE:GetGroupTemplateFromUnitName(self:Name()))
|
|
28026
|
-
self:T(SpawnGroupTemplate)
|
|
28027
28008
|
local SpawnGroup=self:GetGroup()
|
|
28028
|
-
self:T({SpawnGroup=SpawnGroup})
|
|
28029
28009
|
if SpawnGroup then
|
|
28030
28010
|
local Vec3=SpawnGroup:GetVec3()
|
|
28031
28011
|
SpawnGroupTemplate.x=Coordinate.x
|
|
28032
28012
|
SpawnGroupTemplate.y=Coordinate.z
|
|
28033
|
-
self:F(#SpawnGroupTemplate.units)
|
|
28034
28013
|
for UnitID,UnitData in pairs(SpawnGroup:GetUnits()or{})do
|
|
28035
28014
|
local GroupUnit=UnitData
|
|
28036
|
-
self:F(GroupUnit:GetName())
|
|
28037
28015
|
if GroupUnit:IsAlive()then
|
|
28038
28016
|
local GroupUnitVec3=GroupUnit:GetVec3()
|
|
28039
28017
|
local GroupUnitHeading=GroupUnit:GetHeading()
|
|
@@ -28041,22 +28019,17 @@ SpawnGroupTemplate.units[UnitID].alt=GroupUnitVec3.y
|
|
|
28041
28019
|
SpawnGroupTemplate.units[UnitID].x=GroupUnitVec3.x
|
|
28042
28020
|
SpawnGroupTemplate.units[UnitID].y=GroupUnitVec3.z
|
|
28043
28021
|
SpawnGroupTemplate.units[UnitID].heading=GroupUnitHeading
|
|
28044
|
-
self:F({UnitID,SpawnGroupTemplate.units[UnitID],SpawnGroupTemplate.units[UnitID]})
|
|
28045
28022
|
end
|
|
28046
28023
|
end
|
|
28047
28024
|
end
|
|
28048
28025
|
for UnitTemplateID,UnitTemplateData in pairs(SpawnGroupTemplate.units)do
|
|
28049
|
-
self:T({UnitTemplateData.name,self:Name()})
|
|
28050
28026
|
SpawnGroupTemplate.units[UnitTemplateID].unitId=nil
|
|
28051
28027
|
if UnitTemplateData.name==self:Name()then
|
|
28052
|
-
self:T("Adjusting")
|
|
28053
28028
|
SpawnGroupTemplate.units[UnitTemplateID].alt=Coordinate.y
|
|
28054
28029
|
SpawnGroupTemplate.units[UnitTemplateID].x=Coordinate.x
|
|
28055
28030
|
SpawnGroupTemplate.units[UnitTemplateID].y=Coordinate.z
|
|
28056
28031
|
SpawnGroupTemplate.units[UnitTemplateID].heading=Heading
|
|
28057
|
-
self:F({UnitTemplateID,SpawnGroupTemplate.units[UnitTemplateID],SpawnGroupTemplate.units[UnitTemplateID]})
|
|
28058
28032
|
else
|
|
28059
|
-
self:F(SpawnGroupTemplate.units[UnitTemplateID].name)
|
|
28060
28033
|
local GroupUnit=UNIT:FindByName(SpawnGroupTemplate.units[UnitTemplateID].name)
|
|
28061
28034
|
if GroupUnit and GroupUnit:IsAlive()then
|
|
28062
28035
|
local GroupUnitVec3=GroupUnit:GetVec3()
|
|
@@ -28067,7 +28040,6 @@ UnitTemplateData.y=GroupUnitVec3.z
|
|
|
28067
28040
|
UnitTemplateData.heading=GroupUnitHeading
|
|
28068
28041
|
else
|
|
28069
28042
|
if SpawnGroupTemplate.units[UnitTemplateID].name~=self:Name()then
|
|
28070
|
-
self:T("nilling")
|
|
28071
28043
|
SpawnGroupTemplate.units[UnitTemplateID].delete=true
|
|
28072
28044
|
end
|
|
28073
28045
|
end
|
|
@@ -28076,7 +28048,6 @@ end
|
|
|
28076
28048
|
local i=1
|
|
28077
28049
|
while i<=#SpawnGroupTemplate.units do
|
|
28078
28050
|
local UnitTemplateData=SpawnGroupTemplate.units[i]
|
|
28079
|
-
self:T(UnitTemplateData.name)
|
|
28080
28051
|
if UnitTemplateData.delete then
|
|
28081
28052
|
table.remove(SpawnGroupTemplate.units,i)
|
|
28082
28053
|
else
|
|
@@ -28084,11 +28055,9 @@ i=i+1
|
|
|
28084
28055
|
end
|
|
28085
28056
|
end
|
|
28086
28057
|
SpawnGroupTemplate.groupId=nil
|
|
28087
|
-
self:T(SpawnGroupTemplate)
|
|
28088
28058
|
_DATABASE:Spawn(SpawnGroupTemplate)
|
|
28089
28059
|
end
|
|
28090
28060
|
function UNIT:IsActive()
|
|
28091
|
-
self:F2(self.UnitName)
|
|
28092
28061
|
local DCSUnit=self:GetDCSObject()
|
|
28093
28062
|
if DCSUnit then
|
|
28094
28063
|
local UnitIsActive=DCSUnit:isActive()
|
|
@@ -28105,7 +28074,6 @@ end
|
|
|
28105
28074
|
return nil
|
|
28106
28075
|
end
|
|
28107
28076
|
function UNIT:IsAlive()
|
|
28108
|
-
self:F3(self.UnitName)
|
|
28109
28077
|
local DCSUnit=self:GetDCSObject()
|
|
28110
28078
|
if DCSUnit and DCSUnit:isExist()then
|
|
28111
28079
|
local UnitIsAlive=DCSUnit:isActive()
|
|
@@ -28117,7 +28085,6 @@ function UNIT:IsDead()
|
|
|
28117
28085
|
return not self:IsAlive()
|
|
28118
28086
|
end
|
|
28119
28087
|
function UNIT:GetCallsign()
|
|
28120
|
-
self:F2(self.UnitName)
|
|
28121
28088
|
local DCSUnit=self:GetDCSObject()
|
|
28122
28089
|
if DCSUnit then
|
|
28123
28090
|
local UnitCallSign=DCSUnit:getCallsign()
|
|
@@ -28126,7 +28093,6 @@ UnitCallSign=DCSUnit:getName()
|
|
|
28126
28093
|
end
|
|
28127
28094
|
return UnitCallSign
|
|
28128
28095
|
end
|
|
28129
|
-
self:F(self.ClassName.." "..self.UnitName.." not found!")
|
|
28130
28096
|
return nil
|
|
28131
28097
|
end
|
|
28132
28098
|
function UNIT:IsPlayer()
|
|
@@ -28150,7 +28116,6 @@ end
|
|
|
28150
28116
|
return false
|
|
28151
28117
|
end
|
|
28152
28118
|
function UNIT:GetPlayerName()
|
|
28153
|
-
self:F(self.UnitName)
|
|
28154
28119
|
local DCSUnit=self:GetDCSObject()
|
|
28155
28120
|
if DCSUnit then
|
|
28156
28121
|
local PlayerName=DCSUnit:getPlayerName()
|
|
@@ -28176,7 +28141,6 @@ local typename=self:GetTypeName()
|
|
|
28176
28141
|
return UTILS.GetReportingName(typename)
|
|
28177
28142
|
end
|
|
28178
28143
|
function UNIT:GetNumber()
|
|
28179
|
-
self:F2(self.UnitName)
|
|
28180
28144
|
local DCSUnit=self:GetDCSObject()
|
|
28181
28145
|
if DCSUnit then
|
|
28182
28146
|
local UnitNumber=DCSUnit:getNumber()
|
|
@@ -28185,7 +28149,6 @@ end
|
|
|
28185
28149
|
return nil
|
|
28186
28150
|
end
|
|
28187
28151
|
function UNIT:GetSpeedMax()
|
|
28188
|
-
self:F2(self.UnitName)
|
|
28189
28152
|
local Desc=self:GetDesc()
|
|
28190
28153
|
if Desc then
|
|
28191
28154
|
local SpeedMax=Desc.speedMax
|
|
@@ -28194,7 +28157,6 @@ end
|
|
|
28194
28157
|
return 0
|
|
28195
28158
|
end
|
|
28196
28159
|
function UNIT:GetRange()
|
|
28197
|
-
self:F2(self.UnitName)
|
|
28198
28160
|
local Desc=self:GetDesc()
|
|
28199
28161
|
if Desc then
|
|
28200
28162
|
local Range=Desc.range
|
|
@@ -28208,7 +28170,6 @@ end
|
|
|
28208
28170
|
return nil
|
|
28209
28171
|
end
|
|
28210
28172
|
function UNIT:IsRefuelable()
|
|
28211
|
-
self:F2(self.UnitName)
|
|
28212
28173
|
local refuelable=self:HasAttribute("Refuelable")
|
|
28213
28174
|
local system=nil
|
|
28214
28175
|
local Desc=self:GetDesc()
|
|
@@ -28218,7 +28179,6 @@ end
|
|
|
28218
28179
|
return refuelable,system
|
|
28219
28180
|
end
|
|
28220
28181
|
function UNIT:IsTanker()
|
|
28221
|
-
self:F2(self.UnitName)
|
|
28222
28182
|
local tanker=self:HasAttribute("Tankers")
|
|
28223
28183
|
local system=nil
|
|
28224
28184
|
if tanker then
|
|
@@ -28270,7 +28230,6 @@ end
|
|
|
28270
28230
|
return false
|
|
28271
28231
|
end
|
|
28272
28232
|
function UNIT:GetGroup()
|
|
28273
|
-
self:F2(self.UnitName)
|
|
28274
28233
|
local UnitGroup=GROUP:FindByName(self.GroupName)
|
|
28275
28234
|
if UnitGroup then
|
|
28276
28235
|
return UnitGroup
|
|
@@ -28287,17 +28246,14 @@ end
|
|
|
28287
28246
|
return nil
|
|
28288
28247
|
end
|
|
28289
28248
|
function UNIT:GetPrefix()
|
|
28290
|
-
self:F2(self.UnitName)
|
|
28291
28249
|
local DCSUnit=self:GetDCSObject()
|
|
28292
28250
|
if DCSUnit then
|
|
28293
28251
|
local UnitPrefix=string.match(self.UnitName,".*#"):sub(1,-2)
|
|
28294
|
-
self:T3(UnitPrefix)
|
|
28295
28252
|
return UnitPrefix
|
|
28296
28253
|
end
|
|
28297
28254
|
return nil
|
|
28298
28255
|
end
|
|
28299
28256
|
function UNIT:GetAmmo()
|
|
28300
|
-
self:F2(self.UnitName)
|
|
28301
28257
|
local DCSUnit=self:GetDCSObject()
|
|
28302
28258
|
if DCSUnit then
|
|
28303
28259
|
local UnitAmmo=DCSUnit:getAmmo()
|
|
@@ -28393,7 +28349,6 @@ local _,_,_,_,_,shells=self:GetAmmunition()
|
|
|
28393
28349
|
return shells or 0
|
|
28394
28350
|
end
|
|
28395
28351
|
function UNIT:GetSensors()
|
|
28396
|
-
self:F2(self.UnitName)
|
|
28397
28352
|
local DCSUnit=self:GetDCSObject()
|
|
28398
28353
|
if DCSUnit then
|
|
28399
28354
|
local UnitSensors=DCSUnit:getSensors()
|
|
@@ -28402,7 +28357,6 @@ end
|
|
|
28402
28357
|
return nil
|
|
28403
28358
|
end
|
|
28404
28359
|
function UNIT:HasSensors(...)
|
|
28405
|
-
self:F2(arg)
|
|
28406
28360
|
local DCSUnit=self:GetDCSObject()
|
|
28407
28361
|
if DCSUnit then
|
|
28408
28362
|
local HasSensors=DCSUnit:hasSensors(unpack(arg))
|
|
@@ -28411,7 +28365,6 @@ end
|
|
|
28411
28365
|
return nil
|
|
28412
28366
|
end
|
|
28413
28367
|
function UNIT:HasSEAD()
|
|
28414
|
-
self:F2()
|
|
28415
28368
|
local DCSUnit=self:GetDCSObject()
|
|
28416
28369
|
if DCSUnit then
|
|
28417
28370
|
local UnitSEADAttributes=DCSUnit:getDesc().attributes
|
|
@@ -28427,7 +28380,6 @@ end
|
|
|
28427
28380
|
return nil
|
|
28428
28381
|
end
|
|
28429
28382
|
function UNIT:GetRadar()
|
|
28430
|
-
self:F2(self.UnitName)
|
|
28431
28383
|
local DCSUnit=self:GetDCSObject()
|
|
28432
28384
|
if DCSUnit then
|
|
28433
28385
|
local UnitRadarOn,UnitRadarObject=DCSUnit:getRadar()
|
|
@@ -28436,7 +28388,6 @@ end
|
|
|
28436
28388
|
return nil,nil
|
|
28437
28389
|
end
|
|
28438
28390
|
function UNIT:GetFuel()
|
|
28439
|
-
self:F3(self.UnitName)
|
|
28440
28391
|
local DCSUnit=self:GetDCSObject()
|
|
28441
28392
|
if DCSUnit then
|
|
28442
28393
|
local UnitFuel=DCSUnit:getFuel()
|
|
@@ -28445,18 +28396,16 @@ end
|
|
|
28445
28396
|
return nil
|
|
28446
28397
|
end
|
|
28447
28398
|
function UNIT:GetUnits()
|
|
28448
|
-
self:F3({self.UnitName})
|
|
28449
28399
|
local DCSUnit=self:GetDCSObject()
|
|
28450
28400
|
local Units={}
|
|
28451
28401
|
if DCSUnit then
|
|
28452
28402
|
Units[1]=UNIT:Find(DCSUnit)
|
|
28453
|
-
self:T3(Units)
|
|
28403
|
+
-self:T3(Units)
|
|
28454
28404
|
return Units
|
|
28455
28405
|
end
|
|
28456
28406
|
return nil
|
|
28457
28407
|
end
|
|
28458
28408
|
function UNIT:GetLife()
|
|
28459
|
-
self:F2(self.UnitName)
|
|
28460
28409
|
local DCSUnit=self:GetDCSObject()
|
|
28461
28410
|
if DCSUnit and DCSUnit:isExist()then
|
|
28462
28411
|
local UnitLife=DCSUnit:getLife()
|
|
@@ -28465,7 +28414,6 @@ end
|
|
|
28465
28414
|
return-1
|
|
28466
28415
|
end
|
|
28467
28416
|
function UNIT:GetLife0()
|
|
28468
|
-
self:F2(self.UnitName)
|
|
28469
28417
|
local DCSUnit=self:GetDCSObject()
|
|
28470
28418
|
if DCSUnit then
|
|
28471
28419
|
local UnitLife0=DCSUnit:getLife0()
|
|
@@ -28474,7 +28422,6 @@ end
|
|
|
28474
28422
|
return 0
|
|
28475
28423
|
end
|
|
28476
28424
|
function UNIT:GetLifeRelative()
|
|
28477
|
-
self:F2(self.UnitName)
|
|
28478
28425
|
if self and self:IsAlive()then
|
|
28479
28426
|
local life0=self:GetLife0()
|
|
28480
28427
|
local lifeN=self:GetLife()
|
|
@@ -28483,7 +28430,6 @@ end
|
|
|
28483
28430
|
return-1
|
|
28484
28431
|
end
|
|
28485
28432
|
function UNIT:GetDamageRelative()
|
|
28486
|
-
self:F2(self.UnitName)
|
|
28487
28433
|
if self and self:IsAlive()then
|
|
28488
28434
|
return 1-self:GetLifeRelative()
|
|
28489
28435
|
end
|
|
@@ -28498,7 +28444,6 @@ end
|
|
|
28498
28444
|
return 0
|
|
28499
28445
|
end
|
|
28500
28446
|
function UNIT:GetUnitCategory()
|
|
28501
|
-
self:F3(self.UnitName)
|
|
28502
28447
|
local DCSUnit=self:GetDCSObject()
|
|
28503
28448
|
if DCSUnit then
|
|
28504
28449
|
return DCSUnit:getDesc().category
|
|
@@ -28506,7 +28451,6 @@ end
|
|
|
28506
28451
|
return nil
|
|
28507
28452
|
end
|
|
28508
28453
|
function UNIT:GetCategoryName()
|
|
28509
|
-
self:F3(self.UnitName)
|
|
28510
28454
|
local DCSUnit=self:GetDCSObject()
|
|
28511
28455
|
if DCSUnit then
|
|
28512
28456
|
local CategoryNames={
|
|
@@ -28517,7 +28461,6 @@ local CategoryNames={
|
|
|
28517
28461
|
[Unit.Category.STRUCTURE]="Structure",
|
|
28518
28462
|
}
|
|
28519
28463
|
local UnitCategory=DCSUnit:getDesc().category
|
|
28520
|
-
self:T3(UnitCategory)
|
|
28521
28464
|
return CategoryNames[UnitCategory]
|
|
28522
28465
|
end
|
|
28523
28466
|
return nil
|
|
@@ -28628,47 +28571,37 @@ end
|
|
|
28628
28571
|
return nil
|
|
28629
28572
|
end
|
|
28630
28573
|
function UNIT:OtherUnitInRadius(AwaitUnit,Radius)
|
|
28631
|
-
self:F2({self.UnitName,AwaitUnit.UnitName,Radius})
|
|
28632
28574
|
local DCSUnit=self:GetDCSObject()
|
|
28633
28575
|
if DCSUnit then
|
|
28634
28576
|
local UnitVec3=self:GetVec3()
|
|
28635
28577
|
local AwaitUnitVec3=AwaitUnit:GetVec3()
|
|
28636
28578
|
if(((UnitVec3.x-AwaitUnitVec3.x)^2+(UnitVec3.z-AwaitUnitVec3.z)^2)^0.5<=Radius)then
|
|
28637
|
-
self:T3("true")
|
|
28638
28579
|
return true
|
|
28639
28580
|
else
|
|
28640
|
-
self:T3("false")
|
|
28641
28581
|
return false
|
|
28642
28582
|
end
|
|
28643
28583
|
end
|
|
28644
28584
|
return nil
|
|
28645
28585
|
end
|
|
28646
28586
|
function UNIT:IsFriendly(FriendlyCoalition)
|
|
28647
|
-
self:F2()
|
|
28648
28587
|
local DCSUnit=self:GetDCSObject()
|
|
28649
28588
|
if DCSUnit then
|
|
28650
28589
|
local UnitCoalition=DCSUnit:getCoalition()
|
|
28651
|
-
self:T3({UnitCoalition,FriendlyCoalition})
|
|
28652
28590
|
local IsFriendlyResult=(UnitCoalition==FriendlyCoalition)
|
|
28653
|
-
self:F(IsFriendlyResult)
|
|
28654
28591
|
return IsFriendlyResult
|
|
28655
28592
|
end
|
|
28656
28593
|
return nil
|
|
28657
28594
|
end
|
|
28658
28595
|
function UNIT:IsShip()
|
|
28659
|
-
self:F2()
|
|
28660
28596
|
local DCSUnit=self:GetDCSObject()
|
|
28661
28597
|
if DCSUnit then
|
|
28662
28598
|
local UnitDescriptor=DCSUnit:getDesc()
|
|
28663
|
-
self:T3({UnitDescriptor.category,Unit.Category.SHIP})
|
|
28664
28599
|
local IsShipResult=(UnitDescriptor.category==Unit.Category.SHIP)
|
|
28665
|
-
self:T3(IsShipResult)
|
|
28666
28600
|
return IsShipResult
|
|
28667
28601
|
end
|
|
28668
28602
|
return nil
|
|
28669
28603
|
end
|
|
28670
28604
|
function UNIT:InAir(NoHeloCheck)
|
|
28671
|
-
self:F2(self.UnitName)
|
|
28672
28605
|
local DCSUnit=self:GetDCSObject()
|
|
28673
28606
|
if DCSUnit then
|
|
28674
28607
|
local UnitInAir=DCSUnit:inAir()
|
|
@@ -28683,7 +28616,6 @@ if Velocity<1 and Height<=60 then
|
|
|
28683
28616
|
UnitInAir=false
|
|
28684
28617
|
end
|
|
28685
28618
|
end
|
|
28686
|
-
self:T3(UnitInAir)
|
|
28687
28619
|
return UnitInAir
|
|
28688
28620
|
end
|
|
28689
28621
|
return nil
|
|
@@ -28768,7 +28700,6 @@ end
|
|
|
28768
28700
|
return nil
|
|
28769
28701
|
end
|
|
28770
28702
|
function UNIT:EnableEmission(switch)
|
|
28771
|
-
self:F2(self.UnitName)
|
|
28772
28703
|
local switch=switch or false
|
|
28773
28704
|
local DCSUnit=self:GetDCSObject()
|
|
28774
28705
|
if DCSUnit then
|
|
@@ -28777,7 +28708,6 @@ end
|
|
|
28777
28708
|
return self
|
|
28778
28709
|
end
|
|
28779
28710
|
function UNIT:GetSkill()
|
|
28780
|
-
self:F2(self.UnitName)
|
|
28781
28711
|
local name=self.UnitName
|
|
28782
28712
|
local skill="Random"
|
|
28783
28713
|
if _DATABASE.Templates.Units[name]and _DATABASE.Templates.Units[name].Template and _DATABASE.Templates.Units[name].Template.skill then
|
|
@@ -28786,7 +28716,6 @@ end
|
|
|
28786
28716
|
return skill
|
|
28787
28717
|
end
|
|
28788
28718
|
function UNIT:GetSTN()
|
|
28789
|
-
self:F2(self.UnitName)
|
|
28790
28719
|
local STN=nil
|
|
28791
28720
|
local VCL=nil
|
|
28792
28721
|
local VCN=nil
|
|
@@ -36923,7 +36852,7 @@ local HasDetectedObjects=false
|
|
|
36923
36852
|
if Detection and Detection:IsAlive()then
|
|
36924
36853
|
self:T({"DetectionGroup is Alive",Detection:GetName()})
|
|
36925
36854
|
local DetectionGroupName=Detection:GetName()
|
|
36926
|
-
local DetectionUnit=Detection:
|
|
36855
|
+
local DetectionUnit=Detection:GetFirstUnitAlive()
|
|
36927
36856
|
local DetectedUnits={}
|
|
36928
36857
|
local DetectedTargets=DetectionUnit:GetDetectedTargets(
|
|
36929
36858
|
self.DetectVisual,
|
|
@@ -36933,7 +36862,7 @@ self.DetectIRST,
|
|
|
36933
36862
|
self.DetectRWR,
|
|
36934
36863
|
self.DetectDLINK
|
|
36935
36864
|
)
|
|
36936
|
-
for DetectionObjectID,Detection in pairs(DetectedTargets)do
|
|
36865
|
+
for DetectionObjectID,Detection in pairs(DetectedTargets or{})do
|
|
36937
36866
|
local DetectedObject=Detection.object
|
|
36938
36867
|
if DetectedObject and DetectedObject:isExist()and DetectedObject.id_<50000000 then
|
|
36939
36868
|
local DetectedObjectName=DetectedObject:getName()
|
|
@@ -36944,7 +36873,7 @@ self.DetectedObjects[DetectedObjectName].Object=DetectedObject
|
|
|
36944
36873
|
end
|
|
36945
36874
|
end
|
|
36946
36875
|
end
|
|
36947
|
-
for DetectionObjectName,DetectedObjectData in pairs(self.DetectedObjects)do
|
|
36876
|
+
for DetectionObjectName,DetectedObjectData in pairs(self.DetectedObjects or{})do
|
|
36948
36877
|
local DetectedObject=DetectedObjectData.Object
|
|
36949
36878
|
if DetectedObject:isExist()then
|
|
36950
36879
|
local TargetIsDetected,TargetIsVisible,TargetLastTime,TargetKnowType,TargetKnowDistance,TargetLastPos,TargetLastVelocity=DetectionUnit:IsTargetDetected(
|
|
@@ -50860,7 +50789,6 @@ end
|
|
|
50860
50789
|
end
|
|
50861
50790
|
end
|
|
50862
50791
|
function WAREHOUSE:_UnitDead(deadunit,deadgroup,request)
|
|
50863
|
-
self:F(self.lid.."FF unit dead "..deadunit:GetName())
|
|
50864
50792
|
local opsgroup=_DATABASE:FindOpsGroup(deadgroup)
|
|
50865
50793
|
if opsgroup then
|
|
50866
50794
|
return nil
|
|
@@ -61625,7 +61553,7 @@ if u and pn then
|
|
|
61625
61553
|
return u,pn
|
|
61626
61554
|
end
|
|
61627
61555
|
local DCSunit=Unit.getByName(_unitName)
|
|
61628
|
-
if DCSunit then
|
|
61556
|
+
if DCSunit and DCSunit.getPlayerName then
|
|
61629
61557
|
local playername=DCSunit:getPlayerName()
|
|
61630
61558
|
local unit=UNIT:Find(DCSunit)
|
|
61631
61559
|
self:T2({DCSunit=DCSunit,unit=unit,playername=playername})
|
|
@@ -67013,6 +66941,7 @@ DynamicCargo={},
|
|
|
67013
66941
|
ChinookTroopCircleRadius=5,
|
|
67014
66942
|
TroopUnloadDistGround=5,
|
|
67015
66943
|
TroopUnloadDistHover=1.5,
|
|
66944
|
+
UserSetGroup=nil,
|
|
67016
66945
|
}
|
|
67017
66946
|
CTLD.RadioModulation={
|
|
67018
66947
|
AM=0,
|
|
@@ -67047,7 +66976,7 @@ CTLD.UnitTypeCapabilities={
|
|
|
67047
66976
|
["OH-58D"]={type="OH58D",crates=false,troops=false,cratelimit=0,trooplimit=0,length=14,cargoweightlimit=400},
|
|
67048
66977
|
["CH-47Fbl1"]={type="CH-47Fbl1",crates=true,troops=true,cratelimit=4,trooplimit=31,length=20,cargoweightlimit=10800},
|
|
67049
66978
|
}
|
|
67050
|
-
CTLD.version="1.1.
|
|
66979
|
+
CTLD.version="1.1.16"
|
|
67051
66980
|
function CTLD:New(Coalition,Prefixes,Alias)
|
|
67052
66981
|
local self=BASE:Inherit(self,FSM:New())
|
|
67053
66982
|
BASE:T({Coalition,Prefixes,Alias})
|
|
@@ -67171,6 +67100,8 @@ self.nobuildinloadzones=true
|
|
|
67171
67100
|
self.movecratesbeforebuild=true
|
|
67172
67101
|
self.surfacetypes={land.SurfaceType.LAND,land.SurfaceType.ROAD,land.SurfaceType.RUNWAY,land.SurfaceType.SHALLOW_WATER}
|
|
67173
67102
|
self.enableChinookGCLoading=true
|
|
67103
|
+
self.ChinookTroopCircleRadius=5
|
|
67104
|
+
self.UserSetGroup=nil
|
|
67174
67105
|
local AliaS=string.gsub(self.alias," ","_")
|
|
67175
67106
|
self.filename=string.format("CTLD_%s_Persist.csv",AliaS)
|
|
67176
67107
|
self.allowcratepickupagain=true
|
|
@@ -69595,6 +69526,10 @@ capabilities.cargoweightlimit=Maxcargoweight or maxcargo
|
|
|
69595
69526
|
self.UnitTypeCapabilities[unittype]=capabilities
|
|
69596
69527
|
return self
|
|
69597
69528
|
end
|
|
69529
|
+
function CTLD:SetOwnSetPilotGroups(Set)
|
|
69530
|
+
self.UserSetGroup=Set
|
|
69531
|
+
return self
|
|
69532
|
+
end
|
|
69598
69533
|
function CTLD:UnitCapabilities(Unittype,Cancrates,Cantroops,Cratelimit,Trooplimit,Length,Maxcargoweight)
|
|
69599
69534
|
self:I(self.lid.."This function been replaced with `SetUnitCapabilities()` - pls use the new one going forward!")
|
|
69600
69535
|
self:SetUnitCapabilities(Unittype,Cancrates,Cantroops,Cratelimit,Trooplimit,Length,Maxcargoweight)
|
|
@@ -70099,7 +70034,9 @@ end
|
|
|
70099
70034
|
function CTLD:onafterStart(From,Event,To)
|
|
70100
70035
|
self:T({From,Event,To})
|
|
70101
70036
|
self:I(self.lid.."Started ("..self.version..")")
|
|
70102
|
-
if self.
|
|
70037
|
+
if self.UserSetGroup then
|
|
70038
|
+
self.PilotGroups=self.UserSetGroup
|
|
70039
|
+
elseif self.useprefix or self.enableHercules then
|
|
70103
70040
|
local prefix=self.prefixes
|
|
70104
70041
|
if self.enableHercules then
|
|
70105
70042
|
self.PilotGroups=SET_GROUP:New():FilterCoalitions(self.coalitiontxt):FilterPrefixes(prefix):FilterStart()
|
|
@@ -70971,6 +70908,9 @@ topmenuname="CSAR",
|
|
|
70971
70908
|
ADFRadioPwr=1000,
|
|
70972
70909
|
PilotWeight=80,
|
|
70973
70910
|
CreateRadioBeacons=true,
|
|
70911
|
+
UserSetGroup=nil,
|
|
70912
|
+
AllowIRStrobe=false,
|
|
70913
|
+
IRStrobeRuntime=300,
|
|
70974
70914
|
}
|
|
70975
70915
|
CSAR.AircraftType={}
|
|
70976
70916
|
CSAR.AircraftType["SA342Mistral"]=2
|
|
@@ -70990,7 +70930,7 @@ CSAR.AircraftType["MH-60R"]=10
|
|
|
70990
70930
|
CSAR.AircraftType["OH-6A"]=2
|
|
70991
70931
|
CSAR.AircraftType["OH-58D"]=2
|
|
70992
70932
|
CSAR.AircraftType["CH-47Fbl1"]=31
|
|
70993
|
-
CSAR.version="1.0.
|
|
70933
|
+
CSAR.version="1.0.29"
|
|
70994
70934
|
function CSAR:New(Coalition,Template,Alias)
|
|
70995
70935
|
local self=BASE:Inherit(self,FSM:New())
|
|
70996
70936
|
BASE:T({Coalition,Template,Alias})
|
|
@@ -71096,6 +71036,7 @@ self.usewetfeet=false
|
|
|
71096
71036
|
self.allowbronco=false
|
|
71097
71037
|
self.ADFRadioPwr=1000
|
|
71098
71038
|
self.PilotWeight=80
|
|
71039
|
+
self.UserSetGroup=nil
|
|
71099
71040
|
self.useSRS=false
|
|
71100
71041
|
self.SRSPath="E:\\Program Files\\DCS-SimpleRadio-Standalone"
|
|
71101
71042
|
self.SRSchannel=300
|
|
@@ -71116,13 +71057,13 @@ self.filepath=nil
|
|
|
71116
71057
|
self.saveinterval=600
|
|
71117
71058
|
return self
|
|
71118
71059
|
end
|
|
71119
|
-
function CSAR:_CreateDownedPilotTrack(Group,Groupname,Side,OriginalUnit,Description,Typename,Frequency,Playername,Wetfeet)
|
|
71060
|
+
function CSAR:_CreateDownedPilotTrack(Group,Groupname,Side,OriginalUnit,Description,Typename,Frequency,Playername,Wetfeet,BeaconName)
|
|
71120
71061
|
self:T({"_CreateDownedPilotTrack",Groupname,Side,OriginalUnit,Description,Typename,Frequency,Playername})
|
|
71121
71062
|
local DownedPilot={}
|
|
71122
71063
|
DownedPilot.desc=Description or""
|
|
71123
71064
|
DownedPilot.frequency=Frequency or 0
|
|
71124
71065
|
DownedPilot.index=self.downedpilotcounter
|
|
71125
|
-
DownedPilot.name=Groupname or""
|
|
71066
|
+
DownedPilot.name=Groupname or Playername or""
|
|
71126
71067
|
DownedPilot.originalUnit=OriginalUnit or""
|
|
71127
71068
|
DownedPilot.player=Playername or""
|
|
71128
71069
|
DownedPilot.side=Side or 0
|
|
@@ -71131,6 +71072,7 @@ DownedPilot.group=Group
|
|
|
71131
71072
|
DownedPilot.timestamp=0
|
|
71132
71073
|
DownedPilot.alive=true
|
|
71133
71074
|
DownedPilot.wetfeet=Wetfeet or false
|
|
71075
|
+
DownedPilot.BeaconName=BeaconName
|
|
71134
71076
|
local PilotTable=self.downedPilots
|
|
71135
71077
|
local counter=self.downedpilotcounter
|
|
71136
71078
|
PilotTable[counter]={}
|
|
@@ -71243,8 +71185,16 @@ else
|
|
|
71243
71185
|
self:_DisplayToAllSAR("Troops In Contact. ".._typeName.." requests CASEVAC. ",self.coalition,self.messageTime)
|
|
71244
71186
|
end
|
|
71245
71187
|
end
|
|
71188
|
+
local BeaconName
|
|
71189
|
+
if _playerName then
|
|
71190
|
+
BeaconName=_unitName..math.random(1,10000)
|
|
71191
|
+
elseif _unitName then
|
|
71192
|
+
BeaconName=_playerName..math.random(1,10000)
|
|
71193
|
+
else
|
|
71194
|
+
BeaconName="Ghost-1-1"..math.random(1,10000)
|
|
71195
|
+
end
|
|
71246
71196
|
if(_freq and _freq~=0)then
|
|
71247
|
-
self:_AddBeaconToGroup(_spawnedGroup,_freq)
|
|
71197
|
+
self:_AddBeaconToGroup(_spawnedGroup,_freq,BeaconName)
|
|
71248
71198
|
end
|
|
71249
71199
|
self:_AddSpecialOptions(_spawnedGroup)
|
|
71250
71200
|
local _text=_description
|
|
@@ -71265,7 +71215,7 @@ end
|
|
|
71265
71215
|
end
|
|
71266
71216
|
self:T({_spawnedGroup,_alias})
|
|
71267
71217
|
local _GroupName=_spawnedGroup:GetName()or _alias
|
|
71268
|
-
self:_CreateDownedPilotTrack(_spawnedGroup,_GroupName,_coalition,_unitName,_text,_typeName,_freq,_playerName,wetfeet)
|
|
71218
|
+
self:_CreateDownedPilotTrack(_spawnedGroup,_GroupName,_coalition,_unitName,_text,_typeName,_freq,_playerName,wetfeet,BeaconName)
|
|
71269
71219
|
self:_InitSARForPilot(_spawnedGroup,_unitName,_freq,noMessage,_playerName)
|
|
71270
71220
|
return self
|
|
71271
71221
|
end
|
|
@@ -72017,7 +71967,7 @@ _distance=string.format("%.1fnm",UTILS.MetersToNM(_closest.distance))
|
|
|
72017
71967
|
else
|
|
72018
71968
|
_distance=string.format("%.1fkm",_closest.distance/1000)
|
|
72019
71969
|
end
|
|
72020
|
-
local _msg=string.format("%s -
|
|
71970
|
+
local _msg=string.format("%s - Firing signal flare at your %s o\'clock. Distance %s",self:_GetCustomCallSign(_unitName),_clockDir,_distance)
|
|
72021
71971
|
self:_DisplayMessageToSAR(_heli,_msg,self.messageTime,false,true,true)
|
|
72022
71972
|
local _coord=_closest.pilot:GetCoordinate()
|
|
72023
71973
|
_coord:FlareRed(_clockDir)
|
|
@@ -72042,7 +71992,6 @@ local voice=self.CSARVoice or MSRS.Voices.Google.Standard.en_GB_Standard_F
|
|
|
72042
71992
|
if self.msrs:GetProvider()==MSRS.Provider.WINDOWS then
|
|
72043
71993
|
voice=self.CSARVoiceMS or MSRS.Voices.Microsoft.Hedda
|
|
72044
71994
|
end
|
|
72045
|
-
self:F("Voice = "..voice)
|
|
72046
71995
|
self.SRSQueue:NewTransmission(_message,duration,self.msrs,tstart,2,subgroups,subtitle,subduration,self.SRSchannel,self.SRSModulation,gender,culture,voice,volume,label,self.coordinate)
|
|
72047
71996
|
end
|
|
72048
71997
|
if ToScreen==true or ToScreen==nil then
|
|
@@ -72055,6 +72004,37 @@ end
|
|
|
72055
72004
|
end
|
|
72056
72005
|
return self
|
|
72057
72006
|
end
|
|
72007
|
+
function CSAR:_ReqIRStrobe(_unitName)
|
|
72008
|
+
self:T(self.lid.." _ReqIRStrobe")
|
|
72009
|
+
local _heli=self:_GetSARHeli(_unitName)
|
|
72010
|
+
if _heli==nil then
|
|
72011
|
+
return
|
|
72012
|
+
end
|
|
72013
|
+
local smokedist=8000
|
|
72014
|
+
if smokedist<self.approachdist_far then smokedist=self.approachdist_far end
|
|
72015
|
+
local _closest=self:_GetClosestDownedPilot(_heli)
|
|
72016
|
+
if _closest~=nil and _closest.pilot~=nil and _closest.distance>0 and _closest.distance<smokedist then
|
|
72017
|
+
local _clockDir=self:_GetClockDirection(_heli,_closest.pilot)
|
|
72018
|
+
local _distance=string.format("%.1fkm",_closest.distance/1000)
|
|
72019
|
+
if _SETTINGS:IsImperial()then
|
|
72020
|
+
_distance=string.format("%.1fnm",UTILS.MetersToNM(_closest.distance))
|
|
72021
|
+
else
|
|
72022
|
+
_distance=string.format("%.1fkm",_closest.distance/1000)
|
|
72023
|
+
end
|
|
72024
|
+
local _msg=string.format("%s - IR Strobe active at your %s o\'clock. Distance %s",self:_GetCustomCallSign(_unitName),_clockDir,_distance)
|
|
72025
|
+
self:_DisplayMessageToSAR(_heli,_msg,self.messageTime,false,true,true)
|
|
72026
|
+
_closest.pilot:NewIRMarker(true,self.IRStrobeRuntime or 300)
|
|
72027
|
+
else
|
|
72028
|
+
local _distance=string.format("%.1fkm",smokedist/1000)
|
|
72029
|
+
if _SETTINGS:IsImperial()then
|
|
72030
|
+
_distance=string.format("%.1fnm",UTILS.MetersToNM(smokedist))
|
|
72031
|
+
else
|
|
72032
|
+
_distance=string.format("%.1fkm",smokedist/1000)
|
|
72033
|
+
end
|
|
72034
|
+
self:_DisplayMessageToSAR(_heli,string.format("No Pilots within %s",_distance),self.messageTime,false,false,true)
|
|
72035
|
+
end
|
|
72036
|
+
return self
|
|
72037
|
+
end
|
|
72058
72038
|
function CSAR:_Reqsmoke(_unitName)
|
|
72059
72039
|
self:T(self.lid.." _Reqsmoke")
|
|
72060
72040
|
local _heli=self:_GetSARHeli(_unitName)
|
|
@@ -72177,7 +72157,12 @@ local _rootPath=MENU_GROUP:New(_group,menuname)
|
|
|
72177
72157
|
local _rootMenu1=MENU_GROUP_COMMAND:New(_group,"List Active CSAR",_rootPath,self._DisplayActiveSAR,self,_unitName)
|
|
72178
72158
|
local _rootMenu2=MENU_GROUP_COMMAND:New(_group,"Check Onboard",_rootPath,self._CheckOnboard,self,_unitName)
|
|
72179
72159
|
local _rootMenu3=MENU_GROUP_COMMAND:New(_group,"Request Signal Flare",_rootPath,self._SignalFlare,self,_unitName)
|
|
72180
|
-
local _rootMenu4=MENU_GROUP_COMMAND:New(_group,"Request Smoke",_rootPath,self._Reqsmoke,self,_unitName)
|
|
72160
|
+
local _rootMenu4=MENU_GROUP_COMMAND:New(_group,"Request Smoke",_rootPath,self._Reqsmoke,self,_unitName)
|
|
72161
|
+
if self.AllowIRStrobe then
|
|
72162
|
+
local _rootMenu5=MENU_GROUP_COMMAND:New(_group,"Request IR Strobe",_rootPath,self._ReqIRStrobe,self,_unitName):Refresh()
|
|
72163
|
+
else
|
|
72164
|
+
_rootMenu4:Refresh()
|
|
72165
|
+
end
|
|
72181
72166
|
end
|
|
72182
72167
|
end
|
|
72183
72168
|
end
|
|
@@ -72240,7 +72225,7 @@ if clock>12 then clock=clock-12 end
|
|
|
72240
72225
|
end
|
|
72241
72226
|
return clock
|
|
72242
72227
|
end
|
|
72243
|
-
function CSAR:_AddBeaconToGroup(_group,_freq)
|
|
72228
|
+
function CSAR:_AddBeaconToGroup(_group,_freq,_name)
|
|
72244
72229
|
self:T(self.lid.." _AddBeaconToGroup")
|
|
72245
72230
|
if self.CreateRadioBeacons==false then return end
|
|
72246
72231
|
local _group=_group
|
|
@@ -72261,7 +72246,7 @@ local Frequency=_freq
|
|
|
72261
72246
|
local name=_radioUnit:GetName()
|
|
72262
72247
|
local Sound="l10n/DEFAULT/"..self.radioSound
|
|
72263
72248
|
local vec3=_radioUnit:GetVec3()or _radioUnit:GetPositionVec3()or{x=0,y=0,z=0}
|
|
72264
|
-
trigger.action.radioTransmission(Sound,vec3,0,false,Frequency,self.ADFRadioPwr or 1000,
|
|
72249
|
+
trigger.action.radioTransmission(Sound,vec3,0,false,Frequency,self.ADFRadioPwr or 1000,_name)
|
|
72265
72250
|
end
|
|
72266
72251
|
end
|
|
72267
72252
|
return self
|
|
@@ -72276,8 +72261,10 @@ self:T({_pilot.name})
|
|
|
72276
72261
|
local pilot=_pilot
|
|
72277
72262
|
local group=pilot.group
|
|
72278
72263
|
local frequency=pilot.frequency or 0
|
|
72264
|
+
local bname=pilot.BeaconName or pilot.name..math.random(1,100000)
|
|
72265
|
+
trigger.action.stopRadioTransmission(bname)
|
|
72279
72266
|
if group and group:IsAlive()and frequency>0 then
|
|
72280
|
-
self:_AddBeaconToGroup(group,frequency)
|
|
72267
|
+
self:_AddBeaconToGroup(group,frequency,bname)
|
|
72281
72268
|
end
|
|
72282
72269
|
end
|
|
72283
72270
|
end
|
|
@@ -72305,6 +72292,10 @@ else
|
|
|
72305
72292
|
return false
|
|
72306
72293
|
end
|
|
72307
72294
|
end
|
|
72295
|
+
function CSAR:SetOwnSetPilotGroups(Set)
|
|
72296
|
+
self.UserSetGroup=Set
|
|
72297
|
+
return self
|
|
72298
|
+
end
|
|
72308
72299
|
function CSAR:onafterStart(From,Event,To)
|
|
72309
72300
|
self:T({From,Event,To})
|
|
72310
72301
|
self:I(self.lid.."Started ("..self.version..")")
|
|
@@ -72315,7 +72306,9 @@ self:HandleEvent(EVENTS.LandingAfterEjection,self._EventHandler)
|
|
|
72315
72306
|
self:HandleEvent(EVENTS.PlayerEnterAircraft,self._EventHandler)
|
|
72316
72307
|
self:HandleEvent(EVENTS.PlayerEnterUnit,self._EventHandler)
|
|
72317
72308
|
self:HandleEvent(EVENTS.PilotDead,self._EventHandler)
|
|
72318
|
-
if self.
|
|
72309
|
+
if self.UserSetGroup then
|
|
72310
|
+
self.allheligroupset=self.UserSetGroup
|
|
72311
|
+
elseif self.allowbronco then
|
|
72319
72312
|
local prefixes=self.csarPrefix or{}
|
|
72320
72313
|
self.allheligroupset=SET_GROUP:New():FilterCoalitions(self.coalitiontxt):FilterPrefixes(prefixes):FilterStart()
|
|
72321
72314
|
elseif self.useprefix then
|
|
@@ -76123,10 +76116,14 @@ local Dispatcher=AI_A2G_Fsm:GetDispatcher()
|
|
|
76123
76116
|
local Squadron=Dispatcher:GetSquadronFromDefender(DefenderGroup)
|
|
76124
76117
|
if Squadron then
|
|
76125
76118
|
local FirstUnit=AttackSetUnit:GetRandomSurely()
|
|
76119
|
+
if FirstUnit then
|
|
76126
76120
|
local Coordinate=FirstUnit:GetCoordinate()
|
|
76127
76121
|
if self.SetSendPlayerMessages then
|
|
76128
76122
|
Dispatcher:MessageToPlayers(Squadron,DefenderName..", on route to ground target at "..Coordinate:ToStringA2G(DefenderGroup),DefenderGroup)
|
|
76129
76123
|
end
|
|
76124
|
+
else
|
|
76125
|
+
return
|
|
76126
|
+
end
|
|
76130
76127
|
end
|
|
76131
76128
|
self:GetParent(self).onafterEngageRoute(self,DefenderGroup,From,Event,To,AttackSetUnit)
|
|
76132
76129
|
end
|