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 } ) 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 RandomizeUnits = RandomizeUnits or false
InnerRadius = InnerRadius or 0 InnerRadius = InnerRadius or 0
@ -605,19 +602,26 @@ function SPAWN:SpawnFromVec3( Vec3, RandomizeUnits, OuterRadius, InnerRadius, Sp
end end
else else
for UnitID = 1, #SpawnTemplate.units do 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 UnitTemplate = SpawnTemplate.units[UnitID]
local UnitPointVec2 = POINT_VEC2:New( UnitTemplate.x, UnitTemplate.y ) local SX = UnitTemplate.x
local Distance = UnitPointVec2 local SY = UnitTemplate.y
local Angle = UnitPointVec2:GetAngle( PointVec3 ) local BX = SpawnTemplate.route.points[1].x
UnitPointVec2 = UnitPointVec2:Translate( Distance, Angle ) local BY = SpawnTemplate.route.points[1].y
local RandomVec2 = PointVec3:GetRandomVec2InRadius( OuterRadius, InnerRadius ) local TX = Vec3.x + ( SX - BX )
SpawnTemplate.units[UnitID].x = RandomVec2.x local TY = Vec3.z + ( SY - BY )
SpawnTemplate.units[UnitID].y = RandomVec2.y SpawnTemplate.units[UnitID].x = TX
SpawnTemplate.units[UnitID].y = TY
SpawnTemplate.units[UnitID].alt = Vec3.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 ) self:T( 'After Translation SpawnTemplate.units['..UnitID..'].x = ' .. SpawnTemplate.units[UnitID].x .. ', SpawnTemplate.units['..UnitID..'].y = ' .. SpawnTemplate.units[UnitID].y )
end end
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. -- 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 RandomVec2 = PointVec3:GetRandomVec2InRadius( OuterRadius, InnerRadius )
-- local Point = {} -- local Point = {}
@ -1060,8 +1064,6 @@ function SPAWN:_Prepare( SpawnTemplatePrefix, SpawnIndex )
for UnitID = 1, #SpawnTemplate.units do for UnitID = 1, #SpawnTemplate.units do
SpawnTemplate.units[UnitID].name = string.format( SpawnTemplate.name .. '-%02d', UnitID ) SpawnTemplate.units[UnitID].name = string.format( SpawnTemplate.name .. '-%02d', UnitID )
SpawnTemplate.units[UnitID].unitId = nil SpawnTemplate.units[UnitID].unitId = nil
SpawnTemplate.units[UnitID].x = SpawnTemplate.route.points[1].x
SpawnTemplate.units[UnitID].y = SpawnTemplate.route.points[1].y
end end
self:T3( { "Template:", SpawnTemplate } ) 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 local Iteration = 1
GroundZones = { "GroundZone1", "GroundZone2", "GroundZone3" } GroundZones = { "GroundZone1", "GroundZone2", "GroundZone3" }
GroundRandomizeZones = { "GroundRandomizeZone1", "GroundRandomizeZone2", "GroundRandomizeZone3" }
AirplaneZones = { "AirplaneZone1", "AirplaneZone2", "AirplaneZone3" } AirplaneZones = { "AirplaneZone1", "AirplaneZone2", "AirplaneZone3" }
HelicopterZones = { "HelicopterZone1", "HelicopterZone2", "HelicopterZone3" } HelicopterZones = { "HelicopterZone1", "HelicopterZone2", "HelicopterZone3" }
ShipZones = { "ShipZone1", "ShipZone2", "ShipZone3" } ShipZones = { "ShipZone1", "ShipZone2", "ShipZone3" }
@ -10,6 +11,7 @@ ShipZones = { "ShipZone1", "ShipZone2", "ShipZone3" }
HeightLimit = 500 HeightLimit = 500
SpawnGrounds = SPAWN:New("Ground"):Limit( 20, 10 ) SpawnGrounds = SPAWN:New("Ground"):Limit( 20, 10 )
SpawnRandomizeGrounds = SPAWN:New("GroundRandomize"):Limit( 20, 10 )
SpawnAirplanes = SPAWN:New("Airplane"):Limit( 20, 10 ) SpawnAirplanes = SPAWN:New("Airplane"):Limit( 20, 10 )
SpawnHelicopters = SPAWN:New("Helicopter"):Limit( 20, 10 ) SpawnHelicopters = SPAWN:New("Helicopter"):Limit( 20, 10 )
SpawnShips = SPAWN:New("Ship"):Limit( 20, 10 ) SpawnShips = SPAWN:New("Ship"):Limit( 20, 10 )
@ -21,29 +23,36 @@ SCHEDULER:New( nil,
do do
-- Spawn Ground -- Spawn Ground
local ZoneName = GroundZones[ math.random( 1, 3 ) ] local ZoneName = GroundZones[ math.random( 1, 3 ) ]
local SpawnVec3 = POINT_VEC3:NewFromVec3( ZONE:New( ZoneName ):GetPointVec3() ) local SpawnVec3 = POINT_VEC3:NewFromVec3( ZONE:New( ZoneName ):GetVec3() )
SpawnGrounds:SpawnFromVec3( SpawnVec3:GetVec3(), 500, 100 ) 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 end
do do
-- Spawn Airplanes -- Spawn Airplanes
local ZoneName = AirplaneZones[ math.random( 1, 3 ) ] local ZoneName = AirplaneZones[ math.random( 1, 3 ) ]
local SpawnVec3 = POINT_VEC3:NewFromVec3( ZONE:New( ZoneName ):GetPointVec3() ) local SpawnVec3 = POINT_VEC3:NewFromVec3( ZONE:New( ZoneName ):GetVec3() )
SpawnAirplanes:SpawnFromVec3( SpawnVec3:GetVec3(), 500, 100 ) SpawnAirplanes:SpawnFromVec3( SpawnVec3:GetVec3(), false, 500, 100 )
end end
do do
-- Spawn Helicopters -- Spawn Helicopters
local ZoneName = HelicopterZones[ math.random( 1, 3 ) ] local ZoneName = HelicopterZones[ math.random( 1, 3 ) ]
local SpawnVec3 = POINT_VEC3:NewFromVec3( ZONE:New( ZoneName ):GetPointVec3() ) local SpawnVec3 = POINT_VEC3:NewFromVec3( ZONE:New( ZoneName ):GetVec3() )
SpawnHelicopters:SpawnFromVec3( SpawnVec3:GetVec3(), 500, 100 ) SpawnHelicopters:SpawnFromVec3( SpawnVec3:GetVec3(), false, 500, 100 )
end end
do do
-- Spawn Ships -- Spawn Ships
local ZoneName = ShipZones[ math.random( 1, 3 ) ] local ZoneName = ShipZones[ math.random( 1, 3 ) ]
local SpawnVec3 = POINT_VEC3:NewFromVec3( ZONE:New( ZoneName ):GetPointVec3() ) local SpawnVec3 = POINT_VEC3:NewFromVec3( ZONE:New( ZoneName ):GetVec3() )
SpawnShips:SpawnFromVec3( SpawnVec3:GetVec3(), 500, 100 ) SpawnShips:SpawnFromVec3( SpawnVec3:GetVec3(), false, 500, 100 )
end end
end, {}, 0, 15, 0.5 end, {}, 0, 15, 0.5