Lots of changes done...

Change trace prototypes.
Change DCS class prototypes
This commit is contained in:
FlightControl 2016-03-28 22:54:31 +02:00
parent 8eab8622c6
commit 260f109e40
40 changed files with 1251 additions and 1073 deletions

View File

@ -1,9 +1,10 @@
-------------------------------------------------------------------------------
-- @module Airbase
-- @extends CoalitionObject#CoalitionObject
-- @module DCSAirbase
--- Represents airbases: airdromes, helipads and ships with flying decks or landing pads.
-- @type Airbase
-- @extends DCSCoalitionObject#CoalitionObject
-- @field #Airbase.ID ID Identifier of an airbase. It assigned to an airbase by the Mission Editor automatically. This identifier is used in AI tasks to refer an airbase that exists (spawned and not dead) or not.
-- @field #Airbase.Category Category enum contains identifiers of airbase categories.
-- @field #Airbase.Desc Desc Airbase descriptor. Airdromes are unique and their types are unique, but helipads and ships are not always unique and may have the same type.

View File

@ -1,8 +1,8 @@
-------------------------------------------------------------------------------
-- @module CoalitionObject
-- @extends Object#Object
-- @module DCSCoalitionObject
--- @type CoalitionObject
-- @extends DCSObject#Object
--- Returns coalition of the object.
-- @function [parent=#CoalitionObject] getCoalition

View File

@ -1,6 +1,5 @@
-------------------------------------------------------------------------------
-- @module Controller
-- TODO Add Task templates
-- @module DCSController
--- Controller is an object that performs A.I.-routines. Other words controller is an instance of A.I.. Controller stores current main task, active enroute tasks and behavior options. Controller performs commands. Please, read DCS A-10C GUI Manual EN.pdf chapter "Task Planning for Unit Groups", page 91 to understand A.I. system of DCS:A-10C.
--

View File

@ -1,6 +1,5 @@
-------------------------------------------------------------------------------
-- @module Group
-- @module DCSGroup
--- Represents group of Units.
-- @type Group
@ -17,66 +16,67 @@
-- Static Functions
--- Returns group by the name assigned to the group in Mission Editor.
-- @function [parent=#Airbase] getByName
-- @function [parent=#Group] getByName
-- @param #string name
-- @return #Group
-- Member Functions
--- returns true if the group exist or false otherwise.
-- @function [parent=#Airbase] isExist
-- @param self
-- @function [parent=#Group] isExist
-- @param #Group self
-- @return #boolean
--- Destroys the group and all of its units.
-- @function [parent=#Airbase] destroy
-- @param self
-- @function [parent=#Group] destroy
-- @param #Group self
--- Returns category of the group.
-- @function [parent=#Airbase] getCategory
-- @param self
-- @function [parent=#Group] getCategory
-- @param #Group self
-- @return #Group.Category
--TODO check coalition.side
--- Returns coalition of the group.
-- @function [parent=#Airbase] getCoalition
-- @param self
-- @function [parent=#Group] getCoalition
-- @param #Group self
-- @return #coalition.side
--- Returns the group's name. This is the same name assigned to the group in Mission Editor.
-- @function [parent=#Airbase] getName
-- @param self
-- @function [parent=#Group] getName
-- @param #Group self
-- @return #string
--- Returns the group identifier.
-- @function [parent=#Airbase] getID
-- @param self
-- @function [parent=#Group] getID
-- @param #Group self
-- @return #ID
--- Returns the unit with number unitNumber. If the unit is not exists the function will return nil.
-- @function [parent=#Airbase] getUnit
-- @param self
-- @function [parent=#Group] getUnit
-- @param #Group self
-- @param #number unitNumber
-- @return Unit#Unit
-- @return DCSUnit#Unit
--- Returns current size of the group. If some of the units will be destroyed, As units are destroyed the size of the group will be changed.
-- @function [parent=#Airbase] getSize
-- @param self
-- @function [parent=#Group] getSize
-- @param #Group self
-- @return #number
--- Returns initial size of the group. If some of the units will be destroyed, initial size of the group will not be changed. Initial size limits the unitNumber parameter for Group.getUnit() function.
-- @function [parent=#Airbase] getInitialSize
-- @param self
-- @function [parent=#Group] getInitialSize
-- @param #Group self
-- @return #number
--- Returns array of the units present in the group now. Destroyed units will not be enlisted at all.
-- @function [parent=#Airbase] getUnits
-- @param self
-- @return #list<Unit#Unit> array of Units
-- @function [parent=#Group] getUnits
-- @param #Group self
-- @return #list<DCSUnit#Unit> array of Units
--- Returns controller of the group.
-- @function [parent=#Airbase] getController
-- @param self
-- @function [parent=#Group] getController
-- @param #Group self
-- @return Controller#Controller
Group = {} --#Group

View File

@ -1,5 +1,5 @@
-------------------------------------------------------------------------------
-- @module Object
-- @module DCSObject
--- @type Object
-- @field #Object.Category Category
@ -18,55 +18,55 @@
-- @field #Box3 box bounding box of collision geometry
--- @function [parent=#Object] isExist
-- @param self
-- @param #Object self
-- @return #boolean
--- @function [parent=#Object] destroy
-- @param self
-- @param #Object self
--- @function [parent=#Object] getCategory
-- @param self
-- @param #Object self
-- @return #Object.Category
--- Returns type name of the Object.
-- @function [parent=#Object] getTypeName
-- @param self
-- @param #Object self
-- @return #string
--- Returns object descriptor.
-- @function [parent=#Object] getDesc
-- @param self
-- @param #Object self
-- @return #Object.Desc
--- Returns true if the object belongs to the category.
-- @function [parent=#Object] hasAttribute
-- @param self
-- @param #Object self
-- @param #AttributeName attributeName Attribute name to check.
-- @return #boolean
--- Returns name of the object. This is the name that is assigned to the object in the Mission Editor.
-- @function [parent=#Object] getName
-- @param self
-- @param #Object self
-- @return #string
--- Returns object coordinates for current time.
-- @function [parent=#Object] getPoint
-- @param self
-- @param #Object self
-- @return #Vec3
--- Returns object position for current time.
-- @function [parent=#Object] getPosition
-- @param self
-- @param #Object self
-- @return #Position3
--- Returns the unit's velocity vector.
-- @function [parent=#Object] getVelocity
-- @param self
-- @param #Object self
-- @return #Vec3
--- Returns true if the unit is in air.
-- @function [parent=#Object] inAir
-- @param self
-- @param #Object self
-- @return #boolean
Object = {} --#Object

View File

@ -1,5 +1,5 @@
-------------------------------------------------------------------------------
-- @module StaticObject
-- @module DCSStaticObject
-------------------------------------------------------------------------------
@ -22,12 +22,12 @@
--- returns identifier of the static object.
-- @function [parent=#StaticObject] getID
-- @param self
-- @param #StaticObject self
-- @return #StaticObject.ID
--- Returns descriptor of the StaticObject.
-- @function [parent=#StaticObject] getDesc
-- @param self
-- @param #StaticObject self
-- @return #StaticObject.Desc

8
DCS/DCSTask.doclua Normal file
View File

@ -0,0 +1,8 @@
--- @type DCSTask
-- @field #string id
-- @field #DCSTask.param param
--- @type DCSTask.param
env.info( "DCSTask defined" )

View File

@ -1,8 +1,8 @@
-------------------------------------------------------------------------------
-- @module Unit
-- @extends CoalitionObject#CoalitionObject
-- @module DCSUnit
--- @type Unit
-- @extends DCSCoalitionObject#CoalitionObject
-- @field ID Identifier of an unit. It assigned to an unit by the Mission Editor automatically.
-- @field #Unit.Category Category
-- @field #Unit.RefuelingSystem RefuelingSystem
@ -151,68 +151,68 @@
--- Returns if the unit is activated.
-- @function [parent=#Unit] isActive
-- @param self
-- @param #Unit self
-- @return #boolean
--- Returns name of the player that control the unit or nil if the unit is controlled by A.I.
-- @function [parent=#Unit] getPlayerName
-- @param self
-- @param #Unit self
-- @return #string
--- returns the unit's unique identifier.
-- @function [parent=#Unit] getID
-- @param self
-- @param #Unit self
-- @return #Unit.ID
--- Returns the unit's number in the group. The number is the same number the unit has in ME. It may not be changed during the mission. If any unit in the group is destroyed, the numbers of another units will not be changed.
-- @function [parent=#Unit] getNumber
-- @param self
-- @param #Unit self
-- @return #number
--- Returns controller of the unit if it exist and nil otherwise
-- @function [parent=#Unit] getController
-- @param self
-- @param #Unit self
-- @return #Controller
--- Returns the unit's group if it exist and nil otherwise
-- @function [parent=#Unit] getGroup
-- @param self
-- @return Group#Group
-- @param #Unit self
-- @return DCSGroup#Group
--- Returns the unit's callsign - the localized string.
-- @function [parent=#Unit] getCallsign
-- @param self
-- @param #Unit self
-- @return #string
--- Returns the unit's health. Dead units has health <= 1.0
-- @function [parent=#Unit] getLife
-- @param self
-- @param #Unit self
-- @return #number
--- returns the unit's initial health.
-- @function [parent=#Unit] getLife0
-- @param self
-- @param #Unit self
-- @return #number
--- Returns relative amount of fuel (from 0.0 to 1.0) the unit has in its internal tanks. If there are additional fuel tanks the value may be greater than 1.0.
-- @function [parent=#Unit] getFuel
-- @param self
-- @param #Unit self
-- @return #number
--- Returns the unit ammunition.
-- @function [parent=#Unit] getAmmo
-- @param self
-- @param #Unit self
-- @return #Unit.Ammo
--- Returns the unit sensors.
-- @function [parent=#Unit] getSensors
-- @param self
-- @param #Unit self
-- @return #Unit.Sensors
--- Returns true if the unit has specified types of sensors. This function is more preferable than Unit.getSensors() if you don't want to get information about all the unit's sensors, and just want to check if the unit has specified types of sensors.
-- @function [parent=#Unit] hasSensors
-- @param self
-- @param #Unit self
-- @param #Unit.SensorType sensorType (= nil) Sensor type.
-- @param ... Additional parameters.
-- @return #boolean
@ -229,13 +229,13 @@
-- First value indicates if at least one of the unit's radar(s) is on.
-- Second value is the object of the radar's interest. Not nil only if at least one radar of the unit is tracking a target.
-- @function [parent=#Unit] getRadar
-- @param self
-- @param #Unit self
-- @return #boolean, Object#Object
--- Returns unit descriptor. Descriptor type depends on unit category.
-- @function [parent=#Unit] getDesc
-- @param self
-- @return Unit#Unit.Desc
-- @param #Unit self
-- @return #Unit.Desc
Unit = {} --#Unit

View File

@ -1,5 +1,5 @@
-------------------------------------------------------------------------------
-- @module timer
-- @module DCStimer
--- @type timer

File diff suppressed because it is too large Load Diff

View File

@ -4,8 +4,9 @@
Include.File( "Routines" )
_TraceOn = true
_TraceClass = {
local _TraceOn = true
local _TraceLevel = 1
local _TraceClass = {
--DATABASE = true,
--SEAD = true,
--DESTROYBASETASK = true,
@ -51,7 +52,6 @@ FORMATION = {
-- @return #BASE
-- @usage
-- function TASK:New()
-- trace.f(self.ClassName)
--
-- local self = BASE:Inherit( self, BASE:New() )
--
@ -100,8 +100,31 @@ function BASE:Inherited( Child )
return Parent
end
--- Get the ClassName + ClassID of the class instance.
-- The ClassName + ClassID is formatted as '%s#%09d'.
-- @param #BASE self
-- @return #string The ClassName + ClassID of the class instance.
function BASE:GetClassNameAndID()
return string.format( '%s#%09d', self:GetClassName(), self:GetClassID() )
end
--- Get the ClassName of the class instance.
-- @param #BASE self
-- @return #string The ClassName of the class instance.
function BASE:GetClassName()
return self.ClassName
end
--- Get the ClassID of the class instance.
-- @param #BASE self
-- @return #string The ClassID of the class instance.
function BASE:GetClassID()
return self.ClassID
end
function BASE:AddEvent( Event, EventFunction )
trace.f( self.ClassName, Event )
self:F( Event )
self.Events[#self.Events+1] = {}
self.Events[#self.Events].Event = Event
@ -113,22 +136,20 @@ end
function BASE:EnableEvents()
trace.f( self.ClassName )
self:F( #self.Events )
trace.i( self.ClassName, #self.Events )
for EventID, Event in pairs( self.Events ) do
Event.Self = self
Event.EventEnabled = true
end
--env.info( 'EnableEvent Table Task = ' .. tostring(self) )
self.Events.Handler = world.addEventHandler( self )
return self
end
function BASE:DisableEvents()
trace.f( self.ClassName )
self:F()
world.removeEventHandler( self )
for EventID, Event in pairs( self.Events ) do
Event.Self = nil
@ -139,7 +160,7 @@ trace.f( self.ClassName )
end
BaseEventCodes = {
local BaseEventCodes = {
"S_EVENT_SHOT",
"S_EVENT_HIT",
"S_EVENT_TAKEOFF",
@ -179,7 +200,7 @@ BaseEventCodes = {
function BASE:CreateEventBirth( EventTime, Initiator, IniUnitName, place, subplace )
trace.f( self.ClassName, { EventTime, Initiator, IniUnitName, place, subplace } )
self:F( { EventTime, Initiator, IniUnitName, place, subplace } )
local Event = {
id = world.event.S_EVENT_BIRTH,
@ -194,7 +215,7 @@ trace.f( self.ClassName, { EventTime, Initiator, IniUnitName, place, subplace }
end
function BASE:CreateEventCrash( EventTime, Initiator )
trace.f( self.ClassName, { EventTime, Initiator } )
self:F( { EventTime, Initiator } )
local Event = {
id = world.event.S_EVENT_CRASH,
@ -206,7 +227,6 @@ trace.f( self.ClassName, { EventTime, Initiator } )
end
function BASE:onEvent(event)
--trace.f(self.ClassName, event )
--env.info( 'onEvent Table self = ' .. tostring(self) )
if self then
@ -223,7 +243,7 @@ function BASE:onEvent(event)
if event.target and event.target:isExist() then
event.TgtUnitName = event.target:getName()
end
trace.i( self.ClassName, { BaseEventCodes[event.id], event } )
self:T( { BaseEventCodes[event.id], event } )
EventObject.EventFunction( self, event )
end
end
@ -236,6 +256,44 @@ end
-- Trace section
-- Log a trace (only shown when trace is on)
function BASE:F( Arguments )
if _TraceOn and _TraceClass[self.ClassName] then
local DebugInfoCurrent = debug.getinfo( 2, "nl" )
local DebugInfoFrom = debug.getinfo( 3, "l" )
local Function = "function"
if DebugInfoCurrent.name then
Function = DebugInfoCurrent.name
end
local LineCurrent = DebugInfoCurrent.currentline
local LineFrom = 0
if DebugInfoFrom then
LineFrom = DebugInfoFrom.currentline
end
env.info( string.format( "%6d\(%6d\)/%1s:%20s%05d.%s\(%s\)" , LineCurrent, LineFrom, "F", self.ClassName, self.ClassID, Function, routines.utils.oneLineSerialize( Arguments ) ) )
end
end
function BASE:F2( Arguments )
if _TraceLevel >= 2 then
self:F( Arguments )
end
end
function BASE:F3( Arguments )
if _TraceLevel >= 3 then
self:F( Arguments )
end
end
function BASE:T( Arguments )
if _TraceOn and _TraceClass[self.ClassName] then
@ -253,10 +311,28 @@ function BASE:T( Arguments )
if DebugInfoFrom then
LineFrom = DebugInfoFrom.currentline
end
env.info( string.format( "%6d\(%6d\)/%1s:%20s%05d.%s\(%s\)" , LineCurrent, LineFrom, "T", self.ClassName, self.ClassID, Function, routines.utils.oneLineSerialize( Arguments ) ) )
env.info( string.format( "%6d\(%6d\)/%1s:%20s%05d.%s" , LineCurrent, LineFrom, "T", self.ClassName, self.ClassID, routines.utils.oneLineSerialize( Arguments ) ) )
end
end
function BASE:T2( Arguments )
if _TraceLevel >= 2 then
self:T( Arguments )
end
end
function BASE:T3( Arguments )
if _TraceLevel >= 3 then
self:T( Arguments )
end
end
-- Log an exception
function BASE:E( Arguments )

View File

@ -32,7 +32,7 @@ CARGO_ZONE = {
}
function CARGO_ZONE:New( CargoZoneName, CargoHostName ) local self = BASE:Inherit( self, BASE:New() )
self:T( { CargoZoneName, CargoHostName } )
self:F( { CargoZoneName, CargoHostName } )
self.CargoZoneName = CargoZoneName
self.CargoZone = trigger.misc.getZone( CargoZoneName )
@ -48,7 +48,7 @@ self:T( { CargoZoneName, CargoHostName } )
end
function CARGO_ZONE:Spawn()
self:T( self.CargoHostName )
self:F( self.CargoHostName )
if self.CargoHostSpawn then
local CargoHostGroup = self.CargoHostSpawn:GetGroupFromIndex()
@ -66,7 +66,7 @@ function CARGO_ZONE:Spawn()
end
function CARGO_ZONE:GetHostUnit()
self:T( self )
self:F( self )
if self.CargoHostName then
@ -86,7 +86,7 @@ function CARGO_ZONE:GetHostUnit()
end
function CARGO_ZONE:ReportCargosToClient( Client, CargoType )
self:T()
self:F()
local SignalUnit = self:GetHostUnit()
@ -115,7 +115,7 @@ self:T()
end
function CARGO_ZONE:Signal()
self:T()
self:F()
local Signalled = false
@ -169,7 +169,7 @@ self:T()
end
function CARGO_ZONE:WhiteSmoke()
self:T()
self:F()
self.SignalType = CARGO_ZONE.SIGNAL.TYPE.SMOKE
self.SignalColor = CARGO_ZONE.SIGNAL.COLOR.WHITE
@ -178,7 +178,7 @@ self:T()
end
function CARGO_ZONE:BlueSmoke()
self:T()
self:F()
self.SignalType = CARGO_ZONE.SIGNAL.TYPE.SMOKE
self.SignalColor = CARGO_ZONE.SIGNAL.COLOR.BLUE
@ -187,7 +187,7 @@ self:T()
end
function CARGO_ZONE:RedSmoke()
self:T()
self:F()
self.SignalType = CARGO_ZONE.SIGNAL.TYPE.SMOKE
self.SignalColor = CARGO_ZONE.SIGNAL.COLOR.RED
@ -196,7 +196,7 @@ self:T()
end
function CARGO_ZONE:OrangeSmoke()
self:T()
self:F()
self.SignalType = CARGO_ZONE.SIGNAL.TYPE.SMOKE
self.SignalColor = CARGO_ZONE.SIGNAL.COLOR.ORANGE
@ -205,7 +205,7 @@ self:T()
end
function CARGO_ZONE:GreenSmoke()
self:T()
self:F()
self.SignalType = CARGO_ZONE.SIGNAL.TYPE.SMOKE
self.SignalColor = CARGO_ZONE.SIGNAL.COLOR.GREEN
@ -215,7 +215,7 @@ end
function CARGO_ZONE:WhiteFlare()
self:T()
self:F()
self.SignalType = CARGO_ZONE.SIGNAL.TYPE.FLARE
self.SignalColor = CARGO_ZONE.SIGNAL.COLOR.WHITE
@ -224,7 +224,7 @@ self:T()
end
function CARGO_ZONE:RedFlare()
self:T()
self:F()
self.SignalType = CARGO_ZONE.SIGNAL.TYPE.FLARE
self.SignalColor = CARGO_ZONE.SIGNAL.COLOR.RED
@ -233,7 +233,7 @@ self:T()
end
function CARGO_ZONE:GreenFlare()
self:T()
self:F()
self.SignalType = CARGO_ZONE.SIGNAL.TYPE.FLARE
self.SignalColor = CARGO_ZONE.SIGNAL.COLOR.GREEN
@ -242,7 +242,7 @@ self:T()
end
function CARGO_ZONE:YellowFlare()
self:T()
self:F()
self.SignalType = CARGO_ZONE.SIGNAL.TYPE.FLARE
self.SignalColor = CARGO_ZONE.SIGNAL.COLOR.YELLOW
@ -252,7 +252,7 @@ end
function CARGO_ZONE:GetCargoHostUnit()
self:T( self )
self:F( self )
if self.CargoHostSpawn then
local CargoHostGroup = self.CargoHostSpawn:GetGroupFromIndex(1)
@ -268,7 +268,7 @@ function CARGO_ZONE:GetCargoHostUnit()
end
function CARGO_ZONE:GetCargoZoneName()
self:T()
self:F()
return self.CargoZoneName
end
@ -286,7 +286,7 @@ CARGO = {
--- Add Cargo to the mission... Cargo functionality needs to be reworked a bit, so this is still under construction. I need to make a CARGO Class...
function CARGO:New( CargoType, CargoName, CargoWeight ) local self = BASE:Inherit( self, BASE:New() )
self:T( { CargoType, CargoName, CargoWeight } )
self:F( { CargoType, CargoName, CargoWeight } )
self.CargoType = CargoType
@ -299,14 +299,14 @@ self:T( { CargoType, CargoName, CargoWeight } )
end
function CARGO:Spawn( Client )
self:T()
self:F()
return self
end
function CARGO:IsNear( Client, LandingZone )
self:T()
self:F()
local Near = true
@ -316,7 +316,7 @@ end
function CARGO:IsLoadingToClient()
self:T()
self:F()
if self:IsStatusLoading() then
return self.CargoClient
@ -328,7 +328,7 @@ end
function CARGO:IsLoadedInClient()
self:T()
self:F()
if self:IsStatusLoaded() then
return self.CargoClient
@ -340,7 +340,7 @@ end
function CARGO:UnLoad( Client, TargetZoneName )
self:T()
self:F()
self:StatusUnLoaded()
@ -348,7 +348,7 @@ self:T()
end
function CARGO:OnBoard( Client, LandingZone )
self:T()
self:F()
local Valid = true
@ -359,7 +359,7 @@ self:T()
end
function CARGO:OnBoarded( Client, LandingZone )
self:T()
self:F()
local OnBoarded = true
@ -367,7 +367,7 @@ self:T()
end
function CARGO:Load( Client )
self:T()
self:F()
self:StatusLoaded( Client )
@ -375,18 +375,18 @@ self:T()
end
function CARGO:IsLandingRequired()
self:T()
self:F()
return true
end
function CARGO:IsSlingLoad()
self:T()
self:F()
return false
end
function CARGO:StatusNone()
self:T()
self:F()
self.CargoClient = nil
self.CargoStatus = CARGO.STATUS.NONE
@ -395,7 +395,7 @@ self:T()
end
function CARGO:StatusLoading( Client )
self:T()
self:F()
self.CargoClient = Client
self.CargoStatus = CARGO.STATUS.LOADING
@ -405,7 +405,7 @@ self:T()
end
function CARGO:StatusLoaded( Client )
self:T()
self:F()
self.CargoClient = Client
self.CargoStatus = CARGO.STATUS.LOADED
@ -415,7 +415,7 @@ self:T()
end
function CARGO:StatusUnLoaded()
self:T()
self:F()
self.CargoClient = nil
self.CargoStatus = CARGO.STATUS.UNLOADED
@ -425,25 +425,25 @@ end
function CARGO:IsStatusNone()
self:T()
self:F()
return self.CargoStatus == CARGO.STATUS.NONE
end
function CARGO:IsStatusLoading()
self:T()
self:F()
return self.CargoStatus == CARGO.STATUS.LOADING
end
function CARGO:IsStatusLoaded()
self:T()
self:F()
return self.CargoStatus == CARGO.STATUS.LOADED
end
function CARGO:IsStatusUnLoaded()
self:T()
self:F()
return self.CargoStatus == CARGO.STATUS.UNLOADED
end
@ -455,7 +455,7 @@ CARGO_GROUP = {
function CARGO_GROUP:New( CargoType, CargoName, CargoWeight, CargoGroupTemplate, CargoZone ) local self = BASE:Inherit( self, CARGO:New( CargoType, CargoName, CargoWeight ) )
self:T( { CargoType, CargoName, CargoWeight, CargoGroupTemplate, CargoZone } )
self:F( { CargoType, CargoName, CargoWeight, CargoGroupTemplate, CargoZone } )
self.CargoSpawn = SPAWN:NewWithAlias( CargoGroupTemplate, CargoName )
self.CargoZone = CargoZone
@ -467,7 +467,7 @@ function CARGO_GROUP:New( CargoType, CargoName, CargoWeight, CargoGroupTemplate,
end
function CARGO_GROUP:Spawn( Client )
self:T( { Client } )
self:F( { Client } )
local SpawnCargo = true
@ -528,7 +528,7 @@ function CARGO_GROUP:Spawn( Client )
end
function CARGO_GROUP:IsNear( Client, LandingZone )
self:T()
self:F()
local Near = false
@ -545,7 +545,7 @@ end
function CARGO_GROUP:OnBoard( Client, LandingZone, OnBoardSide )
self:T()
self:F()
local Valid = true
@ -624,7 +624,7 @@ end
function CARGO_GROUP:OnBoarded( Client, LandingZone )
self:T()
self:F()
local OnBoarded = false
@ -640,7 +640,7 @@ end
function CARGO_GROUP:UnLoad( Client, TargetZoneName )
self:T()
self:F()
self:T( 'self.CargoName = ' .. self.CargoName )
@ -663,8 +663,7 @@ CARGO_PACKAGE = {
function CARGO_PACKAGE:New( CargoType, CargoName, CargoWeight, CargoClient ) local self = BASE:Inherit( self, CARGO:New( CargoType, CargoName, CargoWeight ) )
self:T( { CargoType, CargoName, CargoWeight, CargoClient } )
self:F( { CargoType, CargoName, CargoWeight, CargoClient } )
self.CargoClient = CargoClient
@ -676,7 +675,7 @@ end
function CARGO_PACKAGE:Spawn( Client )
self:T( { self, Client } )
self:F( { self, Client } )
-- this needs to be checked thoroughly
@ -716,7 +715,7 @@ end
function CARGO_PACKAGE:IsNear( Client, LandingZone )
self:T()
self:F()
local Near = false
@ -735,7 +734,7 @@ end
function CARGO_PACKAGE:OnBoard( Client, LandingZone, OnBoardSide )
self:T()
self:F()
local Valid = true
@ -826,7 +825,7 @@ end
function CARGO_PACKAGE:OnBoarded( Client, LandingZone )
self:T()
self:F()
local OnBoarded = false
@ -846,7 +845,7 @@ end
function CARGO_PACKAGE:UnLoad( Client, TargetZoneName )
self:T()
self:F()
self:T( 'self.CargoName = ' .. self.CargoName )
--self:T( 'self.CargoHostName = ' .. self.CargoHostName )
@ -865,8 +864,7 @@ CARGO_SLINGLOAD = {
function CARGO_SLINGLOAD:New( CargoType, CargoName, CargoWeight, CargoZone, CargoHostName, CargoCountryID )
local self = BASE:Inherit( self, CARGO:New( CargoType, CargoName, CargoWeight ) )
self:T( { CargoType, CargoName, CargoWeight, CargoZone, CargoHostName, CargoCountryID } )
self:F( { CargoType, CargoName, CargoWeight, CargoZone, CargoHostName, CargoCountryID } )
self.CargoHostName = CargoHostName
@ -887,19 +885,19 @@ end
function CARGO_SLINGLOAD:IsLandingRequired()
self:T()
self:F()
return false
end
function CARGO_SLINGLOAD:IsSlingLoad()
self:T()
self:F()
return true
end
function CARGO_SLINGLOAD:Spawn( Client )
self:T( { self, Client } )
self:F( { self, Client } )
local Zone = trigger.misc.getZone( self.CargoZone )
@ -949,7 +947,7 @@ end
function CARGO_SLINGLOAD:IsNear( Client, LandingZone )
self:T()
self:F()
local Near = false
@ -958,7 +956,7 @@ end
function CARGO_SLINGLOAD:IsInLandingZone( Client, LandingZone )
self:T()
self:F()
local Near = false
@ -974,7 +972,7 @@ end
function CARGO_SLINGLOAD:OnBoard( Client, LandingZone, OnBoardSide )
self:T()
self:F()
local Valid = true
@ -984,7 +982,7 @@ end
function CARGO_SLINGLOAD:OnBoarded( Client, LandingZone )
self:T()
self:F()
local OnBoarded = false
@ -1000,7 +998,7 @@ end
function CARGO_SLINGLOAD:UnLoad( Client, TargetZoneName )
self:T()
self:F()
self:T( 'self.CargoName = ' .. self.CargoName )
self:T( 'self.CargoGroupName = ' .. self.CargoGroupName )

View File

@ -28,7 +28,7 @@ CLEANUP = {
-- CleanUpTbilisi = CLEANUP:New( 'CLEAN Tbilisi', 150 )
-- CleanUpKutaisi = CLEANUP:New( 'CLEAN Kutaisi', 600 )
function CLEANUP:New( ZoneNames, TimeInterval ) local self = BASE:Inherit( self, BASE:New() )
self:T( { ZoneNames, TimeInterval } )
self:F( { ZoneNames, TimeInterval } )
if type( ZoneNames ) == 'table' then
self.ZoneNames = ZoneNames
@ -57,7 +57,7 @@ end
--- Destroys a group from the simulator, but checks first if it is still existing!
-- @see CLEANUP
function CLEANUP:_DestroyGroup( GroupObject, CleanUpGroupName )
self:T( { GroupObject, CleanUpGroupName } )
self:F( { GroupObject, CleanUpGroupName } )
if GroupObject then -- and GroupObject:isExist() then
--MESSAGE:New( "Destroy Group " .. CleanUpGroupName, CleanUpGroupName, 1, CleanUpGroupName ):ToAll()
@ -69,7 +69,7 @@ end
--- Destroys a unit from the simulator, but checks first if it is still existing!
-- @see CLEANUP
function CLEANUP:_DestroyUnit( CleanUpUnit, CleanUpUnitName )
self:T( { CleanUpUnit, CleanUpUnitName } )
self:F( { CleanUpUnit, CleanUpUnitName } )
if CleanUpUnit then
--MESSAGE:New( "Destroy " .. CleanUpUnitName, CleanUpUnitName, 1, CleanUpUnitName ):ToAll()
@ -96,7 +96,7 @@ end
--- Destroys a missile from the simulator, but checks first if it is still existing!
-- @see CLEANUP
function CLEANUP:_DestroyMissile( MissileObject )
self:T( { MissileObject } )
self:F( { MissileObject } )
if MissileObject and MissileObject:isExist() then
MissileObject:destroy()
@ -107,7 +107,7 @@ end
--- Detects if an SA site was shot with an anti radiation missile. In this case, take evasive actions based on the skill level set within the ME.
-- @see CLEANUP
function CLEANUP:_EventCrash( event )
self:T( { event } )
self:F( { event } )
--MESSAGE:New( "Crash ", "Crash", 10, "Crash" ):ToAll()
-- self:T("before getGroup")
@ -137,7 +137,7 @@ end
--- Detects if an SA site was shot with an anti radiation missile. In this case, take evasive actions based on the skill level set within the ME.
-- @see CLEANUP
function CLEANUP:_EventShot( event )
self:T( { event } )
self:F( { event } )
local _grp = Unit.getGroup(event.initiator)-- Identify the group that fired
local _groupname = _grp:getName() -- return the name of the group
@ -161,7 +161,7 @@ end
--- Detects if the Unit has an S_EVENT_HIT within the given ZoneNames. If this is the case, destroy the unit.
function CLEANUP:_EventHitCleanUp( event )
self:T( { event } )
self:F( { event } )
local CleanUpUnit = event.initiator -- the Unit
if CleanUpUnit and CleanUpUnit:isExist() and Object.getCategory(CleanUpUnit) == Object.Category.UNIT then
@ -195,7 +195,7 @@ function CLEANUP:_EventHitCleanUp( event )
end
function CLEANUP:_AddForCleanUp( CleanUpUnit, CleanUpUnitName )
self:T( { CleanUpUnit, CleanUpUnitName } )
self:F( { CleanUpUnit, CleanUpUnitName } )
self.CleanUpList[CleanUpUnitName] = {}
self.CleanUpList[CleanUpUnitName].CleanUpUnit = CleanUpUnit
@ -244,7 +244,7 @@ CleanUpSurfaceTypeText = {
--- At the defined time interval, CleanUp the Groups within the CleanUpList.
function CLEANUP:_Scheduler()
self:T( "CleanUp Scheduler" )
self:F( "CleanUp Scheduler" )
for CleanUpUnitName, UnitData in pairs( self.CleanUpList ) do

View File

@ -48,7 +48,7 @@ CLIENT = {
-- Mission:AddClient( CLIENT:New( 'RU MI-8MTV2*RAMP-Deploy Troops 4' ):Transport() )
function CLIENT:New( ClientName, ClientBriefing )
local self = BASE:Inherit( self, BASE:New() )
self:T( ClientName, ClientBriefing )
self:F( ClientName, ClientBriefing )
self.ClientName = ClientName
self:AddBriefing( ClientBriefing )
@ -60,7 +60,7 @@ end
--- Resets a CLIENT.
-- @param string ClientName Name of the Group as defined within the Mission Editor. The Group must have a Unit with the type Client.
function CLIENT:Reset( ClientName )
self:T()
self:F()
self._Menus = {}
end
@ -68,7 +68,7 @@ end
-- This function is modified to deal with a couple of bugs in DCS 1.5.3
-- @return Group#Group
function CLIENT:GetDCSGroup()
--self:T()
self:F3()
-- local ClientData = Group.getByName( self.ClientName )
-- if ClientData and ClientData:isExist() then
@ -80,33 +80,33 @@ function CLIENT:GetDCSGroup()
local CoalitionsData = { AlivePlayersRed = coalition.getPlayers( coalition.side.RED ), AlivePlayersBlue = coalition.getPlayers( coalition.side.BLUE ) }
for CoalitionId, CoalitionData in pairs( CoalitionsData ) do
--self:T( { "CoalitionData:", CoalitionData } )
self:T3( { "CoalitionData:", CoalitionData } )
for UnitId, UnitData in pairs( CoalitionData ) do
--self:T( { "UnitData:", UnitData } )
self:T3( { "UnitData:", UnitData } )
if UnitData and UnitData:isExist() then
local ClientGroup = Group.getByName( self.ClientName )
if ClientGroup then
self:T( "ClientGroup = " .. self.ClientName )
self:T3( "ClientGroup = " .. self.ClientName )
if ClientGroup:isExist() then
if ClientGroup:getID() == UnitData:getGroup():getID() then
self:T( "Normal logic" )
self:T( self.ClientName .. " : group found!" )
self:T3( "Normal logic" )
self:T3( self.ClientName .. " : group found!" )
return ClientGroup
end
else
-- Now we need to resolve the bugs in DCS 1.5 ...
-- Consult the database for the units of the Client Group. (ClientGroup:getUnits() returns nil)
self:T( "Bug 1.5 logic" )
self:T3( "Bug 1.5 logic" )
local ClientUnits = _Database.Groups[self.ClientName].Units
self:T( { ClientUnits[1].name, env.getValueDictByKey(ClientUnits[1].name) } )
self:T3( { ClientUnits[1].name, env.getValueDictByKey(ClientUnits[1].name) } )
for ClientUnitID, ClientUnitData in pairs( ClientUnits ) do
self:T( { tonumber(UnitData:getID()), ClientUnitData.unitId } )
self:T3( { tonumber(UnitData:getID()), ClientUnitData.unitId } )
if tonumber(UnitData:getID()) == ClientUnitData.unitId then
local ClientGroupTemplate = _Database.Groups[self.ClientName].Template
self.ClientID = ClientGroupTemplate.groupId
self.ClientGroupUnit = UnitData
self:T( self.ClientName .. " : group found in bug 1.5 resolvement logic!" )
self:T3( self.ClientName .. " : group found in bug 1.5 resolvement logic!" )
return ClientGroup
end
end
@ -121,10 +121,10 @@ function CLIENT:GetDCSGroup()
-- For non player clients
local ClientGroup = Group.getByName( self.ClientName )
if ClientGroup then
self:T( "ClientGroup = " .. self.ClientName )
self:T3( "ClientGroup = " .. self.ClientName )
if ClientGroup:isExist() then
self:T( "Normal logic" )
self:T( self.ClientName .. " : group found!" )
self:T3( "Normal logic" )
self:T3( self.ClientName .. " : group found!" )
return ClientGroup
end
end
@ -171,7 +171,7 @@ end
--- Returns the Unit of the @{CLIENT}.
-- @return Unit
function CLIENT:GetClientGroupUnit()
self:T()
self:F()
local ClientGroup = self:GetDCSGroup()
@ -185,7 +185,7 @@ end
--- Returns the DCSUnit of the @{CLIENT}.
-- @return DCSUnit
function CLIENT:GetClientGroupDCSUnit()
self:T()
self:F2()
local ClientGroup = self:GetDCSGroup()
@ -197,7 +197,7 @@ function CLIENT:GetClientGroupDCSUnit()
end
function CLIENT:GetUnit()
self:T()
self:F()
return UNIT:New( self:GetClientGroupDCSUnit() )
end
@ -205,7 +205,7 @@ end
--- Returns the Point of the @{CLIENT}.
-- @return DCSTypes#Vec2
function CLIENT:GetPointVec2()
self:T()
self:F()
ClientGroupUnit = self:GetClientGroupDCSUnit()
@ -227,7 +227,7 @@ end
--- Returns the Position of the @{CLIENT}.
-- @return DCSTypes#Position
function CLIENT:ClientPosition()
self:T()
self:F()
ClientGroupUnit = self:GetClientGroupDCSUnit()
@ -243,7 +243,7 @@ end
--- Returns the altitude of the @{CLIENT}.
-- @return DCSTypes#Distance
function CLIENT:GetAltitude()
self:T()
self:F()
ClientGroupUnit = self:GetClientGroupDCSUnit()
@ -261,7 +261,7 @@ end
--- Transport defines that the Client is a Transport.
-- @return CLIENT
function CLIENT:Transport()
self:T()
self:F()
self.ClientTransport = true
return self
@ -271,7 +271,7 @@ end
-- @param string ClientBriefing is the text defining the Mission briefing.
-- @return CLIENT
function CLIENT:AddBriefing( ClientBriefing )
self:T()
self:F()
self.ClientBriefing = ClientBriefing
return self
end
@ -279,14 +279,14 @@ end
--- IsTransport returns if a Client is a transport.
-- @return bool
function CLIENT:IsTransport()
self:T()
self:F()
return self.ClientTransport
end
--- ShowCargo shows the @{CARGO} within the CLIENT to the Player.
-- The @{CARGO} is shown throught the MESSAGE system of DCS World.
function CLIENT:ShowCargo()
self:T()
self:F()
local CargoMsg = ""
@ -317,7 +317,7 @@ end
-- @param string MessageCategory is the category of the message (the title).
-- @param number MessageInterval is the interval in seconds between the display of the Message when the CLIENT is in the air.
function CLIENT:Message( Message, MessageDuration, MessageId, MessageCategory, MessageInterval )
self:T()
self:F()
if not self.MenuMessages then
if self:GetClientGroupID() then

View File

@ -159,7 +159,7 @@ end
--- Set a status to a Group within the Database, this to check crossing events for example.
function DATABASE:SetStatusGroup( GroupName, Status )
self:T( Status )
self:F( Status )
self.Groups[GroupName].Status = Status
end
@ -167,7 +167,7 @@ end
--- Get a status to a Group within the Database, this to check crossing events for example.
function DATABASE:GetStatusGroup( GroupName )
self:T( Status )
self:F( Status )
if self.Groups[GroupName] then
return self.Groups[GroupName].Status
@ -320,7 +320,7 @@ end
--- Follows new players entering Clients within the DCSRTE.
function DATABASE:_FollowPlayers()
self:T( "_FollowPlayers" )
self:F( "_FollowPlayers" )
local ClientUnit = 0
local CoalitionsData = { AlivePlayersRed = coalition.getPlayers(coalition.side.RED), AlivePlayersBlue = coalition.getPlayers(coalition.side.BLUE) }
@ -343,7 +343,7 @@ end
--- Add a new player entering a Unit.
function DATABASE:_AddPlayerFromUnit( UnitData )
self:T( UnitData )
self:F( UnitData )
if UnitData:isExist() then
local UnitName = UnitData:getName()
@ -421,7 +421,7 @@ end
--- Registers Scores the players completing a Mission Task.
function DATABASE:_AddMissionTaskScore( PlayerUnit, MissionName, Score )
self:T( { PlayerUnit, MissionName, Score } )
self:F( { PlayerUnit, MissionName, Score } )
local PlayerName = PlayerUnit:getPlayerName()
@ -447,7 +447,7 @@ end
--- Registers Mission Scores for possible multiple players that contributed in the Mission.
function DATABASE:_AddMissionScore( MissionName, Score )
self:T( { PlayerUnit, MissionName, Score } )
self:F( { PlayerUnit, MissionName, Score } )
for PlayerName, PlayerData in pairs( self.Players ) do
@ -468,7 +468,7 @@ end
function DATABASE:OnHit( event )
self:T( { event } )
self:F( { event } )
local InitUnit = nil
local InitUnitName = ""

View File

@ -18,7 +18,7 @@ DEPLOYTASK = {
-- @return #DEPLOYTASK The created DeployTask
function DEPLOYTASK:New( CargoType )
local self = BASE:Inherit( self, TASK:New() )
self:T()
self:F()
local Valid = true
@ -35,7 +35,7 @@ function DEPLOYTASK:New( CargoType )
end
function DEPLOYTASK:ToZone( LandingZone )
self:T()
self:F()
self.LandingZones.LandingZoneNames[LandingZone.CargoZoneName] = LandingZone.CargoZoneName
self.LandingZones.LandingZones[LandingZone.CargoZoneName] = LandingZone
@ -45,7 +45,7 @@ end
function DEPLOYTASK:InitCargo( InitCargos )
self:T( { InitCargos } )
self:F( { InitCargos } )
if type( InitCargos ) == "table" then
self.Cargos.InitCargos = InitCargos
@ -58,7 +58,7 @@ end
function DEPLOYTASK:LoadCargo( LoadCargos )
self:T( { LoadCargos } )
self:F( { LoadCargos } )
if type( LoadCargos ) == "table" then
self.Cargos.LoadCargos = LoadCargos
@ -73,7 +73,7 @@ end
--- When the cargo is unloaded, it will move to the target zone name.
-- @param string TargetZoneName Name of the Zone to where the Cargo should move after unloading.
function DEPLOYTASK:SetCargoTargetZoneName( TargetZoneName )
self:T()
self:F()
local Valid = true
@ -88,15 +88,15 @@ self:T()
end
function DEPLOYTASK:AddCargoMenus( Client, Cargos, TransportRadius )
self:T()
self:F()
local ClientGroupID = Client:GetClientGroupID()
trace.i( self.ClassName, ClientGroupID )
self:T( ClientGroupID )
for CargoID, Cargo in pairs( Cargos ) do
trace.i( self.ClassName, { Cargo.ClassName, Cargo.CargoName, Cargo.CargoType, Cargo.CargoWeight } )
self:T( { Cargo.ClassName, Cargo.CargoName, Cargo.CargoType, Cargo.CargoWeight } )
if Cargo:IsStatusLoaded() and Client == Cargo:IsLoadedInClient() then
@ -110,7 +110,7 @@ self:T()
self.TEXT[1] .. " " .. Cargo.CargoType,
nil
)
trace.i( self.ClassName, 'Added DeployMenu ' .. self.TEXT[1] )
self:T( 'Added DeployMenu ' .. self.TEXT[1] )
end
if Client._Menus[Cargo.CargoType].DeploySubMenus == nil then
@ -118,7 +118,7 @@ self:T()
end
if Client._Menus[Cargo.CargoType].DeployMenu == nil then
trace.i( self.ClassName, 'deploymenu is nil' )
self:T( 'deploymenu is nil' )
end
Client._Menus[Cargo.CargoType].DeploySubMenus[ #Client._Menus[Cargo.CargoType].DeploySubMenus + 1 ] = missionCommands.addCommandForGroup(
@ -128,29 +128,29 @@ self:T()
self.MenuAction,
{ ReferenceTask = self, CargoTask = Cargo }
)
trace.i( self.ClassName, 'Added DeploySubMenu ' .. Cargo.CargoType .. ":" .. Cargo.CargoName .. " ( " .. Cargo.CargoWeight .. "kg )" )
self:T( 'Added DeploySubMenu ' .. Cargo.CargoType .. ":" .. Cargo.CargoName .. " ( " .. Cargo.CargoWeight .. "kg )" )
end
end
end
function DEPLOYTASK:RemoveCargoMenus( Client )
self:T()
self:F()
local ClientGroupID = Client:GetClientGroupID()
trace.i( self.ClassName, ClientGroupID )
self:T( ClientGroupID )
for MenuID, MenuData in pairs( Client._Menus ) do
if MenuData.DeploySubMenus ~= nil then
for SubMenuID, SubMenuData in pairs( MenuData.DeploySubMenus ) do
missionCommands.removeItemForGroup( ClientGroupID, SubMenuData )
trace.i( self.ClassName, "Removed DeploySubMenu " )
self:T( "Removed DeploySubMenu " )
SubMenuData = nil
end
end
if MenuData.DeployMenu then
missionCommands.removeItemForGroup( ClientGroupID, MenuData.DeployMenu )
trace.i( self.ClassName, "Removed DeployMenu " )
self:T( "Removed DeployMenu " )
MenuData.DeployMenu = nil
end
end

View File

@ -23,7 +23,7 @@ DESTROYBASETASK = {
-- @return DESTROYBASETASK
function DESTROYBASETASK:New( DestroyGroupType, DestroyUnitType, DestroyGroupPrefixes, DestroyPercentage )
local self = BASE:Inherit( self, TASK:New() )
self:T()
self:F()
self.Name = 'Destroy'
self.Destroyed = 0
@ -45,7 +45,7 @@ end
--- Handle the S_EVENT_DEAD events to validate the destruction of units for the task monitoring.
-- @param event Event structure of DCS world.
function DESTROYBASETASK:EventDead( event )
self:T( { 'EventDead', event } )
self:F( { 'EventDead', event } )
if event.initiator and Object.getCategory(event.initiator) == Object.Category.UNIT then
local DestroyUnit = event.initiator
@ -76,7 +76,7 @@ end
-- @param DestroyGroup Group structure describing the group to be evaluated.
-- @param DestroyUnit Unit structure describing the Unit to be evaluated.
function DESTROYBASETASK:ReportGoalProgress( DestroyGroup, DestroyUnit )
self:T()
self:F()
return 0
end

View File

@ -17,27 +17,25 @@ DESTROYGROUPSTASK = {
-- @param ?number DestroyPercentage defines the %-tage that needs to be destroyed to achieve mission success. eg. If in the Group there are 10 units, then a value of 75 would require 8 units to be destroyed from the Group to complete the @{TASK}.
---@return DESTROYGROUPSTASK
function DESTROYGROUPSTASK:New( DestroyGroupType, DestroyUnitType, DestroyGroupNames, DestroyPercentage )
trace.f(self.ClassName)
-- Inheritance
local Child = BASE:Inherit( self, DESTROYBASETASK:New( DestroyGroupType, DestroyUnitType, DestroyGroupNames, DestroyPercentage ) )
Child.Name = 'Destroy Groups'
Child.GoalVerb = "Destroy " .. DestroyGroupType
local self = BASE:Inherit( self, DESTROYBASETASK:New( DestroyGroupType, DestroyUnitType, DestroyGroupNames, DestroyPercentage ) )
self:F()
self.Name = 'Destroy Groups'
self.GoalVerb = "Destroy " .. DestroyGroupType
Child.AddEvent( Child, world.event.S_EVENT_DEAD, Child.EventDead )
Child.AddEvent( Child, world.event.S_EVENT_CRASH, Child.EventDead )
self:AddEvent( world.event.S_EVENT_DEAD, self.EventDead )
self:AddEvent( world.event.S_EVENT_CRASH, self.EventDead )
--Child.AddEvent( Child, world.event.S_EVENT_PILOT_DEAD, Child.EventDead )
return Child
return self
end
--- Report Goal Progress.
-- @param Group DestroyGroup Group structure describing the group to be evaluated.
-- @param Unit DestroyUnit Unit structure describing the Unit to be evaluated.
function DESTROYGROUPSTASK:ReportGoalProgress( DestroyGroup, DestroyUnit )
trace.f(self.ClassName)
trace.i( self.ClassName, DestroyGroup:getSize() )
self:F( { DestroyGroup, DestroyUnit } )
self:T( DestroyGroup:getSize() )
local DestroyCount = 0
if DestroyGroup then

View File

@ -14,29 +14,26 @@ DESTROYRADARSTASK = {
-- @param table{string,...} DestroyGroupNames Table of string containing the group names of which the radars are be destroyed.
-- @return DESTROYRADARSTASK
function DESTROYRADARSTASK:New( DestroyGroupNames )
trace.f(self.ClassName)
-- Inheritance
local Child = BASE:Inherit( self, DESTROYGROUPSTASK:New( 'radar installations', 'radars', DestroyGroupNames ) )
Child.Name = 'Destroy Radars'
local self = BASE:Inherit( self, DESTROYGROUPSTASK:New( 'radar installations', 'radars', DestroyGroupNames ) )
self:F()
self.Name = 'Destroy Radars'
Child.AddEvent( Child, world.event.S_EVENT_DEAD, Child.EventDead )
self:AddEvent( world.event.S_EVENT_DEAD, self.EventDead )
return Child
return self
end
--- Report Goal Progress.
-- @param Group DestroyGroup Group structure describing the group to be evaluated.
-- @param Unit DestroyUnit Unit structure describing the Unit to be evaluated.
function DESTROYRADARSTASK:ReportGoalProgress( DestroyGroup, DestroyUnit )
trace.f(self.ClassName)
self:F( { DestroyGroup, DestroyUnit } )
local DestroyCount = 0
if DestroyUnit and DestroyUnit:hasSensors( Unit.SensorType.RADAR, Unit.RadarType.AS ) then
if DestroyUnit and DestroyUnit:getLife() <= 1.0 then
trace.i( self.ClassName, 'Destroyed a radar' )
self:T( 'Destroyed a radar' )
DestroyCount = 1
end
end

View File

@ -17,33 +17,28 @@ DESTROYUNITTYPESTASK = {
-- @param string DestroyUnitTypes Table of string containing the type names of the units to achieve mission success.
-- @return DESTROYUNITTYPESTASK
function DESTROYUNITTYPESTASK:New( DestroyGroupType, DestroyUnitType, DestroyGroupNames, DestroyUnitTypes )
trace.f(self.ClassName)
-- Inheritance
local Child = BASE:Inherit( self, DESTROYBASETASK:New( DestroyGroupType, DestroyUnitType, DestroyGroupNames ) )
local self = BASE:Inherit( self, DESTROYBASETASK:New( DestroyGroupType, DestroyUnitType, DestroyGroupNames ) )
self:F( { DestroyGroupType, DestroyUnitType, DestroyGroupNames, DestroyUnitTypes } )
if type(DestroyUnitTypes) == 'table' then
Child.DestroyUnitTypes = DestroyUnitTypes
self.DestroyUnitTypes = DestroyUnitTypes
else
Child.DestroyUnitTypes = { DestroyUnitTypes }
self.DestroyUnitTypes = { DestroyUnitTypes }
end
Child.Name = 'Destroy Unit Types'
Child.GoalVerb = "Destroy " .. DestroyGroupType
self.Name = 'Destroy Unit Types'
self.GoalVerb = "Destroy " .. DestroyGroupType
--env.info( 'New Types Child = ' .. tostring(Child) )
--env.info( 'New Types self = ' .. tostring(self) )
self:AddEvent( world.event.S_EVENT_DEAD, self.EventDead )
Child.AddEvent( Child, world.event.S_EVENT_DEAD, Child.EventDead )
return Child
return self
end
--- Report Goal Progress.
-- @param Group DestroyGroup Group structure describing the group to be evaluated.
-- @param Unit DestroyUnit Unit structure describing the Unit to be evaluated.
function DESTROYUNITTYPESTASK:ReportGoalProgress( DestroyGroup, DestroyUnit )
trace.f(self.ClassName)
self:F( { DestroyGroup, DestroyUnit } )
local DestroyCount = 0
for UnitTypeID, UnitType in pairs( self.DestroyUnitTypes ) do

View File

@ -43,7 +43,7 @@ ESCORT = {
-- @return #ESCORT self
function ESCORT:New( EscortClient, EscortGroup, EscortName )
local self = BASE:Inherit( self, BASE:New() )
self:T( { EscortClient, EscortGroup, EscortName } )
self:F( { EscortClient, EscortGroup, EscortName } )
self.EscortClient = EscortClient
self.EscortGroup = EscortGroup
@ -99,8 +99,8 @@ function ESCORT._HoldPosition( MenuParam )
local EscortGroup = MenuParam.ParamSelf.EscortGroup
local EscortClient = MenuParam.ParamSelf.EscortClient
EscortGroup:PushTask( EscortGroup:HoldPosition( 300 ) )
MESSAGE:New( "Holding Position at ... for 5 minutes.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/HoldPosition" ):ToClient( MenuParam.ParamSelf.EscortClient )
EscortGroup:PushTask( EscortGroup:TaskHoldPosition( 300 ) )
MESSAGE:New( "Holding Position at ... for 5 minutes.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/TaskHoldPosition" ):ToClient( EscortClient )
end
--- @param #MENUPARAM MenuParam
@ -109,7 +109,7 @@ function ESCORT._HoldPositionNearBy( MenuParam )
local EscortGroup = MenuParam.ParamSelf.EscortGroup
local EscortClient = MenuParam.ParamSelf.EscortClient
--MenuParam.ParamSelf.EscortGroup:OrbitCircleAtVec2( MenuParam.ParamSelf.EscortClient:GetPointVec2(), 300, 30, 0 )
--MenuParam.ParamSelf.EscortGroup:TaskOrbitCircleAtVec2( MenuParam.ParamSelf.EscortClient:GetPointVec2(), 300, 30, 0 )
local PointFrom = {}
local GroupPoint = EscortGroup:GetPointVec2()
@ -129,13 +129,13 @@ function ESCORT._HoldPositionNearBy( MenuParam )
PointTo.type = AI.Task.WaypointType.TURNING_POINT
PointTo.alt = EscortClient:GetAltitude()
PointTo.alt_type = AI.Task.AltitudeType.BARO
PointTo.task = EscortGroup:OrbitCircleAtVec2( EscortClient:GetPointVec2(), 300, 30, 0 )
PointTo.task = EscortGroup:TaskOrbitCircleAtVec2( EscortClient:GetPointVec2(), 300, 30, 0 )
local Points = { PointFrom, PointTo }
EscortGroup:PushTask( EscortGroup:TaskMission( Points ) )
MESSAGE:New( "Rejoining to your location. Please hold at your location.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/HoldPositionNearBy" ):ToClient( MenuParam.ParamSelf.EscortClient )
MESSAGE:New( "Rejoining to your location. Please hold at your location.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/HoldPositionNearBy" ):ToClient( EscortClient )
end
function ESCORT._ReportNearbyTargets( MenuParam )
@ -152,8 +152,13 @@ function ESCORT._ScanTargets30Seconds( MenuParam )
local EscortGroup = MenuParam.ParamSelf.EscortGroup
local EscortClient = MenuParam.ParamSelf.EscortClient
EscortGroup:PushTask( EscortGroup:OrbitCircle( 30, 200, 20 ) )
MESSAGE:New( "Scanning targets for 30 seconds.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/ScanTargets30Seconds" ):ToClient( MenuParam.ParamSelf.EscortClient )
EscortGroup:PushTask(
EscortGroup:TaskControlled(
EscortGroup:TaskOrbitCircle( 200, 20 ),
EscortGroup:TaskCondition( nil, nil, nil, nil, 30, nil )
)
)
MESSAGE:New( "Scanning targets for 30 seconds.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/ScanTargets30Seconds" ):ToClient( EscortClient )
end
--- @param #MENUPARAM MenuParam
@ -163,8 +168,13 @@ function ESCORT._ScanTargets60Seconds( MenuParam )
local EscortGroup = MenuParam.ParamSelf.EscortGroup
local EscortClient = MenuParam.ParamSelf.EscortClient
EscortGroup:PushTask( EscortGroup:OrbitCircle( 60, 200, 20 ) )
MESSAGE:New( "Scanning targets for 60 seconds.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/ScanTargets60Seconds" ):ToClient( MenuParam.ParamSelf.EscortClient )
EscortGroup:PushTask(
EscortGroup:TaskControlled(
EscortGroup:TaskOrbitCircle( 200, 20 ),
EscortGroup:TaskCondition( nil, nil, nil, nil, 60, nil )
)
)
MESSAGE:New( "Scanning targets for 60 seconds.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/ScanTargets60Seconds" ):ToClient( EscortClient )
end
--- @param #MENUPARAM MenuParam
@ -172,9 +182,12 @@ function ESCORT._AttackTarget( MenuParam )
local EscortGroup = MenuParam.ParamSelf.EscortGroup
local EscortClient = MenuParam.ParamSelf.EscortClient
MenuParam.ParamSelf.EscortGroup:AttackUnit( MenuParam.ParamUnit )
MESSAGE:New( "Attacking Unit", MenuParam.ParamSelf.EscortName, 10, "ESCORT/AttackTarget" ):ToClient( MenuParam.ParamSelf.EscortClient )
local AttackUnit = MenuParam.ParamUnit
EscortGroup:OpenFire()
EscortGroup:EvasionVertical()
EscortGroup:PushTask( EscortGroup:TaskAttackUnit( AttackUnit ) )
MESSAGE:New( "Attacking Unit", MenuParam.ParamSelf.EscortName, 10, "ESCORT/AttackTarget" ):ToClient( EscortClient )
end
--- @param #MENUPARAM MenuParam
@ -183,8 +196,8 @@ function ESCORT._ROEHoldFire( MenuParam )
local EscortGroup = MenuParam.ParamSelf.EscortGroup
local EscortClient = MenuParam.ParamSelf.EscortClient
MenuParam.ParamSelf.EscortGroup:HoldFire()
MESSAGE:New( "Holding weapons.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/ROEHoldFire" ):ToClient( MenuParam.ParamSelf.EscortClient )
EscortGroup:HoldFire()
MESSAGE:New( "Holding weapons.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/ROEHoldFire" ):ToClient( EscortClient )
end
--- @param #MENUPARAM MenuParam
@ -193,8 +206,8 @@ function ESCORT._ROEReturnFire( MenuParam )
local EscortGroup = MenuParam.ParamSelf.EscortGroup
local EscortClient = MenuParam.ParamSelf.EscortClient
MenuParam.ParamSelf.EscortGroup:ReturnFire()
MESSAGE:New( "Returning enemy fire.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/ROEReturnFire" ):ToClient( MenuParam.ParamSelf.EscortClient )
EscortGroup:ReturnFire()
MESSAGE:New( "Returning enemy fire.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/ROEReturnFire" ):ToClient( EscortClient )
end
--- @param #MENUPARAM MenuParam
@ -203,8 +216,8 @@ function ESCORT._ROEOpenFire( MenuParam )
local EscortGroup = MenuParam.ParamSelf.EscortGroup
local EscortClient = MenuParam.ParamSelf.EscortClient
MenuParam.ParamSelf.EscortGroup:OpenFire()
MESSAGE:New( "Open fire on ordered targets.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/ROEOpenFire" ):ToClient( MenuParam.ParamSelf.EscortClient )
EscortGroup:OpenFire()
MESSAGE:New( "Open fire on ordered targets.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/ROEOpenFire" ):ToClient( EscortClient )
end
--- @param #MENUPARAM MenuParam
@ -213,8 +226,8 @@ function ESCORT._ROEWeaponFree( MenuParam )
local EscortGroup = MenuParam.ParamSelf.EscortGroup
local EscortClient = MenuParam.ParamSelf.EscortClient
MenuParam.ParamSelf.EscortGroup:WeaponFree()
MESSAGE:New( "Engaging targets.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/ROEWeaponFree" ):ToClient( MenuParam.ParamSelf.EscortClient )
EscortGroup:WeaponFree()
MESSAGE:New( "Engaging targets.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/ROEWeaponFree" ):ToClient( EscortClient )
end
--- @param #MENUPARAM MenuParam
@ -223,8 +236,8 @@ function ESCORT._EvasionNoReaction( MenuParam )
local EscortGroup = MenuParam.ParamSelf.EscortGroup
local EscortClient = MenuParam.ParamSelf.EscortClient
MenuParam.ParamSelf.EscortGroup:EvasionNoReaction()
MESSAGE:New( "We'll fight until death.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/EvasionNoReaction" ):ToClient( MenuParam.ParamSelf.EscortClient )
EscortGroup:EvasionNoReaction()
MESSAGE:New( "We'll fight until death.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/EvasionNoReaction" ):ToClient( EscortClient )
end
--- @param #MENUPARAM MenuParam
@ -233,8 +246,8 @@ function ESCORT._EvasionPassiveDefense( MenuParam )
local EscortGroup = MenuParam.ParamSelf.EscortGroup
local EscortClient = MenuParam.ParamSelf.EscortClient
MenuParam.ParamSelf.EscortGroup:EvasionPassiveDefense()
MESSAGE:New( "We will use flares, chaff and jammers.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/EvasionPassiveDefense" ):ToClient( MenuParam.ParamSelf.EscortClient )
EscortGroup:EvasionPassiveDefense()
MESSAGE:New( "We will use flares, chaff and jammers.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/EvasionPassiveDefense" ):ToClient( EscortClient )
end
--- @param #MENUPARAM MenuParam
@ -243,8 +256,8 @@ function ESCORT._EvasionEvadeFire( MenuParam )
local EscortGroup = MenuParam.ParamSelf.EscortGroup
local EscortClient = MenuParam.ParamSelf.EscortClient
MenuParam.ParamSelf.EscortGroup:EvasionEvadeFire()
MESSAGE:New( "We'll evade enemy fire.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/EvasionEvadeFire" ):ToClient( MenuParam.ParamSelf.EscortClient )
EscortGroup:EvasionEvadeFire()
MESSAGE:New( "We'll evade enemy fire.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/EvasionEvadeFire" ):ToClient( EscortClient )
end
--- @param #MENUPARAM MenuParam
@ -253,8 +266,8 @@ function ESCORT._EvasionVertical( MenuParam )
local EscortGroup = MenuParam.ParamSelf.EscortGroup
local EscortClient = MenuParam.ParamSelf.EscortClient
MenuParam.ParamSelf.EscortGroup:EvasionVertical()
MESSAGE:New( "We'll perform vertical evasive manoeuvres.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/EvasionVertical" ):ToClient( MenuParam.ParamSelf.EscortClient )
EscortGroup:EvasionVertical()
MESSAGE:New( "We'll perform vertical evasive manoeuvres.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/EvasionVertical" ):ToClient( EscortClient )
end
--- @param #MENUPARAM MenuParam
@ -264,12 +277,12 @@ function ESCORT._CancelCurrentTask( MenuParam )
local EscortClient = MenuParam.ParamSelf.EscortClient
EscortGroup:PopCurrentTask()
MESSAGE:New( "Cancelling with current orders, continuing our mission.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/CancelCurrentTask" ):ToClient( MenuParam.ParamSelf.EscortClient )
MESSAGE:New( "Cancelling with current orders, continuing our mission.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/CancelCurrentTask" ):ToClient( EscortClient )
end
function ESCORT:_ScanForTargets()
self:T()
self:F()
self.Targets = {}

View File

@ -13,26 +13,23 @@ GOHOMETASK = {
-- @param table{string,...}|string LandingZones Table of Landing Zone names where Home(s) are located.
-- @return GOHOMETASK
function GOHOMETASK:New( LandingZones )
trace.f(self.ClassName)
-- Child holds the inherited instance of the PICKUPTASK Class to the BASE class.
local Child = BASE:Inherit( self, TASK:New() )
local self = BASE:Inherit( self, TASK:New() )
self:F( { LandingZones } )
local Valid = true
Valid = routines.ValidateZone( LandingZones, "LandingZones", Valid )
if Valid then
Child.Name = 'Fly Home'
Child.TaskBriefing = "Task: Fly back to your home base. Your co-pilot will provide you with the directions (required flight angle in degrees) and the distance (in km) to your home base."
self.Name = 'Fly Home'
self.TaskBriefing = "Task: Fly back to your home base. Your co-pilot will provide you with the directions (required flight angle in degrees) and the distance (in km) to your home base."
if type( LandingZones ) == "table" then
Child.LandingZones = LandingZones
self.LandingZones = LandingZones
else
Child.LandingZones = { LandingZones }
self.LandingZones = { LandingZones }
end
Child.Stages = { STAGEBRIEF:New(), STAGESTART:New(), STAGEROUTE:New(), STAGEARRIVE:New(), STAGEDONE:New() }
Child.SetStage( Child, 1 )
self.Stages = { STAGEBRIEF:New(), STAGESTART:New(), STAGEROUTE:New(), STAGEARRIVE:New(), STAGEDONE:New() }
self.SetStage( self, 1 )
end
return Child
return self
end

View File

@ -10,7 +10,7 @@ Include.File( "Unit" )
--- The GROUP class
-- @type GROUP
-- @extends Base#BASE
-- @field #Group DCSGroup The DCS group class.
-- @field DCSGroup#Group DCSGroup The DCS group class.
-- @field #string GroupName The name of the group.
-- @field #number GroupID the ID of the group.
-- @field #table Controller The controller of the group.
@ -19,21 +19,22 @@ GROUP = {
GroupName = "",
GroupID = 0,
Controller = nil,
DCSGroup = nil,
}
--- A DCSGroup
-- @type Group
-- @type DCSGroup
-- @field id_ The ID of the group in DCS
GROUPS = {}
--- Create a new GROUP from a DCSGroup
-- @param self
-- @param #Group DCSGroup The DCS Group
-- @param DCSGroup#Group DCSGroup The DCS Group
-- @return #GROUP self
function GROUP:New( DCSGroup )
local self = BASE:Inherit( self, BASE:New() )
self:T( DCSGroup )
self:F( DCSGroup )
self.DCSGroup = DCSGroup
if self.DCSGroup and self.DCSGroup:isExist() then
@ -54,7 +55,7 @@ end
-- @return #GROUP self
function GROUP:NewFromName( GroupName )
local self = BASE:Inherit( self, BASE:New() )
self:T( GroupName )
self:F( GroupName )
self.DCSGroup = Group.getByName( GroupName )
if self.DCSGroup then
@ -72,7 +73,7 @@ end
-- @return #GROUP self
function GROUP:NewFromDCSUnit( DCSUnit )
local self = BASE:Inherit( self, BASE:New() )
self:T( DCSUnit )
self:F( DCSUnit )
self.DCSGroup = DCSUnit:getGroup()
if self.DCSGroup then
@ -88,7 +89,7 @@ end
-- @param self
-- @return #Group The DCSGroup.
function GROUP:GetDCSGroup()
self:T( { self.GroupName } )
self:F( { self.GroupName } )
self.DCSGroup = Group.getByName( self.GroupName )
return self.DCSGroup
end
@ -100,7 +101,7 @@ end
-- @param #number UnitNumber The unit index to be returned from the GROUP.
-- @return #Unit The DCS Unit.
function GROUP:GetDCSUnit( UnitNumber )
self:T( { self.GroupName, UnitNumber } )
self:F( { self.GroupName, UnitNumber } )
return self.DCSGroup:getUnit( UnitNumber )
end
@ -108,7 +109,7 @@ end
--- Activates a GROUP.
-- @param self
function GROUP:Activate()
self:T( { self.GroupName } )
self:F( { self.GroupName } )
trigger.action.activateGroup( self:GetDCSGroup() )
return self:GetDCSGroup()
end
@ -117,7 +118,7 @@ end
-- @param self
-- @return #number The ID of the GROUP.
function GROUP:GetID()
self:T( self.GroupName )
self:F( self.GroupName )
return self.GroupID
end
@ -126,15 +127,35 @@ end
-- @param self
-- @return #string The name of the GROUP.
function GROUP:GetName()
self:T( self.GroupName )
self:F( self.GroupName )
return self.GroupName
end
--- Gets the type name of the group.
-- @param #GROUP self
-- @return #string The type name of the group.
function GROUP:GetTypeName()
self:F( self.GroupName )
return self.DCSGroup:getUnit(1):getTypeName()
end
--- Gets the callsign of the fist unit of the group.
-- @param #GROUP self
-- @return #string The callsign of the first unit of the group.
function GROUP:GetCallsign()
self:F( self.GroupName )
return self.DCSGroup:getUnit(1):getCallsign()
end
--- Gets the current Point of the GROUP in VEC3 format.
-- @return #Vec3 Current x,y and z position of the group.
function GROUP:GetPointVec2()
self:T( self.GroupName )
self:F( self.GroupName )
local GroupPoint = self:GetUnit(1):GetPointVec2()
self:T( GroupPoint )
@ -144,7 +165,7 @@ end
--- Gets the current Point of the GROUP in VEC2 format.
-- @return #Vec2 Current x and y position of the group in the 2D plane.
function GROUP:GetPointVec2()
self:T( self.GroupName )
self:F( self.GroupName )
local GroupPoint = self:GetUnit(1):GetPointVec2()
self:T( GroupPoint )
@ -154,7 +175,7 @@ end
--- Gets the current Point of the GROUP in VEC3 format.
-- @return #Vec3 Current Vec3 position of the group.
function GROUP:GetPositionVec3()
self:T( self.GroupName )
self:F( self.GroupName )
local GroupPoint = self:GetUnit(1):GetPositionVec3()
self:T( GroupPoint )
@ -166,7 +187,7 @@ end
-- So all event listeners will catch the destroy event of this GROUP.
-- @param self
function GROUP:Destroy()
self:T( self.GroupName )
self:F( self.GroupName )
for Index, UnitData in pairs( self.DCSGroup:getUnits() ) do
self:CreateEventCrash( timer.getTime(), UnitData )
@ -182,7 +203,7 @@ end
-- @param #number UnitNumber The number of the Unit to be returned.
-- @return #Unit The DCS Unit.
function GROUP:GetUnit( UnitNumber )
self:T( { self.GroupName, UnitNumber } )
self:F( { self.GroupName, UnitNumber } )
return UNIT:New( self.DCSGroup:getUnit( UnitNumber ) )
end
@ -191,7 +212,7 @@ end
-- @param self
-- @return #boolean Air category evaluation result.
function GROUP:IsAir()
self:T()
self:F()
local IsAirResult = self.DCSGroup:getCategory() == Group.Category.AIRPLANE or self.DCSGroup:getCategory() == Group.Category.HELICOPTER
@ -204,7 +225,7 @@ end
-- @param self
-- @return #boolean Alive result.
function GROUP:IsAlive()
self:T()
self:F()
local IsAliveResult = self.DCSGroup and self.DCSGroup:isExist()
@ -217,7 +238,7 @@ end
-- @param self
-- @return #boolean All units on the ground result.
function GROUP:AllOnGround()
self:T()
self:F()
local AllOnGroundResult = true
@ -233,10 +254,10 @@ end
--- Returns the current maximum velocity of the group.
-- Each unit within the group gets evaluated, and the maximum velocity (= the unit which is going the fastest) is returned.
-- @param self
-- @param #GROUP self
-- @return #number Maximum velocity found.
function GROUP:GetMaxVelocity()
self:T()
self:F()
local MaxVelocity = 0
@ -259,7 +280,7 @@ end
-- @param self
-- @return #number Minimum height found.
function GROUP:GetMinHeight()
self:T()
self:F()
end
@ -269,16 +290,17 @@ end
-- @param self
-- @return #number Maximum height found.
function GROUP:GetMaxHeight()
self:T()
self:F()
end
-- Tasks
--- Popping current Task from the group.
-- @param #GROUP self
-- @return Group#GROUP self
function GROUP:PopCurrentTask()
self:T()
self:F()
local Controller = self:_GetController()
@ -292,7 +314,7 @@ end
-- @param #GROUP self
-- @return Group#GROUP self
function GROUP:PushTask( DCSTask )
self:T()
self:F()
local Controller = self:_GetController()
@ -301,15 +323,60 @@ function GROUP:PushTask( DCSTask )
return self
end
--- Return a condition section for a controlled task
-- @param #GROUP self
-- @param #Time time
-- @param #string userFlag
-- @param #boolean userFlagValue
-- @param #string condition
-- @param #Time duration
-- @param #number lastWayPoint
-- return #DCSTask
function GROUP:TaskCondition( time, userFlag, userFlagValue, condition, duration, lastWayPoint )
self:F( { time, userFlag, userFlagValue, condition, duration, lastWayPoint } )
local DCSStopCondition = {}
DCSStopCondition.time = time
DCSStopCondition.userFlag = userFlag
DCSStopCondition.userFlagValue = userFlagValue
DCSStopCondition.condition = condition
DCSStopCondition.duration = duration
DCSStopCondition.lastWayPoint = lastWayPoint
self:T( { DCSStopCondition } )
return DCSStopCondition
end
--- Return a Controlled Task taking a Task and a TaskCondition
-- @param #GROUP self
-- @param #DCSTask DCSTask
-- @param #DCSStopCondition DCSStopCondition
-- @return #DCSTask
function GROUP:TaskControlled( DCSTask, DCSStopCondition )
self:F( { DCSTask, DCSStopCondition } )
local DCSTaskControlled
DCSTaskControlled = {
id = 'ControlledTask',
params = {
task = DCSTask,
stopCondition = DCSStopCondition,
}
}
self:T( { DCSTaskControlled } )
return DCSTaskControlled
end
--- Orbit at a specified position at a specified alititude during a specified duration with a specified speed.
-- @param #GROUP self
-- @param #Vec2 Point The point to hold the position.
-- @param #number Duration The maximum duration in seconds to hold the position.
-- @param #number Altitude The altitude to hold the position.
-- @param #number Speed The speed flying when holding the position.
-- @return #GROUP self
function GROUP:OrbitCircleAtVec2( Point, Duration, Altitude, Speed )
self:T( { self.GroupName, Point, Duration, Altitude, Speed } )
function GROUP:TaskOrbitCircleAtVec2( Point, Altitude, Speed )
self:F( { self.GroupName, Point, Altitude, Speed } )
-- pattern = enum AI.Task.OribtPattern,
-- point = Vec2,
@ -321,7 +388,7 @@ function GROUP:OrbitCircleAtVec2( Point, Duration, Altitude, Speed )
self:T( { LandHeight } )
local AITask = { id = 'Orbit',
local DCSTask = { id = 'Orbit',
params = { pattern = AI.Task.OrbitPattern.CIRCLE,
point = Point,
speed = Speed,
@ -344,21 +411,20 @@ function GROUP:OrbitCircleAtVec2( Point, Duration, Altitude, Speed )
-- }
-- )
return AITask
return DCSTask
end
--- Orbit at the current position of the first unit of the group at a specified alititude during a specified duration
--- Orbit at the current position of the first unit of the group at a specified alititude
-- @param #GROUP self
-- @param #number Duration The maximum duration in seconds to hold the position.
-- @param #number Altitude The altitude to hold the position.
-- @param #number Speed The speed flying when holding the position.
-- @return #GROUP self
function GROUP:OrbitCircle( Duration, Altitude, Speed )
self:T( { self.GroupName, Duration, Altitude, Speed } )
function GROUP:TaskOrbitCircle( Altitude, Speed )
self:F( { self.GroupName, Altitude, Speed } )
local GroupPoint = self:GetPointVec2()
return self:OrbitCircleAtVec2( GroupPoint, Duration, Altitude, Speed )
return self:TaskOrbitCircleAtVec2( GroupPoint, Altitude, Speed )
end
@ -367,41 +433,57 @@ end
-- @param #GROUP self
-- @param #number Duration The maximum duration in seconds to hold the position.
-- @return #GROUP self
function GROUP:HoldPosition( Duration )
self:T( { self.GroupName, Duration } )
function GROUP:TaskHoldPosition()
self:F( { self.GroupName } )
return self:OrbitCircle( Duration, 30, 0 )
return self:TaskOrbitCircle( 30, 10 )
end
--- Land the group at a Vec2Point.
-- @param self
-- @param #GROUP self
-- @param #Vec2 Point The point where to land.
-- @param #number Duration The duration in seconds to stay on the ground.
-- @return #GROUP self
function GROUP:Land( Point, Duration )
self:T( { self.GroupName, Point, Duration } )
function GROUP:TaskLandAtVec2( Point, Duration )
self:F( { self.GroupName, Point, Duration } )
local Controller = self:_GetController()
local DCSTask
if Duration and Duration > 0 then
Controller:pushTask( { id = 'Land', params = { point = Point, durationFlag = true, duration = Duration } } )
DCSTask = { id = 'Land', params = { point = Point, durationFlag = true, duration = Duration } }
else
Controller:pushTask( { id = 'Land', params = { point = Point, durationFlag = false } } )
DCSTask = { id = 'Land', params = { point = Point, durationFlag = false } }
end
return self
self:T( DCSTask )
return DCSTask
end
--- Attack the Unit.
-- @param self
-- @param #UNIT The unit.
--- Land the group at a @{Zone#ZONE).
-- @param #GROUP self
-- @param Zone#ZONE Zone The zone where to land.
-- @param #number Duration The duration in seconds to stay on the ground.
-- @return #GROUP self
function GROUP:AttackUnit( AttackUnit )
self:T( { self.GroupName, AttackUnit } )
function GROUP:TaskLandAtZone( Zone, Duration )
self:F( { self.GroupName, Zone, Duration } )
local Controller = self:_GetController()
local Point = Zone:GetPointVec2()
local DCSTask = self:TaskLandAtVec2( Point, Duration )
self:T( DCSTask )
return DCSTask
end
--- Attack the Unit.
-- @param #GROUP self
-- @param Unit#UNIT The unit.
-- @return #DCSTask The DCS task structure.
function GROUP:TaskAttackUnit( AttackUnit )
self:F( { self.GroupName, AttackUnit } )
-- AttackUnit = {
-- id = 'AttackUnit',
-- params = {
@ -413,187 +495,88 @@ function GROUP:AttackUnit( AttackUnit )
-- attackQtyLimit = boolean,
-- groupAttack = boolean,
-- }
-- }
Controller:setOption( AI.Option.Air.id.ROE, AI.Option.Air.val.ROE.OPEN_FIRE )
Controller:setOption( AI.Option.Air.id.REACTION_ON_THREAT, AI.Option.Air.val.REACTION_ON_THREAT.EVADE_FIRE )
Controller:pushTask( { id = 'AttackUnit',
params = { unitId = AttackUnit:GetID(),
expend = AI.Task.WeaponExpend.TWO,
groupAttack = true,
}
-- }
local DCSTask
DCSTask = { id = 'AttackUnit',
params = { unitId = AttackUnit:GetID(),
expend = AI.Task.WeaponExpend.TWO,
groupAttack = true,
}
)
return self
end
--- Holding weapons.
-- @param self
-- @return #GROUP self
function GROUP:HoldFire()
self:T( { self.GroupName } )
local Controller = self:_GetController()
}
Controller:setOption( AI.Option.Air.id.ROE, AI.Option.Air.val.ROE.WEAPON_HOLD )
self:T( { DCSTask } )
return self
end
--- Return fire.
-- @param self
-- @return #GROUP self
function GROUP:ReturnFire()
self:T( { self.GroupName } )
local Controller = self:_GetController()
Controller:setOption( AI.Option.Air.id.ROE, AI.Option.Air.val.ROE.RETURN_FIRE )
return self
end
--- Openfire.
-- @param self
-- @return #GROUP self
function GROUP:OpenFire()
self:T( { self.GroupName } )
local Controller = self:_GetController()
Controller:setOption( AI.Option.Air.id.ROE, AI.Option.Air.val.ROE.OPEN_FIRE )
return self
end
--- Weapon free.
-- @param self
-- @return #GROUP self
function GROUP:WeaponFree()
self:T( { self.GroupName } )
local Controller = self:_GetController()
Controller:setOption( AI.Option.Air.id.ROE, AI.Option.Air.val.ROE.WEAPON_FREE )
return self
end
--- No evasion on enemy threats.
-- @param self
-- @return #GROUP self
function GROUP:EvasionNoReaction()
self:T( { self.GroupName } )
local Controller = self:_GetController()
Controller:setOption( AI.Option.Air.id.REACTION_ON_THREAT, AI.Option.Air.val.REACTION_ON_THREAT.NO_REACTION )
return self
end
--- Evasion passive defense.
-- @param self
-- @return #GROUP self
function GROUP:EvasionPassiveDefense()
self:T( { self.GroupName } )
local Controller = self:_GetController()
Controller:setOption( AI.Option.Air.id.REACTION_ON_THREAT, AI.Option.Air.val.REACTION_ON_THREAT.PASSIVE_DEFENSE )
return self
end
--- Evade fire.
-- @param self
-- @return #GROUP self
function GROUP:EvasionEvadeFire()
self:T( { self.GroupName } )
local Controller = self:_GetController()
Controller:setOption( AI.Option.Air.id.REACTION_ON_THREAT, AI.Option.Air.val.REACTION_ON_THREAT.EVADE_FIRE )
return self
end
--- Vertical manoeuvres.
-- @param self
-- @return #GROUP self
function GROUP:EvasionVertical()
self:T( { self.GroupName } )
local Controller = self:_GetController()
Controller:setOption( AI.Option.Air.id.REACTION_ON_THREAT, AI.Option.Air.val.REACTION_ON_THREAT.BYPASS_AND_ESCAPE )
return self
end
--- Move the group to a Vec2 Point, wait for a defined duration and embark a group.
-- @param self
-- @param #GROUP self
-- @param #Vec2 Point The point where to wait.
-- @param #number Duration The duration in seconds to wait.
-- @param EmbarkingGroup The group to be embarked.
-- @return #GROUP self
function GROUP:Embarking( Point, Duration, EmbarkingGroup )
trace.f( self.ClassName, { self.GroupName, Point, Duration, EmbarkingGroup.DCSGroup } )
-- @param #GROUP EmbarkingGroup The group to be embarked.
-- @return #DCSTask The DCS task structure
function GROUP:TaskEmbarkingAtVec2( Point, Duration, EmbarkingGroup )
self:F( { self.GroupName, Point, Duration, EmbarkingGroup.DCSGroup } )
local Controller = self:_GetController()
local DCSTask
DCSTask = { id = 'Embarking',
params = { x = Point.x,
y = Point.y,
duration = Duration,
groupsForEmbarking = { EmbarkingGroup.GroupID },
durationFlag = true,
distributionFlag = false,
distribution = {},
}
}
trace.i( self.ClassName, EmbarkingGroup.GroupID )
trace.i( self.ClassName, EmbarkingGroup.DCSGroup:getID() )
trace.i( self.ClassName, EmbarkingGroup.DCSGroup.id )
Controller:pushTask( { id = 'Embarking',
params = { x = Point.x,
y = Point.y,
duration = Duration,
groupsForEmbarking = { EmbarkingGroup.GroupID },
durationFlag = true,
distributionFlag = false,
distribution = {},
}
}
)
return self
self:T( { DCSTask } )
return DCSTask
end
--- Move to a defined Vec2 Point, and embark to a group when arrived within a defined Radius.
-- @param self
-- @param #GROUP self
-- @param #Vec2 Point The point where to wait.
-- @param #number Radius The radius of the embarking zone around the Point.
-- @return #GROUP self
function GROUP:EmbarkToTransport( Point, Radius )
trace.f( self.ClassName, { self.GroupName, Point, Radius } )
-- @return #DCSTask The DCS task structure.
function GROUP:TaskEmbarkToTransportAtVec2( Point, Radius )
self:F( { self.GroupName, Point, Radius } )
local Controller = self:_GetController()
Controller:pushTask( { id = 'EmbarkToTransport',
params = { x = Point.x,
y = Point.y,
zoneRadius = Radius,
}
}
)
local DCSTask --#DCSTask
DCSTask = { id = 'EmbarkToTransport',
params = { x = Point.x,
y = Point.y,
zoneRadius = Radius,
}
}
return self
self:T( { DCSTask } )
return DCSTask
end
--- Return a Misson task to follow a given route.
-- @param self
-- @param #GROUP self
-- @param #table GoPoints A table of Route Points.
-- @return #DCSTask
function GROUP:TaskMission( Points )
self:T( Points )
self:F( Points )
local MissionTask = { id = 'Mission', params = { route = { points = Points, }, }, }
local DCSTask
DCSTask = { id = 'Mission', params = { route = { points = Points, }, }, }
return MissionTask
self:T( { DCSTask } )
return DCSTask
end
--- Make the group to follow a given route.
-- @param self
-- @param #GROUP self
-- @param #table GoPoints A table of Route Points.
-- @return #GROUP self
function GROUP:Route( GoPoints )
self:T( GoPoints )
self:F( GoPoints )
local Points = routines.utils.deepCopy( GoPoints )
local MissionTask = { id = 'Mission', params = { route = { points = Points, }, }, }
@ -609,13 +592,13 @@ end
-- The group final destination point can be randomized.
-- A speed can be given in km/h.
-- A given formation can be given.
-- @param self
-- @param ZONE#ZONE Zone The zone where to route to.
-- @param #GROUP self
-- @param Zone#ZONE Zone The zone where to route to.
-- @param #boolean Randomize Defines whether to target point gets randomized within the Zone.
-- @param #number Speed The speed.
-- @param BASE#FORMATION Formation The formation string.
function GROUP:RouteToZone( Zone, Randomize, Speed, Formation )
self:T( Zone )
-- @param Base#FORMATION Formation The formation string.
function GROUP:TaskRouteToZone( Zone, Randomize, Speed, Formation )
self:F( Zone )
local GroupPoint = self:GetPointVec2()
@ -661,14 +644,14 @@ function GROUP:RouteToZone( Zone, Randomize, Speed, Formation )
return self
end
--- Return the route of a group.
-- @param self
--- Return the route of a group by using the @{Database#DATABASE} class.
-- @param #GROUP self
-- @param #number Begin The route point from where the copy will start. The base route point is 0.
-- @param #number End The route point where the copy will end. The End point is the last point - the End point. The last point has base 0.
-- @param #boolean Randomize Randomization of the route, when true.
-- @param #number Radius When randomization is on, the randomization is within the radius.
function GROUP:CopyRoute( Begin, End, Randomize, Radius )
self:T( { Begin, End } )
self:F( { Begin, End } )
local Points = {}
@ -733,4 +716,161 @@ function GROUP:IsTargetDetected( DCSObject )
return TargetIsDetected, TargetIsVisible, TargetLastTime, TargetKnowType, TargetKnowDistance, TargetLastPos, TargetLastVelocity
end
end
-- Options
--- Holding weapons.
-- @param #GROUP self
-- @return #GROUP self
function GROUP:HoldFire()
self:F( { self.GroupName } )
local Controller = self:_GetController()
Controller:setOption( AI.Option.Air.id.ROE, AI.Option.Air.val.ROE.WEAPON_HOLD )
return self
end
--- Return fire.
-- @param #GROUP self
-- @return #GROUP self
function GROUP:ReturnFire()
self:F( { self.GroupName } )
local Controller = self:_GetController()
Controller:setOption( AI.Option.Air.id.ROE, AI.Option.Air.val.ROE.RETURN_FIRE )
return self
end
--- Openfire.
-- @param #GROUP self
-- @return #GROUP self
function GROUP:OpenFire()
self:F( { self.GroupName } )
local Controller = self:_GetController()
Controller:setOption( AI.Option.Air.id.ROE, AI.Option.Air.val.ROE.OPEN_FIRE )
return self
end
--- Weapon free.
-- @param #GROUP self
-- @return #GROUP self
function GROUP:WeaponFree()
self:F( { self.GroupName } )
local Controller = self:_GetController()
Controller:setOption( AI.Option.Air.id.ROE, AI.Option.Air.val.ROE.WEAPON_FREE )
return self
end
--- No evasion on enemy threats.
-- @param #GROUP self
-- @return #GROUP self
function GROUP:EvasionNoReaction()
self:F( { self.GroupName } )
local Controller = self:_GetController()
Controller:setOption( AI.Option.Air.id.REACTION_ON_THREAT, AI.Option.Air.val.REACTION_ON_THREAT.NO_REACTION )
return self
end
--- Evasion passive defense.
-- @param #GROUP self
-- @return #GROUP self
function GROUP:EvasionPassiveDefense()
self:F( { self.GroupName } )
local Controller = self:_GetController()
Controller:setOption( AI.Option.Air.id.REACTION_ON_THREAT, AI.Option.Air.val.REACTION_ON_THREAT.PASSIVE_DEFENSE )
return self
end
--- Evade fire.
-- @param #GROUP self
-- @return #GROUP self
function GROUP:EvasionEvadeFire()
self:F( { self.GroupName } )
local Controller = self:_GetController()
Controller:setOption( AI.Option.Air.id.REACTION_ON_THREAT, AI.Option.Air.val.REACTION_ON_THREAT.EVADE_FIRE )
return self
end
--- Vertical manoeuvres.
-- @param #GROUP self
-- @return #GROUP self
function GROUP:EvasionVertical()
self:F( { self.GroupName } )
local Controller = self:_GetController()
Controller:setOption( AI.Option.Air.id.REACTION_ON_THREAT, AI.Option.Air.val.REACTION_ON_THREAT.BYPASS_AND_ESCAPE )
return self
end
-- Message APIs
--- Returns a message for a coalition or a client.
-- @param #GROUP self
-- @param #string Message The message text
-- @param #Duration Duration The duration of the message.
-- @return Message#MESSAGE
function GROUP:Message( Message, Duration )
self:F( { Message, Duration } )
return MESSAGE:New( Message, self:GetCallsign() .. "(" .. self:GetTypeName() .. ")", Duration, self:GetClassNameAndID() )
end
--- Send a message to all coalitions.
-- The message will appear in the message area. The message will begin with the callsign of the group and the type of the first unit sending the message.
-- @param #GROUP self
-- @param #string Message The message text
-- @param #Duration Duration The duration of the message.
function GROUP:MessageToAll( Message, Duration )
self:F( { Message, Duration } )
self:Message( Message, Duration ):ToAll()
end
--- Send a message to the red coalition.
-- The message will appear in the message area. The message will begin with the callsign of the group and the type of the first unit sending the message.
-- @param #GROUP self
-- @param #string Message The message text
-- @param #Duration Duration The duration of the message.
function GROUP:MessageToRed( Message, Duration )
self:F( { Message, Duration } )
self:Message( Message, Duration ):ToRed()
end
--- Send a message to the blue coalition.
-- The message will appear in the message area. The message will begin with the callsign of the group and the type of the first unit sending the message.
-- @param #GROUP self
-- @param #string Message The message text
-- @param #Duration Duration The duration of the message.
function GROUP:MessageToBlue( Message, Duration )
self:F( { Message, Duration } )
self:Message( Message, Duration ):ToBlue()
end
--- Send a message to a client.
-- The message will appear in the message area. The message will begin with the callsign of the group and the type of the first unit sending the message.
-- @param #GROUP self
-- @param #string Message The message text
-- @param #Duration Duration The duration of the message.
-- @param Client#CLIENT Client The client object receiving the message.
function GROUP:MessageToClient( Message, Duration, Client )
self:F( { Message, Duration } )
self:Message( Message, Duration ):ToClient( Client )
end

View File

@ -6,13 +6,12 @@
-- Messages are sent to Clients with MESSAGE:@{ToClient}().
-- Messages are sent to Coalitions with MESSAGE:@{ToCoalition}().
-- Messages are sent to All Players with MESSAGE:@{ToAll}().
-- @module MESSAGE
-- @module Message
Include.File( "Trace" )
Include.File( "Base" )
--- The MESSAGE class
-- @type
-- @type MESSAGE
MESSAGE = {
ClassName = "MESSAGE",
MessageCategory = 0,
@ -39,7 +38,7 @@ MESSAGE = {
-- MessageClient2 = MESSAGE:New( "Congratulations, you've just killed a target", "Score", 25, "Score" )
function MESSAGE:New( MessageText, MessageCategory, MessageDuration, MessageID )
local self = BASE:Inherit( self, BASE:New() )
self:T( { MessageText, MessageCategory, MessageDuration, MessageID } )
self:F( { MessageText, MessageCategory, MessageDuration, MessageID } )
-- When no messagecategory is given, we don't show it as a title...
if MessageCategory and MessageCategory ~= "" then
@ -61,8 +60,9 @@ function MESSAGE:New( MessageText, MessageCategory, MessageDuration, MessageID )
end
--- Sends a MESSAGE to a Client Group. Note that the Group needs to be defined within the ME with the skillset "Client" or "Player".
-- @param CLIENT Client is the Group of the Client.
-- @return MESSAGE
-- @param #MESSAGE self
-- @param Client#CLIENT Client is the Group of the Client.
-- @return #MESSAGE
-- @usage
-- -- Send the 2 messages created with the @{New} method to the Client Group.
-- -- Note that the Message of MessageClient2 is overwriting the Message of MessageClient1.
@ -79,20 +79,21 @@ end
-- MessageClient1:ToClient( ClientGroup )
-- MessageClient2:ToClient( ClientGroup )
function MESSAGE:ToClient( Client )
self:T( Client )
self:F( Client )
if Client and Client:GetClientGroupID() then
local ClientGroupID = Client:GetClientGroupID()
trace.i( self.ClassName, self.MessageCategory .. self.MessageText:gsub("\n$",""):gsub("\n$","") .. " / " .. self.MessageDuration )
self:T( self.MessageCategory .. self.MessageText:gsub("\n$",""):gsub("\n$","") .. " / " .. self.MessageDuration )
trigger.action.outTextForGroup( ClientGroupID, self.MessageCategory .. self.MessageText:gsub("\n$",""):gsub("\n$",""), self.MessageDuration )
end
return self
end
--- Sends a MESSAGE to the Blue coalition.
-- @return MESSAGE
--- Sends a MESSAGE to the Blue coalition.
-- @param #MESSAGE self
-- @return #MESSAGE
-- @usage
-- -- Send a message created with the @{New} method to the BLUE coalition.
-- MessageBLUE = MESSAGE:New( "To the BLUE Players: You receive a penalty because you've killed one of your own units", "Penalty", 25, "Score" ):ToBlue()
@ -102,7 +103,7 @@ end
-- MessageBLUE = MESSAGE:New( "To the BLUE Players: You receive a penalty because you've killed one of your own units", "Penalty", 25, "Score" )
-- MessageBLUE:ToBlue()
function MESSAGE:ToBlue()
self:T()
self:F()
self:ToCoalition( coalition.side.BLUE )
@ -110,7 +111,8 @@ function MESSAGE:ToBlue()
end
--- Sends a MESSAGE to the Red Coalition.
-- @return MESSAGE
-- @param #MESSAGE self
-- @return #MESSAGE
-- @usage
-- -- Send a message created with the @{New} method to the RED coalition.
-- MessageRED = MESSAGE:New( "To the RED Players: You receive a penalty because you've killed one of your own units", "Penalty", 25, "Score" ):ToRed()
@ -120,7 +122,7 @@ end
-- MessageRED = MESSAGE:New( "To the RED Players: You receive a penalty because you've killed one of your own units", "Penalty", 25, "Score" )
-- MessageRED:ToRed()
function MESSAGE:ToRed( )
self:T()
self:F()
self:ToCoalition( coalition.side.RED )
@ -128,8 +130,9 @@ function MESSAGE:ToRed( )
end
--- Sends a MESSAGE to a Coalition.
-- @param #MESSAGE self
-- @param CoalitionSide needs to be filled out by the defined structure of the standard scripting engine @{coalition.side}.
-- @return MESSAGE
-- @return #MESSAGE
-- @usage
-- -- Send a message created with the @{New} method to the RED coalition.
-- MessageRED = MESSAGE:New( "To the RED Players: You receive a penalty because you've killed one of your own units", "Penalty", 25, "Score" ):ToCoalition( coalition.side.RED )
@ -139,10 +142,10 @@ end
-- MessageRED = MESSAGE:New( "To the RED Players: You receive a penalty because you've killed one of your own units", "Penalty", 25, "Score" )
-- MessageRED:ToCoalition( coalition.side.RED )
function MESSAGE:ToCoalition( CoalitionSide )
self:T( CoalitionSide )
self:F( CoalitionSide )
if CoalitionSide then
trace.i(self.ClassName, self.MessageCategory .. self.MessageText:gsub("\n$",""):gsub("\n$","") .. " / " .. self.MessageDuration )
self:T( self.MessageCategory .. self.MessageText:gsub("\n$",""):gsub("\n$","") .. " / " .. self.MessageDuration )
trigger.action.outTextForCoalition( CoalitionSide, self.MessageCategory .. self.MessageText:gsub("\n$",""):gsub("\n$",""), self.MessageDuration )
end
@ -150,7 +153,8 @@ function MESSAGE:ToCoalition( CoalitionSide )
end
--- Sends a MESSAGE to all players.
-- @return MESSAGE
-- @param #MESSAGE self
-- @return #MESSAGE
-- @usage
-- -- Send a message created to all players.
-- MessageAll = MESSAGE:New( "To all Players: BLUE has won! Each player of BLUE wins 50 points!", "End of Mission", 25, "Win" ):ToAll()
@ -160,7 +164,7 @@ end
-- MessageAll = MESSAGE:New( "To all Players: BLUE has won! Each player of BLUE wins 50 points!", "End of Mission", 25, "Win" )
-- MessageAll:ToAll()
function MESSAGE:ToAll()
self:T()
self:F()
self:ToCoalition( coalition.side.RED )
self:ToCoalition( coalition.side.BLUE )
@ -179,7 +183,7 @@ MESSAGEQUEUE = {
function MESSAGEQUEUE:New( RefreshInterval )
local self = BASE:Inherit( self, BASE:New() )
self:T( { RefreshInterval } )
self:F( { RefreshInterval } )
self.RefreshInterval = RefreshInterval

View File

@ -33,7 +33,7 @@ MISSION = {
function MISSION:Meta()
local self = BASE:Inherit( self, BASE:New() )
self:T()
self:F()
return self
end
@ -79,13 +79,13 @@ end
--- Returns if a Mission has completed.
-- @return bool
function MISSION:IsCompleted()
self:T()
self:F()
return self.MissionStatus == "ACCOMPLISHED"
end
--- Set a Mission to completed.
function MISSION:Completed()
self:T()
self:F()
self.MissionStatus = "ACCOMPLISHED"
self:StatusToClients()
end
@ -93,13 +93,13 @@ end
--- Returns if a Mission is ongoing.
-- treturn bool
function MISSION:IsOngoing()
self:T()
self:F()
return self.MissionStatus == "ONGOING"
end
--- Set a Mission to ongoing.
function MISSION:Ongoing()
self:T()
self:F()
self.MissionStatus = "ONGOING"
--self:StatusToClients()
end
@ -107,13 +107,13 @@ end
--- Returns if a Mission is pending.
-- treturn bool
function MISSION:IsPending()
self:T()
self:F()
return self.MissionStatus == "PENDING"
end
--- Set a Mission to pending.
function MISSION:Pending()
self:T()
self:F()
self.MissionStatus = "PENDING"
self:StatusToClients()
end
@ -121,20 +121,20 @@ end
--- Returns if a Mission has failed.
-- treturn bool
function MISSION:IsFailed()
self:T()
self:F()
return self.MissionStatus == "FAILED"
end
--- Set a Mission to failed.
function MISSION:Failed()
self:T()
self:F()
self.MissionStatus = "FAILED"
self:StatusToClients()
end
--- Send the status of the MISSION to all Clients.
function MISSION:StatusToClients()
self:T()
self:F()
if self.MissionReportFlash then
for ClientID, Client in pairs( self._Clients ) do
Client:Message( self.MissionCoalition .. ' "' .. self.Name .. '": ' .. self.MissionStatus .. '! ( ' .. self.MissionPriority .. ' mission ) ', 10, self.Name .. '/Status', "Mission Command: Mission Status")
@ -144,33 +144,28 @@ end
--- Handles the reporting. After certain time intervals, a MISSION report MESSAGE will be shown to All Players.
function MISSION:ReportTrigger()
self:T()
self:F()
if self.MissionReportShow == true then
self.MissionReportShow = false
trace.r( "MISSION", "1", { true } )
return true
else
if self.MissionReportFlash == true then
if timer.getTime() >= self.MissionReportTrigger then
self.MissionReportTrigger = timer.getTime() + self.MissionTimeInterval
trace.r( "MISSION", "2", { true } )
return true
else
trace.r( "MISSION", "3", { false } )
return false
end
else
trace.r( "MISSION", "4", { false } )
return false
end
end
trace.e()
end
--- Report the status of all MISSIONs to all active Clients.
function MISSION:ReportToAll()
self:T()
self:F()
local AlivePlayers = ''
for ClientID, Client in pairs( self._Clients ) do
@ -232,7 +227,7 @@ end
-- local Mission = MISSIONSCHEDULER.AddMission( 'NATO Transport Troops', 'Operational', 'Transport 3 groups of air defense engineers from our barracks "Gold" and "Titan" to each patriot battery control center to activate our air defenses.', 'NATO' )
-- Mission:AddGoalFunction( DeployPatriotTroopsGoal )
function MISSION:AddGoalFunction( GoalFunction )
self:T()
self:F()
self.GoalFunction = GoalFunction
end
@ -240,7 +235,7 @@ end
-- @param CLIENT Client to show briefing to.
-- @return CLIENT
function MISSION:ShowBriefing( Client )
self:T( { Client.ClientName } )
self:F( { Client.ClientName } )
if not Client.ClientBriefingShown then
Client.ClientBriefingShown = true
@ -265,7 +260,7 @@ end
-- Mission:AddClient( CLIENT:New( 'US UH-1H*HOT-Deploy Troops 2', 'Transport 3 groups of air defense engineers from our barracks "Gold" and "Titan" to each patriot battery control center to activate our air defenses.' ):Transport() )
-- Mission:AddClient( CLIENT:New( 'US UH-1H*RAMP-Deploy Troops 4', 'Transport 3 groups of air defense engineers from our barracks "Gold" and "Titan" to each patriot battery control center to activate our air defenses.' ):Transport() )
function MISSION:AddClient( Client )
self:T( { Client } )
self:F( { Client } )
local Valid = true
@ -273,7 +268,6 @@ function MISSION:AddClient( Client )
self._Clients[Client.ClientName] = Client
end
trace.r( self.ClassName, "" )
return Client
end
@ -284,7 +278,7 @@ end
-- -- Seach for Client "Bomber" within the Mission.
-- local BomberClient = Mission:FindClient( "Bomber" )
function MISSION:FindClient( ClientName )
self:T( { self._Clients[ClientName] } )
self:F( { self._Clients[ClientName] } )
return self._Clients[ClientName]
end
@ -315,7 +309,7 @@ end
-- Mission:AddTask( DeployTask, 2 )
function MISSION:AddTask( Task, TaskNumber )
self:T()
self:F()
self._Tasks[TaskNumber] = Task
self._Tasks[TaskNumber]:EnableEvents()
@ -332,7 +326,7 @@ function MISSION:AddTask( Task, TaskNumber )
-- Task2 = Mission:GetTask( 2 )
function MISSION:GetTask( TaskNumber )
self:T()
self:F()
local Valid = true
@ -356,7 +350,7 @@ end
-- Tasks = Mission:GetTasks()
-- env.info( "Task 2 Completion = " .. Tasks[2]:GetGoalPercentage() .. "%" )
function MISSION:GetTasks()
self:T()
self:F()
return self._Tasks
end
@ -391,13 +385,10 @@ MISSIONSCHEDULER = {
--- This is the main MISSIONSCHEDULER Scheduler function. It is considered internal and is automatically created when the Mission.lua file is included.
function MISSIONSCHEDULER.Scheduler()
trace.scheduled("MISSIONSCHEDULER","Scheduler")
-- loop through the missions in the TransportTasks
for MissionName, Mission in pairs( MISSIONSCHEDULER.Missions ) do
trace.i( "MISSIONSCHEDULER", MissionName )
if not Mission:IsCompleted() then
-- This flag will monitor if for this mission, there are clients alive. If this flag is still false at the end of the loop, the mission status will be set to Pending (if not Failed or Completed).
@ -405,8 +396,6 @@ trace.scheduled("MISSIONSCHEDULER","Scheduler")
for ClientID, Client in pairs( Mission._Clients ) do
trace.i( "MISSIONSCHEDULER", "Client: " .. Client.ClientName )
if Client:GetDCSGroup() then
-- There is at least one Client that is alive... So the Mission status is set to Ongoing.
@ -470,7 +459,6 @@ trace.scheduled("MISSIONSCHEDULER","Scheduler")
end
if Task:IsDone() then
trace.i( "MISSIONSCHEDULER", "Task " .. Task.Name .. " is Done." )
--env.info( 'Scheduler: Mission '.. Mission.Name .. ' Task ' .. Task.Name .. ' Stage ' .. Task.Stage.Name .. ' done. TaskComplete = ' .. string.format ( "%s", TaskComplete and "true" or "false" ) )
TaskComplete = true -- when a task is not yet completed, a mission cannot be completed
@ -546,29 +534,22 @@ trace.scheduled("MISSIONSCHEDULER","Scheduler")
if Mission:ReportTrigger() then
Mission:ReportToAll()
end
end
trace.e()
end
--- Start the MISSIONSCHEDULER.
function MISSIONSCHEDULER.Start()
trace.f("MISSIONSCHEDULER")
if MISSIONSCHEDULER ~= nil then
MISSIONSCHEDULER.SchedulerId = routines.scheduleFunction( MISSIONSCHEDULER.Scheduler, { }, 0, 2 )
end
trace.e()
end
--- Stop the MISSIONSCHEDULER.
function MISSIONSCHEDULER.Stop()
trace.f("MISSIONSCHEDULER")
if MISSIONSCHEDULER.SchedulerId then
routines.removeFunction(MISSIONSCHEDULER.SchedulerId)
MISSIONSCHEDULER.SchedulerId = nil
end
trace.e()
end
--- This is the main MISSION declaration method. Each Mission is like the master or a Mission orchestration between, Clients, Tasks, Stages etc.
@ -582,13 +563,11 @@ end
-- 'Russia' )
-- MISSIONSCHEDULER:AddMission( Mission )
function MISSIONSCHEDULER.AddMission( Mission )
trace.f("MISSIONSCHEDULER")
MISSIONSCHEDULER.Missions[Mission.Name] = Mission
MISSIONSCHEDULER.MissionCount = MISSIONSCHEDULER.MissionCount + 1
-- Add an overall AI Client for the AI tasks... This AI Client will facilitate the Events in the background for each Task.
--MissionAdd:AddClient( CLIENT:New( 'AI' ) )
trace.r( "MISSIONSCHEDULER", "" )
return Mission
end
@ -605,10 +584,8 @@ end
-- -- Now remove the Mission.
-- MISSIONSCHEDULER:RemoveMission( 'Russia Transport Troops SA-6' )
function MISSIONSCHEDULER.RemoveMission( MissionName )
trace.f("MISSIONSCHEDULER")
MISSIONSCHEDULER.Missions[MissionName] = nil
MISSIONSCHEDULER.MissionCount = MISSIONSCHEDULER.MissionCount - 1
trace.e()
end
--- Find a MISSION within the MISSIONSCHEDULER.
@ -625,24 +602,19 @@ end
-- -- Now find the Mission.
-- MissionFind = MISSIONSCHEDULER:FindMission( 'Russia Transport Troops SA-6' )
function MISSIONSCHEDULER.FindMission( MissionName )
trace.f("MISSIONSCHEDULER")
trace.r( "MISSIONSCHEDULER", "" )
return MISSIONSCHEDULER.Missions[MissionName]
end
-- Internal function used by the MISSIONSCHEDULER menu.
function MISSIONSCHEDULER.ReportMissionsShow( )
trace.menu("MISSIONSCHEDULER","ReportMissionsShow")
for MissionName, Mission in pairs( MISSIONSCHEDULER.Missions ) do
Mission.MissionReportShow = true
Mission.MissionReportFlash = false
end
trace.e()
end
-- Internal function used by the MISSIONSCHEDULER menu.
function MISSIONSCHEDULER.ReportMissionsFlash( TimeInterval )
trace.menu("MISSIONSCHEDULER","ReportMissionsFlash")
local Count = 0
for MissionName, Mission in pairs( MISSIONSCHEDULER.Missions ) do
Mission.MissionReportShow = false
@ -652,49 +624,40 @@ trace.menu("MISSIONSCHEDULER","ReportMissionsFlash")
env.info( "TimeInterval = " .. Mission.MissionTimeInterval )
Count = Count + 1
end
trace.e()
end
-- Internal function used by the MISSIONSCHEDULER menu.
function MISSIONSCHEDULER.ReportMissionsHide( Prm )
trace.menu("MISSIONSCHEDULER","ReportMissionsHide")
for MissionName, Mission in pairs( MISSIONSCHEDULER.Missions ) do
Mission.MissionReportShow = false
Mission.MissionReportFlash = false
end
trace.e()
end
--- Enables a MENU option in the communications menu under F10 to control the status of the active missions.
-- This function should be called only once when starting the MISSIONSCHEDULER.
function MISSIONSCHEDULER.ReportMenu()
trace.f("MISSIONSCHEDULER")
local ReportMenu = SUBMENU:New( 'Status' )
local ReportMenuShow = COMMANDMENU:New( 'Show Report Missions', ReportMenu, MISSIONSCHEDULER.ReportMissionsShow, 0 )
local ReportMenuFlash = COMMANDMENU:New('Flash Report Missions', ReportMenu, MISSIONSCHEDULER.ReportMissionsFlash, 120 )
local ReportMenuHide = COMMANDMENU:New( 'Hide Report Missions', ReportMenu, MISSIONSCHEDULER.ReportMissionsHide, 0 )
trace.e()
end
--- Show the remaining mission time.
function MISSIONSCHEDULER:TimeShow()
trace.f("MISSIONSCHEDULER")
self.TimeIntervalCount = self.TimeIntervalCount + 1
if self.TimeIntervalCount >= self.TimeTriggerShow then
local TimeMsg = string.format("%00d", ( self.TimeSeconds / 60 ) - ( timer.getTime() / 60 )) .. ' minutes left until mission reload.'
MESSAGE:New( TimeMsg, "Mission time", self.TimeShow, '/TimeMsg' ):ToAll()
self.TimeIntervalCount = 0
end
trace.e()
end
function MISSIONSCHEDULER:Time( TimeSeconds, TimeIntervalShow, TimeShow )
trace.f("MISSIONSCHEDULER")
self.TimeIntervalCount = 0
self.TimeSeconds = TimeSeconds
self.TimeIntervalShow = TimeIntervalShow
self.TimeShow = TimeShow
trace.e()
end

View File

@ -23,7 +23,7 @@ MOVEMENT = {
function MOVEMENT:New( MovePrefixes, MoveMaximum )
local self = BASE:Inherit( self, BASE:New() )
self:T( { MovePrefixes, MoveMaximum } )
self:F( { MovePrefixes, MoveMaximum } )
if type( MovePrefixes ) == 'table' then
self.MovePrefixes = MovePrefixes
@ -35,34 +35,34 @@ function MOVEMENT:New( MovePrefixes, MoveMaximum )
self.AliveUnits = 0 -- Contains the counter how many units are currently alive
self.MoveUnits = {} -- Reflects if the Moving for this MovePrefixes is going to be scheduled or not.
self.AddEvent( self, world.event.S_EVENT_BIRTH, self.OnBirth )
self.AddEvent( self, world.event.S_EVENT_DEAD, self.OnDeadOrCrash )
self.AddEvent( self, world.event.S_EVENT_CRASH, self.OnDeadOrCrash )
self:AddEvent( world.event.S_EVENT_BIRTH, self.OnBirth )
self:AddEvent( world.event.S_EVENT_DEAD, self.OnDeadOrCrash )
self:AddEvent( world.event.S_EVENT_CRASH, self.OnDeadOrCrash )
self.EnableEvents( self )
self:EnableEvents()
self.ScheduleStart( self )
self:ScheduleStart()
return self
end
--- Call this function to start the MOVEMENT scheduling.
function MOVEMENT:ScheduleStart()
self:T()
self:F()
self.MoveFunction = routines.scheduleFunction( self._Scheduler, { self }, timer.getTime() + 1, 120 )
end
--- Call this function to stop the MOVEMENT scheduling.
-- @todo need to implement it ... Forgot.
function MOVEMENT:ScheduleStop()
self:T()
self:F()
end
--- Captures the birth events when new Units were spawned.
-- @todo This method should become obsolete. The new @{DATABASE} class will handle the collection administration.
function MOVEMENT:OnBirth( event )
self:T( { event } )
self:F( { event } )
if timer.getTime0() < timer.getAbsTime() then -- dont need to add units spawned in at the start of the mission if mist is loaded in init line
if event.initiator and Object.getCategory(event.initiator) == Object.Category.UNIT then
@ -88,7 +88,7 @@ end
--- Captures the Dead or Crash events when Units crash or are destroyed.
-- @todo This method should become obsolete. The new @{DATABASE} class will handle the collection administration.
function MOVEMENT:OnDeadOrCrash( event )
self:T( { event } )
self:F( { event } )
if event.initiator and Object.getCategory(event.initiator) == Object.Category.UNIT then
local MovementUnit = event.initiator
@ -106,7 +106,7 @@ end
--- This function is called automatically by the MOVEMENT scheduler. A new function is scheduled when MoveScheduled is true.
function MOVEMENT:_Scheduler()
self:T( { self.MovePrefixes, self.MoveMaximum, self.AliveUnits, self.MovementGroups } )
self:F( { self.MovePrefixes, self.MoveMaximum, self.AliveUnits, self.MovementGroups } )
if self.AliveUnits > 0 then
local MoveProbability = ( self.MoveMaximum * 100 ) / self.AliveUnits

View File

@ -11,19 +11,17 @@ NOTASK = {
--- Creates a new NOTASK.
function NOTASK:New()
trace.f(self.ClassName)
-- Child holds the inherited instance of the PICKUPTASK Class to the BASE class.
local Child = BASE:Inherit( self, TASK:New() )
local self = BASE:Inherit( self, TASK:New() )
self:F()
local Valid = true
if Valid then
Child.Name = 'Nothing'
Child.TaskBriefing = "Task: Execute your mission."
Child.Stages = { STAGEBRIEF:New(), STAGESTART:New(), STAGEDONE:New() }
Child.SetStage( Child, 1 )
self.Name = 'Nothing'
self.TaskBriefing = "Task: Execute your mission."
self.Stages = { STAGEBRIEF:New(), STAGESTART:New(), STAGEDONE:New() }
self.SetStage( self, 1 )
end
return Child
return self
end

View File

@ -19,7 +19,7 @@ PICKUPTASK = {
-- @param number OnBoardSide Reflects from which side the cargo Group will be on-boarded on the Carrier.
function PICKUPTASK:New( CargoType, OnBoardSide )
local self = BASE:Inherit( self, TASK:New() )
self:T()
self:F()
-- self holds the inherited instance of the PICKUPTASK Class to the BASE class.
@ -41,7 +41,7 @@ function PICKUPTASK:New( CargoType, OnBoardSide )
end
function PICKUPTASK:FromZone( LandingZone )
self:T()
self:F()
self.LandingZones.LandingZoneNames[LandingZone.CargoZoneName] = LandingZone.CargoZoneName
self.LandingZones.LandingZones[LandingZone.CargoZoneName] = LandingZone
@ -50,7 +50,7 @@ self:T()
end
function PICKUPTASK:InitCargo( InitCargos )
self:T( { InitCargos } )
self:F( { InitCargos } )
if type( InitCargos ) == "table" then
self.Cargos.InitCargos = InitCargos
@ -62,7 +62,7 @@ self:T( { InitCargos } )
end
function PICKUPTASK:LoadCargo( LoadCargos )
self:T( { LoadCargos } )
self:F( { LoadCargos } )
if type( LoadCargos ) == "table" then
self.Cargos.LoadCargos = LoadCargos
@ -74,7 +74,7 @@ self:T( { LoadCargos } )
end
function PICKUPTASK:AddCargoMenus( Client, Cargos, TransportRadius )
self:T()
self:F()
for CargoID, Cargo in pairs( Cargos ) do
@ -121,7 +121,7 @@ self:T()
end
function PICKUPTASK:RemoveCargoMenus( Client )
self:T()
self:F()
for MenuID, MenuData in pairs( Client._Menus ) do
for SubMenuID, SubMenuData in pairs( MenuData.PickupSubMenus ) do
@ -148,7 +148,7 @@ end
function PICKUPTASK:HasFailed( ClientDead )
self:T()
self:F()
local TaskHasFailed = self.TaskFailed
return TaskHasFailed

View File

@ -13,31 +13,29 @@ ROUTETASK = {
-- @param string TaskBriefing (optional) Defines a text describing the briefing of the task.
-- @return ROUTETASK
function ROUTETASK:New( LandingZones, TaskBriefing )
trace.f(self.ClassName, { LandingZones, TaskBriefing } )
-- Child holds the inherited instance of the PICKUPTASK Class to the BASE class.
local Child = BASE:Inherit( self, TASK:New() )
local self = BASE:Inherit( self, TASK:New() )
self:F( { LandingZones, TaskBriefing } )
local Valid = true
Valid = routines.ValidateZone( LandingZones, "LandingZones", Valid )
if Valid then
Child.Name = 'Route To Zone'
self.Name = 'Route To Zone'
if TaskBriefing then
Child.TaskBriefing = TaskBriefing .. " Your co-pilot will provide you with the directions (required flight angle in degrees) and the distance (in km) to the target objective."
self.TaskBriefing = TaskBriefing .. " Your co-pilot will provide you with the directions (required flight angle in degrees) and the distance (in km) to the target objective."
else
Child.TaskBriefing = "Task: Fly to specified zone(s). Your co-pilot will provide you with the directions (required flight angle in degrees) and the distance (in km) to the target objective."
self.TaskBriefing = "Task: Fly to specified zone(s). Your co-pilot will provide you with the directions (required flight angle in degrees) and the distance (in km) to the target objective."
end
if type( LandingZones ) == "table" then
Child.LandingZones = LandingZones
self.LandingZones = LandingZones
else
Child.LandingZones = { LandingZones }
self.LandingZones = { LandingZones }
end
Child.Stages = { STAGEBRIEF:New(), STAGESTART:New(), STAGEROUTE:New(), STAGEARRIVE:New(), STAGEDONE:New() }
Child.SetStage( Child, 1 )
self.Stages = { STAGEBRIEF:New(), STAGESTART:New(), STAGEROUTE:New(), STAGEARRIVE:New(), STAGEDONE:New() }
self.SetStage( self, 1 )
end
return Child
return self
end

View File

@ -2,7 +2,7 @@
-- @module routines
-- @author Flightcontrol
Include.File( "Trace" )
--Include.File( "Trace" )
--Include.File( "Message" )
@ -1455,7 +1455,7 @@ end
function routines.IsPartOfGroupInZones( CargoGroup, LandingZones )
trace.f()
--trace.f()
local CurrentZoneID = nil
@ -1471,14 +1471,14 @@ trace.f()
end
end
trace.r( "", "", { CurrentZoneID } )
--trace.r( "", "", { CurrentZoneID } )
return CurrentZoneID
end
function routines.IsUnitInZones( TransportUnit, LandingZones )
trace.f("", "routines.IsUnitInZones" )
--trace.f("", "routines.IsUnitInZones" )
local TransportZoneResult = nil
local TransportZonePos = nil
@ -1506,19 +1506,19 @@ trace.f("", "routines.IsUnitInZones" )
end
end
if TransportZoneResult then
trace.i( "routines", "TransportZone:" .. TransportZoneResult )
--trace.i( "routines", "TransportZone:" .. TransportZoneResult )
else
trace.i( "routines", "TransportZone:nil logic" )
--trace.i( "routines", "TransportZone:nil logic" )
end
return TransportZoneResult
else
trace.i( "routines", "TransportZone:nil hard" )
--trace.i( "routines", "TransportZone:nil hard" )
return nil
end
end
function routines.IsStaticInZones( TransportStatic, LandingZones )
trace.f()
--trace.f()
local TransportZoneResult = nil
local TransportZonePos = nil
@ -1545,13 +1545,13 @@ trace.f()
end
end
trace.r( "", "", { TransportZoneResult } )
--trace.r( "", "", { TransportZoneResult } )
return TransportZoneResult
end
function routines.IsUnitInRadius( CargoUnit, ReferencePosition, Radius )
trace.f()
--trace.f()
local Valid = true
@ -1568,7 +1568,7 @@ trace.f()
end
function routines.IsPartOfGroupInRadius( CargoGroup, ReferencePosition, Radius )
trace.f()
--trace.f()
local Valid = true
@ -1594,7 +1594,7 @@ end
function routines.ValidateString( Variable, VariableName, Valid )
trace.f()
--trace.f()
if type( Variable ) == "string" then
if Variable == "" then
@ -1606,12 +1606,12 @@ trace.f()
Valid = false
end
trace.r( "", "", { Valid } )
--trace.r( "", "", { Valid } )
return Valid
end
function routines.ValidateNumber( Variable, VariableName, Valid )
trace.f()
--trace.f()
if type( Variable ) == "number" then
else
@ -1619,25 +1619,25 @@ trace.f()
Valid = false
end
trace.r( "", "", { Valid } )
--trace.r( "", "", { Valid } )
return Valid
end
function routines.ValidateGroup( Variable, VariableName, Valid )
trace.f()
--trace.f()
if Variable == nil then
error( "routines.ValidateGroup: error: " .. VariableName .. " is a nil value!" )
Valid = false
end
trace.r( "", "", { Valid } )
--trace.r( "", "", { Valid } )
return Valid
end
function routines.ValidateZone( LandingZones, VariableName, Valid )
trace.f()
--trace.f()
if LandingZones == nil then
error( "routines.ValidateGroup: error: " .. VariableName .. " is a nil value!" )
@ -1659,12 +1659,12 @@ trace.f()
end
end
trace.r( "", "", { Valid } )
--trace.r( "", "", { Valid } )
return Valid
end
function routines.ValidateEnumeration( Variable, VariableName, Enum, Valid )
trace.f()
--trace.f()
local ValidVariable = false
@ -1681,7 +1681,7 @@ trace.f()
Valid = false
end
trace.r( "", "", { Valid } )
--trace.r( "", "", { Valid } )
return Valid
end
@ -1859,7 +1859,7 @@ routines.ground.patrol = function(gpData, pType, form, speed)
end
function routines.GetUnitHeight( CheckUnit )
trace.f( "routines" )
--trace.f( "routines" )
local UnitPoint = CheckUnit:getPoint()
local UnitPosition = { x = UnitPoint.x, y = UnitPoint.z }
@ -1869,7 +1869,7 @@ trace.f( "routines" )
--env.info(( 'CarrierHeight: LandHeight = ' .. LandHeight .. ' CarrierHeight = ' .. CarrierHeight ))
trace.f( "routines", "Unit Height = " .. UnitHeight - LandHeight )
--trace.f( "routines", "Unit Height = " .. UnitHeight - LandHeight )
return UnitHeight - LandHeight
@ -1886,7 +1886,7 @@ Su34Menus = 0
function Su34AttackCarlVinson(groupName)
trace.menu("", "Su34AttackCarlVinson")
--trace.menu("", "Su34AttackCarlVinson")
local groupSu34 = Group.getByName( groupName )
local controllerSu34 = groupSu34.getController(groupSu34)
local groupCarlVinson = Group.getByName("US Carl Vinson #001")
@ -1900,7 +1900,7 @@ trace.menu("", "Su34AttackCarlVinson")
end
function Su34AttackWest(groupName)
trace.f("","Su34AttackWest")
--trace.f("","Su34AttackWest")
local groupSu34 = Group.getByName( groupName )
local controllerSu34 = groupSu34.getController(groupSu34)
local groupShipWest1 = Group.getByName("US Ship West #001")
@ -1918,7 +1918,7 @@ trace.f("","Su34AttackWest")
end
function Su34AttackNorth(groupName)
trace.menu("","Su34AttackNorth")
--trace.menu("","Su34AttackNorth")
local groupSu34 = Group.getByName( groupName )
local controllerSu34 = groupSu34.getController(groupSu34)
local groupShipNorth1 = Group.getByName("US Ship North #001")
@ -1940,7 +1940,7 @@ trace.menu("","Su34AttackNorth")
end
function Su34Orbit(groupName)
trace.menu("","Su34Orbit")
--trace.menu("","Su34Orbit")
local groupSu34 = Group.getByName( groupName )
local controllerSu34 = groupSu34:getController()
controllerSu34.setOption( controllerSu34, AI.Option.Air.id.ROE, AI.Option.Air.val.ROE.WEAPON_HOLD )
@ -1951,7 +1951,7 @@ trace.menu("","Su34Orbit")
end
function Su34TakeOff(groupName)
trace.menu("","Su34TakeOff")
--trace.menu("","Su34TakeOff")
local groupSu34 = Group.getByName( groupName )
local controllerSu34 = groupSu34:getController()
controllerSu34.setOption( controllerSu34, AI.Option.Air.id.ROE, AI.Option.Air.val.ROE.WEAPON_HOLD )
@ -1961,7 +1961,7 @@ trace.menu("","Su34TakeOff")
end
function Su34Hold(groupName)
trace.menu("","Su34Hold")
--trace.menu("","Su34Hold")
local groupSu34 = Group.getByName( groupName )
local controllerSu34 = groupSu34:getController()
controllerSu34.setOption( controllerSu34, AI.Option.Air.id.ROE, AI.Option.Air.val.ROE.WEAPON_HOLD )
@ -1971,19 +1971,19 @@ trace.menu("","Su34Hold")
end
function Su34RTB(groupName)
trace.menu("","Su34RTB")
--trace.menu("","Su34RTB")
Su34Status.status[groupName] = 6
MessageToRed( string.format('%s: ',groupName) .. 'Return to Krasnodar. ', 10, 'RedStatus' .. groupName )
end
function Su34Destroyed(groupName)
trace.menu("","Su34Destroyed")
--trace.menu("","Su34Destroyed")
Su34Status.status[groupName] = 7
MessageToRed( string.format('%s: ',groupName) .. 'Destroyed. ', 30, 'RedStatus' .. groupName )
end
function GroupAlive( groupName )
trace.menu("","GroupAlive")
--trace.menu("","GroupAlive")
local groupTest = Group.getByName( groupName )
local groupExists = false
@ -1992,17 +1992,17 @@ trace.menu("","GroupAlive")
groupExists = groupTest:isExist()
end
trace.r( "", "", { groupExists } )
--trace.r( "", "", { groupExists } )
return groupExists
end
function Su34IsDead()
trace.f()
--trace.f()
end
function Su34OverviewStatus()
trace.menu("","Su34OverviewStatus")
--trace.menu("","Su34OverviewStatus")
local msg = ""
local currentStatus = 0
local Exists = false
@ -2053,25 +2053,25 @@ end
function UpdateBoardMsg()
trace.f()
--trace.f()
Su34OverviewStatus()
MessageToRed( boardMsgRed.statusMsg, 15, 'RedStatus' )
end
function MusicReset( flg )
trace.f()
--trace.f()
trigger.action.setUserFlag(95,flg)
end
function PlaneActivate(groupNameFormat, flg)
trace.f()
--trace.f()
local groupName = groupNameFormat .. string.format("#%03d", trigger.misc.getUserFlag(flg))
--trigger.action.outText(groupName,10)
trigger.action.activateGroup(Group.getByName(groupName))
end
function Su34Menu(groupName)
trace.f()
--trace.f()
--env.info(( 'Su34Menu(' .. groupName .. ')' ))
local groupSu34 = Group.getByName( groupName )
@ -2144,7 +2144,7 @@ end
--- Obsolete function, but kept to rework in framework.
function ChooseInfantry ( TeleportPrefixTable, TeleportMax )
trace.f("Spawn")
--trace.f("Spawn")
--env.info(( 'ChooseInfantry: ' ))
TeleportPrefixTableCount = #TeleportPrefixTable
@ -2229,7 +2229,7 @@ end
SpawnedInfantry = 0
function LandCarrier ( CarrierGroup, LandingZonePrefix )
trace.f()
--trace.f()
--env.info(( 'LandCarrier: ' ))
--env.info(( 'LandCarrier: CarrierGroup = ' .. CarrierGroup:getName() ))
--env.info(( 'LandCarrier: LandingZone = ' .. LandingZonePrefix ))
@ -2248,7 +2248,7 @@ end
EscortCount = 0
function EscortCarrier ( CarrierGroup, EscortPrefix, EscortLastWayPoint, EscortEngagementDistanceMax, EscortTargetTypes )
trace.f()
--trace.f()
--env.info(( 'EscortCarrier: ' ))
--env.info(( 'EscortCarrier: CarrierGroup = ' .. CarrierGroup:getName() ))
--env.info(( 'EscortCarrier: EscortPrefix = ' .. EscortPrefix ))
@ -2314,7 +2314,7 @@ trace.f()
end
function SendMessageToCarrier( CarrierGroup, CarrierMessage )
trace.f()
--trace.f()
if CarrierGroup ~= nil then
MessageToGroup( CarrierGroup, CarrierMessage, 30, 'Carrier/' .. CarrierGroup:getName() )
@ -2323,7 +2323,7 @@ trace.f()
end
function MessageToGroup( MsgGroup, MsgText, MsgTime, MsgName )
trace.f()
--trace.f()
if type(MsgGroup) == 'string' then
--env.info( 'MessageToGroup: Converted MsgGroup string "' .. MsgGroup .. '" into a Group structure.' )
@ -2342,7 +2342,7 @@ trace.f()
end
function MessageToUnit( UnitName, MsgText, MsgTime, MsgName )
trace.f()
--trace.f()
if UnitName ~= nil then
local MsgTable = {}
@ -2355,25 +2355,25 @@ trace.f()
end
function MessageToAll( MsgText, MsgTime, MsgName )
trace.f()
--trace.f()
MESSAGE:New( MsgText, "Message", MsgTime, MsgName ):ToCoalition( coalition.side.RED ):ToCoalition( coalition.side.BLUE )
end
function MessageToRed( MsgText, MsgTime, MsgName )
trace.f()
--trace.f()
MESSAGE:New( MsgText, "To Red Coalition", MsgTime, MsgName ):ToCoalition( coalition.side.RED )
end
function MessageToBlue( MsgText, MsgTime, MsgName )
trace.f()
--trace.f()
MESSAGE:New( MsgText, "To Blue Coalition", MsgTime, MsgName ):ToCoalition( coalition.side.RED )
end
function getCarrierHeight( CarrierGroup )
trace.f()
--trace.f()
if CarrierGroup ~= nil then
if table.getn(CarrierGroup:getUnits()) == 1 then
@ -2398,7 +2398,7 @@ trace.f()
end
function GetUnitHeight( CheckUnit )
trace.f()
--trace.f()
local UnitPoint = CheckUnit:getPoint()
local UnitPosition = { x = CurrentPoint.x, y = CurrentPoint.z }
@ -2420,7 +2420,7 @@ _MusicTable.FileCnt = 0
function MusicRegister( SndRef, SndFile, SndTime )
trace.f()
--trace.f()
env.info(( 'MusicRegister: SndRef = ' .. SndRef ))
env.info(( 'MusicRegister: SndFile = ' .. SndFile ))
@ -2441,7 +2441,7 @@ trace.f()
end
function MusicToPlayer( SndRef, PlayerName, SndContinue )
trace.f()
--trace.f()
--env.info(( 'MusicToPlayer: SndRef = ' .. SndRef ))
@ -2464,7 +2464,7 @@ trace.f()
end
function MusicToGroup( SndRef, SndGroup, SndContinue )
trace.f()
--trace.f()
--env.info(( 'MusicToGroup: SndRef = ' .. SndRef ))
@ -2507,7 +2507,7 @@ trace.f()
end
function MusicCanStart(PlayerName)
trace.f()
--trace.f()
--env.info(( 'MusicCanStart:' ))
@ -2549,7 +2549,7 @@ trace.f()
end
function MusicScheduler()
trace.scheduled("", "MusicScheduler")
--trace.scheduled("", "MusicScheduler")
--env.info(( 'MusicScheduler:' ))
if _MusicTable['Queue'] ~= nil and _MusicTable.FileCnt > 0 then

View File

@ -34,7 +34,7 @@ SEAD = {
-- SEAD_RU_SAM_Defenses = SEAD:New( { 'RU SA-6 Kub', 'RU SA-6 Defenses', 'RU MI-26 Troops', 'RU Attack Gori' } )
function SEAD:New( SEADGroupPrefixes )
local self = BASE:Inherit( self, BASE:New() )
self:T( SEADGroupPrefixes )
self:F( SEADGroupPrefixes )
if type( SEADGroupPrefixes ) == 'table' then
for SEADGroupPrefixID, SEADGroupPrefix in pairs( SEADGroupPrefixes ) do
self.SEADGroupPrefixes[SEADGroupPrefix] = SEADGroupPrefix
@ -42,8 +42,8 @@ function SEAD:New( SEADGroupPrefixes )
else
self.SEADGroupNames[SEADGroupPrefixes] = SEADGroupPrefixes
end
self.AddEvent( self, world.event.S_EVENT_SHOT, self.EventShot )
self.EnableEvents( self )
self:AddEvent( world.event.S_EVENT_SHOT, self.EventShot )
self:EnableEvents()
return self
end
@ -51,7 +51,7 @@ end
--- Detects if an SA site was shot with an anti radiation missile. In this case, take evasive actions based on the skill level set within the ME.
-- @see SEAD
function SEAD:EventShot( event )
self:T( { event } )
self:F( { event } )
local SEADUnit = event.initiator
local SEADUnitName = SEADUnit:getName()

View File

@ -96,7 +96,7 @@ SPAWN = {
-- @usage local Plane = SPAWN:New( "Plane" ) -- Creates a new local variable that can initiate new planes with the name "Plane#ddd" using the template "Plane" as defined within the ME.
function SPAWN:New( SpawnTemplatePrefix )
local self = BASE:Inherit( self, BASE:New() )
self:T( { SpawnTemplatePrefix } )
self:F( { SpawnTemplatePrefix } )
local TemplateGroup = Group.getByName( SpawnTemplatePrefix )
if TemplateGroup then
@ -118,11 +118,11 @@ function SPAWN:New( SpawnTemplatePrefix )
error( "SPAWN:New: There is no group declared in the mission editor with SpawnTemplatePrefix = '" .. SpawnTemplatePrefix .. "'" )
end
self.AddEvent( self, world.event.S_EVENT_BIRTH, self._OnBirth )
self.AddEvent( self, world.event.S_EVENT_DEAD, self._OnDeadOrCrash )
self.AddEvent( self, world.event.S_EVENT_CRASH, self._OnDeadOrCrash )
self:AddEvent( world.event.S_EVENT_BIRTH, self._OnBirth )
self:AddEvent( world.event.S_EVENT_DEAD, self._OnDeadOrCrash )
self:AddEvent( world.event.S_EVENT_CRASH, self._OnDeadOrCrash )
self.EnableEvents( self )
self:EnableEvents()
return self
end
@ -138,7 +138,7 @@ end
-- @usage local PlaneWithAlias = SPAWN:NewWithAlias( "Plane", "Bomber" ) -- Creates a new local variable that can instantiate new planes with the name "Bomber#ddd" using the template "Plane" as defined within the ME.
function SPAWN:NewWithAlias( SpawnTemplatePrefix, SpawnAliasPrefix )
local self = BASE:Inherit( self, BASE:New() )
self:T( { SpawnTemplatePrefix, SpawnAliasPrefix } )
self:F( { SpawnTemplatePrefix, SpawnAliasPrefix } )
local TemplateGroup = Group.getByName( SpawnTemplatePrefix )
if TemplateGroup then
@ -161,11 +161,11 @@ function SPAWN:NewWithAlias( SpawnTemplatePrefix, SpawnAliasPrefix )
error( "SPAWN:New: There is no group declared in the mission editor with SpawnTemplatePrefix = '" .. SpawnTemplatePrefix .. "'" )
end
self.AddEvent( self, world.event.S_EVENT_BIRTH, self._OnBirth )
self.AddEvent( self, world.event.S_EVENT_DEAD, self._OnDeadOrCrash )
self.AddEvent( self, world.event.S_EVENT_CRASH, self._OnDeadOrCrash )
self:AddEvent( world.event.S_EVENT_BIRTH, self._OnBirth )
self:AddEvent( world.event.S_EVENT_DEAD, self._OnDeadOrCrash )
self:AddEvent( world.event.S_EVENT_CRASH, self._OnDeadOrCrash )
self.EnableEvents( self )
self:EnableEvents()
return self
end
@ -187,7 +187,7 @@ end
-- -- There will be maximum 24 groups spawned during the whole mission lifetime.
-- Spawn_BE_KA50 = SPAWN:New( 'BE KA-50@RAMP-Ground Defense' ):Limit( 2, 24 )
function SPAWN:Limit( SpawnMaxUnitsAlive, SpawnMaxGroups )
self:T( { self.SpawnTemplatePrefix, SpawnMaxUnitsAlive, SpawnMaxGroups } )
self:F( { self.SpawnTemplatePrefix, SpawnMaxUnitsAlive, SpawnMaxGroups } )
self.SpawnMaxUnitsAlive = SpawnMaxUnitsAlive -- The maximum amount of groups that can be alive of SpawnTemplatePrefix at the same time.
self.SpawnMaxGroups = SpawnMaxGroups -- The maximum amount of groups that can be spawned.
@ -215,7 +215,7 @@ end
-- -- The randomization of waypoint 2 and 3 will take place within a radius of 2000 meters.
-- Spawn_BE_KA50 = SPAWN:New( 'BE KA-50@RAMP-Ground Defense' ):RandomizeRoute( 2, 2, 2000 )
function SPAWN:RandomizeRoute( SpawnStartPoint, SpawnEndPoint, SpawnRadius )
self:T( { self.SpawnTemplatePrefix, SpawnStartPoint, SpawnEndPoint, SpawnRadius } )
self:F( { self.SpawnTemplatePrefix, SpawnStartPoint, SpawnEndPoint, SpawnRadius } )
self.SpawnRandomizeRoute = true
self.SpawnRandomizeRouteStartPoint = SpawnStartPoint
@ -250,7 +250,7 @@ end
-- Spawn_US_Platoon_Middle = SPAWN:New( 'US Tank Platoon Middle' ):Limit( 12, 150 ):Schedule( 200, 0.4 ):RandomizeTemplate( Spawn_US_Platoon ):RandomizeRoute( 3, 3, 2000 )
-- Spawn_US_Platoon_Right = SPAWN:New( 'US Tank Platoon Right' ):Limit( 12, 150 ):Schedule( 200, 0.4 ):RandomizeTemplate( Spawn_US_Platoon ):RandomizeRoute( 3, 3, 2000 )
function SPAWN:RandomizeTemplate( SpawnTemplatePrefixTable )
self:T( { self.SpawnTemplatePrefix, SpawnTemplatePrefixTable } )
self:F( { self.SpawnTemplatePrefix, SpawnTemplatePrefixTable } )
self.SpawnTemplatePrefixTable = SpawnTemplatePrefixTable
self.SpawnRandomizeTemplate = true
@ -278,7 +278,7 @@ end
-- -- Re-SPAWN the Group(s) after each landing and Engine Shut-Down automatically.
-- SpawnRU_SU34 = SPAWN:New( 'TF1 RU Su-34 Krymsk@AI - Attack Ships' ):Schedule( 2, 3, 1800, 0.4 ):SpawnUncontrolled():RandomizeRoute( 1, 1, 3000 ):RepeatOnEngineShutDown()
function SPAWN:Repeat()
self:T( { self.SpawnTemplatePrefix } )
self:F( { self.SpawnTemplatePrefix } )
self.SpawnRepeat = true
self.RepeatOnEngineShutDown = false
@ -297,7 +297,7 @@ end
-- @see Repeat
function SPAWN:RepeatOnLanding()
self:T( { self.SpawnTemplatePrefix } )
self:F( { self.SpawnTemplatePrefix } )
self:Repeat()
self.RepeatOnEngineShutDown = false
@ -309,7 +309,7 @@ end
--- Same as the @{#SPAWN.Repeat) method, but now the Group will respawn after its engines have shut down.
-- @return SPAWN
function SPAWN:RepeatOnEngineShutDown()
self:T( { self.SpawnTemplatePrefix } )
self:F( { self.SpawnTemplatePrefix } )
self:Repeat()
self.RepeatOnEngineShutDown = true
@ -326,7 +326,7 @@ end
-- @return #SPAWN self
-- @usage Spawn_Helicopter:CleanUp( 20 ) -- CleanUp the spawning of the helicopters every 20 seconds when they become inactive.
function SPAWN:CleanUp( SpawnCleanUpInterval )
self:T( { self.SpawnTemplatePrefix, SpawnCleanUpInterval } )
self:F( { self.SpawnTemplatePrefix, SpawnCleanUpInterval } )
self.SpawnCleanUpInterval = SpawnCleanUpInterval
self.SpawnCleanUpTimeStamps = {}
@ -349,7 +349,7 @@ end
-- -- Define an array of Groups.
-- Spawn_BE_Ground = SPAWN:New( 'BE Ground' ):Limit( 2, 24 ):Visible( 90, "Diamond", 10, 100, 50 )
function SPAWN:Array( SpawnAngle, SpawnWidth, SpawnDeltaX, SpawnDeltaY )
self:T( { self.SpawnTemplatePrefix, SpawnAngle, SpawnWidth, SpawnDeltaX, SpawnDeltaY } )
self:F( { self.SpawnTemplatePrefix, SpawnAngle, SpawnWidth, SpawnDeltaX, SpawnDeltaY } )
self.SpawnVisible = true -- When the first Spawn executes, all the Groups need to be made visible before start.
@ -397,7 +397,7 @@ end
-- @param self
-- @return GROUP#GROUP The group that was spawned. You can use this group for further actions.
function SPAWN:Spawn()
self:T( { self.SpawnTemplatePrefix, self.SpawnIndex } )
self:F( { self.SpawnTemplatePrefix, self.SpawnIndex } )
return self:SpawnWithIndex( self.SpawnIndex + 1 )
end
@ -408,7 +408,7 @@ end
-- @param #string SpawnIndex The index of the group to be spawned.
-- @return GROUP#GROUP The group that was spawned. You can use this group for further actions.
function SPAWN:ReSpawn( SpawnIndex )
self:T( { self.SpawnTemplatePrefix, SpawnIndex } )
self:F( { self.SpawnTemplatePrefix, SpawnIndex } )
if not SpawnIndex then
SpawnIndex = 1
@ -426,7 +426,7 @@ end
-- Uses @{DATABASE} global object defined in MOOSE.
-- @return GROUP#GROUP The group that was spawned. You can use this group for further actions.
function SPAWN:SpawnWithIndex( SpawnIndex )
self:T( { self.SpawnTemplatePrefix, SpawnIndex, self.SpawnMaxGroups } )
self:F( { self.SpawnTemplatePrefix, SpawnIndex, self.SpawnMaxGroups } )
if self:_GetSpawnIndex( SpawnIndex ) then
@ -466,7 +466,7 @@ end
-- -- Between these two values, a random amount of seconds will be choosen for each new spawn of the helicopters.
-- Spawn_BE_KA50 = SPAWN:New( 'BE KA-50@RAMP-Ground Defense' ):Schedule( 600, 0.5 )
function SPAWN:SpawnScheduled( SpawnTime, SpawnTimeVariation )
self:T( { SpawnTime, SpawnTimeVariation } )
self:F( { SpawnTime, SpawnTimeVariation } )
self.SpawnCurrentTimer = 0 -- The internal timer counter to trigger a scheduled spawning of SpawnTemplatePrefix.
self.SpawnSetTimer = 0 -- The internal timer value when a scheduled spawning of SpawnTemplatePrefix occurs.
@ -490,7 +490,7 @@ end
--- Will start the spawning scheduler.
-- Note: This function is called automatically when @{#SPAWN.Scheduled} is called.
function SPAWN:SpawnScheduleStart()
self:T( { self.SpawnTemplatePrefix } )
self:F( { self.SpawnTemplatePrefix } )
--local ClientUnit = #AlivePlayerUnits()
@ -507,7 +507,7 @@ end
--- Will stop the scheduled spawning scheduler.
function SPAWN:SpawnScheduleStop()
self:T( { self.SpawnTemplatePrefix } )
self:F( { self.SpawnTemplatePrefix } )
self.SpawnIsScheduled = false
end
@ -516,14 +516,14 @@ end
-- Note that each point in the route assigned to the spawning group is reset to the point of the spawn.
-- You can use the returned group to further define the route to be followed.
-- @param self
-- @param #UNIT HostUnit The air or ground unit dropping or unloading the group.
-- @param Unit#UNIT HostUnit The air or ground unit dropping or unloading the group.
-- @param #number OuterRadius The outer radius in meters where the new group will be spawned.
-- @param #number InnerRadius The inner radius in meters where the new group will NOT be spawned.
-- @param #number SpawnIndex (Optional) The index which group to spawn within the given zone.
-- @return GROUP#GROUP that was spawned.
-- @return Group#GROUP that was spawned.
-- @return #nil Nothing was spawned.
function SPAWN:SpawnFromUnit( HostUnit, OuterRadius, InnerRadius, SpawnIndex )
self:T( { self.SpawnTemplatePrefix, HostUnit, OuterRadius, InnerRadius, SpawnIndex } )
self:F( { self.SpawnTemplatePrefix, HostUnit, OuterRadius, InnerRadius, SpawnIndex } )
if HostUnit and HostUnit:IsAlive() then -- and HostUnit:getUnit(1):inAir() == false then
@ -566,14 +566,14 @@ function SPAWN:SpawnFromUnit( HostUnit, OuterRadius, InnerRadius, SpawnIndex )
SpawnTemplate.units[UnitID].x = UnitPoint.x
SpawnTemplate.units[UnitID].y = UnitPoint.y
else
local CirclePos = routines.getRandPointInCircle( UnitPoint, InnerRadius+1, InnerRadius )
local CirclePos = routines.getRandPointInCircle( UnitPoint, OuterRadius, InnerRadius )
SpawnTemplate.units[UnitID].x = CirclePos.x
SpawnTemplate.units[UnitID].y = CirclePos.y
end
self:T( 'SpawnTemplate.units['..UnitID..'].x = ' .. SpawnTemplate.units[UnitID].x .. ', SpawnTemplate.units['..UnitID..'].y = ' .. SpawnTemplate.units[UnitID].y )
end
local SpawnPos = routines.getRandPointInCircle( UnitPoint, InnerRadius+1, InnerRadius )
local SpawnPos = routines.getRandPointInCircle( UnitPoint, OuterRadius, InnerRadius )
local Point = {}
Point.type = "Turning Point"
Point.x = SpawnPos.x
@ -598,7 +598,7 @@ end
-- @return GROUP#GROUP that was spawned.
-- @return #nil when nothing was spawned.
function SPAWN:SpawnInZone( Zone, SpawnIndex )
self:T( { self.SpawnTemplatePrefix, Zone, SpawnIndex } )
self:F( { self.SpawnTemplatePrefix, Zone, SpawnIndex } )
if Zone then
@ -652,7 +652,7 @@ end
-- This will be similar to the uncontrolled flag setting in the ME.
-- @return #SPAWN self
function SPAWN:UnControlled()
self:T( { self.SpawnTemplatePrefix } )
self:F( { self.SpawnTemplatePrefix } )
self.SpawnUnControlled = true
@ -670,7 +670,7 @@ end
-- @param #number SpawnIndex Is the number of the Group that is to be spawned.
-- @return string SpawnGroupName
function SPAWN:SpawnGroupName( SpawnIndex )
self:T( { self.SpawnTemplatePrefix, SpawnIndex } )
self:F( { self.SpawnTemplatePrefix, SpawnIndex } )
local SpawnPrefix = self.SpawnTemplatePrefix
if self.SpawnAliasPrefix then
@ -694,7 +694,7 @@ end
-- @return GROUP#GROUP, #number The group found, the new index where the group was found.
-- @return #nil, #nil When no group is found, #nil is returned.
function SPAWN:GetFirstAliveGroup( SpawnCursor )
self:T( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, SpawnCursor } )
self:F( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, SpawnCursor } )
for SpawnIndex = 1, self.SpawnCount do
local SpawnGroup = self:GetGroupFromIndex( SpawnIndex )
@ -714,7 +714,7 @@ end
-- @return GROUP#GROUP, #number The group found, the new index where the group was found.
-- @return #nil, #nil When no group is found, #nil is returned.
function SPAWN:GetNextAliveGroup( SpawnCursor )
self:T( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, SpawnCursor } )
self:F( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, SpawnCursor } )
SpawnCursor = SpawnCursor + 1
for SpawnIndex = SpawnCursor, self.SpawnCount do
@ -730,7 +730,7 @@ end
--- Find the last alive group during runtime.
function SPAWN:GetLastAliveGroup()
self:T( { self.SpawnTemplatePrefixself.SpawnAliasPrefix } )
self:F( { self.SpawnTemplatePrefixself.SpawnAliasPrefix } )
self.SpawnIndex = self:_GetLastIndex()
for SpawnIndex = self.SpawnIndex, 1, -1 do
@ -754,7 +754,7 @@ end
-- @param #number SpawnIndex The index of the group to return.
-- @return GROUP#GROUP
function SPAWN:GetGroupFromIndex( SpawnIndex )
self:T( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, SpawnIndex } )
self:F( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, SpawnIndex } )
if SpawnIndex then
local SpawnGroup = self.SpawnGroups[SpawnIndex].Group
@ -773,7 +773,7 @@ end
-- @return #string The prefix
-- @return #nil Nothing found
function SPAWN:_GetGroupIndexFromDCSUnit( DCSUnit )
self:T( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, DCSUnit } )
self:F( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, DCSUnit } )
if DCSUnit and DCSUnit:getName() then
local IndexString = string.match( DCSUnit:getName(), "#.*-" ):sub( 2, -2 )
@ -797,7 +797,7 @@ end
-- @return #string The prefix
-- @return #nil Nothing found
function SPAWN:_GetPrefixFromDCSUnit( DCSUnit )
self:T( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, DCSUnit } )
self:F( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, DCSUnit } )
if DCSUnit and DCSUnit:getName() then
local SpawnPrefix = string.match( DCSUnit:getName(), ".*#" )
@ -813,7 +813,7 @@ end
--- Return the group within the SpawnGroups collection with input a DCSUnit.
function SPAWN:_GetGroupFromDCSUnit( DCSUnit )
self:T( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, DCSUnit } )
self:F( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, DCSUnit } )
if DCSUnit then
local SpawnPrefix = self:_GetPrefixFromDCSUnit( DCSUnit )
@ -833,7 +833,7 @@ end
--- Get the index from a given group.
-- The function will search the name of the group for a #, and will return the number behind the #-mark.
function SPAWN:GetSpawnIndexFromGroup( SpawnGroup )
self:T( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, SpawnGroup } )
self:F( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, SpawnGroup } )
local IndexString = string.match( SpawnGroup:GetName(), "#.*$" ):sub( 2 )
local Index = tonumber( IndexString )
@ -845,14 +845,14 @@ end
--- Return the last maximum index that can be used.
function SPAWN:_GetLastIndex()
self:T( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix } )
self:F( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix } )
return self.SpawnMaxGroups
end
--- Initalize the SpawnGroups collection.
function SPAWN:_InitializeSpawnGroups( SpawnIndex )
self:T( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, SpawnIndex } )
self:F( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, SpawnIndex } )
if not self.SpawnGroups[SpawnIndex] then
self.SpawnGroups[SpawnIndex] = {}
@ -899,7 +899,7 @@ end
--- Gets the CountryID of the Group with the given SpawnPrefix
function SPAWN:_GetGroupCountryID( SpawnPrefix )
self:T( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, SpawnPrefix } )
self:F( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, SpawnPrefix } )
local TemplateGroup = Group.getByName( SpawnPrefix )
@ -914,7 +914,7 @@ end
--- Gets the Group Template from the ME environment definition.
-- This method used the @{DATABASE} object, which contains ALL initial and new spawned object in MOOSE.
function SPAWN:_GetTemplate( SpawnTemplatePrefix )
self:T( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, SpawnTemplatePrefix } )
self:F( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, SpawnTemplatePrefix } )
local SpawnTemplate = nil
@ -934,7 +934,7 @@ end
--- Prepares the new Group Template.
function SPAWN:_Prepare( SpawnTemplatePrefix, SpawnIndex )
self:T( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix } )
self:F( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix } )
local SpawnTemplate = self:_GetTemplate( SpawnTemplatePrefix )
SpawnTemplate.name = self:SpawnGroupName( SpawnIndex )
@ -967,7 +967,7 @@ end
-- @param #number SpawnIndex The index of the group to be spawned.
-- @return #SPAWN
function SPAWN:_RandomizeRoute( SpawnIndex )
self:T( { self.SpawnTemplatePrefix, SpawnIndex, self.SpawnRandomizeRoute, self.SpawnRandomizeRouteStartPoint, self.SpawnRandomizeRouteEndPoint, self.SpawnRandomizeRouteRadius } )
self:F( { self.SpawnTemplatePrefix, SpawnIndex, self.SpawnRandomizeRoute, self.SpawnRandomizeRouteStartPoint, self.SpawnRandomizeRouteEndPoint, self.SpawnRandomizeRouteRadius } )
if self.SpawnRandomizeRoute then
local SpawnTemplate = self.SpawnGroups[SpawnIndex].SpawnTemplate
@ -988,7 +988,7 @@ end
function SPAWN:_RandomizeTemplate( SpawnIndex )
self:T( { self.SpawnTemplatePrefix, SpawnIndex } )
self:F( { self.SpawnTemplatePrefix, SpawnIndex } )
if self.SpawnRandomizeTemplate then
self.SpawnGroups[SpawnIndex].SpawnTemplatePrefix = self.SpawnTemplatePrefixTable[ math.random( 1, #self.SpawnTemplatePrefixTable ) ]
@ -1007,7 +1007,7 @@ function SPAWN:_RandomizeTemplate( SpawnIndex )
end
function SPAWN:_TranslateRotate( SpawnIndex, SpawnRootX, SpawnRootY, SpawnX, SpawnY, SpawnAngle )
self:T( { self.SpawnTemplatePrefix, SpawnIndex, SpawnRootX, SpawnRootY, SpawnX, SpawnY, SpawnAngle } )
self:F( { self.SpawnTemplatePrefix, SpawnIndex, SpawnRootX, SpawnRootY, SpawnX, SpawnY, SpawnAngle } )
-- Translate
local TranslatedX = SpawnX
@ -1051,7 +1051,7 @@ end
--- Get the next index of the groups to be spawned. This function is complicated, as it is used at several spaces.
function SPAWN:_GetSpawnIndex( SpawnIndex )
self:T( { self.SpawnTemplatePrefix, SpawnIndex, self.SpawnMaxGroups, self.SpawnMaxUnitsAlive, self.AliveUnits, #self.SpawnTemplate.units } )
self:F( { self.SpawnTemplatePrefix, SpawnIndex, self.SpawnMaxGroups, self.SpawnMaxUnitsAlive, self.AliveUnits, #self.SpawnTemplate.units } )
if ( self.SpawnMaxGroups == 0 ) or ( SpawnIndex <= self.SpawnMaxGroups ) then
@ -1170,7 +1170,7 @@ end
--- This function is called automatically by the Spawning scheduler.
-- It is the internal worker method SPAWNing new Groups on the defined time intervals.
function SPAWN:_Scheduler()
self:T( { "_Scheduler", self.SpawnTemplatePrefix, self.SpawnAliasPrefix, self.SpawnIndex, self.SpawnMaxGroups, self.SpawnMaxUnitsAlive } )
self:F( { "_Scheduler", self.SpawnTemplatePrefix, self.SpawnAliasPrefix, self.SpawnIndex, self.SpawnMaxGroups, self.SpawnMaxUnitsAlive } )
if self.SpawnInit or self.SpawnCurrentTimer == self.SpawnSetTimer then
-- Validate if there are still groups left in the batch...
@ -1188,7 +1188,7 @@ self:T( { "_Scheduler", self.SpawnTemplatePrefix, self.SpawnAliasPrefix, self.Sp
end
function SPAWN:_SpawnCleanUpScheduler()
self:T( { "CleanUp Scheduler:", self.SpawnTemplatePrefix } )
self:F( { "CleanUp Scheduler:", self.SpawnTemplatePrefix } )
local SpawnCursor
local SpawnGroup, SpawnCursor = self:GetFirstAliveGroup( SpawnCursor )

View File

@ -29,7 +29,7 @@ STAGE = {
function STAGE:New()
local self = BASE:Inherit( self, BASE:New() )
self:T()
self:F()
return self
end
@ -61,14 +61,14 @@ STAGEBRIEF = {
function STAGEBRIEF:New()
local self = BASE:Inherit( self, STAGE:New() )
self:T()
self:F()
self.StageType = 'CLIENT'
return self
end
function STAGEBRIEF:Execute( Mission, Client, Task )
local Valid = BASE:Inherited(self):Execute( Mission, Client, Task )
self:T()
self:F()
Mission:ShowBriefing( Client )
self.StageBriefingTime = timer.getTime()
return Valid
@ -98,13 +98,13 @@ STAGESTART = {
function STAGESTART:New()
local self = BASE:Inherit( self, STAGE:New() )
self:T()
self:F()
self.StageType = 'CLIENT'
return self
end
function STAGESTART:Execute( Mission, Client, Task )
self:T()
self:F()
local Valid = BASE:Inherited(self):Execute( Mission, Client, Task )
if Task.TaskBriefing then
Client:Message( Task.TaskBriefing, 30, Mission.Name .. "/Stage", "Mission Command: Tasking" )
@ -116,7 +116,7 @@ self:T()
end
function STAGESTART:Validate( Mission, Client, Task )
self:T()
self:F()
local Valid = STAGE:Validate( Mission, Client, Task )
if timer.getTime() - self.StageStartTime <= self.StageStartDuration then
@ -136,13 +136,13 @@ STAGE_CARGO_LOAD = {
function STAGE_CARGO_LOAD:New()
local self = BASE:Inherit( self, STAGE:New() )
self:T()
self:F()
self.StageType = 'CLIENT'
return self
end
function STAGE_CARGO_LOAD:Execute( Mission, Client, Task )
self:T()
self:F()
local Valid = BASE:Inherited(self):Execute( Mission, Client, Task )
for LoadCargoID, LoadCargo in pairs( Task.Cargos.LoadCargos ) do
@ -157,7 +157,7 @@ self:T()
end
function STAGE_CARGO_LOAD:Validate( Mission, Client, Task )
self:T()
self:F()
local Valid = STAGE:Validate( Mission, Client, Task )
return 1
@ -170,13 +170,13 @@ STAGE_CARGO_INIT = {
function STAGE_CARGO_INIT:New()
local self = BASE:Inherit( self, STAGE:New() )
self:T()
self:F()
self.StageType = 'CLIENT'
return self
end
function STAGE_CARGO_INIT:Execute( Mission, Client, Task )
self:T()
self:F()
local Valid = BASE:Inherited(self):Execute( Mission, Client, Task )
for InitLandingZoneID, InitLandingZone in pairs( Task.LandingZones.LandingZones ) do
@ -196,7 +196,7 @@ end
function STAGE_CARGO_INIT:Validate( Mission, Client, Task )
self:T()
self:F()
local Valid = STAGE:Validate( Mission, Client, Task )
return 1
@ -213,7 +213,7 @@ STAGEROUTE = {
function STAGEROUTE:New()
local self = BASE:Inherit( self, STAGE:New() )
self:T()
self:F()
self.StageType = 'CLIENT'
self.MessageSwitch = true
return self
@ -221,7 +221,7 @@ end
function STAGEROUTE:Execute( Mission, Client, Task )
self:T()
self:F()
local Valid = BASE:Inherited(self):Execute( Mission, Client, Task )
local RouteMessage = "Fly to "
@ -239,7 +239,7 @@ self:T()
end
function STAGEROUTE:Validate( Mission, Client, Task )
self:T()
self:F()
local Valid = STAGE:Validate( Mission, Client, Task )
-- check if the Client is in the landing zone
@ -274,13 +274,13 @@ STAGELANDING = {
function STAGELANDING:New()
local self = BASE:Inherit( self, STAGE:New() )
self:T()
self:F()
self.StageType = 'CLIENT'
return self
end
function STAGELANDING:Execute( Mission, Client, Task )
self:T()
self:F()
Client:Message( "We have arrived at the landing zone.", self.MSG.TIME, Mission.Name .. "/StageArrived", "Co-Pilot: Arrived", 10 )
@ -332,7 +332,7 @@ self:T()
end
function STAGELANDING:Validate( Mission, Client, Task )
self:T()
self:F()
Task.CurrentLandingZoneName = routines.IsUnitInZones( Client:GetClientGroupDCSUnit(), Task.LandingZones.LandingZoneNames )
if Task.CurrentLandingZoneName then
@ -376,13 +376,13 @@ STAGELANDED = {
function STAGELANDED:New()
local self = BASE:Inherit( self, STAGE:New() )
self:T()
self:F()
self.StageType = 'CLIENT'
return self
end
function STAGELANDED:Execute( Mission, Client, Task )
self:T()
self:F()
if Task.IsLandingRequired then
Client:Message( 'We have landed within the landing zone. Use the radio menu (F10) to ' .. Task.TEXT[1] .. ' the ' .. Task.CargoType .. '.',
@ -398,7 +398,7 @@ end
function STAGELANDED:Validate( Mission, Client, Task )
self:T()
self:F()
if not routines.IsUnitInZones( Client:GetClientGroupDCSUnit(), Task.CurrentLandingZoneName ) then
self:T( "Client is not anymore in the landing zone, go back to stage Route, and remove cargo menus." )
@ -431,20 +431,20 @@ STAGEUNLOAD = {
function STAGEUNLOAD:New()
local self = BASE:Inherit( self, STAGE:New() )
self:T()
self:F()
self.StageType = 'CLIENT'
return self
end
function STAGEUNLOAD:Execute( Mission, Client, Task )
self:T()
self:F()
Client:Message( 'The ' .. Task.CargoType .. ' are being ' .. Task.TEXT[2] .. ' within the landing zone. Wait until the helicopter is ' .. Task.TEXT[3] .. '.',
self.MSG.TIME, Mission.Name .. "/StageUnLoad", "Co-Pilot: Unload" )
Task:RemoveCargoMenus( Client )
end
function STAGEUNLOAD:Executing( Mission, Client, Task )
self:T()
self:F()
env.info( 'STAGEUNLOAD:Executing() Task.Cargo.CargoName = ' .. Task.Cargo.CargoName )
local TargetZoneName
@ -464,7 +464,7 @@ self:T()
end
function STAGEUNLOAD:Validate( Mission, Client, Task )
self:T()
self:F()
env.info( 'STAGEUNLOAD:Validate()' )
if routines.IsUnitInZones( Client:GetClientGroupDCSUnit(), Task.CurrentLandingZoneName ) then
@ -503,13 +503,13 @@ STAGELOAD = {
function STAGELOAD:New()
local self = BASE:Inherit( self, STAGE:New() )
self:T()
self:F()
self.StageType = 'CLIENT'
return self
end
function STAGELOAD:Execute( Mission, Client, Task )
self:T()
self:F()
if not Task.IsSlingLoad then
Client:Message( 'The ' .. Task.CargoType .. ' are being ' .. Task.TEXT[2] .. ' within the landing zone. Wait until the helicopter is ' .. Task.TEXT[3] .. '.',
@ -524,13 +524,13 @@ self:T()
end
function STAGELOAD:Executing( Mission, Client, Task )
self:T()
self:F()
-- If the Cargo is ready to be loaded, load it into the Client.
if not Task.IsSlingLoad then
trace.i(self.ClassName, Task.Cargo.CargoName)
self:T( Task.Cargo.CargoName)
if Task.Cargo:OnBoarded( Client, Task.CurrentCargoZone ) then
@ -553,12 +553,12 @@ self:T()
if Cargo:IsSlingLoad() then
local CargoStatic = StaticObject.getByName( Cargo.CargoStaticName )
if CargoStatic then
trace.i(self.ClassName, "Cargo is found in the DCS simulator.")
self:T( "Cargo is found in the DCS simulator.")
local CargoStaticPosition = CargoStatic:getPosition().p
trace.i(self.ClassName, "Cargo Position x = " .. CargoStaticPosition.x .. ", y = " .. CargoStaticPosition.y .. ", z = " .. CargoStaticPosition.z )
self:T( "Cargo Position x = " .. CargoStaticPosition.x .. ", y = " .. CargoStaticPosition.y .. ", z = " .. CargoStaticPosition.z )
local CargoStaticHeight = routines.GetUnitHeight( CargoStatic )
if CargoStaticHeight > 5 then
trace.i(self.ClassName, "Cargo is airborne.")
self:T( "Cargo is airborne.")
Cargo:StatusLoaded()
Task.Cargo = Cargo
Client:Message( 'The Cargo has been successfully hooked onto the helicopter and is now being sling loaded. Fly outside the landing zone.',
@ -576,7 +576,7 @@ self:T()
end
function STAGELOAD:Validate( Mission, Client, Task )
self:T()
self:F()
self:T( "Task.CurrentLandingZoneName = " .. Task.CurrentLandingZoneName )
@ -635,18 +635,18 @@ STAGEDONE = {
function STAGEDONE:New()
local self = BASE:Inherit( self, STAGE:New() )
self:T()
self:F()
self.StageType = 'AI'
return self
end
function STAGEDONE:Execute( Mission, Client, Task )
self:T()
self:F()
end
function STAGEDONE:Validate( Mission, Client, Task )
self:T()
self:F()
Task:Done()
@ -661,20 +661,20 @@ STAGEARRIVE = {
function STAGEARRIVE:New()
local self = BASE:Inherit( self, STAGE:New() )
self:T()
self:F()
self.StageType = 'CLIENT'
return self
end
function STAGEARRIVE:Execute( Mission, Client, Task )
self:T()
self:F()
Client:Message( 'We have arrived at ' .. Task.CurrentLandingZoneName .. ".", self.MSG.TIME, Mission.Name .. "/Stage", "Co-Pilot: Arrived" )
end
function STAGEARRIVE:Validate( Mission, Client, Task )
self:T()
self:F()
Task.CurrentLandingZoneID = routines.IsUnitInZones( Client:GetClientGroupDCSUnit(), Task.LandingZones )
if ( Task.CurrentLandingZoneID ) then
@ -695,7 +695,7 @@ STAGEGROUPSDESTROYED = {
function STAGEGROUPSDESTROYED:New()
local self = BASE:Inherit( self, STAGE:New() )
self:T()
self:F()
self.StageType = 'AI'
return self
end
@ -707,7 +707,7 @@ end
--end
function STAGEGROUPSDESTROYED:Validate( Mission, Client, Task )
self:T()
self:F()
if Task.MissionTask:IsGoalReached() then
return 1
@ -717,7 +717,7 @@ self:T()
end
function STAGEGROUPSDESTROYED:Execute( Mission, Client, Task )
self:T()
self:F()
self:T( { Task.ClassName, Task.Destroyed } )
--env.info( 'Event Table Task = ' .. tostring(Task) )

View File

@ -48,10 +48,9 @@ TASK = {
--- Instantiates a new TASK Base. Should never be used. Interface Class.
-- @return TASK
function TASK:New()
trace.f(self.ClassName)
local self = BASE:Inherit( self, BASE:New() )
self:F()
-- assign Task default values during construction
self.TaskBriefing = "Task: No Task."
self.Time = timer.getTime()
@ -61,14 +60,14 @@ trace.f(self.ClassName)
end
function TASK:SetStage( StageSequenceIncrement )
trace.f(self.ClassName, { StageSequenceIncrement } )
self:F( { StageSequenceIncrement } )
local Valid = false
if StageSequenceIncrement ~= 0 then
self.ActiveStage = self.ActiveStage + StageSequenceIncrement
if 1 <= self.ActiveStage and self.ActiveStage <= #self.Stages then
self.Stage = self.Stages[self.ActiveStage]
trace.i( self.ClassName, { self.Stage.Name } )
self:T( { self.Stage.Name } )
self.Frequency = self.Stage.Frequency
Valid = true
else
@ -81,7 +80,7 @@ trace.f(self.ClassName, { StageSequenceIncrement } )
end
function TASK:Init()
trace.f(self.ClassName)
self:F()
self.ActiveStage = 0
self:SetStage(1)
self.TaskDone = false
@ -92,7 +91,7 @@ end
--- Get progress of a TASK.
-- @return string GoalsText
function TASK:GetGoalProgress()
trace.f(self.ClassName)
self:F()
local GoalsText = ""
for GoalVerb, GoalVerbData in pairs( self.GoalTasks ) do
@ -116,7 +115,7 @@ end
-- @param MISSION Mission Group structure describing the Mission.
-- @param CLIENT Client Group structure describing the Client.
function TASK:ShowGoalProgress( Mission, Client )
trace.f(self.ClassName)
self:F()
local GoalsText = ""
for GoalVerb, GoalVerbData in pairs( self.GoalTasks ) do
@ -138,32 +137,32 @@ end
--- Sets a TASK to status Done.
function TASK:Done()
trace.f(self.ClassName)
self:F()
self.TaskDone = true
end
--- Returns if a TASK is done.
-- @return bool
function TASK:IsDone()
trace.i( self.ClassName, self.TaskDone )
self:F( self.TaskDone )
return self.TaskDone
end
--- Sets a TASK to status failed.
function TASK:Failed()
trace.f(self.ClassName)
self:F()
self.TaskFailed = true
end
--- Returns if a TASk has failed.
-- @return bool
function TASK:IsFailed()
trace.i( self.ClassName, self.TaskFailed )
self:F( self.TaskFailed )
return self.TaskFailed
end
function TASK:Reset( Mission, Client )
trace.f(self.ClassName)
self:F()
self.ExecuteStage = _TransportExecuteStage.NONE
end
@ -177,7 +176,7 @@ end
-- @param ?string GoalVerb is the name of the Goal of the TASK.
-- @return bool
function TASK:Goal( GoalVerb )
trace.f(self.ClassName)
self:F()
if not GoalVerb then
GoalVerb = self.GoalVerb
end
@ -192,7 +191,7 @@ end
-- @param number GoalTotal is the number of times the GoalVerb needs to be achieved.
-- @param ?string GoalVerb is the name of the Goal of the TASK. If the GoalVerb is not given, then the default TASK Goals will be used.
function TASK:SetGoalTotal( GoalTotal, GoalVerb )
trace.f(self.ClassName, { GoalTotal, GoalVerb } )
self:F( { GoalTotal, GoalVerb } )
if not GoalVerb then
GoalVerb = self.GoalVerb
@ -207,7 +206,7 @@ end
--- Gets the total of Goals to be achieved within the TASK of the GoalVerb.
-- @param ?string GoalVerb is the name of the Goal of the TASK. If the GoalVerb is not given, then the default TASK Goals will be used.
function TASK:GetGoalTotal( GoalVerb )
trace.f(self.ClassName)
self:F()
if not GoalVerb then
GoalVerb = self.GoalVerb
end
@ -223,7 +222,7 @@ end
-- @param ?string GoalVerb is the name of the Goal of the TASK. If the GoalVerb is not given, then the default TASK Goals will be used.
-- @return TASK
function TASK:SetGoalCount( GoalCount, GoalVerb )
trace.f(self.ClassName)
self:F()
if not GoalVerb then
GoalVerb = self.GoalVerb
end
@ -238,7 +237,7 @@ end
-- @param ?string GoalVerb is the name of the Goal of the TASK. If the GoalVerb is not given, then the default TASK Goals will be used.
-- @return TASK
function TASK:IncreaseGoalCount( GoalCountIncrease, GoalVerb )
trace.f(self.ClassName)
self:F()
if not GoalVerb then
GoalVerb = self.GoalVerb
end
@ -252,7 +251,7 @@ end
-- @param ?string GoalVerb is the name of the Goal of the TASK. If the GoalVerb is not given, then the default TASK Goals will be used.
-- @return TASK
function TASK:GetGoalCount( GoalVerb )
trace.f(self.ClassName)
self:F()
if not GoalVerb then
GoalVerb = self.GoalVerb
end
@ -267,7 +266,7 @@ end
-- @param ?string GoalVerb is the name of the Goal of the TASK. If the GoalVerb is not given, then the default TASK Goals will be used.
-- @return TASK
function TASK:GetGoalPercentage( GoalVerb )
trace.f(self.ClassName)
self:F()
if not GoalVerb then
GoalVerb = self.GoalVerb
end
@ -285,10 +284,10 @@ function TASK:IsGoalReached( )
local GoalReached = true
for GoalVerb, Goals in pairs( self.GoalTasks ) do
trace.i( self.ClassName, { "GoalVerb", GoalVerb } )
self:T( { "GoalVerb", GoalVerb } )
if self:Goal( GoalVerb ) then
local GoalToDo = self:GetGoalTotal( GoalVerb ) - self:GetGoalCount( GoalVerb )
trace.i( self.ClassName, "GoalToDo = " .. GoalToDo )
self:T( "GoalToDo = " .. GoalToDo )
if GoalToDo <= 0 then
else
GoalReached = false
@ -299,7 +298,7 @@ function TASK:IsGoalReached( )
end
end
trace.i( self.ClassName, GoalReached )
self:T( GoalReached )
return GoalReached
end
@ -308,7 +307,7 @@ end
-- @param string GoalTask is a text describing the Goal of the TASK to be achieved.
-- @param number GoalIncrease is a number by which the Goal achievement is increasing.
function TASK:AddGoalCompletion( GoalVerb, GoalTask, GoalIncrease )
trace.f( self.ClassName, { GoalVerb, GoalTask, GoalIncrease } )
self:F( { GoalVerb, GoalTask, GoalIncrease } )
if self:Goal( GoalVerb ) then
self.GoalTasks[GoalVerb].Goals[#self.GoalTasks[GoalVerb].Goals+1] = GoalTask
@ -321,7 +320,7 @@ end
-- @param ?string GoalVerb is the name of the Goal of the TASK. If the GoalVerb is not given, then the default TASK Goals will be used.
-- @return string Goals
function TASK:GetGoalCompletion( GoalVerb )
trace.f( self.ClassName, { GoalVerb } )
self:F( { GoalVerb } )
if self:Goal( GoalVerb ) then
local Goals = ""
@ -331,14 +330,12 @@ trace.f( self.ClassName, { GoalVerb } )
end
function TASK.MenuAction( Parameter )
trace.menu("TASK","MenuAction")
trace.l( "TASK", "MenuAction" )
Parameter.ReferenceTask.ExecuteStage = _TransportExecuteStage.EXECUTING
Parameter.ReferenceTask.Cargo = Parameter.CargoTask
end
function TASK:StageExecute()
trace.f(self.ClassName)
self:F()
local Execute = false
@ -357,7 +354,7 @@ end
--- Work function to set signal events within a TASK.
function TASK:AddSignal( SignalUnitNames, SignalType, SignalColor, SignalHeight )
trace.f(self.ClassName)
self:F()
local Valid = true
@ -388,7 +385,7 @@ end
-- @param table|string SignalUnitNames Name of the Group that will fire the signal. If this parameter is NIL, the signal will be fired from the center of the landing zone.
-- @param number SignalHeight Altitude that the Signal should be fired...
function TASK:AddSmokeRed( SignalUnitNames, SignalHeight )
trace.f(self.ClassName)
self:F()
self:AddSignal( SignalUnitNames, TASK.SIGNAL.TYPE.SMOKE, TASK.SIGNAL.COLOR.RED, SignalHeight )
end
@ -396,7 +393,7 @@ end
-- @param table|string SignalUnitNames Name of the Group that will fire the signal. If this parameter is NIL, the signal will be fired from the center of the landing zone.
-- @param number SignalHeight Altitude that the Signal should be fired...
function TASK:AddSmokeGreen( SignalUnitNames, SignalHeight )
trace.f(self.ClassName)
self:F()
self:AddSignal( SignalUnitNames, TASK.SIGNAL.TYPE.SMOKE, TASK.SIGNAL.COLOR.GREEN, SignalHeight )
end
@ -404,7 +401,7 @@ end
-- @param table|string SignalUnitNames Name of the Group that will fire the signal. If this parameter is NIL, the signal will be fired from the center of the landing zone.
-- @param number SignalHeight Altitude that the Signal should be fired...
function TASK:AddSmokeBlue( SignalUnitNames, SignalHeight )
trace.f(self.ClassName)
self:F()
self:AddSignal( SignalUnitNames, TASK.SIGNAL.TYPE.SMOKE, TASK.SIGNAL.COLOR.BLUE, SignalHeight )
end
@ -412,7 +409,7 @@ end
-- @param table|string SignalUnitNames Name of the Group that will fire the signal. If this parameter is NIL, the signal will be fired from the center of the landing zone.
-- @param number SignalHeight Altitude that the Signal should be fired...
function TASK:AddSmokeWhite( SignalUnitNames, SignalHeight )
trace.f(self.ClassName)
self:F()
self:AddSignal( SignalUnitNames, TASK.SIGNAL.TYPE.SMOKE, TASK.SIGNAL.COLOR.WHITE, SignalHeight )
end
@ -420,7 +417,7 @@ end
-- @param table|string SignalUnitNames Name of the Group that will fire the signal. If this parameter is NIL, the signal will be fired from the center of the landing zone.
-- @param number SignalHeight Altitude that the Signal should be fired...
function TASK:AddSmokeOrange( SignalUnitNames, SignalHeight )
trace.f(self.ClassName)
self:F()
self:AddSignal( SignalUnitNames, TASK.SIGNAL.TYPE.SMOKE, TASK.SIGNAL.COLOR.ORANGE, SignalHeight )
end
@ -428,7 +425,7 @@ end
-- @param table|string SignalUnitNames Name of the Group that will fire the signal. If this parameter is NIL, the signal will be fired from the center of the landing zone.
-- @param number SignalHeight Altitude that the Signal should be fired...
function TASK:AddFlareRed( SignalUnitNames, SignalHeight )
trace.f(self.ClassName)
self:F()
self:AddSignal( SignalUnitNames, TASK.SIGNAL.TYPE.FLARE, TASK.SIGNAL.COLOR.RED, SignalHeight )
end
@ -436,7 +433,7 @@ end
-- @param table|string SignalUnitNames Name of the Group that will fire the signal. If this parameter is NIL, the signal will be fired from the center of the landing zone.
-- @param number SignalHeight Altitude that the Signal should be fired...
function TASK:AddFlareGreen( SignalUnitNames, SignalHeight )
trace.f(self.ClassName)
self:F()
self:AddSignal( SignalUnitNames, TASK.SIGNAL.TYPE.FLARE, TASK.SIGNAL.COLOR.GREEN, SignalHeight )
end
@ -444,7 +441,7 @@ end
-- @param table|string SignalUnitNames Name of the Group that will fire the signal. If this parameter is NIL, the signal will be fired from the center of the landing zone.
-- @param number SignalHeight Altitude that the Signal should be fired...
function TASK:AddFlareBlue( SignalUnitNames, SignalHeight )
trace.f(self.ClassName)
self:F()
self:AddSignal( SignalUnitNames, TASK.SIGNAL.TYPE.FLARE, TASK.SIGNAL.COLOR.BLUE, SignalHeight )
end
@ -452,7 +449,7 @@ end
-- @param table|string SignalUnitNames Name of the Group that will fire the signal. If this parameter is NIL, the signal will be fired from the center of the landing zone.
-- @param number SignalHeight Altitude that the Signal should be fired...
function TASK:AddFlareWhite( SignalUnitNames, SignalHeight )
trace.f(self.ClassName)
self:F()
self:AddSignal( SignalUnitNames, TASK.SIGNAL.TYPE.FLARE, TASK.SIGNAL.COLOR.WHITE, SignalHeight )
end
@ -460,6 +457,6 @@ end
-- @param table|string SignalUnitNames Name of the Group that will fire the signal. If this parameter is NIL, the signal will be fired from the center of the landing zone.
-- @param number SignalHeight Altitude that the Signal should be fired...
function TASK:AddFlareOrange( SignalUnitNames, SignalHeight )
trace.f(self.ClassName)
self:F()
self:AddSignal( SignalUnitNames, TASK.SIGNAL.TYPE.FLARE, TASK.SIGNAL.COLOR.ORANGE, SignalHeight )
end

View File

@ -21,7 +21,7 @@ UNIT = {
function UNIT:New( DCSUnit )
local self = BASE:Inherit( self, BASE:New() )
self:T( DCSUnit:getName() )
self:F( DCSUnit:getName() )
self.DCSUnit = DCSUnit
self.UnitName = DCSUnit:getName()
@ -31,39 +31,39 @@ function UNIT:New( DCSUnit )
end
function UNIT:IsAlive()
self:T( self.UnitName )
self:F( self.UnitName )
return ( self.DCSUnit and self.DCSUnit:isExist() )
end
function UNIT:GetDCSUnit()
self:T( self.DCSUnit )
self:F( self.DCSUnit )
return self.DCSUnit
end
function UNIT:GetID()
self:T( self.UnitID )
self:F( self.UnitID )
return self.UnitID
end
function UNIT:GetName()
self:T( self.UnitName )
self:F( self.UnitName )
return self.UnitName
end
function UNIT:GetTypeName()
self:T( self.UnitName )
self:F( self.UnitName )
return self.DCSUnit:getTypeName()
end
function UNIT:GetPrefix()
self:T( self.UnitName )
self:F( self.UnitName )
local UnitPrefix = string.match( self.UnitName, ".*#" ):sub( 1, -2 )
self:T( UnitPrefix )
@ -73,14 +73,14 @@ end
function UNIT:GetCallSign()
self:T( self.UnitName )
self:F( self.UnitName )
return self.DCSUnit:getCallsign()
end
function UNIT:GetPointVec2()
self:T( self.UnitName )
self:F( self.UnitName )
local UnitPos = self.DCSUnit:getPosition().p
@ -94,7 +94,7 @@ end
function UNIT:GetPositionVec3()
self:T( self.UnitName )
self:F( self.UnitName )
local UnitPos = self.DCSUnit:getPosition().p
@ -103,7 +103,7 @@ function UNIT:GetPositionVec3()
end
function UNIT:OtherUnitInRadius( AwaitUnit, Radius )
self:T( { self.UnitName, AwaitUnit.UnitName, Radius } )
self:F( { self.UnitName, AwaitUnit.UnitName, Radius } )
local UnitPos = self:GetPositionVec3()
local AwaitUnitPos = AwaitUnit:GetPositionVec3()

View File

@ -13,9 +13,8 @@ ZONE = {
}
function ZONE:New( ZoneName )
trace.f( self.ClassName, ZoneName )
local self = BASE:Inherit( self, BASE:New() )
self:F( ZoneName )
local Zone = trigger.misc.getZone( ZoneName )
@ -31,7 +30,7 @@ trace.f( self.ClassName, ZoneName )
end
function ZONE:GetPointVec2()
self:T( self.ZoneName )
self:F( self.ZoneName )
local Zone = trigger.misc.getZone( self.ZoneName )
local Point = { x = Zone.point.x, y = Zone.point.z }
@ -42,7 +41,7 @@ function ZONE:GetPointVec2()
end
function ZONE:GetRandomPoint()
trace.f( self.ClassName, self.ZoneName )
self:F( self.ZoneName )
local Point = {}
@ -51,18 +50,17 @@ trace.f( self.ClassName, self.ZoneName )
Point.x = Zone.point.x + math.random( Zone.radius * -1, Zone.radius )
Point.y = Zone.point.z + math.random( Zone.radius * -1, Zone.radius )
trace.i( self.ClassName, { Zone } )
trace.i( self.ClassName, { Point } )
self:T( { Zone, Point } )
return Point
end
function ZONE:GetRadius()
trace.f( self.ClassName, self.ZoneName )
self:F( self.ZoneName )
local Zone = trigger.misc.getZone( self.ZoneName )
trace.i( self.ClassName, { Zone } )
self:T( { Zone } )
return Zone.radius
end