Merge branch 'develop' into FF/Ops

This commit is contained in:
Frank 2022-03-26 22:38:20 +01:00
commit e1a4d5497a
8 changed files with 140 additions and 14 deletions

View File

@ -912,7 +912,7 @@ do -- COORDINATE
-- The text will reflect the temperature like this:
--
-- - For Russian and European aircraft using the metric system - Degrees Celcius (°C)
-- - For American aircraft we link to the imperial system - Degrees Farenheit (°F)
-- - For American aircraft we link to the imperial system - Degrees Fahrenheit (°F)
--
-- A text containing a pressure will look like this:
--
@ -932,7 +932,7 @@ do -- COORDINATE
if Settings:IsMetric() then
return string.format( " %-2.2f °C", DegreesCelcius )
else
return string.format( " %-2.2f °F", UTILS.CelciusToFarenheit( DegreesCelcius ) )
return string.format( " %-2.2f °F", UTILS.CelsiusToFahrenheit( DegreesCelcius ) )
end
else
return " no temperature"

View File

@ -742,7 +742,7 @@ function PSEUDOATC:ReportWeather(GID, UID, position, location)
local T=position:GetTemperature()
-- Correct unit system.
local _T=string.format('%d°F', UTILS.CelciusToFarenheit(T))
local _T=string.format('%d°F', UTILS.CelsiusToFahrenheit(T))
if settings:IsMetric() then
_T=string.format('%d°C', T)
end

View File

@ -2762,7 +2762,7 @@ function RANGE:_DisplayRangeWeather(_unitname)
local tW=string.format("%.1f m/s", Ws)
local tP=string.format("%.1f mmHg", P*hPa2mmHg)
if settings:IsImperial() then
--tT=string.format("%d°F", UTILS.CelciusToFarenheit(T))
--tT=string.format("%d°F", UTILS.CelsiusToFahrenheit(T))
tW=string.format("%.1f knots", UTILS.MpsToKnots(Ws))
tP=string.format("%.2f inHg", P*hPa2inHg)
end

View File

@ -1459,8 +1459,8 @@ function ATIS:onafterBroadcast(From, Event, To)
-- Convert to °F.
if self.TDegF then
temperature=UTILS.CelciusToFarenheit(temperature)
dewpoint=UTILS.CelciusToFarenheit(dewpoint)
temperature=UTILS.CelsiusToFahrenheit(temperature)
dewpoint=UTILS.CelsiusToFahrenheit(dewpoint)
end
local TEMPERATURE=string.format("%d", math.abs(temperature))

View File

