diff --git a/Moose Development/Moose/Spawn.lua b/Moose Development/Moose/Spawn.lua index 046d824a5..bc7a97da2 100644 --- a/Moose Development/Moose/Spawn.lua +++ b/Moose Development/Moose/Spawn.lua @@ -416,7 +416,7 @@ function SPAWN:ReSpawn( SpawnIndex ) -- TODO: This logic makes DCS crash and i don't know why (yet). local SpawnGroup = self:GetGroupFromIndex( SpawnIndex ) if SpawnGroup then - local SpawnDCSGroup = SpawnGroup:GetDCSGroup() + local SpawnDCSGroup = SpawnGroup:GetDCSObject() if SpawnDCSGroup then SpawnGroup:Destroy() end diff --git a/Moose Development/Moose/Zone.lua b/Moose Development/Moose/Zone.lua index 786259d4f..d1cc8baef 100644 --- a/Moose Development/Moose/Zone.lua +++ b/Moose Development/Moose/Zone.lua @@ -414,6 +414,23 @@ function ZONE_UNIT:GetVec2() return ZoneVec2 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.