mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Latest Updates
This commit is contained in:
parent
ca4d9f1464
commit
8eab8622c6
@ -1,3 +1,6 @@
|
||||
-------------------------------------------------------------------------------
|
||||
--- @module DCSTypes
|
||||
|
||||
|
||||
--- Time is given in seconds.
|
||||
-- @type Time
|
||||
@ -228,4 +231,5 @@ AI = {} --#AI
|
||||
--- An angle type
|
||||
-- @type Angle
|
||||
|
||||
env.info( 'AI types created' )
|
||||
env.info( 'AI types created' )
|
||||
|
||||
20
DCS/land.doclua
Normal file
20
DCS/land.doclua
Normal file
@ -0,0 +1,20 @@
|
||||
-------------------------------------------------------------------------------
|
||||
-- @module land
|
||||
|
||||
--- @type land
|
||||
-- @field #land.SurfaceType SurfaceType
|
||||
|
||||
|
||||
--- @type land.SurfaceType
|
||||
-- @field LAND
|
||||
-- @field SHALLOW_WATER
|
||||
-- @field WATER
|
||||
-- @field ROAD
|
||||
-- @field RUNWAY
|
||||
|
||||
--- Returns altitude MSL of the point.
|
||||
-- @function [parent=#land] getHeight
|
||||
-- @param #Vec2 point point on the ground.
|
||||
-- @return DCSTypes#Distance
|
||||
|
||||
land = {} --#land
|
||||
@ -3463,10 +3463,10 @@ end
|
||||
|
||||
--- Gets the current Point of the GROUP in VEC2 format.
|
||||
-- @return #Vec2 Current x and Y position of the group.
|
||||
function GROUP:GetPoint()
|
||||
function GROUP:GetPointVec2()
|
||||
self:T( self.GroupName )
|
||||
|
||||
local GroupPoint = self:GetUnit(1):GetPoint()
|
||||
local GroupPoint = self:GetUnit(1):GetPointVec2()
|
||||
self:T( GroupPoint )
|
||||
return GroupPoint
|
||||
end
|
||||
@ -3609,7 +3609,7 @@ trace.f( self.ClassName, { self.GroupName, Duration } )
|
||||
-- speed = Distance,
|
||||
-- altitude = Distance
|
||||
|
||||
local GroupPoint = self:GetPoint()
|
||||
local GroupPoint = self:GetPointVec2()
|
||||
--id = 'Orbit', params = { pattern = AI.Task.OrbitPattern.RACE_TRACK } }, stopCondition = { duration = 600 } }
|
||||
Controller:pushTask( { id = 'ControlledTask',
|
||||
params = { task = { id = 'Orbit',
|
||||
@ -3857,7 +3857,7 @@ end
|
||||
function GROUP:RouteToZone( Zone, Randomize, Speed, Formation )
|
||||
self:T( Zone )
|
||||
|
||||
local GroupPoint = self:GetPoint()
|
||||
local GroupPoint = self:GetPointVec2()
|
||||
|
||||
local PointFrom = {}
|
||||
PointFrom.x = GroupPoint.x
|
||||
@ -3873,7 +3873,7 @@ function GROUP:RouteToZone( Zone, Randomize, Speed, Formation )
|
||||
if Randomize then
|
||||
ZonePoint = Zone:GetRandomPoint()
|
||||
else
|
||||
ZonePoint = Zone:GetPoint()
|
||||
ZonePoint = Zone:GetPointVec2()
|
||||
end
|
||||
|
||||
PointTo.x = ZonePoint.x
|
||||
@ -4051,7 +4051,7 @@ function UNIT:GetCallSign()
|
||||
end
|
||||
|
||||
|
||||
function UNIT:GetPoint()
|
||||
function UNIT:GetPointVec2()
|
||||
self:T( self.UnitName )
|
||||
|
||||
local UnitPos = self.DCSUnit:getPosition().p
|
||||
@ -4128,7 +4128,7 @@ trace.f( self.ClassName, ZoneName )
|
||||
return self
|
||||
end
|
||||
|
||||
function ZONE:GetPoint()
|
||||
function ZONE:GetPointVec2()
|
||||
self:T( self.ZoneName )
|
||||
|
||||
local Zone = trigger.misc.getZone( self.ZoneName )
|
||||
@ -10152,7 +10152,7 @@ function SPAWN:SpawnFromUnit( HostUnit, OuterRadius, InnerRadius, SpawnIndex )
|
||||
|
||||
if SpawnTemplate then
|
||||
|
||||
local UnitPoint = HostUnit:GetPoint()
|
||||
local UnitPoint = HostUnit:GetPointVec2()
|
||||
--for PointID, Point in pairs( SpawnTemplate.route.points ) do
|
||||
--Point.x = UnitPoint.x
|
||||
--Point.y = UnitPoint.y
|
||||
@ -10227,7 +10227,7 @@ function SPAWN:SpawnInZone( Zone, SpawnIndex )
|
||||
|
||||
if SpawnTemplate then
|
||||
|
||||
local ZonePoint = Zone:GetPoint()
|
||||
local ZonePoint = Zone:GetPointVec2()
|
||||
|
||||
SpawnTemplate.route.points = nil
|
||||
SpawnTemplate.route.points = {}
|
||||
|
||||
@ -13,9 +13,9 @@ _TraceClass = {
|
||||
--SPAWN = true,
|
||||
--STAGE = true,
|
||||
--ZONE = true,
|
||||
--GROUP = true,
|
||||
GROUP = true,
|
||||
--UNIT = true,
|
||||
--CLIENT = true,
|
||||
CLIENT = true,
|
||||
--CARGO = true,
|
||||
--CARGO_GROUP = true,
|
||||
--CARGO_PACKAGE = true,
|
||||
|
||||
@ -202,11 +202,32 @@ function CLIENT:GetUnit()
|
||||
return UNIT:New( self:GetClientGroupDCSUnit() )
|
||||
end
|
||||
|
||||
--- Returns the Point of the @{CLIENT}.
|
||||
-- @return DCSTypes#Vec2
|
||||
function CLIENT:GetPointVec2()
|
||||
self:T()
|
||||
|
||||
ClientGroupUnit = self:GetClientGroupDCSUnit()
|
||||
|
||||
if ClientGroupUnit then
|
||||
if ClientGroupUnit:isExist() then
|
||||
local PointVec3 = ClientGroupUnit:getPoint() --DCSTypes#Vec3
|
||||
local PointVec2 = {} --DCSTypes#Vec2
|
||||
PointVec2.x = PointVec3.x
|
||||
PointVec2.y = PointVec3.z
|
||||
self:T( { PointVec2 } )
|
||||
return PointVec2
|
||||
end
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
--- Returns the Position of the @{CLIENT}.
|
||||
-- @return Position
|
||||
-- @return DCSTypes#Position
|
||||
function CLIENT:ClientPosition()
|
||||
--self:T()
|
||||
self:T()
|
||||
|
||||
ClientGroupUnit = self:GetClientGroupDCSUnit()
|
||||
|
||||
@ -219,6 +240,24 @@ function CLIENT:ClientPosition()
|
||||
return nil
|
||||
end
|
||||
|
||||
--- Returns the altitude of the @{CLIENT}.
|
||||
-- @return DCSTypes#Distance
|
||||
function CLIENT:GetAltitude()
|
||||
self:T()
|
||||
|
||||
ClientGroupUnit = self:GetClientGroupDCSUnit()
|
||||
|
||||
if ClientGroupUnit then
|
||||
if ClientGroupUnit:isExist() then
|
||||
local PointVec3 = ClientGroupUnit:getPoint() --DCSTypes#Vec3
|
||||
return PointVec3.y
|
||||
end
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
--- Transport defines that the Client is a Transport.
|
||||
-- @return CLIENT
|
||||
function CLIENT:Transport()
|
||||
|
||||
165
Moose/Escort.lua
165
Moose/Escort.lua
@ -18,18 +18,27 @@ Include.File( "Group" )
|
||||
Include.File( "Zone" )
|
||||
|
||||
--- ESCORT class
|
||||
-- @type
|
||||
--
|
||||
-- @type ESCORT
|
||||
-- @extends Base#BASE
|
||||
-- @field Client#CLIENT EscortClient
|
||||
-- @field Group#GROUP EscortGroup
|
||||
-- @field #string EscortName
|
||||
ESCORT = {
|
||||
ClassName = "ESCORT",
|
||||
EscortName = nil, -- The Escort Name
|
||||
EscortClient = nil,
|
||||
EscortGroup = nil,
|
||||
Targets = {}, -- The identified targets
|
||||
}
|
||||
|
||||
--- MENUPARAM type
|
||||
-- @type MENUPARAM
|
||||
-- @field #ESCORT ParamSelf
|
||||
|
||||
--- ESCORT class constructor for an AI group
|
||||
-- @param self
|
||||
-- @param #CLIENT EscortClient The client escorted by the EscortGroup.
|
||||
-- @param #GROUP EscortGroup The group AI escorting the EscortClient.
|
||||
-- @param Client#CLIENT EscortClient The client escorted by the EscortGroup.
|
||||
-- @param Group#GROUP EscortGroup The group AI escorting the EscortClient.
|
||||
-- @param #string EscortName Name of the escort.
|
||||
-- @return #ESCORT self
|
||||
function ESCORT:New( EscortClient, EscortGroup, EscortName )
|
||||
@ -40,15 +49,22 @@ function ESCORT:New( EscortClient, EscortGroup, EscortName )
|
||||
self.EscortGroup = EscortGroup
|
||||
self.EscortName = EscortName
|
||||
self.ReportTargets = true
|
||||
|
||||
self.EscortMenu = MENU_CLIENT:New( self.EscortClient, "Escort" .. self.EscortName )
|
||||
|
||||
-- Escort Navigation
|
||||
self.EscortMenu = MENU_CLIENT:New( self.EscortClient, "Escort" .. self.EscortName )
|
||||
self.EscortMenuHoldPosition = MENU_CLIENT_COMMAND:New( self.EscortClient, "Hold Position and Stay Low", self.EscortMenu, ESCORT._HoldPosition, { ParamSelf = self } )
|
||||
self.EscortMenuReportNavigation = MENU_CLIENT:New( self.EscortClient, "Navigation", self.EscortMenu )
|
||||
self.EscortMenuHoldPosition = MENU_CLIENT_COMMAND:New( self.EscortClient, "Hold Position and Stay Low", self.EscortMenuReportNavigation, ESCORT._HoldPosition, { ParamSelf = self } )
|
||||
self.EscortMenuHoldPosition = MENU_CLIENT_COMMAND:New( self.EscortClient, "Join-Up and Hold Position NearBy", self.EscortMenuReportNavigation, ESCORT._HoldPositionNearBy, { ParamSelf = self } )
|
||||
|
||||
-- Report Targets
|
||||
self.EscortMenuReportNearbyTargets = MENU_CLIENT:New( self.EscortClient, "Report Targets", self.EscortMenu )
|
||||
self.EscortMenuReportNearbyTargetsOn = MENU_CLIENT_COMMAND:New( self.EscortClient, "Report Targets On", self.EscortMenuReportNearbyTargets, ESCORT._ReportNearbyTargets, { ParamSelf = self, ParamReportTargets = true } )
|
||||
self.EscortMenuReportNearbyTargetsOff = MENU_CLIENT_COMMAND:New( self.EscortClient, "Report Targets Off", self.EscortMenuReportNearbyTargets, ESCORT._ReportNearbyTargets, { ParamSelf = self, ParamReportTargets = false, } )
|
||||
self.EscortMenuReportNearbyTargets = MENU_CLIENT:New( self.EscortClient, "Report targets", self.EscortMenu )
|
||||
self.EscortMenuReportNearbyTargetsOn = MENU_CLIENT_COMMAND:New( self.EscortClient, "Report targets on", self.EscortMenuReportNearbyTargets, ESCORT._ReportNearbyTargets, { ParamSelf = self, ParamReportTargets = true } )
|
||||
self.EscortMenuReportNearbyTargetsOff = MENU_CLIENT_COMMAND:New( self.EscortClient, "Report targets off", self.EscortMenuReportNearbyTargets, ESCORT._ReportNearbyTargets, { ParamSelf = self, ParamReportTargets = false, } )
|
||||
|
||||
-- Scanning Targets
|
||||
self.EscortMenuScanForTargets = MENU_CLIENT:New( self.EscortClient, "Scan targets", self.EscortMenu )
|
||||
self.EscortMenuReportNearbyTargetsOn = MENU_CLIENT_COMMAND:New( self.EscortClient, "Scan targets 30 seconds", self.EscortMenuScanForTargets, ESCORT._ScanTargets30Seconds, { ParamSelf = self, ParamScanDuration = 30 } )
|
||||
|
||||
-- Attack Targets
|
||||
self.EscortMenuAttackNearbyTargets = MENU_CLIENT:New( self.EscortClient, "Attack nearby targets", self.EscortMenu )
|
||||
@ -69,16 +85,59 @@ function ESCORT:New( EscortClient, EscortGroup, EscortName )
|
||||
self.EscortMenuEvasionEvadeFire = MENU_CLIENT_COMMAND:New( self.EscortClient, "Evade enemy fire", self.EscortMenuEvasion, ESCORT._EvasionEvadeFire, { ParamSelf = self, } )
|
||||
self.EscortMenuEvasionVertical = MENU_CLIENT_COMMAND:New( self.EscortClient, "Go below radar and evade fire", self.EscortMenuEvasion, ESCORT._EvasionVertical, { ParamSelf = self, } )
|
||||
|
||||
-- Cancel current Task
|
||||
self.EscortMenuCancelTask = MENU_CLIENT_COMMAND:New( self.EscortClient, "Cancel current task", self.EscortMenu, ESCORT._CancelCurrentTask, { ParamSelf = self, } )
|
||||
|
||||
|
||||
self.ScanForTargetsFunction = routines.scheduleFunction( self._ScanForTargets, { self }, timer.getTime() + 1, 30 )
|
||||
end
|
||||
|
||||
|
||||
--- @param #MENUPARAM MenuParam
|
||||
function ESCORT._HoldPosition( MenuParam )
|
||||
|
||||
MenuParam.ParamSelf.EscortGroup:HoldPosition( 300 )
|
||||
local EscortGroup = MenuParam.ParamSelf.EscortGroup
|
||||
local EscortClient = MenuParam.ParamSelf.EscortClient
|
||||
|
||||
EscortGroup:PushTask( EscortGroup:HoldPosition( 300 ) )
|
||||
MESSAGE:New( "Holding Position at ... for 5 minutes.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/HoldPosition" ):ToClient( MenuParam.ParamSelf.EscortClient )
|
||||
end
|
||||
|
||||
--- @param #MENUPARAM MenuParam
|
||||
function ESCORT._HoldPositionNearBy( MenuParam )
|
||||
|
||||
local EscortGroup = MenuParam.ParamSelf.EscortGroup
|
||||
local EscortClient = MenuParam.ParamSelf.EscortClient
|
||||
|
||||
--MenuParam.ParamSelf.EscortGroup:OrbitCircleAtVec2( MenuParam.ParamSelf.EscortClient:GetPointVec2(), 300, 30, 0 )
|
||||
|
||||
local PointFrom = {}
|
||||
local GroupPoint = EscortGroup:GetPointVec2()
|
||||
PointFrom = {}
|
||||
PointFrom.x = GroupPoint.x
|
||||
PointFrom.y = GroupPoint.y
|
||||
PointFrom.speed = 250
|
||||
PointFrom.type = AI.Task.WaypointType.TURNING_POINT
|
||||
PointFrom.alt = EscortClient:GetAltitude()
|
||||
PointFrom.alt_type = AI.Task.AltitudeType.BARO
|
||||
|
||||
local ClientPoint = MenuParam.ParamSelf.EscortClient:GetPointVec2()
|
||||
local PointTo = {}
|
||||
PointTo.x = ClientPoint.x
|
||||
PointTo.y = ClientPoint.y
|
||||
PointTo.speed = 250
|
||||
PointTo.type = AI.Task.WaypointType.TURNING_POINT
|
||||
PointTo.alt = EscortClient:GetAltitude()
|
||||
PointTo.alt_type = AI.Task.AltitudeType.BARO
|
||||
PointTo.task = EscortGroup:OrbitCircleAtVec2( EscortClient:GetPointVec2(), 300, 30, 0 )
|
||||
|
||||
local Points = { PointFrom, PointTo }
|
||||
|
||||
|
||||
EscortGroup:PushTask( EscortGroup:TaskMission( Points ) )
|
||||
MESSAGE:New( "Rejoining to your location. Please hold at your location.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/HoldPositionNearBy" ):ToClient( MenuParam.ParamSelf.EscortClient )
|
||||
end
|
||||
|
||||
function ESCORT._ReportNearbyTargets( MenuParam )
|
||||
MenuParam.ParamSelf:T()
|
||||
|
||||
@ -86,58 +145,126 @@ function ESCORT._ReportNearbyTargets( MenuParam )
|
||||
|
||||
end
|
||||
|
||||
--- @param #MENUPARAM MenuParam
|
||||
function ESCORT._ScanTargets30Seconds( MenuParam )
|
||||
MenuParam.ParamSelf:T()
|
||||
|
||||
local EscortGroup = MenuParam.ParamSelf.EscortGroup
|
||||
local EscortClient = MenuParam.ParamSelf.EscortClient
|
||||
|
||||
EscortGroup:PushTask( EscortGroup:OrbitCircle( 30, 200, 20 ) )
|
||||
MESSAGE:New( "Scanning targets for 30 seconds.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/ScanTargets30Seconds" ):ToClient( MenuParam.ParamSelf.EscortClient )
|
||||
end
|
||||
|
||||
--- @param #MENUPARAM MenuParam
|
||||
function ESCORT._ScanTargets60Seconds( MenuParam )
|
||||
MenuParam.ParamSelf:T()
|
||||
|
||||
local EscortGroup = MenuParam.ParamSelf.EscortGroup
|
||||
local EscortClient = MenuParam.ParamSelf.EscortClient
|
||||
|
||||
EscortGroup:PushTask( EscortGroup:OrbitCircle( 60, 200, 20 ) )
|
||||
MESSAGE:New( "Scanning targets for 60 seconds.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/ScanTargets60Seconds" ):ToClient( MenuParam.ParamSelf.EscortClient )
|
||||
end
|
||||
|
||||
--- @param #MENUPARAM MenuParam
|
||||
function ESCORT._AttackTarget( MenuParam )
|
||||
|
||||
local EscortGroup = MenuParam.ParamSelf.EscortGroup
|
||||
local EscortClient = MenuParam.ParamSelf.EscortClient
|
||||
|
||||
MenuParam.ParamSelf.EscortGroup:AttackUnit( MenuParam.ParamUnit )
|
||||
MESSAGE:New( "Attacking Unit", MenuParam.ParamSelf.EscortName, 10, "ESCORT/AttackUnit" ):ToClient( MenuParam.ParamSelf.EscortClient )
|
||||
MESSAGE:New( "Attacking Unit", MenuParam.ParamSelf.EscortName, 10, "ESCORT/AttackTarget" ):ToClient( MenuParam.ParamSelf.EscortClient )
|
||||
end
|
||||
|
||||
--- @param #MENUPARAM MenuParam
|
||||
function ESCORT._ROEHoldFire( MenuParam )
|
||||
|
||||
local EscortGroup = MenuParam.ParamSelf.EscortGroup
|
||||
local EscortClient = MenuParam.ParamSelf.EscortClient
|
||||
|
||||
MenuParam.ParamSelf.EscortGroup:HoldFire()
|
||||
MESSAGE:New( "Holding weapons.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/AttackUnit" ):ToClient( MenuParam.ParamSelf.EscortClient )
|
||||
MESSAGE:New( "Holding weapons.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/ROEHoldFire" ):ToClient( MenuParam.ParamSelf.EscortClient )
|
||||
end
|
||||
|
||||
--- @param #MENUPARAM MenuParam
|
||||
function ESCORT._ROEReturnFire( MenuParam )
|
||||
|
||||
local EscortGroup = MenuParam.ParamSelf.EscortGroup
|
||||
local EscortClient = MenuParam.ParamSelf.EscortClient
|
||||
|
||||
MenuParam.ParamSelf.EscortGroup:ReturnFire()
|
||||
MESSAGE:New( "Returning enemy fire.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/AttackUnit" ):ToClient( MenuParam.ParamSelf.EscortClient )
|
||||
MESSAGE:New( "Returning enemy fire.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/ROEReturnFire" ):ToClient( MenuParam.ParamSelf.EscortClient )
|
||||
end
|
||||
|
||||
--- @param #MENUPARAM MenuParam
|
||||
function ESCORT._ROEOpenFire( MenuParam )
|
||||
|
||||
local EscortGroup = MenuParam.ParamSelf.EscortGroup
|
||||
local EscortClient = MenuParam.ParamSelf.EscortClient
|
||||
|
||||
MenuParam.ParamSelf.EscortGroup:OpenFire()
|
||||
MESSAGE:New( "Open fire on ordered targets.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/AttackUnit" ):ToClient( MenuParam.ParamSelf.EscortClient )
|
||||
MESSAGE:New( "Open fire on ordered targets.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/ROEOpenFire" ):ToClient( MenuParam.ParamSelf.EscortClient )
|
||||
end
|
||||
|
||||
--- @param #MENUPARAM MenuParam
|
||||
function ESCORT._ROEWeaponFree( MenuParam )
|
||||
|
||||
local EscortGroup = MenuParam.ParamSelf.EscortGroup
|
||||
local EscortClient = MenuParam.ParamSelf.EscortClient
|
||||
|
||||
MenuParam.ParamSelf.EscortGroup:WeaponFree()
|
||||
MESSAGE:New( "Engaging targets.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/AttackUnit" ):ToClient( MenuParam.ParamSelf.EscortClient )
|
||||
MESSAGE:New( "Engaging targets.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/ROEWeaponFree" ):ToClient( MenuParam.ParamSelf.EscortClient )
|
||||
end
|
||||
|
||||
--- @param #MENUPARAM MenuParam
|
||||
function ESCORT._EvasionNoReaction( MenuParam )
|
||||
|
||||
local EscortGroup = MenuParam.ParamSelf.EscortGroup
|
||||
local EscortClient = MenuParam.ParamSelf.EscortClient
|
||||
|
||||
MenuParam.ParamSelf.EscortGroup:EvasionNoReaction()
|
||||
MESSAGE:New( "We'll fight until death.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/AttackUnit" ):ToClient( MenuParam.ParamSelf.EscortClient )
|
||||
MESSAGE:New( "We'll fight until death.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/EvasionNoReaction" ):ToClient( MenuParam.ParamSelf.EscortClient )
|
||||
end
|
||||
|
||||
--- @param #MENUPARAM MenuParam
|
||||
function ESCORT._EvasionPassiveDefense( MenuParam )
|
||||
|
||||
local EscortGroup = MenuParam.ParamSelf.EscortGroup
|
||||
local EscortClient = MenuParam.ParamSelf.EscortClient
|
||||
|
||||
MenuParam.ParamSelf.EscortGroup:EvasionPassiveDefense()
|
||||
MESSAGE:New( "We will use flares, chaff and jammers.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/AttackUnit" ):ToClient( MenuParam.ParamSelf.EscortClient )
|
||||
MESSAGE:New( "We will use flares, chaff and jammers.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/EvasionPassiveDefense" ):ToClient( MenuParam.ParamSelf.EscortClient )
|
||||
end
|
||||
|
||||
--- @param #MENUPARAM MenuParam
|
||||
function ESCORT._EvasionEvadeFire( MenuParam )
|
||||
|
||||
local EscortGroup = MenuParam.ParamSelf.EscortGroup
|
||||
local EscortClient = MenuParam.ParamSelf.EscortClient
|
||||
|
||||
MenuParam.ParamSelf.EscortGroup:EvasionEvadeFire()
|
||||
MESSAGE:New( "We'll evade enemy fire.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/AttackUnit" ):ToClient( MenuParam.ParamSelf.EscortClient )
|
||||
MESSAGE:New( "We'll evade enemy fire.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/EvasionEvadeFire" ):ToClient( MenuParam.ParamSelf.EscortClient )
|
||||
end
|
||||
|
||||
--- @param #MENUPARAM MenuParam
|
||||
function ESCORT._EvasionVertical( MenuParam )
|
||||
|
||||
local EscortGroup = MenuParam.ParamSelf.EscortGroup
|
||||
local EscortClient = MenuParam.ParamSelf.EscortClient
|
||||
|
||||
MenuParam.ParamSelf.EscortGroup:EvasionVertical()
|
||||
MESSAGE:New( "We'll perform vertical evasive manoeuvres.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/AttackUnit" ):ToClient( MenuParam.ParamSelf.EscortClient )
|
||||
MESSAGE:New( "We'll perform vertical evasive manoeuvres.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/EvasionVertical" ):ToClient( MenuParam.ParamSelf.EscortClient )
|
||||
end
|
||||
|
||||
--- @param #MENUPARAM MenuParam
|
||||
function ESCORT._CancelCurrentTask( MenuParam )
|
||||
|
||||
local EscortGroup = MenuParam.ParamSelf.EscortGroup
|
||||
local EscortClient = MenuParam.ParamSelf.EscortClient
|
||||
|
||||
EscortGroup:PopCurrentTask()
|
||||
MESSAGE:New( "Cancelling with current orders, continuing our mission.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/CancelCurrentTask" ):ToClient( MenuParam.ParamSelf.EscortClient )
|
||||
end
|
||||
|
||||
|
||||
|
||||
155
Moose/Group.lua
155
Moose/Group.lua
@ -131,16 +131,26 @@ function GROUP:GetName()
|
||||
return self.GroupName
|
||||
end
|
||||
|
||||
--- Gets the current Point of the GROUP in VEC2 format.
|
||||
-- @return #Vec2 Current x and Y position of the group.
|
||||
function GROUP:GetPoint()
|
||||
--- Gets the current Point of the GROUP in VEC3 format.
|
||||
-- @return #Vec3 Current x,y and z position of the group.
|
||||
function GROUP:GetPointVec2()
|
||||
self:T( self.GroupName )
|
||||
|
||||
local GroupPoint = self:GetUnit(1):GetPoint()
|
||||
local GroupPoint = self:GetUnit(1):GetPointVec2()
|
||||
self:T( GroupPoint )
|
||||
return GroupPoint
|
||||
end
|
||||
|
||||
--- Gets the current Point of the GROUP in VEC2 format.
|
||||
-- @return #Vec2 Current x and y position of the group in the 2D plane.
|
||||
function GROUP:GetPointVec2()
|
||||
self:T( self.GroupName )
|
||||
|
||||
local GroupPoint = self:GetUnit(1):GetPointVec2()
|
||||
self:T( GroupPoint )
|
||||
return GroupPoint
|
||||
end
|
||||
|
||||
--- Gets the current Point of the GROUP in VEC3 format.
|
||||
-- @return #Vec3 Current Vec3 position of the group.
|
||||
function GROUP:GetPositionVec3()
|
||||
@ -259,51 +269,118 @@ end
|
||||
-- @param self
|
||||
-- @return #number Maximum height found.
|
||||
function GROUP:GetMaxHeight()
|
||||
self:T()
|
||||
self:T()
|
||||
|
||||
end
|
||||
|
||||
|
||||
--- Hold position at the current position of the first unit of the group.
|
||||
-- @param self
|
||||
-- @param #number Duration The maximum duration in seconds to hold the position.
|
||||
-- @return #GROUP self
|
||||
function GROUP:HoldPosition( Duration )
|
||||
trace.f( self.ClassName, { self.GroupName, Duration } )
|
||||
--- Popping current Task from the group.
|
||||
-- @param #GROUP self
|
||||
-- @return Group#GROUP self
|
||||
function GROUP:PopCurrentTask()
|
||||
self:T()
|
||||
|
||||
local Controller = self:_GetController()
|
||||
|
||||
Controller:popTask()
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Pushing Task on the queue from the group.
|
||||
-- @param #GROUP self
|
||||
-- @return Group#GROUP self
|
||||
function GROUP:PushTask( DCSTask )
|
||||
self:T()
|
||||
|
||||
local Controller = self:_GetController()
|
||||
|
||||
Controller:pushTask( DCSTask )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Orbit at a specified position at a specified alititude during a specified duration with a specified speed.
|
||||
-- @param #GROUP self
|
||||
-- @param #Vec2 Point The point to hold the position.
|
||||
-- @param #number Duration The maximum duration in seconds to hold the position.
|
||||
-- @param #number Altitude The altitude to hold the position.
|
||||
-- @param #number Speed The speed flying when holding the position.
|
||||
-- @return #GROUP self
|
||||
function GROUP:OrbitCircleAtVec2( Point, Duration, Altitude, Speed )
|
||||
self:T( { self.GroupName, Point, Duration, Altitude, Speed } )
|
||||
|
||||
-- pattern = enum AI.Task.OribtPattern,
|
||||
-- point = Vec2,
|
||||
-- point2 = Vec2,
|
||||
-- speed = Distance,
|
||||
-- altitude = Distance
|
||||
|
||||
local GroupPoint = self:GetPoint()
|
||||
--id = 'Orbit', params = { pattern = AI.Task.OrbitPattern.RACE_TRACK } }, stopCondition = { duration = 600 } }
|
||||
Controller:pushTask( { id = 'ControlledTask',
|
||||
params = { task = { id = 'Orbit',
|
||||
params = { pattern = AI.Task.OrbitPattern.CIRCLE,
|
||||
point = GroupPoint,
|
||||
speed = 0,
|
||||
altitude = 30
|
||||
}
|
||||
},
|
||||
stopCondition = { duration = Duration
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
return self
|
||||
local LandHeight = land.getHeight( Point )
|
||||
|
||||
self:T( { LandHeight } )
|
||||
|
||||
local AITask = { id = 'Orbit',
|
||||
params = { pattern = AI.Task.OrbitPattern.CIRCLE,
|
||||
point = Point,
|
||||
speed = Speed,
|
||||
altitude = Altitude + LandHeight
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-- local AITask = { id = 'ControlledTask',
|
||||
-- params = { task = { id = 'Orbit',
|
||||
-- params = { pattern = AI.Task.OrbitPattern.CIRCLE,
|
||||
-- point = Point,
|
||||
-- speed = Speed,
|
||||
-- altitude = Altitude + LandHeight
|
||||
-- }
|
||||
-- },
|
||||
-- stopCondition = { duration = Duration
|
||||
-- }
|
||||
-- }
|
||||
-- }
|
||||
-- )
|
||||
|
||||
return AITask
|
||||
end
|
||||
|
||||
--- Orbit at the current position of the first unit of the group at a specified alititude during a specified duration
|
||||
-- @param #GROUP self
|
||||
-- @param #number Duration The maximum duration in seconds to hold the position.
|
||||
-- @param #number Altitude The altitude to hold the position.
|
||||
-- @param #number Speed The speed flying when holding the position.
|
||||
-- @return #GROUP self
|
||||
function GROUP:OrbitCircle( Duration, Altitude, Speed )
|
||||
self:T( { self.GroupName, Duration, Altitude, Speed } )
|
||||
|
||||
local GroupPoint = self:GetPointVec2()
|
||||
|
||||
return self:OrbitCircleAtVec2( GroupPoint, Duration, Altitude, Speed )
|
||||
end
|
||||
|
||||
|
||||
|
||||
--- Hold position at the current position of the first unit of the group.
|
||||
-- @param #GROUP self
|
||||
-- @param #number Duration The maximum duration in seconds to hold the position.
|
||||
-- @return #GROUP self
|
||||
function GROUP:HoldPosition( Duration )
|
||||
self:T( { self.GroupName, Duration } )
|
||||
|
||||
return self:OrbitCircle( Duration, 30, 0 )
|
||||
end
|
||||
|
||||
|
||||
--- Land the group at a Vec2Point.
|
||||
-- @param self
|
||||
-- @param #Vec2 Point The point where to land.
|
||||
-- @param #number Duration The duration in seconds to stay on the ground.
|
||||
-- @return #GROUP self
|
||||
function GROUP:Land( Point, Duration )
|
||||
trace.f( self.ClassName, { self.GroupName, Point, Duration } )
|
||||
self:T( { self.GroupName, Point, Duration } )
|
||||
|
||||
local Controller = self:_GetController()
|
||||
|
||||
@ -498,12 +575,25 @@ trace.f( self.ClassName, { self.GroupName, Point, Radius } )
|
||||
return self
|
||||
end
|
||||
|
||||
--- Return a Misson task to follow a given route.
|
||||
-- @param self
|
||||
-- @param #table GoPoints A table of Route Points.
|
||||
-- @return #DCSTask
|
||||
function GROUP:TaskMission( Points )
|
||||
self:T( Points )
|
||||
|
||||
local MissionTask = { id = 'Mission', params = { route = { points = Points, }, }, }
|
||||
|
||||
return MissionTask
|
||||
end
|
||||
|
||||
|
||||
--- Make the group to follow a given route.
|
||||
-- @param self
|
||||
-- @param #table GoPoints A table of Route Points.
|
||||
-- @return #GROUP self
|
||||
function GROUP:Route( GoPoints )
|
||||
self:T( GoPoints )
|
||||
self:T( GoPoints )
|
||||
|
||||
local Points = routines.utils.deepCopy( GoPoints )
|
||||
local MissionTask = { id = 'Mission', params = { route = { points = Points, }, }, }
|
||||
@ -527,7 +617,7 @@ end
|
||||
function GROUP:RouteToZone( Zone, Randomize, Speed, Formation )
|
||||
self:T( Zone )
|
||||
|
||||
local GroupPoint = self:GetPoint()
|
||||
local GroupPoint = self:GetPointVec2()
|
||||
|
||||
local PointFrom = {}
|
||||
PointFrom.x = GroupPoint.x
|
||||
@ -543,7 +633,7 @@ function GROUP:RouteToZone( Zone, Randomize, Speed, Formation )
|
||||
if Randomize then
|
||||
ZonePoint = Zone:GetRandomPoint()
|
||||
else
|
||||
ZonePoint = Zone:GetPoint()
|
||||
ZonePoint = Zone:GetPointVec2()
|
||||
end
|
||||
|
||||
PointTo.x = ZonePoint.x
|
||||
@ -621,6 +711,9 @@ self:T( { Begin, End } )
|
||||
end
|
||||
|
||||
--- Get the controller for the GROUP.
|
||||
-- @function _GetController
|
||||
-- @param #GROUP self
|
||||
-- @return Controller#Controller
|
||||
function GROUP:_GetController()
|
||||
|
||||
return self.DCSGroup:getController()
|
||||
|
||||
@ -538,7 +538,7 @@ function SPAWN:SpawnFromUnit( HostUnit, OuterRadius, InnerRadius, SpawnIndex )
|
||||
|
||||
if SpawnTemplate then
|
||||
|
||||
local UnitPoint = HostUnit:GetPoint()
|
||||
local UnitPoint = HostUnit:GetPointVec2()
|
||||
--for PointID, Point in pairs( SpawnTemplate.route.points ) do
|
||||
--Point.x = UnitPoint.x
|
||||
--Point.y = UnitPoint.y
|
||||
@ -613,7 +613,7 @@ function SPAWN:SpawnInZone( Zone, SpawnIndex )
|
||||
|
||||
if SpawnTemplate then
|
||||
|
||||
local ZonePoint = Zone:GetPoint()
|
||||
local ZonePoint = Zone:GetPointVec2()
|
||||
|
||||
SpawnTemplate.route.points = nil
|
||||
SpawnTemplate.route.points = {}
|
||||
|
||||
@ -79,7 +79,7 @@ function UNIT:GetCallSign()
|
||||
end
|
||||
|
||||
|
||||
function UNIT:GetPoint()
|
||||
function UNIT:GetPointVec2()
|
||||
self:T( self.UnitName )
|
||||
|
||||
local UnitPos = self.DCSUnit:getPosition().p
|
||||
|
||||
@ -30,7 +30,7 @@ trace.f( self.ClassName, ZoneName )
|
||||
return self
|
||||
end
|
||||
|
||||
function ZONE:GetPoint()
|
||||
function ZONE:GetPointVec2()
|
||||
self:T( self.ZoneName )
|
||||
|
||||
local Zone = trigger.misc.getZone( self.ZoneName )
|
||||
|
||||
@ -32,8 +32,8 @@ Group_Plane:Route( Route_Plane )
|
||||
|
||||
--Route_Helicopter[#Route_Helicopter].linkUnit = Group_Ship1:GetDCSUnit(1)
|
||||
--Route_Helicopter[#Route_Helicopter].helipadId = Group_Ship1:GetDCSUnit(1)
|
||||
--Route_Helicopter[#Route_Helicopter].x = Group_Ship1:GetUnit(1):GetPoint().x
|
||||
--Route_Helicopter[#Route_Helicopter].y = Group_Ship1:GetUnit(1):GetPoint().y
|
||||
--Route_Helicopter[#Route_Helicopter].x = Group_Ship1:GetUnit(1):GetPointVec2().x
|
||||
--Route_Helicopter[#Route_Helicopter].y = Group_Ship1:GetUnit(1):GetPointVec2().y
|
||||
--env.info( Route_Helicopter[#Route_Helicopter].type .. " on " .. Group_Ship1:GetUnit(1):GetID() )
|
||||
--Group_Helicopter:Route( Route_Helicopter )
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user