Next step of folder restructure

This commit is contained in:
kaltokri
2024-01-01 22:41:16 +01:00
parent 5aa1e1a63a
commit 286d2ed571
288 changed files with 6049 additions and 6049 deletions

View File

@@ -0,0 +1,40 @@
---
-- Name: EVT-001 - API Demo 1
-- Author: FlightControl
-- Date Created: 7 February 2017
--
-- # Situation:
--
-- A task shoots another tank. If one of the is dead, the event will be catched.
--
-- # Test cases:
--
-- 1. Observe the tanks shooting each other.
-- 2. If one of the tanks die, an event will be catched.
-- 3. Observe the surviving unit smoking.
local Tank1 = UNIT:FindByName( "Tank A" )
local Tank2 = UNIT:FindByName( "Tank B" )
Tank1:HandleEvent( EVENTS.Dead )
Tank2:HandleEvent( EVENTS.Dead )
--- @param Wrapper.Unit#UNIT self
function Tank1:OnEventDead( EventData )
self:SmokeGreen()
end
--- @param Wrapper.Unit#UNIT self
function Tank2:OnEventDead( EventData )
self:SmokeBlue()
end
function Tank2:OnEventCrash(EventData)
end

View File

@@ -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" )

View File

@@ -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" )

View File

@@ -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" )

View File

@@ -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" )

View File

@@ -0,0 +1,25 @@
---
-- Name: EVT-100 - UNIT OnEventShot Example
-- Author: FlightControl
-- Date Created: 7 Feb 2017
--
-- # Situation:
--
-- A plane is flying in the air and shoots an missile to a ground target.
--
-- # Test cases:
--
-- 1. Observe the plane shooting the missile.
-- 2. Observe when the plane shoots the missile, a dcs.log entry is written in the logging.
-- 3. Check the contents of the fields of the S_EVENT_SHOT entry.
Plane = UNIT:FindByName( "Plane" )
Plane:HandleEvent( EVENTS.Shot )
function Plane:OnEventShot( EventData )
Plane:MessageToAll( "I just fired a missile!", 15, "Alert!" )
end

View File

@@ -0,0 +1,32 @@
---
-- Name: EVT-101 - UNIT OnEventHit Example
-- Author: FlightControl
-- Date Created: 7 Feb 2017
--
-- # Situation:
--
-- A plane is flying in the air and shoots an missile to a ground target.
--
-- # Test cases:
--
-- 1. Observe the plane shooting the missile.
-- 2. Observe when the missile hits the target, a dcs.log entry is written in the logging.
-- 3. Check the contents of the fields of the S_EVENT_HIT entry.
Plane = UNIT:FindByName( "Plane" )
Tank = UNIT:FindByName( "Tank" )
Plane:HandleEvent( EVENTS.Hit )
Tank:HandleEvent( EVENTS.Hit )
function Plane:OnEventHit( EventData )
Plane:MessageToAll( "I just got hit!", 15, "Alert!" )
end
function Tank:OnEventHit( EventData )
Tank:MessageToAll( "I just got hit!", 15, "Alert!" )
end

View File

@@ -0,0 +1,33 @@
---
-- Name: EVT-102 - UNIT OnEventTakeoff Example
-- Author: FlightControl
-- Date Created: 7 Feb 2017
--
-- # Situation:
--
-- A human plane and an AI plane are taking off from an airfield.
--
-- # Test cases:
--
-- 1. Take-Off the planes from the runway.
-- 2. When the planes take-off, observe the message being sent.
-- 3. Check the contents of the fields of the S_EVENT_TAKEOFF entry in the dcs.log file.
PlaneAI = UNIT:FindByName( "PlaneAI" )
PlaneHuman = UNIT:FindByName( "PlaneHuman" )
PlaneAI:HandleEvent( EVENTS.Takeoff )
PlaneHuman:HandleEvent( EVENTS.Takeoff )
function PlaneAI:OnEventTakeoff( EventData )
PlaneHuman:MessageToAll( "AI Taking Off", 15, "Alert!" )
end
function PlaneHuman:OnEventTakeoff( EventData )
PlaneHuman:MessageToAll( "Player " .. PlaneHuman:GetPlayerName() .. " is Taking Off", 15, "Alert!" )
end

View File

