|
|
|
|
@@ -976,7 +976,8 @@ function ARMYGROUP:onafterSpawned(From, Event, To)
|
|
|
|
|
-- Update route.
|
|
|
|
|
if Nwp>1 and self.isMobile then
|
|
|
|
|
self:T(self.lid..string.format("Got %d waypoints on spawn ==> Cruise in -1.0 sec!", Nwp))
|
|
|
|
|
self:__Cruise(-1, nil, self.option.Formation)
|
|
|
|
|
--self:__Cruise(-1, nil, self.option.Formation)
|
|
|
|
|
self:__Cruise(-1)
|
|
|
|
|
else
|
|
|
|
|
self:T(self.lid.."No waypoints on spawn ==> Full Stop!")
|
|
|
|
|
self:FullStop()
|
|
|
|
|
@@ -1948,7 +1949,7 @@ function ARMYGROUP:onafterCruise(From, Event, To, Speed, Formation)
|
|
|
|
|
self.dTwait=nil
|
|
|
|
|
|
|
|
|
|
-- Debug info.
|
|
|
|
|
self:T(self.lid.."Cruise ==> Update route in 0.01 sec")
|
|
|
|
|
self:T(self.lid..string.format("Cruise ==> Update route in 0.01 sec (speed=%s, formation=%s)", tostring(Speed), tostring(Formation)))
|
|
|
|
|
|
|
|
|
|
-- Update route.
|
|
|
|
|
self:__UpdateRoute(-0.01, nil, nil, Speed, Formation)
|
|
|
|
|
@@ -2003,7 +2004,7 @@ function ARMYGROUP:AddWaypoint(Coordinate, Speed, AfterWaypointWithID, Formation
|
|
|
|
|
elseif self.optionDefault.Formation then
|
|
|
|
|
Formation = self.optionDefault.Formation
|
|
|
|
|
elseif self.option.Formation then
|
|
|
|
|
Formation = self.option.Formation
|
|
|
|
|
Formation = self.option.Formation
|
|
|
|
|
else
|
|
|
|
|
-- Default formation is on road.
|
|
|
|
|
Formation = ENUMS.Formation.Vehicle.OnRoad
|
|
|
|
|
@@ -2043,82 +2044,90 @@ end
|
|
|
|
|
-- @param #ARMYGROUP self
|
|
|
|
|
-- @param #table Template Template used to init the group. Default is `self.template`.
|
|
|
|
|
-- @return #ARMYGROUP self
|
|
|
|
|
function ARMYGROUP:_InitGroup(Template)
|
|
|
|
|
function ARMYGROUP:_InitGroup(Template, Delay)
|
|
|
|
|
|
|
|
|
|
-- First check if group was already initialized.
|
|
|
|
|
if self.groupinitialized then
|
|
|
|
|
self:T(self.lid.."WARNING: Group was already initialized! Will NOT do it again!")
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- Get template of group.
|
|
|
|
|
local template=Template or self:_GetTemplate()
|
|
|
|
|
|
|
|
|
|
-- Ground are always AI.
|
|
|
|
|
self.isAI=true
|
|
|
|
|
|
|
|
|
|
-- Is (template) group late activated.
|
|
|
|
|
self.isLateActivated=template.lateActivation
|
|
|
|
|
|
|
|
|
|
-- Ground groups cannot be uncontrolled.
|
|
|
|
|
self.isUncontrolled=false
|
|
|
|
|
|
|
|
|
|
-- Max speed in km/h.
|
|
|
|
|
self.speedMax=self.group:GetSpeedMax()
|
|
|
|
|
|
|
|
|
|
-- Is group mobile?
|
|
|
|
|
if self.speedMax>3.6 then
|
|
|
|
|
self.isMobile=true
|
|
|
|
|
if Delay and Delay>0 then
|
|
|
|
|
self:ScheduleOnce(Delay, ARMYGROUP._InitGroup, self, Template, 0)
|
|
|
|
|
else
|
|
|
|
|
self.isMobile=false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- Cruise speed in km/h
|
|
|
|
|
self.speedCruise=self.speedMax*0.7
|
|
|
|
|
|
|
|
|
|
-- Group ammo.
|
|
|
|
|
self.ammo=self:GetAmmoTot()
|
|
|
|
|
|
|
|
|
|
-- Radio parameters from template.
|
|
|
|
|
self.radio.On=false -- Radio is always OFF for ground.
|
|
|
|
|
self.radio.Freq=133
|
|
|
|
|
self.radio.Modu=radio.modulation.AM
|
|
|
|
|
|
|
|
|
|
-- Set default radio.
|
|
|
|
|
self:SetDefaultRadio(self.radio.Freq, self.radio.Modu, self.radio.On)
|
|
|
|
|
|
|
|
|
|
-- Get current formation from first waypoint.
|
|
|
|
|
self.option.Formation=template.route.points[1].action
|
|
|
|
|
|
|
|
|
|
-- Set default formation to "on road".
|
|
|
|
|
self.optionDefault.Formation=ENUMS.Formation.Vehicle.OnRoad
|
|
|
|
|
|
|
|
|
|
-- Default TACAN off.
|
|
|
|
|
self:SetDefaultTACAN(nil, nil, nil, nil, true)
|
|
|
|
|
self.tacan=UTILS.DeepCopy(self.tacanDefault)
|
|
|
|
|
-- First check if group was already initialized.
|
|
|
|
|
if self.groupinitialized then
|
|
|
|
|
self:T(self.lid.."WARNING: Group was already initialized! Will NOT do it again!")
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
self:I(self.lid.."FF Initializing Group")
|
|
|
|
|
|
|
|
|
|
-- Units of the group.
|
|
|
|
|
local units=self.group:GetUnits()
|
|
|
|
|
-- Get template of group.
|
|
|
|
|
local template=Template or self:_GetTemplate()
|
|
|
|
|
|
|
|
|
|
-- Ground are always AI.
|
|
|
|
|
self.isAI=true
|
|
|
|
|
|
|
|
|
|
-- Is (template) group late activated.
|
|
|
|
|
self.isLateActivated=template.lateActivation
|
|
|
|
|
|
|
|
|
|
-- Ground groups cannot be uncontrolled.
|
|
|
|
|
self.isUncontrolled=false
|
|
|
|
|
|
|
|
|
|
-- Max speed in km/h.
|
|
|
|
|
self.speedMax=self.group:GetSpeedMax()
|
|
|
|
|
|
|
|
|
|
-- Is group mobile?
|
|
|
|
|
if self.speedMax>3.6 then
|
|
|
|
|
self.isMobile=true
|
|
|
|
|
else
|
|
|
|
|
self.isMobile=false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- Cruise speed in km/h
|
|
|
|
|
self.speedCruise=self.speedMax*0.7
|
|
|
|
|
|
|
|
|
|
-- Group ammo.
|
|
|
|
|
self.ammo=self:GetAmmoTot()
|
|
|
|
|
|
|
|
|
|
-- Radio parameters from template.
|
|
|
|
|
self.radio.On=false -- Radio is always OFF for ground.
|
|
|
|
|
self.radio.Freq=133
|
|
|
|
|
self.radio.Modu=radio.modulation.AM
|
|
|
|
|
|
|
|
|
|
-- Set default radio.
|
|
|
|
|
self:SetDefaultRadio(self.radio.Freq, self.radio.Modu, self.radio.On)
|
|
|
|
|
|
|
|
|
|
-- Get current formation from first waypoint.
|
|
|
|
|
self.option.Formation=template.route.points[1].action
|
|
|
|
|
|
|
|
|
|
-- Set default formation to "on road".
|
|
|
|
|
self.optionDefault.Formation=ENUMS.Formation.Vehicle.OnRoad
|
|
|
|
|
|
|
|
|
|
-- DCS group.
|
|
|
|
|
local dcsgroup=Group.getByName(self.groupname)
|
|
|
|
|
local size0=dcsgroup:getInitialSize()
|
|
|
|
|
-- Default TACAN off.
|
|
|
|
|
self:SetDefaultTACAN(nil, nil, nil, nil, true)
|
|
|
|
|
self.tacan=UTILS.DeepCopy(self.tacanDefault)
|
|
|
|
|
|
|
|
|
|
-- Units of the group.
|
|
|
|
|
local units=self.group:GetUnits()
|
|
|
|
|
|
|
|
|
|
-- DCS group.
|
|
|
|
|
local dcsgroup=Group.getByName(self.groupname)
|
|
|
|
|
local size0=dcsgroup:getInitialSize()
|
|
|
|
|
local u=dcsgroup:getUnits()
|
|
|
|
|
|
|
|
|
|
-- Quick check.
|
|
|
|
|
if #units~=size0 then
|
|
|
|
|
self:T(self.lid..string.format("ERROR: Got #units=%d but group consists of %d units! u=%d", #units, size0, #u))
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- Add elemets.
|
|
|
|
|
for _,unit in pairs(units) do
|
|
|
|
|
local unitname=unit:GetName()
|
|
|
|
|
self:_AddElementByName(unitname)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Quick check.
|
|
|
|
|
if #units~=size0 then
|
|
|
|
|
self:T(self.lid..string.format("ERROR: Got #units=%d but group consists of %d units!", #units, size0))
|
|
|
|
|
-- Init done.
|
|
|
|
|
self.groupinitialized=true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- Add elemets.
|
|
|
|
|
for _,unit in pairs(units) do
|
|
|
|
|
local unitname=unit:GetName()
|
|
|
|
|
self:_AddElementByName(unitname)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Init done.
|
|
|
|
|
self.groupinitialized=true
|
|
|
|
|
|
|
|
|
|
return self
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|