mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
OPSGROUP
- Improved respawn behaviour
This commit is contained in:
parent
7e8555d6b7
commit
ee880a893e
@ -2049,60 +2049,62 @@ end
|
|||||||
--- Initialize group parameters. Also initializes waypoints if self.waypoints is nil.
|
--- Initialize group parameters. Also initializes waypoints if self.waypoints is nil.
|
||||||
-- @param #ARMYGROUP self
|
-- @param #ARMYGROUP self
|
||||||
-- @param #table Template Template used to init the group. Default is `self.template`.
|
-- @param #table Template Template used to init the group. Default is `self.template`.
|
||||||
|
-- @param #number Delay Delay in seconds before group is initialized. Default `nil`, *i.e.* instantaneous.
|
||||||
-- @return #ARMYGROUP self
|
-- @return #ARMYGROUP self
|
||||||
function ARMYGROUP:_InitGroup(Template, Delay)
|
function ARMYGROUP:_InitGroup(Template, Delay)
|
||||||
|
|
||||||
if Delay and Delay>0 then
|
if Delay and Delay>0 then
|
||||||
self:ScheduleOnce(Delay, ARMYGROUP._InitGroup, self, Template, 0)
|
self:ScheduleOnce(Delay, ARMYGROUP._InitGroup, self, Template, 0)
|
||||||
else
|
else
|
||||||
-- First check if group was already initialized.
|
|
||||||
if self.groupinitialized then
|
-- First check if group was already initialized.
|
||||||
self:T(self.lid.."WARNING: Group was already initialized! Will NOT do it again!")
|
if self.groupinitialized then
|
||||||
return
|
self:T(self.lid.."WARNING: Group was already initialized! Will NOT do it again!")
|
||||||
end
|
return
|
||||||
|
end
|
||||||
-- Get template of group.
|
|
||||||
local template=Template or self:_GetTemplate()
|
-- Get template of group.
|
||||||
|
local template=Template or self:_GetTemplate()
|
||||||
-- Ground are always AI.
|
|
||||||
self.isAI=true
|
-- Ground are always AI.
|
||||||
|
self.isAI=true
|
||||||
-- Is (template) group late activated.
|
|
||||||
self.isLateActivated=template.lateActivation
|
-- Is (template) group late activated.
|
||||||
|
self.isLateActivated=template.lateActivation
|
||||||
-- Ground groups cannot be uncontrolled.
|
|
||||||
self.isUncontrolled=false
|
-- Ground groups cannot be uncontrolled.
|
||||||
|
self.isUncontrolled=false
|
||||||
-- Max speed in km/h.
|
|
||||||
self.speedMax=self.group:GetSpeedMax()
|
-- Max speed in km/h.
|
||||||
|
self.speedMax=self.group:GetSpeedMax()
|
||||||
-- Is group mobile?
|
|
||||||
if self.speedMax and self.speedMax>3.6 then
|
-- Is group mobile?
|
||||||
self.isMobile=true
|
if self.speedMax and self.speedMax>3.6 then
|
||||||
else
|
self.isMobile=true
|
||||||
self.isMobile=false
|
else
|
||||||
self.speedMax = 0
|
self.isMobile=false
|
||||||
end
|
self.speedMax = 0
|
||||||
|
end
|
||||||
-- Cruise speed in km/h
|
|
||||||
self.speedCruise=self.speedMax*0.7
|
-- Cruise speed in km/h
|
||||||
|
self.speedCruise=self.speedMax*0.7
|
||||||
-- Group ammo.
|
|
||||||
self.ammo=self:GetAmmoTot()
|
-- Group ammo.
|
||||||
|
self.ammo=self:GetAmmoTot()
|
||||||
-- Radio parameters from template.
|
|
||||||
self.radio.On=false -- Radio is always OFF for ground.
|
-- Radio parameters from template.
|
||||||
self.radio.Freq=133
|
self.radio.On=false -- Radio is always OFF for ground.
|
||||||
self.radio.Modu=radio.modulation.AM
|
self.radio.Freq=133
|
||||||
|
self.radio.Modu=radio.modulation.AM
|
||||||
-- Set default radio.
|
|
||||||
self:SetDefaultRadio(self.radio.Freq, self.radio.Modu, self.radio.On)
|
-- 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
|
-- 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
|
-- Set default formation to "on road".
|
||||||
|
self.optionDefault.Formation=ENUMS.Formation.Vehicle.OnRoad
|
||||||
|
|
||||||
-- First check if group was already initialized.
|
-- First check if group was already initialized.
|
||||||
if self.groupinitialized then
|
if self.groupinitialized then
|
||||||
@ -2177,7 +2179,6 @@ function ARMYGROUP:_InitGroup(Template, Delay)
|
|||||||
self:_AddElementByName(unitname)
|
self:_AddElementByName(unitname)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Init done.
|
-- Init done.
|
||||||
self.groupinitialized=true
|
self.groupinitialized=true
|
||||||
end
|
end
|
||||||
|
|||||||
@ -3803,114 +3803,120 @@ end
|
|||||||
--- Initialize group parameters. Also initializes waypoints if self.waypoints is nil.
|
--- Initialize group parameters. Also initializes waypoints if self.waypoints is nil.
|
||||||
-- @param #FLIGHTGROUP self
|
-- @param #FLIGHTGROUP self
|
||||||
-- @param #table Template Template used to init the group. Default is `self.template`.
|
-- @param #table Template Template used to init the group. Default is `self.template`.
|
||||||
|
-- @param #number Delay Delay in seconds before group is initialized. Default `nil`, *i.e.* instantaneous.
|
||||||
-- @return #FLIGHTGROUP self
|
-- @return #FLIGHTGROUP self
|
||||||
function FLIGHTGROUP:_InitGroup(Template)
|
function FLIGHTGROUP:_InitGroup(Template, Delay)
|
||||||
|
|
||||||
-- First check if group was already initialized.
|
if Delay and Delay>0 then
|
||||||
if self.groupinitialized then
|
self:ScheduleOnce(Delay, FLIGHTGROUP._InitGroup, self, Template, 0)
|
||||||
self:T(self.lid.."WARNING: Group was already initialized! Will NOT do it again!")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Group object.
|
|
||||||
local group=self.group --Wrapper.Group#GROUP
|
|
||||||
|
|
||||||
-- Helo group.
|
|
||||||
self.isHelo=group:IsHelicopter()
|
|
||||||
|
|
||||||
-- Max speed in km/h.
|
|
||||||
self.speedMax=group:GetSpeedMax()
|
|
||||||
|
|
||||||
-- Is group mobile?
|
|
||||||
if self.speedMax and self.speedMax>3.6 then
|
|
||||||
self.isMobile=true
|
|
||||||
else
|
else
|
||||||
self.isMobile=false
|
|
||||||
self.speedMax = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Cruise speed limit 380 kts for fixed and 110 knots for rotary wings.
|
-- First check if group was already initialized.
|
||||||
local speedCruiseLimit=self.isHelo and UTILS.KnotsToKmph(110) or UTILS.KnotsToKmph(380)
|
if self.groupinitialized then
|
||||||
|
self:T(self.lid.."WARNING: Group was already initialized! Will NOT do it again!")
|
||||||
-- Cruise speed: 70% of max speed but within limit.
|
return
|
||||||
self.speedCruise=math.min(self.speedMax*0.7, speedCruiseLimit)
|
|
||||||
|
|
||||||
-- Group ammo.
|
|
||||||
self.ammo=self:GetAmmoTot()
|
|
||||||
|
|
||||||
-- Get template of group.
|
|
||||||
local template=Template or self:_GetTemplate()
|
|
||||||
|
|
||||||
-- Is (template) group uncontrolled.
|
|
||||||
self.isUncontrolled=template~=nil and template.uncontrolled or false
|
|
||||||
|
|
||||||
-- Is (template) group late activated.
|
|
||||||
self.isLateActivated=template~=nil and template.lateActivation or false
|
|
||||||
|
|
||||||
if template then
|
|
||||||
|
|
||||||
-- Radio parameters from template. Default is set on spawn if not modified by user.
|
|
||||||
self.radio.Freq=tonumber(template.frequency)
|
|
||||||
self.radio.Modu=tonumber(template.modulation)
|
|
||||||
self.radio.On=template.communication
|
|
||||||
|
|
||||||
-- Set callsign. Default is set on spawn if not modified by user.
|
|
||||||
local callsign=template.units[1].callsign
|
|
||||||
--self:I({callsign=callsign})
|
|
||||||
if type(callsign)=="number" then -- Sometimes callsign is just "101".
|
|
||||||
local cs=tostring(callsign)
|
|
||||||
callsign={}
|
|
||||||
callsign[1]=cs:sub(1,1)
|
|
||||||
callsign[2]=cs:sub(2,2)
|
|
||||||
callsign[3]=cs:sub(3,3)
|
|
||||||
end
|
end
|
||||||
self.callsign.NumberSquad=tonumber(callsign[1])
|
|
||||||
self.callsign.NumberGroup=tonumber(callsign[2])
|
-- Group object.
|
||||||
self.callsign.NameSquad=UTILS.GetCallsignName(self.callsign.NumberSquad)
|
local group=self.group --Wrapper.Group#GROUP
|
||||||
|
|
||||||
|
-- Helo group.
|
||||||
|
self.isHelo=group:IsHelicopter()
|
||||||
|
|
||||||
|
-- Max speed in km/h.
|
||||||
|
self.speedMax=group:GetSpeedMax()
|
||||||
|
|
||||||
end
|
-- Is group mobile?
|
||||||
|
if self.speedMax and self.speedMax>3.6 then
|
||||||
-- Set default formation.
|
self.isMobile=true
|
||||||
if self.isHelo then
|
else
|
||||||
self.optionDefault.Formation=ENUMS.Formation.RotaryWing.EchelonLeft.D300
|
self.isMobile=false
|
||||||
else
|
self.speedMax = 0
|
||||||
self.optionDefault.Formation=ENUMS.Formation.FixedWing.EchelonLeft.Group
|
end
|
||||||
end
|
|
||||||
|
|
||||||
-- Default TACAN off.
|
|
||||||
self:SetDefaultTACAN(nil, nil, nil, nil, true)
|
|
||||||
self.tacan=UTILS.DeepCopy(self.tacanDefault)
|
|
||||||
|
|
||||||
-- Is this purely AI?
|
|
||||||
self.isAI=not self:_IsHuman(group)
|
|
||||||
|
|
||||||
-- Create Menu.
|
|
||||||
if not self.isAI then
|
|
||||||
self.menu=self.menu or {}
|
|
||||||
self.menu.atc=self.menu.atc or {} --#table
|
|
||||||
self.menu.atc.root=self.menu.atc.root or MENU_GROUP:New(self.group, "ATC") --Core.Menu#MENU_GROUP
|
|
||||||
self.menu.atc.help=self.menu.atc.help or MENU_GROUP:New(self.group, "Help", self.menu.atc.root) --Core.Menu#MENU_GROUP
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Units of the group.
|
|
||||||
local units=self.group:GetUnits()
|
|
||||||
|
|
||||||
-- DCS group.
|
-- Cruise speed limit 380 kts for fixed and 110 knots for rotary wings.
|
||||||
local dcsgroup=Group.getByName(self.groupname)
|
local speedCruiseLimit=self.isHelo and UTILS.KnotsToKmph(110) or UTILS.KnotsToKmph(380)
|
||||||
local size0=dcsgroup:getInitialSize()
|
|
||||||
|
|
||||||
-- Quick check.
|
-- Cruise speed: 70% of max speed but within limit.
|
||||||
if #units~=size0 then
|
self.speedCruise=math.min(self.speedMax*0.7, speedCruiseLimit)
|
||||||
self:T(self.lid..string.format("ERROR: Got #units=%d but group consists of %d units!", #units, size0))
|
|
||||||
end
|
-- Group ammo.
|
||||||
|
self.ammo=self:GetAmmoTot()
|
||||||
-- Add elemets.
|
|
||||||
for _,unit in pairs(units) do
|
-- Get template of group.
|
||||||
self:_AddElementByName(unit:GetName())
|
local template=Template or self:_GetTemplate()
|
||||||
|
|
||||||
|
-- Is (template) group uncontrolled.
|
||||||
|
self.isUncontrolled=template~=nil and template.uncontrolled or false
|
||||||
|
|
||||||
|
-- Is (template) group late activated.
|
||||||
|
self.isLateActivated=template~=nil and template.lateActivation or false
|
||||||
|
|
||||||
|
if template then
|
||||||
|
|
||||||
|
-- Radio parameters from template. Default is set on spawn if not modified by user.
|
||||||
|
self.radio.Freq=tonumber(template.frequency)
|
||||||
|
self.radio.Modu=tonumber(template.modulation)
|
||||||
|
self.radio.On=template.communication
|
||||||
|
|
||||||
|
-- Set callsign. Default is set on spawn if not modified by user.
|
||||||
|
local callsign=template.units[1].callsign
|
||||||
|
--self:I({callsign=callsign})
|
||||||
|
if type(callsign)=="number" then -- Sometimes callsign is just "101".
|
||||||
|
local cs=tostring(callsign)
|
||||||
|
callsign={}
|
||||||
|
callsign[1]=cs:sub(1,1)
|
||||||
|
callsign[2]=cs:sub(2,2)
|
||||||
|
callsign[3]=cs:sub(3,3)
|
||||||
|
end
|
||||||
|
self.callsign.NumberSquad=tonumber(callsign[1])
|
||||||
|
self.callsign.NumberGroup=tonumber(callsign[2])
|
||||||
|
self.callsign.NameSquad=UTILS.GetCallsignName(self.callsign.NumberSquad)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Set default formation.
|
||||||
|
if self.isHelo then
|
||||||
|
self.optionDefault.Formation=ENUMS.Formation.RotaryWing.EchelonLeft.D300
|
||||||
|
else
|
||||||
|
self.optionDefault.Formation=ENUMS.Formation.FixedWing.EchelonLeft.Group
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Default TACAN off.
|
||||||
|
self:SetDefaultTACAN(nil, nil, nil, nil, true)
|
||||||
|
self.tacan=UTILS.DeepCopy(self.tacanDefault)
|
||||||
|
|
||||||
|
-- Is this purely AI?
|
||||||
|
self.isAI=not self:_IsHuman(group)
|
||||||
|
|
||||||
|
-- Create Menu.
|
||||||
|
if not self.isAI then
|
||||||
|
self.menu=self.menu or {}
|
||||||
|
self.menu.atc=self.menu.atc or {} --#table
|
||||||
|
self.menu.atc.root=self.menu.atc.root or MENU_GROUP:New(self.group, "ATC") --Core.Menu#MENU_GROUP
|
||||||
|
self.menu.atc.help=self.menu.atc.help or MENU_GROUP:New(self.group, "Help", self.menu.atc.root) --Core.Menu#MENU_GROUP
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Units of the group.
|
||||||
|
local units=self.group:GetUnits()
|
||||||
|
|
||||||
|
-- DCS group.
|
||||||
|
local dcsgroup=Group.getByName(self.groupname)
|
||||||
|
local size0=dcsgroup:getInitialSize()
|
||||||
|
|
||||||
|
-- Quick check.
|
||||||
|
if #units~=size0 then
|
||||||
|
self:T(self.lid..string.format("ERROR: Got #units=%d but group consists of %d units!", #units, size0))
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Add elemets.
|
||||||
|
for _,unit in pairs(units) do
|
||||||
|
self:_AddElementByName(unit:GetName())
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Init done.
|
||||||
|
self.groupinitialized=true
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Init done.
|
|
||||||
self.groupinitialized=true
|
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1841,81 +1841,88 @@ end
|
|||||||
--- Initialize group parameters. Also initializes waypoints if self.waypoints is nil.
|
--- Initialize group parameters. Also initializes waypoints if self.waypoints is nil.
|
||||||
-- @param #NAVYGROUP self
|
-- @param #NAVYGROUP self
|
||||||
-- @param #table Template Template used to init the group. Default is `self.template`.
|
-- @param #table Template Template used to init the group. Default is `self.template`.
|
||||||
|
-- @param #number Delay Delay in seconds before group is initialized. Default `nil`, *i.e.* instantaneous.
|
||||||
-- @return #NAVYGROUP self
|
-- @return #NAVYGROUP self
|
||||||
function NAVYGROUP:_InitGroup(Template)
|
function NAVYGROUP:_InitGroup(Template, Delay)
|
||||||
|
|
||||||
-- First check if group was already initialized.
|
if Delay and Delay>0 then
|
||||||
if self.groupinitialized then
|
-- Delayed call
|
||||||
self:T(self.lid.."WARNING: Group was already initialized! Will NOT do it again!")
|
self:ScheduleOnce(Delay, NAVYGROUP._InitGroup, self, Template, 0)
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Get template of group.
|
|
||||||
local template=Template or self:_GetTemplate()
|
|
||||||
|
|
||||||
-- Ships are always AI.
|
|
||||||
self.isAI=true
|
|
||||||
|
|
||||||
-- Is (template) group late activated.
|
|
||||||
self.isLateActivated=template.lateActivation
|
|
||||||
|
|
||||||
-- Naval groups cannot be uncontrolled.
|
|
||||||
self.isUncontrolled=false
|
|
||||||
|
|
||||||
-- Max speed in km/h.
|
|
||||||
self.speedMax=self.group:GetSpeedMax()
|
|
||||||
|
|
||||||
-- Is group mobile?
|
|
||||||
if self.speedMax and self.speedMax>3.6 then
|
|
||||||
self.isMobile=true
|
|
||||||
else
|
else
|
||||||
self.isMobile=false
|
|
||||||
self.speedMax = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Cruise speed: 70% of max speed.
|
-- First check if group was already initialized.
|
||||||
self.speedCruise=self.speedMax*0.7
|
if self.groupinitialized then
|
||||||
|
self:T(self.lid.."WARNING: Group was already initialized! Will NOT do it again!")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
-- Group ammo.
|
-- Get template of group.
|
||||||
self.ammo=self:GetAmmoTot()
|
local template=Template or self:_GetTemplate()
|
||||||
|
|
||||||
-- Radio parameters from template. Default is set on spawn if not modified by the user.
|
-- Ships are always AI.
|
||||||
self.radio.On=true -- Radio is always on for ships.
|
self.isAI=true
|
||||||
self.radio.Freq=tonumber(template.units[1].frequency)/1000000
|
|
||||||
self.radio.Modu=tonumber(template.units[1].modulation)
|
-- Is (template) group late activated.
|
||||||
|
self.isLateActivated=template.lateActivation
|
||||||
|
|
||||||
|
-- Naval groups cannot be uncontrolled.
|
||||||
|
self.isUncontrolled=false
|
||||||
|
|
||||||
|
-- Max speed in km/h.
|
||||||
|
self.speedMax=self.group:GetSpeedMax()
|
||||||
|
|
||||||
|
-- Is group mobile?
|
||||||
|
if self.speedMax and self.speedMax>3.6 then
|
||||||
|
self.isMobile=true
|
||||||
|
else
|
||||||
|
self.isMobile=false
|
||||||
|
self.speedMax = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Cruise speed: 70% of max speed.
|
||||||
|
self.speedCruise=self.speedMax*0.7
|
||||||
|
|
||||||
|
-- Group ammo.
|
||||||
|
self.ammo=self:GetAmmoTot()
|
||||||
|
|
||||||
|
-- Radio parameters from template. Default is set on spawn if not modified by the user.
|
||||||
|
self.radio.On=true -- Radio is always on for ships.
|
||||||
|
self.radio.Freq=tonumber(template.units[1].frequency)/1000000
|
||||||
|
self.radio.Modu=tonumber(template.units[1].modulation)
|
||||||
|
|
||||||
|
-- Set default formation. No really applicable for ships.
|
||||||
|
self.optionDefault.Formation="Off Road"
|
||||||
|
self.option.Formation=self.optionDefault.Formation
|
||||||
|
|
||||||
-- Set default formation. No really applicable for ships.
|
-- Default TACAN off.
|
||||||
self.optionDefault.Formation="Off Road"
|
self:SetDefaultTACAN(nil, nil, nil, nil, true)
|
||||||
self.option.Formation=self.optionDefault.Formation
|
self.tacan=UTILS.DeepCopy(self.tacanDefault)
|
||||||
|
|
||||||
-- Default TACAN off.
|
-- Default ICLS off.
|
||||||
self:SetDefaultTACAN(nil, nil, nil, nil, true)
|
self:SetDefaultICLS(nil, nil, nil, true)
|
||||||
self.tacan=UTILS.DeepCopy(self.tacanDefault)
|
self.icls=UTILS.DeepCopy(self.iclsDefault)
|
||||||
|
|
||||||
|
-- Get all units of the group.
|
||||||
|
local units=self.group:GetUnits()
|
||||||
|
|
||||||
-- Default ICLS off.
|
-- DCS group.
|
||||||
self:SetDefaultICLS(nil, nil, nil, true)
|
local dcsgroup=Group.getByName(self.groupname)
|
||||||
self.icls=UTILS.DeepCopy(self.iclsDefault)
|
local size0=dcsgroup:getInitialSize()
|
||||||
|
|
||||||
-- Get all units of the group.
|
-- Quick check.
|
||||||
local units=self.group:GetUnits()
|
if #units~=size0 then
|
||||||
|
self:E(self.lid..string.format("ERROR: Got #units=%d but group consists of %d units!", #units, size0))
|
||||||
-- DCS group.
|
end
|
||||||
local dcsgroup=Group.getByName(self.groupname)
|
|
||||||
local size0=dcsgroup:getInitialSize()
|
-- Add elemets.
|
||||||
|
for _,unit in pairs(units) do
|
||||||
-- Quick check.
|
self:_AddElementByName(unit:GetName())
|
||||||
if #units~=size0 then
|
end
|
||||||
self:E(self.lid..string.format("ERROR: Got #units=%d but group consists of %d units!", #units, size0))
|
|
||||||
|
-- Init done.
|
||||||
|
self.groupinitialized=true
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Add elemets.
|
|
||||||
for _,unit in pairs(units) do
|
|
||||||
self:_AddElementByName(unit:GetName())
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Init done.
|
|
||||||
self.groupinitialized=true
|
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -7760,7 +7760,7 @@ function OPSGROUP:_Respawn(Delay, Template, Reset)
|
|||||||
|
|
||||||
|
|
||||||
-- Despawn old group. Dont trigger any remove unit event since this is a respawn.
|
-- Despawn old group. Dont trigger any remove unit event since this is a respawn.
|
||||||
self:Despawn(0, true)
|
--self:Despawn(0, true)
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
@ -7777,13 +7777,16 @@ function OPSGROUP:_Respawn(Delay, Template, Reset)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Debug output.
|
-- Debug output.
|
||||||
self:T({Template=Template})
|
self:T2({Template=Template})
|
||||||
|
|
||||||
-- Spawn new group.
|
-- Spawn new group.
|
||||||
self.group=_DATABASE:Spawn(Template)
|
--self.group=_DATABASE:Spawn(Template)
|
||||||
|
local countryID=self.group:GetCountry()
|
||||||
|
local categoryID=self.group:GetCategory()
|
||||||
|
local dcsgroup=coalition.addGroup(countryID, categoryID, Template)
|
||||||
|
|
||||||
-- Set DCS group and controller.
|
-- Set DCS group and controller.
|
||||||
self.dcsgroup=self:GetDCSGroup()
|
self.dcsgroup=dcsgroup or self:GetDCSGroup()
|
||||||
self.controller=self.dcsgroup:getController()
|
self.controller=self.dcsgroup:getController()
|
||||||
|
|
||||||
-- Set activation and controlled state.
|
-- Set activation and controlled state.
|
||||||
@ -7794,7 +7797,6 @@ function OPSGROUP:_Respawn(Delay, Template, Reset)
|
|||||||
self.isDead=false
|
self.isDead=false
|
||||||
self.isDestroyed=false
|
self.isDestroyed=false
|
||||||
|
|
||||||
|
|
||||||
self.groupinitialized=false
|
self.groupinitialized=false
|
||||||
self.wpcounter=1
|
self.wpcounter=1
|
||||||
self.currentwp=1
|
self.currentwp=1
|
||||||
@ -7802,8 +7804,8 @@ function OPSGROUP:_Respawn(Delay, Template, Reset)
|
|||||||
-- Init waypoints.
|
-- Init waypoints.
|
||||||
self:_InitWaypoints()
|
self:_InitWaypoints()
|
||||||
|
|
||||||
-- Init Group.
|
-- Init Group. This call is delayed because NAVY groups did not like to be initialized just yet (group did not contain any units).
|
||||||
self:_InitGroup(Template)
|
self:_InitGroup(Template, 0.1)
|
||||||
|
|
||||||
-- Reset events.
|
-- Reset events.
|
||||||
--self:ResetEvents()
|
--self:ResetEvents()
|
||||||
@ -7830,24 +7832,6 @@ end
|
|||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
function OPSGROUP:onafterDamaged(From, Event, To)
|
function OPSGROUP:onafterDamaged(From, Event, To)
|
||||||
self:T(self.lid..string.format("Group damaged at t=%.3f", timer.getTime()))
|
self:T(self.lid..string.format("Group damaged at t=%.3f", timer.getTime()))
|
||||||
|
|
||||||
--[[
|
|
||||||
local lifemin=nil
|
|
||||||
for _,_element in pairs(self.elements) do
|
|
||||||
local element=_element --#OPSGROUP.Element
|
|
||||||
if element.status~=OPSGROUP.ElementStatus.DEAD and element.status~=OPSGROUP.ElementStatus.INUTERO then
|
|
||||||
local life, life0=self:GetLifePoints(element)
|
|
||||||
if lifemin==nil or life<lifemin then
|
|
||||||
lifemin=life
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if lifemin and lifemin/self.life<0.5 then
|
|
||||||
self:RTB()
|
|
||||||
end
|
|
||||||
]]
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- On after "Destroyed" event.
|
--- On after "Destroyed" event.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user