mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Reference points implemented
This commit is contained in:
parent
707a5a778a
commit
f8ab65ce0e
@ -158,16 +158,48 @@ do -- ACT_ROUTE
|
|||||||
-- @return #string
|
-- @return #string
|
||||||
function ACT_ROUTE:GetRouteText( Controllable )
|
function ACT_ROUTE:GetRouteText( Controllable )
|
||||||
|
|
||||||
|
self:E()
|
||||||
|
|
||||||
local RouteText = ""
|
local RouteText = ""
|
||||||
|
|
||||||
|
local Coordinate = nil -- Core.Point#COORDINATE
|
||||||
|
|
||||||
if self.Coordinate then
|
if self.Coordinate then
|
||||||
RouteText = self.Coordinate:ToString( Controllable )
|
Coordinate = self.Coordinate
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.Zone then
|
if self.Zone then
|
||||||
local Coordinate = self.Zone:GetPointVec3( self.Altitude )
|
Coordinate = self.Zone:GetPointVec3( self.Altitude )
|
||||||
Coordinate:SetHeading( self.Heading )
|
Coordinate:SetHeading( self.Heading )
|
||||||
RouteText = Coordinate:ToString( Controllable )
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local CC = self:GetTask():GetMission():GetCommandCenter()
|
||||||
|
if CC then
|
||||||
|
if CC:IsModeWWII() then
|
||||||
|
-- Find closest reference point to the target.
|
||||||
|
local ShortestDistance = 0
|
||||||
|
local ShortestReferencePoint = nil
|
||||||
|
local ShortestReferenceName = ""
|
||||||
|
self:E( { CC.ReferencePoints } )
|
||||||
|
for ZoneName, Zone in pairs( CC.ReferencePoints ) do
|
||||||
|
self:E( { ZoneName = ZoneName } )
|
||||||
|
local Zone = Zone -- Core.Zone#ZONE
|
||||||
|
local ZoneCoord = Zone:GetCoordinate()
|
||||||
|
local ZoneDistance = ZoneCoord:Get2DDistance( self.Coordinate )
|
||||||
|
self:E( { ShortestDistance, ShortestReferenceName } )
|
||||||
|
if ShortestDistance == 0 or ZoneDistance < ShortestDistance then
|
||||||
|
ShortestDistance = ZoneDistance
|
||||||
|
ShortestReferencePoint = ZoneCoord
|
||||||
|
ShortestReferenceName = CC.ReferenceNames[ZoneName]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if ShortestReferencePoint then
|
||||||
|
RouteText = Coordinate:ToStringFromRP( ShortestReferencePoint, ShortestReferenceName, Controllable )
|
||||||
|
end
|
||||||
|
else
|
||||||
|
RouteText = self.Coordinate:ToString( Controllable )
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return RouteText
|
return RouteText
|
||||||
|
|||||||
@ -1025,8 +1025,8 @@ function DATABASE:_RegisterTemplates()
|
|||||||
end --if coa_name == 'red' or coa_name == 'blue' and type(coa_data) == 'table' then
|
end --if coa_name == 'red' or coa_name == 'blue' and type(coa_data) == 'table' then
|
||||||
end --for coa_name, coa_data in pairs(mission.coalition) do
|
end --for coa_name, coa_data in pairs(mission.coalition) do
|
||||||
|
|
||||||
for ZoneID, ZoneData in pairs( env.triggers.zones ) do
|
for ZoneID, ZoneData in pairs( env.mission.triggers.zones ) do
|
||||||
local ZoneName = ZoneData.Name
|
local ZoneName = ZoneData.name
|
||||||
self.ZONENAMES[ZoneName] = ZoneName
|
self.ZONENAMES[ZoneName] = ZoneName
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -62,6 +62,7 @@ do -- COORDINATE
|
|||||||
--- @type COORDINATE
|
--- @type COORDINATE
|
||||||
-- @extends Core.Base#BASE
|
-- @extends Core.Base#BASE
|
||||||
|
|
||||||
|
|
||||||
--- # COORDINATE class, extends @{Base#BASE}
|
--- # COORDINATE class, extends @{Base#BASE}
|
||||||
--
|
--
|
||||||
-- COORDINATE defines a 3D point in the simulator and with its methods, you can use or manipulate the point in 3D space.
|
-- COORDINATE defines a 3D point in the simulator and with its methods, you can use or manipulate the point in 3D space.
|
||||||
@ -182,7 +183,7 @@ do -- COORDINATE
|
|||||||
-- @param #COORDINATE self
|
-- @param #COORDINATE self
|
||||||
-- @param Dcs.DCSTypes#Vec2 Vec2 The Vec2 point.
|
-- @param Dcs.DCSTypes#Vec2 Vec2 The Vec2 point.
|
||||||
-- @param Dcs.DCSTypes#Distance LandHeightAdd (optional) The default height if required to be evaluated will be the land height of the x, y coordinate. You can specify an extra height to be added to the land height.
|
-- @param Dcs.DCSTypes#Distance LandHeightAdd (optional) The default height if required to be evaluated will be the land height of the x, y coordinate. You can specify an extra height to be added to the land height.
|
||||||
-- @return Core.Point#COORDINATE
|
-- @return #COORDINATE
|
||||||
function COORDINATE:NewFromVec2( Vec2, LandHeightAdd )
|
function COORDINATE:NewFromVec2( Vec2, LandHeightAdd )
|
||||||
|
|
||||||
local LandHeight = land.getHeight( Vec2 )
|
local LandHeight = land.getHeight( Vec2 )
|
||||||
@ -204,9 +205,8 @@ do -- COORDINATE
|
|||||||
-- @return Core.Point#COORDINATE
|
-- @return Core.Point#COORDINATE
|
||||||
function COORDINATE:NewFromVec3( Vec3 )
|
function COORDINATE:NewFromVec3( Vec3 )
|
||||||
|
|
||||||
local self = self:New( Vec3.x, Vec3.y, Vec3.z )
|
local self = self:New( Vec3.x, Vec3.y, Vec3.z ) -- #COORDINATE
|
||||||
|
|
||||||
--local self = BASE:Inherit( self, POINT_VEC3:NewFromVec3( Vec3 ) ) -- Core.Point#COORDINATE
|
|
||||||
self:F2( self )
|
self:F2( self )
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@ -773,6 +773,37 @@ do -- COORDINATE
|
|||||||
return "MGRS, " .. UTILS.tostringMGRS( MGRS, MGRS_Accuracy )
|
return "MGRS, " .. UTILS.tostringMGRS( MGRS, MGRS_Accuracy )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Provides a coordinate string of the point, based on a coordinate format system:
|
||||||
|
-- * Uses default settings in COORDINATE.
|
||||||
|
-- * Can be overridden if for a GROUP containing x clients, a menu was selected to override the default.
|
||||||
|
-- @param #COORDINATE self
|
||||||
|
-- @param Wrapper.Controllable#CONTROLLABLE Controllable
|
||||||
|
-- @param Core.Settings#SETTINGS Settings
|
||||||
|
-- @return #string The coordinate Text in the configured coordinate system.
|
||||||
|
function COORDINATE:ToStringFromRP( ReferenceCoord, ReferenceName, Controllable, Settings ) -- R2.2
|
||||||
|
|
||||||
|
self:E( { ReferenceCoord = ReferenceCoord, ReferenceName = ReferenceName } )
|
||||||
|
|
||||||
|
local Settings = Settings or ( Controllable and _DATABASE:GetPlayerSettings( Controllable:GetPlayerName() ) ) or _SETTINGS
|
||||||
|
|
||||||
|
local IsAir = Controllable and Controllable:IsAirPlane() or false
|
||||||
|
|
||||||
|
if IsAir then
|
||||||
|
local DirectionVec3 = ReferenceCoord:GetDirectionVec3( self )
|
||||||
|
local AngleRadians = self:GetAngleRadians( DirectionVec3 )
|
||||||
|
local Distance = self:Get2DDistance( ReferenceCoord )
|
||||||
|
return "Targets are the last seen " .. self:GetBRText( AngleRadians, Distance, Settings ) .. " from " .. ReferenceName
|
||||||
|
else
|
||||||
|
local DirectionVec3 = ReferenceCoord:GetDirectionVec3( self )
|
||||||
|
local AngleRadians = self:GetAngleRadians( DirectionVec3 )
|
||||||
|
local Distance = self:Get2DDistance( ReferenceCoord )
|
||||||
|
return "Target are located " .. self:GetBRText( AngleRadians, Distance, Settings ) .. " from " .. ReferenceName
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
--- Provides a coordinate string of the point, based on a coordinate format system:
|
--- Provides a coordinate string of the point, based on a coordinate format system:
|
||||||
-- * Uses default settings in COORDINATE.
|
-- * Uses default settings in COORDINATE.
|
||||||
-- * Can be overridden if for a GROUP containing x clients, a menu was selected to override the default.
|
-- * Can be overridden if for a GROUP containing x clients, a menu was selected to override the default.
|
||||||
@ -1107,7 +1138,7 @@ do -- POINT_VEC2
|
|||||||
LandHeightAdd = LandHeightAdd or 0
|
LandHeightAdd = LandHeightAdd or 0
|
||||||
LandHeight = LandHeight + LandHeightAdd
|
LandHeight = LandHeight + LandHeightAdd
|
||||||
|
|
||||||
local self = BASE:Inherit( self, COORDINATE:NewFromVec2( Vec2, LandHeightAdd ) ) -- Core.Point#POINT_VEC2
|
local self = BASE:Inherit( self, COORDINATE:NewFromVec2( Vec2, LandHeightAdd ) ) -- #POINT_VEC2
|
||||||
self:F2( self )
|
self:F2( self )
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@ -1119,9 +1150,7 @@ do -- POINT_VEC2
|
|||||||
-- @return Core.Point#POINT_VEC2 self
|
-- @return Core.Point#POINT_VEC2 self
|
||||||
function POINT_VEC2:NewFromVec3( Vec3 )
|
function POINT_VEC2:NewFromVec3( Vec3 )
|
||||||
|
|
||||||
local self = BASE:Inherit( self, BASE:New() )
|
local self = BASE:Inherit( self, COORDINATE:NewFromVec3( Vec3 ) ) -- #POINT_VEC2
|
||||||
|
|
||||||
local self = BASE:Inherit( self, COORDINATE:New( Vec3.x, Vec3.y, Vec3.z ) ) -- Core.Point#POINT_VEC2
|
|
||||||
self:F2( self )
|
self:F2( self )
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|||||||
@ -225,7 +225,6 @@ end
|
|||||||
|
|
||||||
--- Returns a @{Point#COORDINATE} of the zone.
|
--- Returns a @{Point#COORDINATE} of the zone.
|
||||||
-- @param #ZONE_BASE self
|
-- @param #ZONE_BASE self
|
||||||
-- @param Dcs.DCSTypes#Distance Height The height to add to the land height where the center of the zone is located.
|
|
||||||
-- @return Core.Point#COORDINATE The Coordinate of the zone.
|
-- @return Core.Point#COORDINATE The Coordinate of the zone.
|
||||||
function ZONE_BASE:GetCoordinate()
|
function ZONE_BASE:GetCoordinate()
|
||||||
self:F2( self.ZoneName )
|
self:F2( self.ZoneName )
|
||||||
|
|||||||
@ -262,13 +262,14 @@ end
|
|||||||
-- @param #string ReferenceZonePrefix Reference points.
|
-- @param #string ReferenceZonePrefix Reference points.
|
||||||
-- @return #COMMANDCENTER
|
-- @return #COMMANDCENTER
|
||||||
function COMMANDCENTER:SetReferenceZones( ReferenceZonePrefix )
|
function COMMANDCENTER:SetReferenceZones( ReferenceZonePrefix )
|
||||||
local MatchPattern = "(" .. ReferenceZonePrefix .. ")" .. "#(a+)"
|
local MatchPattern = "(.*)#(.*)"
|
||||||
|
self:F( { MatchPattern = MatchPattern } )
|
||||||
for ReferenceZoneName in pairs( _DATABASE.ZONENAMES ) do
|
for ReferenceZoneName in pairs( _DATABASE.ZONENAMES ) do
|
||||||
local ZoneName, ReferenceName = string.match( ReferenceZoneName, MatchPattern )
|
local ZoneName, ReferenceName = string.match( ReferenceZoneName, MatchPattern )
|
||||||
self:T( { ZoneName = ZoneName, ReferenceName = ReferenceName } )
|
self:F( { ZoneName = ZoneName, ReferenceName = ReferenceName } )
|
||||||
if ZoneName and ReferenceName then
|
if ZoneName and ReferenceName and ZoneName == ReferenceZonePrefix then
|
||||||
self.ReferencePoints[ZoneName] = ZONE:New( ZoneName )
|
self.ReferencePoints[ReferenceZoneName] = ZONE:New( ReferenceZoneName )
|
||||||
self.ReferenceNames[ZoneName] = ReferenceName
|
self.ReferenceNames[ReferenceZoneName] = ReferenceName
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return self
|
return self
|
||||||
@ -284,6 +285,17 @@ function COMMANDCENTER:SetModeWWII()
|
|||||||
self.CommunicationMode = "WWII"
|
self.CommunicationMode = "WWII"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Returns if the commandcenter operations is in WWII mode
|
||||||
|
-- @param #COMMANDCENTER self
|
||||||
|
-- @return #boolean true if in WWII mode.
|
||||||
|
function COMMANDCENTER:IsModeWWII()
|
||||||
|
return self.CommunicationMode == "WWII"
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Sets the menu structure of the Missions governed by the HQ command center.
|
--- Sets the menu structure of the Missions governed by the HQ command center.
|
||||||
-- @param #COMMANDCENTER self
|
-- @param #COMMANDCENTER self
|
||||||
function COMMANDCENTER:SetMenu()
|
function COMMANDCENTER:SetMenu()
|
||||||
|
|||||||
@ -384,6 +384,53 @@ do -- TASK_A2A_INTERCEPT
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
do -- TASK_A2A_SWEEP
|
||||||
|
|
||||||
|
--- The TASK_A2A_SWEEP class
|
||||||
|
-- @type TASK_A2A_SWEEP
|
||||||
|
-- @field Set#SET_UNIT TargetSetUnit
|
||||||
|
-- @extends Tasking.Task#TASK
|
||||||
|
TASK_A2A_SWEEP = {
|
||||||
|
ClassName = "TASK_A2A_SWEEP",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--- Instantiates a new TASK_A2A_SWEEP.
|
||||||
|
-- @param #TASK_A2A_SWEEP self
|
||||||
|
-- @param Tasking.Mission#MISSION Mission
|
||||||
|
-- @param Core.Set#SET_GROUP SetGroup The set of groups for which the Task can be assigned.
|
||||||
|
-- @param #string TaskName The name of the Task.
|
||||||
|
-- @param Core.Set#SET_UNIT TargetSetUnit
|
||||||
|
-- @param #string TaskBriefing The briefing of the task.
|
||||||
|
-- @return #TASK_A2A_SWEEP self
|
||||||
|
function TASK_A2A_SWEEP:New( Mission, SetGroup, TaskName, TargetSetUnit, TaskBriefing )
|
||||||
|
local self = BASE:Inherit( self, TASK_A2A:New( Mission, SetGroup, TaskName, TargetSetUnit, "INTERCEPT", TaskBriefing ) ) -- #TASK_A2A_SWEEP
|
||||||
|
self:F()
|
||||||
|
|
||||||
|
Mission:AddTask( self )
|
||||||
|
|
||||||
|
--TODO: Add BR, Altitude, type of planes...
|
||||||
|
|
||||||
|
self:SetBriefing(
|
||||||
|
TaskBriefing or
|
||||||
|
"Perform a fighter sweep. Incoming intruders were detected and could be hiding at the location.\n"
|
||||||
|
)
|
||||||
|
|
||||||
|
local TargetCoordinate = TargetSetUnit:GetFirst():GetCoordinate()
|
||||||
|
self:SetInfo( "Coordinates", TargetCoordinate )
|
||||||
|
|
||||||
|
self:SetInfo( "Assumed Threat", "[" .. string.rep( "■", TargetSetUnit:CalculateThreatLevelA2G() ) .. "]" )
|
||||||
|
local DetectedItemsCount = TargetSetUnit:Count()
|
||||||
|
local DetectedItemsTypes = TargetSetUnit:GetTypeNames()
|
||||||
|
self:SetInfo( "Lost Targets", string.format( "%d of %s", DetectedItemsCount, DetectedItemsTypes ) )
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
do -- TASK_A2A_ENGAGE
|
do -- TASK_A2A_ENGAGE
|
||||||
|
|
||||||
--- The TASK_A2A_ENGAGE class
|
--- The TASK_A2A_ENGAGE class
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user