diff --git a/Moose Development/Dcs/DCScountry.lua b/Moose Development/Dcs/DCScountry.lua
index 5a277d1fb..e390894cd 100644
--- a/Moose Development/Dcs/DCScountry.lua
+++ b/Moose Development/Dcs/DCScountry.lua
@@ -3,6 +3,7 @@
--- @type country
-- @field #country.id id
+country = country -- #country
--- @type country.id
-- @field RUSSIA
@@ -23,4 +24,4 @@
-- @field INSURGENTS
-- @field ABKHAZIA
-- @field SOUTH_OSETIA
--- @field ITALY
\ No newline at end of file
+-- @field ITALY
diff --git a/Moose Development/Moose/Database.lua b/Moose Development/Moose/Database.lua
index c75bafc30..1dcc70cdb 100644
--- a/Moose Development/Moose/Database.lua
+++ b/Moose Development/Moose/Database.lua
@@ -380,6 +380,14 @@ function DATABASE:_RegisterTemplate( GroupTemplate, CoalitionID, CategoryID, Cou
self:E( TraceTable )
end
+function DATABASE:GetGroupTemplate( GroupName )
+ local GroupTemplate = self.Templates.Groups[GroupName].Template
+ GroupTemplate.SpawnCoalitionID = self.Templates.Groups[GroupName].CoalitionID
+ GroupTemplate.SpawnCategoryID = self.Templates.Groups[GroupName].CategoryID
+ GroupTemplate.SpawnCountryID = self.Templates.Groups[GroupName].CountryID
+ return GroupTemplate
+end
+
function DATABASE:GetCoalitionFromClientTemplate( ClientName )
return self.Templates.ClientsByName[ClientName].CoalitionID
end
diff --git a/Moose Development/Moose/Group.lua b/Moose Development/Moose/Group.lua
index 5792cad84..57375b510 100644
--- a/Moose Development/Moose/Group.lua
+++ b/Moose Development/Moose/Group.lua
@@ -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
diff --git a/Moose Development/Moose/Zone.lua b/Moose Development/Moose/Zone.lua
index 199005d9a..893abd5c2 100644
--- a/Moose Development/Moose/Zone.lua
+++ b/Moose Development/Moose/Zone.lua
@@ -18,8 +18,9 @@
-- * @{Zone#ZONE_BASE}: The ZONE_BASE class defining the base for all other zone classes.
-- * @{Zone#ZONE_RADIUS}: The ZONE_RADIUS class defined by a zone name, a location and a radius.
-- * @{Zone#ZONE}: The ZONE class, defined by the zone name as defined within the Mission Editor.
--- * @{Zone#ZONE_UNIT}: The ZONE_UNIT class defined by a zone around a @{Unit#UNIT} with a radius.
--- * @{Zone#ZONE_POLYGON}: The ZONE_POLYGON class defined by a sequence of @{Group#GROUP} waypoints within the Mission Editor, forming a polygon.
+-- * @{Zone#ZONE_UNIT}: The ZONE_UNIT class defines by a zone around a @{Unit#UNIT} with a radius.
+-- * @{Zone#ZONE_GROUP}: The ZONE_GROUP class defines by a zone around a @{Group#GROUP} with a radius.
+-- * @{Zone#ZONE_POLYGON}: The ZONE_POLYGON class defines by a sequence of @{Group#GROUP} waypoints within the Mission Editor, forming a polygon.
--
-- Each zone implements two polymorphic functions defined in @{Zone#ZONE_BASE}:
--
@@ -52,7 +53,13 @@
--
-- ===
--
--- 5) @{Zone#ZONE_POLYGON} class, extends @{Zone#ZONE_BASE}
+-- 5) @{Zone#ZONE_GROUP} class, extends @{Zone#ZONE_RADIUS}
+-- =======================================================
+-- The ZONE_GROUP class defines by a zone around a @{Group#GROUP} with a radius. The current leader of the group defines the center of the zone.
+--
+-- ===
+--
+-- 6) @{Zone#ZONE_POLYGON} class, extends @{Zone#ZONE_BASE}
-- ========================================================
-- The ZONE_POLYGON class defined by a sequence of @{Group#GROUP} waypoints within the Mission Editor, forming a polygon.
--
@@ -62,13 +69,6 @@
-- @author FlightControl
-
-
-
-
-
-
-
--- The ZONE_BASE class
-- @type ZONE_BASE
-- @field #string ZoneName Name of the zone.
@@ -422,6 +422,64 @@ function ZONE_UNIT:GetRandomVec2()
return Point
end
+
+--- The ZONE_GROUP class defined by a zone around a @{Group}, taking the average center point of all the units within the Group, with a radius.
+-- @type ZONE_GROUP
+-- @field Group#GROUP ZoneGROUP
+-- @extends Zone#ZONE_RADIUS
+ZONE_GROUP = {
+ ClassName="ZONE_GROUP",
+ }
+
+--- Constructor to create a ZONE_GROUP instance, taking the zone name, a zone @{Group#GROUP} and a radius.
+-- @param #ZONE_GROUP self
+-- @param #string ZoneName Name of the zone.
+-- @param Group#GROUP ZoneGROUP The @{Group} as the center of the zone.
+-- @param DCSTypes#Distance Radius The radius of the zone.
+-- @return #ZONE_GROUP self
+function ZONE_GROUP:New( ZoneName, ZoneGROUP, Radius )
+ local self = BASE:Inherit( self, ZONE_RADIUS:New( ZoneName, ZoneGROUP:GetPointVec2(), Radius ) )
+ self:F( { ZoneName, ZoneGROUP:GetPointVec2(), Radius } )
+
+ self.ZoneGROUP = ZoneGROUP
+
+ return self
+end
+
+
+--- Returns the current location of the @{Group}.
+-- @param #ZONE_GROUP self
+-- @return DCSTypes#Vec2 The location of the zone based on the @{Group} location.
+function ZONE_GROUP:GetPointVec2()
+ self:F( self.ZoneName )
+
+ local ZonePointVec2 = self.ZoneGROUP:GetPointVec2()
+
+ self:T( { ZonePointVec2 } )
+
+ return ZonePointVec2
+end
+
+--- Returns a random location within the zone of the @{Group}.
+-- @param #ZONE_GROUP self
+-- @return DCSTypes#Vec2 The random location of the zone based on the @{Group} location.
+function ZONE_GROUP:GetRandomVec2()
+ self:F( self.ZoneName )
+
+ local Point = {}
+ local PointVec2 = self.ZoneGROUP:GetPointVec2()
+
+ local angle = math.random() * math.pi*2;
+ Point.x = PointVec2.x + math.cos( angle ) * math.random() * self:GetRadius();
+ Point.y = PointVec2.y + math.sin( angle ) * math.random() * self:GetRadius();
+
+ self:T( { Point } )
+
+ return Point
+end
+
+
+
-- Polygons
--- The ZONE_POLYGON_BASE class defined by an array of @{DCSTypes#Vec2}, forming a polygon.
diff --git a/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua b/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua
index 286691208..5f7ca69d2 100644
--- a/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua
+++ b/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua
@@ -1,5 +1,5 @@
env.info( '*** MOOSE STATIC INCLUDE START *** ' )
-env.info( 'Moose Generation Timestamp: 20160704_1648' )
+env.info( 'Moose Generation Timestamp: 20160705_0828' )
local base = _G
Include = {}
@@ -7580,14 +7580,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
@@ -7604,16 +7624,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
@@ -8340,8 +8393,9 @@ end
-- * @{Zone#ZONE_BASE}: The ZONE_BASE class defining the base for all other zone classes.
-- * @{Zone#ZONE_RADIUS}: The ZONE_RADIUS class defined by a zone name, a location and a radius.
-- * @{Zone#ZONE}: The ZONE class, defined by the zone name as defined within the Mission Editor.
--- * @{Zone#ZONE_UNIT}: The ZONE_UNIT class defined by a zone around a @{Unit#UNIT} with a radius.
--- * @{Zone#ZONE_POLYGON}: The ZONE_POLYGON class defined by a sequence of @{Group#GROUP} waypoints within the Mission Editor, forming a polygon.
+-- * @{Zone#ZONE_UNIT}: The ZONE_UNIT class defines by a zone around a @{Unit#UNIT} with a radius.
+-- * @{Zone#ZONE_GROUP}: The ZONE_GROUP class defines by a zone around a @{Group#GROUP} with a radius.
+-- * @{Zone#ZONE_POLYGON}: The ZONE_POLYGON class defines by a sequence of @{Group#GROUP} waypoints within the Mission Editor, forming a polygon.
--
-- Each zone implements two polymorphic functions defined in @{Zone#ZONE_BASE}:
--
@@ -8374,7 +8428,13 @@ end
--
-- ===
--
--- 5) @{Zone#ZONE_POLYGON} class, extends @{Zone#ZONE_BASE}
+-- 5) @{Zone#ZONE_GROUP} class, extends @{Zone#ZONE_RADIUS}
+-- =======================================================
+-- The ZONE_GROUP class defines by a zone around a @{Group#GROUP} with a radius. The current leader of the group defines the center of the zone.
+--
+-- ===
+--
+-- 6) @{Zone#ZONE_POLYGON} class, extends @{Zone#ZONE_BASE}
-- ========================================================
-- The ZONE_POLYGON class defined by a sequence of @{Group#GROUP} waypoints within the Mission Editor, forming a polygon.
--
@@ -8384,13 +8444,6 @@ end
-- @author FlightControl
-
-
-
-
-
-
-
--- The ZONE_BASE class
-- @type ZONE_BASE
-- @field #string ZoneName Name of the zone.
@@ -8744,6 +8797,64 @@ function ZONE_UNIT:GetRandomVec2()
return Point
end
+
+--- The ZONE_GROUP class defined by a zone around a @{Group}, taking the average center point of all the units within the Group, with a radius.
+-- @type ZONE_GROUP
+-- @field Group#GROUP ZoneGROUP
+-- @extends Zone#ZONE_RADIUS
+ZONE_GROUP = {
+ ClassName="ZONE_GROUP",
+ }
+
+--- Constructor to create a ZONE_GROUP instance, taking the zone name, a zone @{Group#GROUP} and a radius.
+-- @param #ZONE_GROUP self
+-- @param #string ZoneName Name of the zone.
+-- @param Group#GROUP ZoneGROUP The @{Group} as the center of the zone.
+-- @param DCSTypes#Distance Radius The radius of the zone.
+-- @return #ZONE_GROUP self
+function ZONE_GROUP:New( ZoneName, ZoneGROUP, Radius )
+ local self = BASE:Inherit( self, ZONE_RADIUS:New( ZoneName, ZoneGROUP:GetPointVec2(), Radius ) )
+ self:F( { ZoneName, ZoneGROUP:GetPointVec2(), Radius } )
+
+ self.ZoneGROUP = ZoneGROUP
+
+ return self
+end
+
+
+--- Returns the current location of the @{Group}.
+-- @param #ZONE_GROUP self
+-- @return DCSTypes#Vec2 The location of the zone based on the @{Group} location.
+function ZONE_GROUP:GetPointVec2()
+ self:F( self.ZoneName )
+
+ local ZonePointVec2 = self.ZoneGROUP:GetPointVec2()
+
+ self:T( { ZonePointVec2 } )
+
+ return ZonePointVec2
+end
+
+--- Returns a random location within the zone of the @{Group}.
+-- @param #ZONE_GROUP self
+-- @return DCSTypes#Vec2 The random location of the zone based on the @{Group} location.
+function ZONE_GROUP:GetRandomVec2()
+ self:F( self.ZoneName )
+
+ local Point = {}
+ local PointVec2 = self.ZoneGROUP:GetPointVec2()
+
+ local angle = math.random() * math.pi*2;
+ Point.x = PointVec2.x + math.cos( angle ) * math.random() * self:GetRadius();
+ Point.y = PointVec2.y + math.sin( angle ) * math.random() * self:GetRadius();
+
+ self:T( { Point } )
+
+ return Point
+end
+
+
+
-- Polygons
--- The ZONE_POLYGON_BASE class defined by an array of @{DCSTypes#Vec2}, forming a polygon.
@@ -9982,6 +10093,14 @@ function DATABASE:_RegisterTemplate( GroupTemplate, CoalitionID, CategoryID, Cou
self:E( TraceTable )
end
+function DATABASE:GetGroupTemplate( GroupName )
+ local GroupTemplate = self.Templates.Groups[GroupName].Template
+ GroupTemplate.SpawnCoalitionID = self.Templates.Groups[GroupName].CoalitionID
+ GroupTemplate.SpawnCategoryID = self.Templates.Groups[GroupName].CategoryID
+ GroupTemplate.SpawnCountryID = self.Templates.Groups[GroupName].CountryID
+ return GroupTemplate
+end
+
function DATABASE:GetCoalitionFromClientTemplate( ClientName )
return self.Templates.ClientsByName[ClientName].CoalitionID
end
diff --git a/Moose Mission Setup/Moose.lua b/Moose Mission Setup/Moose.lua
index 286691208..5f7ca69d2 100644
--- a/Moose Mission Setup/Moose.lua
+++ b/Moose Mission Setup/Moose.lua
@@ -1,5 +1,5 @@
env.info( '*** MOOSE STATIC INCLUDE START *** ' )
-env.info( 'Moose Generation Timestamp: 20160704_1648' )
+env.info( 'Moose Generation Timestamp: 20160705_0828' )
local base = _G
Include = {}
@@ -7580,14 +7580,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
@@ -7604,16 +7624,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
@@ -8340,8 +8393,9 @@ end
-- * @{Zone#ZONE_BASE}: The ZONE_BASE class defining the base for all other zone classes.
-- * @{Zone#ZONE_RADIUS}: The ZONE_RADIUS class defined by a zone name, a location and a radius.
-- * @{Zone#ZONE}: The ZONE class, defined by the zone name as defined within the Mission Editor.
--- * @{Zone#ZONE_UNIT}: The ZONE_UNIT class defined by a zone around a @{Unit#UNIT} with a radius.
--- * @{Zone#ZONE_POLYGON}: The ZONE_POLYGON class defined by a sequence of @{Group#GROUP} waypoints within the Mission Editor, forming a polygon.
+-- * @{Zone#ZONE_UNIT}: The ZONE_UNIT class defines by a zone around a @{Unit#UNIT} with a radius.
+-- * @{Zone#ZONE_GROUP}: The ZONE_GROUP class defines by a zone around a @{Group#GROUP} with a radius.
+-- * @{Zone#ZONE_POLYGON}: The ZONE_POLYGON class defines by a sequence of @{Group#GROUP} waypoints within the Mission Editor, forming a polygon.
--
-- Each zone implements two polymorphic functions defined in @{Zone#ZONE_BASE}:
--
@@ -8374,7 +8428,13 @@ end
--
-- ===
--
--- 5) @{Zone#ZONE_POLYGON} class, extends @{Zone#ZONE_BASE}
+-- 5) @{Zone#ZONE_GROUP} class, extends @{Zone#ZONE_RADIUS}
+-- =======================================================
+-- The ZONE_GROUP class defines by a zone around a @{Group#GROUP} with a radius. The current leader of the group defines the center of the zone.
+--
+-- ===
+--
+-- 6) @{Zone#ZONE_POLYGON} class, extends @{Zone#ZONE_BASE}
-- ========================================================
-- The ZONE_POLYGON class defined by a sequence of @{Group#GROUP} waypoints within the Mission Editor, forming a polygon.
--
@@ -8384,13 +8444,6 @@ end
-- @author FlightControl
-
-
-
-
-
-
-
--- The ZONE_BASE class
-- @type ZONE_BASE
-- @field #string ZoneName Name of the zone.
@@ -8744,6 +8797,64 @@ function ZONE_UNIT:GetRandomVec2()
return Point
end
+
+--- The ZONE_GROUP class defined by a zone around a @{Group}, taking the average center point of all the units within the Group, with a radius.
+-- @type ZONE_GROUP
+-- @field Group#GROUP ZoneGROUP
+-- @extends Zone#ZONE_RADIUS
+ZONE_GROUP = {
+ ClassName="ZONE_GROUP",
+ }
+
+--- Constructor to create a ZONE_GROUP instance, taking the zone name, a zone @{Group#GROUP} and a radius.
+-- @param #ZONE_GROUP self
+-- @param #string ZoneName Name of the zone.
+-- @param Group#GROUP ZoneGROUP The @{Group} as the center of the zone.
+-- @param DCSTypes#Distance Radius The radius of the zone.
+-- @return #ZONE_GROUP self
+function ZONE_GROUP:New( ZoneName, ZoneGROUP, Radius )
+ local self = BASE:Inherit( self, ZONE_RADIUS:New( ZoneName, ZoneGROUP:GetPointVec2(), Radius ) )
+ self:F( { ZoneName, ZoneGROUP:GetPointVec2(), Radius } )
+
+ self.ZoneGROUP = ZoneGROUP
+
+ return self
+end
+
+
+--- Returns the current location of the @{Group}.
+-- @param #ZONE_GROUP self
+-- @return DCSTypes#Vec2 The location of the zone based on the @{Group} location.
+function ZONE_GROUP:GetPointVec2()
+ self:F( self.ZoneName )
+
+ local ZonePointVec2 = self.ZoneGROUP:GetPointVec2()
+
+ self:T( { ZonePointVec2 } )
+
+ return ZonePointVec2
+end
+
+--- Returns a random location within the zone of the @{Group}.
+-- @param #ZONE_GROUP self
+-- @return DCSTypes#Vec2 The random location of the zone based on the @{Group} location.
+function ZONE_GROUP:GetRandomVec2()
+ self:F( self.ZoneName )
+
+ local Point = {}
+ local PointVec2 = self.ZoneGROUP:GetPointVec2()
+
+ local angle = math.random() * math.pi*2;
+ Point.x = PointVec2.x + math.cos( angle ) * math.random() * self:GetRadius();
+ Point.y = PointVec2.y + math.sin( angle ) * math.random() * self:GetRadius();
+
+ self:T( { Point } )
+
+ return Point
+end
+
+
+
-- Polygons
--- The ZONE_POLYGON_BASE class defined by an array of @{DCSTypes#Vec2}, forming a polygon.
@@ -9982,6 +10093,14 @@ function DATABASE:_RegisterTemplate( GroupTemplate, CoalitionID, CategoryID, Cou
self:E( TraceTable )
end
+function DATABASE:GetGroupTemplate( GroupName )
+ local GroupTemplate = self.Templates.Groups[GroupName].Template
+ GroupTemplate.SpawnCoalitionID = self.Templates.Groups[GroupName].CoalitionID
+ GroupTemplate.SpawnCategoryID = self.Templates.Groups[GroupName].CategoryID
+ GroupTemplate.SpawnCountryID = self.Templates.Groups[GroupName].CountryID
+ return GroupTemplate
+end
+
function DATABASE:GetCoalitionFromClientTemplate( ClientName )
return self.Templates.ClientsByName[ClientName].CoalitionID
end
diff --git a/Moose Training/Documentation/AIBalancer.html b/Moose Training/Documentation/AIBalancer.html
index c07c2ae71..c113e2ea1 100644
--- a/Moose Training/Documentation/AIBalancer.html
+++ b/Moose Training/Documentation/AIBalancer.html
@@ -35,6 +35,7 @@
@@ -1066,6 +1085,11 @@ The mission route defined by points.
+
Returns the group template from the DATABASE (_DATABASE object).
+
+
Return value
+
+
#table:
@@ -1544,16 +1568,135 @@ self
+
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.
+
Parameter
+
#table Template :
+The template of the Group retrieved with GROUP:GetTemplate()