Merge branch 'FF/Develop' into FF/Fox2

This commit is contained in:
Frank
2020-03-14 20:18:26 +01:00
2 changed files with 48 additions and 8 deletions
+2 -2
View File
@@ -190,7 +190,7 @@ end
function DATABASE:AddUnit( DCSUnitName ) function DATABASE:AddUnit( DCSUnitName )
if not self.UNITS[DCSUnitName] then if not self.UNITS[DCSUnitName] then
self:T( { "Add UNIT:", DCSUnitName } ) self:I( { "Add UNIT:", DCSUnitName } )
local UnitRegister = UNIT:Register( DCSUnitName ) local UnitRegister = UNIT:Register( DCSUnitName )
self.UNITS[DCSUnitName] = UNIT:Register( DCSUnitName ) self.UNITS[DCSUnitName] = UNIT:Register( DCSUnitName )
@@ -526,7 +526,7 @@ end
function DATABASE:AddGroup( GroupName ) function DATABASE:AddGroup( GroupName )
if not self.GROUPS[GroupName] then if not self.GROUPS[GroupName] then
self:T( { "Add GROUP:", GroupName } ) self:I( { "Add GROUP:", GroupName } )
self.GROUPS[GroupName] = GROUP:Register( GroupName ) self.GROUPS[GroupName] = GROUP:Register( GroupName )
end end
+44 -4
View File
@@ -326,6 +326,7 @@ function SPAWN:New( SpawnTemplatePrefix )
self.SpawnInitRadio = nil -- No radio comms setting. self.SpawnInitRadio = nil -- No radio comms setting.
self.SpawnInitModex = nil self.SpawnInitModex = nil
self.SpawnInitAirbase = nil self.SpawnInitAirbase = nil
self.TweakedTemplate = false -- Check if the user is using self made template.
self.SpawnGroups = {} -- Array containing the descriptions of each Group to be Spawned. self.SpawnGroups = {} -- Array containing the descriptions of each Group to be Spawned.
else else
@@ -379,6 +380,7 @@ function SPAWN:NewWithAlias( SpawnTemplatePrefix, SpawnAliasPrefix )
self.SpawnInitRadio = nil -- No radio comms setting. self.SpawnInitRadio = nil -- No radio comms setting.
self.SpawnInitModex = nil self.SpawnInitModex = nil
self.SpawnInitAirbase = nil self.SpawnInitAirbase = nil
self.TweakedTemplate = false -- Check if the user is using self made template.
self.SpawnGroups = {} -- Array containing the descriptions of each Group to be Spawned. self.SpawnGroups = {} -- Array containing the descriptions of each Group to be Spawned.
else else
@@ -407,6 +409,10 @@ end
function SPAWN:NewFromTemplate( SpawnTemplate, SpawnTemplatePrefix, SpawnAliasPrefix ) function SPAWN:NewFromTemplate( SpawnTemplate, SpawnTemplatePrefix, SpawnAliasPrefix )
local self = BASE:Inherit( self, BASE:New() ) local self = BASE:Inherit( self, BASE:New() )
self:F( { SpawnTemplate, SpawnTemplatePrefix, SpawnAliasPrefix } ) self:F( { SpawnTemplate, SpawnTemplatePrefix, SpawnAliasPrefix } )
if SpawnAliasPrefix == nil or SpawnAliasPrefix == "" then
BASE:I("ERROR: in function NewFromTemplate, required paramter SpawnAliasPrefix is not set")
return nil
end
if SpawnTemplate then if SpawnTemplate then
self.SpawnTemplate = SpawnTemplate -- Contains the template structure for a Group Spawn from the Mission Editor. Note that this group must have lateActivation always on!!! self.SpawnTemplate = SpawnTemplate -- Contains the template structure for a Group Spawn from the Mission Editor. Note that this group must have lateActivation always on!!!
@@ -435,6 +441,7 @@ function SPAWN:NewFromTemplate( SpawnTemplate, SpawnTemplatePrefix, SpawnAliasPr
self.SpawnInitRadio = nil -- No radio comms setting. self.SpawnInitRadio = nil -- No radio comms setting.
self.SpawnInitModex = nil self.SpawnInitModex = nil
self.SpawnInitAirbase = nil self.SpawnInitAirbase = nil
self.TweakedTemplate = true -- Check if the user is using self made template.
self.SpawnGroups = {} -- Array containing the descriptions of each Group to be Spawned. self.SpawnGroups = {} -- Array containing the descriptions of each Group to be Spawned.
else else
@@ -1239,14 +1246,19 @@ function SPAWN:SpawnWithIndex( SpawnIndex, NoBirth )
if self:_GetSpawnIndex( SpawnIndex ) then if self:_GetSpawnIndex( SpawnIndex ) then
if self.SpawnGroups[self.SpawnIndex].Visible then if self.SpawnGroups[self.SpawnIndex].Visible then
env.info("FF visible ==> activate")
self.SpawnGroups[self.SpawnIndex].Group:Activate() self.SpawnGroups[self.SpawnIndex].Group:Activate()
else else
env.info("FF get template")
local SpawnTemplate = self.SpawnGroups[self.SpawnIndex].SpawnTemplate local SpawnTemplate = self.SpawnGroups[self.SpawnIndex].SpawnTemplate
self:T( SpawnTemplate.name ) self:T( SpawnTemplate.name )
if SpawnTemplate then if SpawnTemplate then
env.info("FF found template")
local PointVec3 = POINT_VEC3:New( SpawnTemplate.route.points[1].x, SpawnTemplate.route.points[1].alt, SpawnTemplate.route.points[1].y ) local PointVec3 = POINT_VEC3:New( SpawnTemplate.route.points[1].x, SpawnTemplate.route.points[1].alt, SpawnTemplate.route.points[1].y )
self:T( { "Current point of ", self.SpawnTemplatePrefix, PointVec3 } ) self:T( { "Current point of ", self.SpawnTemplatePrefix, PointVec3 } )
@@ -1417,6 +1429,14 @@ function SPAWN:SpawnWithIndex( SpawnIndex, NoBirth )
SpawnGroup:SetAIOnOff( self.AIOnOff ) SpawnGroup:SetAIOnOff( self.AIOnOff )
end end
env.info("FF Returning spawn group")
if SpawnGroup then
else
end
self:T3( SpawnTemplate.name ) self:T3( SpawnTemplate.name )
-- If there is a SpawnFunction hook defined, call it. -- If there is a SpawnFunction hook defined, call it.
@@ -1428,12 +1448,16 @@ function SPAWN:SpawnWithIndex( SpawnIndex, NoBirth )
--if self.Repeat then --if self.Repeat then
-- _DATABASE:SetStatusGroup( SpawnTemplate.name, "ReSpawn" ) -- _DATABASE:SetStatusGroup( SpawnTemplate.name, "ReSpawn" )
--end --end
--else
-- self:E("ERROR: No spawn template.")
end end
self.SpawnGroups[self.SpawnIndex].Spawned = true self.SpawnGroups[self.SpawnIndex].Spawned = true
return self.SpawnGroups[self.SpawnIndex].Group return self.SpawnGroups[self.SpawnIndex].Group
else else
--self:E( { self.SpawnTemplatePrefix, "No more Groups to Spawn:", SpawnIndex, self.SpawnMaxGroups } ) self:E( { self.SpawnTemplatePrefix, "No more Groups to Spawn:", SpawnIndex, self.SpawnMaxGroups } )
end end
return nil return nil
@@ -1934,9 +1958,20 @@ function SPAWN:SpawnAtAirbase( SpawnAirbase, Takeoff, TakeoffAltitude, TerminalT
SpawnTemplate.uncontrolled = self.SpawnUnControlled SpawnTemplate.uncontrolled = self.SpawnUnControlled
env.info("FF spawning group with index "..self.SpawnIndex)
-- Spawn group. -- Spawn group.
local GroupSpawned = self:SpawnWithIndex( self.SpawnIndex ) local GroupSpawned = self:SpawnWithIndex( self.SpawnIndex )
if GroupSpawned then
env.info("ERROR: spawn group is there!")
GroupSpawned:SmokeRed()
local n=#GroupSpawned:GetUnits()
env.info("FF n="..tostring(n))
else
env.info("ERROR: spawn group not there!")
end
-- When spawned in the air, we need to generate a Takeoff Event. -- When spawned in the air, we need to generate a Takeoff Event.
if Takeoff == GROUP.Takeoff.Air then if Takeoff == GROUP.Takeoff.Air then
for UnitID, UnitSpawned in pairs( GroupSpawned:GetUnits() ) do for UnitID, UnitSpawned in pairs( GroupSpawned:GetUnits() ) do
@@ -2977,9 +3012,14 @@ function SPAWN:_Prepare( SpawnTemplatePrefix, SpawnIndex ) --R2.2
-- self.SpawnTemplate = self:_GetTemplate( SpawnTemplatePrefix ) -- self.SpawnTemplate = self:_GetTemplate( SpawnTemplatePrefix )
-- end -- end
local SpawnTemplate = self:_GetTemplate( SpawnTemplatePrefix ) local SpawnTemplate
--local SpawnTemplate = self.SpawnTemplate if self.TweakedTemplate ~= nil and self.TweakedTemplate == true then
SpawnTemplate.name = self:SpawnGroupName( SpawnIndex ) BASE:I("WARNING: You are using a tweaked template.")
SpawnTemplate = self.SpawnTemplate
else
SpawnTemplate = self:_GetTemplate( SpawnTemplatePrefix )
end
SpawnTemplate.groupId = nil SpawnTemplate.groupId = nil
--SpawnTemplate.lateActivation = false --SpawnTemplate.lateActivation = false