diff --git a/Moose Development/Moose/AI/AI_A2A_Dispatcher.lua b/Moose Development/Moose/AI/AI_A2A_Dispatcher.lua index dc75e8269..26a5403ba 100644 --- a/Moose Development/Moose/AI/AI_A2A_Dispatcher.lua +++ b/Moose Development/Moose/AI/AI_A2A_Dispatcher.lua @@ -2610,7 +2610,7 @@ do -- AI_A2A_DISPATCHER if Cap then - local Spawn = DefenderSquadron.Spawn[ math.random( 1, #DefenderSquadron.Spawn ) ] -- Functional.Spawn#SPAWN + local Spawn = DefenderSquadron.Spawn[ math.random( 1, #DefenderSquadron.Spawn ) ] -- Core.Spawn#SPAWN local DefenderGrouping = DefenderSquadron.Grouping or self.DefenderDefault.Grouping Spawn:InitGrouping( DefenderGrouping ) @@ -2783,7 +2783,7 @@ do -- AI_A2A_DISPATCHER while ( DefendersNeeded > 0 ) do - local Spawn = DefenderSquadron.Spawn[ math.random( 1, #DefenderSquadron.Spawn ) ] -- Functional.Spawn#SPAWN + local Spawn = DefenderSquadron.Spawn[ math.random( 1, #DefenderSquadron.Spawn ) ] -- Core.Spawn#SPAWN local DefenderGrouping = ( DefenderGrouping < DefendersNeeded ) and DefenderGrouping or DefendersNeeded if DefenderGrouping then Spawn:InitGrouping( DefenderGrouping ) diff --git a/Moose Development/Moose/AI/AI_Balancer.lua b/Moose Development/Moose/AI/AI_Balancer.lua index 643dfc5b7..26fba95c9 100644 --- a/Moose Development/Moose/AI/AI_Balancer.lua +++ b/Moose Development/Moose/AI/AI_Balancer.lua @@ -33,7 +33,7 @@ --- @type AI_BALANCER -- @field Core.Set#SET_CLIENT SetClient --- @field Functional.Spawn#SPAWN SpawnAI +-- @field Core.Spawn#SPAWN SpawnAI -- @field Wrapper.Group#GROUP Test -- @extends Core.Fsm#FSM_SET @@ -106,7 +106,7 @@ AI_BALANCER = { --- Creates a new AI_BALANCER object -- @param #AI_BALANCER self -- @param Core.Set#SET_CLIENT SetClient A SET\_CLIENT object that will contain the CLIENT objects to be monitored if they are alive or not (joined by a player). --- @param Functional.Spawn#SPAWN SpawnAI The default Spawn object to spawn new AI Groups when needed. +-- @param Core.Spawn#SPAWN SpawnAI The default Spawn object to spawn new AI Groups when needed. -- @return #AI_BALANCER function AI_BALANCER:New( SetClient, SpawnAI ) diff --git a/Moose Development/Moose/AI/AI_Patrol.lua b/Moose Development/Moose/AI/AI_Patrol.lua index 69c341435..fe3474b0d 100644 --- a/Moose Development/Moose/AI/AI_Patrol.lua +++ b/Moose Development/Moose/AI/AI_Patrol.lua @@ -47,7 +47,7 @@ -- @field Dcs.DCSTypes#Altitude PatrolCeilingAltitude The highest altitude in meters where to execute the patrol. -- @field Dcs.DCSTypes#Speed PatrolMinSpeed The minimum speed of the @{Controllable} in km/h. -- @field Dcs.DCSTypes#Speed PatrolMaxSpeed The maximum speed of the @{Controllable} in km/h. --- @field Functional.Spawn#SPAWN CoordTest +-- @field Core.Spawn#SPAWN CoordTest -- @extends Core.Fsm#FSM_CONTROLLABLE --- # AI_PATROL_ZONE class, extends @{Fsm#FSM_CONTROLLABLE} diff --git a/Moose Development/Moose/Core/Zone.lua b/Moose Development/Moose/Core/Zone.lua index 90f43f470..245360fb6 100644 --- a/Moose Development/Moose/Core/Zone.lua +++ b/Moose Development/Moose/Core/Zone.lua @@ -1354,7 +1354,7 @@ ZONE_POLYGON = { ClassName="ZONE_POLYGON", } ---- Constructor to create a ZONE_POLYGON instance, taking the zone name and the name of the @{Group#GROUP} defined within the Mission Editor. +--- Constructor to create a ZONE_POLYGON instance, taking the zone name and the @{Group#GROUP} defined within the Mission Editor. -- The @{Group#GROUP} waypoints define the polygon corners. The first and the last point are automatically connected by ZONE_POLYGON. -- @param #ZONE_POLYGON self -- @param #string ZoneName Name of the zone. @@ -1370,3 +1370,22 @@ function ZONE_POLYGON:New( ZoneName, ZoneGroup ) return self end + +--- Constructor to create a ZONE_POLYGON instance, taking the zone name and the **name** of the @{Group#GROUP} defined within the Mission Editor. +-- The @{Group#GROUP} waypoints define the polygon corners. The first and the last point are automatically connected by ZONE_POLYGON. +-- @param #ZONE_POLYGON self +-- @param #string ZoneName Name of the zone. +-- @param #string GroupName The group name of the GROUP defining the waypoints within the Mission Editor to define the polygon shape. +-- @return #ZONE_POLYGON self +function ZONE_POLYGON:NewFromGroupName( ZoneName, GroupName ) + + local ZoneGroup = GROUP:FindByName( GroupName ) + + local GroupPoints = ZoneGroup:GetTaskRoute() + + local self = BASE:Inherit( self, ZONE_POLYGON_BASE:New( ZoneName, GroupPoints ) ) + self:F( { ZoneName, ZoneGroup, self._.Polygon } ) + + return self +end + diff --git a/Moose Development/Moose/Functional/RAT.lua b/Moose Development/Moose/Functional/RAT.lua index c4286842b..03055ea3f 100644 --- a/Moose Development/Moose/Functional/RAT.lua +++ b/Moose Development/Moose/Functional/RAT.lua @@ -112,7 +112,7 @@ -- @field #string livery Livery of the aircraft set by user. -- @field #string skill Skill of AI. -- @field #boolean ATCswitch Enable/disable ATC if set to true/false. --- @extends Functional.Spawn#SPAWN +-- @extends Core.Spawn#SPAWN ---# RAT class, extends @{Spawn#SPAWN} -- The RAT class implements an easy to use way to randomly fill your map with AI aircraft. diff --git a/Moose Development/Moose/Functional/Spawn.lua b/Moose Development/Moose/Functional/Spawn.lua index 6a99bdc11..851b2c76c 100644 --- a/Moose Development/Moose/Functional/Spawn.lua +++ b/Moose Development/Moose/Functional/Spawn.lua @@ -1,4 +1,4 @@ ---- **Functional** -- Spawn dynamically new GROUPs in your missions. +--- **Core** -- SPAWN class dynamically spawns new groups of units in your missions. -- -- ![Banner Image](..\Presentations\SPAWN\SPAWN.JPG) -- @@ -55,8 +55,12 @@ --- # SPAWN class, extends @{Base#BASE} -- +-- -- ![Banner Image](..\Presentations\SPAWN\SPAWN.JPG) +-- +-- === +-- -- The SPAWN class allows to spawn dynamically new groups. --- Each SPAWN object needs to be have a related **template group** setup in the Mission Editor (ME), +-- Each SPAWN object needs to be have related **template groups** setup in the Mission Editor (ME), -- which is a normal group with the **Late Activation** flag set. -- This template group will never be activated in your mission. -- SPAWN uses that **template group** to reference to all the characteristics @@ -521,6 +525,73 @@ function SPAWN:InitRandomizeTemplate( SpawnTemplatePrefixTable ) return self end + +--- Randomize templates to be used as the unit representatives for the Spawned group, defined using a SET_GROUP object. +-- This method becomes useful when you need to spawn groups with random templates of groups defined within the mission editor, +-- but they will all follow the same Template route and have the same prefix name. +-- In other words, this method randomizes between a defined set of groups the template to be used for each new spawn of a group. +-- @param #SPAWN self +-- @param Core.Set#SET_GROUP SpawnTemplateSet A SET_GROUP object set, that contains the groups that are possible unit representatives of the group to be spawned. +-- @return #SPAWN +-- @usage +-- -- NATO Tank Platoons invading Gori. +-- +-- -- Choose between different 'US Tank Platoon Template' configurations to be spawned for the +-- -- 'US Tank Platoon Left', 'US Tank Platoon Middle' and 'US Tank Platoon Right' SPAWN objects. +-- +-- -- Each new SPAWN will randomize the route, with a defined time interval of 200 seconds with 40% time variation (randomization) and +-- -- with a limit set of maximum 12 Units alive simulteneously and 150 Groups to be spawned during the whole mission. +-- +-- Spawn_US_PlatoonSet = SET_GROUP:New():FilterPrefixes( "US Tank Platoon Templates" ):FilterOnce() +-- +-- --- Now use the Spawn_US_PlatoonSet to define the templates using InitRandomizeTemplateSet. +-- Spawn_US_Platoon_Left = SPAWN:New( 'US Tank Platoon Left' ):InitLimit( 12, 150 ):Schedule( 200, 0.4 ):InitRandomizeTemplateSet( Spawn_US_PlatoonSet ):InitRandomizeRoute( 3, 3, 2000 ) +-- Spawn_US_Platoon_Middle = SPAWN:New( 'US Tank Platoon Middle' ):InitLimit( 12, 150 ):Schedule( 200, 0.4 ):InitRandomizeTemplateSet( Spawn_US_PlatoonSet ):InitRandomizeRoute( 3, 3, 2000 ) +-- Spawn_US_Platoon_Right = SPAWN:New( 'US Tank Platoon Right' ):InitLimit( 12, 150 ):Schedule( 200, 0.4 ):InitRandomizeTemplateSet( Spawn_US_PlatoonSet ):InitRandomizeRoute( 3, 3, 2000 ) +function SPAWN:InitRandomizeTemplateSet( SpawnTemplateSet ) -- R2.3 + self:F( { self.SpawnTemplatePrefix } ) + + self.SpawnTemplatePrefixTable = SpawnTemplateSet:GetSetNames() + self.SpawnRandomizeTemplate = true + + for SpawnGroupID = 1, self.SpawnMaxGroups do + self:_RandomizeTemplate( SpawnGroupID ) + end + + return self +end + + +--- Randomize templates to be used as the unit representatives for the Spawned group, defined by specifying the prefix names. +-- This method becomes useful when you need to spawn groups with random templates of groups defined within the mission editor, +-- but they will all follow the same Template route and have the same prefix name. +-- In other words, this method randomizes between a defined set of groups the template to be used for each new spawn of a group. +-- @param #SPAWN self +-- @param #string SpawnTemplatePrefixes A string or a list of string that contains the prefixes of the groups that are possible unit representatives of the group to be spawned. +-- @return #SPAWN +-- @usage +-- -- NATO Tank Platoons invading Gori. +-- +-- -- Choose between different 'US Tank Platoon Templates' configurations to be spawned for the +-- -- 'US Tank Platoon Left', 'US Tank Platoon Middle' and 'US Tank Platoon Right' SPAWN objects. +-- +-- -- Each new SPAWN will randomize the route, with a defined time interval of 200 seconds with 40% time variation (randomization) and +-- -- with a limit set of maximum 12 Units alive simulteneously and 150 Groups to be spawned during the whole mission. +-- +-- Spawn_US_Platoon_Left = SPAWN:New( 'US Tank Platoon Left' ):InitLimit( 12, 150 ):Schedule( 200, 0.4 ):InitRandomizeTemplatePrefixes( "US Tank Platoon Templates" ):InitRandomizeRoute( 3, 3, 2000 ) +-- Spawn_US_Platoon_Middle = SPAWN:New( 'US Tank Platoon Middle' ):InitLimit( 12, 150 ):Schedule( 200, 0.4 ):InitRandomizeTemplatePrefixes( "US Tank Platoon Templates" ):InitRandomizeRoute( 3, 3, 2000 ) +-- Spawn_US_Platoon_Right = SPAWN:New( 'US Tank Platoon Right' ):InitLimit( 12, 150 ):Schedule( 200, 0.4 ):InitRandomizeTemplatePrefixes( "US Tank Platoon Templates" ):InitRandomizeRoute( 3, 3, 2000 ) +function SPAWN:InitRandomizeTemplatePrefixes( SpawnTemplatePrefixes ) --R2.3 + self:F( { self.SpawnTemplatePrefix } ) + + local SpawnTemplateSet = SET_GROUP:New():FilterPrefixes( SpawnTemplatePrefixes ):FilterOnce() + + self:InitRandomizeTemplateSet( SpawnTemplateSet ) + + return self +end + + --- When spawning a new group, make the grouping of the units according the InitGrouping setting. -- @param #SPAWN self -- @param #number Grouping Indicates the maximum amount of units in the group. diff --git a/Moose Mission Setup/Moose.files b/Moose Mission Setup/Moose.files index 348844d93..657ffe1bd 100644 --- a/Moose Mission Setup/Moose.files +++ b/Moose Mission Setup/Moose.files @@ -17,6 +17,7 @@ Core/Point.lua Core/Message.lua Core/Fsm.lua Core/Radio.lua +Core/Spawn.lua Core/SpawnStatic.lua Core/Goal.lua Core/Cargo.lua @@ -35,7 +36,6 @@ Wrapper/Scenery.lua Functional/Scoring.lua Functional/CleanUp.lua -Functional/Spawn.lua Functional/Movement.lua Functional/Sead.lua Functional/Escort.lua diff --git a/Moose Mission Setup/Moose.lua b/Moose Mission Setup/Moose.lua index 2b0c46928..b6fe6023e 100644 --- a/Moose Mission Setup/Moose.lua +++ b/Moose Mission Setup/Moose.lua @@ -1,5 +1,5 @@ env.info( '*** MOOSE DYNAMIC INCLUDE START *** ' ) -env.info( 'Moose Generation Timestamp: 20171010_1107' ) +env.info( 'Moose Generation Timestamp: 20171010_2132' ) local base = _G @@ -39,6 +39,7 @@ __Moose.Include( 'Core/Point.lua' ) __Moose.Include( 'Core/Message.lua' ) __Moose.Include( 'Core/Fsm.lua' ) __Moose.Include( 'Core/Radio.lua' ) +__Moose.Include( 'Core/Spawn.lua' ) __Moose.Include( 'Core/SpawnStatic.lua' ) __Moose.Include( 'Core/Goal.lua' ) __Moose.Include( 'Core/Cargo.lua' ) @@ -55,7 +56,6 @@ __Moose.Include( 'Wrapper/Airbase.lua' ) __Moose.Include( 'Wrapper/Scenery.lua' ) __Moose.Include( 'Functional/Scoring.lua' ) __Moose.Include( 'Functional/CleanUp.lua' ) -__Moose.Include( 'Functional/Spawn.lua' ) __Moose.Include( 'Functional/Movement.lua' ) __Moose.Include( 'Functional/Sead.lua' ) __Moose.Include( 'Functional/Escort.lua' ) diff --git a/Moose Mission Setup/Moose_.lua b/Moose Mission Setup/Moose_.lua index 3facc6990..9f5cabf95 100644 --- a/Moose Mission Setup/Moose_.lua +++ b/Moose Mission Setup/Moose_.lua @@ -1,5 +1,5 @@ env.info('*** MOOSE DYNAMIC INCLUDE START *** ') -env.info('Moose Generation Timestamp: 20171010_1107') +env.info('Moose Generation Timestamp: 20171010_2132') local base=_G __Moose={} __Moose.Include=function(IncludeFile) @@ -34,6 +34,7 @@ __Moose.Include('Core/Point.lua') __Moose.Include('Core/Message.lua') __Moose.Include('Core/Fsm.lua') __Moose.Include('Core/Radio.lua') +__Moose.Include('Core/Spawn.lua') __Moose.Include('Core/SpawnStatic.lua') __Moose.Include('Core/Goal.lua') __Moose.Include('Core/Cargo.lua') @@ -50,7 +51,6 @@ __Moose.Include('Wrapper/Airbase.lua') __Moose.Include('Wrapper/Scenery.lua') __Moose.Include('Functional/Scoring.lua') __Moose.Include('Functional/CleanUp.lua') -__Moose.Include('Functional/Spawn.lua') __Moose.Include('Functional/Movement.lua') __Moose.Include('Functional/Sead.lua') __Moose.Include('Functional/Escort.lua')