From 51e50bee71ec71d52734d5dfbbb9a9084828071f Mon Sep 17 00:00:00 2001 From: FlightControl_Master Date: Mon, 11 Sep 2017 06:51:14 +0200 Subject: [PATCH 1/3] Added methods to COORDINATE to place marks on the map * Added new methods to COORDINATE allowing to place marks for players on the map. Now marks can be placed on the map using :AddToAll(), :MarkToCoalition(), :MarkToCoalitionRed(), :MarkToCoalitionBlue(), :MarkToGroup() and marks can be removed using :RemoveMark() --- Moose Development/Moose/Core/Point.lua | 94 +++++++ Moose Development/Moose/Utilities/Utils.lua | 12 +- docs/Documentation/AI_A2A.html | 1 + docs/Documentation/AI_A2A_Dispatcher.html | 59 +++-- docs/Documentation/Cargo.html | 1 + docs/Documentation/Designate.html | 22 +- docs/Documentation/Detection.html | 2 + docs/Documentation/Movement.html | 4 - docs/Documentation/Point.html | 277 +++++++++++++++++++- docs/Documentation/Spawn.html | 26 +- docs/Documentation/SpawnStatic.html | 1 + docs/Documentation/Spot.html | 4 - docs/Documentation/Task.html | 60 +++++ docs/Documentation/Utils.html | 42 +++ 14 files changed, 575 insertions(+), 30 deletions(-) diff --git a/Moose Development/Moose/Core/Point.lua b/Moose Development/Moose/Core/Point.lua index 1f5b26f39..25ea827ea 100644 --- a/Moose Development/Moose/Core/Point.lua +++ b/Moose Development/Moose/Core/Point.lua @@ -90,6 +90,18 @@ do -- COORDINATE -- * @{#COORDINATE.IlluminationBomb}(): To illuminate the point. -- -- + -- ## Markings + -- + -- Place markers (text boxes with clarifications for briefings, target locations or any other reference point) on the map for all players, coalitions or specific groups: + -- + -- * @{#COORDINATE.MarkToAll}(): Place a mark to all players. + -- * @{#COORDINATE.MarkToCoalition}(): Place a mark to a coalition. + -- * @{#COORDINATE.MarkToCoalitionRed}(): Place a mark to the red coalition. + -- * @{#COORDINATE.MarkToCoalitionBlue}(): Place a mark to the blue coalition. + -- * @{#COORDINATE.MarkToGroup}(): Place a mark to a group (needs to have a client in it or a CA group (CA group is bugged)). + -- * @{#COORDINATE.RemoveMark}(): Removes a mark from the map. + -- + -- -- ## 3D calculation methods -- -- Various calculation methods exist to use or manipulate 3D space. Find below a short description of each method: @@ -650,6 +662,88 @@ do -- COORDINATE self:F2( Azimuth ) self:Flare( FLARECOLOR.Red, Azimuth ) end + + do -- Markings + + --- Mark to All + -- @param #COORDINATE self + -- @param #string MarkText Free format text that shows the marking clarification. + -- @return #number The resulting Mark ID which is a number. + -- @usage + -- local TargetCoord = TargetGroup:GetCoordinate() + -- local MarkID = TargetCoord:MarkToAll( "This is a target for all players" ) + function COORDINATE:MarkToAll( MarkText ) + local MarkID = UTILS.GetMarkID() + trigger.action.markToAll( MarkID, MarkText, self:GetVec3() ) + return MarkID + end + + --- Mark to Coalition + -- @param #COORDINATE self + -- @param #string MarkText Free format text that shows the marking clarification. + -- @param Coalition + -- @return #number The resulting Mark ID which is a number. + -- @usage + -- local TargetCoord = TargetGroup:GetCoordinate() + -- local MarkID = TargetCoord:MarkToCoalition( "This is a target for the red coalition", coalition.side.RED ) + function COORDINATE:MarkToCoalition( MarkText, Coalition ) + local MarkID = UTILS.GetMarkID() + trigger.action.markToCoalition( MarkID, MarkText, self:GetVec3(), Coalition ) + return MarkID + end + + --- Mark to Red Coalition + -- @param #COORDINATE self + -- @param #string MarkText Free format text that shows the marking clarification. + -- @return #number The resulting Mark ID which is a number. + -- @usage + -- local TargetCoord = TargetGroup:GetCoordinate() + -- local MarkID = TargetCoord:MarkToCoalitionRed( "This is a target for the red coalition" ) + function COORDINATE:MarkToCoalitionRed( MarkText ) + return self:MarkToCoalition( MarkText, coalition.side.RED ) + end + + --- Mark to Blue Coalition + -- @param #COORDINATE self + -- @param #string MarkText Free format text that shows the marking clarification. + -- @return #number The resulting Mark ID which is a number. + -- @usage + -- local TargetCoord = TargetGroup:GetCoordinate() + -- local MarkID = TargetCoord:MarkToCoalitionBlue( "This is a target for the blue coalition" ) + function COORDINATE:MarkToCoalitionBlue( MarkText ) + return self:MarkToCoalition( MarkText, coalition.side.BLUE ) + end + + --- Mark to Group + -- @param #COORDINATE self + -- @param #string MarkText Free format text that shows the marking clarification. + -- @param Wrapper.Group#GROUP MarkGroup The @{Group} that receives the mark. + -- @return #number The resulting Mark ID which is a number. + -- @usage + -- local TargetCoord = TargetGroup:GetCoordinate() + -- local MarkGroup = GROUP:FindByName( "AttackGroup" ) + -- local MarkID = TargetCoord:MarkToGroup( "This is a target for the attack group", AttackGroup ) + function COORDINATE:MarkToCoalition( MarkText, MarkGroup ) + local MarkID = UTILS.GetMarkID() + trigger.action.markToGroup( MarkID, MarkText, self:GetVec3(), MarkGroup:GetID() ) + return MarkID + end + + --- Remove a mark + -- @param #COORDINATE self + -- @param #number MarkID The ID of the mark to be removed. + -- @usage + -- local TargetCoord = TargetGroup:GetCoordinate() + -- local MarkGroup = GROUP:FindByName( "AttackGroup" ) + -- local MarkID = TargetCoord:MarkToGroup( "This is a target for the attack group", AttackGroup ) + -- <<< logic >>> + -- RemoveMark( MarkID ) -- The mark is now removed + function COORDINATE:RemoveMark( MarkID ) + trigger.action.removeMark( MarkID ) + end + + end -- Markings + --- Returns if a Coordinate has Line of Sight (LOS) with the ToCoordinate. -- @param #COORDINATE self diff --git a/Moose Development/Moose/Utilities/Utils.lua b/Moose Development/Moose/Utilities/Utils.lua index dc292d942..44d7f24e3 100644 --- a/Moose Development/Moose/Utilities/Utils.lua +++ b/Moose Development/Moose/Utilities/Utils.lua @@ -31,7 +31,9 @@ FLARECOLOR = trigger.flareColor -- #FLARECOLOR --- Utilities static class. -- @type UTILS -UTILS = {} +UTILS = { + _MarkID = 0 +} --- Function to infer instance of an object -- @@ -395,3 +397,11 @@ function UTILS.spairs( t, order ) end end end + +-- get a new mark ID for markings +function UTILS.GetMarkID() + + UTILS._MarkID = UTILS._MarkID + 1 + return UTILS._MarkID + +end diff --git a/docs/Documentation/AI_A2A.html b/docs/Documentation/AI_A2A.html index 6d716e063..34f484bce 100644 --- a/docs/Documentation/AI_A2A.html +++ b/docs/Documentation/AI_A2A.html @@ -661,6 +661,7 @@
+ #number AI_A2A.IdleCount diff --git a/docs/Documentation/AI_A2A_Dispatcher.html b/docs/Documentation/AI_A2A_Dispatcher.html index 703bc7751..93e30f590 100644 --- a/docs/Documentation/AI_A2A_Dispatcher.html +++ b/docs/Documentation/AI_A2A_Dispatcher.html @@ -341,13 +341,13 @@ Per one, two, three, four?

- AI_A2A_DISPATCHER:CountDefendersEngaged(Target) + AI_A2A_DISPATCHER:CountDefendersEngaged(AttackerDetection) - AI_A2A_DISPATCHER:CountDefendersToBeEngaged(DetectedItem, DefenderCount) + AI_A2A_DISPATCHER:CountDefendersToBeEngaged(AttackerDetection, DefenderCount) @@ -464,6 +464,12 @@ Per one, two, three, four?

AI_A2A_DISPATCHER:GetDefenderTaskFsm(Defender) + + + + AI_A2A_DISPATCHER:GetDefenderTaskSquadronName(Defender) + + @@ -719,7 +725,7 @@ Per one, two, three, four?

- AI_A2A_DISPATCHER:SetDefenderTaskTarget(AIGroup, Defender, Target) + AI_A2A_DISPATCHER:SetDefenderTaskTarget(AIGroup, Defender, AttackerDetection) @@ -905,13 +911,13 @@ Per one, two, three, four?

- AI_A2A_DISPATCHER:onafterENGAGE(From, Event, To, Target, Defenders) + AI_A2A_DISPATCHER:onafterENGAGE(From, Event, To, AttackerDetection, Defenders) - AI_A2A_DISPATCHER:onafterGCI(From, Event, To, DetectedItem, DefendersMissing, Friendlies) + AI_A2A_DISPATCHER:onafterGCI(From, Event, To, AttackerDetection, DefendersMissing, DefenderFriendlies) @@ -2104,7 +2110,7 @@ DefenderSquadron

-AI_A2A_DISPATCHER:CountDefendersEngaged(Target) +AI_A2A_DISPATCHER:CountDefendersEngaged(AttackerDetection)
@@ -2115,7 +2121,7 @@ DefenderSquadron

  • -

    Target :

    +

    AttackerDetection :

@@ -2125,7 +2131,7 @@ DefenderSquadron

-AI_A2A_DISPATCHER:CountDefendersToBeEngaged(DetectedItem, DefenderCount) +AI_A2A_DISPATCHER:CountDefendersToBeEngaged(AttackerDetection, DefenderCount)
@@ -2136,7 +2142,7 @@ DefenderSquadron

  • -

    DetectedItem :

    +

    AttackerDetection :

  • @@ -2544,6 +2550,27 @@ Takeoff From the airbase hot, from the airbase cold, in the air, from the runway +

    Parameter

    +
      +
    • + +

      Defender :

      + +
    • +
    +
+
+
+
+ + +AI_A2A_DISPATCHER:GetDefenderTaskSquadronName(Defender) + +
+
+ + +

Parameter

@@ -5222,7 +5249,7 @@ Provide a value of true to display every 30 seconds a tactical
-AI_A2A_DISPATCHER:onafterENGAGE(From, Event, To, Target, Defenders) +AI_A2A_DISPATCHER:onafterENGAGE(From, Event, To, AttackerDetection, Defenders)
@@ -5248,7 +5275,7 @@ Provide a value of true to display every 30 seconds a tactical
  • -

    Target :

    +

    AttackerDetection :

  • @@ -5263,7 +5290,7 @@ Provide a value of true to display every 30 seconds a tactical
    -AI_A2A_DISPATCHER:onafterGCI(From, Event, To, DetectedItem, DefendersMissing, Friendlies) +AI_A2A_DISPATCHER:onafterGCI(From, Event, To, AttackerDetection, DefendersMissing, DefenderFriendlies)
    @@ -5289,7 +5316,7 @@ Provide a value of true to display every 30 seconds a tactical
  • -

    DetectedItem :

    +

    AttackerDetection :

  • @@ -5299,7 +5326,7 @@ Provide a value of true to display every 30 seconds a tactical
  • -

    Friendlies :

    +

    DefenderFriendlies :

  • diff --git a/docs/Documentation/Cargo.html b/docs/Documentation/Cargo.html index a11fd4dba..21b706849 100644 --- a/docs/Documentation/Cargo.html +++ b/docs/Documentation/Cargo.html @@ -3543,6 +3543,7 @@ The range till cargo will board.

    + #number CARGO_UNIT.RunCount diff --git a/docs/Documentation/Designate.html b/docs/Documentation/Designate.html index 31210aea8..da55e5179 100644 --- a/docs/Documentation/Designate.html +++ b/docs/Documentation/Designate.html @@ -257,6 +257,12 @@ each detected set of potential targets can be lased or smoked...

    DESIGNATE:LaseOn()

    LaseOn Trigger for DESIGNATE

    + + + + DESIGNATE.LaseStart + + @@ -1090,7 +1096,7 @@ function below will use the range 1-7 just in case

    - #number + DESIGNATE.LaseDuration @@ -1125,6 +1131,20 @@ function below will use the range 1-7 just in case

    LaseOn Trigger for DESIGNATE

    +
    +
    +
    +
    + + + +DESIGNATE.LaseStart + +
    +
    + + +
    diff --git a/docs/Documentation/Detection.html b/docs/Documentation/Detection.html index e055abe7c..aa6ec9489 100644 --- a/docs/Documentation/Detection.html +++ b/docs/Documentation/Detection.html @@ -2465,6 +2465,7 @@ The index of the DetectedItem.

    + #number DETECTION_BASE.DetectedItemCount @@ -2478,6 +2479,7 @@ The index of the DetectedItem.

    + #number DETECTION_BASE.DetectedItemMax diff --git a/docs/Documentation/Movement.html b/docs/Documentation/Movement.html index be5ce073c..4307c3aaa 100644 --- a/docs/Documentation/Movement.html +++ b/docs/Documentation/Movement.html @@ -227,7 +227,6 @@ on defined intervals (currently every minute).

    - #number MOVEMENT.AliveUnits @@ -236,9 +235,6 @@ on defined intervals (currently every minute).

    - -

    Contains the counter how many units are currently alive

    -
    diff --git a/docs/Documentation/Point.html b/docs/Documentation/Point.html index 4c79fc8f9..fef7b4f04 100644 --- a/docs/Documentation/Point.html +++ b/docs/Documentation/Point.html @@ -315,6 +315,30 @@ COORDINATE:IsLOS(ToCoordinate)

    Returns if a Coordinate has Line of Sight (LOS) with the ToCoordinate.

    + + + + COORDINATE:MarkToAll(MarkText) + +

    Mark to All

    + + + + COORDINATE:MarkToCoalition(MarkText, Coalition) + +

    Mark to Coalition

    + + + + COORDINATE:MarkToCoalitionBlue(MarkText) + +

    Mark to Blue Coalition

    + + + + COORDINATE:MarkToCoalitionRed(MarkText) + +

    Mark to Red Coalition

    @@ -333,6 +357,12 @@ COORDINATE:NewFromVec3(Vec3)

    Create a new COORDINATE object from Vec3 coordinates.

    + + + + COORDINATE:RemoveMark(MarkID) + +

    Remove a mark

    @@ -382,6 +412,18 @@

    Provides a coordinate string of the point, based on a coordinate format system: * Uses default settings in COORDINATE.

    + + + + COORDINATE:ToStringA2A(Controllable, Settings) + +

    Provides a coordinate string of the point, based on the A2A coordinate format system.

    + + + + COORDINATE:ToStringA2G(Controllable, Settings) + +

    Provides a coordinate string of the point, based on the A2G coordinate format system.

    @@ -850,6 +892,20 @@ +

    Markings

    + +

    Place markers (text boxes with clarifications for briefings, target locations or any other reference point) on the map for all players, coalitions or specific groups:

    + + + +

    3D calculation methods

    Various calculation methods exist to use or manipulate 3D space. Find below a short description of each method:

    @@ -1688,6 +1744,135 @@ true If the ToCoordinate has LOS with the Coordinate, otherwise false.

    + +COORDINATE:MarkToAll(MarkText) + +
    +
    + +

    Mark to All

    + +

    Parameter

    +
      +
    • + +

      #string MarkText : +Free format text that shows the marking clarification.

      + +
    • +
    +

    Return value

    + +

    #number: +The resulting Mark ID which is a number.

    + +

    Usage:

    +
      local TargetCoord = TargetGroup:GetCoordinate()
    +  local MarkID = TargetCoord:MarkToAll( "This is a target for all players" )
    + +
    +
    +
    +
    + + +COORDINATE:MarkToCoalition(MarkText, Coalition) + +
    +
    + +

    Mark to Coalition

    + +

    Parameters

    +
      +
    • + +

      #string MarkText : +Free format text that shows the marking clarification.

      + +
    • +
    • + +

      Coalition :

      + +
    • +
    +

    Return value

    + +

    #number: +The resulting Mark ID which is a number.

    + +

    Usage:

    +
      local TargetCoord = TargetGroup:GetCoordinate()
    +  local MarkID = TargetCoord:MarkToCoalition( "This is a target for the red coalition", coalition.side.RED )
    + +
    +
    +
    +
    + + +COORDINATE:MarkToCoalitionBlue(MarkText) + +
    +
    + +

    Mark to Blue Coalition

    + +

    Parameter

    +
      +
    • + +

      #string MarkText : +Free format text that shows the marking clarification.

      + +
    • +
    +

    Return value

    + +

    #number: +The resulting Mark ID which is a number.

    + +

    Usage:

    +
      local TargetCoord = TargetGroup:GetCoordinate()
    +  local MarkID = TargetCoord:MarkToCoalitionBlue( "This is a target for the blue coalition" )
    + +
    +
    +
    +
    + + +COORDINATE:MarkToCoalitionRed(MarkText) + +
    +
    + +

    Mark to Red Coalition

    + +

    Parameter

    +
      +
    • + +

      #string MarkText : +Free format text that shows the marking clarification.

      + +
    • +
    +

    Return value

    + +

    #number: +The resulting Mark ID which is a number.

    + +

    Usage:

    +
      local TargetCoord = TargetGroup:GetCoordinate()
    +  local MarkID = TargetCoord:MarkToCoalitionRed( "This is a target for the red coalition" )
    + +
    +
    +
    +
    + COORDINATE:New(x, y, z) @@ -1782,6 +1967,35 @@ The Vec3 point.

    #COORDINATE:

    + +
    +
    +
    + + +COORDINATE:RemoveMark(MarkID) + +
    +
    + +

    Remove a mark

    + +

    Parameter

    +
      +
    • + +

      #number MarkID : +The ID of the mark to be removed.

      + +
    • +
    +

    Usage:

    +
      local TargetCoord = TargetGroup:GetCoordinate()
    +  local MarkGroup = GROUP:FindByName( "AttackGroup" )
    +  local MarkID = TargetCoord:MarkToGroup( "This is a target for the attack group", AttackGroup )
    +  <<< logic >>>
    +  RemoveMark( MarkID ) -- The mark is now removed
    +
    @@ -1937,6 +2151,68 @@ The coordinate Text in the configured coordinate system.

    + +COORDINATE:ToStringA2A(Controllable, Settings) + +
    +
    + +

    Provides a coordinate string of the point, based on the A2A coordinate format system.

    + +

    Parameters

    + +

    Return value

    + +

    #string: +The coordinate Text in the configured coordinate system.

    + +
    +
    +
    +
    + + +COORDINATE:ToStringA2G(Controllable, Settings) + +
    +
    + +

    Provides a coordinate string of the point, based on the A2G coordinate format system.

    + +

    Parameters

    + +

    Return value

    + +

    #string: +The coordinate Text in the configured coordinate system.

    + +
    +
    +
    +
    + COORDINATE:ToStringAspect(TargetCoordinate) @@ -2862,7 +3138,6 @@ The y coordinate.

    - POINT_VEC2.z diff --git a/docs/Documentation/Spawn.html b/docs/Documentation/Spawn.html index 3c14d9de6..aa863f1f4 100644 --- a/docs/Documentation/Spawn.html +++ b/docs/Documentation/Spawn.html @@ -822,6 +822,12 @@ and any spaces before and after the resulting name are removed.

    SPAWN:_TranslateRotate(SpawnIndex, SpawnRootX, SpawnRootY, SpawnX, SpawnY, SpawnAngle) + + + + SPAWN.uncontrolled + + @@ -2194,9 +2200,6 @@ The group that was spawned. You can use this group for further actions.

    - -

    Don't repeat the group from Take-Off till Landing and back Take-Off by ReSpawning.

    -
    @@ -2735,6 +2738,9 @@ when nothing was spawned.

    + +

    Overwrite unit names by default with group name.

    +
    @@ -3733,6 +3739,20 @@ True = Continue Scheduler

    + +
    +
    +
    + + + +SPAWN.uncontrolled + +
    +
    + + +
    diff --git a/docs/Documentation/SpawnStatic.html b/docs/Documentation/SpawnStatic.html index bc91b9624..d8aa5e633 100644 --- a/docs/Documentation/SpawnStatic.html +++ b/docs/Documentation/SpawnStatic.html @@ -436,6 +436,7 @@ ptional) The name of the new static.

    + #number SPAWNSTATIC.SpawnIndex diff --git a/docs/Documentation/Spot.html b/docs/Documentation/Spot.html index 5fdc3b305..ead3792db 100644 --- a/docs/Documentation/Spot.html +++ b/docs/Documentation/Spot.html @@ -765,7 +765,6 @@ true if it is lasing

    - SPOT.ScheduleID @@ -779,7 +778,6 @@ true if it is lasing

    - SPOT.SpotIR @@ -793,7 +791,6 @@ true if it is lasing

    - SPOT.SpotLaser @@ -807,7 +804,6 @@ true if it is lasing

    - SPOT.Target diff --git a/docs/Documentation/Task.html b/docs/Documentation/Task.html index dd18375a7..69575e798 100644 --- a/docs/Documentation/Task.html +++ b/docs/Documentation/Task.html @@ -237,6 +237,12 @@ TASK:GetID()

    Gets the ID of the Task

    + + + + TASK:GetInfo(TaskInfo) + +

    Gets the Information of the Task

    @@ -417,6 +423,12 @@ TASK.MenuAssigned + + + + TASK:MenuMarkToGroup(TaskGroup) + + @@ -1333,6 +1345,33 @@ TaskID

    + +TASK:GetInfo(TaskInfo) + +
    +
    + +

    Gets the Information of the Task

    + +

    Parameter

    +
      +
    • + +

      #string TaskInfo : +The key and title of the task information.

      + +
    • +
    +

    Return value

    + +

    #string: +TaskInfoText The Task info text.

    + +
    +
    +
    +
    + TASK:GetMission() @@ -1887,6 +1926,27 @@ true if Unit is part of the Task.

    + +
    +
    +
    + + +TASK:MenuMarkToGroup(TaskGroup) + +
    +
    + + + +

    Parameter

    +
    diff --git a/docs/Documentation/Utils.html b/docs/Documentation/Utils.html index 13adb0b4a..3fbab0987 100644 --- a/docs/Documentation/Utils.html +++ b/docs/Documentation/Utils.html @@ -236,6 +236,12 @@ which are excellent tools to be reused in an OO environment!.

    UTILS.FeetToMeters(feet) + + + + UTILS.GetMarkID() + + @@ -332,6 +338,12 @@ use negative idp for rounding ahead of decimal place, positive for rounding afte UTILS.ToRadian(angle) + + + + UTILS._MarkID + + @@ -637,6 +649,22 @@ use negative idp for rounding ahead of decimal place, positive for rounding afte
    + +UTILS.GetMarkID() + +
    +
    + + + + +

    get a new mark ID for markings

    + +
    +
    +
    +
    + UTILS.IsInstanceOf(object, className) @@ -943,6 +971,20 @@ use negative idp for rounding ahead of decimal place, positive for rounding afte + +
    +
    +
    + + #number + +UTILS._MarkID + +
    +
    + + +
    From 560f551ed791bafdf1375d611922910ac3942369 Mon Sep 17 00:00:00 2001 From: FlightControl_Master Date: Mon, 11 Sep 2017 14:54:08 +0200 Subject: [PATCH 2/3] Progress --- Moose Development/Moose/Core/Point.lua | 82 ++++++++++++++++++- Moose Development/Moose/Core/Set.lua | 8 +- .../Moose/Functional/Detection.lua | 12 +-- Moose Development/Moose/Tasking/Task.lua | 8 +- Moose Development/Moose/Tasking/Task_A2G.lua | 43 +++++++--- Moose Development/Moose/Utilities/Utils.lua | 2 +- .../Moose/Wrapper/Positionable.lua | 1 + 7 files changed, 128 insertions(+), 28 deletions(-) diff --git a/Moose Development/Moose/Core/Point.lua b/Moose Development/Moose/Core/Point.lua index 25ea827ea..3206696d5 100644 --- a/Moose Development/Moose/Core/Point.lua +++ b/Moose Development/Moose/Core/Point.lua @@ -301,9 +301,55 @@ do -- COORDINATE end + --- Set the heading of the coordinate, if applicable. + -- @param #COORDINATE self function COORDINATE:SetHeading( Heading ) self.Heading = Heading end + + + --- Get the heading of the coordinate, if applicable. + -- @param #COORDINATE self + -- @return #number or nil + function COORDINATE:GetHeading() + return self.Heading + end + + + --- Set the velocity of the COORDINATE. + -- @param #COORDINATE self + -- @param #string Velocity Velocity in meters per second. + function COORDINATE:SetVelocity( Velocity ) + self.Velocity = Velocity + end + + + --- Return the velocity of the COORDINATE. + -- @param #COORDINATE self + -- @return #number Velocity in meters per second. + function COORDINATE:GetVelocity() + local Velocity = self.Velocity + return Velocity or 0 + end + + + --- Return velocity text of the COORDINATE. + -- @param #COORDINATE self + -- @return #string + function COORDINATE:GetMovingText( Settings ) + + local MovingText = "" + + local Velocity = self:GetVelocity() + + if Velocity == 0 then + MovingText = MovingText .. "stationary " + else + MovingText = MovingText .. "moving at " .. self:GetVelocityText( Settings ) .. " " .. self:GetHeadingText( Settings ) + end + + return MovingText + end --- Return a direction vector Vec3 from COORDINATE to the COORDINATE. @@ -359,6 +405,7 @@ do -- COORDINATE return ( ( TargetVec3.x - SourceVec3.x ) ^ 2 + ( TargetVec3.z - SourceVec3.z ) ^ 2 ) ^ 0.5 end + --- Return the 3D distance in meters between the target COORDINATE and the COORDINATE. -- @param #COORDINATE self -- @param #COORDINATE TargetCoordinate The target COORDINATE. @@ -425,6 +472,39 @@ do -- COORDINATE end + + --- Return the velocity text of the COORDINATE. + -- @param #COORDINATE self + -- @return #string Velocity text. + function COORDINATE:GetVelocityText( Settings ) + local Velocity = self:GetVelocity() + local Settings = Settings or _SETTINGS + if Velocity then + if Settings:IsMetric() then + return UTILS.MpsToKmph( Velocity ) .. " km/h" + else + return UTILS.MpsToKmph( Velocity ) / 1.852 .. " mph" + end + else + return "" + end + end + + + --- Return the heading text of the COORDINATE. + -- @param #COORDINATE self + -- @return #string Heading text. + function COORDINATE:GetHeadingText( Settings ) + local Heading = self.Heading + local Settings = Settings or _SETTINGS + if Heading then + return Heading .. "°" + else + return "" + end + end + + --- Provides a Bearing / Range string -- @param #COORDINATE self -- @param #number AngleRadians The angle in randians @@ -723,7 +803,7 @@ do -- COORDINATE -- local TargetCoord = TargetGroup:GetCoordinate() -- local MarkGroup = GROUP:FindByName( "AttackGroup" ) -- local MarkID = TargetCoord:MarkToGroup( "This is a target for the attack group", AttackGroup ) - function COORDINATE:MarkToCoalition( MarkText, MarkGroup ) + function COORDINATE:MarkToGroup( MarkText, MarkGroup ) local MarkID = UTILS.GetMarkID() trigger.action.markToGroup( MarkID, MarkText, self:GetVec3(), MarkGroup:GetID() ) return MarkID diff --git a/Moose Development/Moose/Core/Set.lua b/Moose Development/Moose/Core/Set.lua index f89224259..8ccb7611f 100644 --- a/Moose Development/Moose/Core/Set.lua +++ b/Moose Development/Moose/Core/Set.lua @@ -1788,16 +1788,18 @@ end function SET_UNIT:CalculateThreatLevelA2G() local MaxThreatLevelA2G = 0 + local MaxThreatText = "" for UnitName, UnitData in pairs( self:GetSet() ) do local ThreatUnit = UnitData -- Wrapper.Unit#UNIT - local ThreatLevelA2G = ThreatUnit:GetThreatLevel() + local ThreatLevelA2G, ThreatText = ThreatUnit:GetThreatLevel() if ThreatLevelA2G > MaxThreatLevelA2G then MaxThreatLevelA2G = ThreatLevelA2G + MaxThreatText = ThreatText end end - self:T3( MaxThreatLevelA2G ) - return MaxThreatLevelA2G + self:F( { MaxThreatLevelA2G = MaxThreatLevelA2G, MaxThreatText = MaxThreatText } ) + return MaxThreatLevelA2G, MaxThreatText end diff --git a/Moose Development/Moose/Functional/Detection.lua b/Moose Development/Moose/Functional/Detection.lua index 916b10f85..729be5f40 100644 --- a/Moose Development/Moose/Functional/Detection.lua +++ b/Moose Development/Moose/Functional/Detection.lua @@ -1644,7 +1644,7 @@ do -- DETECTION_BASE DetectedItem.Coordinate = Coordinate DetectedItem.Coordinate:SetHeading( DetectedItemUnit:GetHeading() ) DetectedItem.Coordinate.y = DetectedItemUnit:GetAltitude() - DetectedItem.Coordinate.Speed = DetectedItemUnit:GetVelocityMPS() + DetectedItem.Coordinate:SetVelocity( DetectedItemUnit:GetVelocityMPS() ) end end end @@ -1675,7 +1675,7 @@ do -- DETECTION_BASE local DetectedSet = DetectedItem.Set if DetectedItem then - DetectedItem.ThreatLevel = DetectedSet:CalculateThreatLevelA2G() + DetectedItem.ThreatLevel, DetectedItem.ThreatText = DetectedSet:CalculateThreatLevelA2G() end end @@ -1691,10 +1691,10 @@ do -- DETECTION_BASE local DetectedItem = self:GetDetectedItem( Index ) if DetectedItem then - return DetectedItem.ThreatLevel or 0 + return DetectedItem.ThreatLevel or 0, DetectedItem.ThreatText or "" end - return nil + return nil, "" end @@ -2423,9 +2423,9 @@ do -- DETECTION_AREAS -- @param #DETECTION_BASE.DetectedItem DetectedItem function DETECTION_AREAS:CalculateIntercept( DetectedItem ) - local DetectedSpeed = DetectedItem.Coordinate.Speed - local DetectedHeading = DetectedItem.Coordinate.Heading local DetectedCoord = DetectedItem.Coordinate + local DetectedSpeed = DetectedCoord:GetVelocity() + local DetectedHeading = DetectedCoord:GetHeading() if self.Intercept then local DetectedSet = DetectedItem.Set diff --git a/Moose Development/Moose/Tasking/Task.lua b/Moose Development/Moose/Tasking/Task.lua index 942a36065..20ef9763c 100644 --- a/Moose Development/Moose/Tasking/Task.lua +++ b/Moose Development/Moose/Tasking/Task.lua @@ -870,13 +870,11 @@ function TASK:MenuMarkToGroup( TaskGroup ) local Coordinate = self:GetInfo( "Coordinates" ) -- Core.Point#COORDINATE local Briefing = self:GetTaskBriefing() - local GroupID = TaskGroup:GetID() - local Vec3 = Coordinate:GetVec3() - self:F( { Coordinate = Vec3, Briefing = Briefing, GroupID = GroupID } ) + self:F( { Briefing = Briefing, Coordinate = Coordinate } ) - trigger.action.markToGroup( 1, Briefing, Vec3, GroupID ) - --trigger.action.markToAll( 1, Briefing, Vec3 ) + --Coordinate:MarkToGroup( Briefing, TaskGroup ) + Coordinate:MarkToAll( Briefing ) end --- Report the task status. diff --git a/Moose Development/Moose/Tasking/Task_A2G.lua b/Moose Development/Moose/Tasking/Task_A2G.lua index 9760326c4..84322d342 100644 --- a/Moose Development/Moose/Tasking/Task_A2G.lua +++ b/Moose Development/Moose/Tasking/Task_A2G.lua @@ -323,13 +323,18 @@ do -- TASK_A2G_SEAD Mission:AddTask( self ) - self:SetBriefing( - TaskBriefing or - "Execute a Suppression of Enemy Air Defenses.\n" - ) - self:UpdateTaskInfo() + local ThreatLevel, ThreatText = TargetSetUnit:CalculateThreatLevelA2G() + local TargetUnit = TargetSetUnit:GetFirst() + local TargetCoord = TargetUnit:GetCoordinate() -- Core.Point#COORDINATE + + self:SetBriefing( + TaskBriefing or + "Execute a Suppression of Enemy Air Defenses. " .. + ThreatText .. " targets to be expected. Target is " .. TargetCoord:GetMovingText() .. "." + ) + return self end @@ -466,12 +471,17 @@ do -- TASK_A2G_BAI Mission:AddTask( self ) + self:UpdateTaskInfo() + + local ThreatLevel, ThreatText = TargetSetUnit:CalculateThreatLevelA2G() + local TargetUnit = TargetSetUnit:GetFirst() + local TargetCoord = TargetUnit:GetCoordinate() -- Core.Point#COORDINATE + self:SetBriefing( TaskBriefing or - "Execute a Battlefield Air Interdiction of a group of enemy targets.\n" + "Execute a Battlefield Air Interdiction of a group of enemy targets. " .. + ThreatText .. " targets to be expected. Target is " .. TargetCoord:GetMovingText() .. "." ) - - self:UpdateTaskInfo() return self end @@ -610,13 +620,20 @@ do -- TASK_A2G_CAS Mission:AddTask( self ) + self:UpdateTaskInfo() + + local ThreatLevel, ThreatText = TargetSetUnit:CalculateThreatLevelA2G() + local TargetUnit = TargetSetUnit:GetFirst() + local TargetCoord = TargetUnit:GetCoordinate() -- Core.Point#COORDINATE + self:SetBriefing( TaskBriefing or - "Execute a Close Air Support for a group of enemy targets.\n" .. - "Beware of friendlies at the vicinity!\n" + "Execute a Close Air Support for a group of enemy targets. " .. + "Beware of friendlies at the vicinity! " .. + ThreatText .. " targets to be expected. Target is " .. TargetCoord:GetMovingText() .. "." + ) - self:UpdateTaskInfo() return self end @@ -626,7 +643,9 @@ do -- TASK_A2G_CAS local TargetCoordinate = self.Detection and self.Detection:GetDetectedItemCoordinate( self.DetectedItemIndex ) or self.TargetSetUnit:GetFirst():GetCoordinate() self:SetInfo( "Coordinates", TargetCoordinate, 0 ) - self:SetInfo( "Threat", "[" .. string.rep( "■", self.Detection and self.Detection:GetDetectedItemThreatLevel( self.DetectedItemIndex ) or self.TargetSetUnit:CalculateThreatLevelA2G() ) .. "]", 11 ) + local ThreatLevel = self.Detection and self.Detection:GetDetectedItemThreatLevel( self.DetectedItemIndex ) or self.TargetSetUnit:CalculateThreatLevelA2G() + + self:SetInfo( "Threat", "[" .. string.rep( "■", ThreatLevel ) .. "]", 11 ) if self.Detection then local DetectedItemsCount = self.TargetSetUnit:Count() diff --git a/Moose Development/Moose/Utilities/Utils.lua b/Moose Development/Moose/Utilities/Utils.lua index 44d7f24e3..475d228ac 100644 --- a/Moose Development/Moose/Utilities/Utils.lua +++ b/Moose Development/Moose/Utilities/Utils.lua @@ -32,7 +32,7 @@ FLARECOLOR = trigger.flareColor -- #FLARECOLOR --- Utilities static class. -- @type UTILS UTILS = { - _MarkID = 0 + _MarkID = 1 } --- Function to infer instance of an object diff --git a/Moose Development/Moose/Wrapper/Positionable.lua b/Moose Development/Moose/Wrapper/Positionable.lua index 1005dde1b..8c6816917 100644 --- a/Moose Development/Moose/Wrapper/Positionable.lua +++ b/Moose Development/Moose/Wrapper/Positionable.lua @@ -166,6 +166,7 @@ function POSITIONABLE:GetCoordinate() local PositionableCoordinate = COORDINATE:NewFromVec3( PositionableVec3 ) PositionableCoordinate:SetHeading( self:GetHeading() ) + PositionableCoordinate:SetVelocity( self:GetVelocityMPS() ) self:T2( PositionableCoordinate ) return PositionableCoordinate From f2db40db6e975ff4938c7f60d82819c778b534ae Mon Sep 17 00:00:00 2001 From: FlightControl_Master Date: Mon, 11 Sep 2017 14:59:07 +0200 Subject: [PATCH 3/3] To gruop --- Moose Development/Moose/Tasking/Task.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Moose Development/Moose/Tasking/Task.lua b/Moose Development/Moose/Tasking/Task.lua index 20ef9763c..7000f09ac 100644 --- a/Moose Development/Moose/Tasking/Task.lua +++ b/Moose Development/Moose/Tasking/Task.lua @@ -873,8 +873,8 @@ function TASK:MenuMarkToGroup( TaskGroup ) self:F( { Briefing = Briefing, Coordinate = Coordinate } ) - --Coordinate:MarkToGroup( Briefing, TaskGroup ) - Coordinate:MarkToAll( Briefing ) + Coordinate:MarkToGroup( Briefing, TaskGroup ) + --Coordinate:MarkToAll( Briefing ) end --- Report the task status.