diff --git a/Moose Development/Moose/Core/Point.lua b/Moose Development/Moose/Core/Point.lua index e31653d0e..cfb27e42f 100644 --- a/Moose Development/Moose/Core/Point.lua +++ b/Moose Development/Moose/Core/Point.lua @@ -38,6 +38,8 @@ -- -- Hereby the change log: -- +-- 2017-02-18: POINT_VEC3:**NewFromVec2( Vec2, LandHeightAdd )** added. +-- -- 2016-08-12: POINT_VEC3:**Translate( Distance, Angle )** added. -- -- 2016-08-06: Made PointVec3 and Vec3, PointVec2 and Vec2 terminology used in the code consistent. @@ -127,6 +129,24 @@ function POINT_VEC3:New( x, y, z ) return self end +--- Create a new POINT_VEC3 object from Vec2 coordinates. +-- @param #POINT_VEC3 self +-- @param Dcs.DCSTypes#Vec2 Vec2 The Vec2 point. +-- @return Core.Point#POINT_VEC3 self +function POINT_VEC3:NewFromVec2( Vec2, LandHeightAdd ) + + local LandHeight = land.getHeight( Vec2 ) + + LandHeightAdd = LandHeightAdd or 0 + LandHeight = LandHeight + LandHeightAdd + + self = self:New( Vec2.x, LandHeight, Vec2.y ) + + self:F2( self ) + + return self +end + --- Create a new POINT_VEC3 object from Vec3 coordinates. -- @param #POINT_VEC3 self -- @param Dcs.DCSTypes#Vec3 Vec3 The Vec3 point. diff --git a/Moose Development/Moose/Core/Zone.lua b/Moose Development/Moose/Core/Zone.lua index d096962aa..d60a8cb14 100644 --- a/Moose Development/Moose/Core/Zone.lua +++ b/Moose Development/Moose/Core/Zone.lua @@ -1,4 +1,5 @@ ---- This module contains the ZONE classes, inherited from @{Zone#ZONE_BASE}. +--- This core module contains the ZONE classes, inherited from @{Zone#ZONE_BASE}. +-- -- There are essentially two core functions that zones accomodate: -- -- * Test if an object is within the zone boundaries. @@ -24,94 +25,111 @@ -- -- === -- --- 1) @{Zone#ZONE_BASE} class, extends @{Base#BASE} --- ================================================ +-- # 1) @{Zone#ZONE_BASE} class, extends @{Base#BASE} +-- -- This class is an abstract BASE class for derived classes, and is not meant to be instantiated. -- --- ### 1.1) Each zone has a name: +-- ## 1.1) Each zone has a name: -- -- * @{#ZONE_BASE.GetName}(): Returns the name of the zone. -- --- ### 1.2) Each zone implements two polymorphic functions defined in @{Zone#ZONE_BASE}: +-- ## 1.2) Each zone implements two polymorphic functions defined in @{Zone#ZONE_BASE}: -- -- * @{#ZONE_BASE.IsPointVec2InZone}(): Returns if a @{Point#POINT_VEC2} is within the zone. -- * @{#ZONE_BASE.IsPointVec3InZone}(): Returns if a @{Point#POINT_VEC3} is within the zone. -- --- ### 1.3) A zone has a probability factor that can be set to randomize a selection between zones: +-- ## 1.3) A zone has a probability factor that can be set to randomize a selection between zones: -- -- * @{#ZONE_BASE.SetRandomizeProbability}(): Set the randomization probability of a zone to be selected, taking a value between 0 and 1 ( 0 = 0%, 1 = 100% ) -- * @{#ZONE_BASE.GetRandomizeProbability}(): Get the randomization probability of a zone to be selected, passing a value between 0 and 1 ( 0 = 0%, 1 = 100% ) -- * @{#ZONE_BASE.GetZoneMaybe}(): Get the zone taking into account the randomization probability. nil is returned if this zone is not a candidate. -- --- ### 1.4) A zone manages Vectors: +-- ## 1.4) A zone manages Vectors: -- -- * @{#ZONE_BASE.GetVec2}(): Returns the @{DCSTypes#Vec2} coordinate of the zone. -- * @{#ZONE_BASE.GetRandomVec2}(): Define a random @{DCSTypes#Vec2} within the zone. -- --- ### 1.5) A zone has a bounding square: +-- ## 1.5) A zone has a bounding square: -- -- * @{#ZONE_BASE.GetBoundingSquare}(): Get the outer most bounding square of the zone. -- --- ### 1.6) A zone can be marked: +-- ## 1.6) A zone can be marked: -- -- * @{#ZONE_BASE.SmokeZone}(): Smokes the zone boundaries in a color. -- * @{#ZONE_BASE.FlareZone}(): Flares the zone boundaries in a color. -- -- === -- --- 2) @{Zone#ZONE_RADIUS} class, extends @{Zone#ZONE_BASE} --- ======================================================= +-- # 2) @{Zone#ZONE_RADIUS} class, extends @{Zone#ZONE_BASE} +-- -- The ZONE_RADIUS class defined by a zone name, a location and a radius. -- This class implements the inherited functions from Core.Zone#ZONE_BASE taking into account the own zone format and properties. -- --- ### 2.1) @{Zone#ZONE_RADIUS} constructor: +-- ## 2.1) @{Zone#ZONE_RADIUS} constructor -- --- * @{#ZONE_BASE.New}(): Constructor. +-- * @{#ZONE_RADIUS.New}(): Constructor. -- --- ### 2.2) Manage the radius of the zone: +-- ## 2.2) Manage the radius of the zone -- --- * @{#ZONE_BASE.SetRadius}(): Sets the radius of the zone. --- * @{#ZONE_BASE.GetRadius}(): Returns the radius of the zone. +-- * @{#ZONE_RADIUS.SetRadius}(): Sets the radius of the zone. +-- * @{#ZONE_RADIUS.GetRadius}(): Returns the radius of the zone. -- --- ### 2.3) Manage the location of the zone: +-- ## 2.3) Manage the location of the zone -- --- * @{#ZONE_BASE.SetVec2}(): Sets the @{DCSTypes#Vec2} of the zone. --- * @{#ZONE_BASE.GetVec2}(): Returns the @{DCSTypes#Vec2} of the zone. --- * @{#ZONE_BASE.GetVec3}(): Returns the @{DCSTypes#Vec3} of the zone, taking an additional height parameter. +-- * @{#ZONE_RADIUS.SetVec2}(): Sets the @{DCSTypes#Vec2} of the zone. +-- * @{#ZONE_RADIUS.GetVec2}(): Returns the @{DCSTypes#Vec2} of the zone. +-- * @{#ZONE_RADIUS.GetVec3}(): Returns the @{DCSTypes#Vec3} of the zone, taking an additional height parameter. +-- +-- ## 2.4) Zone point randomization +-- +-- Various functions exist to find random points within the zone. +-- +-- * @{#ZONE_RADIUS.GetRandomVec2}(): Gets a random 2D point in the zone. +-- * @{#ZONE_RADIUS.GetRandomPointVec2}(): Gets a @{Point#POINT_VEC2} object representing a random 2D point in the zone. +-- * @{#ZONE_RADIUS.GetRandomPointVec3}(): Gets a @{Point#POINT_VEC3} object representing a random 3D point in the zone. Note that the height of the point is at landheight. -- -- === -- --- 3) @{Zone#ZONE} class, extends @{Zone#ZONE_RADIUS} --- ========================================== +-- # 3) @{Zone#ZONE} class, extends @{Zone#ZONE_RADIUS} +-- -- The ZONE class, defined by the zone name as defined within the Mission Editor. -- This class implements the inherited functions from {Core.Zone#ZONE_RADIUS} taking into account the own zone format and properties. -- -- === -- --- 4) @{Zone#ZONE_UNIT} class, extends @{Zone#ZONE_RADIUS} --- ======================================================= +-- # 4) @{Zone#ZONE_UNIT} class, extends @{Zone#ZONE_RADIUS} +-- -- The ZONE_UNIT class defined by a zone around a @{Unit#UNIT} with a radius. -- This class implements the inherited functions from @{Zone#ZONE_RADIUS} taking into account the own zone format and properties. -- -- === -- --- 5) @{Zone#ZONE_GROUP} class, extends @{Zone#ZONE_RADIUS} --- ======================================================= +-- # 5) @{Zone#ZONE_GROUP} class, extends @{Zone#ZONE_RADIUS} +-- -- The ZONE_GROUP class defines by a zone around a @{Group#GROUP} with a radius. The current leader of the group defines the center of the zone. -- This class implements the inherited functions from @{Zone#ZONE_RADIUS} taking into account the own zone format and properties. -- -- === -- --- 6) @{Zone#ZONE_POLYGON_BASE} class, extends @{Zone#ZONE_BASE} --- ======================================================== +-- # 6) @{Zone#ZONE_POLYGON_BASE} class, extends @{Zone#ZONE_BASE} +-- -- The ZONE_POLYGON_BASE class defined by a sequence of @{Group#GROUP} waypoints within the Mission Editor, forming a polygon. -- This class implements the inherited functions from @{Zone#ZONE_RADIUS} taking into account the own zone format and properties. -- This class is an abstract BASE class for derived classes, and is not meant to be instantiated. -- +-- ## 6.1) Zone point randomization +-- +-- Various functions exist to find random points within the zone. +-- +-- * @{#ZONE_POLYGON_BASE.GetRandomVec2}(): Gets a random 2D point in the zone. +-- * @{#ZONE_POLYGON_BASE.GetRandomPointVec2}(): Return a @{Point#POINT_VEC2} object representing a random 2D point within the zone. +-- * @{#ZONE_POLYGON_BASE.GetRandomPointVec3}(): Return a @{Point#POINT_VEC3} object representing a random 3D point at landheight within the zone. +-- +-- -- === -- --- 7) @{Zone#ZONE_POLYGON} class, extends @{Zone#ZONE_POLYGON_BASE} --- ================================================================ +-- # 7) @{Zone#ZONE_POLYGON} class, extends @{Zone#ZONE_POLYGON_BASE} +-- -- The ZONE_POLYGON class defined by a sequence of @{Group#GROUP} waypoints within the Mission Editor, forming a polygon. -- This class implements the inherited functions from @{Zone#ZONE_RADIUS} taking into account the own zone format and properties. -- @@ -127,6 +145,14 @@ -- -- Hereby the change log: -- +-- 2017-02-18: ZONE_POLYGON_BASE:**GetRandomPointVec2()** added. +-- +-- 2017-02-18: ZONE_POLYGON_BASE:**GetRandomPointVec3()** added. +-- +-- 2017-02-18: ZONE_RADIUS:**GetRandomPointVec3( inner, outer )** added. +-- +-- 2017-02-18: ZONE_RADIUS:**GetRandomPointVec2( inner, outer )** added. +-- -- 2016-08-15: ZONE_BASE:**GetName()** added. -- -- 2016-08-15: ZONE_BASE:**SetZoneProbability( ZoneProbability )** added. @@ -212,6 +238,7 @@ function ZONE_BASE:GetVec2() return nil end + --- Define a random @{DCSTypes#Vec2} within the zone. -- @param #ZONE_BASE self -- @return Dcs.DCSTypes#Vec2 The Vec2 coordinates. @@ -219,6 +246,13 @@ function ZONE_BASE:GetRandomVec2() return nil end +--- Define a random @{Point#POINT_VEC2} within the zone. +-- @param #ZONE_BASE self +-- @return Core.Point#POINT_VEC2 The PointVec2 coordinates. +function ZONE_BASE:GetRandomPointVec2() + return nil +end + --- Get the bounding square the zone. -- @param #ZONE_BASE self -- @return #nil The bounding square. @@ -447,12 +481,12 @@ function ZONE_RADIUS:IsPointVec3InZone( Vec3 ) return InZone end ---- Returns a random location within the zone. +--- Returns a random Vec2 location within the zone. -- @param #ZONE_RADIUS self --- @param #number inner minimal distance from the center of the zone --- @param #number outer minimal distance from the outer edge of the zone +-- @param #number inner (optional) Minimal distance from the center of the zone. Default is 0. +-- @param #number outer (optional) Maximal distance from the outer edge of the zone. Default is the radius of the zone. -- @return Dcs.DCSTypes#Vec2 The random location within the zone. -function ZONE_RADIUS:GetRandomVec2(inner, outer) +function ZONE_RADIUS:GetRandomVec2( inner, outer ) self:F( self.ZoneName, inner, outer ) local Point = {} @@ -469,6 +503,36 @@ function ZONE_RADIUS:GetRandomVec2(inner, outer) return Point end +--- Returns a @{Point#POINT_VEC2} object reflecting a random 2D location within the zone. +-- @param #ZONE_RADIUS self +-- @param #number inner (optional) Minimal distance from the center of the zone. Default is 0. +-- @param #number outer (optional) Maximal distance from the outer edge of the zone. Default is the radius of the zone. +-- @return Core.Point#POINT_VEC2 The @{Point#POINT_VEC2} object reflecting the random 3D location within the zone. +function ZONE_RADIUS:GetRandomPointVec2( inner, outer ) + self:F( self.ZoneName, inner, outer ) + + local PointVec2 = POINT_VEC2:NewFromVec2( self:GetRandomVec2() ) + + self:T3( { PointVec2 } ) + + return PointVec2 +end + +--- Returns a @{Point#POINT_VEC3} object reflecting a random 3D location within the zone. +-- @param #ZONE_RADIUS self +-- @param #number inner (optional) Minimal distance from the center of the zone. Default is 0. +-- @param #number outer (optional) Maximal distance from the outer edge of the zone. Default is the radius of the zone. +-- @return Core.Point#POINT_VEC3 The @{Point#POINT_VEC3} object reflecting the random 3D location within the zone. +function ZONE_RADIUS:GetRandomPointVec3( inner, outer ) + self:F( self.ZoneName, inner, outer ) + + local PointVec3 = POINT_VEC3:NewFromVec2( self:GetRandomVec2() ) + + self:T3( { PointVec3 } ) + + return PointVec3 +end + --- The ZONE class, defined by the zone name as defined within the Mission Editor. The location and the radius are automatically collected from the mission settings. @@ -783,6 +847,33 @@ function ZONE_POLYGON_BASE:GetRandomVec2() return Vec2 end +--- Return a @{Point#POINT_VEC2} object representing a random 2D point at landheight within the zone. +-- @param #ZONE_POLYGON_BASE self +-- @return @{Point#POINT_VEC2} +function ZONE_POLYGON_BASE:GetRandomPointVec2() + self:F2() + + local PointVec2 = POINT_VEC2:NewFromVec2( self:GetRandomVec2() ) + + self:T2( PointVec2 ) + + return PointVec2 +end + +--- Return a @{Point#POINT_VEC3} object representing a random 3D point at landheight within the zone. +-- @param #ZONE_POLYGON_BASE self +-- @return @{Point#POINT_VEC3} +function ZONE_POLYGON_BASE:GetRandomPointVec3() + self:F2() + + local PointVec3 = POINT_VEC3:NewFromVec2( self:GetRandomVec2() ) + + self:T2( PointVec3 ) + + return PointVec3 +end + + --- Get the bounding square the zone. -- @param #ZONE_POLYGON_BASE self -- @return #ZONE_POLYGON_BASE.BoundingSquare The bounding square. diff --git a/Moose Development/ReleaseNotes.txt b/Moose Development/ReleaseNotes.txt index 6686615c8..4b2258255 100644 --- a/Moose Development/ReleaseNotes.txt +++ b/Moose Development/ReleaseNotes.txt @@ -1,3 +1,14 @@ +2017-02-08 + + - Reworked some vector functions. + -- POINT_VEC3:NewFromVec2( Vec2, LandHeightAdd ) added. + -- ZONE_RADIUS:GetRandomPointVec2( inner, outer ) added. + -- ZONE_RADIUS:GetRandomPointVec3( inner, outer ) added. + -- ZONE_POLYGON_BASE:GetRandomPointVec2() added. + -- ZONE_POLYGON_BASE:GetRandomPointVec3() added. + + + 2016-12-06 - Renamed the documentation references following the structure of the files. diff --git a/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua b/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua index e18ea7e6c..45f88da4d 100644 --- a/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua +++ b/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua @@ -1,5 +1,5 @@ env.info( '*** MOOSE STATIC INCLUDE START *** ' ) -env.info( 'Moose Generation Timestamp: 20170214_1649' ) +env.info( 'Moose Generation Timestamp: 20170218_2236' ) local base = _G Include = {} @@ -6069,7 +6069,8 @@ do end ---- This module contains the ZONE classes, inherited from @{Zone#ZONE_BASE}. +--- This core module contains the ZONE classes, inherited from @{Zone#ZONE_BASE}. +-- -- There are essentially two core functions that zones accomodate: -- -- * Test if an object is within the zone boundaries. @@ -6095,94 +6096,111 @@ end -- -- === -- --- 1) @{Zone#ZONE_BASE} class, extends @{Base#BASE} --- ================================================ +-- # 1) @{Zone#ZONE_BASE} class, extends @{Base#BASE} +-- -- This class is an abstract BASE class for derived classes, and is not meant to be instantiated. -- --- ### 1.1) Each zone has a name: +-- ## 1.1) Each zone has a name: -- -- * @{#ZONE_BASE.GetName}(): Returns the name of the zone. -- --- ### 1.2) Each zone implements two polymorphic functions defined in @{Zone#ZONE_BASE}: +-- ## 1.2) Each zone implements two polymorphic functions defined in @{Zone#ZONE_BASE}: -- -- * @{#ZONE_BASE.IsPointVec2InZone}(): Returns if a @{Point#POINT_VEC2} is within the zone. -- * @{#ZONE_BASE.IsPointVec3InZone}(): Returns if a @{Point#POINT_VEC3} is within the zone. -- --- ### 1.3) A zone has a probability factor that can be set to randomize a selection between zones: +-- ## 1.3) A zone has a probability factor that can be set to randomize a selection between zones: -- -- * @{#ZONE_BASE.SetRandomizeProbability}(): Set the randomization probability of a zone to be selected, taking a value between 0 and 1 ( 0 = 0%, 1 = 100% ) -- * @{#ZONE_BASE.GetRandomizeProbability}(): Get the randomization probability of a zone to be selected, passing a value between 0 and 1 ( 0 = 0%, 1 = 100% ) -- * @{#ZONE_BASE.GetZoneMaybe}(): Get the zone taking into account the randomization probability. nil is returned if this zone is not a candidate. -- --- ### 1.4) A zone manages Vectors: +-- ## 1.4) A zone manages Vectors: -- -- * @{#ZONE_BASE.GetVec2}(): Returns the @{DCSTypes#Vec2} coordinate of the zone. -- * @{#ZONE_BASE.GetRandomVec2}(): Define a random @{DCSTypes#Vec2} within the zone. -- --- ### 1.5) A zone has a bounding square: +-- ## 1.5) A zone has a bounding square: -- -- * @{#ZONE_BASE.GetBoundingSquare}(): Get the outer most bounding square of the zone. -- --- ### 1.6) A zone can be marked: +-- ## 1.6) A zone can be marked: -- -- * @{#ZONE_BASE.SmokeZone}(): Smokes the zone boundaries in a color. -- * @{#ZONE_BASE.FlareZone}(): Flares the zone boundaries in a color. -- -- === -- --- 2) @{Zone#ZONE_RADIUS} class, extends @{Zone#ZONE_BASE} --- ======================================================= +-- # 2) @{Zone#ZONE_RADIUS} class, extends @{Zone#ZONE_BASE} +-- -- The ZONE_RADIUS class defined by a zone name, a location and a radius. -- This class implements the inherited functions from Core.Zone#ZONE_BASE taking into account the own zone format and properties. -- --- ### 2.1) @{Zone#ZONE_RADIUS} constructor: +-- ## 2.1) @{Zone#ZONE_RADIUS} constructor -- --- * @{#ZONE_BASE.New}(): Constructor. +-- * @{#ZONE_RADIUS.New}(): Constructor. -- --- ### 2.2) Manage the radius of the zone: +-- ## 2.2) Manage the radius of the zone -- --- * @{#ZONE_BASE.SetRadius}(): Sets the radius of the zone. --- * @{#ZONE_BASE.GetRadius}(): Returns the radius of the zone. +-- * @{#ZONE_RADIUS.SetRadius}(): Sets the radius of the zone. +-- * @{#ZONE_RADIUS.GetRadius}(): Returns the radius of the zone. -- --- ### 2.3) Manage the location of the zone: +-- ## 2.3) Manage the location of the zone -- --- * @{#ZONE_BASE.SetVec2}(): Sets the @{DCSTypes#Vec2} of the zone. --- * @{#ZONE_BASE.GetVec2}(): Returns the @{DCSTypes#Vec2} of the zone. --- * @{#ZONE_BASE.GetVec3}(): Returns the @{DCSTypes#Vec3} of the zone, taking an additional height parameter. +-- * @{#ZONE_RADIUS.SetVec2}(): Sets the @{DCSTypes#Vec2} of the zone. +-- * @{#ZONE_RADIUS.GetVec2}(): Returns the @{DCSTypes#Vec2} of the zone. +-- * @{#ZONE_RADIUS.GetVec3}(): Returns the @{DCSTypes#Vec3} of the zone, taking an additional height parameter. +-- +-- ## 2.4) Zone point randomization +-- +-- Various functions exist to find random points within the zone. +-- +-- * @{#ZONE_RADIUS.GetRandomVec2}(): Gets a random 2D point in the zone. +-- * @{#ZONE_RADIUS.GetRandomPointVec2}(): Gets a @{Point#POINT_VEC2} object representing a random 2D point in the zone. +-- * @{#ZONE_RADIUS.GetRandomPointVec3}(): Gets a @{Point#POINT_VEC3} object representing a random 3D point in the zone. Note that the height of the point is at landheight. -- -- === -- --- 3) @{Zone#ZONE} class, extends @{Zone#ZONE_RADIUS} --- ========================================== +-- # 3) @{Zone#ZONE} class, extends @{Zone#ZONE_RADIUS} +-- -- The ZONE class, defined by the zone name as defined within the Mission Editor. -- This class implements the inherited functions from {Core.Zone#ZONE_RADIUS} taking into account the own zone format and properties. -- -- === -- --- 4) @{Zone#ZONE_UNIT} class, extends @{Zone#ZONE_RADIUS} --- ======================================================= +-- # 4) @{Zone#ZONE_UNIT} class, extends @{Zone#ZONE_RADIUS} +-- -- The ZONE_UNIT class defined by a zone around a @{Unit#UNIT} with a radius. -- This class implements the inherited functions from @{Zone#ZONE_RADIUS} taking into account the own zone format and properties. -- -- === -- --- 5) @{Zone#ZONE_GROUP} class, extends @{Zone#ZONE_RADIUS} --- ======================================================= +-- # 5) @{Zone#ZONE_GROUP} class, extends @{Zone#ZONE_RADIUS} +-- -- The ZONE_GROUP class defines by a zone around a @{Group#GROUP} with a radius. The current leader of the group defines the center of the zone. -- This class implements the inherited functions from @{Zone#ZONE_RADIUS} taking into account the own zone format and properties. -- -- === -- --- 6) @{Zone#ZONE_POLYGON_BASE} class, extends @{Zone#ZONE_BASE} --- ======================================================== +-- # 6) @{Zone#ZONE_POLYGON_BASE} class, extends @{Zone#ZONE_BASE} +-- -- The ZONE_POLYGON_BASE class defined by a sequence of @{Group#GROUP} waypoints within the Mission Editor, forming a polygon. -- This class implements the inherited functions from @{Zone#ZONE_RADIUS} taking into account the own zone format and properties. -- This class is an abstract BASE class for derived classes, and is not meant to be instantiated. -- +-- ## 6.1) Zone point randomization +-- +-- Various functions exist to find random points within the zone. +-- +-- * @{#ZONE_POLYGON_BASE.GetRandomVec2}(): Gets a random 2D point in the zone. +-- * @{#ZONE_POLYGON_BASE.GetRandomPointVec2}(): Return a @{Point#POINT_VEC2} object representing a random 2D point within the zone. +-- * @{#ZONE_POLYGON_BASE.GetRandomPointVec3}(): Return a @{Point#POINT_VEC3} object representing a random 3D point at landheight within the zone. +-- +-- -- === -- --- 7) @{Zone#ZONE_POLYGON} class, extends @{Zone#ZONE_POLYGON_BASE} --- ================================================================ +-- # 7) @{Zone#ZONE_POLYGON} class, extends @{Zone#ZONE_POLYGON_BASE} +-- -- The ZONE_POLYGON class defined by a sequence of @{Group#GROUP} waypoints within the Mission Editor, forming a polygon. -- This class implements the inherited functions from @{Zone#ZONE_RADIUS} taking into account the own zone format and properties. -- @@ -6198,6 +6216,14 @@ end -- -- Hereby the change log: -- +-- 2017-02-18: ZONE_POLYGON_BASE:**GetRandomPointVec2()** added. +-- +-- 2017-02-18: ZONE_POLYGON_BASE:**GetRandomPointVec3()** added. +-- +-- 2017-02-18: ZONE_RADIUS:**GetRandomPointVec3( inner, outer )** added. +-- +-- 2017-02-18: ZONE_RADIUS:**GetRandomPointVec2( inner, outer )** added. +-- -- 2016-08-15: ZONE_BASE:**GetName()** added. -- -- 2016-08-15: ZONE_BASE:**SetZoneProbability( ZoneProbability )** added. @@ -6283,6 +6309,7 @@ function ZONE_BASE:GetVec2() return nil end + --- Define a random @{DCSTypes#Vec2} within the zone. -- @param #ZONE_BASE self -- @return Dcs.DCSTypes#Vec2 The Vec2 coordinates. @@ -6290,6 +6317,13 @@ function ZONE_BASE:GetRandomVec2() return nil end +--- Define a random @{Point#POINT_VEC2} within the zone. +-- @param #ZONE_BASE self +-- @return Core.Point#POINT_VEC2 The PointVec2 coordinates. +function ZONE_BASE:GetRandomPointVec2() + return nil +end + --- Get the bounding square the zone. -- @param #ZONE_BASE self -- @return #nil The bounding square. @@ -6518,12 +6552,12 @@ function ZONE_RADIUS:IsPointVec3InZone( Vec3 ) return InZone end ---- Returns a random location within the zone. +--- Returns a random Vec2 location within the zone. -- @param #ZONE_RADIUS self --- @param #number inner minimal distance from the center of the zone --- @param #number outer minimal distance from the outer edge of the zone +-- @param #number inner (optional) Minimal distance from the center of the zone. Default is 0. +-- @param #number outer (optional) Maximal distance from the outer edge of the zone. Default is the radius of the zone. -- @return Dcs.DCSTypes#Vec2 The random location within the zone. -function ZONE_RADIUS:GetRandomVec2(inner, outer) +function ZONE_RADIUS:GetRandomVec2( inner, outer ) self:F( self.ZoneName, inner, outer ) local Point = {} @@ -6540,6 +6574,36 @@ function ZONE_RADIUS:GetRandomVec2(inner, outer) return Point end +--- Returns a @{Point#POINT_VEC2} object reflecting a random 2D location within the zone. +-- @param #ZONE_RADIUS self +-- @param #number inner (optional) Minimal distance from the center of the zone. Default is 0. +-- @param #number outer (optional) Maximal distance from the outer edge of the zone. Default is the radius of the zone. +-- @return Core.Point#POINT_VEC2 The @{Point#POINT_VEC2} object reflecting the random 3D location within the zone. +function ZONE_RADIUS:GetRandomPointVec2( inner, outer ) + self:F( self.ZoneName, inner, outer ) + + local PointVec2 = POINT_VEC2:NewFromVec2( self:GetRandomVec2() ) + + self:T3( { PointVec2 } ) + + return PointVec2 +end + +--- Returns a @{Point#POINT_VEC3} object reflecting a random 3D location within the zone. +-- @param #ZONE_RADIUS self +-- @param #number inner (optional) Minimal distance from the center of the zone. Default is 0. +-- @param #number outer (optional) Maximal distance from the outer edge of the zone. Default is the radius of the zone. +-- @return Core.Point#POINT_VEC3 The @{Point#POINT_VEC3} object reflecting the random 3D location within the zone. +function ZONE_RADIUS:GetRandomPointVec3( inner, outer ) + self:F( self.ZoneName, inner, outer ) + + local PointVec3 = POINT_VEC3:NewFromVec2( self:GetRandomVec2() ) + + self:T3( { PointVec3 } ) + + return PointVec3 +end + --- The ZONE class, defined by the zone name as defined within the Mission Editor. The location and the radius are automatically collected from the mission settings. @@ -6854,6 +6918,33 @@ function ZONE_POLYGON_BASE:GetRandomVec2() return Vec2 end +--- Return a @{Point#POINT_VEC2} object representing a random 2D point at landheight within the zone. +-- @param #ZONE_POLYGON_BASE self +-- @return @{Point#POINT_VEC2} +function ZONE_POLYGON_BASE:GetRandomPointVec2() + self:F2() + + local PointVec2 = POINT_VEC2:NewFromVec2( self:GetRandomVec2() ) + + self:T2( PointVec2 ) + + return PointVec2 +end + +--- Return a @{Point#POINT_VEC3} object representing a random 3D point at landheight within the zone. +-- @param #ZONE_POLYGON_BASE self +-- @return @{Point#POINT_VEC3} +function ZONE_POLYGON_BASE:GetRandomPointVec3() + self:F2() + + local PointVec3 = POINT_VEC3:NewFromVec2( self:GetRandomVec2() ) + + self:T2( PointVec3 ) + + return PointVec3 +end + + --- Get the bounding square the zone. -- @param #ZONE_POLYGON_BASE self -- @return #ZONE_POLYGON_BASE.BoundingSquare The bounding square. @@ -10013,6 +10104,8 @@ end -- -- Hereby the change log: -- +-- 2017-02-18: POINT_VEC3:**NewFromVec2( Vec2, LandHeightAdd )** added. +-- -- 2016-08-12: POINT_VEC3:**Translate( Distance, Angle )** added. -- -- 2016-08-06: Made PointVec3 and Vec3, PointVec2 and Vec2 terminology used in the code consistent. @@ -10102,6 +10195,24 @@ function POINT_VEC3:New( x, y, z ) return self end +--- Create a new POINT_VEC3 object from Vec2 coordinates. +-- @param #POINT_VEC3 self +-- @param Dcs.DCSTypes#Vec2 Vec2 The Vec2 point. +-- @return Core.Point#POINT_VEC3 self +function POINT_VEC3:NewFromVec2( Vec2, LandHeightAdd ) + + local LandHeight = land.getHeight( Vec2 ) + + LandHeightAdd = LandHeightAdd or 0 + LandHeight = LandHeight + LandHeightAdd + + self = self:New( Vec2.x, LandHeight, Vec2.y ) + + self:F2( self ) + + return self +end + --- Create a new POINT_VEC3 object from Vec3 coordinates. -- @param #POINT_VEC3 self -- @param Dcs.DCSTypes#Vec3 Vec3 The Vec3 point. @@ -22292,9 +22403,8 @@ function MISSILETRAINER:_EventShot( Event ) end else -- TODO: some weapons don't know the target unit... Need to develop a workaround for this. - SCHEDULER:New( TrainerWeapon, TrainerWeapon.destroy, {}, 2 ) - if ( TrainerWeapon:getTypeName() == "9M311" ) then - SCHEDULER:New( TrainerWeapon, TrainerWeapon.destroy, {}, 2 ) + if ( TrainerWeapon:getTypeName() == "9M311" ) then + SCHEDULER:New( TrainerWeapon, TrainerWeapon.destroy, {}, 1 ) else end end diff --git a/Moose Mission Setup/Moose.lua b/Moose Mission Setup/Moose.lua index 39b6b291f..45f88da4d 100644 --- a/Moose Mission Setup/Moose.lua +++ b/Moose Mission Setup/Moose.lua @@ -1,5 +1,5 @@ env.info( '*** MOOSE STATIC INCLUDE START *** ' ) -env.info( 'Moose Generation Timestamp: 20170214_1649' ) +env.info( 'Moose Generation Timestamp: 20170218_2236' ) local base = _G Include = {} @@ -6069,7 +6069,8 @@ do end ---- This module contains the ZONE classes, inherited from @{Zone#ZONE_BASE}. +--- This core module contains the ZONE classes, inherited from @{Zone#ZONE_BASE}. +-- -- There are essentially two core functions that zones accomodate: -- -- * Test if an object is within the zone boundaries. @@ -6095,94 +6096,111 @@ end -- -- === -- --- 1) @{Zone#ZONE_BASE} class, extends @{Base#BASE} --- ================================================ +-- # 1) @{Zone#ZONE_BASE} class, extends @{Base#BASE} +-- -- This class is an abstract BASE class for derived classes, and is not meant to be instantiated. -- --- ### 1.1) Each zone has a name: +-- ## 1.1) Each zone has a name: -- -- * @{#ZONE_BASE.GetName}(): Returns the name of the zone. -- --- ### 1.2) Each zone implements two polymorphic functions defined in @{Zone#ZONE_BASE}: +-- ## 1.2) Each zone implements two polymorphic functions defined in @{Zone#ZONE_BASE}: -- -- * @{#ZONE_BASE.IsPointVec2InZone}(): Returns if a @{Point#POINT_VEC2} is within the zone. -- * @{#ZONE_BASE.IsPointVec3InZone}(): Returns if a @{Point#POINT_VEC3} is within the zone. -- --- ### 1.3) A zone has a probability factor that can be set to randomize a selection between zones: +-- ## 1.3) A zone has a probability factor that can be set to randomize a selection between zones: -- -- * @{#ZONE_BASE.SetRandomizeProbability}(): Set the randomization probability of a zone to be selected, taking a value between 0 and 1 ( 0 = 0%, 1 = 100% ) -- * @{#ZONE_BASE.GetRandomizeProbability}(): Get the randomization probability of a zone to be selected, passing a value between 0 and 1 ( 0 = 0%, 1 = 100% ) -- * @{#ZONE_BASE.GetZoneMaybe}(): Get the zone taking into account the randomization probability. nil is returned if this zone is not a candidate. -- --- ### 1.4) A zone manages Vectors: +-- ## 1.4) A zone manages Vectors: -- -- * @{#ZONE_BASE.GetVec2}(): Returns the @{DCSTypes#Vec2} coordinate of the zone. -- * @{#ZONE_BASE.GetRandomVec2}(): Define a random @{DCSTypes#Vec2} within the zone. -- --- ### 1.5) A zone has a bounding square: +-- ## 1.5) A zone has a bounding square: -- -- * @{#ZONE_BASE.GetBoundingSquare}(): Get the outer most bounding square of the zone. -- --- ### 1.6) A zone can be marked: +-- ## 1.6) A zone can be marked: -- -- * @{#ZONE_BASE.SmokeZone}(): Smokes the zone boundaries in a color. -- * @{#ZONE_BASE.FlareZone}(): Flares the zone boundaries in a color. -- -- === -- --- 2) @{Zone#ZONE_RADIUS} class, extends @{Zone#ZONE_BASE} --- ======================================================= +-- # 2) @{Zone#ZONE_RADIUS} class, extends @{Zone#ZONE_BASE} +-- -- The ZONE_RADIUS class defined by a zone name, a location and a radius. -- This class implements the inherited functions from Core.Zone#ZONE_BASE taking into account the own zone format and properties. -- --- ### 2.1) @{Zone#ZONE_RADIUS} constructor: +-- ## 2.1) @{Zone#ZONE_RADIUS} constructor -- --- * @{#ZONE_BASE.New}(): Constructor. +-- * @{#ZONE_RADIUS.New}(): Constructor. -- --- ### 2.2) Manage the radius of the zone: +-- ## 2.2) Manage the radius of the zone -- --- * @{#ZONE_BASE.SetRadius}(): Sets the radius of the zone. --- * @{#ZONE_BASE.GetRadius}(): Returns the radius of the zone. +-- * @{#ZONE_RADIUS.SetRadius}(): Sets the radius of the zone. +-- * @{#ZONE_RADIUS.GetRadius}(): Returns the radius of the zone. -- --- ### 2.3) Manage the location of the zone: +-- ## 2.3) Manage the location of the zone -- --- * @{#ZONE_BASE.SetVec2}(): Sets the @{DCSTypes#Vec2} of the zone. --- * @{#ZONE_BASE.GetVec2}(): Returns the @{DCSTypes#Vec2} of the zone. --- * @{#ZONE_BASE.GetVec3}(): Returns the @{DCSTypes#Vec3} of the zone, taking an additional height parameter. +-- * @{#ZONE_RADIUS.SetVec2}(): Sets the @{DCSTypes#Vec2} of the zone. +-- * @{#ZONE_RADIUS.GetVec2}(): Returns the @{DCSTypes#Vec2} of the zone. +-- * @{#ZONE_RADIUS.GetVec3}(): Returns the @{DCSTypes#Vec3} of the zone, taking an additional height parameter. +-- +-- ## 2.4) Zone point randomization +-- +-- Various functions exist to find random points within the zone. +-- +-- * @{#ZONE_RADIUS.GetRandomVec2}(): Gets a random 2D point in the zone. +-- * @{#ZONE_RADIUS.GetRandomPointVec2}(): Gets a @{Point#POINT_VEC2} object representing a random 2D point in the zone. +-- * @{#ZONE_RADIUS.GetRandomPointVec3}(): Gets a @{Point#POINT_VEC3} object representing a random 3D point in the zone. Note that the height of the point is at landheight. -- -- === -- --- 3) @{Zone#ZONE} class, extends @{Zone#ZONE_RADIUS} --- ========================================== +-- # 3) @{Zone#ZONE} class, extends @{Zone#ZONE_RADIUS} +-- -- The ZONE class, defined by the zone name as defined within the Mission Editor. -- This class implements the inherited functions from {Core.Zone#ZONE_RADIUS} taking into account the own zone format and properties. -- -- === -- --- 4) @{Zone#ZONE_UNIT} class, extends @{Zone#ZONE_RADIUS} --- ======================================================= +-- # 4) @{Zone#ZONE_UNIT} class, extends @{Zone#ZONE_RADIUS} +-- -- The ZONE_UNIT class defined by a zone around a @{Unit#UNIT} with a radius. -- This class implements the inherited functions from @{Zone#ZONE_RADIUS} taking into account the own zone format and properties. -- -- === -- --- 5) @{Zone#ZONE_GROUP} class, extends @{Zone#ZONE_RADIUS} --- ======================================================= +-- # 5) @{Zone#ZONE_GROUP} class, extends @{Zone#ZONE_RADIUS} +-- -- The ZONE_GROUP class defines by a zone around a @{Group#GROUP} with a radius. The current leader of the group defines the center of the zone. -- This class implements the inherited functions from @{Zone#ZONE_RADIUS} taking into account the own zone format and properties. -- -- === -- --- 6) @{Zone#ZONE_POLYGON_BASE} class, extends @{Zone#ZONE_BASE} --- ======================================================== +-- # 6) @{Zone#ZONE_POLYGON_BASE} class, extends @{Zone#ZONE_BASE} +-- -- The ZONE_POLYGON_BASE class defined by a sequence of @{Group#GROUP} waypoints within the Mission Editor, forming a polygon. -- This class implements the inherited functions from @{Zone#ZONE_RADIUS} taking into account the own zone format and properties. -- This class is an abstract BASE class for derived classes, and is not meant to be instantiated. -- +-- ## 6.1) Zone point randomization +-- +-- Various functions exist to find random points within the zone. +-- +-- * @{#ZONE_POLYGON_BASE.GetRandomVec2}(): Gets a random 2D point in the zone. +-- * @{#ZONE_POLYGON_BASE.GetRandomPointVec2}(): Return a @{Point#POINT_VEC2} object representing a random 2D point within the zone. +-- * @{#ZONE_POLYGON_BASE.GetRandomPointVec3}(): Return a @{Point#POINT_VEC3} object representing a random 3D point at landheight within the zone. +-- +-- -- === -- --- 7) @{Zone#ZONE_POLYGON} class, extends @{Zone#ZONE_POLYGON_BASE} --- ================================================================ +-- # 7) @{Zone#ZONE_POLYGON} class, extends @{Zone#ZONE_POLYGON_BASE} +-- -- The ZONE_POLYGON class defined by a sequence of @{Group#GROUP} waypoints within the Mission Editor, forming a polygon. -- This class implements the inherited functions from @{Zone#ZONE_RADIUS} taking into account the own zone format and properties. -- @@ -6198,6 +6216,14 @@ end -- -- Hereby the change log: -- +-- 2017-02-18: ZONE_POLYGON_BASE:**GetRandomPointVec2()** added. +-- +-- 2017-02-18: ZONE_POLYGON_BASE:**GetRandomPointVec3()** added. +-- +-- 2017-02-18: ZONE_RADIUS:**GetRandomPointVec3( inner, outer )** added. +-- +-- 2017-02-18: ZONE_RADIUS:**GetRandomPointVec2( inner, outer )** added. +-- -- 2016-08-15: ZONE_BASE:**GetName()** added. -- -- 2016-08-15: ZONE_BASE:**SetZoneProbability( ZoneProbability )** added. @@ -6283,6 +6309,7 @@ function ZONE_BASE:GetVec2() return nil end + --- Define a random @{DCSTypes#Vec2} within the zone. -- @param #ZONE_BASE self -- @return Dcs.DCSTypes#Vec2 The Vec2 coordinates. @@ -6290,6 +6317,13 @@ function ZONE_BASE:GetRandomVec2() return nil end +--- Define a random @{Point#POINT_VEC2} within the zone. +-- @param #ZONE_BASE self +-- @return Core.Point#POINT_VEC2 The PointVec2 coordinates. +function ZONE_BASE:GetRandomPointVec2() + return nil +end + --- Get the bounding square the zone. -- @param #ZONE_BASE self -- @return #nil The bounding square. @@ -6518,12 +6552,12 @@ function ZONE_RADIUS:IsPointVec3InZone( Vec3 ) return InZone end ---- Returns a random location within the zone. +--- Returns a random Vec2 location within the zone. -- @param #ZONE_RADIUS self --- @param #number inner minimal distance from the center of the zone --- @param #number outer minimal distance from the outer edge of the zone +-- @param #number inner (optional) Minimal distance from the center of the zone. Default is 0. +-- @param #number outer (optional) Maximal distance from the outer edge of the zone. Default is the radius of the zone. -- @return Dcs.DCSTypes#Vec2 The random location within the zone. -function ZONE_RADIUS:GetRandomVec2(inner, outer) +function ZONE_RADIUS:GetRandomVec2( inner, outer ) self:F( self.ZoneName, inner, outer ) local Point = {} @@ -6540,6 +6574,36 @@ function ZONE_RADIUS:GetRandomVec2(inner, outer) return Point end +--- Returns a @{Point#POINT_VEC2} object reflecting a random 2D location within the zone. +-- @param #ZONE_RADIUS self +-- @param #number inner (optional) Minimal distance from the center of the zone. Default is 0. +-- @param #number outer (optional) Maximal distance from the outer edge of the zone. Default is the radius of the zone. +-- @return Core.Point#POINT_VEC2 The @{Point#POINT_VEC2} object reflecting the random 3D location within the zone. +function ZONE_RADIUS:GetRandomPointVec2( inner, outer ) + self:F( self.ZoneName, inner, outer ) + + local PointVec2 = POINT_VEC2:NewFromVec2( self:GetRandomVec2() ) + + self:T3( { PointVec2 } ) + + return PointVec2 +end + +--- Returns a @{Point#POINT_VEC3} object reflecting a random 3D location within the zone. +-- @param #ZONE_RADIUS self +-- @param #number inner (optional) Minimal distance from the center of the zone. Default is 0. +-- @param #number outer (optional) Maximal distance from the outer edge of the zone. Default is the radius of the zone. +-- @return Core.Point#POINT_VEC3 The @{Point#POINT_VEC3} object reflecting the random 3D location within the zone. +function ZONE_RADIUS:GetRandomPointVec3( inner, outer ) + self:F( self.ZoneName, inner, outer ) + + local PointVec3 = POINT_VEC3:NewFromVec2( self:GetRandomVec2() ) + + self:T3( { PointVec3 } ) + + return PointVec3 +end + --- The ZONE class, defined by the zone name as defined within the Mission Editor. The location and the radius are automatically collected from the mission settings. @@ -6854,6 +6918,33 @@ function ZONE_POLYGON_BASE:GetRandomVec2() return Vec2 end +--- Return a @{Point#POINT_VEC2} object representing a random 2D point at landheight within the zone. +-- @param #ZONE_POLYGON_BASE self +-- @return @{Point#POINT_VEC2} +function ZONE_POLYGON_BASE:GetRandomPointVec2() + self:F2() + + local PointVec2 = POINT_VEC2:NewFromVec2( self:GetRandomVec2() ) + + self:T2( PointVec2 ) + + return PointVec2 +end + +--- Return a @{Point#POINT_VEC3} object representing a random 3D point at landheight within the zone. +-- @param #ZONE_POLYGON_BASE self +-- @return @{Point#POINT_VEC3} +function ZONE_POLYGON_BASE:GetRandomPointVec3() + self:F2() + + local PointVec3 = POINT_VEC3:NewFromVec2( self:GetRandomVec2() ) + + self:T2( PointVec3 ) + + return PointVec3 +end + + --- Get the bounding square the zone. -- @param #ZONE_POLYGON_BASE self -- @return #ZONE_POLYGON_BASE.BoundingSquare The bounding square. @@ -10013,6 +10104,8 @@ end -- -- Hereby the change log: -- +-- 2017-02-18: POINT_VEC3:**NewFromVec2( Vec2, LandHeightAdd )** added. +-- -- 2016-08-12: POINT_VEC3:**Translate( Distance, Angle )** added. -- -- 2016-08-06: Made PointVec3 and Vec3, PointVec2 and Vec2 terminology used in the code consistent. @@ -10102,6 +10195,24 @@ function POINT_VEC3:New( x, y, z ) return self end +--- Create a new POINT_VEC3 object from Vec2 coordinates. +-- @param #POINT_VEC3 self +-- @param Dcs.DCSTypes#Vec2 Vec2 The Vec2 point. +-- @return Core.Point#POINT_VEC3 self +function POINT_VEC3:NewFromVec2( Vec2, LandHeightAdd ) + + local LandHeight = land.getHeight( Vec2 ) + + LandHeightAdd = LandHeightAdd or 0 + LandHeight = LandHeight + LandHeightAdd + + self = self:New( Vec2.x, LandHeight, Vec2.y ) + + self:F2( self ) + + return self +end + --- Create a new POINT_VEC3 object from Vec3 coordinates. -- @param #POINT_VEC3 self -- @param Dcs.DCSTypes#Vec3 Vec3 The Vec3 point. diff --git a/Moose Test Missions/ZON - Zones/ZON-100 - Normal Zone/ZON-100 - Normal Zone.miz b/Moose Test Missions/ZON - Zones/ZON-100 - Normal Zone/ZON-100 - Normal Zone.miz index b46c6d364..2fdd6ba89 100644 Binary files a/Moose Test Missions/ZON - Zones/ZON-100 - Normal Zone/ZON-100 - Normal Zone.miz and b/Moose Test Missions/ZON - Zones/ZON-100 - Normal Zone/ZON-100 - Normal Zone.miz differ diff --git a/Moose Test Missions/ZON - Zones/ZON-101 - Normal Zone - Random Point/ZON-101 - Normal Zone - Random Point.lua b/Moose Test Missions/ZON - Zones/ZON-101 - Normal Zone - Random Point/ZON-101 - Normal Zone - Random Point.lua new file mode 100644 index 000000000..ed9dd3595 --- /dev/null +++ b/Moose Test Missions/ZON - Zones/ZON-101 - Normal Zone - Random Point/ZON-101 - Normal Zone - Random Point.lua @@ -0,0 +1,43 @@ +--- +-- Name: ZON-101 - Normal Zone - Random Point +-- Author: FlightControl +-- Date Created: 18 Feb 2017 +-- +-- # Situation: +-- +-- Three zones are defined. +-- 15 points are smoked in each zone. +-- The first 15 points are blue smoked using the GetRandomVec2() API. +-- The second 15 points are orange smoked using the GetRandomPointVec2() API. +-- The third 15 points are red smoked using the GetRandomPointVec3() API. +-- Note: The zones perimeters are also smoked in white, so you can observe the random point placement. +-- Note: At each zone an vehicle is placed, so you can view the smoking in external view. +-- +-- # Test cases: +-- +-- 1. Observe smoking of Blue smoke in Zone 1. +-- 2. Observe smoking of Orange smoke in Zone 2. +-- 3. Observe smoking of Red smoke in Zone 3. + +local Zone1 = ZONE:New( "Zone 1" ) +local Zone2 = ZONE:New( "Zone 2" ) +local Zone3 = ZONE:New( "Zone 3" ) + +Zone1:SmokeZone( SMOKECOLOR.White, 18 ) +Zone2:SmokeZone( SMOKECOLOR.White, 18 ) +Zone3:SmokeZone( SMOKECOLOR.White, 18 ) + +for i = 1, 15 do + -- Zone 1 + local Vec2 = Zone1:GetRandomVec2() + local PointVec2 = POINT_VEC2:NewFromVec2( Vec2 ) + PointVec2:SmokeBlue() + + -- Zone 2 + local PointVec2 = Zone2:GetRandomPointVec2() + PointVec2:SmokeOrange() + + -- Zone 3 + local PointVec3 = Zone3:GetRandomPointVec3() + PointVec3:SmokeRed() +end diff --git a/Moose Test Missions/ZON - Zones/ZON-101 - Normal Zone - Random Point/ZON-101 - Normal Zone - Random Point.miz b/Moose Test Missions/ZON - Zones/ZON-101 - Normal Zone - Random Point/ZON-101 - Normal Zone - Random Point.miz new file mode 100644 index 000000000..6af4a527d Binary files /dev/null and b/Moose Test Missions/ZON - Zones/ZON-101 - Normal Zone - Random Point/ZON-101 - Normal Zone - Random Point.miz differ diff --git a/Moose Test Missions/ZON - Zones/ZON-200 - Group Zone/ZON-200 - Group Zone.miz b/Moose Test Missions/ZON - Zones/ZON-200 - Group Zone/ZON-200 - Group Zone.miz index ead8ae249..74d2452b5 100644 Binary files a/Moose Test Missions/ZON - Zones/ZON-200 - Group Zone/ZON-200 - Group Zone.miz and b/Moose Test Missions/ZON - Zones/ZON-200 - Group Zone/ZON-200 - Group Zone.miz differ diff --git a/Moose Test Missions/ZON - Zones/ZON-201 - Group Zone - Random Point/ZON-201 - Group Zone - Random Point.lua b/Moose Test Missions/ZON - Zones/ZON-201 - Group Zone - Random Point/ZON-201 - Group Zone - Random Point.lua new file mode 100644 index 000000000..e20b5913d --- /dev/null +++ b/Moose Test Missions/ZON - Zones/ZON-201 - Group Zone - Random Point/ZON-201 - Group Zone - Random Point.lua @@ -0,0 +1,43 @@ +--- +-- Name: ZON-201 - Group Zone - Random Point +-- Author: FlightControl +-- Date Created: 18 Feb 2017 +-- +-- # Situation: +-- +-- Three zones are defined. +-- 15 points are smoked in each zone. +-- The first 15 points are blue smoked using the GetRandomVec2() API. +-- The second 15 points are orange smoked using the GetRandomPointVec2() API. +-- The third 15 points are red smoked using the GetRandomPointVec3() API. +-- Note: The zones perimeters are also smoked in white, so you can observe the random point placement. +-- Note: At each zone an vehicle is placed, so you can view the smoking in external view. +-- +-- # Test cases: +-- +-- 1. Observe smoking of Blue smoke in Zone 1. +-- 2. Observe smoking of Orange smoke in Zone 2. +-- 3. Observe smoking of Red smoke in Zone 3. + +local Zone1 = ZONE_GROUP:New( "Zone 1", GROUP:FindByName( "Zone 1" ), 300 ) +local Zone2 = ZONE_GROUP:New( "Zone 2", GROUP:FindByName( "Zone 2" ), 300 ) +local Zone3 = ZONE_GROUP:New( "Zone 3", GROUP:FindByName( "Zone 3" ), 300 ) + +Zone1:SmokeZone( SMOKECOLOR.White, 18 ) +Zone2:SmokeZone( SMOKECOLOR.White, 18 ) +Zone3:SmokeZone( SMOKECOLOR.White, 18 ) + +for i = 1, 15 do + -- Zone 1 + local Vec2 = Zone1:GetRandomVec2() + local PointVec2 = POINT_VEC2:NewFromVec2( Vec2 ) + PointVec2:SmokeBlue() + + -- Zone 2 + local PointVec2 = Zone2:GetRandomPointVec2() + PointVec2:SmokeOrange() + + -- Zone 3 + local PointVec3 = Zone3:GetRandomPointVec3() + PointVec3:SmokeRed() +end diff --git a/Moose Test Missions/ZON - Zones/ZON-201 - Group Zone - Random Point/ZON-201 - Group Zone - Random Point.miz b/Moose Test Missions/ZON - Zones/ZON-201 - Group Zone - Random Point/ZON-201 - Group Zone - Random Point.miz new file mode 100644 index 000000000..a52ef23db Binary files /dev/null and b/Moose Test Missions/ZON - Zones/ZON-201 - Group Zone - Random Point/ZON-201 - Group Zone - Random Point.miz differ diff --git a/Moose Test Missions/ZON - Zones/ZON-300 - Unit Zone/ZON-300 - Unit Zone.miz b/Moose Test Missions/ZON - Zones/ZON-300 - Unit Zone/ZON-300 - Unit Zone.miz index db4ebf071..55fe2a739 100644 Binary files a/Moose Test Missions/ZON - Zones/ZON-300 - Unit Zone/ZON-300 - Unit Zone.miz and b/Moose Test Missions/ZON - Zones/ZON-300 - Unit Zone/ZON-300 - Unit Zone.miz differ diff --git a/Moose Test Missions/ZON - Zones/ZON-301 - Unit Zone - Random Point/ZON-301 - Unit Zone - Random Point.lua b/Moose Test Missions/ZON - Zones/ZON-301 - Unit Zone - Random Point/ZON-301 - Unit Zone - Random Point.lua new file mode 100644 index 000000000..95a38c69b --- /dev/null +++ b/Moose Test Missions/ZON - Zones/ZON-301 - Unit Zone - Random Point/ZON-301 - Unit Zone - Random Point.lua @@ -0,0 +1,43 @@ +--- +-- Name: ZON-301 - Unit Zone - Random Point +-- Author: FlightControl +-- Date Created: 18 Feb 2017 +-- +-- # Situation: +-- +-- Three zones are defined. +-- 15 points are smoked in each zone. +-- The first 15 points are blue smoked using the GetRandomVec2() API. +-- The second 15 points are orange smoked using the GetRandomPointVec2() API. +-- The third 15 points are red smoked using the GetRandomPointVec3() API. +-- Note: The zones perimeters are also smoked in white, so you can observe the random point placement. +-- Note: At each zone an vehicle is placed, so you can view the smoking in external view. +-- +-- # Test cases: +-- +-- 1. Observe smoking of Blue smoke in Zone 1. +-- 2. Observe smoking of Orange smoke in Zone 2. +-- 3. Observe smoking of Red smoke in Zone 3. + +local Zone1 = ZONE_UNIT:New( "Zone 1", UNIT:FindByName( "Zone 1" ), 300 ) +local Zone2 = ZONE_UNIT:New( "Zone 2", UNIT:FindByName( "Zone 2" ), 300 ) +local Zone3 = ZONE_UNIT:New( "Zone 3", UNIT:FindByName( "Zone 3" ), 300 ) + +Zone1:SmokeZone( SMOKECOLOR.White, 18 ) +Zone2:SmokeZone( SMOKECOLOR.White, 18 ) +Zone3:SmokeZone( SMOKECOLOR.White, 18 ) + +for i = 1, 15 do + -- Zone 1 + local Vec2 = Zone1:GetRandomVec2() + local PointVec2 = POINT_VEC2:NewFromVec2( Vec2 ) + PointVec2:SmokeBlue() + + -- Zone 2 + local PointVec2 = Zone2:GetRandomPointVec2() + PointVec2:SmokeOrange() + + -- Zone 3 + local PointVec3 = Zone3:GetRandomPointVec3() + PointVec3:SmokeRed() +end diff --git a/Moose Test Missions/ZON - Zones/ZON-301 - Unit Zone - Random Point/ZON-301 - Unit Zone - Random Point.miz b/Moose Test Missions/ZON - Zones/ZON-301 - Unit Zone - Random Point/ZON-301 - Unit Zone - Random Point.miz new file mode 100644 index 000000000..2c0d5beed Binary files /dev/null and b/Moose Test Missions/ZON - Zones/ZON-301 - Unit Zone - Random Point/ZON-301 - Unit Zone - Random Point.miz differ diff --git a/Moose Test Missions/ZON - Zones/ZON-400 - Radius Zone/ZON-400 - Radius Zone.miz b/Moose Test Missions/ZON - Zones/ZON-400 - Radius Zone/ZON-400 - Radius Zone.miz index 559f975f4..40f791bcc 100644 Binary files a/Moose Test Missions/ZON - Zones/ZON-400 - Radius Zone/ZON-400 - Radius Zone.miz and b/Moose Test Missions/ZON - Zones/ZON-400 - Radius Zone/ZON-400 - Radius Zone.miz differ diff --git a/Moose Test Missions/ZON - Zones/ZON-401 - Radius Zone - Random Point/ZON-401 - Radius Zone - Random Point.lua b/Moose Test Missions/ZON - Zones/ZON-401 - Radius Zone - Random Point/ZON-401 - Radius Zone - Random Point.lua new file mode 100644 index 000000000..62857df37 --- /dev/null +++ b/Moose Test Missions/ZON - Zones/ZON-401 - Radius Zone - Random Point/ZON-401 - Radius Zone - Random Point.lua @@ -0,0 +1,48 @@ +--- +-- Name: ZON-401 - Radius Zone - Random Point +-- Author: FlightControl +-- Date Created: 18 Feb 2017 +-- +-- # Situation: +-- +-- Three zones are defined. +-- 15 points are smoked in each zone. +-- The first 15 points are blue smoked using the GetRandomVec2() API. +-- The second 15 points are orange smoked using the GetRandomPointVec2() API. +-- The third 15 points are red smoked using the GetRandomPointVec3() API. +-- Note: The zones perimeters are also smoked in white, so you can observe the random point placement. +-- Note: At each zone an vehicle is placed, so you can view the smoking in external view. +-- +-- # Test cases: +-- +-- 1. Observe smoking of Blue smoke in Zone 1. +-- 2. Observe smoking of Orange smoke in Zone 2. +-- 3. Observe smoking of Red smoke in Zone 3. + +local Unit1 = UNIT:FindByName( "Zone 1" ) +local Unit2 = UNIT:FindByName( "Zone 2" ) +local Unit3 = UNIT:FindByName( "Zone 3" ) + + +local Zone1 = ZONE_RADIUS:New( "Zone 1", Unit1:GetVec2(), 300 ) +local Zone2 = ZONE_RADIUS:New( "Zone 2", Unit2:GetVec2(), 300 ) +local Zone3 = ZONE_RADIUS:New( "Zone 3", Unit3:GetVec2(), 300 ) + +Zone1:SmokeZone( SMOKECOLOR.White, 18 ) +Zone2:SmokeZone( SMOKECOLOR.White, 18 ) +Zone3:SmokeZone( SMOKECOLOR.White, 18 ) + +for i = 1, 15 do + -- Zone 1 + local Vec2 = Zone1:GetRandomVec2() + local PointVec2 = POINT_VEC2:NewFromVec2( Vec2 ) + PointVec2:SmokeBlue() + + -- Zone 2 + local PointVec2 = Zone2:GetRandomPointVec2() + PointVec2:SmokeOrange() + + -- Zone 3 + local PointVec3 = Zone3:GetRandomPointVec3() + PointVec3:SmokeRed() +end diff --git a/Moose Test Missions/ZON - Zones/ZON-401 - Radius Zone - Random Point/ZON-401 - Radius Zone - Random Point.miz b/Moose Test Missions/ZON - Zones/ZON-401 - Radius Zone - Random Point/ZON-401 - Radius Zone - Random Point.miz new file mode 100644 index 000000000..3c187ce3f Binary files /dev/null and b/Moose Test Missions/ZON - Zones/ZON-401 - Radius Zone - Random Point/ZON-401 - Radius Zone - Random Point.miz differ diff --git a/Moose Test Missions/ZON - Zones/ZON-500 - Polygon Zone/ZON-500 - Polygon Zone.miz b/Moose Test Missions/ZON - Zones/ZON-500 - Polygon Zone/ZON-500 - Polygon Zone.miz index 869b0dbd6..15b5a0990 100644 Binary files a/Moose Test Missions/ZON - Zones/ZON-500 - Polygon Zone/ZON-500 - Polygon Zone.miz and b/Moose Test Missions/ZON - Zones/ZON-500 - Polygon Zone/ZON-500 - Polygon Zone.miz differ diff --git a/Moose Test Missions/ZON - Zones/ZON-501 - Polygon Zone - Random Point/ZON-501 - Polygon Zone - Random Point.lua b/Moose Test Missions/ZON - Zones/ZON-501 - Polygon Zone - Random Point/ZON-501 - Polygon Zone - Random Point.lua new file mode 100644 index 000000000..451aec542 --- /dev/null +++ b/Moose Test Missions/ZON - Zones/ZON-501 - Polygon Zone - Random Point/ZON-501 - Polygon Zone - Random Point.lua @@ -0,0 +1,43 @@ +--- +-- Name: ZON-501 - Polygon Zone - Random Point +-- Author: FlightControl +-- Date Created: 18 Feb 2017 +-- +-- # Situation: +-- +-- Three zones are defined. +-- 15 points are smoked in each zone. +-- The first 15 points are blue smoked using the GetRandomVec2() API. +-- The second 15 points are orange smoked using the GetRandomPointVec2() API. +-- The third 15 points are red smoked using the GetRandomPointVec3() API. +-- Note: The zones perimeters are also smoked in white, so you can observe the random point placement. +-- Note: At each zone an vehicle is placed, so you can view the smoking in external view. +-- +-- # Test cases: +-- +-- 1. Observe smoking of Blue smoke in Zone 1. +-- 2. Observe smoking of Orange smoke in Zone 2. +-- 3. Observe smoking of Red smoke in Zone 3. + +local Zone1 = ZONE_POLYGON:New( "Zone 1", GROUP:FindByName( "Zone 1" ) ) +local Zone2 = ZONE_POLYGON:New( "Zone 2", GROUP:FindByName( "Zone 2" ) ) +local Zone3 = ZONE_POLYGON:New( "Zone 3", GROUP:FindByName( "Zone 3" ) ) + +Zone1:SmokeZone( SMOKECOLOR.White, 4 ) +Zone2:SmokeZone( SMOKECOLOR.White, 4 ) +Zone3:SmokeZone( SMOKECOLOR.White, 4 ) + +for i = 1, 15 do + -- Zone 1 + local Vec2 = Zone1:GetRandomVec2() + local PointVec2 = POINT_VEC2:NewFromVec2( Vec2 ) + PointVec2:SmokeBlue() + + -- Zone 2 + local PointVec2 = Zone2:GetRandomPointVec2() + PointVec2:SmokeOrange() + + -- Zone 3 + local PointVec3 = Zone3:GetRandomPointVec3() + PointVec3:SmokeRed() +end diff --git a/Moose Test Missions/ZON - Zones/ZON-501 - Polygon Zone - Random Point/ZON-501 - Polygon Zone - Random Point.miz b/Moose Test Missions/ZON - Zones/ZON-501 - Polygon Zone - Random Point/ZON-501 - Polygon Zone - Random Point.miz new file mode 100644 index 000000000..9b9803f24 Binary files /dev/null and b/Moose Test Missions/ZON - Zones/ZON-501 - Polygon Zone - Random Point/ZON-501 - Polygon Zone - Random Point.miz differ diff --git a/Moose Test Missions/ZON - Zones/ZON-510 - Send message if Clients fly the first time in the Polygon Zones/ZON-510 - Send message if Clients fly the first time in the Polygon Zones.miz b/Moose Test Missions/ZON - Zones/ZON-510 - Send message if Clients fly the first time in the Polygon Zones/ZON-510 - Send message if Clients fly the first time in the Polygon Zones.miz index 2e6d9a204..5c17d5204 100644 Binary files a/Moose Test Missions/ZON - Zones/ZON-510 - Send message if Clients fly the first time in the Polygon Zones/ZON-510 - Send message if Clients fly the first time in the Polygon Zones.miz and b/Moose Test Missions/ZON - Zones/ZON-510 - Send message if Clients fly the first time in the Polygon Zones/ZON-510 - Send message if Clients fly the first time in the Polygon Zones.miz differ diff --git a/docs/Documentation/AI_Patrol.html b/docs/Documentation/AI_Patrol.html index cfd08e72f..c2d613229 100644 --- a/docs/Documentation/AI_Patrol.html +++ b/docs/Documentation/AI_Patrol.html @@ -880,9 +880,6 @@ Use the method AIPATROLZONE.M - -

