mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
CONTROLLABLE:PatrolRouteRandom fix for Subs (#1536)
* CONTROLLABLE:PatrolRouteRandom fix for Subs fixes issue #1535 * Update Controllable.lua * Update Controllable.lua
This commit is contained in:
parent
41b01a508d
commit
47d814e409
@ -175,10 +175,7 @@
|
|||||||
-- * @{#CONTROLLABLE.OptionKeepWeaponsOnThreat}
|
-- * @{#CONTROLLABLE.OptionKeepWeaponsOnThreat}
|
||||||
--
|
--
|
||||||
-- ## 5.5) Air-2-Air missile attack range:
|
-- ## 5.5) Air-2-Air missile attack range:
|
||||||
-- * @{#CONTROLLABLE.OptionAAAttackRange}(): Defines the usage of A2A missiles against possible targets.
|
-- * @{#CONTROLLABLE.OptionAAAttackRange}(): Defines the usage of A2A missiles against possible targets .
|
||||||
--
|
|
||||||
-- ## 5.6) GROUND units attack range:
|
|
||||||
-- * @{#CONTROLLABLE.OptionEngageRange}(): Engage range limit in percent (a number between 0 and 100). Default 100. Defines the range at which a GROUND unit/group (e.g. a SAM site) is allowed to use its weapons automatically.
|
|
||||||
--
|
--
|
||||||
-- @field #CONTROLLABLE
|
-- @field #CONTROLLABLE
|
||||||
CONTROLLABLE = {
|
CONTROLLABLE = {
|
||||||
@ -1482,6 +1479,7 @@ end
|
|||||||
--- (AIR + GROUND) The task makes the controllable/unit a FAC and orders the FAC to control the target (enemy ground controllable) destruction.
|
--- (AIR + GROUND) The task makes the controllable/unit a FAC and orders the FAC to control the target (enemy ground controllable) destruction.
|
||||||
-- The killer is player-controlled allied CAS-aircraft that is in contact with the FAC.
|
-- The killer is player-controlled allied CAS-aircraft that is in contact with the FAC.
|
||||||
-- If the task is assigned to the controllable lead unit will be a FAC.
|
-- If the task is assigned to the controllable lead unit will be a FAC.
|
||||||
|
-- It's important to note that depending on the type of unit that is being assigned the task (AIR or GROUND), you must choose the correct type of callsign enumerator. For airborne controllables use CALLSIGN.Aircraft and for ground based use CALLSIGN.JTAC enumerators.
|
||||||
-- @param #CONTROLLABLE self
|
-- @param #CONTROLLABLE self
|
||||||
-- @param Wrapper.Group#GROUP AttackGroup Target GROUP object.
|
-- @param Wrapper.Group#GROUP AttackGroup Target GROUP object.
|
||||||
-- @param #number WeaponType Bitmask of weapon types, which are allowed to use.
|
-- @param #number WeaponType Bitmask of weapon types, which are allowed to use.
|
||||||
@ -1489,7 +1487,7 @@ end
|
|||||||
-- @param #boolean Datalink (Optional) Allows to use datalink to send the target information to attack aircraft. Enabled by default.
|
-- @param #boolean Datalink (Optional) Allows to use datalink to send the target information to attack aircraft. Enabled by default.
|
||||||
-- @param #number Frequency Frequency in MHz used to communicate with the FAC. Default 133 MHz.
|
-- @param #number Frequency Frequency in MHz used to communicate with the FAC. Default 133 MHz.
|
||||||
-- @param #number Modulation Modulation of radio for communication. Default 0=AM.
|
-- @param #number Modulation Modulation of radio for communication. Default 0=AM.
|
||||||
-- @param #number CallsignName Callsign enumerator name of the FAC.
|
-- @param #number CallsignName Callsign enumerator name of the FAC. (CALLSIGN.Aircraft.{name} for airborne controllables, CALLSIGN.JTACS.{name} for ground units)
|
||||||
-- @param #number CallsignNumber Callsign number, e.g. Axeman-**1**.
|
-- @param #number CallsignNumber Callsign number, e.g. Axeman-**1**.
|
||||||
-- @return DCS#Task The DCS task structure.
|
-- @return DCS#Task The DCS task structure.
|
||||||
function CONTROLLABLE:TaskFAC_AttackGroup( AttackGroup, WeaponType, Designation, Datalink, Frequency, Modulation, CallsignName, CallsignNumber )
|
function CONTROLLABLE:TaskFAC_AttackGroup( AttackGroup, WeaponType, Designation, Datalink, Frequency, Modulation, CallsignName, CallsignNumber )
|
||||||
@ -1853,7 +1851,26 @@ do -- Patrol methods
|
|||||||
|
|
||||||
-- Calculate the new Route.
|
-- Calculate the new Route.
|
||||||
local FromCoord = PatrolGroup:GetCoordinate()
|
local FromCoord = PatrolGroup:GetCoordinate()
|
||||||
local From = FromCoord:WaypointGround( 120 )
|
|
||||||
|
-- test for submarine
|
||||||
|
local depth = 0
|
||||||
|
local IsSub = false
|
||||||
|
if PatrolGroup:IsShip() then
|
||||||
|
local navalvec3 = FromCoord:GetVec3()
|
||||||
|
if navalvec3.y < 0 then
|
||||||
|
depth = navalvec3.y
|
||||||
|
IsSub = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local Waypoint = Waypoints[1]
|
||||||
|
local Speed = Waypoint.speed or (20 / 3.6)
|
||||||
|
local From = FromCoord:WaypointGround( Speed )
|
||||||
|
|
||||||
|
if IsSub then
|
||||||
|
From = FromCoord:WaypointNaval( Speed, Waypoint.alt )
|
||||||
|
end
|
||||||
|
|
||||||
table.insert( Waypoints, 1, From )
|
table.insert( Waypoints, 1, From )
|
||||||
|
|
||||||
@ -1894,7 +1911,16 @@ do -- Patrol methods
|
|||||||
if ToWaypoint then
|
if ToWaypoint then
|
||||||
FromWaypoint = ToWaypoint
|
FromWaypoint = ToWaypoint
|
||||||
end
|
end
|
||||||
|
-- test for submarine
|
||||||
|
local depth = 0
|
||||||
|
local IsSub = false
|
||||||
|
if PatrolGroup:IsShip() then
|
||||||
|
local navalvec3 = FromCoord:GetVec3()
|
||||||
|
if navalvec3.y < 0 then
|
||||||
|
depth = navalvec3.y
|
||||||
|
IsSub = true
|
||||||
|
end
|
||||||
|
end
|
||||||
-- Loop until a waypoint has been found that is not the same as the current waypoint.
|
-- Loop until a waypoint has been found that is not the same as the current waypoint.
|
||||||
-- Otherwise the object zon't move or drive in circles and the algorithm would not do exactly
|
-- Otherwise the object zon't move or drive in circles and the algorithm would not do exactly
|
||||||
-- what it is supposed to do, which is making groups drive around.
|
-- what it is supposed to do, which is making groups drive around.
|
||||||
@ -1909,9 +1935,13 @@ do -- Patrol methods
|
|||||||
local ToCoord = COORDINATE:NewFromVec2( { x = Waypoint.x, y = Waypoint.y } )
|
local ToCoord = COORDINATE:NewFromVec2( { x = Waypoint.x, y = Waypoint.y } )
|
||||||
-- Create a "ground route point", which is a "point" structure that can be given as a parameter to a Task
|
-- Create a "ground route point", which is a "point" structure that can be given as a parameter to a Task
|
||||||
local Route = {}
|
local Route = {}
|
||||||
Route[#Route+1] = FromCoord:WaypointGround( Speed, Formation )
|
if IsSub then
|
||||||
Route[#Route+1] = ToCoord:WaypointGround( Speed, Formation )
|
Route[#Route+1] = FromCoord:WaypointNaval( Speed, depth )
|
||||||
|
Route[#Route+1] = ToCoord:WaypointNaval( Speed, Waypoint.alt )
|
||||||
|
else
|
||||||
|
Route[#Route+1] = FromCoord:WaypointGround( Speed, Formation )
|
||||||
|
Route[#Route+1] = ToCoord:WaypointGround( Speed, Formation )
|
||||||
|
end
|
||||||
|
|
||||||
local TaskRouteToZone = PatrolGroup:TaskFunction( "CONTROLLABLE.PatrolRouteRandom", Speed, Formation, ToWaypoint )
|
local TaskRouteToZone = PatrolGroup:TaskFunction( "CONTROLLABLE.PatrolRouteRandom", Speed, Formation, ToWaypoint )
|
||||||
|
|
||||||
@ -1956,15 +1986,30 @@ do -- Patrol methods
|
|||||||
-- Calculate the new Route.
|
-- Calculate the new Route.
|
||||||
local FromCoord = PatrolGroup:GetCoordinate()
|
local FromCoord = PatrolGroup:GetCoordinate()
|
||||||
|
|
||||||
|
-- test for submarine
|
||||||
|
local depth = 0
|
||||||
|
local IsSub = false
|
||||||
|
if PatrolGroup:IsShip() then
|
||||||
|
local navalvec3 = FromCoord:GetVec3()
|
||||||
|
if navalvec3.y < 0 then
|
||||||
|
depth = navalvec3.y
|
||||||
|
IsSub = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Select a random Zone and get the Coordinate of the new Zone.
|
-- Select a random Zone and get the Coordinate of the new Zone.
|
||||||
local RandomZone = ZoneList[ math.random( 1, #ZoneList ) ] -- Core.Zone#ZONE
|
local RandomZone = ZoneList[ math.random( 1, #ZoneList ) ] -- Core.Zone#ZONE
|
||||||
local ToCoord = RandomZone:GetRandomCoordinate( 10 )
|
local ToCoord = RandomZone:GetRandomCoordinate( 10 )
|
||||||
|
|
||||||
-- Create a "ground route point", which is a "point" structure that can be given as a parameter to a Task
|
-- Create a "ground route point", which is a "point" structure that can be given as a parameter to a Task
|
||||||
local Route = {}
|
local Route = {}
|
||||||
Route[#Route+1] = FromCoord:WaypointGround( Speed, Formation )
|
if IsSub then
|
||||||
Route[#Route+1] = ToCoord:WaypointGround( Speed, Formation )
|
Route[#Route+1] = FromCoord:WaypointNaval( Speed, depth )
|
||||||
|
Route[#Route+1] = ToCoord:WaypointNaval( Speed, depth )
|
||||||
|
else
|
||||||
|
Route[#Route+1] = FromCoord:WaypointGround( Speed, Formation )
|
||||||
|
Route[#Route+1] = ToCoord:WaypointGround( Speed, Formation )
|
||||||
|
end
|
||||||
|
|
||||||
local TaskRouteToZone = PatrolGroup:TaskFunction( "CONTROLLABLE.PatrolZones", ZoneList, Speed, Formation, DelayMin, DelayMax )
|
local TaskRouteToZone = PatrolGroup:TaskFunction( "CONTROLLABLE.PatrolZones", ZoneList, Speed, Formation, DelayMin, DelayMax )
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user