From ac7dd8cb2ffa088112255296e9021c809f51d1e6 Mon Sep 17 00:00:00 2001 From: 132nd-etcher <132nd-etcher@daribouca.net> Date: Sat, 28 Jan 2017 20:08:30 +0100 Subject: [PATCH] add "inner" and "outer" parameter to ZONE_RADIUS:GetRandomVec2() method --- Moose Development/Moose/Core/Zone.lua | 14 +++++++++----- Moose Mission Setup/Moose.lua | 14 +++++++++----- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/Moose Development/Moose/Core/Zone.lua b/Moose Development/Moose/Core/Zone.lua index d0b8c635c..d8aef9bdd 100644 --- a/Moose Development/Moose/Core/Zone.lua +++ b/Moose Development/Moose/Core/Zone.lua @@ -449,16 +449,20 @@ end --- Returns a random 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 -- @return Dcs.DCSTypes#Vec2 The random location within the zone. -function ZONE_RADIUS:GetRandomVec2() - self:F( self.ZoneName ) +function ZONE_RADIUS:GetRandomVec2(inner, outer) + self:F( self.ZoneName, inner, outer ) local Point = {} local Vec2 = self:GetVec2() + local _inner = inner or 0 + local _outer = outer or self:GetRadius() - local angle = math.random() * math.pi*2; - Point.x = Vec2.x + math.cos( angle ) * math.random() * self:GetRadius(); - Point.y = Vec2.y + math.sin( angle ) * math.random() * self:GetRadius(); + local angle = math.random() * math.pi * 2; + Point.x = Vec2.x + math.cos( angle ) * math.random(_inner, _outer); + Point.y = Vec2.y + math.sin( angle ) * math.random(_inner, _outer); self:T( { Point } ) diff --git a/Moose Mission Setup/Moose.lua b/Moose Mission Setup/Moose.lua index 31a028f31..226d78d39 100644 --- a/Moose Mission Setup/Moose.lua +++ b/Moose Mission Setup/Moose.lua @@ -6321,16 +6321,20 @@ end --- Returns a random 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 -- @return Dcs.DCSTypes#Vec2 The random location within the zone. -function ZONE_RADIUS:GetRandomVec2() - self:F( self.ZoneName ) +function ZONE_RADIUS:GetRandomVec2(inner, outer) + self:F( self.ZoneName, inner, outer ) local Point = {} local Vec2 = self:GetVec2() + local _inner = inner or 0 + local _outer = outer or self:GetRadius() - local angle = math.random() * math.pi*2; - Point.x = Vec2.x + math.cos( angle ) * math.random() * self:GetRadius(); - Point.y = Vec2.y + math.sin( angle ) * math.random() * self:GetRadius(); + local angle = math.random() * math.pi * 2; + Point.x = Vec2.x + math.cos( angle ) * math.random(_inner, _outer); + Point.y = Vec2.y + math.sin( angle ) * math.random(_inner, _outer); self:T( { Point } )