@@ -0,0 +1,38 @@
---
-- Name: EVT-103 - UNIT OnEventLand Example
-- Author: FlightControl
-- Date Created: 7 Feb 2017
--
-- # Situation:
--
-- An AI plane is landing on an airfield.
-- When the plane landed, a new plane is spawned.
--
-- # Test cases:
--
-- 1. Observe the plane landing.
-- 2. When the AI plane lands, observe the new plane being spawned.
-- 3. Check the contents of the fields of the S_EVENT_LAND entry in the dcs.log file.
-- Create a variable PlaneAI that holds a reference to UNIT object (created by moose at the beginning of the mission) with the name "PlaneAI".
PlaneAI = UNIT:FindByName( "PlaneAI" )
-- Create a SPAWN object to spawn a new plane once the hold one lands.
SpawnPlane = SPAWN:New( "SpawnPlaneAI" )
-- Declare a new variable that will hold the new spawned SpawnPlaneAI
local NewPlane
-- Subscribe to the event Land. The Land event occurs when a plane lands at an airfield.
PlaneAI:HandleEvent( EVENTS.Land )
-- Because the PlaneAI object is subscribed to the Land event, the following method will be automatically
-- called when the land event is happening FOR THE PlaneAI UNIT only!
function PlaneAI:OnEventLand( EventData )
-- Okay, the PlaneAI has landed, now spawn the new plane ( a predator )
NewPlane = SpawnPlane:Spawn()
end

View File

@@ -0,0 +1,35 @@
---
-- Name: EVT-104 - UNIT OnEventCrash Example
-- Author: FlightControl
-- Date Created: 7 Feb 2017
--
-- # Situation:
--
-- A human plane is fyling in the air. Crash it into the ground.
-- Once you are crashed into the ground, at the place where you crashed, a smoke should start burning ...
--
-- # Test cases:
--
-- 1. Fly the plane into the ground.
-- 2. When your plane crashes, observe a smoke starting to burn right were you crashed.
-- 3. Check the contents of the fields of the S_EVENT_CRASH entry in the dcs.log file.
-- Create a variable PlaneHuman that holds a reference to UNIT object (created by moose at the beginning of the mission) with the name "PlaneHuman".
PlaneHuman = UNIT:FindByName( "PlaneHuman" )
-- Subscribe to the event Crash. The Crash event occurs when a plane crashes into the ground (or into something else).
PlaneHuman:HandleEvent( EVENTS.Crash )
-- Because the PlaneHuman object is subscribed to the Crash event, the following method will be automatically
-- called when the Crash event is happening FOR THE PlaneHuman UNIT only!
--- @param self
-- @param Core.Event#EVENTDATA EventData
function PlaneHuman:OnEventCrash( EventData )
-- Okay, the PlaneHuman has crashed, now smoke at the x, z position.
self:E( "Smoking at the position" )
EventData.IniUnit:SmokeOrange()
end

View File

@@ -0,0 +1,107 @@
---
-- Name: EVT-105 - UNIT OnEventPlayerEnterUnit Example
-- Author: FlightControl
-- Date Created: 15 Dec 2017
--
-- 2 planes and 2 tanks are located on and near the airport.
-- The test is about checking if S_EVENT_PLAYER_ENTER_UNIT is correctly working in DCS single player and multi player.
-- The test requires you to jump into the 2 planes and into the 2 tanks using CA.
-- Please execute the following scenarios in Single and Multi-Player:
--
-- 1. Test in Single Player:
--
-- First we need to get the mission running... To do this, do the following actions:
-- - At mission startup, once you get the slots, press the ESC key... The slot selection window will disappear.
-- - Then press the ESC key again, and in the window, select the menu option "Select Slot".
--
-- Next, we select the 2 planes...
-- - Select Plane 1 slot. Go to external view. Once you are in the SU-25T, an orange smoke and a message should appear.
-- - Select Plane 2 slot. Go to external view. Once you are in the SU-25T, a red smoke and a message should appear.
--
-- Next, we select the 2 tanks... Select the MAP view using F10, and:
-- - Select the Tank 1 unit using the arrow. And then press RALT-J which should jump you into Tank 1. Go to external view. Once you are in the Tank, a blue smoke and a message should appear.
-- - Select the Tank 2 unit using the arrow. And then press RALT-J which should jump you into Tank 2. Go to external view. Once you are in the Tank, a green smoke and a message should appear.
--
--
-- 2. Test in Multi Player:
--
-- Run the mission on a server, and connect to the mission with a client...
--
-- On the client machine, we select the 2 planes...
-- - Select Plane 1 slot. Go to external view. Once you are in the SU-25T, an orange smoke and a message should appear.
-- - Select Plane 2 slot. Go to external view. Once you are in the SU-25T, a red smoke and a message should appear.
--
-- On the client machine, we select the 2 tanks... Select the MAP view using F10, and:
-- - Select the Tank 1 unit using the arrow. And then press RALT-J which should jump you into Tank 1. Go to external view. Once you are in the Tank, a blue smoke and a message should appear.
-- - Select the Tank 2 unit using the arrow. And then press RALT-J which should jump you into Tank 2. Go to external view. Once you are in the Tank, a green smoke and a message should appear.
--
--
-- If all of this is working correctly, then the fix is correctly patched!
-- Create a variable PlaneHuman that holds a reference to UNIT object (created by moose at the beginning of the mission) with the name "Plane x".
Plane1 = CLIENT:FindByName( "Plane 1" )
Plane2 = CLIENT:FindByName( "Plane 2" )
-- Subscribe to the event. The event occurs when a player enters a slot.
Plane1:HandleEvent( EVENTS.PlayerEnterUnit )
Plane2:HandleEvent( EVENTS.PlayerEnterUnit )
-- Because the Plane object is subscribed to the PlayerEnterUnit event, the following method will be automatically
-- called when the event is happening!
--- @param self
-- @param Core.Event#EVENTDATA EventData
function Plane1:OnEventPlayerEnterUnit( EventData )
-- Okay, the Human has entered the unit, now smoke at the x, z position.
EventData.IniUnit:SmokeOrange()
MESSAGE:NewType( "A human has entered Plane 1", MESSAGE.Type.Information ):ToAll()
end
--- @param self
-- @param Core.Event#EVENTDATA EventData
function Plane2:OnEventPlayerEnterUnit( EventData )
-- Okay, the Human has entered the unit, now smoke at the x, z position.
EventData.IniUnit:SmokeRed()
MESSAGE:NewType( "A human has entered Plane 2", MESSAGE.Type.Information ):ToAll()
end
--- Now for the ground units
Tank1 = UNIT:FindByName( "Tank 1" )
Tank2 = UNIT:FindByName( "Tank 2" )
-- Subscribe to the event. The event occurs when a player enters a slot.
Tank1:HandleEvent( EVENTS.PlayerEnterUnit )
Tank2:HandleEvent( EVENTS.PlayerEnterUnit )
-- Because the Tank object is subscribed to the PlayerEnterUnit event, the following method will be automatically
-- called when the event is happening!
--- @param self
-- @param Core.Event#EVENTDATA EventData
function Tank1:OnEventPlayerEnterUnit( EventData )
-- Okay, the Human has entered the unit, now smoke at the x, z position.
EventData.IniUnit:SmokeBlue()
MESSAGE:NewType( "A human has entered Tank 1", MESSAGE.Type.Information ):ToAll()
end
--- @param self
-- @param Core.Event#EVENTDATA EventData
function Tank2:OnEventPlayerEnterUnit( EventData )
-- Okay, the Human has entered the unit, now smoke at the x, z position.
EventData.IniUnit:SmokeGreen()
MESSAGE:NewType( "A human has entered Tank 2", MESSAGE.Type.Information ):ToAll()
end

View File

@@ -0,0 +1,28 @@
---
-- Name: EVT-200 - GROUP OnEventShot Example
-- Author: FlightControl
-- Date Created: 07 Mar 2017
--
-- # Situation:
--
-- Two groups of planes are flying in the air and shoot an missile to a multitude of ground targets.
--
-- # Test cases:
--
-- 1. Observe the planes shooting the missile.
-- 2. Observe when the planes shoots the missile, a dcs.log entry is written in the logging.
-- 3. Check the contents of the fields of the S_EVENT_SHOT entry.
-- 4. The planes of GROUP "Group Plane A", should only send a message when they shoot a missile.
-- 5. The planes of GROUP "Group Plane B", should NOT send a message when they shoot a missile.
PlaneGroup = GROUP:FindByName( "Group Plane A" )
PlaneGroup:HandleEvent( EVENTS.Shot )
function PlaneGroup:OnEventShot( EventData )
self:E( "I just fired a missile and I am part of " .. EventData.IniGroupName )
EventData.IniUnit:MessageToAll( "I just fired a missile and I am part of " .. EventData.IniGroupName, 15, "Alert!" )
end

View File

@@ -0,0 +1,28 @@
---
-- Name: EVT-201 - GROUP OnEventHit Example
-- Author: FlightControl
-- Date Created: 08 Mar 2017
--
-- # Situation:
--
-- Two groups of planes are flying in the air and shoot an missile to a multitude of ground targets.
--
-- # Test cases:
--
-- 1. Observe the planes shooting the missile.
-- 2. Observe when the planes shoots the missile, and hit the group Tanks A, a dcs.log entry is written in the logging.
-- 3. Check the contents of the fields of the S_EVENT_HIT entry.
-- 4. The tanks of GROUP "Group Tanks A", should only send a message when they get hit.
-- 5. The tanks of GROUP "Group Tanks B", should NOT send a message when they get hit.
TanksGroup = GROUP:FindByName( "Group Tanks A" )
TanksGroup:HandleEvent( EVENTS.Hit )
function TanksGroup:OnEventHit( EventData )
self:E( "I just got hit and I am part of " .. EventData.TgtGroupName )
EventData.TgtUnit:MessageToAll( "I just got hit and I am part of " .. EventData.TgtGroupName, 15, "Alert!" )
end

View File

@@ -0,0 +1,28 @@
---
-- Name: EVT-201 - GROUP OnEventHit Example
-- Author: FlightControl
-- Date Created: 08 Mar 2017
--
-- # Situation:
--
-- Two groups of planes are flying in the air and shoot an missile to a multitude of ground targets.
--
-- # Test cases:
--
-- 1. Observe the planes shooting the missile.
-- 2. Observe when the planes shoots the missile, and hit the group Tanks A, a dcs.log entry is written in the logging.
-- 3. Check the contents of the fields of the S_EVENT_HIT entry.
-- 4. The tanks of GROUP "Group Tanks A", should only send a message when they get hit.
-- 5. The tanks of GROUP "Group Tanks B", should NOT send a message when they get hit.
TanksGroup = GROUP:FindByName( "Group Tanks A" )
TanksGroup:HandleEvent( EVENTS.Hit )
function TanksGroup:OnEventHit( EventData )
self:E( "I just got hit and I am part of " .. EventData.TgtGroupName )
EventData.TgtUnit:MessageToAll( "I just got hit and I am part of " .. EventData.TgtGroupName, 15, "Alert!" )
end

View File

@@ -0,0 +1,34 @@
---
-- Name: EVT-204 - GROUP OnEventCrash Example
-- Author: FlightControl
-- Date Created: 29 May 2017
--
-- # Situation:
--
-- A human plane is fyling in the air. Crash it into the ground.
-- Once you are crashed into the ground, at the place where you crashed, a smoke should start burning ...
--
-- # Test cases:
--
-- 1. Fly the plane into the ground.
-- 2. When your plane crashes, observe a smoke starting to burn right were you crashed.
-- 3. Check the contents of the fields of the S_EVENT_CRASH entry in the dcs.log file.
-- Create a variable PlaneHuman that holds a reference to UNIT object (created by moose at the beginning of the mission) with the name "PlaneHuman".
PlaneHumanGroup = GROUP:FindByName( "PlaneGroup" )
-- Subscribe to the event Crash. The Crash event occurs when a plane crashes into the ground (or into something else).
PlaneHumanGroup:HandleEvent( EVENTS.Crash )
-- Because the PlaneHuman object is subscribed to the Crash event, the following method will be automatically
-- called when the Crash event is happening FOR THE PlaneHuman UNIT only!
--- @param self
-- @param Core.Event#EVENTDATA EventData
function PlaneHumanGroup:OnEventCrash( EventData )
-- Okay, the PlaneHuman has crashed, now smoke at the x, z position.
self:E( "Smoking at the position" )
EventData.IniUnit:SmokeOrange()
end

View File

@@ -0,0 +1,28 @@
---
-- Name: EVT-205 - GROUP OnEventDead Example
-- Author: FlightControl
-- Date Created: 29 May 2017
--
-- # Situation:
--
-- Two groups of planes are flying in the air and shoot an missile to a multitude of ground targets.
--
-- # Test cases:
--
-- 1. Observe the planes shooting the missile.
-- 2. Observe when the planes shoots the missile, and hit the group Tanks A, a dcs.log entry is written in the logging.
-- 3. Check the contents of the fields of the S_EVENT_HIT entry.
-- 4. The tanks of GROUP "Group Tanks A", should only send a message when they get hit.
-- 5. The tanks of GROUP "Group Tanks B", should NOT send a message when they get hit.
TanksGroup = GROUP:FindByName( "Group Tanks A" )
TanksGroup:HandleEvent( EVENTS.Dead )
function TanksGroup:OnEventDead( EventData )
self:E( "I just got dead and I am part of " .. EventData.IniGroupName )
EventData.IniUnit:MessageToAll( "I just got dead and I am part of " .. EventData.IniGroupName, 15, "Alert!" )
end

View File

@@ -0,0 +1,34 @@
---
-- Name: EVT-401 - Generic OnEventHit Example
-- Author: FlightControl
-- Date Created: 15 February 2017
--
-- # Situation:
--
-- Ground targets are shooting each other.
--
-- # Test cases:
--
-- 1. Observe the ground forces shooting each other.
-- 2. Observe when a tank receives a hit, a dcs.log entry is written in the logging.
-- 3. The generic EventHandler objects should receive the hit events.
CC = COMMANDCENTER:New( UNIT:FindByName( "HQ" ), "HQ" )
EventHandler1 = EVENTHANDLER:New()
EventHandler2 = EVENTHANDLER:New()
EventHandler1:HandleEvent( EVENTS.Hit )
EventHandler2:HandleEvent( EVENTS.Hit )
function EventHandler1:OnEventHit( EventData )
self:E("hello 1")
CC:GetPositionable():MessageToAll( "I just got hit!", 15 , "Alert!" )
end
function EventHandler2:OnEventHit( EventData )
self:E("hello 2")
CC:GetPositionable():MessageToAll( "I just got hit!", 15, "Alert!" )
end

View File

@@ -0,0 +1,26 @@
---
-- Name: EVT-402 - Generic OnEventMissionEnd Example
-- Author: FlightControl
-- Date Created: 12 Apr 2017
--
-- # Situation:
--
-- Test mission end event handler.
--
-- # Test cases:
--
-- 1. Observe when the mission ends, a dcs.log entry is written in the logging.
-- 2. The generic EventHandler objects should be called, and a log entry in dcs.log should be written.
CC = COMMANDCENTER:New( UNIT:FindByName( "HQ" ), "HQ" )
EventHandler = EVENTHANDLER:New()
EventHandler:HandleEvent( EVENTS.MissionEnd )
function EventHandler:OnEventMissionEnd( EventData )
self:E("Mission End")
end

View File

@@ -0,0 +1,32 @@
---
-- Name: EVT-401 - Generic OnEventHit Example
-- Author: FlightControl
-- Date Created: 15 February 2017
--
-- # Situation:
--
-- Ground targets are shooting each other.
--
-- # Test cases:
--
-- 1. Observe the ground forces shooting each other.
-- 2. Observe when a tank receives a hit, a dcs.log entry is written in the logging.
-- 3. The generic EventHandler objects should receive the hit events.
CC = COMMANDCENTER:New( GROUP:FindByName( "HQ" ), "HQ" )
EventHandler1 = EVENTHANDLER:New()
EventHandler1:HandleEvent( EVENTS.Birth )
--- @param Core.Event#EVENT self
-- @param Core.Event#EVENTDATA EventData
function EventHandler1:OnEventBirth( EventData )
self:E("hello 1")
self:E( EventData.IniUnit:GetName() )
CC:GetPositionable():MessageToAll( "I just got born!", 15 , "Alert!" )
end

View File

@@ -0,0 +1,63 @@
---
-- Name: EVT-103 - OnEventLand Example
-- Author: CraigOwen
-- Date Created: 12 February 2017
--
-- # Situation:
--
-- A client plane is landing on an airfield, trying to pick a rope in the landing zones.
-- When the plane landed in one of the zones, a vehicle flares and a message ist printed out to the client.
--
-- # Test cases:
--
-- 1. Land the plane.
-- 2. When the plane landed, observe your message and the signal.
-- 3. Check the contents of the fields of the S_EVENT_LAND entry in the dcs.log file.
-- Create a unit which signalizes if the client landed good.
signal = UNIT:FindByName("LandingZoneChallenge - Signal")
-- Create the zones used for the landing check
-- Init Zone
InitZone = ZONE:New("LandingChallange - InitZone")
-- Ropes
zonegroup1 = GROUP:FindByName("LandingZoneChallenge - RopeGroup 1" )
zonegroup2 = GROUP:FindByName("LandingZoneChallenge - RopeGroup 2" )
zonegroup3 = GROUP:FindByName("LandingZoneChallenge - RopeGroup 3" )
LandZoneRope1 = ZONE_POLYGON:New( "Rope1", zonegroup1)
LandZoneRope2 = ZONE_POLYGON:New( "Rope2", zonegroup2)
LandZoneRope3 = ZONE_POLYGON:New( "Rope3", zonegroup3)
-- Create a variable Plane that holds a reference to CLIENT object (created by moose at the beginning of the mission) with the name "Plane".
Plane = CLIENT:FindByName( "Plane" )
-- Subscribe to the event Land. The Land event occurs when a plane lands at an airfield.
Plane:HandleEvent( EVENTS.Land )
-- This function will be called whenever the Plane-Object (client) lands!
function Plane:OnEventLand( EventData )
-- check wether the client landet at the right airport, where the challenge is located
if not Plane:IsInZone(InitZone) then
return
end
-- check if the touchdown took place inside of one of the zones
if Plane:IsInZone(LandZoneRope1) then
MESSAGE:New("Great job! You picked the first rope.", 15, "Landing challenge" ):ToClient( Plane )
signal:FlareGreen()
elseif Plane:IsInZone(LandZoneRope2) then
MESSAGE:New("Good job! You picked the second rope.", 15, "Landing challenge" ):ToClient( Plane )
signal:FlareYellow()
elseif Plane:IsInZone(LandZoneRope3) then
MESSAGE:New("Close! You picked the last rope.", 15, "Landing challenge" ):ToClient( Plane )
signal:FlareRed()
else
MESSAGE:New("Too bad, no rope picked! Thrust your engines and try again.", 15, "Landing challenge" ):ToClient( Plane )
end
end
MESSAGE:New("Try to land on the runway in between the red trucks.", 15, "Landing challenge"):ToClient(Plane)

View File

@@ -0,0 +1,63 @@
---
-- Name: EVT-103 - OnEventLand Example
-- Author: CraigOwen
-- Date Created: 12 February 2017
--
-- # Situation:
--
-- A client plane is landing on an airfield, trying to pick a rope in the landing zones.
-- When the plane landed in one of the zones, a vehicle flares and a message ist printed out to the client.
--
-- # Test cases:
--
-- 1. Land the plane.
-- 2. When the plane landed, observe your message and the signal.
-- 3. Check the contents of the fields of the S_EVENT_LAND entry in the dcs.log file.
-- Create a unit which signalizes if the client landed good.
signal = UNIT:FindByName("LandingZoneChallenge - Signal")
-- Create the zones used for the landing check
-- Init Zone
InitZone = ZONE:New("LandingChallange - InitZone")
-- Ropes
zonegroup1 = GROUP:FindByName("LandingZoneChallenge - RopeGroup 1" )
zonegroup2 = GROUP:FindByName("LandingZoneChallenge - RopeGroup 2" )
zonegroup3 = GROUP:FindByName("LandingZoneChallenge - RopeGroup 3" )
LandZoneRope1 = ZONE_POLYGON:New( "Rope1", zonegroup1)
LandZoneRope2 = ZONE_POLYGON:New( "Rope2", zonegroup2)
LandZoneRope3 = ZONE_POLYGON:New( "Rope3", zonegroup3)
-- Create a variable Plane that holds a reference to CLIENT object (created by moose at the beginning of the mission) with the name "Plane".
Plane = CLIENT:FindByName( "Plane" )
-- Subscribe to the event Land. The Land event occurs when a plane lands at an airfield.
Plane:HandleEvent( EVENTS.Land )
-- This function will be called whenever the Plane-Object (client) lands!
function Plane:OnEventLand( EventData )
-- check wether the client landet at the right airport, where the challenge is located
if not Plane:IsInZone(InitZone) then
return
end
-- check if the touchdown took place inside of one of the zones
if Plane:IsInZone(LandZoneRope1) then
MESSAGE:New("Great job! You picked the first rope.", 15, "Landing challenge" ):ToClient( Plane )
signal:FlareGreen()
elseif Plane:IsInZone(LandZoneRope2) then
MESSAGE:New("Good job! You picked the second rope.", 15, "Landing challenge" ):ToClient( Plane )
signal:FlareYellow()
elseif Plane:IsInZone(LandZoneRope3) then
MESSAGE:New("Close! You picked the last rope.", 15, "Landing challenge" ):ToClient( Plane )
signal:FlareRed()
else
MESSAGE:New("Too bad, no rope picked! Thrust your engines and try again.", 15, "Landing challenge" ):ToClient( Plane )
end
end
MESSAGE:New("Try to land on the runway in between the red trucks.", 15, "Landing challenge"):ToClient(Plane)