This table contains the targets detected during patrol.

-
diff --git a/docs/Documentation/Event.html b/docs/Documentation/Event.html index 2990127f4..79c16f3a2 100644 --- a/docs/Documentation/Event.html +++ b/docs/Documentation/Event.html @@ -245,6 +245,12 @@ YYYY-MM-DD: CLASS:NewFunction( Params ) added

EVENT + + + + EVENTHANDLER + + @@ -682,6 +688,28 @@ YYYY-MM-DD: CLASS:NewFunction( Params ) added

EVENTDATA.weapon + + + + +

Type EVENTHANDLER

+ + + + + + + + + + + +
EVENTHANDLER.ClassID + +
EVENTHANDLER.ClassName + +
EVENTHANDLER:New() +

The EVENTHANDLER constructor

@@ -841,6 +869,20 @@ YYYY-MM-DD: CLASS:NewFunction( Params ) added

+ +
+
+
+ + #EVENTHANDLER + +EVENTHANDLER + +
+
+ + +
@@ -2662,6 +2704,58 @@ The self instance of the class for which the event is.

+ +
+ +

Type EVENTHANDLER

+ +

The EVENTHANDLER structure

+ +

Field(s)

+
+
+ + #number + +EVENTHANDLER.ClassID + +
+
+ + + +
+
+
+
+ + #string + +EVENTHANDLER.ClassName + +
+
+ + + +
+
+
+
+ + +EVENTHANDLER:New() + +
+
+ +

