SPAWNSTATIC

- Attempt to SPAWN FARPS. Does not work yet.
This commit is contained in:
Frank
2020-12-14 00:08:30 +01:00
parent 2500cfb3c7
commit 47c461e504
2 changed files with 40 additions and 8 deletions

View File

@@ -241,6 +241,20 @@ function SPAWNSTATIC:InitShape(StaticShape)
return self
end
--- Initialize parameters for spawning FARPs.
-- @param #SPAWNSTATIC self
-- @param #number CallsignID Callsign ID. Default 1 (="London").
-- @param #number Frequency Frequency in MHz. Default 127.5 MHz.
-- @param #number Modulation Modulation 0=AM, 1=FM.
-- @return #SPAWNSTATIC self
function SPAWNSTATIC:InitFARP(CallsignID, Frequency, Modulation)
self.InitFarp=true
self.InitFarpCallsignID=CallsignID or 1
self.InitFarpFreq=Frequency or 127.5
self.InitFarpModu=Modulation or 0
return self
end
--- Initialize cargo mass.
-- @param #SPAWNSTATIC self
-- @param #number Mass Mass of the cargo in kg.
@@ -420,22 +434,34 @@ function SPAWNSTATIC:_SpawnStatic(Template, CountryID)
Template.offsets.angle=self.InitOffsetAngle and math.rad(self.InitOffsetAngle) or 0
end
if self.InitFarp then
Template.heliport_callsign_id = self.InitFarpCallsignID
Template.heliport_frequency = self.InitFarpFreq
Template.heliport_modulation = self.InitFarpModu
Template.unitId=nil
end
-- Increase spawn index counter.
self.SpawnIndex = self.SpawnIndex + 1
-- Name of the spawned static.
Template.name = self.InitStaticName or string.format("%s#%05d", self.SpawnTemplatePrefix, self.SpawnIndex)
-- Register the new static.
--_DATABASE:_RegisterStaticTemplate(Template, self.CoalitionID, self.CategoryID, CountryID)
_DATABASE:AddStatic(Template.name)
-- Add and register the new static.
local mystatic=_DATABASE:AddStatic(Template.name)
-- Debug output.
self:T(Template)
-- Add static to the game.
local Static=coalition.addStaticObject(CountryID, Template)
local Static=nil
if self.InitFARP then
env.info("Spawning FARP")
Static=coalition.addGroup(CountryID, -1, Template)
else
Static=coalition.addStaticObject(CountryID, Template)
end
return _DATABASE:FindStatic(Static:getName())
return mystatic
end