Group Updates

This commit is contained in:
FlightControl_Master
2018-03-01 17:42:50 +01:00
parent 96216494bb
commit 2620927146
+27 -1
View File
@@ -996,11 +996,33 @@ end
--- Randomize the unit positions for the units of the respawned group. --- Randomize the unit positions for the units of the respawned group.
-- When a Respawn happens, the units of the group will be placed at random positions within the Zone (selected).
-- @param #GROUP self -- @param #GROUP self
-- @param #boolean Positions true will randomize the positions. -- @param #boolean Positions true will randomize the positions within the Zone.
-- @return #GROUP self -- @return #GROUP self
function GROUP:InitRandomizePositions( Positions ) function GROUP:InitRandomizePositions( Positions )
self.InitRespawnRandomizePositions = Positions self.InitRespawnRandomizePositions = Positions
self.InitRespawnRandomizePositionsInner = nil
self.InitRespawnRandomizePositionsOuter = nil
return self
end
--- Randomize the unit positions for the units 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 )
self.InitRespawnRandomizePositions = nil
self.InitRespawnRandomizePositionsInner = Inner
self.InitRespawnRandomizePositionsOuter = Outer
return self return self
end end
@@ -1049,10 +1071,14 @@ function GROUP:Respawn( Template )
if Zone then if Zone then
if self.InitRespawnRandomizePositions then if self.InitRespawnRandomizePositions then
GroupUnitVec3 = Zone:GetRandomVec3() GroupUnitVec3 = Zone:GetRandomVec3()
else
if self.InitRespawnRandomizePositionsInner and self.InitRespawnRandomizePositionsOuter then
GroupUnitVec3 = POINT_VEC3:NewFromVec2( From ):GetRandomPointVec3InRadius( self.InitRespawnRandomizePositionsOuter, self.InitRespawnRandomizePositionsInner )
else else
GroupUnitVec3 = Zone:GetVec3() GroupUnitVec3 = Zone:GetVec3()
end end
end end
end
Template.units[UnitID].alt = self.InitRespawnHeight and self.InitRespawnHeight or GroupUnitVec3.y 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].x = ( Template.units[UnitID].x - From.x ) + GroupUnitVec3.x -- Keep the original x position of the template and translate to the new position.