Merge branch 'develop' into FF/OpsDev

This commit is contained in:
Frank
2024-06-27 21:31:24 +02:00
10 changed files with 310 additions and 131 deletions

View File

@@ -3898,18 +3898,9 @@ function FLIGHTGROUP:_InitGroup(Template)
-- Group object.
local group=self.group --Wrapper.Group#GROUP
-- Get template of group.
local template=Template or self:_GetTemplate()
-- Helo group.
self.isHelo=group:IsHelicopter()
-- Is (template) group uncontrolled.
self.isUncontrolled=template.uncontrolled
-- Is (template) group late activated.
self.isLateActivated=template.lateActivation
-- Max speed in km/h.
self.speedMax=group:GetSpeedMax()
@@ -3929,25 +3920,38 @@ function FLIGHTGROUP:_InitGroup(Template)
-- 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 user.
self.radio.Freq=tonumber(template.frequency)
self.radio.Modu=tonumber(template.modulation)
self.radio.On=template.communication
-- Is (template) group uncontrolled.
self.isUncontrolled=template~=nil and template.uncontrolled or false
-- 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)
-- 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
self.callsign.NumberSquad=tonumber(callsign[1])
self.callsign.NumberGroup=tonumber(callsign[2])
self.callsign.NameSquad=UTILS.GetCallsignName(self.callsign.NumberSquad)
-- Set default formation.
if self.isHelo then

View File

@@ -11378,11 +11378,19 @@ end
-- @return #OPSGROUP self
function OPSGROUP:_InitWaypoints(WpIndexMin, WpIndexMax)
-- Template waypoints.
self.waypoints0=UTILS.DeepCopy(_DATABASE:GetGroupTemplate(self.groupname).route.points) --self.group:GetTemplateRoutePoints()
-- Waypoints empty!
self.waypoints={}
self.waypoints0={}
-- Get group template
local template=_DATABASE:GetGroupTemplate(self.groupname)
if template==nil then
return self
end
-- Template waypoints.
self.waypoints0=UTILS.DeepCopy(template.route.points) --self.group:GetTemplateRoutePoints()
WpIndexMin=WpIndexMin or 1
WpIndexMax=WpIndexMax or #self.waypoints0
@@ -13641,11 +13649,7 @@ function OPSGROUP:_AddElementByName(unitname)
local unit=UNIT:FindByName(unitname)
if unit then
-- Get unit template.
local unittemplate=unit:GetTemplate()
--local unittemplate=_DATABASE:GetUnitTemplateFromUnitName(unitname)
-- Element table.
local element=self:GetElementByName(unitname)
@@ -13672,8 +13676,18 @@ function OPSGROUP:_AddElementByName(unitname)
element.Nhit=0
element.opsgroup=self
-- Get unit template.
local unittemplate=unit:GetTemplate()
if unittemplate==nil then
if element.DCSunit:getPlayerName() then
element.skill="Client"
end
else
element.skill=unittemplate~=nil and unittemplate.skill or "Unknown"
end
-- Skill etc.
element.skill=unittemplate.skill or "Unknown"
if element.skill=="Client" or element.skill=="Player" then
element.ai=false
element.client=CLIENT:FindByName(unitname)
@@ -13732,24 +13746,22 @@ function OPSGROUP:_AddElementByName(unitname)
element.weightCargo=0
end
element.weight=element.weightEmpty+element.weightCargo
-- FLIGHTGROUP specific.
if self.isFlightgroup then
element.callsign=element.unit:GetCallsign()
element.callsign=element.unit:GetCallsign()
element.fuelmass=element.fuelmass0 or 99999
element.fuelrel=element.unit:GetFuel() or 1
if self.isFlightgroup and unittemplate then
element.modex=unittemplate.onboard_num
element.payload=unittemplate.payload
element.pylons=unittemplate.payload and unittemplate.payload.pylons or nil
element.fuelmass0=unittemplate.payload and unittemplate.payload.fuel or 0
element.fuelmass=element.fuelmass0
element.fuelrel=element.unit:GetFuel()
else
element.callsign="Peter-1-1"
element.modex="000"
element.payload={}
element.pylons={}
element.fuelmass0=99999
element.fuelmass =99999
element.fuelrel=1
end
-- Debug text.

View File

@@ -604,6 +604,14 @@ function OPSZONE:GetAttackDuration()
return nil
end
--- Find an OPSZONE using the Zone Name.
-- @param #OPSZONE self
-- @param #string ZoneName The zone name.
-- @return #OPSZONE The OPSZONE or nil if not found.
function OPSZONE:FindByName( ZoneName )
local Found = _DATABASE:FindOpsZone( ZoneName )
return Found
end
--- Check if the red coalition is currently owning the zone.
-- @param #OPSZONE self