mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Merge pull request #2195 from FlightControl-Master/FF/Ops
OPSGROUP v1.0.3
This commit is contained in:
commit
1fbe78b667
@ -68,7 +68,7 @@ ARMYGROUP = {
|
||||
|
||||
--- Army Group version.
|
||||
-- @field #string version
|
||||
ARMYGROUP.version="1.0.1"
|
||||
ARMYGROUP.version="1.0.3"
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- TODO list
|
||||
@ -2049,114 +2049,70 @@ end
|
||||
--- Initialize group parameters. Also initializes waypoints if self.waypoints is nil.
|
||||
-- @param #ARMYGROUP self
|
||||
-- @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
|
||||
function ARMYGROUP:_InitGroup(Template, Delay)
|
||||
|
||||
if Delay and Delay>0 then
|
||||
self:ScheduleOnce(Delay, ARMYGROUP._InitGroup, self, Template, 0)
|
||||
else
|
||||
-- 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 and self.speedMax>3.6 then
|
||||
self.isMobile=true
|
||||
else
|
||||
self.isMobile=false
|
||||
self.speedMax = 0
|
||||
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
|
||||
|
||||
|
||||
-- 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:T(self.lid.."FF Initializing Group")
|
||||
|
||||
|
||||
-- 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
|
||||
if self.speedMax and self.speedMax>3.6 then
|
||||
self.isMobile=true
|
||||
else
|
||||
self.isMobile=false
|
||||
self.speedMax = 0
|
||||
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)
|
||||
if not self.tacanDefault then
|
||||
self:SetDefaultTACAN(nil, nil, nil, nil, true)
|
||||
end
|
||||
if not self.tacan then
|
||||
self.tacan=UTILS.DeepCopy(self.tacanDefault)
|
||||
end
|
||||
|
||||
-- Units of the group.
|
||||
local units=self.group:GetUnits()
|
||||
@ -2177,7 +2133,6 @@ function ARMYGROUP:_InitGroup(Template, Delay)
|
||||
self:_AddElementByName(unitname)
|
||||
end
|
||||
|
||||
|
||||
-- Init done.
|
||||
self.groupinitialized=true
|
||||
end
|
||||
|
||||
@ -217,7 +217,7 @@ FLIGHTGROUP.Players={}
|
||||
|
||||
--- FLIGHTGROUP class version.
|
||||
-- @field #string version
|
||||
FLIGHTGROUP.version="1.0.2"
|
||||
FLIGHTGROUP.version="1.0.3"
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- TODO list
|
||||
@ -3803,114 +3803,124 @@ end
|
||||
--- Initialize group parameters. Also initializes waypoints if self.waypoints is nil.
|
||||
-- @param #FLIGHTGROUP self
|
||||
-- @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
|
||||
function FLIGHTGROUP:_InitGroup(Template)
|
||||
function FLIGHTGROUP:_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
|
||||
|
||||
-- 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
|
||||
if Delay and Delay>0 then
|
||||
self:ScheduleOnce(Delay, FLIGHTGROUP._InitGroup, self, Template, 0)
|
||||
else
|
||||
self.isMobile=false
|
||||
self.speedMax = 0
|
||||
end
|
||||
|
||||
-- Cruise speed limit 380 kts for fixed and 110 knots for rotary wings.
|
||||
local speedCruiseLimit=self.isHelo and UTILS.KnotsToKmph(110) or UTILS.KnotsToKmph(380)
|
||||
|
||||
-- Cruise speed: 70% of max speed but within limit.
|
||||
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)
|
||||
-- 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.callsign.NumberSquad=tonumber(callsign[1])
|
||||
self.callsign.NumberGroup=tonumber(callsign[2])
|
||||
self.callsign.NameSquad=UTILS.GetCallsignName(self.callsign.NumberSquad)
|
||||
|
||||
-- Group object.
|
||||
local group=self.group --Wrapper.Group#GROUP
|
||||
|
||||
-- Helo group.
|
||||
self.isHelo=group:IsHelicopter()
|
||||
|
||||
-- Max speed in km/h.
|
||||
self.speedMax=group:GetSpeedMax()
|
||||
|
||||
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()
|
||||
-- Is group mobile?
|
||||
if self.speedMax and self.speedMax>3.6 then
|
||||
self.isMobile=true
|
||||
else
|
||||
self.isMobile=false
|
||||
self.speedMax = 0
|
||||
end
|
||||
|
||||
-- DCS group.
|
||||
local dcsgroup=Group.getByName(self.groupname)
|
||||
local size0=dcsgroup:getInitialSize()
|
||||
-- Cruise speed limit 380 kts for fixed and 110 knots for rotary wings.
|
||||
local speedCruiseLimit=self.isHelo and UTILS.KnotsToKmph(110) or UTILS.KnotsToKmph(380)
|
||||
|
||||
-- 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())
|
||||
-- Cruise speed: 70% of max speed but within limit.
|
||||
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
|
||||
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.
|
||||
if not self.tacanDefault then
|
||||
self:SetDefaultTACAN(nil, nil, nil, nil, true)
|
||||
end
|
||||
if not self.tacan then
|
||||
self.tacan=UTILS.DeepCopy(self.tacanDefault)
|
||||
end
|
||||
|
||||
-- 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
|
||||
|
||||
-- Init done.
|
||||
self.groupinitialized=true
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
@ -91,7 +91,7 @@ NAVYGROUP = {
|
||||
|
||||
--- NavyGroup version.
|
||||
-- @field #string version
|
||||
NAVYGROUP.version="1.0.2"
|
||||
NAVYGROUP.version="1.0.3"
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- TODO list
|
||||
@ -395,7 +395,7 @@ function NAVYGROUP:New(group)
|
||||
self:HandleEvent(EVENTS.Birth, self.OnEventBirth)
|
||||
self:HandleEvent(EVENTS.Dead, self.OnEventDead)
|
||||
self:HandleEvent(EVENTS.RemoveUnit, self.OnEventRemoveUnit)
|
||||
self:HandleEvent(EVENTS.UnitLost, self.OnEventRemoveUnit)
|
||||
self:HandleEvent(EVENTS.UnitLost, self.OnEventRemoveUnit)
|
||||
|
||||
-- Start the status monitoring.
|
||||
self.timerStatus=TIMER:New(self.Status, self):Start(1, 30)
|
||||
@ -775,7 +775,7 @@ end
|
||||
|
||||
--- Update status.
|
||||
-- @param #NAVYGROUP self
|
||||
function NAVYGROUP:Status(From, Event, To)
|
||||
function NAVYGROUP:Status()
|
||||
|
||||
-- FSM state.
|
||||
local fsmstate=self:GetState()
|
||||
@ -978,6 +978,35 @@ function NAVYGROUP:Status(From, Event, To)
|
||||
|
||||
end
|
||||
|
||||
---
|
||||
-- Elements
|
||||
---
|
||||
|
||||
if self.verbose>=2 then
|
||||
local text="Elements:"
|
||||
for i,_element in pairs(self.elements) do
|
||||
local element=_element --Ops.OpsGroup#OPSGROUP.Element
|
||||
|
||||
local name=element.name
|
||||
local status=element.status
|
||||
local unit=element.unit
|
||||
local life,life0=self:GetLifePoints(element)
|
||||
|
||||
local life0=element.life0
|
||||
|
||||
-- Get ammo.
|
||||
local ammo=self:GetAmmoElement(element)
|
||||
|
||||
-- Output text for element.
|
||||
text=text..string.format("\n[%d] %s: status=%s, life=%.1f/%.1f, guns=%d, rockets=%d, bombs=%d, missiles=%d, cargo=%d/%d kg",
|
||||
i, name, status, life, life0, ammo.Guns, ammo.Rockets, ammo.Bombs, ammo.Missiles, element.weightCargo, element.weightMaxCargo)
|
||||
end
|
||||
if #self.elements==0 then
|
||||
text=text.." none!"
|
||||
end
|
||||
self:I(self.lid..text)
|
||||
end
|
||||
|
||||
---
|
||||
-- Engage Detected Targets
|
||||
---
|
||||
@ -1041,7 +1070,7 @@ function NAVYGROUP:onafterSpawned(From, Event, To)
|
||||
|
||||
-- Debug info.
|
||||
if self.verbose>=1 then
|
||||
local text=string.format("Initialized Navy Group %s:\n", self.groupname)
|
||||
local text=string.format("Initialized Navy Group %s [GID=%d]:\n", self.groupname, self.group:GetID())
|
||||
text=text..string.format("Unit type = %s\n", self.actype)
|
||||
text=text..string.format("Speed max = %.1f Knots\n", UTILS.KmphToKnots(self.speedMax))
|
||||
text=text..string.format("Speed cruise = %.1f Knots\n", UTILS.KmphToKnots(self.speedCruise))
|
||||
@ -1841,81 +1870,96 @@ end
|
||||
--- Initialize group parameters. Also initializes waypoints if self.waypoints is nil.
|
||||
-- @param #NAVYGROUP self
|
||||
-- @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
|
||||
function NAVYGROUP:_InitGroup(Template)
|
||||
function NAVYGROUP:_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()
|
||||
|
||||
-- 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
|
||||
if Delay and Delay>0 then
|
||||
-- Delayed call
|
||||
self:ScheduleOnce(Delay, NAVYGROUP._InitGroup, self, Template, 0)
|
||||
else
|
||||
self.isMobile=false
|
||||
self.speedMax = 0
|
||||
end
|
||||
|
||||
-- Cruise speed: 70% of max speed.
|
||||
self.speedCruise=self.speedMax*0.7
|
||||
-- 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
|
||||
|
||||
-- Group ammo.
|
||||
self.ammo=self:GetAmmoTot()
|
||||
-- Get template of group.
|
||||
local template=Template or self:_GetTemplate()
|
||||
|
||||
-- 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)
|
||||
-- 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
|
||||
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.
|
||||
self.optionDefault.Formation="Off Road"
|
||||
self.option.Formation=self.optionDefault.Formation
|
||||
|
||||
-- Default TACAN off.
|
||||
self:SetDefaultTACAN(nil, nil, nil, nil, true)
|
||||
self.tacan=UTILS.DeepCopy(self.tacanDefault)
|
||||
-- Default TACAN off (we check if something is set already to keep those values in case of respawn)
|
||||
if not self.tacanDefault then
|
||||
self:SetDefaultTACAN(nil, nil, nil, nil, true)
|
||||
end
|
||||
if not self.tacan then
|
||||
self.tacan=UTILS.DeepCopy(self.tacanDefault)
|
||||
end
|
||||
|
||||
-- Default ICLS off.
|
||||
if not self.iclsDefault then
|
||||
self:SetDefaultICLS(nil, nil, nil, true)
|
||||
end
|
||||
if not self.icls then
|
||||
self.icls=UTILS.DeepCopy(self.iclsDefault)
|
||||
end
|
||||
|
||||
-- Get all units of the group.
|
||||
local units=self.group:GetUnits()
|
||||
|
||||
-- Default ICLS off.
|
||||
self:SetDefaultICLS(nil, nil, nil, true)
|
||||
self.icls=UTILS.DeepCopy(self.iclsDefault)
|
||||
|
||||
-- Get all 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:E(self.lid..string.format("ERROR: Got #units=%d but group consists of %d units!", #units, size0))
|
||||
-- DCS group.
|
||||
local dcsgroup=Group.getByName(self.groupname)
|
||||
local size0=dcsgroup:getInitialSize()
|
||||
|
||||
-- Quick check.
|
||||
if #units~=size0 then
|
||||
self:E(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
|
||||
|
||||
-- Add elemets.
|
||||
for _,unit in pairs(units) do
|
||||
self:_AddElementByName(unit:GetName())
|
||||
end
|
||||
|
||||
-- Init done.
|
||||
self.groupinitialized=true
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
@ -512,7 +512,7 @@ OPSGROUP.CargoStatus={
|
||||
|
||||
--- OpsGroup version.
|
||||
-- @field #string version
|
||||
OPSGROUP.version="1.0.1"
|
||||
OPSGROUP.version="1.0.3"
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- TODO list
|
||||
@ -7675,6 +7675,7 @@ function OPSGROUP:Teleport(Coordinate, Delay, NoPauseMission)
|
||||
unit.heading=math.rad(heading)
|
||||
unit.psi=-unit.heading
|
||||
else
|
||||
-- Remove unit from spawn template because it is already dead
|
||||
table.remove(units, i)
|
||||
end
|
||||
end
|
||||
@ -7762,25 +7763,41 @@ function OPSGROUP:_Respawn(Delay, Template, Reset)
|
||||
-- Despawn old group. Dont trigger any remove unit event since this is a respawn.
|
||||
self:Despawn(0, true)
|
||||
|
||||
else
|
||||
|
||||
---
|
||||
-- Group is NOT ALIVE
|
||||
---
|
||||
|
||||
-- Ensure elements in utero.
|
||||
for _,_element in pairs(self.elements) do
|
||||
local element=_element --#OPSGROUP.Element
|
||||
self:ElementInUtero(element)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- Ensure elements in utero.
|
||||
for _,_element in pairs(self.elements) do
|
||||
local element=_element --#OPSGROUP.Element
|
||||
if element and element.status~=OPSGROUP.ElementStatus.DEAD then
|
||||
self:ElementInUtero(element)
|
||||
end
|
||||
end
|
||||
|
||||
-- Spawn with a little delay (especially Navy groups caused problems if they were instantly respawned)
|
||||
self:_Spawn(0.01, Template)
|
||||
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Spawn group from a given template.
|
||||
-- @param #OPSGROUP self
|
||||
-- @param #number Delay Delay in seconds before respawn happens. Default 0.
|
||||
-- @param DCS#Template Template (optional) The template of the Group retrieved with GROUP:GetTemplate(). If the template is not provided, the template will be retrieved of the group itself.
|
||||
-- @return #OPSGROUP self
|
||||
function OPSGROUP:_Spawn(Delay, Template)
|
||||
if Delay and Delay>0 then
|
||||
self:ScheduleOnce(Delay, OPSGROUP._Spawn, self, 0, Template)
|
||||
else
|
||||
-- Debug output.
|
||||
self:T({Template=Template})
|
||||
self:T2({Template=Template})
|
||||
|
||||
-- Spawn new group.
|
||||
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.
|
||||
self.dcsgroup=self:GetDCSGroup()
|
||||
@ -7794,7 +7811,6 @@ function OPSGROUP:_Respawn(Delay, Template, Reset)
|
||||
self.isDead=false
|
||||
self.isDestroyed=false
|
||||
|
||||
|
||||
self.groupinitialized=false
|
||||
self.wpcounter=1
|
||||
self.currentwp=1
|
||||
@ -7802,15 +7818,12 @@ function OPSGROUP:_Respawn(Delay, Template, Reset)
|
||||
-- Init waypoints.
|
||||
self:_InitWaypoints()
|
||||
|
||||
-- Init Group.
|
||||
self:_InitGroup(Template)
|
||||
-- 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, 0.001)
|
||||
|
||||
-- Reset events.
|
||||
--self:ResetEvents()
|
||||
|
||||
--self:ResetEvents()
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- On after "InUtero" event.
|
||||
@ -7830,24 +7843,6 @@ end
|
||||
-- @param #string To To state.
|
||||
function OPSGROUP:onafterDamaged(From, Event, To)
|
||||
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
|
||||
|
||||
--- On after "Destroyed" event.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user