This commit is contained in:
Frank 2020-10-12 00:09:02 +02:00
parent 7792381c36
commit 2ad81ca499
5 changed files with 81 additions and 56 deletions

View File

@ -1273,17 +1273,19 @@ AIRBOSS.AircraftCarrier={
--- Carrier types. --- Carrier types.
-- @type AIRBOSS.CarrierType -- @type AIRBOSS.CarrierType
-- @field #string ROOSEVELT USS Theodore Roosevelt (CVN-71) -- @field #string ROOSEVELT USS Theodore Roosevelt (CVN-71) [Super Carrier Module]
-- @field #string LINCOLN USS Abraham Lincoln (CVN-72) -- @field #string LINCOLN USS Abraham Lincoln (CVN-72) [Super Carrier Module]
-- @field #string WASHINGTON USS George Washington (CVN-73) -- @field #string WASHINGTON USS George Washington (CVN-73) [Super Carrier Module]
-- @field #string STENNIS USS John C. Stennis (CVN-74) -- @field #string STENNIS USS John C. Stennis (CVN-74)
-- @field #string VINSON USS Carl Vinson (CVN-70) -- @field #string TRUMAN USS Harry S. Trueman (CVN-75) [Super Carrier Module]
-- @field #string VINSON USS Carl Vinson (CVN-70) [Obsolete]
-- @field #string TARAWA USS Tarawa (LHA-1) -- @field #string TARAWA USS Tarawa (LHA-1)
-- @field #string KUZNETSOV Admiral Kuznetsov (CV 1143.5) -- @field #string KUZNETSOV Admiral Kuznetsov (CV 1143.5)
AIRBOSS.CarrierType={ AIRBOSS.CarrierType={
ROOSEVELT="CVN_71", ROOSEVELT="CVN_71",
LINCOLN="CVN_72", LINCOLN="CVN_72",
WASHINGTON="CVN_73", WASHINGTON="CVN_73",
TRUMAN="CVN_75",
STENNIS="Stennis", STENNIS="Stennis",
VINSON="VINSON", VINSON="VINSON",
TARAWA="LHA_Tarawa", TARAWA="LHA_Tarawa",

View File

@ -40,7 +40,7 @@ ARMYGROUP = {
--- Army Group version. --- Army Group version.
-- @field #string version -- @field #string version
ARMYGROUP.version="0.1.0" ARMYGROUP.version="0.3.0"
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- TODO list -- TODO list
@ -350,7 +350,7 @@ function ARMYGROUP:onafterSpawned(From, Event, To)
-- Set TACAN to default. -- Set TACAN to default.
self:_SwitchTACAN() self:_SwitchTACAN()
-- Turn on the radio. -- Turn on the radio.
if self.radioDefault then if self.radioDefault then
self:SwitchRadio(self.radioDefault.Freq, self.radioDefault.Modu) self:SwitchRadio(self.radioDefault.Freq, self.radioDefault.Modu)
@ -361,7 +361,7 @@ function ARMYGROUP:onafterSpawned(From, Event, To)
end end
-- Update route. -- Update route.
self:Cruise() self:Cruise(nil, self.option.Formation or self.optionDefault.Formation)
end end
@ -394,7 +394,10 @@ function ARMYGROUP:onafterUpdateRoute(From, Event, To, n, Speed, Formation)
if Speed then if Speed then
wp.speed=UTILS.KnotsToMps(Speed) wp.speed=UTILS.KnotsToMps(Speed)
else else
-- Take default waypoint speed. -- Take default waypoint speed. But make sure speed>0 if patrol ad infinitum.
if self.adinfinitum and wp.speed<0.1 then
wp.speed=UTILS.KmphToMps(self.speedCruise)
end
end end
-- Formation. -- Formation.
@ -425,10 +428,15 @@ function ARMYGROUP:onafterUpdateRoute(From, Event, To, n, Speed, Formation)
-- Add waypoint. -- Add waypoint.
table.insert(waypoints, wp) table.insert(waypoints, wp)
-- Apply formation at the current position or it will only be changed when reaching the next waypoint.
local formation=ENUMS.Formation.Vehicle.OffRoad
if wp.action~=ENUMS.Formation.Vehicle.OnRoad then
formation=wp.action
end
-- Current point. -- Current point.
local current=self:GetCoordinate():WaypointGround(UTILS.MpsToKmph(self.speedWp), ENUMS.Formation.Vehicle.OffRoad) local current=self:GetCoordinate():WaypointGround(UTILS.MpsToKmph(self.speedWp), formation)
table.insert(waypoints, 1, current) table.insert(waypoints, 1, current)
-- Insert a point on road. -- Insert a point on road.
@ -442,32 +450,31 @@ function ARMYGROUP:onafterUpdateRoute(From, Event, To, n, Speed, Formation)
for i,_wp in pairs(waypoints) do for i,_wp in pairs(waypoints) do
local wp=_wp local wp=_wp
local text=string.format("WP #%d UID=%d type=%s: Speed=%d m/s, alt=%d m, Action=%s", i, wp.uid and wp.uid or 0, wp.type, wp.speed, wp.alt, wp.action) local text=string.format("WP #%d UID=%d type=%s: Speed=%d m/s, alt=%d m, Action=%s", i, wp.uid and wp.uid or 0, wp.type, wp.speed, wp.alt, wp.action)
self:I(text) self:T(text)
if wp.coordinate then if false and wp.coordinate then
wp.coordinate:MarkToAll(text) wp.coordinate:MarkToAll(text)
end end
end end
end end
if not self.passedfinalwp then
if #waypoints>=2 then
-- Debug info. -- Debug info.
self:T(self.lid..string.format("Updateing route: WP %d-->%d-->%d (#%d), Speed=%.1f knots, Formation=%s", self:T(self.lid..string.format("Updateing route: WP %d-->%d (%d/%d), Speed=%.1f knots, Formation=%s",
self.currentwp, n, #self.waypoints, #waypoints-2, UTILS.MpsToKnots(self.speedWp), tostring(self.option.Formation))) self.currentwp, n, #waypoints, #self.waypoints, UTILS.MpsToKnots(self.speedWp), tostring(self.option.Formation)))
-- Route group to all defined waypoints remaining. -- Route group to all defined waypoints remaining.
self:Route(waypoints) self:Route(waypoints)
else else
--- ---
-- No waypoints left -- Passed final WP ==> Full Stop
--- ---
self:E(self.lid..string.format("WARNING: No waypoints left ==> Full Stop!")) self:E(self.lid..string.format("WARNING: Passed final WP ==> Full Stop!"))
self:FullStop() self:FullStop()
end end
end end
@ -746,8 +753,7 @@ function ARMYGROUP:_InitGroup()
self:SetDefaultRadio(self.radio.Freq, self.radio.Modu, self.radio.On) self:SetDefaultRadio(self.radio.Freq, self.radio.Modu, self.radio.On)
-- Set default formation from first waypoint. -- Set default formation from first waypoint.
self.option.Formation=self:GetWaypoint(1).action self.optionDefault.Formation=self:GetWaypoint(1).action
self.optionDefault.Formation=self.option.Formation
-- Default TACAN off. -- Default TACAN off.
self:SetDefaultTACAN(nil, nil, nil, nil, true) self:SetDefaultTACAN(nil, nil, nil, nil, true)
@ -815,10 +821,11 @@ end
-- @param #ARMYGROUP self -- @param #ARMYGROUP self
-- @param #number Formation New formation the group will fly in. Default is the setting of `SetDefaultFormation()`. -- @param #number Formation New formation the group will fly in. Default is the setting of `SetDefaultFormation()`.
-- @param #boolean Permanently If true, formation always used from now on. -- @param #boolean Permanently If true, formation always used from now on.
-- @param #boolean NoRouteUpdate If true, route is not updated.
-- @return #ARMYGROUP self -- @return #ARMYGROUP self
function ARMYGROUP:SwitchFormation(Formation, Permanently) function ARMYGROUP:SwitchFormation(Formation, Permanently, NoRouteUpdate)
if self:IsAlive() then if self:IsAlive() or self:IsInUtero() then
Formation=Formation or self.optionDefault.Formation Formation=Formation or self.optionDefault.Formation
@ -831,11 +838,20 @@ function ARMYGROUP:SwitchFormation(Formation, Permanently)
-- Set current formation. -- Set current formation.
self.option.Formation=Formation self.option.Formation=Formation
-- Update route with the new formation. if self:IsInUtero() then
self:__UpdateRoute(-1, nil, nil, Formation) self:T(self.lid..string.format("Will switch formation to %s (permanently=%s) when group is spawned", self.option.Formation, tostring(Permanently)))
else
-- Debug info. -- Update route with the new formation.
self:T(self.lid..string.format("Switching formation to %s (permanently=%s)", self.option.Formation, tostring(Permanently))) if NoRouteUpdate then
else
self:__UpdateRoute(-1, nil, nil, Formation)
end
-- Debug info.
self:T(self.lid..string.format("Switching formation to %s (permanently=%s)", self.option.Formation, tostring(Permanently)))
end
end end

View File

@ -1166,6 +1166,8 @@ function AUFTRAG:NewARTY(Target, Nshots, Radius)
mission.artyShots=Nshots or 3 mission.artyShots=Nshots or 3
mission.artyRadius=Radius or 100 mission.artyRadius=Radius or 100
mission.engageWeaponType=ENUMS.WeaponFlag.Auto
mission.optionROE=ENUMS.ROE.OpenFire -- Ground/naval need open fire! mission.optionROE=ENUMS.ROE.OpenFire -- Ground/naval need open fire!
mission.optionAlarm=0 mission.optionAlarm=0

View File

@ -241,14 +241,15 @@ end
-- @param #number Nshots Number of shots to fire. Default 3. -- @param #number Nshots Number of shots to fire. Default 3.
-- @param #number WeaponType Type of weapon. Default auto. -- @param #number WeaponType Type of weapon. Default auto.
-- @param #number Prio Priority of the task. -- @param #number Prio Priority of the task.
-- @param #number Duration Duration in seconds after which the task is cancelled. Default *never*.
-- @return Ops.OpsGroup#OPSGROUP.Task The task table. -- @return Ops.OpsGroup#OPSGROUP.Task The task table.
function NAVYGROUP:AddTaskWaypointFireAtPoint(Coordinate, Waypoint, Radius, Nshots, WeaponType, Prio) function NAVYGROUP:AddTaskWaypointFireAtPoint(Coordinate, Waypoint, Radius, Nshots, WeaponType, Prio, Duration)
Waypoint=Waypoint or self:GetWaypointNext() Waypoint=Waypoint or self:GetWaypointNext()
local DCStask=CONTROLLABLE.TaskFireAtPoint(nil, Coordinate:GetVec2(), Radius, Nshots, WeaponType) local DCStask=CONTROLLABLE.TaskFireAtPoint(nil, Coordinate:GetVec2(), Radius, Nshots, WeaponType)
local task=self:AddTaskWaypoint(DCStask, Waypoint, nil, Prio) local task=self:AddTaskWaypoint(DCStask, Waypoint, nil, Prio, Duration)
return task return task
end end
@ -608,9 +609,6 @@ function NAVYGROUP:onafterUpdateRoute(From, Event, To, n, Speed, Depth)
-- Update route from this waypoint number onwards. -- Update route from this waypoint number onwards.
n=n or self:GetWaypointIndexNext() n=n or self:GetWaypointIndexNext()
-- Debug info.
self:T(self.lid..string.format("Update route n=%d", n))
-- Update waypoint tasks, i.e. inject WP tasks into waypoint table. -- Update waypoint tasks, i.e. inject WP tasks into waypoint table.
self:_UpdateWaypointTasks(n) self:_UpdateWaypointTasks(n)
@ -650,11 +648,10 @@ function NAVYGROUP:onafterUpdateRoute(From, Event, To, n, Speed, Depth)
table.insert(waypoints, 1, current) table.insert(waypoints, 1, current)
if #waypoints>1 then if not self.passedfinalwp then
self:T(self.lid..string.format("Updateing route: WP %d-->%d-->%d (#%d), Speed=%.1f knots, Depth=%d m",
self.currentwp, n, #self.waypoints, #waypoints-1, UTILS.MpsToKnots(self.speedWp), wp.alt))
-- Debug info.
self:T(self.lid..string.format("Updateing route: WP %d-->%d (%d/%d), Speed=%.1f knots, Depth=%d m", self.currentwp, n, #waypoints, #self.waypoints, UTILS.MpsToKnots(self.speedWp), wp.alt))
-- Route group to all defined waypoints remaining. -- Route group to all defined waypoints remaining.
self:Route(waypoints) self:Route(waypoints)
@ -662,10 +659,10 @@ function NAVYGROUP:onafterUpdateRoute(From, Event, To, n, Speed, Depth)
else else
--- ---
-- No waypoints left ==> Full Stop -- Passed final WP ==> Full Stop
--- ---
self:E(self.lid..string.format("WARNING: No waypoints left ==> Full Stop!")) self:E(self.lid..string.format("WARNING: Passed final WP ==> Full Stop!"))
self:FullStop() self:FullStop()
end end

View File

@ -479,11 +479,11 @@ function OPSGROUP:AddCheckZone(CheckZone)
end end
--- Add a zone that triggers and event if the group enters or leaves any of the zones. --- Add a weapon range for ARTY auftrag.
-- @param #OPSGROUP self -- @param #OPSGROUP self
-- @param #number RangeMin -- @param #number RangeMin Minimum range in kilometers. Default 0 km.
-- @param #number RangeMax -- @param #number RangeMax Maximum range in kilometers. Default 10 km.
-- @param #number BitType -- @param #number BitType Bit mask of weapon type for which the given min/max ranges apply. Default is `ENUMS.WeaponFlag.Auto`, i.e. for all weapon types.
-- @return #OPSGROUP self -- @return #OPSGROUP self
function OPSGROUP:AddWeaponRange(RangeMin, RangeMax, BitType) function OPSGROUP:AddWeaponRange(RangeMin, RangeMax, BitType)
@ -2565,9 +2565,14 @@ function OPSGROUP:RouteToMission(mission, delay)
end end
end end
local formation=nil
if self.isGround and mission.optionFormation then
formation=mission.optionFormation
end
-- Add waypoint. -- Add waypoint.
local waypoint=self:AddWaypoint(waypointcoord, SpeedToMission, nil, nil, false) local waypoint=self:AddWaypoint(waypointcoord, SpeedToMission, nil, formation, false)
-- Add waypoint task. UpdateRoute is called inside. -- Add waypoint task. UpdateRoute is called inside.
local waypointtask=self:AddTaskWaypoint(mission.DCStask, waypoint, mission.name, mission.prio, mission.duration) local waypointtask=self:AddTaskWaypoint(mission.DCStask, waypoint, mission.name, mission.prio, mission.duration)
@ -2595,7 +2600,7 @@ function OPSGROUP:RouteToMission(mission, delay)
self:SwitchAlarmstate(mission.optionAlarm) self:SwitchAlarmstate(mission.optionAlarm)
end end
-- Formation -- Formation
if mission.optionFormation then if mission.optionFormation and self.isAircraft then
self:SwitchFormation(mission.optionFormation) self:SwitchFormation(mission.optionFormation)
end end
-- Radio frequency and modulation. -- Radio frequency and modulation.
@ -2697,8 +2702,10 @@ function OPSGROUP:onafterPassingWaypoint(From, Event, To, Waypoint)
-- Final waypoint reached? -- Final waypoint reached?
if wpindex==nil or wpindex==#self.waypoints then if wpindex==nil or wpindex==#self.waypoints then
-- Set switch to true. -- Set switch to true.
self.passedfinalwp=true if not self.adinfinitum or #self.waypoints<=1 then
self.passedfinalwp=true
end
end end
@ -2711,7 +2718,7 @@ function OPSGROUP:onafterPassingWaypoint(From, Event, To, Waypoint)
-- Debug info. -- Debug info.
local text=string.format("Group passed waypoint %s/%d ID=%d: final=%s detour=%s astar=%s", local text=string.format("Group passed waypoint %s/%d ID=%d: final=%s detour=%s astar=%s",
tostring(wpindex), #self.waypoints, Waypoint.uid, tostring(self.passedfinalwp), tostring(Waypoint.detour), tostring(Waypoint.astar)) tostring(wpindex), #self.waypoints, Waypoint.uid, tostring(self.passedfinalwp), tostring(Waypoint.detour), tostring(Waypoint.astar))
self:I(self.lid..text) self:T(self.lid..text)
end end
@ -3091,7 +3098,7 @@ function OPSGROUP:_CheckGroupDone(delay)
-- We only want to update the route if there are no more tasks to be done. -- We only want to update the route if there are no more tasks to be done.
if ntasks>0 then if ntasks>0 then
self:T(self.lid..string.format("Still got %d tasks for the current waypoint UID=%d", ntasks, waypoint.uid)) self:T(self.lid..string.format("Still got %d tasks for the current waypoint UID=%d ==> RETURN (no action)", ntasks, waypoint.uid))
return return
end end
end end
@ -3135,7 +3142,7 @@ function OPSGROUP:_CheckGroupDone(delay)
-- No further waypoints. Command a full stop. -- No further waypoints. Command a full stop.
self:__FullStop(-1) self:__FullStop(-1)
self:T(self.lid..string.format("Passed final WP, #WP>1, adinfinitum=FALSE ==> Full Stop")) self:T(self.lid..string.format("Passed final WP, adinfinitum=FALSE ==> Full Stop"))
else else
@ -3295,17 +3302,18 @@ function OPSGROUP:InitWaypoints()
self.waypoints={} self.waypoints={}
for index,wp in pairs(self.waypoints0) do for index,wp in pairs(self.waypoints0) do
--local waypoint=self:_CreateWaypoint(wp) -- Coordinate of the waypoint.
--self:_AddWaypoint(waypoint)
local coordinate=COORDINATE:New(wp.x, wp.alt, wp.y) local coordinate=COORDINATE:New(wp.x, wp.alt, wp.y)
-- Speed at the waypoint.
local speedknots=UTILS.MpsToKnots(wp.speed) local speedknots=UTILS.MpsToKnots(wp.speed)
if index==1 then if index==1 then
self.speedWp=wp.speed self.speedWp=wp.speed
end end
-- Add waypoint.
self:AddWaypoint(coordinate, speedknots, index-1, nil, false) self:AddWaypoint(coordinate, speedknots, index-1, nil, false)
end end