The EVENTHANDLER constructor

+ +

Return value

+ +

#EVENTHANDLER:

+ +
diff --git a/docs/Documentation/Fsm.html b/docs/Documentation/Fsm.html index 3ef15c2df..4992d02fb 100644 --- a/docs/Documentation/Fsm.html +++ b/docs/Documentation/Fsm.html @@ -1505,7 +1505,7 @@ A string defining the start state.

- + #string FSM._StartState @@ -1804,7 +1804,6 @@ A string defining the start state.

- FSM.current diff --git a/docs/Documentation/Point.html b/docs/Documentation/Point.html index 3146ea03a..576c45b98 100644 --- a/docs/Documentation/Point.html +++ b/docs/Documentation/Point.html @@ -114,6 +114,8 @@ In order to keep the credibility of the the author, I want to emphasize that the

Hereby the change log:

+

2017-02-18: POINT_VEC3:NewFromVec2( Vec2, LandHeightAdd ) added.

+

2016-08-12: POINT_VEC3:Translate( Distance, Angle ) added.

2016-08-06: Made PointVec3 and Vec3, PointVec2 and Vec2 terminology used in the code consistent.

@@ -399,6 +401,12 @@ In order to keep the credibility of the the author, I want to emphasize that the POINT_VEC3:New(x, y, z)

