MOOSE demonstration missions [skip ci]

This commit is contained in:
Applevangelist
2021-05-21 13:19:55 +00:00
parent 95f42d6822
commit 09ae973553
1021 changed files with 493980 additions and 0 deletions
@@ -0,0 +1,74 @@
---
-- Name: EVT-001 - UNIT OnEventShot Stability Test
-- Author: FlightControl
-- Date Created: 9 Apr 2017
--
-- # Situation:
--
-- A couple of planes are firing to each other. Monitor the shot events.
-- I am doing a collectgarbage to test the stability of the event handling.
-- Also when the planes are destroyed, the event handling should stop etc.
-- The tests are on GROUP level.
--
-- # Test cases:
--
-- 1. Observe the planes shooting the missiles.
-- 2. Observe when the plane shoots the missile, a dcs.log entry is written in the logging.
-- 3. Check the stability of the event handlings.
PlaneGroupsBlue = {}
PlaneGroupsRed = {}
PlaneSpawnBlue = SPAWN
:New( "Planes Blue" )
:InitLimit( 2, 0 )
:SpawnScheduled( 10,0 )
:OnSpawnGroup(
function( SpawnGroup )
SpawnGroupName = SpawnGroup:GetName()
PlaneGroupsBlue[SpawnGroupName] = SpawnGroup
PlaneGroupsBlue[SpawnGroupName]:HandleEvent( EVENTS.Shot )
PlaneGroupsBlue[SpawnGroupName]:HandleEvent( EVENTS.Hit )
collectgarbage()
PlaneGroupsBlue[SpawnGroupName].OnEventShot = function( self, EventData )
self:F( EventData )
self:MessageToAll( "I just fired a missile!", 15, "Alert!" )
end
PlaneGroupsBlue[SpawnGroupName].OnEventHit = function( self, EventData )
self:F( EventData )
self:MessageToAll( "I just got hit!", 15, "Alert!" )
end
end
)
PlaneSpawnRed = SPAWN
:New( "Planes Red" )
:InitLimit( 2, 0 )
:SpawnScheduled(10,0)
:OnSpawnGroup(
function( SpawnGroup )
SpawnGroupName = SpawnGroup:GetName()
PlaneGroupsRed[SpawnGroupName] = SpawnGroup
PlaneGroupsRed[SpawnGroupName]:HandleEvent( EVENTS.Shot )
PlaneGroupsRed[SpawnGroupName]:HandleEvent( EVENTS.Hit )
collectgarbage()
--- @param self
-- @param Core.Event#EVENTDATA EventData
PlaneGroupsRed[SpawnGroupName].OnEventShot = function ( self, EventData )
self:F( EventData )
self:MessageToAll( "I just got hit!", 15, "Alert!" )
end
PlaneGroupsRed[SpawnGroupName].OnEventHit = function( self, EventData )
self:F( EventData )
self:MessageToAll( "I just fired a missile!", 15, "Alert!" )
end
end
)
collectgarbage()
BASE:E( "Collected garbage" )
@@ -0,0 +1,40 @@
---
-- Name: EVT-002 - UNIT OnEventLand ReSpawn Test
-- Author: FlightControl
-- Date Created: 9 Apr 2017
--
-- # Situation:
--
-- A couple of planes are taking off from an airbase.
-- When they land, they send out a message that they landed.
-- But! They are automatically respawned upon landing.
-- The 2nd time the same plane lands, they should send the message again!!!
--
-- # Test cases:
--
-- 1. Observe in the logging, that the event subscriptions are reset when the respawn happens!
-- 2. Observe the 2nd time the same plane lands, they should send the message again!!!
-- 3. Check the stability of the event handlings.
PlaneBlueSpawn = SPAWN
:New( "PlaneBlue" )
:InitLimit(2,0)
:InitRepeatOnEngineShutDown()
:SpawnScheduled(60,0)
:OnSpawnGroup(
--- @param Wrapper.Group#GROUP SpawnGroup
function( SpawnGroup )
SpawnGroup:HandleEvent( EVENTS.Land )
--- @param self
-- @param Core.Event#EVENTDATA EventData
function SpawnGroup:OnEventLand(EventData)
EventData.IniGroup:MessageToAll("Landed",15,"Land Event")
end
end
)
collectgarbage()
BASE:E( "Collected garbage" )
@@ -0,0 +1,139 @@
Include.File( "Spawn" )
-- Tests Anapa: Spawn Basics
-- -------------------------
-- Spawning groups using Spawn function.
Spawn_Plane = SPAWN:New( "Spawn Plane" )
Group_Plane = Spawn_Plane:Spawn()
Spawn_Helicopter = SPAWN:New( "Spawn Helicopter" ):RandomizeRoute( 1, 1, 1000 )
Group_Helicopter = Spawn_Helicopter:Spawn()
Group_Helicopter2 = Spawn_Helicopter:Spawn()
Spawn_Ship = SPAWN:New( "Spawn Ship" ):RandomizeRoute( 0, 0, 2000 )
Group_Ship1 = Spawn_Ship:Spawn()
Group_Ship2 = Spawn_Ship:Spawn()
Spawn_Vehicle = SPAWN:New( "Spawn Vehicle" ):RandomizeRoute( 1, 0, 50 )
Group_Vehicle1 = Spawn_Vehicle:Spawn()
Group_Vehicle2 = Spawn_Vehicle:Spawn()
Group_Vehicle3 = Spawn_Vehicle:Spawn()
Group_Vehicle4 = Spawn_Vehicle:Spawn()
Group_Vehicle5 = Spawn_Vehicle:Spawn()
Group_Vehicle6 = Spawn_Vehicle:Spawn()
Group_Vehicle1:TaskRouteToZone( ZONE:New( "Landing Zone" ), true, 40, "Cone" )
-- Now land the spawned plane on to the Vinson, by copying the route of another object.
Route_Plane = GROUP:NewFromName( "Spawn Helicopter Route Copy" ):CopyRoute( 1, 0 )
Group_Plane:Route( Route_Plane )
--Route_Helicopter[#Route_Helicopter].linkUnit = Group_Ship1:GetDCSUnit(1)
--Route_Helicopter[#Route_Helicopter].helipadId = Group_Ship1:GetDCSUnit(1)
--Route_Helicopter[#Route_Helicopter].x = Group_Ship1:GetUnit(1):GetPointVec2().x
--Route_Helicopter[#Route_Helicopter].y = Group_Ship1:GetUnit(1):GetPointVec2().y
--env.info( Route_Helicopter[#Route_Helicopter].type .. " on " .. Group_Ship1:GetUnit(1):GetID() )
--Group_Helicopter:Route( Route_Helicopter )
-- Tests Batumi: Scheduled Spawning
-- --------------------------------
-- Unlimited spawning of groups, scheduled every 30 seconds ...
Spawn_Plane_Scheduled = SPAWN:New( "Spawn Plane Scheduled" ):SpawnScheduled( 30, 0.4 )
Spawn_Helicopter_Scheduled = SPAWN:New( "Spawn Helicopter Scheduled" ):SpawnScheduled( 30, 1 )
Spawn_Ship_Scheduled = SPAWN:New( "Spawn Ship Scheduled" ):SpawnScheduled( 30, 0.5 )
Spawn_Vehicle_Scheduled = SPAWN:New( "Spawn Vehicle Scheduled" ):SpawnScheduled( 30, 0.5 )
-- Tests Tbilisi: Limited Spawning
-- -------------------------------
-- Spawing one group, and respawning the same group when it lands ...
Spawn_Plane_Limited_Repeat = SPAWN:New( "Spawn Plane Limited Repeat" ):Limit( 1, 1 ):Repeat():Spawn()
Spawn_Plane_Limited_RepeatOnLanding = SPAWN:New( "Spawn Plane Limited RepeatOnLanding" ):Limit( 1, 1 ):Repeat():Spawn()
Spawn_Plane_Limited_RepeatOnEngineShutDown = SPAWN:New( "Spawn Plane Limited RepeatOnEngineShutDown" ):Limit( 1, 1 ):Repeat():Spawn()
Spawn_Helicopter_Limited_Repeat = SPAWN:New( "Spawn Helicopter Limited Repeat" ):Limit( 1, 1 ):Repeat():Spawn()
Spawn_Helicopter_Limited_RepeatOnLanding = SPAWN:New( "Spawn Helicopter Limited RepeatOnLanding" ):Limit( 1, 1 ):Repeat():Spawn()
Spawn_Helicopter_Limited_RepeatOnEngineShutDown = SPAWN:New( "Spawn Helicopter Limited RepeatOnEngineShutDown" ):Limit( 1, 1 ):Repeat():Spawn()
-- Tests Soganlug
-- --------------
-- Limited spawning of groups, scheduled every 30 seconds ...
Spawn_Plane_Limited_Scheduled = SPAWN:New( "Spawn Plane Limited Scheduled" ):Limit( 2, 10 ):SpawnScheduled( 30, 0 )
Spawn_Helicopter_Limited_Scheduled = SPAWN:New( "Spawn Helicopter Limited Scheduled" ):Limit( 2, 10 ):SpawnScheduled( 30, 0 )
Spawn_Ground_Limited_Scheduled = SPAWN:New( "Spawn Vehicle Limited Scheduled" ):Limit( 1, 20 ):SpawnScheduled( 90, 0 )
-- Tests Sukhumi
-- -------------
-- Limited spawning of groups, scheduled every seconds with route randomization.
Spawn_Plane_Limited_Scheduled_RandomizeRoute = SPAWN:New( "Spawn Plane Limited Scheduled RandomizeRoute" ):Limit( 2, 10 ):RandomizeRoute( 1, 1, 4000 ):SpawnScheduled( 30, 0 )
Spawn_Helicopter_Limited_Scheduled_RandomizeRoute = SPAWN:New( "Spawn Helicopter Limited Scheduled RandomizeRoute" ):Limit( 2, 10 ):RandomizeRoute( 1, 1, 4000 ):SpawnScheduled( 30, 0 )
Spawn_Vehicle_Limited_Scheduled_RandomizeRoute = SPAWN:New( "Spawn Vehicle Limited Scheduled RandomizeRoute" ):Limit( 10, 10 ):RandomizeRoute( 1, 1, 1000 ):SpawnScheduled( 1, 0 )
-- Tests Kutaisi
-- -------------
-- Tests the CleanUp functionality.
-- Limited spawning of groups, scheduled every 10 seconds, who are engaging into combat. Some helicopters may crash land on the ground.
-- Observe when helicopters land but are not dead and are out of the danger zone, that they get removed after a while (+/- 180 seconds) and ReSpawn.
Spawn_Helicopter_Scheduled_CleanUp = SPAWN:New( "Spawn Helicopter Scheduled CleanUp" ):Limit( 3, 100 ):RandomizeRoute( 1, 1, 1000 ):CleanUp( 180 ):SpawnScheduled( 10, 0 )
Spawn_Vehicle_Scheduled_CleanUp = SPAWN:New( "Spawn Vehicle Scheduled CleanUp" ):Limit( 3, 100 ):RandomizeRoute( 1, 1, 1000 ):SpawnScheduled( 10, 0 )
-- Maykop
-- ------
-- Creates arrays of groups ready to be spawned and dynamic spawning of groups from another group.
-- SpawnTestVisible creates an array of 200 groups, every 20 groups with 20 meters space in between, and will activate a group of the array every 10 seconds with a 0.2 time randomization.
SpawnTestVisible = SPAWN:New( "Spawn Vehicle Visible Scheduled" ):Limit( 200, 200 ):Array( 59, 20, 20, 10 ):SpawnScheduled( 10, 0.2 )
-- Spawn_Templates_Visible contains different templates...
Spawn_Templates_Visible = { "Spawn Vehicle Visible Template A",
"Spawn Vehicle Visible Template B",
"Spawn Vehicle Visible Template C",
"Spawn Vehicle Visible Template D",
"Spawn Vehicle Visible Template E",
"Spawn Vehicle Visible Template F",
"Spawn Vehicle Visible Template G",
"Spawn Vehicle Visible Template H",
"Spawn Vehicle Visible Template I",
"Spawn Vehicle Visible Template J"
}
-- Spawn_Vehicle_Visible_RandomizeTemplate_Scheduled creates an array of 40 vehicle groups, spread out by 20 groups each, with an 8 meter distance,
-- and chooses for each group from the templates specified in Spawn_Templates_Visible.
Spawn_Vehicle_Visible_RandomizeTemplate_Scheduled = SPAWN:New( "Spawn Vehicle Visible RandomizeTemplate Scheduled" )
:Limit( 80, 80 )
:RandomizeTemplate( Spawn_Templates_Visible )
:Array( 49, 20, 8, 8 )
:SpawnScheduled( 10, 0.2 )
-- Spawn_Infantry allows to spawn 10 Infantry groups.
Spawn_Infantry = SPAWN:New( "Spawn Infantry" )
:Limit( 10, 10 )
-- Spawn_Vehicle_Host reserves 10 vehicle groups, shown within an array arranged by 5 vehicles in a row with a distance of 8 meters, and schedules a vehicle each 10 seconds with a 20% variation.
Spawn_Vehicle_Host = SPAWN:New( "Spawn Vehicle Host" )
:Limit( 10, 10 )
:Array( 0, 5, 8, 8 )
:SpawnScheduled( 10, 0.2 )
-- Spawn_Vehicle_SpawnToZone allows to spawn 10 vehicle groups.
Spawn_Vehicle_SpawnToZone = SPAWN:New( "Spawn Vehicle SpawnToZone" )
:Limit( 10, 10 )
-- Spawn_Helicopter_SpawnToZone will fly to a location, hover, and spawn one vehicle on the ground, the helicopter will land
-- and the vehicle will drive to a random location within the defined zone.
-- For this, the following code is activated within the mission on waypoint 3:
--
-- local InfantryDropGroup = Spawn_Vehicle_SpawnToZone:SpawnFromUnit( GROUP:New( ... ):GetUnit(1) )
-- local InfantryDropRoute = InfantryDropGroup:CopyRoute( 1, 0 )
-- InfantryDropGroup:RouteToZone( ZONE:New( "Target Zone" ), true, 80 )
--
Spawn_Helicopter_SpawnToZone = SPAWN:New( "Spawn Helicopter SpawnToZone" )
:Limit( 10, 10 )
:SpawnScheduled( 60, 0.2 )