mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Added a couple of function to allow Respawning of GROUPS more efficiently.
This commit is contained in:
@@ -708,14 +708,34 @@ function GROUP:GetMaxHeight()
|
||||
|
||||
end
|
||||
|
||||
--- @param Group#GROUP self
|
||||
-- SPAWNING
|
||||
|
||||
--- Respawn the @{GROUP} using a (tweaked) template of the Group.
|
||||
-- The template must be retrieved with the @{Group#GROUP.GetTemplate}() function.
|
||||
-- The template contains all the definitions as declared within the mission file.
|
||||
-- To understand templates, do the following:
|
||||
--
|
||||
-- * unpack your .miz file into a directory using 7-zip.
|
||||
-- * browse in the directory created to the file **mission**.
|
||||
-- * open the file and search for the country group definitions.
|
||||
--
|
||||
-- Your group template will contain the fields as described within the mission file.
|
||||
--
|
||||
-- This function will:
|
||||
--
|
||||
-- * Get the current position and heading of the group.
|
||||
-- * When the group is alive, it will tweak the template x, y and heading coordinates of the group and the embedded units to the current units positions.
|
||||
-- * Then it will destroy the current alive group.
|
||||
-- * And it will respawn the group using your new template definition.
|
||||
-- @param Group#GROUP self
|
||||
-- @param #table Template The template of the Group retrieved with GROUP:GetTemplate()
|
||||
function GROUP:Respawn( Template )
|
||||
|
||||
local Vec3 = self:GetPointVec3()
|
||||
--Template.x = Vec3.x
|
||||
--Template.y = Vec3.z
|
||||
Template.x = nil
|
||||
Template.y = nil
|
||||
Template.x = Vec3.x
|
||||
Template.y = Vec3.z
|
||||
--Template.x = nil
|
||||
--Template.y = nil
|
||||
|
||||
self:E( #Template.units )
|
||||
for UnitID, UnitData in pairs( self:GetUnits() ) do
|
||||
@@ -732,16 +752,49 @@ function GROUP:Respawn( Template )
|
||||
end
|
||||
end
|
||||
|
||||
self:Destroy()
|
||||
_DATABASE:Spawn( Template )
|
||||
|
||||
end
|
||||
|
||||
--- Returns the group template from the @{DATABASE} (_DATABASE object).
|
||||
-- @param #GROUP self
|
||||
-- @return #table
|
||||
function GROUP:GetTemplate()
|
||||
|
||||
return _DATABASE.Templates.Groups[self:GetName()].Template
|
||||
|
||||
local GroupName = self:GetName()
|
||||
self:E( GroupName )
|
||||
return _DATABASE:GetGroupTemplate( GroupName )
|
||||
end
|
||||
|
||||
--- Sets the controlled status in a Template.
|
||||
-- @param #GROUP self
|
||||
-- @param #boolean Controlled true is controlled, false is uncontrolled.
|
||||
-- @return #table
|
||||
function GROUP:SetTemplateControlled( Template, Controlled )
|
||||
Template.uncontrolled = not Controlled
|
||||
return Template
|
||||
end
|
||||
|
||||
--- Sets the CountryID of the group in a Template.
|
||||
-- @param #GROUP self
|
||||
-- @param DCScountry#country.id CountryID The country ID.
|
||||
-- @return #table
|
||||
function GROUP:SetTemplateCountry( Template, CountryID )
|
||||
Template.CountryID = CountryID
|
||||
return Template
|
||||
end
|
||||
|
||||
--- Sets the CoalitionID of the group in a Template.
|
||||
-- @param #GROUP self
|
||||
-- @param DCSCoalitionObject#coalition.side CoalitionID The coalition ID.
|
||||
-- @return #table
|
||||
function GROUP:SetTemplateCoalition( Template, CoalitionID )
|
||||
Template.CoalitionID = CoalitionID
|
||||
return Template
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
--- Return the mission template of the group.
|
||||
-- @param #GROUP self
|
||||
-- @return #table The MissionTemplate
|
||||
|
||||
Reference in New Issue
Block a user