From b2bd37edbce0a104d17450a0646dca9fc9a64967 Mon Sep 17 00:00:00 2001 From: FlightControl Date: Sat, 18 Jun 2016 12:24:05 +0200 Subject: [PATCH] Create the PATROLZONE class --- Moose Development/Moose/AIBalancer.lua | 19 +++++++- Moose Development/Moose/PatrolZone.lua | 60 ++++++++++++++++++++++++++ Moose Development/Moose/Set.lua | 2 - 3 files changed, 77 insertions(+), 4 deletions(-) create mode 100644 Moose Development/Moose/PatrolZone.lua diff --git a/Moose Development/Moose/AIBalancer.lua b/Moose Development/Moose/AIBalancer.lua index 96f48ea4d..394c7e7ff 100644 --- a/Moose Development/Moose/AIBalancer.lua +++ b/Moose Development/Moose/AIBalancer.lua @@ -13,13 +13,24 @@ -- -- * @{#AIBALANCER.New}: Creates a new AIBALANCER object. -- --- 1.2) AIBALANCER return AI to Airbases: --- -------------------------------------- +-- 1.2) AIBALANCER returns AI to Airbases: +-- --------------------------------------- -- You can configure to have the AI to return to: -- -- * @{#AIBALANCER.ReturnToHomeAirbase}: Returns the AI to the home @{Airbase#AIRBASE}. -- * @{#AIBALANCER.ReturnToNearestAirbases}: Returns the AI to the nearest friendly @{Airbase#AIRBASE}. -- +-- 1.3) AIBALANCER allows AI to patrol specific zones: +-- --------------------------------------------------- +-- Use @{AIBalancer#AIBALANCER.AddPatrolZone}() to specify zones where airplanes need patrol a zone ( @{Zone} ) for a specific time, at a specific altitude, with a specific speed. +-- Multiple zones can be patrolled, calling @{AIBalancer#AIBALANCER.AddPatrolZone}() multiple times. The AI will patrol at a random zone in the list. +-- And when the PatrolTime is finished, it will patrol another zone. +-- +-- 1.4) AIRBALANCER manages AI out of fuel events: +-- ----------------------------------------------- +-- Once an AI is out of fuel, it will contact the home base, so that on time, a new replacement AI is spawned, while the old will orbit for a specific time and RTB. +-- Use @{AIBalancer#AIBALANCER.GuardFuel}() to guard for each AI the fuel status. +-- -- === -- -- CREDITS @@ -28,6 +39,10 @@ -- Working together with James has resulted in the creation of the AIBALANCER class. -- James has shared his ideas on balancing AI with air units, and together we made a first design which you can use now :-) -- +-- **SNAFU** +-- Had a couple of mails with the guys to validate, if the same concept in the GTI/CAP script could be reworked within MOOSE. +-- Non of the script code has been used however within the new AIBALANCER moose class. +-- -- @module AIBalancer -- @author FlightControl diff --git a/Moose Development/Moose/PatrolZone.lua b/Moose Development/Moose/PatrolZone.lua new file mode 100644 index 000000000..2d0cbc23a --- /dev/null +++ b/Moose Development/Moose/PatrolZone.lua @@ -0,0 +1,60 @@ +--- This module contains the PATROLZONE class. +-- +-- === +-- +-- 1) @{Patrol#PATROLZONE} class, extends @{Base#BASE} +-- =================================================== +-- The @{Patrol#PATROLZONE} class implements the core functions to patrol a @{Zone}. +-- +-- 1.1) PATROLZONE constructor: +-- ---------------------------- +-- @{PatrolZone#PATROLZONE.New}(): Creates a new PATROLZONE object. +-- +-- 1.2) Modify the PATROLZONE parameters: +-- -------------------------------------- +-- The following methods are available to modify the parameters of a PATROLZONE object: +-- +-- * @{PatrolZone#PATROLZONE.SetSpeed}(): Set the patrol speed of the AI, while patrolling. +-- * @{PatrolZone#PATROLZONE.SetAltitude}(): Set altitude of the AI, while patrolling. +-- +-- === +-- +-- @module PatrolZone +-- @author FlightControl + + +--- PATROLZONE class +-- @type PATROLZONE +-- @extends Base#BASE +PATROLZONE = { + ClassName = "PATROLZONE", +} + +--- Creates a new PATROLZONE object, taking a @{Group} object as a parameter. The GROUP needs to be alive. +-- @param #PATROLZONE self +-- @param Group#GROUP PatrolGroup The @{Group} patrolling. +-- @param Zone#ZONE_BASE PatrolZone The @{Zone} where the patrol needs to be executed. +-- @param DCSTypes#Altitude PatrolFloorAltitude The lowest altitude in meters where to execute the patrol. +-- @param DCSTypes#Altitude PatrolCeilingAltitude The highest altitude in meters where to execute the patrol. +-- @param DCSTypes#Speed PatrolMinSpeed The minimum speed of the @{Group} in km/h. +-- @param DCSTypes#Speed PatrolMaxSpeed The maximum speed of the @{Group} in km/h. +-- @return #PATROLZONE self +-- @usage +-- -- Define a new PATROLZONE Object. This PatrolArea will patrol a group within PatrolZone between 3000 and 6000 meters, with a variying speed between 600 and 900 km/h. +-- PatrolZone = ZONE:New( 'PatrolZone' ) +-- PatrolGroup = GROUP:FindByName( "Patrol Group" ) +-- PatrolArea = PATROLZONE:New( PatrolGroup, PatrolZone, 3000, 6000, 600, 900 ) +function PATROLZONE:New( PatrolGroup, PatrolZone, PatrolFloorAltitude, PatrolCeilingAltitude, PatrolMinSpeed, PatrolMaxSpeed ) + + -- Inherits from BASE + local self = BASE:Inherit( self, BASE:New() ) + + self.PatrolGroup = PatrolGroup + self.PatrolZone = PatrolZone + self.PatrolFloorAltitude = PatrolFloorAltitude + self.PatrolCeilingAltitude = PatrolCeilingAltitude + self.PatrolMinSpeed = PatrolMinSpeed + self.PatrolMaxSpeed = PatrolMaxSpeed + + return self +end diff --git a/Moose Development/Moose/Set.lua b/Moose Development/Moose/Set.lua index 388de8741..447c608c8 100644 --- a/Moose Development/Moose/Set.lua +++ b/Moose Development/Moose/Set.lua @@ -238,8 +238,6 @@ SET_BASE = { -- DBObject = SET_BASE:New() function SET_BASE:New( Database ) - env.info( tostring( Database ) ) - -- Inherits from BASE local self = BASE:Inherit( self, BASE:New() )