Fixed AI_CAS_ZONE

-- Added separate detection loop during engagement
-- Detection during patrolling is off.
-- Engage now has several parameters that specify how to engage within
the zone.
-- Created several additional test missions, more to come.
This commit is contained in:
FlightControl
2017-02-06 14:58:19 +01:00
parent 9f63184a5e
commit 93e7fab116
94 changed files with 814 additions and 169 deletions

View File

@@ -1,11 +1,26 @@
-- Name: CAS in a ZONE
---
-- Name: CAS-001 - CAS in a Zone by Airplane Group
-- Author: FlightControl
-- Date Created: 13 January 2017
--
-- # Situation:
--
-- A group of 4 Su-25T at patrolling north of an engage zone for 10 minutes.
-- After 10 minutes, the command center orders the Su-25T to engage the zone and execute a CAS.
--
-- # Test cases:
--
-- 1. Observe that the Su-25T is patrolling in the patrol zone, until the engage command is given.
-- 2. The Su-25T are not detecting any target during the patrol.
-- 3. When the Su-25T is commanded to engage, the group will fly to the engage zone.
-- 4. Detection is activated and detected targets within the engage zone are assigned for CAS.
-- 5. Observe the Su-25T eliminating the targets.
-- 6. Observe the Su-25T defenses.
-- 7. When all targets within the engage zone are destroyed, the Su-25T CAS task is set to Accomplished.
-- 8. The Su-25T will return to base.
-- Create a local variable (in this case called CASEngagementZone) and
-- using the ZONE function find the pre-defined zone called "Engagement Zone"
-- currently on the map and assign it to this variable
@@ -42,18 +57,18 @@ AICasZone:__Engage( 600 )
-- When the trigger completed has been fired, the Plane will go back to the Patrol Zone.
Check, CheckScheduleID = SCHEDULER:New(nil,
function()
BASE:E( { "In Scheduler: ", Targets:GetSize() } )
if Targets:IsAlive() and Targets:GetSize() > 5 then
BASE:E("Still alive")
BASE:E( "Test Mission: " .. Targets:GetSize() .. " targets left to be destroyed.")
else
BASE:E("Destroyed")
BASE:E( "Test Mission: The required targets are destroyed." )
AICasZone:__Accomplish( 1 ) -- Now they should fly back to teh patrolzone and patrol.
Check:Stop(CheckScheduleID)
end
end, {}, 20, 60, 0.2 )
-- When the targets in the zone are destroyed, (see scheduled function), the planes will return home ...
function AICasZone:OnAfterAccomplish( Controllable, From, Event, To )
BASE:E( "Test Mission: Sending the Su-25T back to base." )
Check:Stop( CheckScheduleID )
AICasZone:__RTB( 1 )
end

View File