Create a new POINT_VEC3 object.

+ + + + POINT_VEC3:NewFromVec2(Vec2, LandHeightAdd) + +

Create a new POINT_VEC3 object from Vec2 coordinates.

@@ -1599,6 +1607,38 @@ self

+ +POINT_VEC3:NewFromVec2(Vec2, LandHeightAdd) + +
+
+ +

Create a new POINT_VEC3 object from Vec2 coordinates.

+ +

Parameters

+ +

Return value

+ +

Core.Point#POINT_VEC3: +self

+ +
+
+
+
+ POINT_VEC3:NewFromVec3(Vec3) diff --git a/docs/Documentation/Spawn.html b/docs/Documentation/Spawn.html index 5237d7f0e..42eb4a563 100644 --- a/docs/Documentation/Spawn.html +++ b/docs/Documentation/Spawn.html @@ -1758,9 +1758,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.

-
@@ -2235,7 +2232,7 @@ when nothing was spawned.

- #number + SPAWN.SpawnMaxGroups @@ -2252,7 +2249,7 @@ when nothing was spawned.

- #number + SPAWN.SpawnMaxUnitsAlive @@ -2531,7 +2528,7 @@ Spawn_BE_KA50 = SPAWN:New( 'BE KA-50@RAMP-Ground Defense' ):Schedule( 600, 0.5 )
- #boolean + SPAWN.SpawnUnControlled @@ -2555,7 +2552,7 @@ Spawn_BE_KA50 = SPAWN:New( 'BE KA-50@RAMP-Ground Defense' ):Schedule( 600, 0.5 ) -

When the first Spawn executes, all the Groups need to be made visible before start.

+

Flag that indicates if all the Groups of the SpawnGroup need to be visible when Spawned.

diff --git a/docs/Documentation/Zone.html b/docs/Documentation/Zone.html index 965854e1f..a1a076180 100644 --- a/docs/Documentation/Zone.html +++ b/docs/Documentation/Zone.html @@ -71,9 +71,10 @@

Module Zone

-

This module contains the ZONE classes, inherited from Zone#ZONE_BASE.

+

This core module contains the ZONE classes, inherited from Zone#ZONE_BASE.

+

There are essentially two core functions that zones accomodate: