diff --git a/Moose Development/Moose/Point.lua b/Moose Development/Moose/Point.lua index 530d0217d..9b7f73546 100644 --- a/Moose Development/Moose/Point.lua +++ b/Moose Development/Moose/Point.lua @@ -124,10 +124,7 @@ end -- @return Point#POINT_VEC3 self function POINT_VEC3:NewFromVec3( Vec3 ) - local self = BASE:Inherit( self, BASE:New() ) - self.PointVec3 = Vec3 - self:F2( self.PointVec3 ) - return self + return self:New( Vec3.x, Vec3.y, Vec3.z ) end @@ -138,11 +135,19 @@ function POINT_VEC3:GetVec3() return self.PointVec3 end +--- Return the coordinates of the POINT_VEC3 in Vec2 format. +-- @param #POINT_VEC3 self +-- @return DCSTypes#Vec2 The Vec2 coodinate. +function POINT_VEC3:GetVec2() + return { x = self.PointVec3.x, y = self.PointVec3.z } +end + --- Return the x coordinate of the POINT_VEC3. -- @param #POINT_VEC3 self -- @return #number The x coodinate. function POINT_VEC3:GetX() + self:F2(self.PointVec3.x) return self.PointVec3.x end @@ -150,6 +155,7 @@ end -- @param #POINT_VEC3 self -- @return #number The y coodinate. function POINT_VEC3:GetY() + self:F2(self.PointVec3.y) return self.PointVec3.y end @@ -157,9 +163,55 @@ end -- @param #POINT_VEC3 self -- @return #number The z coodinate. function POINT_VEC3:GetZ() + self:F2(self.PointVec3.z) return self.PointVec3.z end +--- Return a random Vec3 point within an Outer Radius and optionally NOT within an Inner Radius of the POINT_VEC3. +-- @param #POINT_VEC3 self +-- @param DCSTypes#Distance OuterRadius +-- @param DCSTypes#Distance InnerRadius +-- @return DCSTypes#Vec2 Vec2 +function POINT_VEC3:GetRandomVec2InRadius( OuterRadius, InnerRadius ) + self:F2( { self.PointVec3, OuterRadius, InnerRadius } ) + + local Theta = 2 * math.pi * math.random() + local Radials = math.random() + math.random() + if Radials > 1 then + Radials = 2 - Radials + end + + local RadialMultiplier + if InnerRadius and InnerRadius <= OuterRadius then + RadialMultiplier = ( OuterRadius - InnerRadius ) * Radials + InnerRadius + else + RadialMultiplier = OuterRadius * Radials + end + + local RandomVec3 + if OuterRadius > 0 then + RandomVec3 = { x = math.cos( Theta ) * RadialMultiplier + self:GetX(), y = math.sin( Theta ) * RadialMultiplier + self:GetZ() } + else + RandomVec3 = { x = self:GetX(), y = self:GetZ() } + end + + return RandomVec3 +end + +--- Return a random Vec3 point within an Outer Radius and optionally NOT within an Inner Radius of the POINT_VEC3. +-- @param #POINT_VEC3 self +-- @param DCSTypes#Distance OuterRadius +-- @param DCSTypes#Distance InnerRadius +-- @return DCSTypes#Vec3 Vec3 +function POINT_VEC3:GetRandomVec3InRadius( OuterRadius, InnerRadius ) + + local RandomVec2 = self:GetRandomVec2InRadius( OuterRadius, InnerRadius ) + local y = self:GetY() + math.random( InnerRadius, OuterRadius ) + local RandomVec3 = { x = RandomVec2.x, y = y, z = RandomVec2.z } + + return RandomVec3 +end + --- Return a direction vector Vec3 from POINT_VEC3 to the POINT_VEC3. -- @param #POINT_VEC3 self @@ -443,6 +495,28 @@ function POINT_VEC2:New( x, y, LandHeightAdd ) return self end +--- Create a new POINT_VEC2 object from Vec2 coordinates. +-- @param #POINT_VEC2 self +-- @param DCSTypes#Vec2 Vec2 The Vec2 point. +-- @return Point#POINT_VEC2 self +function POINT_VEC2:NewFromVec2( Vec2, LandHeightAdd ) + + local self = BASE:Inherit( self, BASE:New() ) + + local LandHeight = land.getHeight( Vec2 ) + if LandHeightAdd then + LandHeight = LandHeight + LandHeightAdd + end + + local self = BASE:Inherit( self, POINT_VEC3:New( Vec2.x, LandHeight, Vec2.y ) ) + self:F2( { Vec2.x, Vec2.y, LandHeightAdd } ) + + self.PointVec2 = Vec2 + self:F2( self.PointVec3 ) + + return self +end + --- Calculate the distance from a reference @{Point#POINT_VEC2}. -- @param #POINT_VEC2 self -- @param #POINT_VEC2 PointVec2Reference The reference @{Point#POINT_VEC2}. diff --git a/Moose Development/Moose/Spawn.lua b/Moose Development/Moose/Spawn.lua index 4606a1e0e..170bff907 100644 --- a/Moose Development/Moose/Spawn.lua +++ b/Moose Development/Moose/Spawn.lua @@ -52,6 +52,9 @@ -- * @{#SPAWN.Spawn}: Spawn one new group based on the last spawned index. -- * @{#SPAWN.ReSpawn}: Re-spawn a group based on a given index. -- * @{#SPAWN.SpawnScheduled}: Spawn groups at scheduled but randomized intervals. You can use @{#SPAWN.SpawnScheduleStart} and @{#SPAWN.SpawnScheduleStop} to start and stop the schedule respectively. +-- * @{#SPAWN.SpawnFromVec3}: Spawn a new group from a Vec3 coordinate. (The group will can be spawned at a point in the air). +-- * @{#SPAWN.SpawnFromVec2}: Spawn a new group from a Vec2 coordinate. (The group will be spawned at land height ). +-- * @{#SPAWN.SpawnFromStatic}: Spawn a new group from a structure, taking the position of a @{STATIC}. -- * @{#SPAWN.SpawnFromUnit}: Spawn a new group taking the position of a @{UNIT}. -- * @{#SPAWN.SpawnInZone}: Spawn a new group in a @{ZONE}. -- @@ -537,6 +540,86 @@ function SPAWN:SpawnFunction( SpawnFunctionHook, ... ) end +--- Will spawn a group from a Vec3 in 3D space. +-- This function is mostly advisable to be used if you want to simulate spawning units in the air, like helicopters or airplanes. +-- Note that each point in the route assigned to the spawning group is reset to the point of the spawn. +-- You can use the returned group to further define the route to be followed. +-- @param #SPAWN self +-- @param DCSTypes#Vec3 Vec3 The Vec3 coordinates where to spawn the group. +-- @param #number OuterRadius (Optional) The outer radius in meters where the new group will be spawned. +-- @param #number InnerRadius (Optional) The inner radius in meters where the new group will NOT be spawned. +-- @param #number SpawnIndex (Optional) The index which group to spawn within the given zone. +-- @return Group#GROUP that was spawned. +-- @return #nil Nothing was spawned. +function SPAWN:SpawnFromVec3( Vec3, OuterRadius, InnerRadius, SpawnIndex ) + self:F( { self.SpawnTemplatePrefix, Vec3, OuterRadius, InnerRadius, SpawnIndex } ) + + local PointVec3 = POINT_VEC3:NewFromVec3( Vec3 ) + self:T2(PointVec3) + + if SpawnIndex then + else + SpawnIndex = self.SpawnIndex + 1 + end + + if self:_GetSpawnIndex( SpawnIndex ) then + + local SpawnTemplate = self.SpawnGroups[self.SpawnIndex].SpawnTemplate + + if SpawnTemplate then + + self:T( { "Current point of ", self.SpawnTemplatePrefix, Vec3 } ) + + SpawnTemplate.route.points[1].x = Vec3.x + SpawnTemplate.route.points[1].y = Vec3.z + SpawnTemplate.route.points[1].alt = Vec3.y + + InnerRadius = InnerRadius or 0 + OuterRadius = OuterRadius or 0 + + -- Apply SpawnFormation + for UnitID = 1, #SpawnTemplate.units do + local RandomVec2 = PointVec3:GetRandomVec2InRadius( OuterRadius, InnerRadius ) + SpawnTemplate.units[UnitID].x = RandomVec2.x + SpawnTemplate.units[UnitID].y = RandomVec2.y + SpawnTemplate.units[UnitID].alt = Vec3.y + self:T( 'SpawnTemplate.units['..UnitID..'].x = ' .. SpawnTemplate.units[UnitID].x .. ', SpawnTemplate.units['..UnitID..'].y = ' .. SpawnTemplate.units[UnitID].y ) + end + + -- TODO: Need to rework this. A spawn action should always be at the random point to start from. This move is not correct to be here. +-- local RandomVec2 = PointVec3:GetRandomVec2InRadius( OuterRadius, InnerRadius ) +-- local Point = {} +-- Point.type = "Turning Point" +-- Point.x = RandomVec2.x +-- Point.y = RandomVec2.y +-- Point.action = "Cone" +-- Point.speed = 5 +-- table.insert( SpawnTemplate.route.points, 2, Point ) + + return self:SpawnWithIndex( self.SpawnIndex ) + end + end + + return nil +end + +--- Will spawn a group from a Vec2 in 3D space. +-- This function is mostly advisable to be used if you want to simulate spawning groups on the ground from air units, like vehicles. +-- Note that each point in the route assigned to the spawning group is reset to the point of the spawn. +-- You can use the returned group to further define the route to be followed. +-- @param #SPAWN self +-- @param DCSTypes#Vec2 Vec2 The Vec2 coordinates where to spawn the group. +-- @param #number OuterRadius (Optional) The outer radius in meters where the new group will be spawned. +-- @param #number InnerRadius (Optional) The inner radius in meters where the new group will NOT be spawned. +-- @param #number SpawnIndex (Optional) The index which group to spawn within the given zone. +-- @return Group#GROUP that was spawned. +-- @return #nil Nothing was spawned. +function SPAWN:SpawnFromVec2( Vec2, OuterRadius, InnerRadius, SpawnIndex ) + self:F( { self.SpawnTemplatePrefix, Vec2, OuterRadius, InnerRadius, SpawnIndex } ) + + local PointVec2 = POINT_VEC2:NewFromVec2( Vec2 ) + return self:SpawnFromVec3( PointVec2:GetVec3(), OuterRadius, InnerRadius, SpawnIndex ) +end --- Will spawn a group from a hosting unit. This function is mostly advisable to be used if you want to simulate spawning from air units, like helicopters, which are dropping infantry into a defined Landing Zone. @@ -544,8 +627,8 @@ end -- You can use the returned group to further define the route to be followed. -- @param #SPAWN self -- @param Unit#UNIT HostUnit The air or ground unit dropping or unloading the group. --- @param #number OuterRadius The outer radius in meters where the new group will be spawned. --- @param #number InnerRadius The inner radius in meters where the new group will NOT be spawned. +-- @param #number OuterRadius (Optional) The outer radius in meters where the new group will be spawned. +-- @param #number InnerRadius (Optional) The inner radius in meters where the new group will NOT be spawned. -- @param #number SpawnIndex (Optional) The index which group to spawn within the given zone. -- @return Group#GROUP that was spawned. -- @return #nil Nothing was spawned. @@ -553,66 +636,26 @@ function SPAWN:SpawnFromUnit( HostUnit, OuterRadius, InnerRadius, SpawnIndex ) self:F( { self.SpawnTemplatePrefix, HostUnit, OuterRadius, InnerRadius, SpawnIndex } ) if HostUnit and HostUnit:IsAlive() then -- and HostUnit:getUnit(1):inAir() == false then + return self:SpawnFromVec3( HostUnit:GetPointVec3(), OuterRadius, InnerRadius, SpawnIndex ) + end + + return nil +end - if SpawnIndex then - else - SpawnIndex = self.SpawnIndex + 1 - end - - if self:_GetSpawnIndex( SpawnIndex ) then - - local SpawnTemplate = self.SpawnGroups[self.SpawnIndex].SpawnTemplate - - if SpawnTemplate then +--- Will spawn a group from a hosting static. This function is mostly advisable to be used if you want to simulate spawning from buldings and structures (static buildings). +-- You can use the returned group to further define the route to be followed. +-- @param #SPAWN self +-- @param Static#STATIC HostStatic The static dropping or unloading the group. +-- @param #number OuterRadius (Optional) The outer radius in meters where the new group will be spawned. +-- @param #number InnerRadius (Optional) The inner radius in meters where the new group will NOT be spawned. +-- @param #number SpawnIndex (Optional) The index which group to spawn within the given zone. +-- @return Group#GROUP that was spawned. +-- @return #nil Nothing was spawned. +function SPAWN:SpawnFromStatic( HostStatic, OuterRadius, InnerRadius, SpawnIndex ) + self:F( { self.SpawnTemplatePrefix, HostStatic, OuterRadius, InnerRadius, SpawnIndex } ) - local UnitPoint = HostUnit:GetVec2() - - self:T( { "Current point of ", self.SpawnTemplatePrefix, UnitPoint } ) - - --for PointID, Point in pairs( SpawnTemplate.route.points ) do - --Point.x = UnitPoint.x - --Point.y = UnitPoint.y - --Point.alt = nil - --Point.alt_type = nil - --end - - SpawnTemplate.route.points[1].x = UnitPoint.x - SpawnTemplate.route.points[1].y = UnitPoint.y - - if not InnerRadius then - InnerRadius = 10 - end - - if not OuterRadius then - OuterRadius = 50 - end - - -- Apply SpawnFormation - for UnitID = 1, #SpawnTemplate.units do - if InnerRadius == 0 then - SpawnTemplate.units[UnitID].x = UnitPoint.x - SpawnTemplate.units[UnitID].y = UnitPoint.y - else - local CirclePos = routines.getRandPointInCircle( UnitPoint, OuterRadius, InnerRadius ) - SpawnTemplate.units[UnitID].x = CirclePos.x - SpawnTemplate.units[UnitID].y = CirclePos.y - end - self:T( 'SpawnTemplate.units['..UnitID..'].x = ' .. SpawnTemplate.units[UnitID].x .. ', SpawnTemplate.units['..UnitID..'].y = ' .. SpawnTemplate.units[UnitID].y ) - end - - local SpawnPos = routines.getRandPointInCircle( UnitPoint, OuterRadius, InnerRadius ) - local Point = {} - Point.type = "Turning Point" - Point.x = SpawnPos.x - Point.y = SpawnPos.y - Point.action = "Cone" - Point.speed = 5 - - table.insert( SpawnTemplate.route.points, 2, Point ) - - return self:SpawnWithIndex( self.SpawnIndex ) - end - end + if HostStatic and HostStatic:IsAlive() then + return self:SpawnFromVec3( HostStatic:GetPointVec3(), OuterRadius, InnerRadius, SpawnIndex ) end return nil @@ -631,39 +674,10 @@ function SPAWN:SpawnInZone( Zone, ZoneRandomize, SpawnIndex ) self:F( { self.SpawnTemplatePrefix, Zone, ZoneRandomize, SpawnIndex } ) if Zone then - - if SpawnIndex then + if ZoneRandomize then + return self:SpawnFromVec2( Zone:GetVec2(), Zone:GetRadius(), 0, SpawnIndex ) else - SpawnIndex = self.SpawnIndex + 1 - end - - if self:_GetSpawnIndex( SpawnIndex ) then - - local SpawnTemplate = self.SpawnGroups[self.SpawnIndex].SpawnTemplate - - if SpawnTemplate then - - local ZonePoint - - if ZoneRandomize == true then - ZonePoint = Zone:GetRandomVec2() - else - ZonePoint = Zone:GetVec2() - end - - SpawnTemplate.route.points[1].x = ZonePoint.x - SpawnTemplate.route.points[1].y = ZonePoint.y - - -- Apply SpawnFormation - for UnitID = 1, #SpawnTemplate.units do - local ZonePointUnit = Zone:GetRandomVec2() - SpawnTemplate.units[UnitID].x = ZonePointUnit.x - SpawnTemplate.units[UnitID].y = ZonePointUnit.y - self:T( 'SpawnTemplate.units['..UnitID..'].x = ' .. SpawnTemplate.units[UnitID].x .. ', SpawnTemplate.units['..UnitID..'].y = ' .. SpawnTemplate.units[UnitID].y ) - end - - return self:SpawnWithIndex( self.SpawnIndex ) - end + return self:SpawnFromVec2( Zone:GetVec2(), 0, 0, SpawnIndex ) end end diff --git a/Moose Development/Moose/Static.lua b/Moose Development/Moose/Static.lua index 6833cf646..7d6492672 100644 --- a/Moose Development/Moose/Static.lua +++ b/Moose Development/Moose/Static.lua @@ -52,6 +52,8 @@ STATIC = { function STATIC:FindByName( StaticName ) local StaticFound = _DATABASE:FindStatic( StaticName ) + self.StaticName = StaticName + if StaticFound then StaticFound:F( { StaticName } ) @@ -63,12 +65,13 @@ end function STATIC:Register( StaticName ) local self = BASE:Inherit( self, POSITIONABLE:New( StaticName ) ) + self.StaticName = StaticName return self end -function STATIC:GetDCSUnit() - local DCSStatic = StaticObject.getByName( self.UnitName ) +function STATIC:GetDCSObject() + local DCSStatic = StaticObject.getByName( self.StaticName ) if DCSStatic then return DCSStatic diff --git a/Moose Development/Moose/Zone.lua b/Moose Development/Moose/Zone.lua index 6db3a3f20..30b118fcd 100644 --- a/Moose Development/Moose/Zone.lua +++ b/Moose Development/Moose/Zone.lua @@ -287,15 +287,16 @@ end -- @param DCSTypes#Distance Height The height to add to the land height where the center of the zone is located. -- @return DCSTypes#Vec3 The point of the zone. function ZONE_RADIUS:GetPointVec3( Height ) - self:F2( self.ZoneName ) - + self:F2( { self.ZoneName, Height } ) + + Height = Height or 0 local Vec2 = self:GetVec2() - local PointVec3 = { x = Vec2.x, y = land.getHeight( self:GetVec2() ) + Height, z = Vec2.y } + local Vec3 = { x = Vec2.x, y = land.getHeight( self:GetVec2() ) + Height, z = Vec2.y } - self:T2( { PointVec3 } ) + self:T2( { Vec3 } ) - return PointVec3 + return Vec3 end 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 21c7fa9fc..6aba8f786 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: 20160722_1718' ) +env.info( 'Moose Generation Timestamp: 20160723_1028' ) local base = _G Include = {} @@ -9864,15 +9864,16 @@ end -- @param DCSTypes#Distance Height The height to add to the land height where the center of the zone is located. -- @return DCSTypes#Vec3 The point of the zone. function ZONE_RADIUS:GetPointVec3( Height ) - self:F2( self.ZoneName ) - + self:F2( { self.ZoneName, Height } ) + + Height = Height or 0 local Vec2 = self:GetVec2() - local PointVec3 = { x = Vec2.x, y = land.getHeight( self:GetVec2() ) + Height, z = Vec2.y } + local Vec3 = { x = Vec2.x, y = land.getHeight( self:GetVec2() ) + Height, z = Vec2.y } - self:T2( { PointVec3 } ) + self:T2( { Vec3 } ) - return PointVec3 + return Vec3 end @@ -10811,6 +10812,8 @@ STATIC = { function STATIC:FindByName( StaticName ) local StaticFound = _DATABASE:FindStatic( StaticName ) + self.StaticName = StaticName + if StaticFound then StaticFound:F( { StaticName } ) @@ -10822,12 +10825,13 @@ end function STATIC:Register( StaticName ) local self = BASE:Inherit( self, POSITIONABLE:New( StaticName ) ) + self.StaticName = StaticName return self end -function STATIC:GetDCSUnit() - local DCSStatic = StaticObject.getByName( self.UnitName ) +function STATIC:GetDCSObject() + local DCSStatic = StaticObject.getByName( self.StaticName ) if DCSStatic then return DCSStatic @@ -14054,10 +14058,7 @@ end -- @return Point#POINT_VEC3 self function POINT_VEC3:NewFromVec3( Vec3 ) - local self = BASE:Inherit( self, BASE:New() ) - self.PointVec3 = Vec3 - self:F2( self.PointVec3 ) - return self + return self:New( Vec3.x, Vec3.y, Vec3.z ) end @@ -14068,11 +14069,19 @@ function POINT_VEC3:GetVec3() return self.PointVec3 end +--- Return the coordinates of the POINT_VEC3 in Vec2 format. +-- @param #POINT_VEC3 self +-- @return DCSTypes#Vec2 The Vec2 coodinate. +function POINT_VEC3:GetVec2() + return { x = self.PointVec3.x, y = self.PointVec3.z } +end + --- Return the x coordinate of the POINT_VEC3. -- @param #POINT_VEC3 self -- @return #number The x coodinate. function POINT_VEC3:GetX() + self:F2(self.PointVec3.x) return self.PointVec3.x end @@ -14080,6 +14089,7 @@ end -- @param #POINT_VEC3 self -- @return #number The y coodinate. function POINT_VEC3:GetY() + self:F2(self.PointVec3.y) return self.PointVec3.y end @@ -14087,9 +14097,55 @@ end -- @param #POINT_VEC3 self -- @return #number The z coodinate. function POINT_VEC3:GetZ() + self:F2(self.PointVec3.z) return self.PointVec3.z end +--- Return a random Vec3 point within an Outer Radius and optionally NOT within an Inner Radius of the POINT_VEC3. +-- @param #POINT_VEC3 self +-- @param DCSTypes#Distance OuterRadius +-- @param DCSTypes#Distance InnerRadius +-- @return DCSTypes#Vec2 Vec2 +function POINT_VEC3:GetRandomVec2InRadius( OuterRadius, InnerRadius ) + self:F2( { self.PointVec3, OuterRadius, InnerRadius } ) + + local Theta = 2 * math.pi * math.random() + local Radials = math.random() + math.random() + if Radials > 1 then + Radials = 2 - Radials + end + + local RadialMultiplier + if InnerRadius and InnerRadius <= OuterRadius then + RadialMultiplier = ( OuterRadius - InnerRadius ) * Radials + InnerRadius + else + RadialMultiplier = OuterRadius * Radials + end + + local RandomVec3 + if OuterRadius > 0 then + RandomVec3 = { x = math.cos( Theta ) * RadialMultiplier + self:GetX(), y = math.sin( Theta ) * RadialMultiplier + self:GetZ() } + else + RandomVec3 = { x = self:GetX(), y = self:GetZ() } + end + + return RandomVec3 +end + +--- Return a random Vec3 point within an Outer Radius and optionally NOT within an Inner Radius of the POINT_VEC3. +-- @param #POINT_VEC3 self +-- @param DCSTypes#Distance OuterRadius +-- @param DCSTypes#Distance InnerRadius +-- @return DCSTypes#Vec3 Vec3 +function POINT_VEC3:GetRandomVec3InRadius( OuterRadius, InnerRadius ) + + local RandomVec2 = self:GetRandomVec2InRadius( OuterRadius, InnerRadius ) + local y = self:GetY() + math.random( InnerRadius, OuterRadius ) + local RandomVec3 = { x = RandomVec2.x, y = y, z = RandomVec2.z } + + return RandomVec3 +end + --- Return a direction vector Vec3 from POINT_VEC3 to the POINT_VEC3. -- @param #POINT_VEC3 self @@ -14373,6 +14429,28 @@ function POINT_VEC2:New( x, y, LandHeightAdd ) return self end +--- Create a new POINT_VEC2 object from Vec2 coordinates. +-- @param #POINT_VEC2 self +-- @param DCSTypes#Vec2 Vec2 The Vec2 point. +-- @return Point#POINT_VEC2 self +function POINT_VEC2:NewFromVec2( Vec2, LandHeightAdd ) + + local self = BASE:Inherit( self, BASE:New() ) + + local LandHeight = land.getHeight( Vec2 ) + if LandHeightAdd then + LandHeight = LandHeight + LandHeightAdd + end + + local self = BASE:Inherit( self, POINT_VEC3:New( Vec2.x, LandHeight, Vec2.y ) ) + self:F2( { Vec2.x, Vec2.y, LandHeightAdd } ) + + self.PointVec2 = Vec2 + self:F2( self.PointVec3 ) + + return self +end + --- Calculate the distance from a reference @{Point#POINT_VEC2}. -- @param #POINT_VEC2 self -- @param #POINT_VEC2 PointVec2Reference The reference @{Point#POINT_VEC2}. @@ -20238,6 +20316,9 @@ end -- * @{#SPAWN.Spawn}: Spawn one new group based on the last spawned index. -- * @{#SPAWN.ReSpawn}: Re-spawn a group based on a given index. -- * @{#SPAWN.SpawnScheduled}: Spawn groups at scheduled but randomized intervals. You can use @{#SPAWN.SpawnScheduleStart} and @{#SPAWN.SpawnScheduleStop} to start and stop the schedule respectively. +-- * @{#SPAWN.SpawnFromVec3}: Spawn a new group from a Vec3 coordinate. (The group will can be spawned at a point in the air). +-- * @{#SPAWN.SpawnFromVec2}: Spawn a new group from a Vec2 coordinate. (The group will be spawned at land height ). +-- * @{#SPAWN.SpawnFromStatic}: Spawn a new group from a structure, taking the position of a @{STATIC}. -- * @{#SPAWN.SpawnFromUnit}: Spawn a new group taking the position of a @{UNIT}. -- * @{#SPAWN.SpawnInZone}: Spawn a new group in a @{ZONE}. -- @@ -20723,6 +20804,86 @@ function SPAWN:SpawnFunction( SpawnFunctionHook, ... ) end +--- Will spawn a group from a Vec3 in 3D space. +-- This function is mostly advisable to be used if you want to simulate spawning units in the air, like helicopters or airplanes. +-- Note that each point in the route assigned to the spawning group is reset to the point of the spawn. +-- You can use the returned group to further define the route to be followed. +-- @param #SPAWN self +-- @param DCSTypes#Vec3 Vec3 The Vec3 coordinates where to spawn the group. +-- @param #number OuterRadius (Optional) The outer radius in meters where the new group will be spawned. +-- @param #number InnerRadius (Optional) The inner radius in meters where the new group will NOT be spawned. +-- @param #number SpawnIndex (Optional) The index which group to spawn within the given zone. +-- @return Group#GROUP that was spawned. +-- @return #nil Nothing was spawned. +function SPAWN:SpawnFromVec3( Vec3, OuterRadius, InnerRadius, SpawnIndex ) + self:F( { self.SpawnTemplatePrefix, Vec3, OuterRadius, InnerRadius, SpawnIndex } ) + + local PointVec3 = POINT_VEC3:NewFromVec3( Vec3 ) + self:T2(PointVec3) + + if SpawnIndex then + else + SpawnIndex = self.SpawnIndex + 1 + end + + if self:_GetSpawnIndex( SpawnIndex ) then + + local SpawnTemplate = self.SpawnGroups[self.SpawnIndex].SpawnTemplate + + if SpawnTemplate then + + self:T( { "Current point of ", self.SpawnTemplatePrefix, Vec3 } ) + + SpawnTemplate.route.points[1].x = Vec3.x + SpawnTemplate.route.points[1].y = Vec3.z + SpawnTemplate.route.points[1].alt = Vec3.y + + InnerRadius = InnerRadius or 0 + OuterRadius = OuterRadius or 0 + + -- Apply SpawnFormation + for UnitID = 1, #SpawnTemplate.units do + local RandomVec2 = PointVec3:GetRandomVec2InRadius( OuterRadius, InnerRadius ) + SpawnTemplate.units[UnitID].x = RandomVec2.x + SpawnTemplate.units[UnitID].y = RandomVec2.y + SpawnTemplate.units[UnitID].alt = Vec3.y + self:T( 'SpawnTemplate.units['..UnitID..'].x = ' .. SpawnTemplate.units[UnitID].x .. ', SpawnTemplate.units['..UnitID..'].y = ' .. SpawnTemplate.units[UnitID].y ) + end + + -- TODO: Need to rework this. A spawn action should always be at the random point to start from. This move is not correct to be here. +-- local RandomVec2 = PointVec3:GetRandomVec2InRadius( OuterRadius, InnerRadius ) +-- local Point = {} +-- Point.type = "Turning Point" +-- Point.x = RandomVec2.x +-- Point.y = RandomVec2.y +-- Point.action = "Cone" +-- Point.speed = 5 +-- table.insert( SpawnTemplate.route.points, 2, Point ) + + return self:SpawnWithIndex( self.SpawnIndex ) + end + end + + return nil +end + +--- Will spawn a group from a Vec2 in 3D space. +-- This function is mostly advisable to be used if you want to simulate spawning groups on the ground from air units, like vehicles. +-- Note that each point in the route assigned to the spawning group is reset to the point of the spawn. +-- You can use the returned group to further define the route to be followed. +-- @param #SPAWN self +-- @param DCSTypes#Vec2 Vec2 The Vec2 coordinates where to spawn the group. +-- @param #number OuterRadius (Optional) The outer radius in meters where the new group will be spawned. +-- @param #number InnerRadius (Optional) The inner radius in meters where the new group will NOT be spawned. +-- @param #number SpawnIndex (Optional) The index which group to spawn within the given zone. +-- @return Group#GROUP that was spawned. +-- @return #nil Nothing was spawned. +function SPAWN:SpawnFromVec2( Vec2, OuterRadius, InnerRadius, SpawnIndex ) + self:F( { self.SpawnTemplatePrefix, Vec2, OuterRadius, InnerRadius, SpawnIndex } ) + + local PointVec2 = POINT_VEC2:NewFromVec2( Vec2 ) + return self:SpawnFromVec3( PointVec2:GetVec3(), OuterRadius, InnerRadius, SpawnIndex ) +end --- Will spawn a group from a hosting unit. This function is mostly advisable to be used if you want to simulate spawning from air units, like helicopters, which are dropping infantry into a defined Landing Zone. @@ -20730,8 +20891,8 @@ end -- You can use the returned group to further define the route to be followed. -- @param #SPAWN self -- @param Unit#UNIT HostUnit The air or ground unit dropping or unloading the group. --- @param #number OuterRadius The outer radius in meters where the new group will be spawned. --- @param #number InnerRadius The inner radius in meters where the new group will NOT be spawned. +-- @param #number OuterRadius (Optional) The outer radius in meters where the new group will be spawned. +-- @param #number InnerRadius (Optional) The inner radius in meters where the new group will NOT be spawned. -- @param #number SpawnIndex (Optional) The index which group to spawn within the given zone. -- @return Group#GROUP that was spawned. -- @return #nil Nothing was spawned. @@ -20739,66 +20900,26 @@ function SPAWN:SpawnFromUnit( HostUnit, OuterRadius, InnerRadius, SpawnIndex ) self:F( { self.SpawnTemplatePrefix, HostUnit, OuterRadius, InnerRadius, SpawnIndex } ) if HostUnit and HostUnit:IsAlive() then -- and HostUnit:getUnit(1):inAir() == false then + return self:SpawnFromVec3( HostUnit:GetPointVec3(), OuterRadius, InnerRadius, SpawnIndex ) + end + + return nil +end - if SpawnIndex then - else - SpawnIndex = self.SpawnIndex + 1 - end - - if self:_GetSpawnIndex( SpawnIndex ) then - - local SpawnTemplate = self.SpawnGroups[self.SpawnIndex].SpawnTemplate - - if SpawnTemplate then +--- Will spawn a group from a hosting static. This function is mostly advisable to be used if you want to simulate spawning from buldings and structures (static buildings). +-- You can use the returned group to further define the route to be followed. +-- @param #SPAWN self +-- @param Static#STATIC HostStatic The static dropping or unloading the group. +-- @param #number OuterRadius (Optional) The outer radius in meters where the new group will be spawned. +-- @param #number InnerRadius (Optional) The inner radius in meters where the new group will NOT be spawned. +-- @param #number SpawnIndex (Optional) The index which group to spawn within the given zone. +-- @return Group#GROUP that was spawned. +-- @return #nil Nothing was spawned. +function SPAWN:SpawnFromStatic( HostStatic, OuterRadius, InnerRadius, SpawnIndex ) + self:F( { self.SpawnTemplatePrefix, HostStatic, OuterRadius, InnerRadius, SpawnIndex } ) - local UnitPoint = HostUnit:GetVec2() - - self:T( { "Current point of ", self.SpawnTemplatePrefix, UnitPoint } ) - - --for PointID, Point in pairs( SpawnTemplate.route.points ) do - --Point.x = UnitPoint.x - --Point.y = UnitPoint.y - --Point.alt = nil - --Point.alt_type = nil - --end - - SpawnTemplate.route.points[1].x = UnitPoint.x - SpawnTemplate.route.points[1].y = UnitPoint.y - - if not InnerRadius then - InnerRadius = 10 - end - - if not OuterRadius then - OuterRadius = 50 - end - - -- Apply SpawnFormation - for UnitID = 1, #SpawnTemplate.units do - if InnerRadius == 0 then - SpawnTemplate.units[UnitID].x = UnitPoint.x - SpawnTemplate.units[UnitID].y = UnitPoint.y - else - local CirclePos = routines.getRandPointInCircle( UnitPoint, OuterRadius, InnerRadius ) - SpawnTemplate.units[UnitID].x = CirclePos.x - SpawnTemplate.units[UnitID].y = CirclePos.y - end - self:T( 'SpawnTemplate.units['..UnitID..'].x = ' .. SpawnTemplate.units[UnitID].x .. ', SpawnTemplate.units['..UnitID..'].y = ' .. SpawnTemplate.units[UnitID].y ) - end - - local SpawnPos = routines.getRandPointInCircle( UnitPoint, OuterRadius, InnerRadius ) - local Point = {} - Point.type = "Turning Point" - Point.x = SpawnPos.x - Point.y = SpawnPos.y - Point.action = "Cone" - Point.speed = 5 - - table.insert( SpawnTemplate.route.points, 2, Point ) - - return self:SpawnWithIndex( self.SpawnIndex ) - end - end + if HostStatic and HostStatic:IsAlive() then + return self:SpawnFromVec3( HostStatic:GetPointVec3(), OuterRadius, InnerRadius, SpawnIndex ) end return nil @@ -20817,39 +20938,10 @@ function SPAWN:SpawnInZone( Zone, ZoneRandomize, SpawnIndex ) self:F( { self.SpawnTemplatePrefix, Zone, ZoneRandomize, SpawnIndex } ) if Zone then - - if SpawnIndex then + if ZoneRandomize then + return self:SpawnFromVec2( Zone:GetVec2(), Zone:GetRadius(), 0, SpawnIndex ) else - SpawnIndex = self.SpawnIndex + 1 - end - - if self:_GetSpawnIndex( SpawnIndex ) then - - local SpawnTemplate = self.SpawnGroups[self.SpawnIndex].SpawnTemplate - - if SpawnTemplate then - - local ZonePoint - - if ZoneRandomize == true then - ZonePoint = Zone:GetRandomVec2() - else - ZonePoint = Zone:GetVec2() - end - - SpawnTemplate.route.points[1].x = ZonePoint.x - SpawnTemplate.route.points[1].y = ZonePoint.y - - -- Apply SpawnFormation - for UnitID = 1, #SpawnTemplate.units do - local ZonePointUnit = Zone:GetRandomVec2() - SpawnTemplate.units[UnitID].x = ZonePointUnit.x - SpawnTemplate.units[UnitID].y = ZonePointUnit.y - self:T( 'SpawnTemplate.units['..UnitID..'].x = ' .. SpawnTemplate.units[UnitID].x .. ', SpawnTemplate.units['..UnitID..'].y = ' .. SpawnTemplate.units[UnitID].y ) - end - - return self:SpawnWithIndex( self.SpawnIndex ) - end + return self:SpawnFromVec2( Zone:GetVec2(), 0, 0, SpawnIndex ) end end diff --git a/Moose Mission Setup/Moose.lua b/Moose Mission Setup/Moose.lua index 21c7fa9fc..6aba8f786 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: 20160722_1718' ) +env.info( 'Moose Generation Timestamp: 20160723_1028' ) local base = _G Include = {} @@ -9864,15 +9864,16 @@ end -- @param DCSTypes#Distance Height The height to add to the land height where the center of the zone is located. -- @return DCSTypes#Vec3 The point of the zone. function ZONE_RADIUS:GetPointVec3( Height ) - self:F2( self.ZoneName ) - + self:F2( { self.ZoneName, Height } ) + + Height = Height or 0 local Vec2 = self:GetVec2() - local PointVec3 = { x = Vec2.x, y = land.getHeight( self:GetVec2() ) + Height, z = Vec2.y } + local Vec3 = { x = Vec2.x, y = land.getHeight( self:GetVec2() ) + Height, z = Vec2.y } - self:T2( { PointVec3 } ) + self:T2( { Vec3 } ) - return PointVec3 + return Vec3 end @@ -10811,6 +10812,8 @@ STATIC = { function STATIC:FindByName( StaticName ) local StaticFound = _DATABASE:FindStatic( StaticName ) + self.StaticName = StaticName + if StaticFound then StaticFound:F( { StaticName } ) @@ -10822,12 +10825,13 @@ end function STATIC:Register( StaticName ) local self = BASE:Inherit( self, POSITIONABLE:New( StaticName ) ) + self.StaticName = StaticName return self end -function STATIC:GetDCSUnit() - local DCSStatic = StaticObject.getByName( self.UnitName ) +function STATIC:GetDCSObject() + local DCSStatic = StaticObject.getByName( self.StaticName ) if DCSStatic then return DCSStatic @@ -14054,10 +14058,7 @@ end -- @return Point#POINT_VEC3 self function POINT_VEC3:NewFromVec3( Vec3 ) - local self = BASE:Inherit( self, BASE:New() ) - self.PointVec3 = Vec3 - self:F2( self.PointVec3 ) - return self + return self:New( Vec3.x, Vec3.y, Vec3.z ) end @@ -14068,11 +14069,19 @@ function POINT_VEC3:GetVec3() return self.PointVec3 end +--- Return the coordinates of the POINT_VEC3 in Vec2 format. +-- @param #POINT_VEC3 self +-- @return DCSTypes#Vec2 The Vec2 coodinate. +function POINT_VEC3:GetVec2() + return { x = self.PointVec3.x, y = self.PointVec3.z } +end + --- Return the x coordinate of the POINT_VEC3. -- @param #POINT_VEC3 self -- @return #number The x coodinate. function POINT_VEC3:GetX() + self:F2(self.PointVec3.x) return self.PointVec3.x end @@ -14080,6 +14089,7 @@ end -- @param #POINT_VEC3 self -- @return #number The y coodinate. function POINT_VEC3:GetY() + self:F2(self.PointVec3.y) return self.PointVec3.y end @@ -14087,9 +14097,55 @@ end -- @param #POINT_VEC3 self -- @return #number The z coodinate. function POINT_VEC3:GetZ() + self:F2(self.PointVec3.z) return self.PointVec3.z end +--- Return a random Vec3 point within an Outer Radius and optionally NOT within an Inner Radius of the POINT_VEC3. +-- @param #POINT_VEC3 self +-- @param DCSTypes#Distance OuterRadius +-- @param DCSTypes#Distance InnerRadius +-- @return DCSTypes#Vec2 Vec2 +function POINT_VEC3:GetRandomVec2InRadius( OuterRadius, InnerRadius ) + self:F2( { self.PointVec3, OuterRadius, InnerRadius } ) + + local Theta = 2 * math.pi * math.random() + local Radials = math.random() + math.random() + if Radials > 1 then + Radials = 2 - Radials + end + + local RadialMultiplier + if InnerRadius and InnerRadius <= OuterRadius then + RadialMultiplier = ( OuterRadius - InnerRadius ) * Radials + InnerRadius + else + RadialMultiplier = OuterRadius * Radials + end + + local RandomVec3 + if OuterRadius > 0 then + RandomVec3 = { x = math.cos( Theta ) * RadialMultiplier + self:GetX(), y = math.sin( Theta ) * RadialMultiplier + self:GetZ() } + else + RandomVec3 = { x = self:GetX(), y = self:GetZ() } + end + + return RandomVec3 +end + +--- Return a random Vec3 point within an Outer Radius and optionally NOT within an Inner Radius of the POINT_VEC3. +-- @param #POINT_VEC3 self +-- @param DCSTypes#Distance OuterRadius +-- @param DCSTypes#Distance InnerRadius +-- @return DCSTypes#Vec3 Vec3 +function POINT_VEC3:GetRandomVec3InRadius( OuterRadius, InnerRadius ) + + local RandomVec2 = self:GetRandomVec2InRadius( OuterRadius, InnerRadius ) + local y = self:GetY() + math.random( InnerRadius, OuterRadius ) + local RandomVec3 = { x = RandomVec2.x, y = y, z = RandomVec2.z } + + return RandomVec3 +end + --- Return a direction vector Vec3 from POINT_VEC3 to the POINT_VEC3. -- @param #POINT_VEC3 self @@ -14373,6 +14429,28 @@ function POINT_VEC2:New( x, y, LandHeightAdd ) return self end +--- Create a new POINT_VEC2 object from Vec2 coordinates. +-- @param #POINT_VEC2 self +-- @param DCSTypes#Vec2 Vec2 The Vec2 point. +-- @return Point#POINT_VEC2 self +function POINT_VEC2:NewFromVec2( Vec2, LandHeightAdd ) + + local self = BASE:Inherit( self, BASE:New() ) + + local LandHeight = land.getHeight( Vec2 ) + if LandHeightAdd then + LandHeight = LandHeight + LandHeightAdd + end + + local self = BASE:Inherit( self, POINT_VEC3:New( Vec2.x, LandHeight, Vec2.y ) ) + self:F2( { Vec2.x, Vec2.y, LandHeightAdd } ) + + self.PointVec2 = Vec2 + self:F2( self.PointVec3 ) + + return self +end + --- Calculate the distance from a reference @{Point#POINT_VEC2}. -- @param #POINT_VEC2 self -- @param #POINT_VEC2 PointVec2Reference The reference @{Point#POINT_VEC2}. @@ -20238,6 +20316,9 @@ end -- * @{#SPAWN.Spawn}: Spawn one new group based on the last spawned index. -- * @{#SPAWN.ReSpawn}: Re-spawn a group based on a given index. -- * @{#SPAWN.SpawnScheduled}: Spawn groups at scheduled but randomized intervals. You can use @{#SPAWN.SpawnScheduleStart} and @{#SPAWN.SpawnScheduleStop} to start and stop the schedule respectively. +-- * @{#SPAWN.SpawnFromVec3}: Spawn a new group from a Vec3 coordinate. (The group will can be spawned at a point in the air). +-- * @{#SPAWN.SpawnFromVec2}: Spawn a new group from a Vec2 coordinate. (The group will be spawned at land height ). +-- * @{#SPAWN.SpawnFromStatic}: Spawn a new group from a structure, taking the position of a @{STATIC}. -- * @{#SPAWN.SpawnFromUnit}: Spawn a new group taking the position of a @{UNIT}. -- * @{#SPAWN.SpawnInZone}: Spawn a new group in a @{ZONE}. -- @@ -20723,6 +20804,86 @@ function SPAWN:SpawnFunction( SpawnFunctionHook, ... ) end +--- Will spawn a group from a Vec3 in 3D space. +-- This function is mostly advisable to be used if you want to simulate spawning units in the air, like helicopters or airplanes. +-- Note that each point in the route assigned to the spawning group is reset to the point of the spawn. +-- You can use the returned group to further define the route to be followed. +-- @param #SPAWN self +-- @param DCSTypes#Vec3 Vec3 The Vec3 coordinates where to spawn the group. +-- @param #number OuterRadius (Optional) The outer radius in meters where the new group will be spawned. +-- @param #number InnerRadius (Optional) The inner radius in meters where the new group will NOT be spawned. +-- @param #number SpawnIndex (Optional) The index which group to spawn within the given zone. +-- @return Group#GROUP that was spawned. +-- @return #nil Nothing was spawned. +function SPAWN:SpawnFromVec3( Vec3, OuterRadius, InnerRadius, SpawnIndex ) + self:F( { self.SpawnTemplatePrefix, Vec3, OuterRadius, InnerRadius, SpawnIndex } ) + + local PointVec3 = POINT_VEC3:NewFromVec3( Vec3 ) + self:T2(PointVec3) + + if SpawnIndex then + else + SpawnIndex = self.SpawnIndex + 1 + end + + if self:_GetSpawnIndex( SpawnIndex ) then + + local SpawnTemplate = self.SpawnGroups[self.SpawnIndex].SpawnTemplate + + if SpawnTemplate then + + self:T( { "Current point of ", self.SpawnTemplatePrefix, Vec3 } ) + + SpawnTemplate.route.points[1].x = Vec3.x + SpawnTemplate.route.points[1].y = Vec3.z + SpawnTemplate.route.points[1].alt = Vec3.y + + InnerRadius = InnerRadius or 0 + OuterRadius = OuterRadius or 0 + + -- Apply SpawnFormation + for UnitID = 1, #SpawnTemplate.units do + local RandomVec2 = PointVec3:GetRandomVec2InRadius( OuterRadius, InnerRadius ) + SpawnTemplate.units[UnitID].x = RandomVec2.x + SpawnTemplate.units[UnitID].y = RandomVec2.y + SpawnTemplate.units[UnitID].alt = Vec3.y + self:T( 'SpawnTemplate.units['..UnitID..'].x = ' .. SpawnTemplate.units[UnitID].x .. ', SpawnTemplate.units['..UnitID..'].y = ' .. SpawnTemplate.units[UnitID].y ) + end + + -- TODO: Need to rework this. A spawn action should always be at the random point to start from. This move is not correct to be here. +-- local RandomVec2 = PointVec3:GetRandomVec2InRadius( OuterRadius, InnerRadius ) +-- local Point = {} +-- Point.type = "Turning Point" +-- Point.x = RandomVec2.x +-- Point.y = RandomVec2.y +-- Point.action = "Cone" +-- Point.speed = 5 +-- table.insert( SpawnTemplate.route.points, 2, Point ) + + return self:SpawnWithIndex( self.SpawnIndex ) + end + end + + return nil +end + +--- Will spawn a group from a Vec2 in 3D space. +-- This function is mostly advisable to be used if you want to simulate spawning groups on the ground from air units, like vehicles. +-- Note that each point in the route assigned to the spawning group is reset to the point of the spawn. +-- You can use the returned group to further define the route to be followed. +-- @param #SPAWN self +-- @param DCSTypes#Vec2 Vec2 The Vec2 coordinates where to spawn the group. +-- @param #number OuterRadius (Optional) The outer radius in meters where the new group will be spawned. +-- @param #number InnerRadius (Optional) The inner radius in meters where the new group will NOT be spawned. +-- @param #number SpawnIndex (Optional) The index which group to spawn within the given zone. +-- @return Group#GROUP that was spawned. +-- @return #nil Nothing was spawned. +function SPAWN:SpawnFromVec2( Vec2, OuterRadius, InnerRadius, SpawnIndex ) + self:F( { self.SpawnTemplatePrefix, Vec2, OuterRadius, InnerRadius, SpawnIndex } ) + + local PointVec2 = POINT_VEC2:NewFromVec2( Vec2 ) + return self:SpawnFromVec3( PointVec2:GetVec3(), OuterRadius, InnerRadius, SpawnIndex ) +end --- Will spawn a group from a hosting unit. This function is mostly advisable to be used if you want to simulate spawning from air units, like helicopters, which are dropping infantry into a defined Landing Zone. @@ -20730,8 +20891,8 @@ end -- You can use the returned group to further define the route to be followed. -- @param #SPAWN self -- @param Unit#UNIT HostUnit The air or ground unit dropping or unloading the group. --- @param #number OuterRadius The outer radius in meters where the new group will be spawned. --- @param #number InnerRadius The inner radius in meters where the new group will NOT be spawned. +-- @param #number OuterRadius (Optional) The outer radius in meters where the new group will be spawned. +-- @param #number InnerRadius (Optional) The inner radius in meters where the new group will NOT be spawned. -- @param #number SpawnIndex (Optional) The index which group to spawn within the given zone. -- @return Group#GROUP that was spawned. -- @return #nil Nothing was spawned. @@ -20739,66 +20900,26 @@ function SPAWN:SpawnFromUnit( HostUnit, OuterRadius, InnerRadius, SpawnIndex ) self:F( { self.SpawnTemplatePrefix, HostUnit, OuterRadius, InnerRadius, SpawnIndex } ) if HostUnit and HostUnit:IsAlive() then -- and HostUnit:getUnit(1):inAir() == false then + return self:SpawnFromVec3( HostUnit:GetPointVec3(), OuterRadius, InnerRadius, SpawnIndex ) + end + + return nil +end - if SpawnIndex then - else - SpawnIndex = self.SpawnIndex + 1 - end - - if self:_GetSpawnIndex( SpawnIndex ) then - - local SpawnTemplate = self.SpawnGroups[self.SpawnIndex].SpawnTemplate - - if SpawnTemplate then +--- Will spawn a group from a hosting static. This function is mostly advisable to be used if you want to simulate spawning from buldings and structures (static buildings). +-- You can use the returned group to further define the route to be followed. +-- @param #SPAWN self +-- @param Static#STATIC HostStatic The static dropping or unloading the group. +-- @param #number OuterRadius (Optional) The outer radius in meters where the new group will be spawned. +-- @param #number InnerRadius (Optional) The inner radius in meters where the new group will NOT be spawned. +-- @param #number SpawnIndex (Optional) The index which group to spawn within the given zone. +-- @return Group#GROUP that was spawned. +-- @return #nil Nothing was spawned. +function SPAWN:SpawnFromStatic( HostStatic, OuterRadius, InnerRadius, SpawnIndex ) + self:F( { self.SpawnTemplatePrefix, HostStatic, OuterRadius, InnerRadius, SpawnIndex } ) - local UnitPoint = HostUnit:GetVec2() - - self:T( { "Current point of ", self.SpawnTemplatePrefix, UnitPoint } ) - - --for PointID, Point in pairs( SpawnTemplate.route.points ) do - --Point.x = UnitPoint.x - --Point.y = UnitPoint.y - --Point.alt = nil - --Point.alt_type = nil - --end - - SpawnTemplate.route.points[1].x = UnitPoint.x - SpawnTemplate.route.points[1].y = UnitPoint.y - - if not InnerRadius then - InnerRadius = 10 - end - - if not OuterRadius then - OuterRadius = 50 - end - - -- Apply SpawnFormation - for UnitID = 1, #SpawnTemplate.units do - if InnerRadius == 0 then - SpawnTemplate.units[UnitID].x = UnitPoint.x - SpawnTemplate.units[UnitID].y = UnitPoint.y - else - local CirclePos = routines.getRandPointInCircle( UnitPoint, OuterRadius, InnerRadius ) - SpawnTemplate.units[UnitID].x = CirclePos.x - SpawnTemplate.units[UnitID].y = CirclePos.y - end - self:T( 'SpawnTemplate.units['..UnitID..'].x = ' .. SpawnTemplate.units[UnitID].x .. ', SpawnTemplate.units['..UnitID..'].y = ' .. SpawnTemplate.units[UnitID].y ) - end - - local SpawnPos = routines.getRandPointInCircle( UnitPoint, OuterRadius, InnerRadius ) - local Point = {} - Point.type = "Turning Point" - Point.x = SpawnPos.x - Point.y = SpawnPos.y - Point.action = "Cone" - Point.speed = 5 - - table.insert( SpawnTemplate.route.points, 2, Point ) - - return self:SpawnWithIndex( self.SpawnIndex ) - end - end + if HostStatic and HostStatic:IsAlive() then + return self:SpawnFromVec3( HostStatic:GetPointVec3(), OuterRadius, InnerRadius, SpawnIndex ) end return nil @@ -20817,39 +20938,10 @@ function SPAWN:SpawnInZone( Zone, ZoneRandomize, SpawnIndex ) self:F( { self.SpawnTemplatePrefix, Zone, ZoneRandomize, SpawnIndex } ) if Zone then - - if SpawnIndex then + if ZoneRandomize then + return self:SpawnFromVec2( Zone:GetVec2(), Zone:GetRadius(), 0, SpawnIndex ) else - SpawnIndex = self.SpawnIndex + 1 - end - - if self:_GetSpawnIndex( SpawnIndex ) then - - local SpawnTemplate = self.SpawnGroups[self.SpawnIndex].SpawnTemplate - - if SpawnTemplate then - - local ZonePoint - - if ZoneRandomize == true then - ZonePoint = Zone:GetRandomVec2() - else - ZonePoint = Zone:GetVec2() - end - - SpawnTemplate.route.points[1].x = ZonePoint.x - SpawnTemplate.route.points[1].y = ZonePoint.y - - -- Apply SpawnFormation - for UnitID = 1, #SpawnTemplate.units do - local ZonePointUnit = Zone:GetRandomVec2() - SpawnTemplate.units[UnitID].x = ZonePointUnit.x - SpawnTemplate.units[UnitID].y = ZonePointUnit.y - self:T( 'SpawnTemplate.units['..UnitID..'].x = ' .. SpawnTemplate.units[UnitID].x .. ', SpawnTemplate.units['..UnitID..'].y = ' .. SpawnTemplate.units[UnitID].y ) - end - - return self:SpawnWithIndex( self.SpawnIndex ) - end + return self:SpawnFromVec2( Zone:GetVec2(), 0, 0, SpawnIndex ) end end diff --git a/Moose Test Missions/MOOSE_Test_Template.miz b/Moose Test Missions/MOOSE_Test_Template.miz index b26984a78..227b83112 100644 Binary files a/Moose Test Missions/MOOSE_Test_Template.miz and b/Moose Test Missions/MOOSE_Test_Template.miz differ diff --git a/Moose Test Missions/Moose_Test_AIBALANCER/Moose_Test_AIBALANCER.miz b/Moose Test Missions/Moose_Test_AIBALANCER/Moose_Test_AIBALANCER.miz index 612bb5df2..6e9587695 100644 Binary files a/Moose Test Missions/Moose_Test_AIBALANCER/Moose_Test_AIBALANCER.miz and b/Moose Test Missions/Moose_Test_AIBALANCER/Moose_Test_AIBALANCER.miz differ diff --git a/Moose Test Missions/Moose_Test_AIRBASEPOLICE/Moose_Test_AIRBASEPOLICE-DB.miz b/Moose Test Missions/Moose_Test_AIRBASEPOLICE/Moose_Test_AIRBASEPOLICE-DB.miz index ce32a91c3..c97c5b76d 100644 Binary files a/Moose Test Missions/Moose_Test_AIRBASEPOLICE/Moose_Test_AIRBASEPOLICE-DB.miz and b/Moose Test Missions/Moose_Test_AIRBASEPOLICE/Moose_Test_AIRBASEPOLICE-DB.miz differ diff --git a/Moose Test Missions/Moose_Test_AIRBASEPOLICE/Moose_Test_AIRBASEPOLICE.miz b/Moose Test Missions/Moose_Test_AIRBASEPOLICE/Moose_Test_AIRBASEPOLICE.miz index 8c6ee7555..e06d201aa 100644 Binary files a/Moose Test Missions/Moose_Test_AIRBASEPOLICE/Moose_Test_AIRBASEPOLICE.miz and b/Moose Test Missions/Moose_Test_AIRBASEPOLICE/Moose_Test_AIRBASEPOLICE.miz differ diff --git a/Moose Test Missions/Moose_Test_AIRBASEPOLICE/Moose_Test_AIRBASEPOLICE_CAUCASUS.miz b/Moose Test Missions/Moose_Test_AIRBASEPOLICE/Moose_Test_AIRBASEPOLICE_CAUCASUS.miz index 995a76834..ae217dbce 100644 Binary files a/Moose Test Missions/Moose_Test_AIRBASEPOLICE/Moose_Test_AIRBASEPOLICE_CAUCASUS.miz and b/Moose Test Missions/Moose_Test_AIRBASEPOLICE/Moose_Test_AIRBASEPOLICE_CAUCASUS.miz differ diff --git a/Moose Test Missions/Moose_Test_AIRBASEPOLICE/Moose_Test_AIRBASEPOLICE_NEVADA.miz b/Moose Test Missions/Moose_Test_AIRBASEPOLICE/Moose_Test_AIRBASEPOLICE_NEVADA.miz index 37df2feb6..5a44886d8 100644 Binary files a/Moose Test Missions/Moose_Test_AIRBASEPOLICE/Moose_Test_AIRBASEPOLICE_NEVADA.miz and b/Moose Test Missions/Moose_Test_AIRBASEPOLICE/Moose_Test_AIRBASEPOLICE_NEVADA.miz differ diff --git a/Moose Test Missions/Moose_Test_BASE/Moose_Test_AIRBLANCER_with_Moose.miz b/Moose Test Missions/Moose_Test_BASE/Moose_Test_AIRBLANCER_with_Moose.miz index 10eb96568..f27989837 100644 Binary files a/Moose Test Missions/Moose_Test_BASE/Moose_Test_AIRBLANCER_with_Moose.miz and b/Moose Test Missions/Moose_Test_BASE/Moose_Test_AIRBLANCER_with_Moose.miz differ diff --git a/Moose Test Missions/Moose_Test_BASE/Moose_Test_AIRBLANCER_without_Moose.miz b/Moose Test Missions/Moose_Test_BASE/Moose_Test_AIRBLANCER_without_Moose.miz index 9d23ef6fe..a2d787da4 100644 Binary files a/Moose Test Missions/Moose_Test_BASE/Moose_Test_AIRBLANCER_without_Moose.miz and b/Moose Test Missions/Moose_Test_BASE/Moose_Test_AIRBLANCER_without_Moose.miz differ diff --git a/Moose Test Missions/Moose_Test_BASE/Moose_Test_BASE.miz b/Moose Test Missions/Moose_Test_BASE/Moose_Test_BASE.miz index fdc8e1944..5616f6191 100644 Binary files a/Moose Test Missions/Moose_Test_BASE/Moose_Test_BASE.miz and b/Moose Test Missions/Moose_Test_BASE/Moose_Test_BASE.miz differ diff --git a/Moose Test Missions/Moose_Test_CLEANUP/Moose_Test_CLEANUP.miz b/Moose Test Missions/Moose_Test_CLEANUP/Moose_Test_CLEANUP.miz index b1723d84b..7cdd53d5a 100644 Binary files a/Moose Test Missions/Moose_Test_CLEANUP/Moose_Test_CLEANUP.miz and b/Moose Test Missions/Moose_Test_CLEANUP/Moose_Test_CLEANUP.miz differ diff --git a/Moose Test Missions/Moose_Test_DETECTION/Moose_Test_DETECTION.miz b/Moose Test Missions/Moose_Test_DETECTION/Moose_Test_DETECTION.miz index 77b8b3fe4..eb40473c5 100644 Binary files a/Moose Test Missions/Moose_Test_DETECTION/Moose_Test_DETECTION.miz and b/Moose Test Missions/Moose_Test_DETECTION/Moose_Test_DETECTION.miz differ diff --git a/Moose Test Missions/Moose_Test_DETECTION/Moose_Test_DETECTION_Laser.miz b/Moose Test Missions/Moose_Test_DETECTION/Moose_Test_DETECTION_Laser.miz index 1c2d92055..df5a7590f 100644 Binary files a/Moose Test Missions/Moose_Test_DETECTION/Moose_Test_DETECTION_Laser.miz and b/Moose Test Missions/Moose_Test_DETECTION/Moose_Test_DETECTION_Laser.miz differ diff --git a/Moose Test Missions/Moose_Test_DETECTION_DISPATCHER/Moose_Test_DETECTION_DISPATCHER.miz b/Moose Test Missions/Moose_Test_DETECTION_DISPATCHER/Moose_Test_DETECTION_DISPATCHER.miz index ac7f39879..7417eaec4 100644 Binary files a/Moose Test Missions/Moose_Test_DETECTION_DISPATCHER/Moose_Test_DETECTION_DISPATCHER.miz and b/Moose Test Missions/Moose_Test_DETECTION_DISPATCHER/Moose_Test_DETECTION_DISPATCHER.miz differ diff --git a/Moose Test Missions/Moose_Test_ESCORT/MOOSE_Test_ESCORT.miz b/Moose Test Missions/Moose_Test_ESCORT/MOOSE_Test_ESCORT.miz index 8636dcb5f..4645e3dcd 100644 Binary files a/Moose Test Missions/Moose_Test_ESCORT/MOOSE_Test_ESCORT.miz and b/Moose Test Missions/Moose_Test_ESCORT/MOOSE_Test_ESCORT.miz differ diff --git a/Moose Test Missions/Moose_Test_FAC/Moose_Test_FAC.miz b/Moose Test Missions/Moose_Test_FAC/Moose_Test_FAC.miz index 76563b94e..54889c702 100644 Binary files a/Moose Test Missions/Moose_Test_FAC/Moose_Test_FAC.miz and b/Moose Test Missions/Moose_Test_FAC/Moose_Test_FAC.miz differ diff --git a/Moose Test Missions/Moose_Test_GROUP_SwitchWayPoint/MOOSE_Test_GROUP_SwitchWayPoint.miz b/Moose Test Missions/Moose_Test_GROUP_SwitchWayPoint/MOOSE_Test_GROUP_SwitchWayPoint.miz index 5ff23e71a..a656641c1 100644 Binary files a/Moose Test Missions/Moose_Test_GROUP_SwitchWayPoint/MOOSE_Test_GROUP_SwitchWayPoint.miz and b/Moose Test Missions/Moose_Test_GROUP_SwitchWayPoint/MOOSE_Test_GROUP_SwitchWayPoint.miz differ diff --git a/Moose Test Missions/Moose_Test_MENU_CLIENT/Moose_Test_MENU_CLIENT.miz b/Moose Test Missions/Moose_Test_MENU_CLIENT/Moose_Test_MENU_CLIENT.miz index dedc7928d..aa48911dd 100644 Binary files a/Moose Test Missions/Moose_Test_MENU_CLIENT/Moose_Test_MENU_CLIENT.miz and b/Moose Test Missions/Moose_Test_MENU_CLIENT/Moose_Test_MENU_CLIENT.miz differ diff --git a/Moose Test Missions/Moose_Test_MENU_COALITION/Moose_Test_MENU_COALITION.miz b/Moose Test Missions/Moose_Test_MENU_COALITION/Moose_Test_MENU_COALITION.miz index c78f4e4f9..8043ac720 100644 Binary files a/Moose Test Missions/Moose_Test_MENU_COALITION/Moose_Test_MENU_COALITION.miz and b/Moose Test Missions/Moose_Test_MENU_COALITION/Moose_Test_MENU_COALITION.miz differ diff --git a/Moose Test Missions/Moose_Test_MENU_GROUP/Moose_Test_MENU_GROUP.miz b/Moose Test Missions/Moose_Test_MENU_GROUP/Moose_Test_MENU_GROUP.miz index 978e38708..f04df6412 100644 Binary files a/Moose Test Missions/Moose_Test_MENU_GROUP/Moose_Test_MENU_GROUP.miz and b/Moose Test Missions/Moose_Test_MENU_GROUP/Moose_Test_MENU_GROUP.miz differ diff --git a/Moose Test Missions/Moose_Test_MISSILETRAINER/Moose_Test_MISSILETRAINER.miz b/Moose Test Missions/Moose_Test_MISSILETRAINER/Moose_Test_MISSILETRAINER.miz index f2aca0b38..12e87744a 100644 Binary files a/Moose Test Missions/Moose_Test_MISSILETRAINER/Moose_Test_MISSILETRAINER.miz and b/Moose Test Missions/Moose_Test_MISSILETRAINER/Moose_Test_MISSILETRAINER.miz differ diff --git a/Moose Test Missions/Moose_Test_PATROLZONE/MOOSE_Test_PATROLZONE.miz b/Moose Test Missions/Moose_Test_PATROLZONE/MOOSE_Test_PATROLZONE.miz index 6789dc47a..2341bf8b7 100644 Binary files a/Moose Test Missions/Moose_Test_PATROLZONE/MOOSE_Test_PATROLZONE.miz and b/Moose Test Missions/Moose_Test_PATROLZONE/MOOSE_Test_PATROLZONE.miz differ diff --git a/Moose Test Missions/Moose_Test_SCHEDULER/Moose_Test_SCHEDULER.miz b/Moose Test Missions/Moose_Test_SCHEDULER/Moose_Test_SCHEDULER.miz index 7a68c34a9..87bf68dd9 100644 Binary files a/Moose Test Missions/Moose_Test_SCHEDULER/Moose_Test_SCHEDULER.miz and b/Moose Test Missions/Moose_Test_SCHEDULER/Moose_Test_SCHEDULER.miz differ diff --git a/Moose Test Missions/Moose_Test_SEAD/MOOSE_Test_SEAD.miz b/Moose Test Missions/Moose_Test_SEAD/MOOSE_Test_SEAD.miz index 6ac4101f1..acdcf4eb1 100644 Binary files a/Moose Test Missions/Moose_Test_SEAD/MOOSE_Test_SEAD.miz and b/Moose Test Missions/Moose_Test_SEAD/MOOSE_Test_SEAD.miz differ diff --git a/Moose Test Missions/Moose_Test_SET_AIRBASE/Moose_Test_SET_AIRBASE.miz b/Moose Test Missions/Moose_Test_SET_AIRBASE/Moose_Test_SET_AIRBASE.miz index c3aa5ee43..d33bd09a9 100644 Binary files a/Moose Test Missions/Moose_Test_SET_AIRBASE/Moose_Test_SET_AIRBASE.miz and b/Moose Test Missions/Moose_Test_SET_AIRBASE/Moose_Test_SET_AIRBASE.miz differ diff --git a/Moose Test Missions/Moose_Test_SET_CLIENT/Moose_Test_SET_CLIENT.miz b/Moose Test Missions/Moose_Test_SET_CLIENT/Moose_Test_SET_CLIENT.miz index 13451841b..976bb40e8 100644 Binary files a/Moose Test Missions/Moose_Test_SET_CLIENT/Moose_Test_SET_CLIENT.miz and b/Moose Test Missions/Moose_Test_SET_CLIENT/Moose_Test_SET_CLIENT.miz differ diff --git a/Moose Test Missions/Moose_Test_SET_GROUP/Moose_Test_SET_GROUP.miz b/Moose Test Missions/Moose_Test_SET_GROUP/Moose_Test_SET_GROUP.miz index ab2c9b534..6cb820499 100644 Binary files a/Moose Test Missions/Moose_Test_SET_GROUP/Moose_Test_SET_GROUP.miz and b/Moose Test Missions/Moose_Test_SET_GROUP/Moose_Test_SET_GROUP.miz differ diff --git a/Moose Test Missions/Moose_Test_SPAWN/MOOSE_Test_SPAWN.miz b/Moose Test Missions/Moose_Test_SPAWN/MOOSE_Test_SPAWN.miz index 330cb0c4f..a8938da14 100644 Binary files a/Moose Test Missions/Moose_Test_SPAWN/MOOSE_Test_SPAWN.miz and b/Moose Test Missions/Moose_Test_SPAWN/MOOSE_Test_SPAWN.miz differ diff --git a/Moose Test Missions/Moose_Test_SPAWN_CleanUp/MOOSE_Test_SPAWN_CleanUp.lua b/Moose Test Missions/Moose_Test_SPAWN/Moose_Test_SPAWN_CleanUp/MOOSE_Test_SPAWN_CleanUp.lua similarity index 100% rename from Moose Test Missions/Moose_Test_SPAWN_CleanUp/MOOSE_Test_SPAWN_CleanUp.lua rename to Moose Test Missions/Moose_Test_SPAWN/Moose_Test_SPAWN_CleanUp/MOOSE_Test_SPAWN_CleanUp.lua diff --git a/Moose Test Missions/Moose_Test_SPAWN/Moose_Test_SPAWN_CleanUp/MOOSE_Test_SPAWN_CleanUp.miz b/Moose Test Missions/Moose_Test_SPAWN/Moose_Test_SPAWN_CleanUp/MOOSE_Test_SPAWN_CleanUp.miz new file mode 100644 index 000000000..abf68378f Binary files /dev/null and b/Moose Test Missions/Moose_Test_SPAWN/Moose_Test_SPAWN_CleanUp/MOOSE_Test_SPAWN_CleanUp.miz differ diff --git a/Moose Test Missions/Moose_Test_SPAWN_Limit_Scheduled/MOOSE_Test_SPAWN_Limit_Scheduled.lua b/Moose Test Missions/Moose_Test_SPAWN/Moose_Test_SPAWN_Limit_Scheduled/MOOSE_Test_SPAWN_Limit_Scheduled.lua similarity index 100% rename from Moose Test Missions/Moose_Test_SPAWN_Limit_Scheduled/MOOSE_Test_SPAWN_Limit_Scheduled.lua rename to Moose Test Missions/Moose_Test_SPAWN/Moose_Test_SPAWN_Limit_Scheduled/MOOSE_Test_SPAWN_Limit_Scheduled.lua diff --git a/Moose Test Missions/Moose_Test_SPAWN/Moose_Test_SPAWN_Limit_Scheduled/MOOSE_Test_SPAWN_Limit_Scheduled.miz b/Moose Test Missions/Moose_Test_SPAWN/Moose_Test_SPAWN_Limit_Scheduled/MOOSE_Test_SPAWN_Limit_Scheduled.miz new file mode 100644 index 000000000..4ce8f8588 Binary files /dev/null and b/Moose Test Missions/Moose_Test_SPAWN/Moose_Test_SPAWN_Limit_Scheduled/MOOSE_Test_SPAWN_Limit_Scheduled.miz differ diff --git a/Moose Test Missions/Moose_Test_SPAWN_Repeat/MOOSE_Test_SPAWN_Repeat.lua b/Moose Test Missions/Moose_Test_SPAWN/Moose_Test_SPAWN_Repeat/MOOSE_Test_SPAWN_Repeat.lua similarity index 100% rename from Moose Test Missions/Moose_Test_SPAWN_Repeat/MOOSE_Test_SPAWN_Repeat.lua rename to Moose Test Missions/Moose_Test_SPAWN/Moose_Test_SPAWN_Repeat/MOOSE_Test_SPAWN_Repeat.lua diff --git a/Moose Test Missions/Moose_Test_SPAWN/Moose_Test_SPAWN_Repeat/MOOSE_Test_SPAWN_Repeat.miz b/Moose Test Missions/Moose_Test_SPAWN/Moose_Test_SPAWN_Repeat/MOOSE_Test_SPAWN_Repeat.miz new file mode 100644 index 000000000..69cadd336 Binary files /dev/null and b/Moose Test Missions/Moose_Test_SPAWN/Moose_Test_SPAWN_Repeat/MOOSE_Test_SPAWN_Repeat.miz differ diff --git a/Moose Test Missions/Moose_Test_SPAWN/Moose_Test_SPAWN_SpawnFromStatic/Moose_Test_SPAWN_SpawnFromStatic.lua b/Moose Test Missions/Moose_Test_SPAWN/Moose_Test_SPAWN_SpawnFromStatic/Moose_Test_SPAWN_SpawnFromStatic.lua new file mode 100644 index 000000000..c2d67f822 --- /dev/null +++ b/Moose Test Missions/Moose_Test_SPAWN/Moose_Test_SPAWN_SpawnFromStatic/Moose_Test_SPAWN_SpawnFromStatic.lua @@ -0,0 +1,50 @@ + +local Iterations = 10 +local Iteration = 1 + +GroundStatics = { "GroundStatic1", "GroundStatic2", "GroundStatic3" } +AirplaneStatics = { "AirplaneStatic1", "AirplaneStatic2", "AirplaneStatic3" } +HelicopterStatics = { "HelicopterStatic1", "HelicopterStatic2", "HelicopterStatic3" } +ShipStatics = { "ShipStatic1", "ShipStatic2", "ShipStatic3" } + +HeightLimit = 500 + +SpawnGrounds = SPAWN:New("Ground"):Limit( 20, 10 ) +SpawnAirplanes = SPAWN:New("Airplane"):Limit( 20, 10 ) +SpawnHelicopters = SPAWN:New("Helicopter"):Limit( 20, 10 ) +SpawnShips = SPAWN:New("Ship"):Limit( 20, 10 ) + +--- Spawns these groups slowly. +SCHEDULER:New( nil, + + function( Interation, Iterations ) + do + -- Spawn Ground + local StaticName = GroundStatics[ math.random( 1, 3 ) ] + local SpawnStatic = STATIC:FindByName( StaticName ) + SpawnGrounds:SpawnFromUnit( SpawnStatic, 500, 100 ) + end + + do + -- Spawn Airplanes + local StaticName = AirplaneStatics[ math.random( 1, 3 ) ] + local SpawnStatic = STATIC:FindByName( StaticName ) + SpawnAirplanes:SpawnFromUnit( SpawnStatic, 500, 100 ) + end + + do + -- Spawn Helicopters + local StaticName = HelicopterStatics[ math.random( 1, 3 ) ] + local SpawnStatic = STATIC:FindByName( StaticName ) + SpawnHelicopters:SpawnFromUnit( SpawnStatic, 500, 100 ) + end + + do + -- Spawn Ships + local StaticName = ShipStatics[ math.random( 1, 3 ) ] + local SpawnStatic = STATIC:FindByName( StaticName ) + SpawnShips:SpawnFromUnit( SpawnStatic, 500, 100 ) + end + + end, {}, 0, 15, 0.5 +) diff --git a/Moose Test Missions/Moose_Test_SPAWN/Moose_Test_SPAWN_SpawnFromStatic/Moose_Test_SPAWN_SpawnFromStatic.miz b/Moose Test Missions/Moose_Test_SPAWN/Moose_Test_SPAWN_SpawnFromStatic/Moose_Test_SPAWN_SpawnFromStatic.miz new file mode 100644 index 000000000..cbc837157 Binary files /dev/null and b/Moose Test Missions/Moose_Test_SPAWN/Moose_Test_SPAWN_SpawnFromStatic/Moose_Test_SPAWN_SpawnFromStatic.miz differ diff --git a/Moose Test Missions/Moose_Test_SPAWN/Moose_Test_SPAWN_SpawnFromUnit/Moose_Test_SPAWN_SpawnFromUnit.lua b/Moose Test Missions/Moose_Test_SPAWN/Moose_Test_SPAWN_SpawnFromUnit/Moose_Test_SPAWN_SpawnFromUnit.lua new file mode 100644 index 000000000..57436b943 --- /dev/null +++ b/Moose Test Missions/Moose_Test_SPAWN/Moose_Test_SPAWN_SpawnFromUnit/Moose_Test_SPAWN_SpawnFromUnit.lua @@ -0,0 +1,50 @@ + +local Iterations = 10 +local Iteration = 1 + +GroundUnits = { "GroundUnit1", "GroundUnit2", "GroundUnit3" } +AirplaneUnits = { "AirplaneUnit1", "AirplaneUnit2", "AirplaneUnit3" } +HelicopterUnits = { "HelicopterUnit1", "HelicopterUnit2", "HelicopterUnit3" } +ShipUnits = { "ShipUnit1", "ShipUnit2", "ShipUnit3" } + +HeightLimit = 500 + +SpawnGrounds = SPAWN:New("Ground"):Limit( 20, 10 ) +SpawnAirplanes = SPAWN:New("Airplane"):Limit( 20, 10 ) +SpawnHelicopters = SPAWN:New("Helicopter"):Limit( 20, 10 ) +SpawnShips = SPAWN:New("Ship"):Limit( 20, 10 ) + +--- Spawns these groups slowly. +SCHEDULER:New( nil, + + function( Interation, Iterations ) + do + -- Spawn Ground + local UnitName = GroundUnits[ math.random( 1, 3 ) ] + local SpawnUnit = UNIT:FindByName( UnitName ) + SpawnGrounds:SpawnFromUnit( SpawnUnit, 10, 3 ) + end + + do + -- Spawn Airplanes + local UnitName = AirplaneUnits[ math.random( 1, 3 ) ] + local SpawnUnit = UNIT:FindByName( UnitName ) + SpawnAirplanes:SpawnFromUnit( SpawnUnit ) + end + + do + -- Spawn Helicopters + local UnitName = HelicopterUnits[ math.random( 1, 3 ) ] + local SpawnUnit = UNIT:FindByName( UnitName ) + SpawnHelicopters:SpawnFromUnit( SpawnUnit ) + end + + do + -- Spawn Ships + local UnitName = ShipUnits[ math.random( 1, 3 ) ] + local SpawnUnit = UNIT:FindByName( UnitName ) + SpawnShips:SpawnFromUnit( SpawnUnit ) + end + + end, {}, 0, 15, 0.5 +) diff --git a/Moose Test Missions/Moose_Test_SPAWN/Moose_Test_SPAWN_SpawnFromUnit/Moose_Test_SPAWN_SpawnFromUnit.miz b/Moose Test Missions/Moose_Test_SPAWN/Moose_Test_SPAWN_SpawnFromUnit/Moose_Test_SPAWN_SpawnFromUnit.miz new file mode 100644 index 000000000..d0c792431 Binary files /dev/null and b/Moose Test Missions/Moose_Test_SPAWN/Moose_Test_SPAWN_SpawnFromUnit/Moose_Test_SPAWN_SpawnFromUnit.miz differ diff --git a/Moose Test Missions/Moose_Test_SPAWN/Moose_Test_SPAWN_SpawnFromVec2/Moose_Test_SPAWN_SpawnFromVec2.lua b/Moose Test Missions/Moose_Test_SPAWN/Moose_Test_SPAWN_SpawnFromVec2/Moose_Test_SPAWN_SpawnFromVec2.lua new file mode 100644 index 000000000..b68256f98 --- /dev/null +++ b/Moose Test Missions/Moose_Test_SPAWN/Moose_Test_SPAWN_SpawnFromVec2/Moose_Test_SPAWN_SpawnFromVec2.lua @@ -0,0 +1,50 @@ + +local Iterations = 10 +local Iteration = 1 + +GroundZones = { "GroundZone1", "GroundZone2", "GroundZone3" } +AirplaneZones = { "AirplaneZone1", "AirplaneZone2", "AirplaneZone3" } +HelicopterZones = { "HelicopterZone1", "HelicopterZone2", "HelicopterZone3" } +ShipZones = { "ShipZone1", "ShipZone2", "ShipZone3" } + +HeightLimit = 500 + +SpawnGrounds = SPAWN:New("Ground"):Limit( 20, 10 ) +SpawnAirplanes = SPAWN:New("Airplane"):Limit( 20, 10 ) +SpawnHelicopters = SPAWN:New("Helicopter"):Limit( 20, 10 ) +SpawnShips = SPAWN:New("Ship"):Limit( 20, 10 ) + +--- Spawns these groups slowly. +SCHEDULER:New( nil, + + function( Interation, Iterations ) + do + -- Spawn Ground + local ZoneName = GroundZones[ math.random( 1, 3 ) ] + local SpawnVec3 = POINT_VEC3:NewFromVec3( ZONE:New( ZoneName ):GetPointVec3() ) + SpawnGrounds:SpawnFromVec2( SpawnVec3:GetVec2(), 500, 100 ) + end + + do + -- Spawn Airplanes + local ZoneName = AirplaneZones[ math.random( 1, 3 ) ] + local SpawnVec3 = POINT_VEC3:NewFromVec3( ZONE:New( ZoneName ):GetPointVec3() ) + SpawnAirplanes:SpawnFromVec2( SpawnVec3:GetVec2(), 500, 100 ) + end + + do + -- Spawn Helicopters + local ZoneName = HelicopterZones[ math.random( 1, 3 ) ] + local SpawnVec3 = POINT_VEC3:NewFromVec3( ZONE:New( ZoneName ):GetPointVec3() ) + SpawnHelicopters:SpawnFromVec2( SpawnVec3:GetVec2(), 500, 100 ) + end + + do + -- Spawn Ships + local ZoneName = ShipZones[ math.random( 1, 3 ) ] + local SpawnVec3 = POINT_VEC3:NewFromVec3( ZONE:New( ZoneName ):GetPointVec3() ) + SpawnShips:SpawnFromVec2( SpawnVec3:GetVec2(), 500, 100 ) + end + + end, {}, 0, 15, 0.5 +) diff --git a/Moose Test Missions/Moose_Test_SPAWN/Moose_Test_SPAWN_SpawnFromVec2/Moose_Test_SPAWN_SpawnFromVec2.miz b/Moose Test Missions/Moose_Test_SPAWN/Moose_Test_SPAWN_SpawnFromVec2/Moose_Test_SPAWN_SpawnFromVec2.miz new file mode 100644 index 000000000..243ee5e34 Binary files /dev/null and b/Moose Test Missions/Moose_Test_SPAWN/Moose_Test_SPAWN_SpawnFromVec2/Moose_Test_SPAWN_SpawnFromVec2.miz differ diff --git a/Moose Test Missions/Moose_Test_SPAWN/Moose_Test_SPAWN_SpawnFromVec3/Moose_Test_SPAWN_SpawnFromVec3.lua b/Moose Test Missions/Moose_Test_SPAWN/Moose_Test_SPAWN_SpawnFromVec3/Moose_Test_SPAWN_SpawnFromVec3.lua new file mode 100644 index 000000000..524e6df52 --- /dev/null +++ b/Moose Test Missions/Moose_Test_SPAWN/Moose_Test_SPAWN_SpawnFromVec3/Moose_Test_SPAWN_SpawnFromVec3.lua @@ -0,0 +1,50 @@ + +local Iterations = 10 +local Iteration = 1 + +GroundZones = { "GroundZone1", "GroundZone2", "GroundZone3" } +AirplaneZones = { "AirplaneZone1", "AirplaneZone2", "AirplaneZone3" } +HelicopterZones = { "HelicopterZone1", "HelicopterZone2", "HelicopterZone3" } +ShipZones = { "ShipZone1", "ShipZone2", "ShipZone3" } + +HeightLimit = 500 + +SpawnGrounds = SPAWN:New("Ground"):Limit( 20, 10 ) +SpawnAirplanes = SPAWN:New("Airplane"):Limit( 20, 10 ) +SpawnHelicopters = SPAWN:New("Helicopter"):Limit( 20, 10 ) +SpawnShips = SPAWN:New("Ship"):Limit( 20, 10 ) + +--- Spawns these groups slowly. +SCHEDULER:New( nil, + + function( Interation, Iterations ) + do + -- Spawn Ground + local ZoneName = GroundZones[ math.random( 1, 3 ) ] + local SpawnVec3 = POINT_VEC3:NewFromVec3( ZONE:New( ZoneName ):GetPointVec3() ) + SpawnGrounds:SpawnFromVec3( SpawnVec3:GetVec3(), 500, 100 ) + end + + do + -- Spawn Airplanes + local ZoneName = AirplaneZones[ math.random( 1, 3 ) ] + local SpawnVec3 = POINT_VEC3:NewFromVec3( ZONE:New( ZoneName ):GetPointVec3() ) + SpawnAirplanes:SpawnFromVec3( SpawnVec3:GetVec3(), 500, 100 ) + end + + do + -- Spawn Helicopters + local ZoneName = HelicopterZones[ math.random( 1, 3 ) ] + local SpawnVec3 = POINT_VEC3:NewFromVec3( ZONE:New( ZoneName ):GetPointVec3() ) + SpawnHelicopters:SpawnFromVec3( SpawnVec3:GetVec3(), 500, 100 ) + end + + do + -- Spawn Ships + local ZoneName = ShipZones[ math.random( 1, 3 ) ] + local SpawnVec3 = POINT_VEC3:NewFromVec3( ZONE:New( ZoneName ):GetPointVec3() ) + SpawnShips:SpawnFromVec3( SpawnVec3:GetVec3(), 500, 100 ) + end + + end, {}, 0, 15, 0.5 +) diff --git a/Moose Test Missions/Moose_Test_SPAWN/Moose_Test_SPAWN_SpawnFromVec3/Moose_Test_SPAWN_SpawnFromVec3.miz b/Moose Test Missions/Moose_Test_SPAWN/Moose_Test_SPAWN_SpawnFromVec3/Moose_Test_SPAWN_SpawnFromVec3.miz new file mode 100644 index 000000000..b1497efc5 Binary files /dev/null and b/Moose Test Missions/Moose_Test_SPAWN/Moose_Test_SPAWN_SpawnFromVec3/Moose_Test_SPAWN_SpawnFromVec3.miz differ diff --git a/Moose Test Missions/Moose_Test_SPAWN_CleanUp/MOOSE_Test_SPAWN_CleanUp.miz b/Moose Test Missions/Moose_Test_SPAWN_CleanUp/MOOSE_Test_SPAWN_CleanUp.miz deleted file mode 100644 index 7d0bca928..000000000 Binary files a/Moose Test Missions/Moose_Test_SPAWN_CleanUp/MOOSE_Test_SPAWN_CleanUp.miz and /dev/null differ diff --git a/Moose Test Missions/Moose_Test_SPAWN_Limit_Scheduled/MOOSE_Test_SPAWN_Limit_Scheduled.miz b/Moose Test Missions/Moose_Test_SPAWN_Limit_Scheduled/MOOSE_Test_SPAWN_Limit_Scheduled.miz deleted file mode 100644 index 2bcba28fe..000000000 Binary files a/Moose Test Missions/Moose_Test_SPAWN_Limit_Scheduled/MOOSE_Test_SPAWN_Limit_Scheduled.miz and /dev/null differ diff --git a/Moose Test Missions/Moose_Test_SPAWN_Repeat/MOOSE_Test_SPAWN_Repeat.miz b/Moose Test Missions/Moose_Test_SPAWN_Repeat/MOOSE_Test_SPAWN_Repeat.miz deleted file mode 100644 index 58e4792ed..000000000 Binary files a/Moose Test Missions/Moose_Test_SPAWN_Repeat/MOOSE_Test_SPAWN_Repeat.miz and /dev/null differ diff --git a/Moose Test Missions/Moose_Test_TASK_Pickup_and_Deploy/MOOSE_Test_TASK_Pickup_and_Deploy.miz b/Moose Test Missions/Moose_Test_TASK_Pickup_and_Deploy/MOOSE_Test_TASK_Pickup_and_Deploy.miz index 473c916a2..f3471e8bd 100644 Binary files a/Moose Test Missions/Moose_Test_TASK_Pickup_and_Deploy/MOOSE_Test_TASK_Pickup_and_Deploy.miz and b/Moose Test Missions/Moose_Test_TASK_Pickup_and_Deploy/MOOSE_Test_TASK_Pickup_and_Deploy.miz differ diff --git a/Moose Test Missions/Moose_Test_TASK_SEAD/Moose_Test_TASK_SEAD.miz b/Moose Test Missions/Moose_Test_TASK_SEAD/Moose_Test_TASK_SEAD.miz index 4041984ac..2f02a5003 100644 Binary files a/Moose Test Missions/Moose_Test_TASK_SEAD/Moose_Test_TASK_SEAD.miz and b/Moose Test Missions/Moose_Test_TASK_SEAD/Moose_Test_TASK_SEAD.miz differ diff --git a/Moose Test Missions/Moose_Test_WRAPPER/Moose_Test_WRAPPER.miz b/Moose Test Missions/Moose_Test_WRAPPER/Moose_Test_WRAPPER.miz index e449b2754..1932b0623 100644 Binary files a/Moose Test Missions/Moose_Test_WRAPPER/Moose_Test_WRAPPER.miz and b/Moose Test Missions/Moose_Test_WRAPPER/Moose_Test_WRAPPER.miz differ diff --git a/Moose Test Missions/Moose_Test_ZONE/Moose_Test_ZONE.miz b/Moose Test Missions/Moose_Test_ZONE/Moose_Test_ZONE.miz index 37eb7847b..dcbf1821a 100644 Binary files a/Moose Test Missions/Moose_Test_ZONE/Moose_Test_ZONE.miz and b/Moose Test Missions/Moose_Test_ZONE/Moose_Test_ZONE.miz differ diff --git a/Moose Test Missions/Moose_Test_ZONE_GROUP/Moose_Test_ZONE_GROUP.miz b/Moose Test Missions/Moose_Test_ZONE_GROUP/Moose_Test_ZONE_GROUP.miz index eda5b4fd5..329b6dd84 100644 Binary files a/Moose Test Missions/Moose_Test_ZONE_GROUP/Moose_Test_ZONE_GROUP.miz and b/Moose Test Missions/Moose_Test_ZONE_GROUP/Moose_Test_ZONE_GROUP.miz differ diff --git a/Moose Test Missions/Moose_Test_ZONE_POLYGON/Moose_Test_ZONE_POLYGON.miz b/Moose Test Missions/Moose_Test_ZONE_POLYGON/Moose_Test_ZONE_POLYGON.miz index f6e7989b8..ea9a790db 100644 Binary files a/Moose Test Missions/Moose_Test_ZONE_POLYGON/Moose_Test_ZONE_POLYGON.miz and b/Moose Test Missions/Moose_Test_ZONE_POLYGON/Moose_Test_ZONE_POLYGON.miz differ diff --git a/Moose Test Missions/Moose_Test_ZONE_RADIUS/Moose_Test_ZONE_RADIUS.miz b/Moose Test Missions/Moose_Test_ZONE_RADIUS/Moose_Test_ZONE_RADIUS.miz index 3d8353562..e3f75440a 100644 Binary files a/Moose Test Missions/Moose_Test_ZONE_RADIUS/Moose_Test_ZONE_RADIUS.miz and b/Moose Test Missions/Moose_Test_ZONE_RADIUS/Moose_Test_ZONE_RADIUS.miz differ diff --git a/Moose Test Missions/Moose_Test_ZONE_UNIT/Moose_Test_ZONE_UNIT.miz b/Moose Test Missions/Moose_Test_ZONE_UNIT/Moose_Test_ZONE_UNIT.miz index 0b6cec606..1cc8ac7ed 100644 Binary files a/Moose Test Missions/Moose_Test_ZONE_UNIT/Moose_Test_ZONE_UNIT.miz and b/Moose Test Missions/Moose_Test_ZONE_UNIT/Moose_Test_ZONE_UNIT.miz differ