@ -418,6 +418,7 @@ AUFTRAG.Type={
BARRAGE="Barrage",
ARMORATTACK="Armor Attack",
CASENHANCED="CAS Enhanced",
HOVER="Hover",
}
--- Mission status of an assigned group.
@ -440,6 +441,7 @@ AUFTRAG.SpecialTask={
ARMOREDGUARD="ArmoredGuard",
BARRAGE="Barrage",
ARMORATTACK="AmorAttack",
HOVER="Hover",
}
--- Mission status.
@ -560,7 +562,7 @@ AUFTRAG.Category={
--- AUFTRAG class version.
-- @field #string version
AUFTRAG.version="0.8.4"
AUFTRAG.version="0.8.5"
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- TODO list
@ -913,6 +915,44 @@ function AUFTRAG:NewANTISHIP(Target, Altitude)
return mission
end
--- **[AIR/HELICOPTER]** Create an HOVER mission.
-- @param #AUFTRAG self
-- @param Core.Point#COORDINATE Coordinate Where to hover.
-- @param #number Altitude Hover altitude in feet AGL. Default is 50 feet above ground.
-- @param #number Time Time in seconds to hold the hover. Default 300 seconds.
-- @param #number Speed Speed in knots to fly to the target coordinate. Default 150kn.
-- @param #number MissionAlt Altitide to fly towards the mission in feet AGL. Default 1000ft.
-- @return #AUFTRAG self
function AUFTRAG:NewHOVER(Coordinate, Altitude, Time, Speed, MissionAlt)
local mission=AUFTRAG:New(AUFTRAG.Type.HOVER)
-- Altitude.
if Altitude then
mission.hoverAltitude=Coordinate:GetLandHeight()+UTILS.FeetToMeters(Altitude)
else
mission.hoverAltitude=Coordinate:GetLandHeight()+UTILS.FeetToMeters(50)
end
mission:_TargetFromObject(Coordinate)
mission.hoverSpeed = 0.1 -- the DCS Task itself will shortly be build with this so MPS
mission.hoverTime = Time or 300
mission.missionSpeed = UTILS.KnotsToMps(Speed or 150)
-- Mission options:
mission.missionAltitude=mission.MissionAlt or UTILS.FeetToMeters(1000)
mission.missionFraction=0.9
mission.optionROE=ENUMS.ROE.ReturnFire
mission.optionROT=ENUMS.ROT.PassiveDefense
mission.categories={AUFTRAG.Category.AIRCRAFT}
mission.DCStask=mission:GetDCSMissionTask()
return mission
end
--- **[AIR]** Create an ORBIT mission, which can be either a circular orbit or a race-track pattern.
-- @param #AUFTRAG self
-- @param Core.Point#COORDINATE Coordinate Where to orbit.
@ -5111,6 +5151,39 @@ function AUFTRAG:GetDCSMissionTask(TaskControllable)
table.insert(DCStasks, DCStask)
elseif self.type==AUFTRAG.Type.HOVER then
---------------------
-- HOVER Mission --
---------------------
local DCStask={}
DCStask.id=AUFTRAG.SpecialTask.HOVER
local param={}
param.hoverAltitude=self.hoverAltitude
param.hoverTime = self.hoverTime
param.missionSpeed = self.missionSpeed
param.missionAltitude = self.missionAltitude
DCStask.params=param
--[[ Task script.
local DCSScript = {}
local altitude = self.hoverAltitude
DCSScript[#DCSScript+1] = 'local group = ...'
DCSScript[#DCSScript+1] = 'local helo = GROUP:Find(group)'
DCSScript[#DCSScript+1] = 'helo:SetSpeed(0.1,true)'
DCSScript[#DCSScript+1] = string.format('helo:SetAltitude(UTILS.FeetToMeters(%d),true,"BARO")',altitude) -- Call the function, e.g. myfunction.(warehouse,mygroup)
-- Create task.
local DCSTask=CONTROLLABLE.TaskWrappedAction(self, CONTROLLABLE.CommandDoScript(self, table.concat(DCSScript)))
--]]
table.insert(DCStasks, DCStask)
elseif self.type==AUFTRAG.Type.ONGUARD or self.type==AUFTRAG.Type.ARMOREDGUARD then
----------------------
@ -5248,6 +5321,8 @@ function AUFTRAG:GetMissionTaskforMissionType(MissionType)
mtask=ENUMS.MissionTask.TRANSPORT
elseif MissionType==AUFTRAG.Type.ARMORATTACK then
mtask=ENUMS.MissionTask.NOTHING
elseif MissionType==AUFTRAG.Type.HOVER then
mtask=ENUMS.MissionTask.NOTHING
end
return mtask

View File

@ -1902,6 +1902,9 @@ function FLIGHTGROUP:onbeforeUpdateRoute(From, Event, To, n, N)
elseif task.dcstask.id=="ReconMission" then
-- For recon missions, we need to allow the update as we insert new waypoints.
self:T2(self.lid.."Allowing update route for Task: ReconMission")
elseif task.dcstask.id=="Hover" then
-- For recon missions, we need to allow the update as we insert new waypoints.
self:T2(self.lid.."Allowing update route for Task: Hover")
elseif task.description and task.description=="Task_Land_At" then
-- We allow this
self:T2(self.lid.."Allowing update route for Task: Task_Land_At")

View File

@ -697,6 +697,8 @@ function OPSGROUP:New(group)
self:AddTransition("*", "TransportCancel", "*") -- Cancel (current) transport.
self:AddTransition("*", "HoverStart", "*") -- Helo group is hovering
self:AddTransition("*", "HoverEnd", "*") -- Helo group is flying on
------------------------
--- Pseudo Functions ---
------------------------
@ -798,6 +800,19 @@ function OPSGROUP:New(group)
-- @param #string To To state.
-- @param Ops.Auftrag#AUFTRAG Mission The mission.
--- On after "HoverStart" event.
-- @function [parent=#OPSGROUP] OnAfterHoverStart
-- @param #OPSGROUP self
-- @param #string From From state.
-- @param #string Event Event.
-- @param #string To To state.
--- On after "HoverEnd" event.
-- @function [parent=#OPSGROUP] OnAfterHoverEnd
-- @param #OPSGROUP self
-- @param #string From From state.
-- @param #string Event Event.
-- @param #string To To state.
--- Triggers the FSM event "TransportCancel".
-- @function [parent=#OPSGROUP] TransportCancel
@ -3542,11 +3557,11 @@ end
-- @param #string To To state.
-- @param Ops.OpsGroup#OPSGROUP.Task Task The task.
function OPSGROUP:onafterTaskExecute(From, Event, To, Task)
self:T({Task})
-- Debug message.
local text=string.format("Task %s ID=%d execute", tostring(Task.description), Task.id)
self:T(self.lid..text)
self:T({Task})
-- Cancel current task if there is any.
if self.taskcurrent>0 then
self:TaskCancel()
@ -3703,6 +3718,34 @@ function OPSGROUP:onafterTaskExecute(From, Event, To, Task)
-- FLIGHTGROUP not implemented (intended!) for this AUFTRAG type.
end
---
-- Task "Hover" Mission.
---
elseif Task.dcstask.id==AUFTRAG.SpecialTask.HOVER then
if self.isFlightgroup then
self:T("We are Special Auftrag HOVER, hovering now ...")
--self:I({Task.dcstask.params})
local alt = Task.dcstask.params.hoverAltitude
local time =Task.dcstask.params.hoverTime
local Speed=UTILS.MpsToKnots(Task.dcstask.params.missionSpeed) or UTILS.KmphToKnots(self.speedCruise)
local CruiseAlt = UTILS.FeetToMeters(Task.dcstask.params.missionAltitude)
local helo = self:GetGroup()
helo:SetSpeed(0.01,true)
helo:SetAltitude(alt,true,"BARO")
self:HoverStart()
local function FlyOn(Helo,Speed,CruiseAlt,Task)
if Helo then
Helo:SetSpeed(Speed,true)
Helo:SetAltitude(CruiseAlt,true,"BARO")
self:T("We are Special Auftrag HOVER, end of hovering now ...")
self:TaskDone(Task)
self:HoverEnd()
end
end
local timer = TIMER:New(FlyOn,helo,Speed,CruiseAlt,Task)
timer:Start(time)
end
else
-- If task is scheduled (not waypoint) set task.
@ -4591,6 +4634,11 @@ function OPSGROUP:RouteToMission(mission, delay)
waypointcoord=mission:GetMissionWaypointCoord(self.group, randomradius, surfacetypes)
end
if mission.type==AUFTRAG.Type.HOVER then
local zone=mission.engageTarget:GetObject() --Core.Zone#ZONE
waypointcoord=zone:GetCoordinate()
end
local armorwaypointcoord = nil
if mission.type==AUFTRAG.Type.ARMORATTACK then
local target=mission.engageTarget:GetObject() -- Wrapper.Positionable#POSITIONABLE

View File

@ -473,10 +473,10 @@ UTILS.KnotsToMps = function( knots )
end
end
--- Convert temperature from Celsius to Farenheit.
--- Convert temperature from Celsius to Fahrenheit.
-- @param #number Celcius Temperature in degrees Celsius.
-- @return #number Temperature in degrees Farenheit.
UTILS.CelciusToFarenheit = function( Celcius )
-- @return #number Temperature in degrees Fahrenheit.
UTILS.CelsiusToFahrenheit = function( Celcius )
return Celcius * 9/5 + 32
end