View File

@@ -0,0 +1,151 @@
---
-- Name: EVT-103 - OnEventLand LandingChallengeComplex
-- Author: CraigOwen
-- Date Created: 12 February 2017
--
-- # Situation:
--
-- Approaching the airfield the client gets a message and can try to land inside the landing zones.
-- Here we want all clients to participate in the challenge, not only one.
-- When the plane landed in one of the zones, a vehicle flares and a message ist printed out to the client.
--
-- # Test cases:
--
-- 1. Land one of the planes.
-- 2. While landing the plane, observe your message and the signal (flare).
-- 3. Check the contents of the fields of the S_EVENT_LAND entry in the dcs.log file.
-- In this advanced challenge we want to make sure all the following.
-- 1. The challenge takes place at a certain airfield.
-- 2. All clients can repeat the challange at any time, try after try.
-- 3. All clients approaching the airport get a message indicating the challenge.
-- 4. There is no useraction needet to participate in this, providing full focus on the task.
-- So lets go then... in five steps
-- 1. Create a unit to signalize (flare) whenever a client landed correctly
-- 2. Create Zones
-- 3. Create a set of clients
-- 4. Handle the EVENT.Land for all clients in the set using the signal unit
-- 5. Create a scheduler checking for clients in zones
-- 1. Create a unit which signalizes if the client landed good.
signal = UNIT:FindByName("LandingZoneChallenge - Signal")
-- 2. Create Zones
-- Init Zone - This is the global Zone for the LandingChallenge
InitZone = ZONE:New("LandingChallange - InitZone")
--Ingress Zone - This Zone tries to asure the client approaches the runway from the right side
IngressZoneTemplate = GROUP:FindByName( "LandingZoneChallenge - IngressZone" )
IngressZone = ZONE_POLYGON:New( "IngressZone", IngressZoneTemplate )
-- Ropes - theese zones will simulate the ropes on a carrier.
zonegroup1 = GROUP:FindByName("LandingZoneChallenge - Rope 1" )
zonegroup2 = GROUP:FindByName("LandingZoneChallenge - Rope 2" )
zonegroup3 = GROUP:FindByName("LandingZoneChallenge - Rope 3" )
LandZoneRope1 = ZONE_POLYGON:New( "Rope1", zonegroup1)
LandZoneRope2 = ZONE_POLYGON:New( "Rope2", zonegroup2)
LandZoneRope3 = ZONE_POLYGON:New( "Rope3", zonegroup3)
-- 3. Create a set of clients
-- In this example we do not want to handle the event for one specific client, but rather for all red plane clients.
-- To achieve this, we start with filtering the clients and saving those into the "BlueClients" variable
RedClients = SET_CLIENT:New():FilterCoalitions("red"):FilterStart()
-- 4. We want to let every client subscribe to the event EVENT.Land. This event occurs when a plane lands. Be aware that this could be any airfield at this point.
-- To do so, we run the ForEachClient method on our set of clients and call a function taking the client as parameter
RedClients:ForEachClient(
--- This function will be called for every single client in the set
-- @param MooseClient#CLIENT ClientInSet
function( ClientInSet )
-- Inside here we want to do two things.
-- 1. Write down the local function doing all the magic.
-- 2. Call this function for each ClientInSet
-- 1. The magic
local function ResetClientForZone( MooseClient )
--At first we set this client to a state, in wich she/he is not participating in this event
MooseClient:SetState( MooseClient, "ZoneStep", "0" )
--Now we subscribe to the event just like we did in the first example.
MooseClient:HandleEvent(EVENTS.Land)
--- Finally we set up the so called handler FOR the event. This is a function wich will determine what happens, whenever a client lands.
-- Note here, that the function has the MooseClient in front. So this function will literaly get a part of the client itself.
-- Therefore we can refere to "self" inside the function whenever meaning the MooseClient
-- The param EventData is a parameter given to all event handlers and providing several data about this particular event.
-- @param Core.Event#EVENTDATA EventData
function MooseClient:OnEventLand( EventData )
-- Ok now the client "MooseClient" definetly has landed. And beeing here means being the client. MooseClient <-> self
-- So now i want to know 2 things, to verify that i have done everything right.
-- 1. I want to know if my(self) landed in the challengeZone, so landing in other places will not react to this challenge
-- 2. Furthermore i want to know if my(self) came from the right side.
-- In all other cases nothing shell happen, so we reset the client state here and return doin nothing else.
if not self:IsInZone(InitZone) or self:GetState( self, "ZoneStep" ) ~= "2" then
self:SetState( self, "ZoneStep", "0" )
return
end
-- Here we check wich rope was picked and set the signal and message according to it.
if self:IsInZone(LandZoneRope1) then
MESSAGE:New("Great job! You picked the first rope.", 15, "Landing challenge" ):ToClient( self )
signal:FlareGreen()
elseif self:IsInZone(LandZoneRope2) then
MESSAGE:New("Good job! You picked the second rope.", 15, "Landing challenge" ):ToClient( self )
signal:FlareYellow()
elseif self:IsInZone(LandZoneRope3) then
MESSAGE:New("Close! You picked the last rope.", 15, "Landing challenge" ):ToClient( self )
signal:FlareRed()
else
MESSAGE:New("Too bad, no rope picked! Thrust your engines and try again.", 15, "Landing challenge" ):ToClient( self )
end
-- Finally we set the client back to step 1, allowing a new message for landing
self:SetState( self, "ZoneStep", "1" )
end
end
-- 2. As we're now all set, we can finally call our function for every ClientInSet
ClientInSet:Alive( ResetClientForZone )
end
)
-- 5. Finally we use a scheduler checking wether clients are inside or outside these zones.
LandingChallangeActionsScheduler, LandingChallangeActionsSchedulerID = SCHEDULER:New( nil,
function ()
-- Flying by the airport there will be a message showing that the landing challange is currently in place.
-- This will make the ClientState shift from 0 -> 1
RedClients:ForEachClientInZone( InitZone,
function( MooseClient )
BASE:E( { Client = MooseClient, State = MooseClient:GetState( MooseClient, "ZoneStep" ) } )
if MooseClient:IsAlive() and MooseClient:GetState( MooseClient, "ZoneStep" ) == "0" then
MooseClient:SetState( MooseClient, "ZoneStep", "1" )
MESSAGE:New("Welcome to the Landing challenge. If you want to participate, get yourself a landing clearance by ATC and navigate to the landing corridor.", 20, "Landing challenge" ):ToClient( MooseClient )
end
end
)
-- The client is approaching the runway from the correct side?
-- If yes, then shift state from 1 to 2
RedClients:ForEachClientInZone( IngressZone,
function( MooseClient )
BASE:E( { Client = MooseClient, State = MooseClient:GetState( MooseClient, "ZoneStep" ) } )
if MooseClient:IsAlive() and MooseClient:GetState( MooseClient, "ZoneStep" ) == "1" then
MooseClient:SetState( MooseClient, "ZoneStep", "2" )
MESSAGE:New("Ok, now its your turn. Land your airframe and try to get one of the ropes. Good luck!", 15, "Landing challenge" ):ToClient( MooseClient )
end
end
)
end, {}, 5, 5
)
MESSAGE:New("Try to land on the runway in between the red trucks located at the right side.", 15, "Landing challenge"):ToAll()

View File

@@ -0,0 +1,29 @@
---
-- Name: EVT-600 - OnEventHit Example with a Set of Units
-- Author: FlightControl
-- Date Created: 6 Mar 2017
--
-- # Situation:
--
-- A plane is flying in the air and shoots an missile to a ground target.
-- It will shoot a couple of tanks units that are part of a Set.
--
-- # Test cases:
--
-- 1. Observe the plane shooting the missile.
-- 2. Observe when the plane hits a tank, a dcs.log entry is written in the logging.
-- 4. Observe the tanks hitting the targets and the messages appear.
-- 3. Check the contents of the fields of the S_EVENT_HIT entries.
Plane = UNIT:FindByName( "Plane" )
UnitSet = SET_UNIT:New():FilterPrefixes( "Tank" ):FilterStart()
UnitSet:HandleEvent( EVENTS.Hit )
function UnitSet:OnEventHit( EventData )
Plane:MessageToAll( "I just hit a tank! " .. EventData.IniUnit:GetName(), 15, "Alert!" )
end