From 123dc13532d279c2c4a4f8eb4fb205f3bd959637 Mon Sep 17 00:00:00 2001 From: FlightControl Date: Sun, 3 Jul 2016 07:54:37 +0200 Subject: [PATCH] Fixed a bug in ZONE_UNIT GetRandomVec2() did not work for ZONE_UNIT --- Moose Development/Moose/Zone.lua | 17 +++++++++++++++++ .../l10n/DEFAULT/Moose.lua | 19 ++++++++++++++++++- Moose Mission Setup/Moose.lua | 19 ++++++++++++++++++- 3 files changed, 53 insertions(+), 2 deletions(-) diff --git a/Moose Development/Moose/Zone.lua b/Moose Development/Moose/Zone.lua index 9bb906a90..199005d9a 100644 --- a/Moose Development/Moose/Zone.lua +++ b/Moose Development/Moose/Zone.lua @@ -405,6 +405,23 @@ function ZONE_UNIT:GetPointVec2() return ZonePointVec2 end +--- Returns a random location within the zone. +-- @param #ZONE_UNIT self +-- @return DCSTypes#Vec2 The random location within the zone. +function ZONE_UNIT:GetRandomVec2() + self:F( self.ZoneName ) + + local Point = {} + local PointVec2 = self.ZoneUNIT:GetPointVec2() + + local angle = math.random() * math.pi*2; + Point.x = PointVec2.x + math.cos( angle ) * math.random() * self:GetRadius(); + Point.y = PointVec2.y + math.sin( angle ) * math.random() * self:GetRadius(); + + self:T( { Point } ) + + return Point +end -- Polygons --- The ZONE_POLYGON_BASE class defined by an array of @{DCSTypes#Vec2}, forming a polygon. 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 e474c94e6..3596afab8 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: 20160628_1157' ) +env.info( 'Moose Generation Timestamp: 20160703_0754' ) local base = _G Include = {} @@ -8727,6 +8727,23 @@ function ZONE_UNIT:GetPointVec2() return ZonePointVec2 end +--- Returns a random location within the zone. +-- @param #ZONE_UNIT self +-- @return DCSTypes#Vec2 The random location within the zone. +function ZONE_UNIT:GetRandomVec2() + self:F( self.ZoneName ) + + local Point = {} + local PointVec2 = self.ZoneUNIT:GetPointVec2() + + local angle = math.random() * math.pi*2; + Point.x = PointVec2.x + math.cos( angle ) * math.random() * self:GetRadius(); + Point.y = PointVec2.y + math.sin( angle ) * math.random() * self:GetRadius(); + + self:T( { Point } ) + + return Point +end -- Polygons --- The ZONE_POLYGON_BASE class defined by an array of @{DCSTypes#Vec2}, forming a polygon. diff --git a/Moose Mission Setup/Moose.lua b/Moose Mission Setup/Moose.lua index e474c94e6..3596afab8 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: 20160628_1157' ) +env.info( 'Moose Generation Timestamp: 20160703_0754' ) local base = _G Include = {} @@ -8727,6 +8727,23 @@ function ZONE_UNIT:GetPointVec2() return ZonePointVec2 end +--- Returns a random location within the zone. +-- @param #ZONE_UNIT self +-- @return DCSTypes#Vec2 The random location within the zone. +function ZONE_UNIT:GetRandomVec2() + self:F( self.ZoneName ) + + local Point = {} + local PointVec2 = self.ZoneUNIT:GetPointVec2() + + local angle = math.random() * math.pi*2; + Point.x = PointVec2.x + math.cos( angle ) * math.random() * self:GetRadius(); + Point.y = PointVec2.y + math.sin( angle ) * math.random() * self:GetRadius(); + + self:T( { Point } ) + + return Point +end -- Polygons --- The ZONE_POLYGON_BASE class defined by an array of @{DCSTypes#Vec2}, forming a polygon.