This commit is contained in:
Sven Van de Velde 2016-08-13 07:01:13 +02:00
parent e59caac2c7
commit be55fdde9a
5 changed files with 64 additions and 59849 deletions

View File

@ -586,9 +586,6 @@ function SPAWN:SpawnFromVec3( Vec3, RandomizeUnits, OuterRadius, InnerRadius, Sp
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
RandomizeUnits = RandomizeUnits or false
InnerRadius = InnerRadius or 0
@ -605,19 +602,26 @@ function SPAWN:SpawnFromVec3( Vec3, RandomizeUnits, OuterRadius, InnerRadius, Sp
end
else
for UnitID = 1, #SpawnTemplate.units do
self:T( 'Before Translation SpawnTemplate.units['..UnitID..'].x = ' .. SpawnTemplate.units[UnitID].x .. ', SpawnTemplate.units['..UnitID..'].y = ' .. SpawnTemplate.units[UnitID].y )
local UnitTemplate = SpawnTemplate.units[UnitID]
local UnitPointVec2 = POINT_VEC2:New( UnitTemplate.x, UnitTemplate.y )
local Distance = UnitPointVec2
local Angle = UnitPointVec2:GetAngle( PointVec3 )
UnitPointVec2 = UnitPointVec2:Translate( Distance, Angle )
local RandomVec2 = PointVec3:GetRandomVec2InRadius( OuterRadius, InnerRadius )
SpawnTemplate.units[UnitID].x = RandomVec2.x
SpawnTemplate.units[UnitID].y = RandomVec2.y
local SX = UnitTemplate.x
local SY = UnitTemplate.y
local BX = SpawnTemplate.route.points[1].x
local BY = SpawnTemplate.route.points[1].y
local TX = Vec3.x + ( SX - BX )
local TY = Vec3.z + ( SY - BY )
SpawnTemplate.units[UnitID].x = TX
SpawnTemplate.units[UnitID].y = TY
SpawnTemplate.units[UnitID].alt = Vec3.y
self:T( 'SpawnTemplate.units['..UnitID..'].x = ' .. SpawnTemplate.units[UnitID].x .. ', SpawnTemplate.units['..UnitID..'].y = ' .. SpawnTemplate.units[UnitID].y )
self:T( 'After Translation SpawnTemplate.units['..UnitID..'].x = ' .. SpawnTemplate.units[UnitID].x .. ', SpawnTemplate.units['..UnitID..'].y = ' .. SpawnTemplate.units[UnitID].y )
end
end
SpawnTemplate.route.points[1].x = Vec3.x
SpawnTemplate.route.points[1].y = Vec3.z
SpawnTemplate.route.points[1].alt = Vec3.y
SpawnTemplate.route.points[1].action = "Custom"
-- 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 = {}
@ -1060,8 +1064,6 @@ function SPAWN:_Prepare( SpawnTemplatePrefix, SpawnIndex )
for UnitID = 1, #SpawnTemplate.units do
SpawnTemplate.units[UnitID].name = string.format( SpawnTemplate.name .. '-%02d', UnitID )
SpawnTemplate.units[UnitID].unitId = nil
SpawnTemplate.units[UnitID].x = SpawnTemplate.route.points[1].x
SpawnTemplate.units[UnitID].y = SpawnTemplate.route.points[1].y
end
self:T3( { "Template:", SpawnTemplate } )

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -3,6 +3,7 @@ local Iterations = 10
local Iteration = 1
GroundZones = { "GroundZone1", "GroundZone2", "GroundZone3" }
GroundRandomizeZones = { "GroundRandomizeZone1", "GroundRandomizeZone2", "GroundRandomizeZone3" }
AirplaneZones = { "AirplaneZone1", "AirplaneZone2", "AirplaneZone3" }
HelicopterZones = { "HelicopterZone1", "HelicopterZone2", "HelicopterZone3" }
ShipZones = { "ShipZone1", "ShipZone2", "ShipZone3" }
@ -10,6 +11,7 @@ ShipZones = { "ShipZone1", "ShipZone2", "ShipZone3" }
HeightLimit = 500
SpawnGrounds = SPAWN:New("Ground"):Limit( 20, 10 )
SpawnRandomizeGrounds = SPAWN:New("GroundRandomize"):Limit( 20, 10 )
SpawnAirplanes = SPAWN:New("Airplane"):Limit( 20, 10 )
SpawnHelicopters = SPAWN:New("Helicopter"):Limit( 20, 10 )
SpawnShips = SPAWN:New("Ship"):Limit( 20, 10 )
@ -21,29 +23,36 @@ SCHEDULER:New( nil,
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 )
local SpawnVec3 = POINT_VEC3:NewFromVec3( ZONE:New( ZoneName ):GetVec3() )
SpawnGrounds:SpawnFromVec3( SpawnVec3:GetVec3(), false, 500, 100 )
end
do
-- Spawn Ground Randomize
local ZoneName = GroundRandomizeZones[ math.random( 1, 3 ) ]
local SpawnVec3 = POINT_VEC3:NewFromVec3( ZONE:New( ZoneName ):GetVec3() )
SpawnRandomizeGrounds:SpawnFromVec3( SpawnVec3:GetVec3(), true, 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 )
local SpawnVec3 = POINT_VEC3:NewFromVec3( ZONE:New( ZoneName ):GetVec3() )
SpawnAirplanes:SpawnFromVec3( SpawnVec3:GetVec3(), false, 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 )
local SpawnVec3 = POINT_VEC3:NewFromVec3( ZONE:New( ZoneName ):GetVec3() )
SpawnHelicopters:SpawnFromVec3( SpawnVec3:GetVec3(), false, 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 )
local SpawnVec3 = POINT_VEC3:NewFromVec3( ZONE:New( ZoneName ):GetVec3() )
SpawnShips:SpawnFromVec3( SpawnVec3:GetVec3(), false, 500, 100 )
end
end, {}, 0, 15, 0.5