@@ -0,0 +1,75 @@
---
-- Name: CAS-002 - CAS in a Zone by Airplane Group - Engage with Speed
-- Author: FlightControl
-- Date Created: 06 February 2017
--
-- # Situation:
--
-- A group of 4 Su-25T at patrolling north of an engage zone for 1 minute.
-- After 1 minute, the command center orders the Su-25T to engage the zone and execute a CAS.
--
-- # Test cases:
--
-- 1. Observe that the Su-25T is patrolling in the patrol zone, until the engage command is given.
-- 2. The Su-25T are not detecting any target during the patrol.
-- 3. When the Su-25T is commanded to engage, the group will fly to the engage zone.
-- 3.1. The approach speed to the engage zone is set to 400 km/h.
-- 4. Detection is activated and detected targets within the engage zone are assigned for CAS.
-- 5. Observe the Su-25T eliminating the targets.
-- 6. Observe the Su-25T defenses.
-- 7. When all targets within the engage zone are destroyed, the Su-25T CAS task is set to Accomplished.
-- 8. The Su-25T will return to base.
-- Create a local variable (in this case called CASEngagementZone) and
-- using the ZONE function find the pre-defined zone called "Engagement Zone"
-- currently on the map and assign it to this variable
local CASEngagementZone = ZONE:New( "Engagement Zone" )
-- Create a local variable (in this case called CASPlane) and
-- using the GROUP function find the aircraft group called "Plane" and assign to this variable
local CASPlane = GROUP:FindByName( "Plane" )
-- Create a local Variable (in this cased called PatrolZone and
-- using the ZONE function find the pre-defined zone called "Patrol Zone" and assign it to this variable
local PatrolZone = ZONE:New( "Patrol Zone" )
-- Create and object (in this case called AICasZone) and
-- using the functions AI_CAS_ZONE assign the parameters that define this object
-- (in this case PatrolZone, 500, 1000, 500, 600, CASEngagementZone)
local AICasZone = AI_CAS_ZONE:New( PatrolZone, 500, 1000, 500, 600, CASEngagementZone )
-- Create an object (in this case called Targets) and
-- using the GROUP function find the group labeled "Targets" and assign it to this object
local Targets = GROUP:FindByName("Targets")
-- Tell the program to use the object (in this case called CASPlane) as the group to use in the CAS function
AICasZone:SetControllable( CASPlane )
-- Tell the group CASPlane to start the mission in 1 second.
AICasZone:__Start( 1 ) -- They should statup, and start patrolling in the PatrolZone.
-- After 10 minutes, tell the group CASPlane to engage the targets located in the engagement zone called CASEngagement Zone. (600 is 600 seconds)
AICasZone:__Engage( 60, 400 ) -- Engage after one minute with a speed of 400 km/h.
-- Check every 60 seconds whether the Targets have been eliminated.
-- When the trigger completed has been fired, the Plane will go back to the Patrol Zone.
Check, CheckScheduleID = SCHEDULER:New(nil,
function()
if Targets:IsAlive() and Targets:GetSize() > 5 then
BASE:E( "Test Mission: " .. Targets:GetSize() .. " targets left to be destroyed.")
else
BASE:E( "Test Mission: The required targets are destroyed." )
AICasZone:__Accomplish( 1 ) -- Now they should fly back to teh patrolzone and patrol.
end
end, {}, 20, 60, 0.2 )
-- When the targets in the zone are destroyed, (see scheduled function), the planes will return home ...
function AICasZone:OnAfterAccomplish( Controllable, From, Event, To )
BASE:E( "Test Mission: Sending the Su-25T back to base." )
Check:Stop( CheckScheduleID )
AICasZone:__RTB( 1 )
end

View File

@@ -0,0 +1,76 @@
---
-- Name: CAS-003 - CAS in a Zone by Airplane Group - Engage with Speed and Altitude
-- Author: FlightControl
-- Date Created: 6 February 2017
--
-- # Situation:
--
-- A group of 4 Su-25T at patrolling north of an engage zone for 1 minute.
-- After 1 minute, the command center orders the Su-25T to engage the zone and execute a CAS.
--
-- # Test cases:
--
-- 1. Observe that the Su-25T is patrolling in the patrol zone, until the engage command is given.
-- 2. The Su-25T are not detecting any target during the patrol.
-- 3. When the Su-25T is commanded to engage, the group will fly to the engage zone
-- 3.1. The approach speed to the engage zone is set to 400 km/h.
-- 3.2. The altitude to the engage zone and CAS execution is set to 500 meters.
-- 4. Detection is activated and detected targets within the engage zone are assigned for CAS.
-- 5. Observe the Su-25T eliminating the targets.
-- 6. Observe the Su-25T defenses.
-- 7. When all targets within the engage zone are destroyed, the Su-25T CAS task is set to Accomplished.
-- 8. The Su-25T will return to base.
-- Create a local variable (in this case called CASEngagementZone) and
-- using the ZONE function find the pre-defined zone called "Engagement Zone"
-- currently on the map and assign it to this variable
local CASEngagementZone = ZONE:New( "Engagement Zone" )
-- Create a local variable (in this case called CASPlane) and
-- using the GROUP function find the aircraft group called "Plane" and assign to this variable
local CASPlane = GROUP:FindByName( "Plane" )
-- Create a local Variable (in this cased called PatrolZone and
-- using the ZONE function find the pre-defined zone called "Patrol Zone" and assign it to this variable
local PatrolZone = ZONE:New( "Patrol Zone" )
-- Create and object (in this case called AICasZone) and
-- using the functions AI_CAS_ZONE assign the parameters that define this object
-- (in this case PatrolZone, 500, 1000, 500, 600, CASEngagementZone)
local AICasZone = AI_CAS_ZONE:New( PatrolZone, 500, 1000, 500, 600, CASEngagementZone )
-- Create an object (in this case called Targets) and
-- using the GROUP function find the group labeled "Targets" and assign it to this object
local Targets = GROUP:FindByName("Targets")
-- Tell the program to use the object (in this case called CASPlane) as the group to use in the CAS function
AICasZone:SetControllable( CASPlane )
-- Tell the group CASPlane to start the mission in 1 second.
AICasZone:__Start( 1 ) -- They should statup, and start patrolling in the PatrolZone.
-- After 10 minutes, tell the group CASPlane to engage the targets located in the engagement zone called CASEngagement Zone. (600 is 600 seconds)
AICasZone:__Engage( 60, 400, 500 ) -- Engage after one minute with a speed of 400 km/h and an altitude of 500 meters.
-- Check every 60 seconds whether the Targets have been eliminated.
-- When the trigger completed has been fired, the Plane will go back to the Patrol Zone.
Check, CheckScheduleID = SCHEDULER:New(nil,
function()
if Targets:IsAlive() and Targets:GetSize() > 5 then
BASE:E( "Test Mission: " .. Targets:GetSize() .. " targets left to be destroyed.")
else
BASE:E( "Test Mission: The required targets are destroyed." )
AICasZone:__Accomplish( 1 ) -- Now they should fly back to teh patrolzone and patrol.
end
end, {}, 20, 60, 0.2 )
-- When the targets in the zone are destroyed, (see scheduled function), the planes will return home ...
function AICasZone:OnAfterAccomplish( Controllable, From, Event, To )
BASE:E( "Test Mission: Sending the Su-25T back to base." )
Check:Stop( CheckScheduleID )
AICasZone:__RTB( 1 )
end

View File

@@ -0,0 +1,76 @@
---
-- Name: CAS-010 - CAS in a Zone by Helicopter
-- Author: FlightControl
-- Date Created: 6 February 2017
--
-- # Situation:
--
-- A group of 1 Ka-50 patrolling north of an engage zone for 1 minute.
-- After 1 minute, the command center orders the Ka-50 to engage the zone and execute a CAS.
--
-- # Test cases:
--
-- 1. Observe that the Ka-50 is patrolling in the patrol zone, until the engage command is given.
-- 2. The Ka-50 are not detecting any target during the patrol.
-- 3. When the Ka-50 is commanded to engage, the group will fly to the engage zone.
-- 3.1. Engage Speed is set to 100 km/h.
-- 3.2. Engage Altitude is set to 150 meters.
-- 4. Detection is activated and detected targets within the engage zone are assigned for CAS.
-- 5. Observe the Ka-50 eliminating the targets.
-- 6. Observe the Ka-50 defenses.
-- 7. When all targets within the engage zone are destroyed, the Ka-50 CAS task is set to Accomplished.
-- 8. The Ka-50 will return to base.
-- Create a local variable (in this case called CASEngagementZone) and
-- using the ZONE function find the pre-defined zone called "Engagement Zone"
-- currently on the map and assign it to this variable
local CASEngagementZone = ZONE:New( "Engagement Zone" )
-- Create a local variable (in this case called CASPlane) and
-- using the GROUP function find the aircraft group called "Plane" and assign to this variable
local CASPlane = GROUP:FindByName( "Helicopter" )
-- Create a local Variable (in this cased called PatrolZone and
-- using the ZONE function find the pre-defined zone called "Patrol Zone" and assign it to this variable
local PatrolZone = ZONE:New( "Patrol Zone" )
-- Create and object (in this case called AICasZone) and
-- using the functions AI_CAS_ZONE assign the parameters that define this object
-- (in this case PatrolZone, 500, 1000, 500, 600, CASEngagementZone)
local AICasZone = AI_CAS_ZONE:New( PatrolZone, 500, 1000, 500, 600, CASEngagementZone )
-- Create an object (in this case called Targets) and
-- using the GROUP function find the group labeled "Targets" and assign it to this object
local Targets = GROUP:FindByName("Targets")
-- Tell the program to use the object (in this case called CASPlane) as the group to use in the CAS function
AICasZone:SetControllable( CASPlane )
-- Tell the group CASPlane to start the mission in 1 second.
AICasZone:__Start( 1 ) -- They should statup, and start patrolling in the PatrolZone.
-- After 10 minutes, tell the group CASPlane to engage the targets located in the engagement zone called CASEngagement Zone. (600 is 600 seconds)
AICasZone:__Engage( 60, 100, 150 )
-- Check every 60 seconds whether the Targets have been eliminated.
-- When the trigger completed has been fired, the Plane will go back to the Patrol Zone.
Check, CheckScheduleID = SCHEDULER:New(nil,
function()
if Targets:IsAlive() and Targets:GetSize() > 5 then
BASE:E( "Test Mission: " .. Targets:GetSize() .. " targets left to be destroyed.")
else
BASE:E( "Test Mission: The required targets are destroyed." )
AICasZone:__Accomplish( 1 ) -- Now they should fly back to teh patrolzone and patrol.
end
end, {}, 20, 60, 0.2 )
-- When the targets in the zone are destroyed, (see scheduled function), the planes will return home ...
function AICasZone:OnAfterAccomplish( Controllable, From, Event, To )
BASE:E( "Test Mission: Sending the Su-25T back to base." )
Check:Stop( CheckScheduleID )
AICasZone:__RTB( 1 )
end

View File

@@ -0,0 +1,75 @@
---
-- Name: CAS-011 - CAS in a Zone by Helicopter Group
-- Author: FlightControl
-- Date Created: 6 February 2017
--
-- # Situation:
--
-- A group of 4 Ka-50 patrolling north of an engage zone for 1 minute.
-- After 1 minute, the command center orders the Ka-50 to engage the zone and execute a CAS.
--
-- # Test cases:
--
-- 1. Observe that the Ka-50 is patrolling in the patrol zone, until the engage command is given.
-- 2. The Ka-50 are not detecting any target during the patrol.
-- 3. When the Ka-50 is commanded to engage, the group will fly to the engage zone.
-- 3.1. Engage Speed is set to 100 km/h.
-- 3.2. Engage Altitude is set to 150 meters.
-- 4. Detection is activated and detected targets within the engage zone are assigned for CAS.
-- 5. Observe the Ka-50 eliminating the targets.
-- 6. Observe the Ka-50 defenses.
-- 7. When all targets within the engage zone are destroyed, the Ka-50 CAS task is set to Accomplished.
-- 8. The Ka-50 will return to base.
-- Create a local variable (in this case called CASEngagementZone) and
-- using the ZONE function find the pre-defined zone called "Engagement Zone"
-- currently on the map and assign it to this variable
local CASEngagementZone = ZONE:New( "Engagement Zone" )
-- Create a local variable (in this case called CASPlane) and
-- using the GROUP function find the aircraft group called "Plane" and assign to this variable
local CASPlane = GROUP:FindByName( "Helicopter" )
-- Create a local Variable (in this cased called PatrolZone and
-- using the ZONE function find the pre-defined zone called "Patrol Zone" and assign it to this variable
local PatrolZone = ZONE:New( "Patrol Zone" )
-- Create and object (in this case called AICasZone) and
-- using the functions AI_CAS_ZONE assign the parameters that define this object
-- (in this case PatrolZone, 500, 1000, 500, 600, CASEngagementZone)
local AICasZone = AI_CAS_ZONE:New( PatrolZone, 500, 1000, 500, 600, CASEngagementZone )
-- Create an object (in this case called Targets) and
-- using the GROUP function find the group labeled "Targets" and assign it to this object
local Targets = GROUP:FindByName("Targets")
-- Tell the program to use the object (in this case called CASPlane) as the group to use in the CAS function
AICasZone:SetControllable( CASPlane )
-- Tell the group CASPlane to start the mission in 1 second.
AICasZone:__Start( 1 ) -- They should statup, and start patrolling in the PatrolZone.
-- After 10 minutes, tell the group CASPlane to engage the targets located in the engagement zone called CASEngagement Zone. (600 is 600 seconds)
AICasZone:__Engage( 60, 100, 150 )
-- Check every 60 seconds whether the Targets have been eliminated.
-- When the trigger completed has been fired, the Plane will go back to the Patrol Zone.
Check, CheckScheduleID = SCHEDULER:New(nil,
function()
if Targets:IsAlive() and Targets:GetSize() > 5 then
BASE:E( "Test Mission: " .. Targets:GetSize() .. " targets left to be destroyed.")
else
BASE:E( "Test Mission: The required targets are destroyed." )
AICasZone:__Accomplish( 1 ) -- Now they should fly back to teh patrolzone and patrol.
end
end, {}, 20, 60, 0.2 )
-- When the targets in the zone are destroyed, (see scheduled function), the planes will return home ...
function AICasZone:OnAfterAccomplish( Controllable, From, Event, To )
BASE:E( "Test Mission: Sending the Su-25T back to base." )
Check:Stop( CheckScheduleID )
AICasZone:__RTB( 1 )
end

View File

@@ -0,0 +1,91 @@
---
-- Name: CAS-111 - Multiple CAS in 1 Radius Zone by Helicopter and AirPlane Groups
-- Author: FlightControl
-- Date Created: 6 February 2017
--
-- # Situation:
--
-- A group of 4 Ka-50 and 5 Su-25T are patrolling north in two engage zone for 5 minutes.
-- After 5 minutes, the command center orders the groups to engage the zone and execute a CAS.
--
-- # Test cases:
--
-- 1. Observe that the groups is patrolling in the patrol zone, until the engage command is given.
-- 2. The groups are not detecting any target during the patrol.
-- 3. When the groups is commanded to engage, the group will fly to the engage zone.
-- 3.1. Engage Speed for the Su-25T is set to 350 km/h.
-- 3.2. Engage Altitude for the Su-25T is set to 1500 meters.
-- 3.3. Engage Speed for the Ka-50 is set to 100 km/h.
-- 3.4. Engage Altitude for the Ka-50 is set to 150 meters.
-- 4. Detection is activated and detected targets within the engage zone are assigned for CAS.
-- 5. Observe the groups eliminating the targets.
-- 6. Observe the groups defenses.
-- 7. When all targets within the engage zone are destroyed, the groups CAS task is set to Accomplished.
-- 8. The groups will return to base.
-- Create a local variable (in this case called CASEngagementZone) and
-- using the ZONE function find the pre-defined zone called "Engagement Zone"
-- currently on the map and assign it to this variable
local CASEngagementZone = ZONE:New( "Engagement Zone" )
-- Create a local variables (in this case called CASPlane and CASHelicopters) and
-- using the GROUP function find the aircraft group called "Plane" and "Helicopter" and assign to these variables
local CASPlane = GROUP:FindByName( "Plane" )
local CASHelicopter = GROUP:FindByName( "Helicopter" )
-- Create two patrol zones, one for the Planes and one for the Helicopters.
local PatrolZonePlanes = ZONE:New( "Patrol Zone Planes" )
local PatrolZoneHelicopters = ZONE:New( "Patrol Zone Helicopters" )
-- Create and object (in this case called AICasZone) and
-- using the functions AI_CAS_ZONE assign the parameters that define this object
-- (in this case PatrolZone, 500, 1000, 500, 600, CASEngagementZone)
local AICasZonePlanes = AI_CAS_ZONE:New( PatrolZonePlanes, 400, 500, 500, 2500, CASEngagementZone )
local AICasZoneHelicopters = AI_CAS_ZONE:New( PatrolZoneHelicopters, 100, 250, 300, 1000, CASEngagementZone )
-- Create an object (in this case called Targets) and
-- using the GROUP function find the group labeled "Targets" and assign it to this object
local Targets = GROUP:FindByName("Targets")
-- Tell the program to use the object (in this case called CASPlane) as the group to use in the CAS function
AICasZonePlanes:SetControllable( CASPlane )
AICasZoneHelicopters:SetControllable( CASHelicopter )
-- Tell the group CASPlane to start the mission in 1 second.
AICasZonePlanes:__Start( 1 ) -- They should startup, and start patrolling in the PatrolZone.
AICasZoneHelicopters:__Start( 1 ) -- They should startup, and start patrolling in the PatrolZone.
-- After 10 minutes, tell the group CASPlanes and CASHelicopters to engage the targets located in the engagement zone called CASEngagement Zone.
AICasZonePlanes:__Engage( 300, 350, 1500 ) -- Engage with a speed of 350 km/h and 1500 meter altitude.
AICasZoneHelicopters:__Engage( 300, 100, 150 ) -- Engage with a speed of 100 km/h and 150 meter altitude.
-- Check every 60 seconds whether the Targets have been eliminated.
-- When the trigger completed has been fired, the Planes and Helicopters will go back to the Patrol Zone.
Check, CheckScheduleID = SCHEDULER:New(nil,
function()
if Targets:IsAlive() and Targets:GetSize() > 5 then
BASE:E( "Test Mission: " .. Targets:GetSize() .. " targets left to be destroyed.")
else
BASE:E( "Test Mission: The required targets are destroyed." )
Check:Stop( CheckScheduleID )
AICasZonePlanes:__Accomplish( 1 ) -- Now they should fly back to teh patrolzone and patrol.
AICasZoneHelicopters:__Accomplish( 1 ) -- Now they should fly back to teh patrolzone and patrol.
end
end, {}, 20, 60, 0.2 )
-- When the targets in the zone are destroyed, (see scheduled function), the planes will return home ...
function AICasZonePlanes:OnAfterAccomplish( Controllable, From, Event, To )
BASE:E( "Test Mission: Sending the Su-25T back to base." )
AICasZonePlanes:__RTB( 1 )
end
-- When the targets in the zone are destroyed, (see scheduled function), the helicpters will return home ...
function AICasZoneHelicopters:OnAfterAccomplish( Controllable, From, Event, To )
BASE:E( "Test Mission: Sending the Ka-50 back to base." )
AICasZoneHelicopters:__RTB( 1 )
end