Updated function names

This commit is contained in:
FlightControl_Master 2018-03-01 20:41:26 +01:00
parent 2620927146
commit 733b4940f8

View File

@ -995,33 +995,33 @@ function GROUP:InitZone( Zone )
end
--- Randomize the unit positions for the units of the respawned group.
--- Randomize the positions of the units of the respawned group within the @{Zone}.
-- When a Respawn happens, the units of the group will be placed at random positions within the Zone (selected).
-- @param #GROUP self
-- @param #boolean Positions true will randomize the positions within the Zone.
-- @param #boolean PositionZone true will randomize the positions within the Zone.
-- @return #GROUP self
function GROUP:InitRandomizePositions( Positions )
function GROUP:InitRandomizePositionZone( PositionZone )
self.InitRespawnRandomizePositions = Positions
self.InitRespawnRandomizePositionsInner = nil
self.InitRespawnRandomizePositionsOuter = nil
self.InitRespawnRandomizePositionZone = PositionZone
self.InitRespawnRandomizePositionInner = nil
self.InitRespawnRandomizePositionOuter = nil
return self
end
--- Randomize the unit positions for the units in a circle band.
--- Randomize the positions of the units of the respawned group in a circle band.
-- When a Respawn happens, the units of the group will be positioned at random places within the Outer and Inner radius.
-- Thus, a band is created around the respawn location where the units will be placed at random positions.
-- @param #GROUP self
-- @param #boolean OuterRadius Outer band in meters from the center.
-- @param #boolean InnerRadius Inner band in meters from the center.
-- @return #GROUP self
function GROUP:InitRandomizePositionsRadius( OuterRadius, InnerRadius )
function GROUP:InitRandomizePositionRadius( OuterRadius, InnerRadius )
self.InitRespawnRandomizePositions = nil
self.InitRespawnRandomizePositionsInner = Inner
self.InitRespawnRandomizePositionsOuter = Outer
self.InitRespawnRandomizePositionZone = nil
self.InitRespawnRandomizePositionOuter = OuterRadius
self.InitRespawnRandomizePositionInner = InnerRadius
return self
end
@ -1036,7 +1036,8 @@ end
-- - @{#GROUP.InitRandomizeHeading}: Randomize the headings for the units within the respawned group.
-- - @{#GROUP.InitZone}: Set the respawn @{Zone} for the respawned group.
-- - @{#GROUP.InitRandomizeZones}: Randomize the respawn @{Zone} between one of the @{Zone}s given for the respawned group.
-- - @{#GROUP.InitRandomizePositions}: Randomize the unit positions for the units of the respawned group.
-- - @{#GROUP.InitRandomizePositionZone}: Randomize the positions of the units of the respawned group within the @{Zone}.
-- - @{#GROUP.InitRandomizePositionRadius}: Randomize the positions of the units of the respawned group in a circle band.
-- - @{#GROUP.InitRandomizeTemplates}: Randomize the Template for the respawned group.
--
--
@ -1047,7 +1048,7 @@ end
--
-- @param Wrapper.Group#GROUP self
-- @param #table Template (optional) The template of the Group retrieved with GROUP:GetTemplate(). If the template is not provided, the template will be retrieved of the group itself.
function GROUP:Respawn( Template )
function GROUP:Respawn( Template, Reset )
if not Template then
Template = self:GetTemplate()
@ -1063,16 +1064,41 @@ function GROUP:Respawn( Template )
--Template.y = nil
self:E( #Template.units )
for UnitID, UnitData in pairs( self:GetUnits() ) do
local GroupUnit = UnitData -- Wrapper.Unit#UNIT
self:E( GroupUnit:GetName() )
if GroupUnit:IsAlive() then
local GroupUnitVec3 = GroupUnit:GetVec3()
if Reset == true then
for UnitID, UnitData in pairs( self:GetUnits() ) do
local GroupUnit = UnitData -- Wrapper.Unit#UNIT
self:E( GroupUnit:GetName() )
if GroupUnit:IsAlive() then
self:E( "Alive" )
local GroupUnitVec3 = GroupUnit:GetVec3()
if Zone then
if self.InitRespawnRandomizePositionZone then
GroupUnitVec3 = Zone:GetRandomVec3()
else
if self.InitRespawnRandomizePositionInner and self.InitRespawnRandomizePositionOuter then
GroupUnitVec3 = POINT_VEC3:NewFromVec2( From ):GetRandomPointVec3InRadius( self.InitRespawnRandomizePositionsOuter, self.InitRespawnRandomizePositionsInner )
else
GroupUnitVec3 = Zone:GetVec3()
end
end
end
Template.units[UnitID].alt = self.InitRespawnHeight and self.InitRespawnHeight or GroupUnitVec3.y
Template.units[UnitID].x = ( Template.units[UnitID].x - From.x ) + GroupUnitVec3.x -- Keep the original x position of the template and translate to the new position.
Template.units[UnitID].y = ( Template.units[UnitID].y - From.y ) + GroupUnitVec3.z -- Keep the original z position of the template and translate to the new position.
Template.units[UnitID].heading = self.InitRespawnHeading and self.InitRespawnHeading or GroupUnit:GetHeading()
self:E( { UnitID, Template.units[UnitID], Template.units[UnitID] } )
end
end
else
for UnitID, TemplateUnitData in pairs( Template.units ) do
self:E( "Reset" )
local GroupUnitVec3 = { x = TemplateUnitData.x, y = TemplateUnitData.alt, z = TemplateUnitData.z }
if Zone then
if self.InitRespawnRandomizePositions then
if self.InitRespawnRandomizePositionZone then
GroupUnitVec3 = Zone:GetRandomVec3()
else
if self.InitRespawnRandomizePositionsInner and self.InitRespawnRandomizePositionsOuter then
if self.InitRespawnRandomizePositionInner and self.InitRespawnRandomizePositionOuter then
GroupUnitVec3 = POINT_VEC3:NewFromVec2( From ):GetRandomPointVec3InRadius( self.InitRespawnRandomizePositionsOuter, self.InitRespawnRandomizePositionsInner )
else
GroupUnitVec3 = Zone:GetVec3()
@ -1083,10 +1109,10 @@ function GROUP:Respawn( Template )
Template.units[UnitID].alt = self.InitRespawnHeight and self.InitRespawnHeight or GroupUnitVec3.y
Template.units[UnitID].x = ( Template.units[UnitID].x - From.x ) + GroupUnitVec3.x -- Keep the original x position of the template and translate to the new position.
Template.units[UnitID].y = ( Template.units[UnitID].y - From.y ) + GroupUnitVec3.z -- Keep the original z position of the template and translate to the new position.
Template.units[UnitID].heading = self.InitRespawnHeading and self.InitRespawnHeading or GroupUnit:GetHeading()
Template.units[UnitID].heading = self.InitRespawnHeading and self.InitRespawnHeading or TemplateUnitData.heading
self:E( { UnitID, Template.units[UnitID], Template.units[UnitID] } )
end
end
end
end