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
+3 -2
View File
@@ -1,9 +1,10 @@
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
-- @module Airbase -- @module DCSAirbase
-- @extends CoalitionObject#CoalitionObject
--- Represents airbases: airdromes, helipads and ships with flying decks or landing pads. --- Represents airbases: airdromes, helipads and ships with flying decks or landing pads.
-- @type Airbase -- @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.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.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. -- @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.
@@ -1,8 +1,8 @@
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
-- @module CoalitionObject -- @module DCSCoalitionObject
-- @extends Object#Object
--- @type CoalitionObject --- @type CoalitionObject
-- @extends DCSObject#Object
--- Returns coalition of the object. --- Returns coalition of the object.
-- @function [parent=#CoalitionObject] getCoalition -- @function [parent=#CoalitionObject] getCoalition
@@ -1,6 +1,5 @@
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
-- @module Controller -- @module DCSController
-- TODO Add Task templates
--- 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. --- 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.
-- --
+27 -27
View File
@@ -1,6 +1,5 @@
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
-- @module Group -- @module DCSGroup
--- Represents group of Units. --- Represents group of Units.
-- @type Group -- @type Group
@@ -17,66 +16,67 @@
-- Static Functions -- Static Functions
--- Returns group by the name assigned to the group in Mission Editor. --- Returns group by the name assigned to the group in Mission Editor.
-- @function [parent=#Airbase] getByName -- @function [parent=#Group] getByName
-- @param #string name -- @param #string name
-- @return #Group -- @return #Group
-- Member Functions -- Member Functions
--- returns true if the group exist or false otherwise. --- returns true if the group exist or false otherwise.
-- @function [parent=#Airbase] isExist -- @function [parent=#Group] isExist
-- @param self -- @param #Group self
-- @return #boolean -- @return #boolean
--- Destroys the group and all of its units. --- Destroys the group and all of its units.
-- @function [parent=#Airbase] destroy -- @function [parent=#Group] destroy
-- @param self -- @param #Group self
--- Returns category of the group. --- Returns category of the group.
-- @function [parent=#Airbase] getCategory -- @function [parent=#Group] getCategory
-- @param self -- @param #Group self
-- @return #Group.Category -- @return #Group.Category
--TODO check coalition.side --TODO check coalition.side
--- Returns coalition of the group. --- Returns coalition of the group.
-- @function [parent=#Airbase] getCoalition -- @function [parent=#Group] getCoalition
-- @param self -- @param #Group self
-- @return #coalition.side -- @return #coalition.side
--- Returns the group's name. This is the same name assigned to the group in Mission Editor. --- Returns the group's name. This is the same name assigned to the group in Mission Editor.
-- @function [parent=#Airbase] getName -- @function [parent=#Group] getName
-- @param self -- @param #Group self
-- @return #string -- @return #string
--- Returns the group identifier. --- Returns the group identifier.
-- @function [parent=#Airbase] getID -- @function [parent=#Group] getID
-- @param self -- @param #Group self
-- @return #ID -- @return #ID
--- Returns the unit with number unitNumber. If the unit is not exists the function will return nil. --- Returns the unit with number unitNumber. If the unit is not exists the function will return nil.
-- @function [parent=#Airbase] getUnit -- @function [parent=#Group] getUnit
-- @param self -- @param #Group self
-- @param #number unitNumber -- @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. --- 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 -- @function [parent=#Group] getSize
-- @param self -- @param #Group self
-- @return #number -- @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. --- 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 -- @function [parent=#Group] getInitialSize
-- @param self -- @param #Group self
-- @return #number -- @return #number
--- Returns array of the units present in the group now. Destroyed units will not be enlisted at all. --- Returns array of the units present in the group now. Destroyed units will not be enlisted at all.
-- @function [parent=#Airbase] getUnits -- @function [parent=#Group] getUnits
-- @param self -- @param #Group self
-- @return #list<Unit#Unit> array of Units -- @return #list<DCSUnit#Unit> array of Units
--- Returns controller of the group. --- Returns controller of the group.
-- @function [parent=#Airbase] getController -- @function [parent=#Group] getController
-- @param self -- @param #Group self
-- @return Controller#Controller -- @return Controller#Controller
Group = {} --#Group Group = {} --#Group
+12 -12
View File
@@ -1,5 +1,5 @@
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
-- @module Object -- @module DCSObject
--- @type Object --- @type Object
-- @field #Object.Category Category -- @field #Object.Category Category
@@ -18,55 +18,55 @@
-- @field #Box3 box bounding box of collision geometry -- @field #Box3 box bounding box of collision geometry
--- @function [parent=#Object] isExist --- @function [parent=#Object] isExist
-- @param self -- @param #Object self
-- @return #boolean -- @return #boolean
--- @function [parent=#Object] destroy --- @function [parent=#Object] destroy
-- @param self -- @param #Object self
--- @function [parent=#Object] getCategory --- @function [parent=#Object] getCategory
-- @param self -- @param #Object self
-- @return #Object.Category -- @return #Object.Category
--- Returns type name of the Object. --- Returns type name of the Object.
-- @function [parent=#Object] getTypeName -- @function [parent=#Object] getTypeName
-- @param self -- @param #Object self
-- @return #string -- @return #string
--- Returns object descriptor. --- Returns object descriptor.
-- @function [parent=#Object] getDesc -- @function [parent=#Object] getDesc
-- @param self -- @param #Object self
-- @return #Object.Desc -- @return #Object.Desc
--- Returns true if the object belongs to the category. --- Returns true if the object belongs to the category.
-- @function [parent=#Object] hasAttribute -- @function [parent=#Object] hasAttribute
-- @param self -- @param #Object self
-- @param #AttributeName attributeName Attribute name to check. -- @param #AttributeName attributeName Attribute name to check.
-- @return #boolean -- @return #boolean
--- Returns name of the object. This is the name that is assigned to the object in the Mission Editor. --- Returns name of the object. This is the name that is assigned to the object in the Mission Editor.
-- @function [parent=#Object] getName -- @function [parent=#Object] getName
-- @param self -- @param #Object self
-- @return #string -- @return #string
--- Returns object coordinates for current time. --- Returns object coordinates for current time.
-- @function [parent=#Object] getPoint -- @function [parent=#Object] getPoint
-- @param self -- @param #Object self
-- @return #Vec3 -- @return #Vec3
--- Returns object position for current time. --- Returns object position for current time.
-- @function [parent=#Object] getPosition -- @function [parent=#Object] getPosition
-- @param self -- @param #Object self
-- @return #Position3 -- @return #Position3
--- Returns the unit's velocity vector. --- Returns the unit's velocity vector.
-- @function [parent=#Object] getVelocity -- @function [parent=#Object] getVelocity
-- @param self -- @param #Object self
-- @return #Vec3 -- @return #Vec3
--- Returns true if the unit is in air. --- Returns true if the unit is in air.
-- @function [parent=#Object] inAir -- @function [parent=#Object] inAir
-- @param self -- @param #Object self
-- @return #boolean -- @return #boolean
Object = {} --#Object Object = {} --#Object
@@ -1,5 +1,5 @@
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
-- @module StaticObject -- @module DCSStaticObject
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
@@ -22,12 +22,12 @@
--- returns identifier of the static object. --- returns identifier of the static object.
-- @function [parent=#StaticObject] getID -- @function [parent=#StaticObject] getID
-- @param self -- @param #StaticObject self
-- @return #StaticObject.ID -- @return #StaticObject.ID
--- Returns descriptor of the StaticObject. --- Returns descriptor of the StaticObject.
-- @function [parent=#StaticObject] getDesc -- @function [parent=#StaticObject] getDesc
-- @param self -- @param #StaticObject self
-- @return #StaticObject.Desc -- @return #StaticObject.Desc
+8
View File
@@ -0,0 +1,8 @@
--- @type DCSTask
-- @field #string id
-- @field #DCSTask.param param
--- @type DCSTask.param
env.info( "DCSTask defined" )
+19 -19
View File
@@ -1,8 +1,8 @@
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
-- @module Unit -- @module DCSUnit
-- @extends CoalitionObject#CoalitionObject
--- @type Unit --- @type Unit
-- @extends DCSCoalitionObject#CoalitionObject
-- @field ID Identifier of an unit. It assigned to an unit by the Mission Editor automatically. -- @field ID Identifier of an unit. It assigned to an unit by the Mission Editor automatically.
-- @field #Unit.Category Category -- @field #Unit.Category Category
-- @field #Unit.RefuelingSystem RefuelingSystem -- @field #Unit.RefuelingSystem RefuelingSystem
@@ -151,68 +151,68 @@
--- Returns if the unit is activated. --- Returns if the unit is activated.
-- @function [parent=#Unit] isActive -- @function [parent=#Unit] isActive
-- @param self -- @param #Unit self
-- @return #boolean -- @return #boolean
--- Returns name of the player that control the unit or nil if the unit is controlled by A.I. --- Returns name of the player that control the unit or nil if the unit is controlled by A.I.
-- @function [parent=#Unit] getPlayerName -- @function [parent=#Unit] getPlayerName
-- @param self -- @param #Unit self
-- @return #string -- @return #string
--- returns the unit's unique identifier. --- returns the unit's unique identifier.
-- @function [parent=#Unit] getID -- @function [parent=#Unit] getID
-- @param self -- @param #Unit self
-- @return #Unit.ID -- @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. --- 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 -- @function [parent=#Unit] getNumber
-- @param self -- @param #Unit self
-- @return #number -- @return #number
--- Returns controller of the unit if it exist and nil otherwise --- Returns controller of the unit if it exist and nil otherwise
-- @function [parent=#Unit] getController -- @function [parent=#Unit] getController
-- @param self -- @param #Unit self
-- @return #Controller -- @return #Controller
--- Returns the unit's group if it exist and nil otherwise --- Returns the unit's group if it exist and nil otherwise
-- @function [parent=#Unit] getGroup -- @function [parent=#Unit] getGroup
-- @param self -- @param #Unit self
-- @return Group#Group -- @return DCSGroup#Group
--- Returns the unit's callsign - the localized string. --- Returns the unit's callsign - the localized string.
-- @function [parent=#Unit] getCallsign -- @function [parent=#Unit] getCallsign
-- @param self -- @param #Unit self
-- @return #string -- @return #string
--- Returns the unit's health. Dead units has health <= 1.0 --- Returns the unit's health. Dead units has health <= 1.0
-- @function [parent=#Unit] getLife -- @function [parent=#Unit] getLife
-- @param self -- @param #Unit self
-- @return #number -- @return #number
--- returns the unit's initial health. --- returns the unit's initial health.
-- @function [parent=#Unit] getLife0 -- @function [parent=#Unit] getLife0
-- @param self -- @param #Unit self
-- @return #number -- @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. --- 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 -- @function [parent=#Unit] getFuel
-- @param self -- @param #Unit self
-- @return #number -- @return #number
--- Returns the unit ammunition. --- Returns the unit ammunition.
-- @function [parent=#Unit] getAmmo -- @function [parent=#Unit] getAmmo
-- @param self -- @param #Unit self
-- @return #Unit.Ammo -- @return #Unit.Ammo
--- Returns the unit sensors. --- Returns the unit sensors.
-- @function [parent=#Unit] getSensors -- @function [parent=#Unit] getSensors
-- @param self -- @param #Unit self
-- @return #Unit.Sensors -- @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. --- 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 -- @function [parent=#Unit] hasSensors
-- @param self -- @param #Unit self
-- @param #Unit.SensorType sensorType (= nil) Sensor type. -- @param #Unit.SensorType sensorType (= nil) Sensor type.
-- @param ... Additional parameters. -- @param ... Additional parameters.
-- @return #boolean -- @return #boolean
@@ -229,13 +229,13 @@
-- First value indicates if at least one of the unit's radar(s) is on. -- 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. -- 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 -- @function [parent=#Unit] getRadar
-- @param self -- @param #Unit self
-- @return #boolean, Object#Object -- @return #boolean, Object#Object
--- Returns unit descriptor. Descriptor type depends on unit category. --- Returns unit descriptor. Descriptor type depends on unit category.
-- @function [parent=#Unit] getDesc -- @function [parent=#Unit] getDesc
-- @param self -- @param #Unit self
-- @return Unit#Unit.Desc -- @return #Unit.Desc
Unit = {} --#Unit Unit = {} --#Unit
+1 -1
View File
@@ -1,5 +1,5 @@
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
-- @module timer -- @module DCStimer
--- @type timer --- @type timer
File diff suppressed because it is too large Load Diff
+91 -15
View File
@@ -4,8 +4,9 @@
Include.File( "Routines" ) Include.File( "Routines" )
_TraceOn = true local _TraceOn = true
_TraceClass = { local _TraceLevel = 1
local _TraceClass = {
--DATABASE = true, --DATABASE = true,
--SEAD = true, --SEAD = true,
--DESTROYBASETASK = true, --DESTROYBASETASK = true,
@@ -51,7 +52,6 @@ FORMATION = {
-- @return #BASE -- @return #BASE
-- @usage -- @usage
-- function TASK:New() -- function TASK:New()
-- trace.f(self.ClassName)
-- --
-- local self = BASE:Inherit( self, BASE:New() ) -- local self = BASE:Inherit( self, BASE:New() )
-- --
@@ -100,8 +100,31 @@ function BASE:Inherited( Child )
return Parent return Parent
end 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 ) function BASE:AddEvent( Event, EventFunction )
trace.f( self.ClassName, Event ) self:F( Event )
self.Events[#self.Events+1] = {} self.Events[#self.Events+1] = {}
self.Events[#self.Events].Event = Event self.Events[#self.Events].Event = Event
@@ -113,22 +136,20 @@ end
function BASE:EnableEvents() 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 for EventID, Event in pairs( self.Events ) do
Event.Self = self Event.Self = self
Event.EventEnabled = true Event.EventEnabled = true
end end
--env.info( 'EnableEvent Table Task = ' .. tostring(self) )
self.Events.Handler = world.addEventHandler( self ) self.Events.Handler = world.addEventHandler( self )
return self return self
end end
function BASE:DisableEvents() function BASE:DisableEvents()
trace.f( self.ClassName ) self:F()
world.removeEventHandler( self ) world.removeEventHandler( self )
for EventID, Event in pairs( self.Events ) do for EventID, Event in pairs( self.Events ) do
Event.Self = nil Event.Self = nil
@@ -139,7 +160,7 @@ trace.f( self.ClassName )
end end
BaseEventCodes = { local BaseEventCodes = {
"S_EVENT_SHOT", "S_EVENT_SHOT",
"S_EVENT_HIT", "S_EVENT_HIT",
"S_EVENT_TAKEOFF", "S_EVENT_TAKEOFF",
@@ -179,7 +200,7 @@ BaseEventCodes = {
function BASE:CreateEventBirth( EventTime, Initiator, IniUnitName, place, subplace ) 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 = { local Event = {
id = world.event.S_EVENT_BIRTH, id = world.event.S_EVENT_BIRTH,
@@ -194,7 +215,7 @@ trace.f( self.ClassName, { EventTime, Initiator, IniUnitName, place, subplace }
end end
function BASE:CreateEventCrash( EventTime, Initiator ) function BASE:CreateEventCrash( EventTime, Initiator )
trace.f( self.ClassName, { EventTime, Initiator } ) self:F( { EventTime, Initiator } )
local Event = { local Event = {
id = world.event.S_EVENT_CRASH, id = world.event.S_EVENT_CRASH,
@@ -206,7 +227,6 @@ trace.f( self.ClassName, { EventTime, Initiator } )
end end
function BASE:onEvent(event) function BASE:onEvent(event)
--trace.f(self.ClassName, event )
--env.info( 'onEvent Table self = ' .. tostring(self) ) --env.info( 'onEvent Table self = ' .. tostring(self) )
if self then if self then
@@ -223,7 +243,7 @@ function BASE:onEvent(event)
if event.target and event.target:isExist() then if event.target and event.target:isExist() then
event.TgtUnitName = event.target:getName() event.TgtUnitName = event.target:getName()
end end
trace.i( self.ClassName, { BaseEventCodes[event.id], event } ) self:T( { BaseEventCodes[event.id], event } )
EventObject.EventFunction( self, event ) EventObject.EventFunction( self, event )
end end
end end
@@ -236,6 +256,44 @@ end
-- Trace section -- Trace section
-- Log a trace (only shown when trace is on) -- 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 ) function BASE:T( Arguments )
if _TraceOn and _TraceClass[self.ClassName] then if _TraceOn and _TraceClass[self.ClassName] then
@@ -253,10 +311,28 @@ function BASE:T( Arguments )
if DebugInfoFrom then if DebugInfoFrom then
LineFrom = DebugInfoFrom.currentline LineFrom = DebugInfoFrom.currentline
end 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
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 -- Log an exception
function BASE:E( Arguments ) function BASE:E( Arguments )
+56 -58
View File
@@ -32,7 +32,7 @@ CARGO_ZONE = {
} }
function CARGO_ZONE:New( CargoZoneName, CargoHostName ) local self = BASE:Inherit( self, BASE:New() ) 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.CargoZoneName = CargoZoneName
self.CargoZone = trigger.misc.getZone( CargoZoneName ) self.CargoZone = trigger.misc.getZone( CargoZoneName )
@@ -48,7 +48,7 @@ self:T( { CargoZoneName, CargoHostName } )
end end
function CARGO_ZONE:Spawn() function CARGO_ZONE:Spawn()
self:T( self.CargoHostName ) self:F( self.CargoHostName )
if self.CargoHostSpawn then if self.CargoHostSpawn then
local CargoHostGroup = self.CargoHostSpawn:GetGroupFromIndex() local CargoHostGroup = self.CargoHostSpawn:GetGroupFromIndex()
@@ -66,7 +66,7 @@ function CARGO_ZONE:Spawn()
end end
function CARGO_ZONE:GetHostUnit() function CARGO_ZONE:GetHostUnit()
self:T( self ) self:F( self )
if self.CargoHostName then if self.CargoHostName then
@@ -86,7 +86,7 @@ function CARGO_ZONE:GetHostUnit()
end end
function CARGO_ZONE:ReportCargosToClient( Client, CargoType ) function CARGO_ZONE:ReportCargosToClient( Client, CargoType )
self:T() self:F()
local SignalUnit = self:GetHostUnit() local SignalUnit = self:GetHostUnit()
@@ -115,7 +115,7 @@ self:T()
end end
function CARGO_ZONE:Signal() function CARGO_ZONE:Signal()
self:T() self:F()
local Signalled = false local Signalled = false
@@ -169,7 +169,7 @@ self:T()
end end
function CARGO_ZONE:WhiteSmoke() function CARGO_ZONE:WhiteSmoke()
self:T() self:F()
self.SignalType = CARGO_ZONE.SIGNAL.TYPE.SMOKE self.SignalType = CARGO_ZONE.SIGNAL.TYPE.SMOKE
self.SignalColor = CARGO_ZONE.SIGNAL.COLOR.WHITE self.SignalColor = CARGO_ZONE.SIGNAL.COLOR.WHITE
@@ -178,7 +178,7 @@ self:T()
end end
function CARGO_ZONE:BlueSmoke() function CARGO_ZONE:BlueSmoke()
self:T() self:F()
self.SignalType = CARGO_ZONE.SIGNAL.TYPE.SMOKE self.SignalType = CARGO_ZONE.SIGNAL.TYPE.SMOKE
self.SignalColor = CARGO_ZONE.SIGNAL.COLOR.BLUE self.SignalColor = CARGO_ZONE.SIGNAL.COLOR.BLUE
@@ -187,7 +187,7 @@ self:T()
end end
function CARGO_ZONE:RedSmoke() function CARGO_ZONE:RedSmoke()
self:T() self:F()
self.SignalType = CARGO_ZONE.SIGNAL.TYPE.SMOKE self.SignalType = CARGO_ZONE.SIGNAL.TYPE.SMOKE
self.SignalColor = CARGO_ZONE.SIGNAL.COLOR.RED self.SignalColor = CARGO_ZONE.SIGNAL.COLOR.RED
@@ -196,7 +196,7 @@ self:T()
end end
function CARGO_ZONE:OrangeSmoke() function CARGO_ZONE:OrangeSmoke()
self:T() self:F()
self.SignalType = CARGO_ZONE.SIGNAL.TYPE.SMOKE self.SignalType = CARGO_ZONE.SIGNAL.TYPE.SMOKE
self.SignalColor = CARGO_ZONE.SIGNAL.COLOR.ORANGE self.SignalColor = CARGO_ZONE.SIGNAL.COLOR.ORANGE
@@ -205,7 +205,7 @@ self:T()
end end
function CARGO_ZONE:GreenSmoke() function CARGO_ZONE:GreenSmoke()
self:T() self:F()
self.SignalType = CARGO_ZONE.SIGNAL.TYPE.SMOKE self.SignalType = CARGO_ZONE.SIGNAL.TYPE.SMOKE
self.SignalColor = CARGO_ZONE.SIGNAL.COLOR.GREEN self.SignalColor = CARGO_ZONE.SIGNAL.COLOR.GREEN
@@ -215,7 +215,7 @@ end
function CARGO_ZONE:WhiteFlare() function CARGO_ZONE:WhiteFlare()
self:T() self:F()
self.SignalType = CARGO_ZONE.SIGNAL.TYPE.FLARE self.SignalType = CARGO_ZONE.SIGNAL.TYPE.FLARE
self.SignalColor = CARGO_ZONE.SIGNAL.COLOR.WHITE self.SignalColor = CARGO_ZONE.SIGNAL.COLOR.WHITE
@@ -224,7 +224,7 @@ self:T()
end end
function CARGO_ZONE:RedFlare() function CARGO_ZONE:RedFlare()
self:T() self:F()
self.SignalType = CARGO_ZONE.SIGNAL.TYPE.FLARE self.SignalType = CARGO_ZONE.SIGNAL.TYPE.FLARE
self.SignalColor = CARGO_ZONE.SIGNAL.COLOR.RED self.SignalColor = CARGO_ZONE.SIGNAL.COLOR.RED
@@ -233,7 +233,7 @@ self:T()
end end
function CARGO_ZONE:GreenFlare() function CARGO_ZONE:GreenFlare()
self:T() self:F()
self.SignalType = CARGO_ZONE.SIGNAL.TYPE.FLARE self.SignalType = CARGO_ZONE.SIGNAL.TYPE.FLARE
self.SignalColor = CARGO_ZONE.SIGNAL.COLOR.GREEN self.SignalColor = CARGO_ZONE.SIGNAL.COLOR.GREEN
@@ -242,7 +242,7 @@ self:T()
end end
function CARGO_ZONE:YellowFlare() function CARGO_ZONE:YellowFlare()
self:T() self:F()
self.SignalType = CARGO_ZONE.SIGNAL.TYPE.FLARE self.SignalType = CARGO_ZONE.SIGNAL.TYPE.FLARE
self.SignalColor = CARGO_ZONE.SIGNAL.COLOR.YELLOW self.SignalColor = CARGO_ZONE.SIGNAL.COLOR.YELLOW
@@ -252,7 +252,7 @@ end
function CARGO_ZONE:GetCargoHostUnit() function CARGO_ZONE:GetCargoHostUnit()
self:T( self ) self:F( self )
if self.CargoHostSpawn then if self.CargoHostSpawn then
local CargoHostGroup = self.CargoHostSpawn:GetGroupFromIndex(1) local CargoHostGroup = self.CargoHostSpawn:GetGroupFromIndex(1)
@@ -268,7 +268,7 @@ function CARGO_ZONE:GetCargoHostUnit()
end end
function CARGO_ZONE:GetCargoZoneName() function CARGO_ZONE:GetCargoZoneName()
self:T() self:F()
return self.CargoZoneName return self.CargoZoneName
end 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... --- 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() ) 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 self.CargoType = CargoType
@@ -299,14 +299,14 @@ self:T( { CargoType, CargoName, CargoWeight } )
end end
function CARGO:Spawn( Client ) function CARGO:Spawn( Client )
self:T() self:F()
return self return self
end end
function CARGO:IsNear( Client, LandingZone ) function CARGO:IsNear( Client, LandingZone )
self:T() self:F()
local Near = true local Near = true
@@ -316,7 +316,7 @@ end
function CARGO:IsLoadingToClient() function CARGO:IsLoadingToClient()
self:T() self:F()
if self:IsStatusLoading() then if self:IsStatusLoading() then
return self.CargoClient return self.CargoClient
@@ -328,7 +328,7 @@ end
function CARGO:IsLoadedInClient() function CARGO:IsLoadedInClient()
self:T() self:F()
if self:IsStatusLoaded() then if self:IsStatusLoaded() then
return self.CargoClient return self.CargoClient
@@ -340,7 +340,7 @@ end
function CARGO:UnLoad( Client, TargetZoneName ) function CARGO:UnLoad( Client, TargetZoneName )
self:T() self:F()
self:StatusUnLoaded() self:StatusUnLoaded()
@@ -348,7 +348,7 @@ self:T()
end end
function CARGO:OnBoard( Client, LandingZone ) function CARGO:OnBoard( Client, LandingZone )
self:T() self:F()
local Valid = true local Valid = true
@@ -359,7 +359,7 @@ self:T()
end end
function CARGO:OnBoarded( Client, LandingZone ) function CARGO:OnBoarded( Client, LandingZone )
self:T() self:F()
local OnBoarded = true local OnBoarded = true
@@ -367,7 +367,7 @@ self:T()
end end
function CARGO:Load( Client ) function CARGO:Load( Client )
self:T() self:F()
self:StatusLoaded( Client ) self:StatusLoaded( Client )
@@ -375,18 +375,18 @@ self:T()
end end
function CARGO:IsLandingRequired() function CARGO:IsLandingRequired()
self:T() self:F()
return true return true
end end
function CARGO:IsSlingLoad() function CARGO:IsSlingLoad()
self:T() self:F()
return false return false
end end
function CARGO:StatusNone() function CARGO:StatusNone()
self:T() self:F()
self.CargoClient = nil self.CargoClient = nil
self.CargoStatus = CARGO.STATUS.NONE self.CargoStatus = CARGO.STATUS.NONE
@@ -395,7 +395,7 @@ self:T()
end end
function CARGO:StatusLoading( Client ) function CARGO:StatusLoading( Client )
self:T() self:F()
self.CargoClient = Client self.CargoClient = Client
self.CargoStatus = CARGO.STATUS.LOADING self.CargoStatus = CARGO.STATUS.LOADING
@@ -405,7 +405,7 @@ self:T()
end end
function CARGO:StatusLoaded( Client ) function CARGO:StatusLoaded( Client )
self:T() self:F()
self.CargoClient = Client self.CargoClient = Client
self.CargoStatus = CARGO.STATUS.LOADED self.CargoStatus = CARGO.STATUS.LOADED
@@ -415,7 +415,7 @@ self:T()
end end
function CARGO:StatusUnLoaded() function CARGO:StatusUnLoaded()
self:T() self:F()
self.CargoClient = nil self.CargoClient = nil
self.CargoStatus = CARGO.STATUS.UNLOADED self.CargoStatus = CARGO.STATUS.UNLOADED
@@ -425,25 +425,25 @@ end
function CARGO:IsStatusNone() function CARGO:IsStatusNone()
self:T() self:F()
return self.CargoStatus == CARGO.STATUS.NONE return self.CargoStatus == CARGO.STATUS.NONE
end end
function CARGO:IsStatusLoading() function CARGO:IsStatusLoading()
self:T() self:F()
return self.CargoStatus == CARGO.STATUS.LOADING return self.CargoStatus == CARGO.STATUS.LOADING
end end
function CARGO:IsStatusLoaded() function CARGO:IsStatusLoaded()
self:T() self:F()
return self.CargoStatus == CARGO.STATUS.LOADED return self.CargoStatus == CARGO.STATUS.LOADED
end end
function CARGO:IsStatusUnLoaded() function CARGO:IsStatusUnLoaded()
self:T() self:F()
return self.CargoStatus == CARGO.STATUS.UNLOADED return self.CargoStatus == CARGO.STATUS.UNLOADED
end 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 ) ) 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.CargoSpawn = SPAWN:NewWithAlias( CargoGroupTemplate, CargoName )
self.CargoZone = CargoZone self.CargoZone = CargoZone
@@ -467,7 +467,7 @@ function CARGO_GROUP:New( CargoType, CargoName, CargoWeight, CargoGroupTemplate,
end end
function CARGO_GROUP:Spawn( Client ) function CARGO_GROUP:Spawn( Client )
self:T( { Client } ) self:F( { Client } )
local SpawnCargo = true local SpawnCargo = true
@@ -528,7 +528,7 @@ function CARGO_GROUP:Spawn( Client )
end end
function CARGO_GROUP:IsNear( Client, LandingZone ) function CARGO_GROUP:IsNear( Client, LandingZone )
self:T() self:F()
local Near = false local Near = false
@@ -545,7 +545,7 @@ end
function CARGO_GROUP:OnBoard( Client, LandingZone, OnBoardSide ) function CARGO_GROUP:OnBoard( Client, LandingZone, OnBoardSide )
self:T() self:F()
local Valid = true local Valid = true
@@ -624,7 +624,7 @@ end
function CARGO_GROUP:OnBoarded( Client, LandingZone ) function CARGO_GROUP:OnBoarded( Client, LandingZone )
self:T() self:F()
local OnBoarded = false local OnBoarded = false
@@ -640,7 +640,7 @@ end
function CARGO_GROUP:UnLoad( Client, TargetZoneName ) function CARGO_GROUP:UnLoad( Client, TargetZoneName )
self:T() self:F()
self:T( 'self.CargoName = ' .. self.CargoName ) 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 ) ) function CARGO_PACKAGE:New( CargoType, CargoName, CargoWeight, CargoClient ) local self = BASE:Inherit( self, CARGO:New( CargoType, CargoName, CargoWeight ) )
self:F( { CargoType, CargoName, CargoWeight, CargoClient } )
self:T( { CargoType, CargoName, CargoWeight, CargoClient } )
self.CargoClient = CargoClient self.CargoClient = CargoClient
@@ -676,7 +675,7 @@ end
function CARGO_PACKAGE:Spawn( Client ) function CARGO_PACKAGE:Spawn( Client )
self:T( { self, Client } ) self:F( { self, Client } )
-- this needs to be checked thoroughly -- this needs to be checked thoroughly
@@ -716,7 +715,7 @@ end
function CARGO_PACKAGE:IsNear( Client, LandingZone ) function CARGO_PACKAGE:IsNear( Client, LandingZone )
self:T() self:F()
local Near = false local Near = false
@@ -735,7 +734,7 @@ end
function CARGO_PACKAGE:OnBoard( Client, LandingZone, OnBoardSide ) function CARGO_PACKAGE:OnBoard( Client, LandingZone, OnBoardSide )
self:T() self:F()
local Valid = true local Valid = true
@@ -826,7 +825,7 @@ end
function CARGO_PACKAGE:OnBoarded( Client, LandingZone ) function CARGO_PACKAGE:OnBoarded( Client, LandingZone )
self:T() self:F()
local OnBoarded = false local OnBoarded = false
@@ -846,7 +845,7 @@ end
function CARGO_PACKAGE:UnLoad( Client, TargetZoneName ) function CARGO_PACKAGE:UnLoad( Client, TargetZoneName )
self:T() self:F()
self:T( 'self.CargoName = ' .. self.CargoName ) self:T( 'self.CargoName = ' .. self.CargoName )
--self:T( 'self.CargoHostName = ' .. self.CargoHostName ) --self:T( 'self.CargoHostName = ' .. self.CargoHostName )
@@ -865,8 +864,7 @@ CARGO_SLINGLOAD = {
function CARGO_SLINGLOAD:New( CargoType, CargoName, CargoWeight, CargoZone, CargoHostName, CargoCountryID ) function CARGO_SLINGLOAD:New( CargoType, CargoName, CargoWeight, CargoZone, CargoHostName, CargoCountryID )
local self = BASE:Inherit( self, CARGO:New( CargoType, CargoName, CargoWeight ) ) local self = BASE:Inherit( self, CARGO:New( CargoType, CargoName, CargoWeight ) )
self:F( { CargoType, CargoName, CargoWeight, CargoZone, CargoHostName, CargoCountryID } )
self:T( { CargoType, CargoName, CargoWeight, CargoZone, CargoHostName, CargoCountryID } )
self.CargoHostName = CargoHostName self.CargoHostName = CargoHostName
@@ -887,19 +885,19 @@ end
function CARGO_SLINGLOAD:IsLandingRequired() function CARGO_SLINGLOAD:IsLandingRequired()
self:T() self:F()
return false return false
end end
function CARGO_SLINGLOAD:IsSlingLoad() function CARGO_SLINGLOAD:IsSlingLoad()
self:T() self:F()
return true return true
end end
function CARGO_SLINGLOAD:Spawn( Client ) function CARGO_SLINGLOAD:Spawn( Client )
self:T( { self, Client } ) self:F( { self, Client } )
local Zone = trigger.misc.getZone( self.CargoZone ) local Zone = trigger.misc.getZone( self.CargoZone )
@@ -949,7 +947,7 @@ end
function CARGO_SLINGLOAD:IsNear( Client, LandingZone ) function CARGO_SLINGLOAD:IsNear( Client, LandingZone )
self:T() self:F()
local Near = false local Near = false
@@ -958,7 +956,7 @@ end
function CARGO_SLINGLOAD:IsInLandingZone( Client, LandingZone ) function CARGO_SLINGLOAD:IsInLandingZone( Client, LandingZone )
self:T() self:F()
local Near = false local Near = false
@@ -974,7 +972,7 @@ end
function CARGO_SLINGLOAD:OnBoard( Client, LandingZone, OnBoardSide ) function CARGO_SLINGLOAD:OnBoard( Client, LandingZone, OnBoardSide )
self:T() self:F()
local Valid = true local Valid = true
@@ -984,7 +982,7 @@ end
function CARGO_SLINGLOAD:OnBoarded( Client, LandingZone ) function CARGO_SLINGLOAD:OnBoarded( Client, LandingZone )
self:T() self:F()
local OnBoarded = false local OnBoarded = false
@@ -1000,7 +998,7 @@ end
function CARGO_SLINGLOAD:UnLoad( Client, TargetZoneName ) function CARGO_SLINGLOAD:UnLoad( Client, TargetZoneName )
self:T() self:F()
self:T( 'self.CargoName = ' .. self.CargoName ) self:T( 'self.CargoName = ' .. self.CargoName )
self:T( 'self.CargoGroupName = ' .. self.CargoGroupName ) self:T( 'self.CargoGroupName = ' .. self.CargoGroupName )
+9 -9
View File
@@ -28,7 +28,7 @@ CLEANUP = {
-- CleanUpTbilisi = CLEANUP:New( 'CLEAN Tbilisi', 150 ) -- CleanUpTbilisi = CLEANUP:New( 'CLEAN Tbilisi', 150 )
-- CleanUpKutaisi = CLEANUP:New( 'CLEAN Kutaisi', 600 ) -- CleanUpKutaisi = CLEANUP:New( 'CLEAN Kutaisi', 600 )
function CLEANUP:New( ZoneNames, TimeInterval ) local self = BASE:Inherit( self, BASE:New() ) 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 if type( ZoneNames ) == 'table' then
self.ZoneNames = ZoneNames self.ZoneNames = ZoneNames
@@ -57,7 +57,7 @@ end
--- Destroys a group from the simulator, but checks first if it is still existing! --- Destroys a group from the simulator, but checks first if it is still existing!
-- @see CLEANUP -- @see CLEANUP
function CLEANUP:_DestroyGroup( GroupObject, CleanUpGroupName ) function CLEANUP:_DestroyGroup( GroupObject, CleanUpGroupName )
self:T( { GroupObject, CleanUpGroupName } ) self:F( { GroupObject, CleanUpGroupName } )
if GroupObject then -- and GroupObject:isExist() then if GroupObject then -- and GroupObject:isExist() then
--MESSAGE:New( "Destroy Group " .. CleanUpGroupName, CleanUpGroupName, 1, CleanUpGroupName ):ToAll() --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! --- Destroys a unit from the simulator, but checks first if it is still existing!
-- @see CLEANUP -- @see CLEANUP
function CLEANUP:_DestroyUnit( CleanUpUnit, CleanUpUnitName ) function CLEANUP:_DestroyUnit( CleanUpUnit, CleanUpUnitName )
self:T( { CleanUpUnit, CleanUpUnitName } ) self:F( { CleanUpUnit, CleanUpUnitName } )
if CleanUpUnit then if CleanUpUnit then
--MESSAGE:New( "Destroy " .. CleanUpUnitName, CleanUpUnitName, 1, CleanUpUnitName ):ToAll() --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! --- Destroys a missile from the simulator, but checks first if it is still existing!
-- @see CLEANUP -- @see CLEANUP
function CLEANUP:_DestroyMissile( MissileObject ) function CLEANUP:_DestroyMissile( MissileObject )
self:T( { MissileObject } ) self:F( { MissileObject } )
if MissileObject and MissileObject:isExist() then if MissileObject and MissileObject:isExist() then
MissileObject:destroy() 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. --- 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 -- @see CLEANUP
function CLEANUP:_EventCrash( event ) function CLEANUP:_EventCrash( event )
self:T( { event } ) self:F( { event } )
--MESSAGE:New( "Crash ", "Crash", 10, "Crash" ):ToAll() --MESSAGE:New( "Crash ", "Crash", 10, "Crash" ):ToAll()
-- self:T("before getGroup") -- 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. --- 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 -- @see CLEANUP
function CLEANUP:_EventShot( event ) function CLEANUP:_EventShot( event )
self:T( { event } ) self:F( { event } )
local _grp = Unit.getGroup(event.initiator)-- Identify the group that fired local _grp = Unit.getGroup(event.initiator)-- Identify the group that fired
local _groupname = _grp:getName() -- return the name of the group 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. --- 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 ) function CLEANUP:_EventHitCleanUp( event )
self:T( { event } ) self:F( { event } )
local CleanUpUnit = event.initiator -- the Unit local CleanUpUnit = event.initiator -- the Unit
if CleanUpUnit and CleanUpUnit:isExist() and Object.getCategory(CleanUpUnit) == Object.Category.UNIT then if CleanUpUnit and CleanUpUnit:isExist() and Object.getCategory(CleanUpUnit) == Object.Category.UNIT then
@@ -195,7 +195,7 @@ function CLEANUP:_EventHitCleanUp( event )
end end
function CLEANUP:_AddForCleanUp( CleanUpUnit, CleanUpUnitName ) function CLEANUP:_AddForCleanUp( CleanUpUnit, CleanUpUnitName )
self:T( { CleanUpUnit, CleanUpUnitName } ) self:F( { CleanUpUnit, CleanUpUnitName } )
self.CleanUpList[CleanUpUnitName] = {} self.CleanUpList[CleanUpUnitName] = {}
self.CleanUpList[CleanUpUnitName].CleanUpUnit = CleanUpUnit self.CleanUpList[CleanUpUnitName].CleanUpUnit = CleanUpUnit
@@ -244,7 +244,7 @@ CleanUpSurfaceTypeText = {
--- At the defined time interval, CleanUp the Groups within the CleanUpList. --- At the defined time interval, CleanUp the Groups within the CleanUpList.
function CLEANUP:_Scheduler() function CLEANUP:_Scheduler()
self:T( "CleanUp Scheduler" ) self:F( "CleanUp Scheduler" )
for CleanUpUnitName, UnitData in pairs( self.CleanUpList ) do for CleanUpUnitName, UnitData in pairs( self.CleanUpList ) do
+26 -26
View File
@@ -48,7 +48,7 @@ CLIENT = {
-- Mission:AddClient( CLIENT:New( 'RU MI-8MTV2*RAMP-Deploy Troops 4' ):Transport() ) -- Mission:AddClient( CLIENT:New( 'RU MI-8MTV2*RAMP-Deploy Troops 4' ):Transport() )
function CLIENT:New( ClientName, ClientBriefing ) function CLIENT:New( ClientName, ClientBriefing )
local self = BASE:Inherit( self, BASE:New() ) local self = BASE:Inherit( self, BASE:New() )
self:T( ClientName, ClientBriefing ) self:F( ClientName, ClientBriefing )
self.ClientName = ClientName self.ClientName = ClientName
self:AddBriefing( ClientBriefing ) self:AddBriefing( ClientBriefing )
@@ -60,7 +60,7 @@ end
--- Resets a CLIENT. --- 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. -- @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 ) function CLIENT:Reset( ClientName )
self:T() self:F()
self._Menus = {} self._Menus = {}
end end
@@ -68,7 +68,7 @@ end
-- This function is modified to deal with a couple of bugs in DCS 1.5.3 -- This function is modified to deal with a couple of bugs in DCS 1.5.3
-- @return Group#Group -- @return Group#Group
function CLIENT:GetDCSGroup() function CLIENT:GetDCSGroup()
--self:T() self:F3()
-- local ClientData = Group.getByName( self.ClientName ) -- local ClientData = Group.getByName( self.ClientName )
-- if ClientData and ClientData:isExist() then -- 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 ) } local CoalitionsData = { AlivePlayersRed = coalition.getPlayers( coalition.side.RED ), AlivePlayersBlue = coalition.getPlayers( coalition.side.BLUE ) }
for CoalitionId, CoalitionData in pairs( CoalitionsData ) do for CoalitionId, CoalitionData in pairs( CoalitionsData ) do
--self:T( { "CoalitionData:", CoalitionData } ) self:T3( { "CoalitionData:", CoalitionData } )
for UnitId, UnitData in pairs( CoalitionData ) do for UnitId, UnitData in pairs( CoalitionData ) do
--self:T( { "UnitData:", UnitData } ) self:T3( { "UnitData:", UnitData } )
if UnitData and UnitData:isExist() then if UnitData and UnitData:isExist() then
local ClientGroup = Group.getByName( self.ClientName ) local ClientGroup = Group.getByName( self.ClientName )
if ClientGroup then if ClientGroup then
self:T( "ClientGroup = " .. self.ClientName ) self:T3( "ClientGroup = " .. self.ClientName )
if ClientGroup:isExist() then if ClientGroup:isExist() then
if ClientGroup:getID() == UnitData:getGroup():getID() then if ClientGroup:getID() == UnitData:getGroup():getID() then
self:T( "Normal logic" ) self:T3( "Normal logic" )
self:T( self.ClientName .. " : group found!" ) self:T3( self.ClientName .. " : group found!" )
return ClientGroup return ClientGroup
end end
else else
-- Now we need to resolve the bugs in DCS 1.5 ... -- 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) -- 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 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 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 if tonumber(UnitData:getID()) == ClientUnitData.unitId then
local ClientGroupTemplate = _Database.Groups[self.ClientName].Template local ClientGroupTemplate = _Database.Groups[self.ClientName].Template
self.ClientID = ClientGroupTemplate.groupId self.ClientID = ClientGroupTemplate.groupId
self.ClientGroupUnit = UnitData 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 return ClientGroup
end end
end end
@@ -121,10 +121,10 @@ function CLIENT:GetDCSGroup()
-- For non player clients -- For non player clients
local ClientGroup = Group.getByName( self.ClientName ) local ClientGroup = Group.getByName( self.ClientName )
if ClientGroup then if ClientGroup then
self:T( "ClientGroup = " .. self.ClientName ) self:T3( "ClientGroup = " .. self.ClientName )
if ClientGroup:isExist() then if ClientGroup:isExist() then
self:T( "Normal logic" ) self:T3( "Normal logic" )
self:T( self.ClientName .. " : group found!" ) self:T3( self.ClientName .. " : group found!" )
return ClientGroup return ClientGroup
end end
end end
@@ -171,7 +171,7 @@ end
--- Returns the Unit of the @{CLIENT}. --- Returns the Unit of the @{CLIENT}.
-- @return Unit -- @return Unit
function CLIENT:GetClientGroupUnit() function CLIENT:GetClientGroupUnit()
self:T() self:F()
local ClientGroup = self:GetDCSGroup() local ClientGroup = self:GetDCSGroup()
@@ -185,7 +185,7 @@ end
--- Returns the DCSUnit of the @{CLIENT}. --- Returns the DCSUnit of the @{CLIENT}.
-- @return DCSUnit -- @return DCSUnit
function CLIENT:GetClientGroupDCSUnit() function CLIENT:GetClientGroupDCSUnit()
self:T() self:F2()
local ClientGroup = self:GetDCSGroup() local ClientGroup = self:GetDCSGroup()
@@ -197,7 +197,7 @@ function CLIENT:GetClientGroupDCSUnit()
end end
function CLIENT:GetUnit() function CLIENT:GetUnit()
self:T() self:F()
return UNIT:New( self:GetClientGroupDCSUnit() ) return UNIT:New( self:GetClientGroupDCSUnit() )
end end
@@ -205,7 +205,7 @@ end
--- Returns the Point of the @{CLIENT}. --- Returns the Point of the @{CLIENT}.
-- @return DCSTypes#Vec2 -- @return DCSTypes#Vec2
function CLIENT:GetPointVec2() function CLIENT:GetPointVec2()
self:T() self:F()
ClientGroupUnit = self:GetClientGroupDCSUnit() ClientGroupUnit = self:GetClientGroupDCSUnit()
@@ -227,7 +227,7 @@ end
--- Returns the Position of the @{CLIENT}. --- Returns the Position of the @{CLIENT}.
-- @return DCSTypes#Position -- @return DCSTypes#Position
function CLIENT:ClientPosition() function CLIENT:ClientPosition()
self:T() self:F()
ClientGroupUnit = self:GetClientGroupDCSUnit() ClientGroupUnit = self:GetClientGroupDCSUnit()
@@ -243,7 +243,7 @@ end
--- Returns the altitude of the @{CLIENT}. --- Returns the altitude of the @{CLIENT}.
-- @return DCSTypes#Distance -- @return DCSTypes#Distance
function CLIENT:GetAltitude() function CLIENT:GetAltitude()
self:T() self:F()
ClientGroupUnit = self:GetClientGroupDCSUnit() ClientGroupUnit = self:GetClientGroupDCSUnit()
@@ -261,7 +261,7 @@ end
--- Transport defines that the Client is a Transport. --- Transport defines that the Client is a Transport.
-- @return CLIENT -- @return CLIENT
function CLIENT:Transport() function CLIENT:Transport()
self:T() self:F()
self.ClientTransport = true self.ClientTransport = true
return self return self
@@ -271,7 +271,7 @@ end
-- @param string ClientBriefing is the text defining the Mission briefing. -- @param string ClientBriefing is the text defining the Mission briefing.
-- @return CLIENT -- @return CLIENT
function CLIENT:AddBriefing( ClientBriefing ) function CLIENT:AddBriefing( ClientBriefing )
self:T() self:F()
self.ClientBriefing = ClientBriefing self.ClientBriefing = ClientBriefing
return self return self
end end
@@ -279,14 +279,14 @@ end
--- IsTransport returns if a Client is a transport. --- IsTransport returns if a Client is a transport.
-- @return bool -- @return bool
function CLIENT:IsTransport() function CLIENT:IsTransport()
self:T() self:F()
return self.ClientTransport return self.ClientTransport
end end
--- ShowCargo shows the @{CARGO} within the CLIENT to the Player. --- ShowCargo shows the @{CARGO} within the CLIENT to the Player.
-- The @{CARGO} is shown throught the MESSAGE system of DCS World. -- The @{CARGO} is shown throught the MESSAGE system of DCS World.
function CLIENT:ShowCargo() function CLIENT:ShowCargo()
self:T() self:F()
local CargoMsg = "" local CargoMsg = ""
@@ -317,7 +317,7 @@ end
-- @param string MessageCategory is the category of the message (the title). -- @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. -- @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 ) function CLIENT:Message( Message, MessageDuration, MessageId, MessageCategory, MessageInterval )
self:T() self:F()
if not self.MenuMessages then if not self.MenuMessages then
if self:GetClientGroupID() then if self:GetClientGroupID() then
+7 -7
View File
@@ -159,7 +159,7 @@ end
--- Set a status to a Group within the Database, this to check crossing events for example. --- Set a status to a Group within the Database, this to check crossing events for example.
function DATABASE:SetStatusGroup( GroupName, Status ) function DATABASE:SetStatusGroup( GroupName, Status )
self:T( Status ) self:F( Status )
self.Groups[GroupName].Status = Status self.Groups[GroupName].Status = Status
end end
@@ -167,7 +167,7 @@ end
--- Get a status to a Group within the Database, this to check crossing events for example. --- Get a status to a Group within the Database, this to check crossing events for example.
function DATABASE:GetStatusGroup( GroupName ) function DATABASE:GetStatusGroup( GroupName )
self:T( Status ) self:F( Status )
if self.Groups[GroupName] then if self.Groups[GroupName] then
return self.Groups[GroupName].Status return self.Groups[GroupName].Status
@@ -320,7 +320,7 @@ end
--- Follows new players entering Clients within the DCSRTE. --- Follows new players entering Clients within the DCSRTE.
function DATABASE:_FollowPlayers() function DATABASE:_FollowPlayers()
self:T( "_FollowPlayers" ) self:F( "_FollowPlayers" )
local ClientUnit = 0 local ClientUnit = 0
local CoalitionsData = { AlivePlayersRed = coalition.getPlayers(coalition.side.RED), AlivePlayersBlue = coalition.getPlayers(coalition.side.BLUE) } 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. --- Add a new player entering a Unit.
function DATABASE:_AddPlayerFromUnit( UnitData ) function DATABASE:_AddPlayerFromUnit( UnitData )
self:T( UnitData ) self:F( UnitData )
if UnitData:isExist() then if UnitData:isExist() then
local UnitName = UnitData:getName() local UnitName = UnitData:getName()
@@ -421,7 +421,7 @@ end
--- Registers Scores the players completing a Mission Task. --- Registers Scores the players completing a Mission Task.
function DATABASE:_AddMissionTaskScore( PlayerUnit, MissionName, Score ) function DATABASE:_AddMissionTaskScore( PlayerUnit, MissionName, Score )
self:T( { PlayerUnit, MissionName, Score } ) self:F( { PlayerUnit, MissionName, Score } )
local PlayerName = PlayerUnit:getPlayerName() local PlayerName = PlayerUnit:getPlayerName()
@@ -447,7 +447,7 @@ end
--- Registers Mission Scores for possible multiple players that contributed in the Mission. --- Registers Mission Scores for possible multiple players that contributed in the Mission.
function DATABASE:_AddMissionScore( MissionName, Score ) function DATABASE:_AddMissionScore( MissionName, Score )
self:T( { PlayerUnit, MissionName, Score } ) self:F( { PlayerUnit, MissionName, Score } )
for PlayerName, PlayerData in pairs( self.Players ) do for PlayerName, PlayerData in pairs( self.Players ) do
@@ -468,7 +468,7 @@ end
function DATABASE:OnHit( event ) function DATABASE:OnHit( event )
self:T( { event } ) self:F( { event } )
local InitUnit = nil local InitUnit = nil
local InitUnitName = "" local InitUnitName = ""
+15 -15
View File
@@ -18,7 +18,7 @@ DEPLOYTASK = {
-- @return #DEPLOYTASK The created DeployTask -- @return #DEPLOYTASK The created DeployTask
function DEPLOYTASK:New( CargoType ) function DEPLOYTASK:New( CargoType )
local self = BASE:Inherit( self, TASK:New() ) local self = BASE:Inherit( self, TASK:New() )
self:T() self:F()
local Valid = true local Valid = true
@@ -35,7 +35,7 @@ function DEPLOYTASK:New( CargoType )
end end
function DEPLOYTASK:ToZone( LandingZone ) function DEPLOYTASK:ToZone( LandingZone )
self:T() self:F()
self.LandingZones.LandingZoneNames[LandingZone.CargoZoneName] = LandingZone.CargoZoneName self.LandingZones.LandingZoneNames[LandingZone.CargoZoneName] = LandingZone.CargoZoneName
self.LandingZones.LandingZones[LandingZone.CargoZoneName] = LandingZone self.LandingZones.LandingZones[LandingZone.CargoZoneName] = LandingZone
@@ -45,7 +45,7 @@ end
function DEPLOYTASK:InitCargo( InitCargos ) function DEPLOYTASK:InitCargo( InitCargos )
self:T( { InitCargos } ) self:F( { InitCargos } )
if type( InitCargos ) == "table" then if type( InitCargos ) == "table" then
self.Cargos.InitCargos = InitCargos self.Cargos.InitCargos = InitCargos
@@ -58,7 +58,7 @@ end
function DEPLOYTASK:LoadCargo( LoadCargos ) function DEPLOYTASK:LoadCargo( LoadCargos )
self:T( { LoadCargos } ) self:F( { LoadCargos } )
if type( LoadCargos ) == "table" then if type( LoadCargos ) == "table" then
self.Cargos.LoadCargos = LoadCargos self.Cargos.LoadCargos = LoadCargos
@@ -73,7 +73,7 @@ end
--- When the cargo is unloaded, it will move to the target zone name. --- 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. -- @param string TargetZoneName Name of the Zone to where the Cargo should move after unloading.
function DEPLOYTASK:SetCargoTargetZoneName( TargetZoneName ) function DEPLOYTASK:SetCargoTargetZoneName( TargetZoneName )
self:T() self:F()
local Valid = true local Valid = true
@@ -88,15 +88,15 @@ self:T()
end end
function DEPLOYTASK:AddCargoMenus( Client, Cargos, TransportRadius ) function DEPLOYTASK:AddCargoMenus( Client, Cargos, TransportRadius )
self:T() self:F()
local ClientGroupID = Client:GetClientGroupID() local ClientGroupID = Client:GetClientGroupID()
trace.i( self.ClassName, ClientGroupID ) self:T( ClientGroupID )
for CargoID, Cargo in pairs( Cargos ) do 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 if Cargo:IsStatusLoaded() and Client == Cargo:IsLoadedInClient() then
@@ -110,7 +110,7 @@ self:T()
self.TEXT[1] .. " " .. Cargo.CargoType, self.TEXT[1] .. " " .. Cargo.CargoType,
nil nil
) )
trace.i( self.ClassName, 'Added DeployMenu ' .. self.TEXT[1] ) self:T( 'Added DeployMenu ' .. self.TEXT[1] )
end end
if Client._Menus[Cargo.CargoType].DeploySubMenus == nil then if Client._Menus[Cargo.CargoType].DeploySubMenus == nil then
@@ -118,7 +118,7 @@ self:T()
end end
if Client._Menus[Cargo.CargoType].DeployMenu == nil then if Client._Menus[Cargo.CargoType].DeployMenu == nil then
trace.i( self.ClassName, 'deploymenu is nil' ) self:T( 'deploymenu is nil' )
end end
Client._Menus[Cargo.CargoType].DeploySubMenus[ #Client._Menus[Cargo.CargoType].DeploySubMenus + 1 ] = missionCommands.addCommandForGroup( Client._Menus[Cargo.CargoType].DeploySubMenus[ #Client._Menus[Cargo.CargoType].DeploySubMenus + 1 ] = missionCommands.addCommandForGroup(
@@ -128,29 +128,29 @@ self:T()
self.MenuAction, self.MenuAction,
{ ReferenceTask = self, CargoTask = Cargo } { 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 end
end end
function DEPLOYTASK:RemoveCargoMenus( Client ) function DEPLOYTASK:RemoveCargoMenus( Client )
self:T() self:F()
local ClientGroupID = Client:GetClientGroupID() local ClientGroupID = Client:GetClientGroupID()
trace.i( self.ClassName, ClientGroupID ) self:T( ClientGroupID )
for MenuID, MenuData in pairs( Client._Menus ) do for MenuID, MenuData in pairs( Client._Menus ) do
if MenuData.DeploySubMenus ~= nil then if MenuData.DeploySubMenus ~= nil then
for SubMenuID, SubMenuData in pairs( MenuData.DeploySubMenus ) do for SubMenuID, SubMenuData in pairs( MenuData.DeploySubMenus ) do
missionCommands.removeItemForGroup( ClientGroupID, SubMenuData ) missionCommands.removeItemForGroup( ClientGroupID, SubMenuData )
trace.i( self.ClassName, "Removed DeploySubMenu " ) self:T( "Removed DeploySubMenu " )
SubMenuData = nil SubMenuData = nil
end end
end end
if MenuData.DeployMenu then if MenuData.DeployMenu then
missionCommands.removeItemForGroup( ClientGroupID, MenuData.DeployMenu ) missionCommands.removeItemForGroup( ClientGroupID, MenuData.DeployMenu )
trace.i( self.ClassName, "Removed DeployMenu " ) self:T( "Removed DeployMenu " )
MenuData.DeployMenu = nil MenuData.DeployMenu = nil
end end
end end
+3 -3
View File
@@ -23,7 +23,7 @@ DESTROYBASETASK = {
-- @return DESTROYBASETASK -- @return DESTROYBASETASK
function DESTROYBASETASK:New( DestroyGroupType, DestroyUnitType, DestroyGroupPrefixes, DestroyPercentage ) function DESTROYBASETASK:New( DestroyGroupType, DestroyUnitType, DestroyGroupPrefixes, DestroyPercentage )
local self = BASE:Inherit( self, TASK:New() ) local self = BASE:Inherit( self, TASK:New() )
self:T() self:F()
self.Name = 'Destroy' self.Name = 'Destroy'
self.Destroyed = 0 self.Destroyed = 0
@@ -45,7 +45,7 @@ end
--- Handle the S_EVENT_DEAD events to validate the destruction of units for the task monitoring. --- Handle the S_EVENT_DEAD events to validate the destruction of units for the task monitoring.
-- @param event Event structure of DCS world. -- @param event Event structure of DCS world.
function DESTROYBASETASK:EventDead( event ) function DESTROYBASETASK:EventDead( event )
self:T( { 'EventDead', event } ) self:F( { 'EventDead', event } )
if event.initiator and Object.getCategory(event.initiator) == Object.Category.UNIT then if event.initiator and Object.getCategory(event.initiator) == Object.Category.UNIT then
local DestroyUnit = event.initiator local DestroyUnit = event.initiator
@@ -76,7 +76,7 @@ end
-- @param DestroyGroup Group structure describing the group to be evaluated. -- @param DestroyGroup Group structure describing the group to be evaluated.
-- @param DestroyUnit Unit structure describing the Unit to be evaluated. -- @param DestroyUnit Unit structure describing the Unit to be evaluated.
function DESTROYBASETASK:ReportGoalProgress( DestroyGroup, DestroyUnit ) function DESTROYBASETASK:ReportGoalProgress( DestroyGroup, DestroyUnit )
self:T() self:F()
return 0 return 0
end end
+10 -12
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}. -- @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 ---@return DESTROYGROUPSTASK
function DESTROYGROUPSTASK:New( DestroyGroupType, DestroyUnitType, DestroyGroupNames, DestroyPercentage ) function DESTROYGROUPSTASK:New( DestroyGroupType, DestroyUnitType, DestroyGroupNames, DestroyPercentage )
trace.f(self.ClassName) local self = BASE:Inherit( self, DESTROYBASETASK:New( DestroyGroupType, DestroyUnitType, DestroyGroupNames, DestroyPercentage ) )
self:F()
-- Inheritance
local Child = BASE:Inherit( self, DESTROYBASETASK:New( DestroyGroupType, DestroyUnitType, DestroyGroupNames, DestroyPercentage ) ) self.Name = 'Destroy Groups'
self.GoalVerb = "Destroy " .. DestroyGroupType
Child.Name = 'Destroy Groups'
Child.GoalVerb = "Destroy " .. DestroyGroupType
Child.AddEvent( Child, world.event.S_EVENT_DEAD, Child.EventDead ) self:AddEvent( world.event.S_EVENT_DEAD, self.EventDead )
Child.AddEvent( Child, world.event.S_EVENT_CRASH, Child.EventDead ) self:AddEvent( world.event.S_EVENT_CRASH, self.EventDead )
--Child.AddEvent( Child, world.event.S_EVENT_PILOT_DEAD, Child.EventDead ) --Child.AddEvent( Child, world.event.S_EVENT_PILOT_DEAD, Child.EventDead )
return Child return self
end end
--- Report Goal Progress. --- Report Goal Progress.
-- @param Group DestroyGroup Group structure describing the group to be evaluated. -- @param Group DestroyGroup Group structure describing the group to be evaluated.
-- @param Unit DestroyUnit Unit structure describing the Unit to be evaluated. -- @param Unit DestroyUnit Unit structure describing the Unit to be evaluated.
function DESTROYGROUPSTASK:ReportGoalProgress( DestroyGroup, DestroyUnit ) function DESTROYGROUPSTASK:ReportGoalProgress( DestroyGroup, DestroyUnit )
trace.f(self.ClassName) self:F( { DestroyGroup, DestroyUnit } )
trace.i( self.ClassName, DestroyGroup:getSize() ) self:T( DestroyGroup:getSize() )
local DestroyCount = 0 local DestroyCount = 0
if DestroyGroup then if DestroyGroup then
+7 -10
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. -- @param table{string,...} DestroyGroupNames Table of string containing the group names of which the radars are be destroyed.
-- @return DESTROYRADARSTASK -- @return DESTROYRADARSTASK
function DESTROYRADARSTASK:New( DestroyGroupNames ) function DESTROYRADARSTASK:New( DestroyGroupNames )
trace.f(self.ClassName) local self = BASE:Inherit( self, DESTROYGROUPSTASK:New( 'radar installations', 'radars', DestroyGroupNames ) )
self:F()
-- Inheritance
local Child = BASE:Inherit( self, DESTROYGROUPSTASK:New( 'radar installations', 'radars', DestroyGroupNames ) )
Child.Name = 'Destroy Radars'
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 end
--- Report Goal Progress. --- Report Goal Progress.
-- @param Group DestroyGroup Group structure describing the group to be evaluated. -- @param Group DestroyGroup Group structure describing the group to be evaluated.
-- @param Unit DestroyUnit Unit structure describing the Unit to be evaluated. -- @param Unit DestroyUnit Unit structure describing the Unit to be evaluated.
function DESTROYRADARSTASK:ReportGoalProgress( DestroyGroup, DestroyUnit ) function DESTROYRADARSTASK:ReportGoalProgress( DestroyGroup, DestroyUnit )
trace.f(self.ClassName) self:F( { DestroyGroup, DestroyUnit } )
local DestroyCount = 0 local DestroyCount = 0
if DestroyUnit and DestroyUnit:hasSensors( Unit.SensorType.RADAR, Unit.RadarType.AS ) then if DestroyUnit and DestroyUnit:hasSensors( Unit.SensorType.RADAR, Unit.RadarType.AS ) then
if DestroyUnit and DestroyUnit:getLife() <= 1.0 then if DestroyUnit and DestroyUnit:getLife() <= 1.0 then
trace.i( self.ClassName, 'Destroyed a radar' ) self:T( 'Destroyed a radar' )
DestroyCount = 1 DestroyCount = 1
end end
end end
+10 -15
View File
@@ -17,33 +17,28 @@ DESTROYUNITTYPESTASK = {
-- @param string DestroyUnitTypes Table of string containing the type names of the units to achieve mission success. -- @param string DestroyUnitTypes Table of string containing the type names of the units to achieve mission success.
-- @return DESTROYUNITTYPESTASK -- @return DESTROYUNITTYPESTASK
function DESTROYUNITTYPESTASK:New( DestroyGroupType, DestroyUnitType, DestroyGroupNames, DestroyUnitTypes ) function DESTROYUNITTYPESTASK:New( DestroyGroupType, DestroyUnitType, DestroyGroupNames, DestroyUnitTypes )
trace.f(self.ClassName) local self = BASE:Inherit( self, DESTROYBASETASK:New( DestroyGroupType, DestroyUnitType, DestroyGroupNames ) )
self:F( { DestroyGroupType, DestroyUnitType, DestroyGroupNames, DestroyUnitTypes } )
-- Inheritance
local Child = BASE:Inherit( self, DESTROYBASETASK:New( DestroyGroupType, DestroyUnitType, DestroyGroupNames ) )
if type(DestroyUnitTypes) == 'table' then if type(DestroyUnitTypes) == 'table' then
Child.DestroyUnitTypes = DestroyUnitTypes self.DestroyUnitTypes = DestroyUnitTypes
else else
Child.DestroyUnitTypes = { DestroyUnitTypes } self.DestroyUnitTypes = { DestroyUnitTypes }
end end
Child.Name = 'Destroy Unit Types' self.Name = 'Destroy Unit Types'
Child.GoalVerb = "Destroy " .. DestroyGroupType self.GoalVerb = "Destroy " .. DestroyGroupType
--env.info( 'New Types Child = ' .. tostring(Child) ) self:AddEvent( world.event.S_EVENT_DEAD, self.EventDead )
--env.info( 'New Types self = ' .. tostring(self) )
Child.AddEvent( Child, world.event.S_EVENT_DEAD, Child.EventDead ) return self
return Child
end end
--- Report Goal Progress. --- Report Goal Progress.
-- @param Group DestroyGroup Group structure describing the group to be evaluated. -- @param Group DestroyGroup Group structure describing the group to be evaluated.
-- @param Unit DestroyUnit Unit structure describing the Unit to be evaluated. -- @param Unit DestroyUnit Unit structure describing the Unit to be evaluated.
function DESTROYUNITTYPESTASK:ReportGoalProgress( DestroyGroup, DestroyUnit ) function DESTROYUNITTYPESTASK:ReportGoalProgress( DestroyGroup, DestroyUnit )
trace.f(self.ClassName) self:F( { DestroyGroup, DestroyUnit } )
local DestroyCount = 0 local DestroyCount = 0
for UnitTypeID, UnitType in pairs( self.DestroyUnitTypes ) do for UnitTypeID, UnitType in pairs( self.DestroyUnitTypes ) do
+44 -31
View File
@@ -43,7 +43,7 @@ ESCORT = {
-- @return #ESCORT self -- @return #ESCORT self
function ESCORT:New( EscortClient, EscortGroup, EscortName ) function ESCORT:New( EscortClient, EscortGroup, EscortName )
local self = BASE:Inherit( self, BASE:New() ) local self = BASE:Inherit( self, BASE:New() )
self:T( { EscortClient, EscortGroup, EscortName } ) self:F( { EscortClient, EscortGroup, EscortName } )
self.EscortClient = EscortClient self.EscortClient = EscortClient
self.EscortGroup = EscortGroup self.EscortGroup = EscortGroup
@@ -99,8 +99,8 @@ function ESCORT._HoldPosition( MenuParam )
local EscortGroup = MenuParam.ParamSelf.EscortGroup local EscortGroup = MenuParam.ParamSelf.EscortGroup
local EscortClient = MenuParam.ParamSelf.EscortClient local EscortClient = MenuParam.ParamSelf.EscortClient
EscortGroup:PushTask( EscortGroup:HoldPosition( 300 ) ) EscortGroup:PushTask( EscortGroup:TaskHoldPosition( 300 ) )
MESSAGE:New( "Holding Position at ... for 5 minutes.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/HoldPosition" ):ToClient( MenuParam.ParamSelf.EscortClient ) MESSAGE:New( "Holding Position at ... for 5 minutes.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/TaskHoldPosition" ):ToClient( EscortClient )
end end
--- @param #MENUPARAM MenuParam --- @param #MENUPARAM MenuParam
@@ -109,7 +109,7 @@ function ESCORT._HoldPositionNearBy( MenuParam )
local EscortGroup = MenuParam.ParamSelf.EscortGroup local EscortGroup = MenuParam.ParamSelf.EscortGroup
local EscortClient = MenuParam.ParamSelf.EscortClient 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 PointFrom = {}
local GroupPoint = EscortGroup:GetPointVec2() local GroupPoint = EscortGroup:GetPointVec2()
@@ -129,13 +129,13 @@ function ESCORT._HoldPositionNearBy( MenuParam )
PointTo.type = AI.Task.WaypointType.TURNING_POINT PointTo.type = AI.Task.WaypointType.TURNING_POINT
PointTo.alt = EscortClient:GetAltitude() PointTo.alt = EscortClient:GetAltitude()
PointTo.alt_type = AI.Task.AltitudeType.BARO 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 } local Points = { PointFrom, PointTo }
EscortGroup:PushTask( EscortGroup:TaskMission( Points ) ) 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 end
function ESCORT._ReportNearbyTargets( MenuParam ) function ESCORT._ReportNearbyTargets( MenuParam )
@@ -152,8 +152,13 @@ function ESCORT._ScanTargets30Seconds( MenuParam )
local EscortGroup = MenuParam.ParamSelf.EscortGroup local EscortGroup = MenuParam.ParamSelf.EscortGroup
local EscortClient = MenuParam.ParamSelf.EscortClient local EscortClient = MenuParam.ParamSelf.EscortClient
EscortGroup:PushTask( EscortGroup:OrbitCircle( 30, 200, 20 ) ) EscortGroup:PushTask(
MESSAGE:New( "Scanning targets for 30 seconds.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/ScanTargets30Seconds" ):ToClient( MenuParam.ParamSelf.EscortClient ) 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 end
--- @param #MENUPARAM MenuParam --- @param #MENUPARAM MenuParam
@@ -163,8 +168,13 @@ function ESCORT._ScanTargets60Seconds( MenuParam )
local EscortGroup = MenuParam.ParamSelf.EscortGroup local EscortGroup = MenuParam.ParamSelf.EscortGroup
local EscortClient = MenuParam.ParamSelf.EscortClient local EscortClient = MenuParam.ParamSelf.EscortClient
EscortGroup:PushTask( EscortGroup:OrbitCircle( 60, 200, 20 ) ) EscortGroup:PushTask(
MESSAGE:New( "Scanning targets for 60 seconds.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/ScanTargets60Seconds" ):ToClient( MenuParam.ParamSelf.EscortClient ) 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 end
--- @param #MENUPARAM MenuParam --- @param #MENUPARAM MenuParam
@@ -172,9 +182,12 @@ function ESCORT._AttackTarget( MenuParam )
local EscortGroup = MenuParam.ParamSelf.EscortGroup local EscortGroup = MenuParam.ParamSelf.EscortGroup
local EscortClient = MenuParam.ParamSelf.EscortClient local EscortClient = MenuParam.ParamSelf.EscortClient
local AttackUnit = MenuParam.ParamUnit
MenuParam.ParamSelf.EscortGroup:AttackUnit( MenuParam.ParamUnit )
MESSAGE:New( "Attacking Unit", MenuParam.ParamSelf.EscortName, 10, "ESCORT/AttackTarget" ):ToClient( MenuParam.ParamSelf.EscortClient ) EscortGroup:OpenFire()
EscortGroup:EvasionVertical()
EscortGroup:PushTask( EscortGroup:TaskAttackUnit( AttackUnit ) )
MESSAGE:New( "Attacking Unit", MenuParam.ParamSelf.EscortName, 10, "ESCORT/AttackTarget" ):ToClient( EscortClient )
end end
--- @param #MENUPARAM MenuParam --- @param #MENUPARAM MenuParam
@@ -183,8 +196,8 @@ function ESCORT._ROEHoldFire( MenuParam )
local EscortGroup = MenuParam.ParamSelf.EscortGroup local EscortGroup = MenuParam.ParamSelf.EscortGroup
local EscortClient = MenuParam.ParamSelf.EscortClient local EscortClient = MenuParam.ParamSelf.EscortClient
MenuParam.ParamSelf.EscortGroup:HoldFire() EscortGroup:HoldFire()
MESSAGE:New( "Holding weapons.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/ROEHoldFire" ):ToClient( MenuParam.ParamSelf.EscortClient ) MESSAGE:New( "Holding weapons.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/ROEHoldFire" ):ToClient( EscortClient )
end end
--- @param #MENUPARAM MenuParam --- @param #MENUPARAM MenuParam
@@ -193,8 +206,8 @@ function ESCORT._ROEReturnFire( MenuParam )
local EscortGroup = MenuParam.ParamSelf.EscortGroup local EscortGroup = MenuParam.ParamSelf.EscortGroup
local EscortClient = MenuParam.ParamSelf.EscortClient local EscortClient = MenuParam.ParamSelf.EscortClient
MenuParam.ParamSelf.EscortGroup:ReturnFire() EscortGroup:ReturnFire()
MESSAGE:New( "Returning enemy fire.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/ROEReturnFire" ):ToClient( MenuParam.ParamSelf.EscortClient ) MESSAGE:New( "Returning enemy fire.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/ROEReturnFire" ):ToClient( EscortClient )
end end
--- @param #MENUPARAM MenuParam --- @param #MENUPARAM MenuParam
@@ -203,8 +216,8 @@ function ESCORT._ROEOpenFire( MenuParam )
local EscortGroup = MenuParam.ParamSelf.EscortGroup local EscortGroup = MenuParam.ParamSelf.EscortGroup
local EscortClient = MenuParam.ParamSelf.EscortClient local EscortClient = MenuParam.ParamSelf.EscortClient
MenuParam.ParamSelf.EscortGroup:OpenFire() EscortGroup:OpenFire()
MESSAGE:New( "Open fire on ordered targets.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/ROEOpenFire" ):ToClient( MenuParam.ParamSelf.EscortClient ) MESSAGE:New( "Open fire on ordered targets.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/ROEOpenFire" ):ToClient( EscortClient )
end end
--- @param #MENUPARAM MenuParam --- @param #MENUPARAM MenuParam
@@ -213,8 +226,8 @@ function ESCORT._ROEWeaponFree( MenuParam )
local EscortGroup = MenuParam.ParamSelf.EscortGroup local EscortGroup = MenuParam.ParamSelf.EscortGroup
local EscortClient = MenuParam.ParamSelf.EscortClient local EscortClient = MenuParam.ParamSelf.EscortClient
MenuParam.ParamSelf.EscortGroup:WeaponFree() EscortGroup:WeaponFree()
MESSAGE:New( "Engaging targets.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/ROEWeaponFree" ):ToClient( MenuParam.ParamSelf.EscortClient ) MESSAGE:New( "Engaging targets.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/ROEWeaponFree" ):ToClient( EscortClient )
end end
--- @param #MENUPARAM MenuParam --- @param #MENUPARAM MenuParam
@@ -223,8 +236,8 @@ function ESCORT._EvasionNoReaction( MenuParam )
local EscortGroup = MenuParam.ParamSelf.EscortGroup local EscortGroup = MenuParam.ParamSelf.EscortGroup
local EscortClient = MenuParam.ParamSelf.EscortClient local EscortClient = MenuParam.ParamSelf.EscortClient
MenuParam.ParamSelf.EscortGroup:EvasionNoReaction() EscortGroup:EvasionNoReaction()
MESSAGE:New( "We'll fight until death.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/EvasionNoReaction" ):ToClient( MenuParam.ParamSelf.EscortClient ) MESSAGE:New( "We'll fight until death.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/EvasionNoReaction" ):ToClient( EscortClient )
end end
--- @param #MENUPARAM MenuParam --- @param #MENUPARAM MenuParam
@@ -233,8 +246,8 @@ function ESCORT._EvasionPassiveDefense( MenuParam )
local EscortGroup = MenuParam.ParamSelf.EscortGroup local EscortGroup = MenuParam.ParamSelf.EscortGroup
local EscortClient = MenuParam.ParamSelf.EscortClient local EscortClient = MenuParam.ParamSelf.EscortClient
MenuParam.ParamSelf.EscortGroup:EvasionPassiveDefense() EscortGroup:EvasionPassiveDefense()
MESSAGE:New( "We will use flares, chaff and jammers.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/EvasionPassiveDefense" ):ToClient( MenuParam.ParamSelf.EscortClient ) MESSAGE:New( "We will use flares, chaff and jammers.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/EvasionPassiveDefense" ):ToClient( EscortClient )
end end
--- @param #MENUPARAM MenuParam --- @param #MENUPARAM MenuParam
@@ -243,8 +256,8 @@ function ESCORT._EvasionEvadeFire( MenuParam )
local EscortGroup = MenuParam.ParamSelf.EscortGroup local EscortGroup = MenuParam.ParamSelf.EscortGroup
local EscortClient = MenuParam.ParamSelf.EscortClient local EscortClient = MenuParam.ParamSelf.EscortClient
MenuParam.ParamSelf.EscortGroup:EvasionEvadeFire() EscortGroup:EvasionEvadeFire()
MESSAGE:New( "We'll evade enemy fire.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/EvasionEvadeFire" ):ToClient( MenuParam.ParamSelf.EscortClient ) MESSAGE:New( "We'll evade enemy fire.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/EvasionEvadeFire" ):ToClient( EscortClient )
end end
--- @param #MENUPARAM MenuParam --- @param #MENUPARAM MenuParam
@@ -253,8 +266,8 @@ function ESCORT._EvasionVertical( MenuParam )
local EscortGroup = MenuParam.ParamSelf.EscortGroup local EscortGroup = MenuParam.ParamSelf.EscortGroup
local EscortClient = MenuParam.ParamSelf.EscortClient local EscortClient = MenuParam.ParamSelf.EscortClient
MenuParam.ParamSelf.EscortGroup:EvasionVertical() EscortGroup:EvasionVertical()
MESSAGE:New( "We'll perform vertical evasive manoeuvres.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/EvasionVertical" ):ToClient( MenuParam.ParamSelf.EscortClient ) MESSAGE:New( "We'll perform vertical evasive manoeuvres.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/EvasionVertical" ):ToClient( EscortClient )
end end
--- @param #MENUPARAM MenuParam --- @param #MENUPARAM MenuParam
@@ -264,12 +277,12 @@ function ESCORT._CancelCurrentTask( MenuParam )
local EscortClient = MenuParam.ParamSelf.EscortClient local EscortClient = MenuParam.ParamSelf.EscortClient
EscortGroup:PopCurrentTask() 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 end
function ESCORT:_ScanForTargets() function ESCORT:_ScanForTargets()
self:T() self:F()
self.Targets = {} self.Targets = {}
+9 -12
View File
@@ -13,26 +13,23 @@ GOHOMETASK = {
-- @param table{string,...}|string LandingZones Table of Landing Zone names where Home(s) are located. -- @param table{string,...}|string LandingZones Table of Landing Zone names where Home(s) are located.
-- @return GOHOMETASK -- @return GOHOMETASK
function GOHOMETASK:New( LandingZones ) function GOHOMETASK:New( LandingZones )
trace.f(self.ClassName) local self = BASE:Inherit( self, TASK:New() )
self:F( { LandingZones } )
-- Child holds the inherited instance of the PICKUPTASK Class to the BASE class.
local Child = BASE:Inherit( self, TASK:New() )
local Valid = true local Valid = true
Valid = routines.ValidateZone( LandingZones, "LandingZones", Valid ) Valid = routines.ValidateZone( LandingZones, "LandingZones", Valid )
if Valid then if Valid then
Child.Name = 'Fly Home' self.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.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 if type( LandingZones ) == "table" then
Child.LandingZones = LandingZones self.LandingZones = LandingZones
else else
Child.LandingZones = { LandingZones } self.LandingZones = { LandingZones }
end end
Child.Stages = { STAGEBRIEF:New(), STAGESTART:New(), STAGEROUTE:New(), STAGEARRIVE:New(), STAGEDONE:New() } self.Stages = { STAGEBRIEF:New(), STAGESTART:New(), STAGEROUTE:New(), STAGEARRIVE:New(), STAGEDONE:New() }
Child.SetStage( Child, 1 ) self.SetStage( self, 1 )
end end
return Child return self
end end
+348 -208
View File
@@ -10,7 +10,7 @@ Include.File( "Unit" )
--- The GROUP class --- The GROUP class
-- @type GROUP -- @type GROUP
-- @extends Base#BASE -- @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 #string GroupName The name of the group.
-- @field #number GroupID the ID of the group. -- @field #number GroupID the ID of the group.
-- @field #table Controller The controller of the group. -- @field #table Controller The controller of the group.
@@ -19,21 +19,22 @@ GROUP = {
GroupName = "", GroupName = "",
GroupID = 0, GroupID = 0,
Controller = nil, Controller = nil,
DCSGroup = nil,
} }
--- A DCSGroup --- A DCSGroup
-- @type Group -- @type DCSGroup
-- @field id_ The ID of the group in DCS -- @field id_ The ID of the group in DCS
GROUPS = {} GROUPS = {}
--- Create a new GROUP from a DCSGroup --- Create a new GROUP from a DCSGroup
-- @param self -- @param self
-- @param #Group DCSGroup The DCS Group -- @param DCSGroup#Group DCSGroup The DCS Group
-- @return #GROUP self -- @return #GROUP self
function GROUP:New( DCSGroup ) function GROUP:New( DCSGroup )
local self = BASE:Inherit( self, BASE:New() ) local self = BASE:Inherit( self, BASE:New() )
self:T( DCSGroup ) self:F( DCSGroup )
self.DCSGroup = DCSGroup self.DCSGroup = DCSGroup
if self.DCSGroup and self.DCSGroup:isExist() then if self.DCSGroup and self.DCSGroup:isExist() then
@@ -54,7 +55,7 @@ end
-- @return #GROUP self -- @return #GROUP self
function GROUP:NewFromName( GroupName ) function GROUP:NewFromName( GroupName )
local self = BASE:Inherit( self, BASE:New() ) local self = BASE:Inherit( self, BASE:New() )
self:T( GroupName ) self:F( GroupName )
self.DCSGroup = Group.getByName( GroupName ) self.DCSGroup = Group.getByName( GroupName )
if self.DCSGroup then if self.DCSGroup then
@@ -72,7 +73,7 @@ end
-- @return #GROUP self -- @return #GROUP self
function GROUP:NewFromDCSUnit( DCSUnit ) function GROUP:NewFromDCSUnit( DCSUnit )
local self = BASE:Inherit( self, BASE:New() ) local self = BASE:Inherit( self, BASE:New() )
self:T( DCSUnit ) self:F( DCSUnit )
self.DCSGroup = DCSUnit:getGroup() self.DCSGroup = DCSUnit:getGroup()
if self.DCSGroup then if self.DCSGroup then
@@ -88,7 +89,7 @@ end
-- @param self -- @param self
-- @return #Group The DCSGroup. -- @return #Group The DCSGroup.
function GROUP:GetDCSGroup() function GROUP:GetDCSGroup()
self:T( { self.GroupName } ) self:F( { self.GroupName } )
self.DCSGroup = Group.getByName( self.GroupName ) self.DCSGroup = Group.getByName( self.GroupName )
return self.DCSGroup return self.DCSGroup
end end
@@ -100,7 +101,7 @@ end
-- @param #number UnitNumber The unit index to be returned from the GROUP. -- @param #number UnitNumber The unit index to be returned from the GROUP.
-- @return #Unit The DCS Unit. -- @return #Unit The DCS Unit.
function GROUP:GetDCSUnit( UnitNumber ) function GROUP:GetDCSUnit( UnitNumber )
self:T( { self.GroupName, UnitNumber } ) self:F( { self.GroupName, UnitNumber } )
return self.DCSGroup:getUnit( UnitNumber ) return self.DCSGroup:getUnit( UnitNumber )
end end
@@ -108,7 +109,7 @@ end
--- Activates a GROUP. --- Activates a GROUP.
-- @param self -- @param self
function GROUP:Activate() function GROUP:Activate()
self:T( { self.GroupName } ) self:F( { self.GroupName } )
trigger.action.activateGroup( self:GetDCSGroup() ) trigger.action.activateGroup( self:GetDCSGroup() )
return self:GetDCSGroup() return self:GetDCSGroup()
end end
@@ -117,7 +118,7 @@ end
-- @param self -- @param self
-- @return #number The ID of the GROUP. -- @return #number The ID of the GROUP.
function GROUP:GetID() function GROUP:GetID()
self:T( self.GroupName ) self:F( self.GroupName )
return self.GroupID return self.GroupID
end end
@@ -126,15 +127,35 @@ end
-- @param self -- @param self
-- @return #string The name of the GROUP. -- @return #string The name of the GROUP.
function GROUP:GetName() function GROUP:GetName()
self:T( self.GroupName ) self:F( self.GroupName )
return self.GroupName return self.GroupName
end 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. --- Gets the current Point of the GROUP in VEC3 format.
-- @return #Vec3 Current x,y and z position of the group. -- @return #Vec3 Current x,y and z position of the group.
function GROUP:GetPointVec2() function GROUP:GetPointVec2()
self:T( self.GroupName ) self:F( self.GroupName )
local GroupPoint = self:GetUnit(1):GetPointVec2() local GroupPoint = self:GetUnit(1):GetPointVec2()
self:T( GroupPoint ) self:T( GroupPoint )
@@ -144,7 +165,7 @@ end
--- Gets the current Point of the GROUP in VEC2 format. --- Gets the current Point of the GROUP in VEC2 format.
-- @return #Vec2 Current x and y position of the group in the 2D plane. -- @return #Vec2 Current x and y position of the group in the 2D plane.
function GROUP:GetPointVec2() function GROUP:GetPointVec2()
self:T( self.GroupName ) self:F( self.GroupName )
local GroupPoint = self:GetUnit(1):GetPointVec2() local GroupPoint = self:GetUnit(1):GetPointVec2()
self:T( GroupPoint ) self:T( GroupPoint )
@@ -154,7 +175,7 @@ end
--- Gets the current Point of the GROUP in VEC3 format. --- Gets the current Point of the GROUP in VEC3 format.
-- @return #Vec3 Current Vec3 position of the group. -- @return #Vec3 Current Vec3 position of the group.
function GROUP:GetPositionVec3() function GROUP:GetPositionVec3()
self:T( self.GroupName ) self:F( self.GroupName )
local GroupPoint = self:GetUnit(1):GetPositionVec3() local GroupPoint = self:GetUnit(1):GetPositionVec3()
self:T( GroupPoint ) self:T( GroupPoint )
@@ -166,7 +187,7 @@ end
-- So all event listeners will catch the destroy event of this GROUP. -- So all event listeners will catch the destroy event of this GROUP.
-- @param self -- @param self
function GROUP:Destroy() function GROUP:Destroy()
self:T( self.GroupName ) self:F( self.GroupName )
for Index, UnitData in pairs( self.DCSGroup:getUnits() ) do for Index, UnitData in pairs( self.DCSGroup:getUnits() ) do
self:CreateEventCrash( timer.getTime(), UnitData ) self:CreateEventCrash( timer.getTime(), UnitData )
@@ -182,7 +203,7 @@ end
-- @param #number UnitNumber The number of the Unit to be returned. -- @param #number UnitNumber The number of the Unit to be returned.
-- @return #Unit The DCS Unit. -- @return #Unit The DCS Unit.
function GROUP:GetUnit( UnitNumber ) function GROUP:GetUnit( UnitNumber )
self:T( { self.GroupName, UnitNumber } ) self:F( { self.GroupName, UnitNumber } )
return UNIT:New( self.DCSGroup:getUnit( UnitNumber ) ) return UNIT:New( self.DCSGroup:getUnit( UnitNumber ) )
end end
@@ -191,7 +212,7 @@ end
-- @param self -- @param self
-- @return #boolean Air category evaluation result. -- @return #boolean Air category evaluation result.
function GROUP:IsAir() function GROUP:IsAir()
self:T() self:F()
local IsAirResult = self.DCSGroup:getCategory() == Group.Category.AIRPLANE or self.DCSGroup:getCategory() == Group.Category.HELICOPTER local IsAirResult = self.DCSGroup:getCategory() == Group.Category.AIRPLANE or self.DCSGroup:getCategory() == Group.Category.HELICOPTER
@@ -204,7 +225,7 @@ end
-- @param self -- @param self
-- @return #boolean Alive result. -- @return #boolean Alive result.
function GROUP:IsAlive() function GROUP:IsAlive()
self:T() self:F()
local IsAliveResult = self.DCSGroup and self.DCSGroup:isExist() local IsAliveResult = self.DCSGroup and self.DCSGroup:isExist()
@@ -217,7 +238,7 @@ end
-- @param self -- @param self
-- @return #boolean All units on the ground result. -- @return #boolean All units on the ground result.
function GROUP:AllOnGround() function GROUP:AllOnGround()
self:T() self:F()
local AllOnGroundResult = true local AllOnGroundResult = true
@@ -233,10 +254,10 @@ end
--- Returns the current maximum velocity of the group. --- 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. -- 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. -- @return #number Maximum velocity found.
function GROUP:GetMaxVelocity() function GROUP:GetMaxVelocity()
self:T() self:F()
local MaxVelocity = 0 local MaxVelocity = 0
@@ -259,7 +280,7 @@ end
-- @param self -- @param self
-- @return #number Minimum height found. -- @return #number Minimum height found.
function GROUP:GetMinHeight() function GROUP:GetMinHeight()
self:T() self:F()
end end
@@ -269,16 +290,17 @@ end
-- @param self -- @param self
-- @return #number Maximum height found. -- @return #number Maximum height found.
function GROUP:GetMaxHeight() function GROUP:GetMaxHeight()
self:T() self:F()
end end
-- Tasks
--- Popping current Task from the group. --- Popping current Task from the group.
-- @param #GROUP self -- @param #GROUP self
-- @return Group#GROUP self -- @return Group#GROUP self
function GROUP:PopCurrentTask() function GROUP:PopCurrentTask()
self:T() self:F()
local Controller = self:_GetController() local Controller = self:_GetController()
@@ -292,7 +314,7 @@ end
-- @param #GROUP self -- @param #GROUP self
-- @return Group#GROUP self -- @return Group#GROUP self
function GROUP:PushTask( DCSTask ) function GROUP:PushTask( DCSTask )
self:T() self:F()
local Controller = self:_GetController() local Controller = self:_GetController()
@@ -301,15 +323,60 @@ function GROUP:PushTask( DCSTask )
return self return self
end 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. --- Orbit at a specified position at a specified alititude during a specified duration with a specified speed.
-- @param #GROUP self -- @param #GROUP self
-- @param #Vec2 Point The point to hold the position. -- @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 Altitude The altitude to hold the position.
-- @param #number Speed The speed flying when holding the position. -- @param #number Speed The speed flying when holding the position.
-- @return #GROUP self -- @return #GROUP self
function GROUP:OrbitCircleAtVec2( Point, Duration, Altitude, Speed ) function GROUP:TaskOrbitCircleAtVec2( Point, Altitude, Speed )
self:T( { self.GroupName, Point, Duration, Altitude, Speed } ) self:F( { self.GroupName, Point, Altitude, Speed } )
-- pattern = enum AI.Task.OribtPattern, -- pattern = enum AI.Task.OribtPattern,
-- point = Vec2, -- point = Vec2,
@@ -321,7 +388,7 @@ function GROUP:OrbitCircleAtVec2( Point, Duration, Altitude, Speed )
self:T( { LandHeight } ) self:T( { LandHeight } )
local AITask = { id = 'Orbit', local DCSTask = { id = 'Orbit',
params = { pattern = AI.Task.OrbitPattern.CIRCLE, params = { pattern = AI.Task.OrbitPattern.CIRCLE,
point = Point, point = Point,
speed = Speed, speed = Speed,
@@ -344,21 +411,20 @@ function GROUP:OrbitCircleAtVec2( Point, Duration, Altitude, Speed )
-- } -- }
-- ) -- )
return AITask return DCSTask
end 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 #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 Altitude The altitude to hold the position.
-- @param #number Speed The speed flying when holding the position. -- @param #number Speed The speed flying when holding the position.
-- @return #GROUP self -- @return #GROUP self
function GROUP:OrbitCircle( Duration, Altitude, Speed ) function GROUP:TaskOrbitCircle( Altitude, Speed )
self:T( { self.GroupName, Duration, Altitude, Speed } ) self:F( { self.GroupName, Altitude, Speed } )
local GroupPoint = self:GetPointVec2() local GroupPoint = self:GetPointVec2()
return self:OrbitCircleAtVec2( GroupPoint, Duration, Altitude, Speed ) return self:TaskOrbitCircleAtVec2( GroupPoint, Altitude, Speed )
end end
@@ -367,41 +433,57 @@ end
-- @param #GROUP self -- @param #GROUP self
-- @param #number Duration The maximum duration in seconds to hold the position. -- @param #number Duration The maximum duration in seconds to hold the position.
-- @return #GROUP self -- @return #GROUP self
function GROUP:HoldPosition( Duration ) function GROUP:TaskHoldPosition()
self:T( { self.GroupName, Duration } ) self:F( { self.GroupName } )
return self:OrbitCircle( Duration, 30, 0 ) return self:TaskOrbitCircle( 30, 10 )
end end
--- Land the group at a Vec2Point. --- Land the group at a Vec2Point.
-- @param self -- @param #GROUP self
-- @param #Vec2 Point The point where to land. -- @param #Vec2 Point The point where to land.
-- @param #number Duration The duration in seconds to stay on the ground. -- @param #number Duration The duration in seconds to stay on the ground.
-- @return #GROUP self -- @return #GROUP self
function GROUP:Land( Point, Duration ) function GROUP:TaskLandAtVec2( Point, Duration )
self:T( { self.GroupName, Point, Duration } ) self:F( { self.GroupName, Point, Duration } )
local Controller = self:_GetController() local DCSTask
if Duration and Duration > 0 then 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 else
Controller:pushTask( { id = 'Land', params = { point = Point, durationFlag = false } } ) DCSTask = { id = 'Land', params = { point = Point, durationFlag = false } }
end end
return self self:T( DCSTask )
return DCSTask
end end
--- Attack the Unit. --- Land the group at a @{Zone#ZONE).
-- @param self -- @param #GROUP self
-- @param #UNIT The unit. -- @param Zone#ZONE Zone The zone where to land.
-- @param #number Duration The duration in seconds to stay on the ground.
-- @return #GROUP self -- @return #GROUP self
function GROUP:AttackUnit( AttackUnit ) function GROUP:TaskLandAtZone( Zone, Duration )
self:T( { self.GroupName, AttackUnit } ) 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 = { -- AttackUnit = {
-- id = 'AttackUnit', -- id = 'AttackUnit',
-- params = { -- params = {
@@ -413,187 +495,88 @@ function GROUP:AttackUnit( AttackUnit )
-- attackQtyLimit = boolean, -- attackQtyLimit = boolean,
-- groupAttack = 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 ) local DCSTask
DCSTask = { id = 'AttackUnit',
Controller:pushTask( { id = 'AttackUnit', params = { unitId = AttackUnit:GetID(),
params = { unitId = AttackUnit:GetID(), expend = AI.Task.WeaponExpend.TWO,
expend = AI.Task.WeaponExpend.TWO, groupAttack = true,
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 return self
end 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. --- 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 #Vec2 Point The point where to wait.
-- @param #number Duration The duration in seconds to wait. -- @param #number Duration The duration in seconds to wait.
-- @param EmbarkingGroup The group to be embarked. -- @param #GROUP EmbarkingGroup The group to be embarked.
-- @return #GROUP self -- @return #DCSTask The DCS task structure
function GROUP:Embarking( Point, Duration, EmbarkingGroup ) function GROUP:TaskEmbarkingAtVec2( Point, Duration, EmbarkingGroup )
trace.f( self.ClassName, { self.GroupName, Point, Duration, EmbarkingGroup.DCSGroup } ) 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 ) self:T( { DCSTask } )
trace.i( self.ClassName, EmbarkingGroup.DCSGroup:getID() ) return DCSTask
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
end end
--- Move to a defined Vec2 Point, and embark to a group when arrived within a defined Radius. --- 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 #Vec2 Point The point where to wait.
-- @param #number Radius The radius of the embarking zone around the Point. -- @param #number Radius The radius of the embarking zone around the Point.
-- @return #GROUP self -- @return #DCSTask The DCS task structure.
function GROUP:EmbarkToTransport( Point, Radius ) function GROUP:TaskEmbarkToTransportAtVec2( Point, Radius )
trace.f( self.ClassName, { self.GroupName, Point, Radius } ) self:F( { self.GroupName, Point, Radius } )
local Controller = self:_GetController() local DCSTask --#DCSTask
DCSTask = { id = 'EmbarkToTransport',
Controller:pushTask( { id = 'EmbarkToTransport', params = { x = Point.x,
params = { x = Point.x, y = Point.y,
y = Point.y, zoneRadius = Radius,
zoneRadius = Radius, }
} }
}
)
return self self:T( { DCSTask } )
return DCSTask
end end
--- Return a Misson task to follow a given route. --- Return a Misson task to follow a given route.
-- @param self -- @param #GROUP self
-- @param #table GoPoints A table of Route Points. -- @param #table GoPoints A table of Route Points.
-- @return #DCSTask -- @return #DCSTask
function GROUP:TaskMission( Points ) 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 end
--- Make the group to follow a given route. --- Make the group to follow a given route.
-- @param self -- @param #GROUP self
-- @param #table GoPoints A table of Route Points. -- @param #table GoPoints A table of Route Points.
-- @return #GROUP self -- @return #GROUP self
function GROUP:Route( GoPoints ) function GROUP:Route( GoPoints )
self:T( GoPoints ) self:F( GoPoints )
local Points = routines.utils.deepCopy( GoPoints ) local Points = routines.utils.deepCopy( GoPoints )
local MissionTask = { id = 'Mission', params = { route = { points = Points, }, }, } local MissionTask = { id = 'Mission', params = { route = { points = Points, }, }, }
@@ -609,13 +592,13 @@ end
-- The group final destination point can be randomized. -- The group final destination point can be randomized.
-- A speed can be given in km/h. -- A speed can be given in km/h.
-- A given formation can be given. -- A given formation can be given.
-- @param self -- @param #GROUP self
-- @param ZONE#ZONE Zone The zone where to route to. -- @param Zone#ZONE Zone The zone where to route to.
-- @param #boolean Randomize Defines whether to target point gets randomized within the Zone. -- @param #boolean Randomize Defines whether to target point gets randomized within the Zone.
-- @param #number Speed The speed. -- @param #number Speed The speed.
-- @param BASE#FORMATION Formation The formation string. -- @param Base#FORMATION Formation The formation string.
function GROUP:RouteToZone( Zone, Randomize, Speed, Formation ) function GROUP:TaskRouteToZone( Zone, Randomize, Speed, Formation )
self:T( Zone ) self:F( Zone )
local GroupPoint = self:GetPointVec2() local GroupPoint = self:GetPointVec2()
@@ -661,14 +644,14 @@ function GROUP:RouteToZone( Zone, Randomize, Speed, Formation )
return self return self
end end
--- Return the route of a group. --- Return the route of a group by using the @{Database#DATABASE} class.
-- @param self -- @param #GROUP self
-- @param #number Begin The route point from where the copy will start. The base route point is 0. -- @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 #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 #boolean Randomize Randomization of the route, when true.
-- @param #number Radius When randomization is on, the randomization is within the radius. -- @param #number Radius When randomization is on, the randomization is within the radius.
function GROUP:CopyRoute( Begin, End, Randomize, Radius ) function GROUP:CopyRoute( Begin, End, Randomize, Radius )
self:T( { Begin, End } ) self:F( { Begin, End } )
local Points = {} local Points = {}
@@ -733,4 +716,161 @@ function GROUP:IsTargetDetected( DCSObject )
return TargetIsDetected, TargetIsVisible, TargetLastTime, TargetKnowType, TargetKnowDistance, TargetLastPos, TargetLastVelocity 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
+23 -19
View File
@@ -6,13 +6,12 @@
-- Messages are sent to Clients with MESSAGE:@{ToClient}(). -- Messages are sent to Clients with MESSAGE:@{ToClient}().
-- Messages are sent to Coalitions with MESSAGE:@{ToCoalition}(). -- Messages are sent to Coalitions with MESSAGE:@{ToCoalition}().
-- Messages are sent to All Players with MESSAGE:@{ToAll}(). -- Messages are sent to All Players with MESSAGE:@{ToAll}().
-- @module MESSAGE -- @module Message
Include.File( "Trace" )
Include.File( "Base" ) Include.File( "Base" )
--- The MESSAGE class --- The MESSAGE class
-- @type -- @type MESSAGE
MESSAGE = { MESSAGE = {
ClassName = "MESSAGE", ClassName = "MESSAGE",
MessageCategory = 0, MessageCategory = 0,
@@ -39,7 +38,7 @@ MESSAGE = {
-- MessageClient2 = MESSAGE:New( "Congratulations, you've just killed a target", "Score", 25, "Score" ) -- MessageClient2 = MESSAGE:New( "Congratulations, you've just killed a target", "Score", 25, "Score" )
function MESSAGE:New( MessageText, MessageCategory, MessageDuration, MessageID ) function MESSAGE:New( MessageText, MessageCategory, MessageDuration, MessageID )
local self = BASE:Inherit( self, BASE:New() ) 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... -- When no messagecategory is given, we don't show it as a title...
if MessageCategory and MessageCategory ~= "" then if MessageCategory and MessageCategory ~= "" then
@@ -61,8 +60,9 @@ function MESSAGE:New( MessageText, MessageCategory, MessageDuration, MessageID )
end 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". --- 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. -- @param #MESSAGE self
-- @return MESSAGE -- @param Client#CLIENT Client is the Group of the Client.
-- @return #MESSAGE
-- @usage -- @usage
-- -- Send the 2 messages created with the @{New} method to the Client Group. -- -- 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. -- -- Note that the Message of MessageClient2 is overwriting the Message of MessageClient1.
@@ -79,20 +79,21 @@ end
-- MessageClient1:ToClient( ClientGroup ) -- MessageClient1:ToClient( ClientGroup )
-- MessageClient2:ToClient( ClientGroup ) -- MessageClient2:ToClient( ClientGroup )
function MESSAGE:ToClient( Client ) function MESSAGE:ToClient( Client )
self:T( Client ) self:F( Client )
if Client and Client:GetClientGroupID() then if Client and Client:GetClientGroupID() then
local ClientGroupID = Client:GetClientGroupID() 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 ) trigger.action.outTextForGroup( ClientGroupID, self.MessageCategory .. self.MessageText:gsub("\n$",""):gsub("\n$",""), self.MessageDuration )
end end
return self return self
end end
--- Sends a MESSAGE to the Blue coalition. --- Sends a MESSAGE to the Blue coalition.
-- @return MESSAGE -- @param #MESSAGE self
-- @return #MESSAGE
-- @usage -- @usage
-- -- Send a message created with the @{New} method to the BLUE coalition. -- -- 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() -- 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 = MESSAGE:New( "To the BLUE Players: You receive a penalty because you've killed one of your own units", "Penalty", 25, "Score" )
-- MessageBLUE:ToBlue() -- MessageBLUE:ToBlue()
function MESSAGE:ToBlue() function MESSAGE:ToBlue()
self:T() self:F()
self:ToCoalition( coalition.side.BLUE ) self:ToCoalition( coalition.side.BLUE )
@@ -110,7 +111,8 @@ function MESSAGE:ToBlue()
end end
--- Sends a MESSAGE to the Red Coalition. --- Sends a MESSAGE to the Red Coalition.
-- @return MESSAGE -- @param #MESSAGE self
-- @return #MESSAGE
-- @usage -- @usage
-- -- Send a message created with the @{New} method to the RED coalition. -- -- 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() -- 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 = MESSAGE:New( "To the RED Players: You receive a penalty because you've killed one of your own units", "Penalty", 25, "Score" )
-- MessageRED:ToRed() -- MessageRED:ToRed()
function MESSAGE:ToRed( ) function MESSAGE:ToRed( )
self:T() self:F()
self:ToCoalition( coalition.side.RED ) self:ToCoalition( coalition.side.RED )
@@ -128,8 +130,9 @@ function MESSAGE:ToRed( )
end end
--- Sends a MESSAGE to a Coalition. --- 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}. -- @param CoalitionSide needs to be filled out by the defined structure of the standard scripting engine @{coalition.side}.
-- @return MESSAGE -- @return #MESSAGE
-- @usage -- @usage
-- -- Send a message created with the @{New} method to the RED coalition. -- -- 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 ) -- 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 = 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 ) -- MessageRED:ToCoalition( coalition.side.RED )
function MESSAGE:ToCoalition( CoalitionSide ) function MESSAGE:ToCoalition( CoalitionSide )
self:T( CoalitionSide ) self:F( CoalitionSide )
if CoalitionSide then 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 ) trigger.action.outTextForCoalition( CoalitionSide, self.MessageCategory .. self.MessageText:gsub("\n$",""):gsub("\n$",""), self.MessageDuration )
end end
@@ -150,7 +153,8 @@ function MESSAGE:ToCoalition( CoalitionSide )
end end
--- Sends a MESSAGE to all players. --- Sends a MESSAGE to all players.
-- @return MESSAGE -- @param #MESSAGE self
-- @return #MESSAGE
-- @usage -- @usage
-- -- Send a message created to all players. -- -- 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() -- 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 = MESSAGE:New( "To all Players: BLUE has won! Each player of BLUE wins 50 points!", "End of Mission", 25, "Win" )
-- MessageAll:ToAll() -- MessageAll:ToAll()
function MESSAGE:ToAll() function MESSAGE:ToAll()
self:T() self:F()
self:ToCoalition( coalition.side.RED ) self:ToCoalition( coalition.side.RED )
self:ToCoalition( coalition.side.BLUE ) self:ToCoalition( coalition.side.BLUE )
@@ -179,7 +183,7 @@ MESSAGEQUEUE = {
function MESSAGEQUEUE:New( RefreshInterval ) function MESSAGEQUEUE:New( RefreshInterval )
local self = BASE:Inherit( self, BASE:New() ) local self = BASE:Inherit( self, BASE:New() )
self:T( { RefreshInterval } ) self:F( { RefreshInterval } )
self.RefreshInterval = RefreshInterval self.RefreshInterval = RefreshInterval
+19 -56
View File
@@ -33,7 +33,7 @@ MISSION = {
function MISSION:Meta() function MISSION:Meta()
local self = BASE:Inherit( self, BASE:New() ) local self = BASE:Inherit( self, BASE:New() )
self:T() self:F()
return self return self
end end
@@ -79,13 +79,13 @@ end
--- Returns if a Mission has completed. --- Returns if a Mission has completed.
-- @return bool -- @return bool
function MISSION:IsCompleted() function MISSION:IsCompleted()
self:T() self:F()
return self.MissionStatus == "ACCOMPLISHED" return self.MissionStatus == "ACCOMPLISHED"
end end
--- Set a Mission to completed. --- Set a Mission to completed.
function MISSION:Completed() function MISSION:Completed()
self:T() self:F()
self.MissionStatus = "ACCOMPLISHED" self.MissionStatus = "ACCOMPLISHED"
self:StatusToClients() self:StatusToClients()
end end
@@ -93,13 +93,13 @@ end
--- Returns if a Mission is ongoing. --- Returns if a Mission is ongoing.
-- treturn bool -- treturn bool
function MISSION:IsOngoing() function MISSION:IsOngoing()
self:T() self:F()
return self.MissionStatus == "ONGOING" return self.MissionStatus == "ONGOING"
end end
--- Set a Mission to ongoing. --- Set a Mission to ongoing.
function MISSION:Ongoing() function MISSION:Ongoing()
self:T() self:F()
self.MissionStatus = "ONGOING" self.MissionStatus = "ONGOING"
--self:StatusToClients() --self:StatusToClients()
end end
@@ -107,13 +107,13 @@ end
--- Returns if a Mission is pending. --- Returns if a Mission is pending.
-- treturn bool -- treturn bool
function MISSION:IsPending() function MISSION:IsPending()
self:T() self:F()
return self.MissionStatus == "PENDING" return self.MissionStatus == "PENDING"
end end
--- Set a Mission to pending. --- Set a Mission to pending.
function MISSION:Pending() function MISSION:Pending()
self:T() self:F()
self.MissionStatus = "PENDING" self.MissionStatus = "PENDING"
self:StatusToClients() self:StatusToClients()
end end
@@ -121,20 +121,20 @@ end
--- Returns if a Mission has failed. --- Returns if a Mission has failed.
-- treturn bool -- treturn bool
function MISSION:IsFailed() function MISSION:IsFailed()
self:T() self:F()
return self.MissionStatus == "FAILED" return self.MissionStatus == "FAILED"
end end
--- Set a Mission to failed. --- Set a Mission to failed.
function MISSION:Failed() function MISSION:Failed()
self:T() self:F()
self.MissionStatus = "FAILED" self.MissionStatus = "FAILED"
self:StatusToClients() self:StatusToClients()
end end
--- Send the status of the MISSION to all Clients. --- Send the status of the MISSION to all Clients.
function MISSION:StatusToClients() function MISSION:StatusToClients()
self:T() self:F()
if self.MissionReportFlash then if self.MissionReportFlash then
for ClientID, Client in pairs( self._Clients ) do 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") 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. --- Handles the reporting. After certain time intervals, a MISSION report MESSAGE will be shown to All Players.
function MISSION:ReportTrigger() function MISSION:ReportTrigger()
self:T() self:F()
if self.MissionReportShow == true then if self.MissionReportShow == true then
self.MissionReportShow = false self.MissionReportShow = false
trace.r( "MISSION", "1", { true } )
return true return true
else else
if self.MissionReportFlash == true then if self.MissionReportFlash == true then
if timer.getTime() >= self.MissionReportTrigger then if timer.getTime() >= self.MissionReportTrigger then
self.MissionReportTrigger = timer.getTime() + self.MissionTimeInterval self.MissionReportTrigger = timer.getTime() + self.MissionTimeInterval
trace.r( "MISSION", "2", { true } )
return true return true
else else
trace.r( "MISSION", "3", { false } )
return false return false
end end
else else
trace.r( "MISSION", "4", { false } )
return false return false
end end
end end
trace.e()
end end
--- Report the status of all MISSIONs to all active Clients. --- Report the status of all MISSIONs to all active Clients.
function MISSION:ReportToAll() function MISSION:ReportToAll()
self:T() self:F()
local AlivePlayers = '' local AlivePlayers = ''
for ClientID, Client in pairs( self._Clients ) do 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' ) -- 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 ) -- Mission:AddGoalFunction( DeployPatriotTroopsGoal )
function MISSION:AddGoalFunction( GoalFunction ) function MISSION:AddGoalFunction( GoalFunction )
self:T() self:F()
self.GoalFunction = GoalFunction self.GoalFunction = GoalFunction
end end
@@ -240,7 +235,7 @@ end
-- @param CLIENT Client to show briefing to. -- @param CLIENT Client to show briefing to.
-- @return CLIENT -- @return CLIENT
function MISSION:ShowBriefing( Client ) function MISSION:ShowBriefing( Client )
self:T( { Client.ClientName } ) self:F( { Client.ClientName } )
if not Client.ClientBriefingShown then if not Client.ClientBriefingShown then
Client.ClientBriefingShown = true 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*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() ) -- 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 ) function MISSION:AddClient( Client )
self:T( { Client } ) self:F( { Client } )
local Valid = true local Valid = true
@@ -273,7 +268,6 @@ function MISSION:AddClient( Client )
self._Clients[Client.ClientName] = Client self._Clients[Client.ClientName] = Client
end end
trace.r( self.ClassName, "" )
return Client return Client
end end
@@ -284,7 +278,7 @@ end
-- -- Seach for Client "Bomber" within the Mission. -- -- Seach for Client "Bomber" within the Mission.
-- local BomberClient = Mission:FindClient( "Bomber" ) -- local BomberClient = Mission:FindClient( "Bomber" )
function MISSION:FindClient( ClientName ) function MISSION:FindClient( ClientName )
self:T( { self._Clients[ClientName] } ) self:F( { self._Clients[ClientName] } )
return self._Clients[ClientName] return self._Clients[ClientName]
end end
@@ -315,7 +309,7 @@ end
-- Mission:AddTask( DeployTask, 2 ) -- Mission:AddTask( DeployTask, 2 )
function MISSION:AddTask( Task, TaskNumber ) function MISSION:AddTask( Task, TaskNumber )
self:T() self:F()
self._Tasks[TaskNumber] = Task self._Tasks[TaskNumber] = Task
self._Tasks[TaskNumber]:EnableEvents() self._Tasks[TaskNumber]:EnableEvents()
@@ -332,7 +326,7 @@ function MISSION:AddTask( Task, TaskNumber )
-- Task2 = Mission:GetTask( 2 ) -- Task2 = Mission:GetTask( 2 )
function MISSION:GetTask( TaskNumber ) function MISSION:GetTask( TaskNumber )
self:T() self:F()
local Valid = true local Valid = true
@@ -356,7 +350,7 @@ end
-- Tasks = Mission:GetTasks() -- Tasks = Mission:GetTasks()
-- env.info( "Task 2 Completion = " .. Tasks[2]:GetGoalPercentage() .. "%" ) -- env.info( "Task 2 Completion = " .. Tasks[2]:GetGoalPercentage() .. "%" )
function MISSION:GetTasks() function MISSION:GetTasks()
self:T() self:F()
return self._Tasks return self._Tasks
end 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. --- 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() function MISSIONSCHEDULER.Scheduler()
trace.scheduled("MISSIONSCHEDULER","Scheduler")
-- loop through the missions in the TransportTasks -- loop through the missions in the TransportTasks
for MissionName, Mission in pairs( MISSIONSCHEDULER.Missions ) do for MissionName, Mission in pairs( MISSIONSCHEDULER.Missions ) do
trace.i( "MISSIONSCHEDULER", MissionName )
if not Mission:IsCompleted() then 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). -- 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 for ClientID, Client in pairs( Mission._Clients ) do
trace.i( "MISSIONSCHEDULER", "Client: " .. Client.ClientName )
if Client:GetDCSGroup() then if Client:GetDCSGroup() then
-- There is at least one Client that is alive... So the Mission status is set to Ongoing. -- 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 end
if Task:IsDone() then 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" ) ) --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 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 if Mission:ReportTrigger() then
Mission:ReportToAll() Mission:ReportToAll()
end end
end end
trace.e()
end end
--- Start the MISSIONSCHEDULER. --- Start the MISSIONSCHEDULER.
function MISSIONSCHEDULER.Start() function MISSIONSCHEDULER.Start()
trace.f("MISSIONSCHEDULER")
if MISSIONSCHEDULER ~= nil then if MISSIONSCHEDULER ~= nil then
MISSIONSCHEDULER.SchedulerId = routines.scheduleFunction( MISSIONSCHEDULER.Scheduler, { }, 0, 2 ) MISSIONSCHEDULER.SchedulerId = routines.scheduleFunction( MISSIONSCHEDULER.Scheduler, { }, 0, 2 )
end end
trace.e()
end end
--- Stop the MISSIONSCHEDULER. --- Stop the MISSIONSCHEDULER.
function MISSIONSCHEDULER.Stop() function MISSIONSCHEDULER.Stop()
trace.f("MISSIONSCHEDULER")
if MISSIONSCHEDULER.SchedulerId then if MISSIONSCHEDULER.SchedulerId then
routines.removeFunction(MISSIONSCHEDULER.SchedulerId) routines.removeFunction(MISSIONSCHEDULER.SchedulerId)
MISSIONSCHEDULER.SchedulerId = nil MISSIONSCHEDULER.SchedulerId = nil
end end
trace.e()
end end
--- This is the main MISSION declaration method. Each Mission is like the master or a Mission orchestration between, Clients, Tasks, Stages etc. --- 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' ) -- 'Russia' )
-- MISSIONSCHEDULER:AddMission( Mission ) -- MISSIONSCHEDULER:AddMission( Mission )
function MISSIONSCHEDULER.AddMission( Mission ) function MISSIONSCHEDULER.AddMission( Mission )
trace.f("MISSIONSCHEDULER")
MISSIONSCHEDULER.Missions[Mission.Name] = Mission MISSIONSCHEDULER.Missions[Mission.Name] = Mission
MISSIONSCHEDULER.MissionCount = MISSIONSCHEDULER.MissionCount + 1 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. -- 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' ) ) --MissionAdd:AddClient( CLIENT:New( 'AI' ) )
trace.r( "MISSIONSCHEDULER", "" )
return Mission return Mission
end end
@@ -605,10 +584,8 @@ end
-- -- Now remove the Mission. -- -- Now remove the Mission.
-- MISSIONSCHEDULER:RemoveMission( 'Russia Transport Troops SA-6' ) -- MISSIONSCHEDULER:RemoveMission( 'Russia Transport Troops SA-6' )
function MISSIONSCHEDULER.RemoveMission( MissionName ) function MISSIONSCHEDULER.RemoveMission( MissionName )
trace.f("MISSIONSCHEDULER")
MISSIONSCHEDULER.Missions[MissionName] = nil MISSIONSCHEDULER.Missions[MissionName] = nil
MISSIONSCHEDULER.MissionCount = MISSIONSCHEDULER.MissionCount - 1 MISSIONSCHEDULER.MissionCount = MISSIONSCHEDULER.MissionCount - 1
trace.e()
end end
--- Find a MISSION within the MISSIONSCHEDULER. --- Find a MISSION within the MISSIONSCHEDULER.
@@ -625,24 +602,19 @@ end
-- -- Now find the Mission. -- -- Now find the Mission.
-- MissionFind = MISSIONSCHEDULER:FindMission( 'Russia Transport Troops SA-6' ) -- MissionFind = MISSIONSCHEDULER:FindMission( 'Russia Transport Troops SA-6' )
function MISSIONSCHEDULER.FindMission( MissionName ) function MISSIONSCHEDULER.FindMission( MissionName )
trace.f("MISSIONSCHEDULER")
trace.r( "MISSIONSCHEDULER", "" )
return MISSIONSCHEDULER.Missions[MissionName] return MISSIONSCHEDULER.Missions[MissionName]
end end
-- Internal function used by the MISSIONSCHEDULER menu. -- Internal function used by the MISSIONSCHEDULER menu.
function MISSIONSCHEDULER.ReportMissionsShow( ) function MISSIONSCHEDULER.ReportMissionsShow( )
trace.menu("MISSIONSCHEDULER","ReportMissionsShow")
for MissionName, Mission in pairs( MISSIONSCHEDULER.Missions ) do for MissionName, Mission in pairs( MISSIONSCHEDULER.Missions ) do
Mission.MissionReportShow = true Mission.MissionReportShow = true
Mission.MissionReportFlash = false Mission.MissionReportFlash = false
end end
trace.e()
end end
-- Internal function used by the MISSIONSCHEDULER menu. -- Internal function used by the MISSIONSCHEDULER menu.
function MISSIONSCHEDULER.ReportMissionsFlash( TimeInterval ) function MISSIONSCHEDULER.ReportMissionsFlash( TimeInterval )
trace.menu("MISSIONSCHEDULER","ReportMissionsFlash")
local Count = 0 local Count = 0
for MissionName, Mission in pairs( MISSIONSCHEDULER.Missions ) do for MissionName, Mission in pairs( MISSIONSCHEDULER.Missions ) do
Mission.MissionReportShow = false Mission.MissionReportShow = false
@@ -652,49 +624,40 @@ trace.menu("MISSIONSCHEDULER","ReportMissionsFlash")
env.info( "TimeInterval = " .. Mission.MissionTimeInterval ) env.info( "TimeInterval = " .. Mission.MissionTimeInterval )
Count = Count + 1 Count = Count + 1
end end
trace.e()
end end
-- Internal function used by the MISSIONSCHEDULER menu. -- Internal function used by the MISSIONSCHEDULER menu.
function MISSIONSCHEDULER.ReportMissionsHide( Prm ) function MISSIONSCHEDULER.ReportMissionsHide( Prm )
trace.menu("MISSIONSCHEDULER","ReportMissionsHide")
for MissionName, Mission in pairs( MISSIONSCHEDULER.Missions ) do for MissionName, Mission in pairs( MISSIONSCHEDULER.Missions ) do
Mission.MissionReportShow = false Mission.MissionReportShow = false
Mission.MissionReportFlash = false Mission.MissionReportFlash = false
end end
trace.e()
end end
--- Enables a MENU option in the communications menu under F10 to control the status of the active missions. --- 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. -- This function should be called only once when starting the MISSIONSCHEDULER.
function MISSIONSCHEDULER.ReportMenu() function MISSIONSCHEDULER.ReportMenu()
trace.f("MISSIONSCHEDULER")
local ReportMenu = SUBMENU:New( 'Status' ) local ReportMenu = SUBMENU:New( 'Status' )
local ReportMenuShow = COMMANDMENU:New( 'Show Report Missions', ReportMenu, MISSIONSCHEDULER.ReportMissionsShow, 0 ) local ReportMenuShow = COMMANDMENU:New( 'Show Report Missions', ReportMenu, MISSIONSCHEDULER.ReportMissionsShow, 0 )
local ReportMenuFlash = COMMANDMENU:New('Flash Report Missions', ReportMenu, MISSIONSCHEDULER.ReportMissionsFlash, 120 ) local ReportMenuFlash = COMMANDMENU:New('Flash Report Missions', ReportMenu, MISSIONSCHEDULER.ReportMissionsFlash, 120 )
local ReportMenuHide = COMMANDMENU:New( 'Hide Report Missions', ReportMenu, MISSIONSCHEDULER.ReportMissionsHide, 0 ) local ReportMenuHide = COMMANDMENU:New( 'Hide Report Missions', ReportMenu, MISSIONSCHEDULER.ReportMissionsHide, 0 )
trace.e()
end end
--- Show the remaining mission time. --- Show the remaining mission time.
function MISSIONSCHEDULER:TimeShow() function MISSIONSCHEDULER:TimeShow()
trace.f("MISSIONSCHEDULER")
self.TimeIntervalCount = self.TimeIntervalCount + 1 self.TimeIntervalCount = self.TimeIntervalCount + 1
if self.TimeIntervalCount >= self.TimeTriggerShow then if self.TimeIntervalCount >= self.TimeTriggerShow then
local TimeMsg = string.format("%00d", ( self.TimeSeconds / 60 ) - ( timer.getTime() / 60 )) .. ' minutes left until mission reload.' 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() MESSAGE:New( TimeMsg, "Mission time", self.TimeShow, '/TimeMsg' ):ToAll()
self.TimeIntervalCount = 0 self.TimeIntervalCount = 0
end end
trace.e()
end end
function MISSIONSCHEDULER:Time( TimeSeconds, TimeIntervalShow, TimeShow ) function MISSIONSCHEDULER:Time( TimeSeconds, TimeIntervalShow, TimeShow )
trace.f("MISSIONSCHEDULER")
self.TimeIntervalCount = 0 self.TimeIntervalCount = 0
self.TimeSeconds = TimeSeconds self.TimeSeconds = TimeSeconds
self.TimeIntervalShow = TimeIntervalShow self.TimeIntervalShow = TimeIntervalShow
self.TimeShow = TimeShow self.TimeShow = TimeShow
trace.e()
end end
+11 -11
View File
@@ -23,7 +23,7 @@ MOVEMENT = {
function MOVEMENT:New( MovePrefixes, MoveMaximum ) function MOVEMENT:New( MovePrefixes, MoveMaximum )
local self = BASE:Inherit( self, BASE:New() ) local self = BASE:Inherit( self, BASE:New() )
self:T( { MovePrefixes, MoveMaximum } ) self:F( { MovePrefixes, MoveMaximum } )
if type( MovePrefixes ) == 'table' then if type( MovePrefixes ) == 'table' then
self.MovePrefixes = MovePrefixes 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.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.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( world.event.S_EVENT_BIRTH, self.OnBirth )
self.AddEvent( self, world.event.S_EVENT_DEAD, self.OnDeadOrCrash ) self:AddEvent( world.event.S_EVENT_DEAD, self.OnDeadOrCrash )
self.AddEvent( self, world.event.S_EVENT_CRASH, self.OnDeadOrCrash ) self:AddEvent( world.event.S_EVENT_CRASH, self.OnDeadOrCrash )
self.EnableEvents( self ) self:EnableEvents()
self.ScheduleStart( self ) self:ScheduleStart()
return self return self
end end
--- Call this function to start the MOVEMENT scheduling. --- Call this function to start the MOVEMENT scheduling.
function MOVEMENT:ScheduleStart() function MOVEMENT:ScheduleStart()
self:T() self:F()
self.MoveFunction = routines.scheduleFunction( self._Scheduler, { self }, timer.getTime() + 1, 120 ) self.MoveFunction = routines.scheduleFunction( self._Scheduler, { self }, timer.getTime() + 1, 120 )
end end
--- Call this function to stop the MOVEMENT scheduling. --- Call this function to stop the MOVEMENT scheduling.
-- @todo need to implement it ... Forgot. -- @todo need to implement it ... Forgot.
function MOVEMENT:ScheduleStop() function MOVEMENT:ScheduleStop()
self:T() self:F()
end end
--- Captures the birth events when new Units were spawned. --- Captures the birth events when new Units were spawned.
-- @todo This method should become obsolete. The new @{DATABASE} class will handle the collection administration. -- @todo This method should become obsolete. The new @{DATABASE} class will handle the collection administration.
function MOVEMENT:OnBirth( event ) 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 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 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. --- 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. -- @todo This method should become obsolete. The new @{DATABASE} class will handle the collection administration.
function MOVEMENT:OnDeadOrCrash( event ) function MOVEMENT:OnDeadOrCrash( event )
self:T( { event } ) self:F( { event } )
if event.initiator and Object.getCategory(event.initiator) == Object.Category.UNIT then if event.initiator and Object.getCategory(event.initiator) == Object.Category.UNIT then
local MovementUnit = event.initiator 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. --- This function is called automatically by the MOVEMENT scheduler. A new function is scheduled when MoveScheduled is true.
function MOVEMENT:_Scheduler() 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 if self.AliveUnits > 0 then
local MoveProbability = ( self.MoveMaximum * 100 ) / self.AliveUnits local MoveProbability = ( self.MoveMaximum * 100 ) / self.AliveUnits
+8 -10
View File
@@ -11,19 +11,17 @@ NOTASK = {
--- Creates a new NOTASK. --- Creates a new NOTASK.
function NOTASK:New() function NOTASK:New()
trace.f(self.ClassName) local self = BASE:Inherit( self, TASK:New() )
self:F()
-- Child holds the inherited instance of the PICKUPTASK Class to the BASE class.
local Child = BASE:Inherit( self, TASK:New() )
local Valid = true local Valid = true
if Valid then if Valid then
Child.Name = 'Nothing' self.Name = 'Nothing'
Child.TaskBriefing = "Task: Execute your mission." self.TaskBriefing = "Task: Execute your mission."
Child.Stages = { STAGEBRIEF:New(), STAGESTART:New(), STAGEDONE:New() } self.Stages = { STAGEBRIEF:New(), STAGESTART:New(), STAGEDONE:New() }
Child.SetStage( Child, 1 ) self.SetStage( self, 1 )
end end
return Child return self
end end
+7 -7
View File
@@ -19,7 +19,7 @@ PICKUPTASK = {
-- @param number OnBoardSide Reflects from which side the cargo Group will be on-boarded on the Carrier. -- @param number OnBoardSide Reflects from which side the cargo Group will be on-boarded on the Carrier.
function PICKUPTASK:New( CargoType, OnBoardSide ) function PICKUPTASK:New( CargoType, OnBoardSide )
local self = BASE:Inherit( self, TASK:New() ) local self = BASE:Inherit( self, TASK:New() )
self:T() self:F()
-- self holds the inherited instance of the PICKUPTASK Class to the BASE class. -- self holds the inherited instance of the PICKUPTASK Class to the BASE class.
@@ -41,7 +41,7 @@ function PICKUPTASK:New( CargoType, OnBoardSide )
end end
function PICKUPTASK:FromZone( LandingZone ) function PICKUPTASK:FromZone( LandingZone )
self:T() self:F()
self.LandingZones.LandingZoneNames[LandingZone.CargoZoneName] = LandingZone.CargoZoneName self.LandingZones.LandingZoneNames[LandingZone.CargoZoneName] = LandingZone.CargoZoneName
self.LandingZones.LandingZones[LandingZone.CargoZoneName] = LandingZone self.LandingZones.LandingZones[LandingZone.CargoZoneName] = LandingZone
@@ -50,7 +50,7 @@ self:T()
end end
function PICKUPTASK:InitCargo( InitCargos ) function PICKUPTASK:InitCargo( InitCargos )
self:T( { InitCargos } ) self:F( { InitCargos } )
if type( InitCargos ) == "table" then if type( InitCargos ) == "table" then
self.Cargos.InitCargos = InitCargos self.Cargos.InitCargos = InitCargos
@@ -62,7 +62,7 @@ self:T( { InitCargos } )
end end
function PICKUPTASK:LoadCargo( LoadCargos ) function PICKUPTASK:LoadCargo( LoadCargos )
self:T( { LoadCargos } ) self:F( { LoadCargos } )
if type( LoadCargos ) == "table" then if type( LoadCargos ) == "table" then
self.Cargos.LoadCargos = LoadCargos self.Cargos.LoadCargos = LoadCargos
@@ -74,7 +74,7 @@ self:T( { LoadCargos } )
end end
function PICKUPTASK:AddCargoMenus( Client, Cargos, TransportRadius ) function PICKUPTASK:AddCargoMenus( Client, Cargos, TransportRadius )
self:T() self:F()
for CargoID, Cargo in pairs( Cargos ) do for CargoID, Cargo in pairs( Cargos ) do
@@ -121,7 +121,7 @@ self:T()
end end
function PICKUPTASK:RemoveCargoMenus( Client ) function PICKUPTASK:RemoveCargoMenus( Client )
self:T() self:F()
for MenuID, MenuData in pairs( Client._Menus ) do for MenuID, MenuData in pairs( Client._Menus ) do
for SubMenuID, SubMenuData in pairs( MenuData.PickupSubMenus ) do for SubMenuID, SubMenuData in pairs( MenuData.PickupSubMenus ) do
@@ -148,7 +148,7 @@ end
function PICKUPTASK:HasFailed( ClientDead ) function PICKUPTASK:HasFailed( ClientDead )
self:T() self:F()
local TaskHasFailed = self.TaskFailed local TaskHasFailed = self.TaskFailed
return TaskHasFailed return TaskHasFailed
+10 -12
View File
@@ -13,31 +13,29 @@ ROUTETASK = {
-- @param string TaskBriefing (optional) Defines a text describing the briefing of the task. -- @param string TaskBriefing (optional) Defines a text describing the briefing of the task.
-- @return ROUTETASK -- @return ROUTETASK
function ROUTETASK:New( LandingZones, TaskBriefing ) function ROUTETASK:New( LandingZones, TaskBriefing )
trace.f(self.ClassName, { LandingZones, TaskBriefing } ) local self = BASE:Inherit( self, TASK:New() )
self:F( { LandingZones, TaskBriefing } )
-- Child holds the inherited instance of the PICKUPTASK Class to the BASE class.
local Child = BASE:Inherit( self, TASK:New() )
local Valid = true local Valid = true
Valid = routines.ValidateZone( LandingZones, "LandingZones", Valid ) Valid = routines.ValidateZone( LandingZones, "LandingZones", Valid )
if Valid then if Valid then
Child.Name = 'Route To Zone' self.Name = 'Route To Zone'
if TaskBriefing then 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 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 end
if type( LandingZones ) == "table" then if type( LandingZones ) == "table" then
Child.LandingZones = LandingZones self.LandingZones = LandingZones
else else
Child.LandingZones = { LandingZones } self.LandingZones = { LandingZones }
end end
Child.Stages = { STAGEBRIEF:New(), STAGESTART:New(), STAGEROUTE:New(), STAGEARRIVE:New(), STAGEDONE:New() } self.Stages = { STAGEBRIEF:New(), STAGESTART:New(), STAGEROUTE:New(), STAGEARRIVE:New(), STAGEDONE:New() }
Child.SetStage( Child, 1 ) self.SetStage( self, 1 )
end end
return Child return self
end end
+55 -55
View File
@@ -2,7 +2,7 @@
-- @module routines -- @module routines
-- @author Flightcontrol -- @author Flightcontrol
Include.File( "Trace" ) --Include.File( "Trace" )
--Include.File( "Message" ) --Include.File( "Message" )
@@ -1455,7 +1455,7 @@ end
function routines.IsPartOfGroupInZones( CargoGroup, LandingZones ) function routines.IsPartOfGroupInZones( CargoGroup, LandingZones )
trace.f() --trace.f()
local CurrentZoneID = nil local CurrentZoneID = nil
@@ -1471,14 +1471,14 @@ trace.f()
end end
end end
trace.r( "", "", { CurrentZoneID } ) --trace.r( "", "", { CurrentZoneID } )
return CurrentZoneID return CurrentZoneID
end end
function routines.IsUnitInZones( TransportUnit, LandingZones ) function routines.IsUnitInZones( TransportUnit, LandingZones )
trace.f("", "routines.IsUnitInZones" ) --trace.f("", "routines.IsUnitInZones" )
local TransportZoneResult = nil local TransportZoneResult = nil
local TransportZonePos = nil local TransportZonePos = nil
@@ -1506,19 +1506,19 @@ trace.f("", "routines.IsUnitInZones" )
end end
end end
if TransportZoneResult then if TransportZoneResult then
trace.i( "routines", "TransportZone:" .. TransportZoneResult ) --trace.i( "routines", "TransportZone:" .. TransportZoneResult )
else else
trace.i( "routines", "TransportZone:nil logic" ) --trace.i( "routines", "TransportZone:nil logic" )
end end
return TransportZoneResult return TransportZoneResult
else else
trace.i( "routines", "TransportZone:nil hard" ) --trace.i( "routines", "TransportZone:nil hard" )
return nil return nil
end end
end end
function routines.IsStaticInZones( TransportStatic, LandingZones ) function routines.IsStaticInZones( TransportStatic, LandingZones )
trace.f() --trace.f()
local TransportZoneResult = nil local TransportZoneResult = nil
local TransportZonePos = nil local TransportZonePos = nil
@@ -1545,13 +1545,13 @@ trace.f()
end end
end end
trace.r( "", "", { TransportZoneResult } ) --trace.r( "", "", { TransportZoneResult } )
return TransportZoneResult return TransportZoneResult
end end
function routines.IsUnitInRadius( CargoUnit, ReferencePosition, Radius ) function routines.IsUnitInRadius( CargoUnit, ReferencePosition, Radius )
trace.f() --trace.f()
local Valid = true local Valid = true
@@ -1568,7 +1568,7 @@ trace.f()
end end
function routines.IsPartOfGroupInRadius( CargoGroup, ReferencePosition, Radius ) function routines.IsPartOfGroupInRadius( CargoGroup, ReferencePosition, Radius )
trace.f() --trace.f()
local Valid = true local Valid = true
@@ -1594,7 +1594,7 @@ end
function routines.ValidateString( Variable, VariableName, Valid ) function routines.ValidateString( Variable, VariableName, Valid )
trace.f() --trace.f()
if type( Variable ) == "string" then if type( Variable ) == "string" then
if Variable == "" then if Variable == "" then
@@ -1606,12 +1606,12 @@ trace.f()
Valid = false Valid = false
end end
trace.r( "", "", { Valid } ) --trace.r( "", "", { Valid } )
return Valid return Valid
end end
function routines.ValidateNumber( Variable, VariableName, Valid ) function routines.ValidateNumber( Variable, VariableName, Valid )
trace.f() --trace.f()
if type( Variable ) == "number" then if type( Variable ) == "number" then
else else
@@ -1619,25 +1619,25 @@ trace.f()
Valid = false Valid = false
end end
trace.r( "", "", { Valid } ) --trace.r( "", "", { Valid } )
return Valid return Valid
end end
function routines.ValidateGroup( Variable, VariableName, Valid ) function routines.ValidateGroup( Variable, VariableName, Valid )
trace.f() --trace.f()
if Variable == nil then if Variable == nil then
error( "routines.ValidateGroup: error: " .. VariableName .. " is a nil value!" ) error( "routines.ValidateGroup: error: " .. VariableName .. " is a nil value!" )
Valid = false Valid = false
end end
trace.r( "", "", { Valid } ) --trace.r( "", "", { Valid } )
return Valid return Valid
end end
function routines.ValidateZone( LandingZones, VariableName, Valid ) function routines.ValidateZone( LandingZones, VariableName, Valid )
trace.f() --trace.f()
if LandingZones == nil then if LandingZones == nil then
error( "routines.ValidateGroup: error: " .. VariableName .. " is a nil value!" ) error( "routines.ValidateGroup: error: " .. VariableName .. " is a nil value!" )
@@ -1659,12 +1659,12 @@ trace.f()
end end
end end
trace.r( "", "", { Valid } ) --trace.r( "", "", { Valid } )
return Valid return Valid
end end
function routines.ValidateEnumeration( Variable, VariableName, Enum, Valid ) function routines.ValidateEnumeration( Variable, VariableName, Enum, Valid )
trace.f() --trace.f()
local ValidVariable = false local ValidVariable = false
@@ -1681,7 +1681,7 @@ trace.f()
Valid = false Valid = false
end end
trace.r( "", "", { Valid } ) --trace.r( "", "", { Valid } )
return Valid return Valid
end end
@@ -1859,7 +1859,7 @@ routines.ground.patrol = function(gpData, pType, form, speed)
end end
function routines.GetUnitHeight( CheckUnit ) function routines.GetUnitHeight( CheckUnit )
trace.f( "routines" ) --trace.f( "routines" )
local UnitPoint = CheckUnit:getPoint() local UnitPoint = CheckUnit:getPoint()
local UnitPosition = { x = UnitPoint.x, y = UnitPoint.z } local UnitPosition = { x = UnitPoint.x, y = UnitPoint.z }
@@ -1869,7 +1869,7 @@ trace.f( "routines" )
--env.info(( 'CarrierHeight: LandHeight = ' .. LandHeight .. ' CarrierHeight = ' .. CarrierHeight )) --env.info(( 'CarrierHeight: LandHeight = ' .. LandHeight .. ' CarrierHeight = ' .. CarrierHeight ))
trace.f( "routines", "Unit Height = " .. UnitHeight - LandHeight ) --trace.f( "routines", "Unit Height = " .. UnitHeight - LandHeight )
return UnitHeight - LandHeight return UnitHeight - LandHeight
@@ -1886,7 +1886,7 @@ Su34Menus = 0
function Su34AttackCarlVinson(groupName) function Su34AttackCarlVinson(groupName)
trace.menu("", "Su34AttackCarlVinson") --trace.menu("", "Su34AttackCarlVinson")
local groupSu34 = Group.getByName( groupName ) local groupSu34 = Group.getByName( groupName )
local controllerSu34 = groupSu34.getController(groupSu34) local controllerSu34 = groupSu34.getController(groupSu34)
local groupCarlVinson = Group.getByName("US Carl Vinson #001") local groupCarlVinson = Group.getByName("US Carl Vinson #001")
@@ -1900,7 +1900,7 @@ trace.menu("", "Su34AttackCarlVinson")
end end
function Su34AttackWest(groupName) function Su34AttackWest(groupName)
trace.f("","Su34AttackWest") --trace.f("","Su34AttackWest")
local groupSu34 = Group.getByName( groupName ) local groupSu34 = Group.getByName( groupName )
local controllerSu34 = groupSu34.getController(groupSu34) local controllerSu34 = groupSu34.getController(groupSu34)
local groupShipWest1 = Group.getByName("US Ship West #001") local groupShipWest1 = Group.getByName("US Ship West #001")
@@ -1918,7 +1918,7 @@ trace.f("","Su34AttackWest")
end end
function Su34AttackNorth(groupName) function Su34AttackNorth(groupName)
trace.menu("","Su34AttackNorth") --trace.menu("","Su34AttackNorth")
local groupSu34 = Group.getByName( groupName ) local groupSu34 = Group.getByName( groupName )
local controllerSu34 = groupSu34.getController(groupSu34) local controllerSu34 = groupSu34.getController(groupSu34)
local groupShipNorth1 = Group.getByName("US Ship North #001") local groupShipNorth1 = Group.getByName("US Ship North #001")
@@ -1940,7 +1940,7 @@ trace.menu("","Su34AttackNorth")
end end
function Su34Orbit(groupName) function Su34Orbit(groupName)
trace.menu("","Su34Orbit") --trace.menu("","Su34Orbit")
local groupSu34 = Group.getByName( groupName ) local groupSu34 = Group.getByName( groupName )
local controllerSu34 = groupSu34:getController() local controllerSu34 = groupSu34:getController()
controllerSu34.setOption( controllerSu34, AI.Option.Air.id.ROE, AI.Option.Air.val.ROE.WEAPON_HOLD ) controllerSu34.setOption( controllerSu34, AI.Option.Air.id.ROE, AI.Option.Air.val.ROE.WEAPON_HOLD )
@@ -1951,7 +1951,7 @@ trace.menu("","Su34Orbit")
end end
function Su34TakeOff(groupName) function Su34TakeOff(groupName)
trace.menu("","Su34TakeOff") --trace.menu("","Su34TakeOff")
local groupSu34 = Group.getByName( groupName ) local groupSu34 = Group.getByName( groupName )
local controllerSu34 = groupSu34:getController() local controllerSu34 = groupSu34:getController()
controllerSu34.setOption( controllerSu34, AI.Option.Air.id.ROE, AI.Option.Air.val.ROE.WEAPON_HOLD ) controllerSu34.setOption( controllerSu34, AI.Option.Air.id.ROE, AI.Option.Air.val.ROE.WEAPON_HOLD )
@@ -1961,7 +1961,7 @@ trace.menu("","Su34TakeOff")
end end
function Su34Hold(groupName) function Su34Hold(groupName)
trace.menu("","Su34Hold") --trace.menu("","Su34Hold")
local groupSu34 = Group.getByName( groupName ) local groupSu34 = Group.getByName( groupName )
local controllerSu34 = groupSu34:getController() local controllerSu34 = groupSu34:getController()
controllerSu34.setOption( controllerSu34, AI.Option.Air.id.ROE, AI.Option.Air.val.ROE.WEAPON_HOLD ) controllerSu34.setOption( controllerSu34, AI.Option.Air.id.ROE, AI.Option.Air.val.ROE.WEAPON_HOLD )
@@ -1971,19 +1971,19 @@ trace.menu("","Su34Hold")
end end
function Su34RTB(groupName) function Su34RTB(groupName)
trace.menu("","Su34RTB") --trace.menu("","Su34RTB")
Su34Status.status[groupName] = 6 Su34Status.status[groupName] = 6
MessageToRed( string.format('%s: ',groupName) .. 'Return to Krasnodar. ', 10, 'RedStatus' .. groupName ) MessageToRed( string.format('%s: ',groupName) .. 'Return to Krasnodar. ', 10, 'RedStatus' .. groupName )
end end
function Su34Destroyed(groupName) function Su34Destroyed(groupName)
trace.menu("","Su34Destroyed") --trace.menu("","Su34Destroyed")
Su34Status.status[groupName] = 7 Su34Status.status[groupName] = 7
MessageToRed( string.format('%s: ',groupName) .. 'Destroyed. ', 30, 'RedStatus' .. groupName ) MessageToRed( string.format('%s: ',groupName) .. 'Destroyed. ', 30, 'RedStatus' .. groupName )
end end
function GroupAlive( groupName ) function GroupAlive( groupName )
trace.menu("","GroupAlive") --trace.menu("","GroupAlive")
local groupTest = Group.getByName( groupName ) local groupTest = Group.getByName( groupName )
local groupExists = false local groupExists = false
@@ -1992,17 +1992,17 @@ trace.menu("","GroupAlive")
groupExists = groupTest:isExist() groupExists = groupTest:isExist()
end end
trace.r( "", "", { groupExists } ) --trace.r( "", "", { groupExists } )
return groupExists return groupExists
end end
function Su34IsDead() function Su34IsDead()
trace.f() --trace.f()
end end
function Su34OverviewStatus() function Su34OverviewStatus()
trace.menu("","Su34OverviewStatus") --trace.menu("","Su34OverviewStatus")
local msg = "" local msg = ""
local currentStatus = 0 local currentStatus = 0
local Exists = false local Exists = false
@@ -2053,25 +2053,25 @@ end
function UpdateBoardMsg() function UpdateBoardMsg()
trace.f() --trace.f()
Su34OverviewStatus() Su34OverviewStatus()
MessageToRed( boardMsgRed.statusMsg, 15, 'RedStatus' ) MessageToRed( boardMsgRed.statusMsg, 15, 'RedStatus' )
end end
function MusicReset( flg ) function MusicReset( flg )
trace.f() --trace.f()
trigger.action.setUserFlag(95,flg) trigger.action.setUserFlag(95,flg)
end end
function PlaneActivate(groupNameFormat, flg) function PlaneActivate(groupNameFormat, flg)
trace.f() --trace.f()
local groupName = groupNameFormat .. string.format("#%03d", trigger.misc.getUserFlag(flg)) local groupName = groupNameFormat .. string.format("#%03d", trigger.misc.getUserFlag(flg))
--trigger.action.outText(groupName,10) --trigger.action.outText(groupName,10)
trigger.action.activateGroup(Group.getByName(groupName)) trigger.action.activateGroup(Group.getByName(groupName))
end end
function Su34Menu(groupName) function Su34Menu(groupName)
trace.f() --trace.f()
--env.info(( 'Su34Menu(' .. groupName .. ')' )) --env.info(( 'Su34Menu(' .. groupName .. ')' ))
local groupSu34 = Group.getByName( groupName ) local groupSu34 = Group.getByName( groupName )
@@ -2144,7 +2144,7 @@ end
--- Obsolete function, but kept to rework in framework. --- Obsolete function, but kept to rework in framework.
function ChooseInfantry ( TeleportPrefixTable, TeleportMax ) function ChooseInfantry ( TeleportPrefixTable, TeleportMax )
trace.f("Spawn") --trace.f("Spawn")
--env.info(( 'ChooseInfantry: ' )) --env.info(( 'ChooseInfantry: ' ))
TeleportPrefixTableCount = #TeleportPrefixTable TeleportPrefixTableCount = #TeleportPrefixTable
@@ -2229,7 +2229,7 @@ end
SpawnedInfantry = 0 SpawnedInfantry = 0
function LandCarrier ( CarrierGroup, LandingZonePrefix ) function LandCarrier ( CarrierGroup, LandingZonePrefix )
trace.f() --trace.f()
--env.info(( 'LandCarrier: ' )) --env.info(( 'LandCarrier: ' ))
--env.info(( 'LandCarrier: CarrierGroup = ' .. CarrierGroup:getName() )) --env.info(( 'LandCarrier: CarrierGroup = ' .. CarrierGroup:getName() ))
--env.info(( 'LandCarrier: LandingZone = ' .. LandingZonePrefix )) --env.info(( 'LandCarrier: LandingZone = ' .. LandingZonePrefix ))
@@ -2248,7 +2248,7 @@ end
EscortCount = 0 EscortCount = 0
function EscortCarrier ( CarrierGroup, EscortPrefix, EscortLastWayPoint, EscortEngagementDistanceMax, EscortTargetTypes ) function EscortCarrier ( CarrierGroup, EscortPrefix, EscortLastWayPoint, EscortEngagementDistanceMax, EscortTargetTypes )
trace.f() --trace.f()
--env.info(( 'EscortCarrier: ' )) --env.info(( 'EscortCarrier: ' ))
--env.info(( 'EscortCarrier: CarrierGroup = ' .. CarrierGroup:getName() )) --env.info(( 'EscortCarrier: CarrierGroup = ' .. CarrierGroup:getName() ))
--env.info(( 'EscortCarrier: EscortPrefix = ' .. EscortPrefix )) --env.info(( 'EscortCarrier: EscortPrefix = ' .. EscortPrefix ))
@@ -2314,7 +2314,7 @@ trace.f()
end end
function SendMessageToCarrier( CarrierGroup, CarrierMessage ) function SendMessageToCarrier( CarrierGroup, CarrierMessage )
trace.f() --trace.f()
if CarrierGroup ~= nil then if CarrierGroup ~= nil then
MessageToGroup( CarrierGroup, CarrierMessage, 30, 'Carrier/' .. CarrierGroup:getName() ) MessageToGroup( CarrierGroup, CarrierMessage, 30, 'Carrier/' .. CarrierGroup:getName() )
@@ -2323,7 +2323,7 @@ trace.f()
end end
function MessageToGroup( MsgGroup, MsgText, MsgTime, MsgName ) function MessageToGroup( MsgGroup, MsgText, MsgTime, MsgName )
trace.f() --trace.f()
if type(MsgGroup) == 'string' then if type(MsgGroup) == 'string' then
--env.info( 'MessageToGroup: Converted MsgGroup string "' .. MsgGroup .. '" into a Group structure.' ) --env.info( 'MessageToGroup: Converted MsgGroup string "' .. MsgGroup .. '" into a Group structure.' )
@@ -2342,7 +2342,7 @@ trace.f()
end end
function MessageToUnit( UnitName, MsgText, MsgTime, MsgName ) function MessageToUnit( UnitName, MsgText, MsgTime, MsgName )
trace.f() --trace.f()
if UnitName ~= nil then if UnitName ~= nil then
local MsgTable = {} local MsgTable = {}
@@ -2355,25 +2355,25 @@ trace.f()
end end
function MessageToAll( MsgText, MsgTime, MsgName ) function MessageToAll( MsgText, MsgTime, MsgName )
trace.f() --trace.f()
MESSAGE:New( MsgText, "Message", MsgTime, MsgName ):ToCoalition( coalition.side.RED ):ToCoalition( coalition.side.BLUE ) MESSAGE:New( MsgText, "Message", MsgTime, MsgName ):ToCoalition( coalition.side.RED ):ToCoalition( coalition.side.BLUE )
end end
function MessageToRed( MsgText, MsgTime, MsgName ) function MessageToRed( MsgText, MsgTime, MsgName )
trace.f() --trace.f()
MESSAGE:New( MsgText, "To Red Coalition", MsgTime, MsgName ):ToCoalition( coalition.side.RED ) MESSAGE:New( MsgText, "To Red Coalition", MsgTime, MsgName ):ToCoalition( coalition.side.RED )
end end
function MessageToBlue( MsgText, MsgTime, MsgName ) function MessageToBlue( MsgText, MsgTime, MsgName )
trace.f() --trace.f()
MESSAGE:New( MsgText, "To Blue Coalition", MsgTime, MsgName ):ToCoalition( coalition.side.RED ) MESSAGE:New( MsgText, "To Blue Coalition", MsgTime, MsgName ):ToCoalition( coalition.side.RED )
end end
function getCarrierHeight( CarrierGroup ) function getCarrierHeight( CarrierGroup )
trace.f() --trace.f()
if CarrierGroup ~= nil then if CarrierGroup ~= nil then
if table.getn(CarrierGroup:getUnits()) == 1 then if table.getn(CarrierGroup:getUnits()) == 1 then
@@ -2398,7 +2398,7 @@ trace.f()
end end
function GetUnitHeight( CheckUnit ) function GetUnitHeight( CheckUnit )
trace.f() --trace.f()
local UnitPoint = CheckUnit:getPoint() local UnitPoint = CheckUnit:getPoint()
local UnitPosition = { x = CurrentPoint.x, y = CurrentPoint.z } local UnitPosition = { x = CurrentPoint.x, y = CurrentPoint.z }
@@ -2420,7 +2420,7 @@ _MusicTable.FileCnt = 0
function MusicRegister( SndRef, SndFile, SndTime ) function MusicRegister( SndRef, SndFile, SndTime )
trace.f() --trace.f()
env.info(( 'MusicRegister: SndRef = ' .. SndRef )) env.info(( 'MusicRegister: SndRef = ' .. SndRef ))
env.info(( 'MusicRegister: SndFile = ' .. SndFile )) env.info(( 'MusicRegister: SndFile = ' .. SndFile ))
@@ -2441,7 +2441,7 @@ trace.f()
end end
function MusicToPlayer( SndRef, PlayerName, SndContinue ) function MusicToPlayer( SndRef, PlayerName, SndContinue )
trace.f() --trace.f()
--env.info(( 'MusicToPlayer: SndRef = ' .. SndRef )) --env.info(( 'MusicToPlayer: SndRef = ' .. SndRef ))
@@ -2464,7 +2464,7 @@ trace.f()
end end
function MusicToGroup( SndRef, SndGroup, SndContinue ) function MusicToGroup( SndRef, SndGroup, SndContinue )
trace.f() --trace.f()
--env.info(( 'MusicToGroup: SndRef = ' .. SndRef )) --env.info(( 'MusicToGroup: SndRef = ' .. SndRef ))
@@ -2507,7 +2507,7 @@ trace.f()
end end
function MusicCanStart(PlayerName) function MusicCanStart(PlayerName)
trace.f() --trace.f()
--env.info(( 'MusicCanStart:' )) --env.info(( 'MusicCanStart:' ))
@@ -2549,7 +2549,7 @@ trace.f()
end end
function MusicScheduler() function MusicScheduler()
trace.scheduled("", "MusicScheduler") --trace.scheduled("", "MusicScheduler")
--env.info(( 'MusicScheduler:' )) --env.info(( 'MusicScheduler:' ))
if _MusicTable['Queue'] ~= nil and _MusicTable.FileCnt > 0 then if _MusicTable['Queue'] ~= nil and _MusicTable.FileCnt > 0 then
+4 -4
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' } ) -- 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 ) function SEAD:New( SEADGroupPrefixes )
local self = BASE:Inherit( self, BASE:New() ) local self = BASE:Inherit( self, BASE:New() )
self:T( SEADGroupPrefixes ) self:F( SEADGroupPrefixes )
if type( SEADGroupPrefixes ) == 'table' then if type( SEADGroupPrefixes ) == 'table' then
for SEADGroupPrefixID, SEADGroupPrefix in pairs( SEADGroupPrefixes ) do for SEADGroupPrefixID, SEADGroupPrefix in pairs( SEADGroupPrefixes ) do
self.SEADGroupPrefixes[SEADGroupPrefix] = SEADGroupPrefix self.SEADGroupPrefixes[SEADGroupPrefix] = SEADGroupPrefix
@@ -42,8 +42,8 @@ function SEAD:New( SEADGroupPrefixes )
else else
self.SEADGroupNames[SEADGroupPrefixes] = SEADGroupPrefixes self.SEADGroupNames[SEADGroupPrefixes] = SEADGroupPrefixes
end end
self.AddEvent( self, world.event.S_EVENT_SHOT, self.EventShot ) self:AddEvent( world.event.S_EVENT_SHOT, self.EventShot )
self.EnableEvents( self ) self:EnableEvents()
return self return self
end 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. --- 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 -- @see SEAD
function SEAD:EventShot( event ) function SEAD:EventShot( event )
self:T( { event } ) self:F( { event } )
local SEADUnit = event.initiator local SEADUnit = event.initiator
local SEADUnitName = SEADUnit:getName() local SEADUnitName = SEADUnit:getName()
+51 -51
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. -- @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 ) function SPAWN:New( SpawnTemplatePrefix )
local self = BASE:Inherit( self, BASE:New() ) local self = BASE:Inherit( self, BASE:New() )
self:T( { SpawnTemplatePrefix } ) self:F( { SpawnTemplatePrefix } )
local TemplateGroup = Group.getByName( SpawnTemplatePrefix ) local TemplateGroup = Group.getByName( SpawnTemplatePrefix )
if TemplateGroup then 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 .. "'" ) error( "SPAWN:New: There is no group declared in the mission editor with SpawnTemplatePrefix = '" .. SpawnTemplatePrefix .. "'" )
end end
self.AddEvent( self, world.event.S_EVENT_BIRTH, self._OnBirth ) self:AddEvent( world.event.S_EVENT_BIRTH, self._OnBirth )
self.AddEvent( self, world.event.S_EVENT_DEAD, self._OnDeadOrCrash ) self:AddEvent( world.event.S_EVENT_DEAD, self._OnDeadOrCrash )
self.AddEvent( self, world.event.S_EVENT_CRASH, self._OnDeadOrCrash ) self:AddEvent( world.event.S_EVENT_CRASH, self._OnDeadOrCrash )
self.EnableEvents( self ) self:EnableEvents()
return self return self
end 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. -- @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 ) function SPAWN:NewWithAlias( SpawnTemplatePrefix, SpawnAliasPrefix )
local self = BASE:Inherit( self, BASE:New() ) local self = BASE:Inherit( self, BASE:New() )
self:T( { SpawnTemplatePrefix, SpawnAliasPrefix } ) self:F( { SpawnTemplatePrefix, SpawnAliasPrefix } )
local TemplateGroup = Group.getByName( SpawnTemplatePrefix ) local TemplateGroup = Group.getByName( SpawnTemplatePrefix )
if TemplateGroup then 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 .. "'" ) error( "SPAWN:New: There is no group declared in the mission editor with SpawnTemplatePrefix = '" .. SpawnTemplatePrefix .. "'" )
end end
self.AddEvent( self, world.event.S_EVENT_BIRTH, self._OnBirth ) self:AddEvent( world.event.S_EVENT_BIRTH, self._OnBirth )
self.AddEvent( self, world.event.S_EVENT_DEAD, self._OnDeadOrCrash ) self:AddEvent( world.event.S_EVENT_DEAD, self._OnDeadOrCrash )
self.AddEvent( self, world.event.S_EVENT_CRASH, self._OnDeadOrCrash ) self:AddEvent( world.event.S_EVENT_CRASH, self._OnDeadOrCrash )
self.EnableEvents( self ) self:EnableEvents()
return self return self
end end
@@ -187,7 +187,7 @@ end
-- -- There will be maximum 24 groups spawned during the whole mission lifetime. -- -- 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 ) -- Spawn_BE_KA50 = SPAWN:New( 'BE KA-50@RAMP-Ground Defense' ):Limit( 2, 24 )
function SPAWN:Limit( SpawnMaxUnitsAlive, SpawnMaxGroups ) 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.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. 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. -- -- 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 ) -- Spawn_BE_KA50 = SPAWN:New( 'BE KA-50@RAMP-Ground Defense' ):RandomizeRoute( 2, 2, 2000 )
function SPAWN:RandomizeRoute( SpawnStartPoint, SpawnEndPoint, SpawnRadius ) function SPAWN:RandomizeRoute( SpawnStartPoint, SpawnEndPoint, SpawnRadius )
self:T( { self.SpawnTemplatePrefix, SpawnStartPoint, SpawnEndPoint, SpawnRadius } ) self:F( { self.SpawnTemplatePrefix, SpawnStartPoint, SpawnEndPoint, SpawnRadius } )
self.SpawnRandomizeRoute = true self.SpawnRandomizeRoute = true
self.SpawnRandomizeRouteStartPoint = SpawnStartPoint 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_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 ) -- 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 ) function SPAWN:RandomizeTemplate( SpawnTemplatePrefixTable )
self:T( { self.SpawnTemplatePrefix, SpawnTemplatePrefixTable } ) self:F( { self.SpawnTemplatePrefix, SpawnTemplatePrefixTable } )
self.SpawnTemplatePrefixTable = SpawnTemplatePrefixTable self.SpawnTemplatePrefixTable = SpawnTemplatePrefixTable
self.SpawnRandomizeTemplate = true self.SpawnRandomizeTemplate = true
@@ -278,7 +278,7 @@ end
-- -- Re-SPAWN the Group(s) after each landing and Engine Shut-Down automatically. -- -- 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() -- 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() function SPAWN:Repeat()
self:T( { self.SpawnTemplatePrefix } ) self:F( { self.SpawnTemplatePrefix } )
self.SpawnRepeat = true self.SpawnRepeat = true
self.RepeatOnEngineShutDown = false self.RepeatOnEngineShutDown = false
@@ -297,7 +297,7 @@ end
-- @see Repeat -- @see Repeat
function SPAWN:RepeatOnLanding() function SPAWN:RepeatOnLanding()
self:T( { self.SpawnTemplatePrefix } ) self:F( { self.SpawnTemplatePrefix } )
self:Repeat() self:Repeat()
self.RepeatOnEngineShutDown = false 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. --- Same as the @{#SPAWN.Repeat) method, but now the Group will respawn after its engines have shut down.
-- @return SPAWN -- @return SPAWN
function SPAWN:RepeatOnEngineShutDown() function SPAWN:RepeatOnEngineShutDown()
self:T( { self.SpawnTemplatePrefix } ) self:F( { self.SpawnTemplatePrefix } )
self:Repeat() self:Repeat()
self.RepeatOnEngineShutDown = true self.RepeatOnEngineShutDown = true
@@ -326,7 +326,7 @@ end
-- @return #SPAWN self -- @return #SPAWN self
-- @usage Spawn_Helicopter:CleanUp( 20 ) -- CleanUp the spawning of the helicopters every 20 seconds when they become inactive. -- @usage Spawn_Helicopter:CleanUp( 20 ) -- CleanUp the spawning of the helicopters every 20 seconds when they become inactive.
function SPAWN:CleanUp( SpawnCleanUpInterval ) function SPAWN:CleanUp( SpawnCleanUpInterval )
self:T( { self.SpawnTemplatePrefix, SpawnCleanUpInterval } ) self:F( { self.SpawnTemplatePrefix, SpawnCleanUpInterval } )
self.SpawnCleanUpInterval = SpawnCleanUpInterval self.SpawnCleanUpInterval = SpawnCleanUpInterval
self.SpawnCleanUpTimeStamps = {} self.SpawnCleanUpTimeStamps = {}
@@ -349,7 +349,7 @@ end
-- -- Define an array of Groups. -- -- Define an array of Groups.
-- Spawn_BE_Ground = SPAWN:New( 'BE Ground' ):Limit( 2, 24 ):Visible( 90, "Diamond", 10, 100, 50 ) -- Spawn_BE_Ground = SPAWN:New( 'BE Ground' ):Limit( 2, 24 ):Visible( 90, "Diamond", 10, 100, 50 )
function SPAWN:Array( SpawnAngle, SpawnWidth, SpawnDeltaX, SpawnDeltaY ) 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. 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 -- @param self
-- @return GROUP#GROUP The group that was spawned. You can use this group for further actions. -- @return GROUP#GROUP The group that was spawned. You can use this group for further actions.
function SPAWN:Spawn() function SPAWN:Spawn()
self:T( { self.SpawnTemplatePrefix, self.SpawnIndex } ) self:F( { self.SpawnTemplatePrefix, self.SpawnIndex } )
return self:SpawnWithIndex( self.SpawnIndex + 1 ) return self:SpawnWithIndex( self.SpawnIndex + 1 )
end end
@@ -408,7 +408,7 @@ end
-- @param #string SpawnIndex The index of the group to be spawned. -- @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. -- @return GROUP#GROUP The group that was spawned. You can use this group for further actions.
function SPAWN:ReSpawn( SpawnIndex ) function SPAWN:ReSpawn( SpawnIndex )
self:T( { self.SpawnTemplatePrefix, SpawnIndex } ) self:F( { self.SpawnTemplatePrefix, SpawnIndex } )
if not SpawnIndex then if not SpawnIndex then
SpawnIndex = 1 SpawnIndex = 1
@@ -426,7 +426,7 @@ end
-- Uses @{DATABASE} global object defined in MOOSE. -- Uses @{DATABASE} global object defined in MOOSE.
-- @return GROUP#GROUP The group that was spawned. You can use this group for further actions. -- @return GROUP#GROUP The group that was spawned. You can use this group for further actions.
function SPAWN:SpawnWithIndex( SpawnIndex ) function SPAWN:SpawnWithIndex( SpawnIndex )
self:T( { self.SpawnTemplatePrefix, SpawnIndex, self.SpawnMaxGroups } ) self:F( { self.SpawnTemplatePrefix, SpawnIndex, self.SpawnMaxGroups } )
if self:_GetSpawnIndex( SpawnIndex ) then 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. -- -- 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 ) -- Spawn_BE_KA50 = SPAWN:New( 'BE KA-50@RAMP-Ground Defense' ):Schedule( 600, 0.5 )
function SPAWN:SpawnScheduled( SpawnTime, SpawnTimeVariation ) 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.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. self.SpawnSetTimer = 0 -- The internal timer value when a scheduled spawning of SpawnTemplatePrefix occurs.
@@ -490,7 +490,7 @@ end
--- Will start the spawning scheduler. --- Will start the spawning scheduler.
-- Note: This function is called automatically when @{#SPAWN.Scheduled} is called. -- Note: This function is called automatically when @{#SPAWN.Scheduled} is called.
function SPAWN:SpawnScheduleStart() function SPAWN:SpawnScheduleStart()
self:T( { self.SpawnTemplatePrefix } ) self:F( { self.SpawnTemplatePrefix } )
--local ClientUnit = #AlivePlayerUnits() --local ClientUnit = #AlivePlayerUnits()
@@ -507,7 +507,7 @@ end
--- Will stop the scheduled spawning scheduler. --- Will stop the scheduled spawning scheduler.
function SPAWN:SpawnScheduleStop() function SPAWN:SpawnScheduleStop()
self:T( { self.SpawnTemplatePrefix } ) self:F( { self.SpawnTemplatePrefix } )
self.SpawnIsScheduled = false self.SpawnIsScheduled = false
end 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. -- 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. -- You can use the returned group to further define the route to be followed.
-- @param self -- @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 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 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. -- @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. -- @return #nil Nothing was spawned.
function SPAWN:SpawnFromUnit( HostUnit, OuterRadius, InnerRadius, SpawnIndex ) 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 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].x = UnitPoint.x
SpawnTemplate.units[UnitID].y = UnitPoint.y SpawnTemplate.units[UnitID].y = UnitPoint.y
else 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].x = CirclePos.x
SpawnTemplate.units[UnitID].y = CirclePos.y SpawnTemplate.units[UnitID].y = CirclePos.y
end end
self:T( 'SpawnTemplate.units['..UnitID..'].x = ' .. SpawnTemplate.units[UnitID].x .. ', SpawnTemplate.units['..UnitID..'].y = ' .. SpawnTemplate.units[UnitID].y ) self:T( 'SpawnTemplate.units['..UnitID..'].x = ' .. SpawnTemplate.units[UnitID].x .. ', SpawnTemplate.units['..UnitID..'].y = ' .. SpawnTemplate.units[UnitID].y )
end end
local SpawnPos = routines.getRandPointInCircle( UnitPoint, InnerRadius+1, InnerRadius ) local SpawnPos = routines.getRandPointInCircle( UnitPoint, OuterRadius, InnerRadius )
local Point = {} local Point = {}
Point.type = "Turning Point" Point.type = "Turning Point"
Point.x = SpawnPos.x Point.x = SpawnPos.x
@@ -598,7 +598,7 @@ end
-- @return GROUP#GROUP that was spawned. -- @return GROUP#GROUP that was spawned.
-- @return #nil when nothing was spawned. -- @return #nil when nothing was spawned.
function SPAWN:SpawnInZone( Zone, SpawnIndex ) function SPAWN:SpawnInZone( Zone, SpawnIndex )
self:T( { self.SpawnTemplatePrefix, Zone, SpawnIndex } ) self:F( { self.SpawnTemplatePrefix, Zone, SpawnIndex } )
if Zone then if Zone then
@@ -652,7 +652,7 @@ end
-- This will be similar to the uncontrolled flag setting in the ME. -- This will be similar to the uncontrolled flag setting in the ME.
-- @return #SPAWN self -- @return #SPAWN self
function SPAWN:UnControlled() function SPAWN:UnControlled()
self:T( { self.SpawnTemplatePrefix } ) self:F( { self.SpawnTemplatePrefix } )
self.SpawnUnControlled = true self.SpawnUnControlled = true
@@ -670,7 +670,7 @@ end
-- @param #number SpawnIndex Is the number of the Group that is to be spawned. -- @param #number SpawnIndex Is the number of the Group that is to be spawned.
-- @return string SpawnGroupName -- @return string SpawnGroupName
function SPAWN:SpawnGroupName( SpawnIndex ) function SPAWN:SpawnGroupName( SpawnIndex )
self:T( { self.SpawnTemplatePrefix, SpawnIndex } ) self:F( { self.SpawnTemplatePrefix, SpawnIndex } )
local SpawnPrefix = self.SpawnTemplatePrefix local SpawnPrefix = self.SpawnTemplatePrefix
if self.SpawnAliasPrefix then 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 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. -- @return #nil, #nil When no group is found, #nil is returned.
function SPAWN:GetFirstAliveGroup( SpawnCursor ) function SPAWN:GetFirstAliveGroup( SpawnCursor )
self:T( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, SpawnCursor } ) self:F( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, SpawnCursor } )
for SpawnIndex = 1, self.SpawnCount do for SpawnIndex = 1, self.SpawnCount do
local SpawnGroup = self:GetGroupFromIndex( SpawnIndex ) 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 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. -- @return #nil, #nil When no group is found, #nil is returned.
function SPAWN:GetNextAliveGroup( SpawnCursor ) function SPAWN:GetNextAliveGroup( SpawnCursor )
self:T( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, SpawnCursor } ) self:F( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, SpawnCursor } )
SpawnCursor = SpawnCursor + 1 SpawnCursor = SpawnCursor + 1
for SpawnIndex = SpawnCursor, self.SpawnCount do for SpawnIndex = SpawnCursor, self.SpawnCount do
@@ -730,7 +730,7 @@ end
--- Find the last alive group during runtime. --- Find the last alive group during runtime.
function SPAWN:GetLastAliveGroup() function SPAWN:GetLastAliveGroup()
self:T( { self.SpawnTemplatePrefixself.SpawnAliasPrefix } ) self:F( { self.SpawnTemplatePrefixself.SpawnAliasPrefix } )
self.SpawnIndex = self:_GetLastIndex() self.SpawnIndex = self:_GetLastIndex()
for SpawnIndex = self.SpawnIndex, 1, -1 do for SpawnIndex = self.SpawnIndex, 1, -1 do
@@ -754,7 +754,7 @@ end
-- @param #number SpawnIndex The index of the group to return. -- @param #number SpawnIndex The index of the group to return.
-- @return GROUP#GROUP -- @return GROUP#GROUP
function SPAWN:GetGroupFromIndex( SpawnIndex ) function SPAWN:GetGroupFromIndex( SpawnIndex )
self:T( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, SpawnIndex } ) self:F( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, SpawnIndex } )
if SpawnIndex then if SpawnIndex then
local SpawnGroup = self.SpawnGroups[SpawnIndex].Group local SpawnGroup = self.SpawnGroups[SpawnIndex].Group
@@ -773,7 +773,7 @@ end
-- @return #string The prefix -- @return #string The prefix
-- @return #nil Nothing found -- @return #nil Nothing found
function SPAWN:_GetGroupIndexFromDCSUnit( DCSUnit ) function SPAWN:_GetGroupIndexFromDCSUnit( DCSUnit )
self:T( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, DCSUnit } ) self:F( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, DCSUnit } )
if DCSUnit and DCSUnit:getName() then if DCSUnit and DCSUnit:getName() then
local IndexString = string.match( DCSUnit:getName(), "#.*-" ):sub( 2, -2 ) local IndexString = string.match( DCSUnit:getName(), "#.*-" ):sub( 2, -2 )
@@ -797,7 +797,7 @@ end
-- @return #string The prefix -- @return #string The prefix
-- @return #nil Nothing found -- @return #nil Nothing found
function SPAWN:_GetPrefixFromDCSUnit( DCSUnit ) function SPAWN:_GetPrefixFromDCSUnit( DCSUnit )
self:T( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, DCSUnit } ) self:F( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, DCSUnit } )
if DCSUnit and DCSUnit:getName() then if DCSUnit and DCSUnit:getName() then
local SpawnPrefix = string.match( DCSUnit:getName(), ".*#" ) local SpawnPrefix = string.match( DCSUnit:getName(), ".*#" )
@@ -813,7 +813,7 @@ end
--- Return the group within the SpawnGroups collection with input a DCSUnit. --- Return the group within the SpawnGroups collection with input a DCSUnit.
function SPAWN:_GetGroupFromDCSUnit( DCSUnit ) function SPAWN:_GetGroupFromDCSUnit( DCSUnit )
self:T( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, DCSUnit } ) self:F( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, DCSUnit } )
if DCSUnit then if DCSUnit then
local SpawnPrefix = self:_GetPrefixFromDCSUnit( DCSUnit ) local SpawnPrefix = self:_GetPrefixFromDCSUnit( DCSUnit )
@@ -833,7 +833,7 @@ end
--- Get the index from a given group. --- 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. -- The function will search the name of the group for a #, and will return the number behind the #-mark.
function SPAWN:GetSpawnIndexFromGroup( SpawnGroup ) 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 IndexString = string.match( SpawnGroup:GetName(), "#.*$" ):sub( 2 )
local Index = tonumber( IndexString ) local Index = tonumber( IndexString )
@@ -845,14 +845,14 @@ end
--- Return the last maximum index that can be used. --- Return the last maximum index that can be used.
function SPAWN:_GetLastIndex() function SPAWN:_GetLastIndex()
self:T( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix } ) self:F( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix } )
return self.SpawnMaxGroups return self.SpawnMaxGroups
end end
--- Initalize the SpawnGroups collection. --- Initalize the SpawnGroups collection.
function SPAWN:_InitializeSpawnGroups( SpawnIndex ) function SPAWN:_InitializeSpawnGroups( SpawnIndex )
self:T( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, SpawnIndex } ) self:F( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, SpawnIndex } )
if not self.SpawnGroups[SpawnIndex] then if not self.SpawnGroups[SpawnIndex] then
self.SpawnGroups[SpawnIndex] = {} self.SpawnGroups[SpawnIndex] = {}
@@ -899,7 +899,7 @@ end
--- Gets the CountryID of the Group with the given SpawnPrefix --- Gets the CountryID of the Group with the given SpawnPrefix
function SPAWN:_GetGroupCountryID( SpawnPrefix ) function SPAWN:_GetGroupCountryID( SpawnPrefix )
self:T( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, SpawnPrefix } ) self:F( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, SpawnPrefix } )
local TemplateGroup = Group.getByName( SpawnPrefix ) local TemplateGroup = Group.getByName( SpawnPrefix )
@@ -914,7 +914,7 @@ end
--- Gets the Group Template from the ME environment definition. --- 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. -- This method used the @{DATABASE} object, which contains ALL initial and new spawned object in MOOSE.
function SPAWN:_GetTemplate( SpawnTemplatePrefix ) function SPAWN:_GetTemplate( SpawnTemplatePrefix )
self:T( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, SpawnTemplatePrefix } ) self:F( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, SpawnTemplatePrefix } )
local SpawnTemplate = nil local SpawnTemplate = nil
@@ -934,7 +934,7 @@ end
--- Prepares the new Group Template. --- Prepares the new Group Template.
function SPAWN:_Prepare( SpawnTemplatePrefix, SpawnIndex ) function SPAWN:_Prepare( SpawnTemplatePrefix, SpawnIndex )
self:T( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix } ) self:F( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix } )
local SpawnTemplate = self:_GetTemplate( SpawnTemplatePrefix ) local SpawnTemplate = self:_GetTemplate( SpawnTemplatePrefix )
SpawnTemplate.name = self:SpawnGroupName( SpawnIndex ) SpawnTemplate.name = self:SpawnGroupName( SpawnIndex )
@@ -967,7 +967,7 @@ end
-- @param #number SpawnIndex The index of the group to be spawned. -- @param #number SpawnIndex The index of the group to be spawned.
-- @return #SPAWN -- @return #SPAWN
function SPAWN:_RandomizeRoute( SpawnIndex ) 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 if self.SpawnRandomizeRoute then
local SpawnTemplate = self.SpawnGroups[SpawnIndex].SpawnTemplate local SpawnTemplate = self.SpawnGroups[SpawnIndex].SpawnTemplate
@@ -988,7 +988,7 @@ end
function SPAWN:_RandomizeTemplate( SpawnIndex ) function SPAWN:_RandomizeTemplate( SpawnIndex )
self:T( { self.SpawnTemplatePrefix, SpawnIndex } ) self:F( { self.SpawnTemplatePrefix, SpawnIndex } )
if self.SpawnRandomizeTemplate then if self.SpawnRandomizeTemplate then
self.SpawnGroups[SpawnIndex].SpawnTemplatePrefix = self.SpawnTemplatePrefixTable[ math.random( 1, #self.SpawnTemplatePrefixTable ) ] self.SpawnGroups[SpawnIndex].SpawnTemplatePrefix = self.SpawnTemplatePrefixTable[ math.random( 1, #self.SpawnTemplatePrefixTable ) ]
@@ -1007,7 +1007,7 @@ function SPAWN:_RandomizeTemplate( SpawnIndex )
end end
function SPAWN:_TranslateRotate( SpawnIndex, SpawnRootX, SpawnRootY, SpawnX, SpawnY, SpawnAngle ) 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 -- Translate
local TranslatedX = SpawnX 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. --- 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 ) 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 if ( self.SpawnMaxGroups == 0 ) or ( SpawnIndex <= self.SpawnMaxGroups ) then
@@ -1170,7 +1170,7 @@ end
--- This function is called automatically by the Spawning scheduler. --- This function is called automatically by the Spawning scheduler.
-- It is the internal worker method SPAWNing new Groups on the defined time intervals. -- It is the internal worker method SPAWNing new Groups on the defined time intervals.
function SPAWN:_Scheduler() 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 if self.SpawnInit or self.SpawnCurrentTimer == self.SpawnSetTimer then
-- Validate if there are still groups left in the batch... -- Validate if there are still groups left in the batch...
@@ -1188,7 +1188,7 @@ self:T( { "_Scheduler", self.SpawnTemplatePrefix, self.SpawnAliasPrefix, self.Sp
end end
function SPAWN:_SpawnCleanUpScheduler() function SPAWN:_SpawnCleanUpScheduler()
self:T( { "CleanUp Scheduler:", self.SpawnTemplatePrefix } ) self:F( { "CleanUp Scheduler:", self.SpawnTemplatePrefix } )
local SpawnCursor local SpawnCursor
local SpawnGroup, SpawnCursor = self:GetFirstAliveGroup( SpawnCursor ) local SpawnGroup, SpawnCursor = self:GetFirstAliveGroup( SpawnCursor )
+42 -42
View File
@@ -29,7 +29,7 @@ STAGE = {
function STAGE:New() function STAGE:New()
local self = BASE:Inherit( self, BASE:New() ) local self = BASE:Inherit( self, BASE:New() )
self:T() self:F()
return self return self
end end
@@ -61,14 +61,14 @@ STAGEBRIEF = {
function STAGEBRIEF:New() function STAGEBRIEF:New()
local self = BASE:Inherit( self, STAGE:New() ) local self = BASE:Inherit( self, STAGE:New() )
self:T() self:F()
self.StageType = 'CLIENT' self.StageType = 'CLIENT'
return self return self
end end
function STAGEBRIEF:Execute( Mission, Client, Task ) function STAGEBRIEF:Execute( Mission, Client, Task )
local Valid = BASE:Inherited(self):Execute( Mission, Client, Task ) local Valid = BASE:Inherited(self):Execute( Mission, Client, Task )
self:T() self:F()
Mission:ShowBriefing( Client ) Mission:ShowBriefing( Client )
self.StageBriefingTime = timer.getTime() self.StageBriefingTime = timer.getTime()
return Valid return Valid
@@ -98,13 +98,13 @@ STAGESTART = {
function STAGESTART:New() function STAGESTART:New()
local self = BASE:Inherit( self, STAGE:New() ) local self = BASE:Inherit( self, STAGE:New() )
self:T() self:F()
self.StageType = 'CLIENT' self.StageType = 'CLIENT'
return self return self
end end
function STAGESTART:Execute( Mission, Client, Task ) function STAGESTART:Execute( Mission, Client, Task )
self:T() self:F()
local Valid = BASE:Inherited(self):Execute( Mission, Client, Task ) local Valid = BASE:Inherited(self):Execute( Mission, Client, Task )
if Task.TaskBriefing then if Task.TaskBriefing then
Client:Message( Task.TaskBriefing, 30, Mission.Name .. "/Stage", "Mission Command: Tasking" ) Client:Message( Task.TaskBriefing, 30, Mission.Name .. "/Stage", "Mission Command: Tasking" )
@@ -116,7 +116,7 @@ self:T()
end end
function STAGESTART:Validate( Mission, Client, Task ) function STAGESTART:Validate( Mission, Client, Task )
self:T() self:F()
local Valid = STAGE:Validate( Mission, Client, Task ) local Valid = STAGE:Validate( Mission, Client, Task )
if timer.getTime() - self.StageStartTime <= self.StageStartDuration then if timer.getTime() - self.StageStartTime <= self.StageStartDuration then
@@ -136,13 +136,13 @@ STAGE_CARGO_LOAD = {
function STAGE_CARGO_LOAD:New() function STAGE_CARGO_LOAD:New()
local self = BASE:Inherit( self, STAGE:New() ) local self = BASE:Inherit( self, STAGE:New() )
self:T() self:F()
self.StageType = 'CLIENT' self.StageType = 'CLIENT'
return self return self
end end
function STAGE_CARGO_LOAD:Execute( Mission, Client, Task ) function STAGE_CARGO_LOAD:Execute( Mission, Client, Task )
self:T() self:F()
local Valid = BASE:Inherited(self):Execute( Mission, Client, Task ) local Valid = BASE:Inherited(self):Execute( Mission, Client, Task )
for LoadCargoID, LoadCargo in pairs( Task.Cargos.LoadCargos ) do for LoadCargoID, LoadCargo in pairs( Task.Cargos.LoadCargos ) do
@@ -157,7 +157,7 @@ self:T()
end end
function STAGE_CARGO_LOAD:Validate( Mission, Client, Task ) function STAGE_CARGO_LOAD:Validate( Mission, Client, Task )
self:T() self:F()
local Valid = STAGE:Validate( Mission, Client, Task ) local Valid = STAGE:Validate( Mission, Client, Task )
return 1 return 1
@@ -170,13 +170,13 @@ STAGE_CARGO_INIT = {
function STAGE_CARGO_INIT:New() function STAGE_CARGO_INIT:New()
local self = BASE:Inherit( self, STAGE:New() ) local self = BASE:Inherit( self, STAGE:New() )
self:T() self:F()
self.StageType = 'CLIENT' self.StageType = 'CLIENT'
return self return self
end end
function STAGE_CARGO_INIT:Execute( Mission, Client, Task ) function STAGE_CARGO_INIT:Execute( Mission, Client, Task )
self:T() self:F()
local Valid = BASE:Inherited(self):Execute( Mission, Client, Task ) local Valid = BASE:Inherited(self):Execute( Mission, Client, Task )
for InitLandingZoneID, InitLandingZone in pairs( Task.LandingZones.LandingZones ) do for InitLandingZoneID, InitLandingZone in pairs( Task.LandingZones.LandingZones ) do
@@ -196,7 +196,7 @@ end
function STAGE_CARGO_INIT:Validate( Mission, Client, Task ) function STAGE_CARGO_INIT:Validate( Mission, Client, Task )
self:T() self:F()
local Valid = STAGE:Validate( Mission, Client, Task ) local Valid = STAGE:Validate( Mission, Client, Task )
return 1 return 1
@@ -213,7 +213,7 @@ STAGEROUTE = {
function STAGEROUTE:New() function STAGEROUTE:New()
local self = BASE:Inherit( self, STAGE:New() ) local self = BASE:Inherit( self, STAGE:New() )
self:T() self:F()
self.StageType = 'CLIENT' self.StageType = 'CLIENT'
self.MessageSwitch = true self.MessageSwitch = true
return self return self
@@ -221,7 +221,7 @@ end
function STAGEROUTE:Execute( Mission, Client, Task ) function STAGEROUTE:Execute( Mission, Client, Task )
self:T() self:F()
local Valid = BASE:Inherited(self):Execute( Mission, Client, Task ) local Valid = BASE:Inherited(self):Execute( Mission, Client, Task )
local RouteMessage = "Fly to " local RouteMessage = "Fly to "
@@ -239,7 +239,7 @@ self:T()
end end
function STAGEROUTE:Validate( Mission, Client, Task ) function STAGEROUTE:Validate( Mission, Client, Task )
self:T() self:F()
local Valid = STAGE:Validate( Mission, Client, Task ) local Valid = STAGE:Validate( Mission, Client, Task )
-- check if the Client is in the landing zone -- check if the Client is in the landing zone
@@ -274,13 +274,13 @@ STAGELANDING = {
function STAGELANDING:New() function STAGELANDING:New()
local self = BASE:Inherit( self, STAGE:New() ) local self = BASE:Inherit( self, STAGE:New() )
self:T() self:F()
self.StageType = 'CLIENT' self.StageType = 'CLIENT'
return self return self
end end
function STAGELANDING:Execute( Mission, Client, Task ) 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 ) 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 end
function STAGELANDING:Validate( Mission, Client, Task ) function STAGELANDING:Validate( Mission, Client, Task )
self:T() self:F()
Task.CurrentLandingZoneName = routines.IsUnitInZones( Client:GetClientGroupDCSUnit(), Task.LandingZones.LandingZoneNames ) Task.CurrentLandingZoneName = routines.IsUnitInZones( Client:GetClientGroupDCSUnit(), Task.LandingZones.LandingZoneNames )
if Task.CurrentLandingZoneName then if Task.CurrentLandingZoneName then
@@ -376,13 +376,13 @@ STAGELANDED = {
function STAGELANDED:New() function STAGELANDED:New()
local self = BASE:Inherit( self, STAGE:New() ) local self = BASE:Inherit( self, STAGE:New() )
self:T() self:F()
self.StageType = 'CLIENT' self.StageType = 'CLIENT'
return self return self
end end
function STAGELANDED:Execute( Mission, Client, Task ) function STAGELANDED:Execute( Mission, Client, Task )
self:T() self:F()
if Task.IsLandingRequired then 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 .. '.', 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 ) function STAGELANDED:Validate( Mission, Client, Task )
self:T() self:F()
if not routines.IsUnitInZones( Client:GetClientGroupDCSUnit(), Task.CurrentLandingZoneName ) then 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." ) 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() function STAGEUNLOAD:New()
local self = BASE:Inherit( self, STAGE:New() ) local self = BASE:Inherit( self, STAGE:New() )
self:T() self:F()
self.StageType = 'CLIENT' self.StageType = 'CLIENT'
return self return self
end end
function STAGEUNLOAD:Execute( Mission, Client, Task ) 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] .. '.', 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" ) self.MSG.TIME, Mission.Name .. "/StageUnLoad", "Co-Pilot: Unload" )
Task:RemoveCargoMenus( Client ) Task:RemoveCargoMenus( Client )
end end
function STAGEUNLOAD:Executing( Mission, Client, Task ) function STAGEUNLOAD:Executing( Mission, Client, Task )
self:T() self:F()
env.info( 'STAGEUNLOAD:Executing() Task.Cargo.CargoName = ' .. Task.Cargo.CargoName ) env.info( 'STAGEUNLOAD:Executing() Task.Cargo.CargoName = ' .. Task.Cargo.CargoName )
local TargetZoneName local TargetZoneName
@@ -464,7 +464,7 @@ self:T()
end end
function STAGEUNLOAD:Validate( Mission, Client, Task ) function STAGEUNLOAD:Validate( Mission, Client, Task )
self:T() self:F()
env.info( 'STAGEUNLOAD:Validate()' ) env.info( 'STAGEUNLOAD:Validate()' )
if routines.IsUnitInZones( Client:GetClientGroupDCSUnit(), Task.CurrentLandingZoneName ) then if routines.IsUnitInZones( Client:GetClientGroupDCSUnit(), Task.CurrentLandingZoneName ) then
@@ -503,13 +503,13 @@ STAGELOAD = {
function STAGELOAD:New() function STAGELOAD:New()
local self = BASE:Inherit( self, STAGE:New() ) local self = BASE:Inherit( self, STAGE:New() )
self:T() self:F()
self.StageType = 'CLIENT' self.StageType = 'CLIENT'
return self return self
end end
function STAGELOAD:Execute( Mission, Client, Task ) function STAGELOAD:Execute( Mission, Client, Task )
self:T() self:F()
if not Task.IsSlingLoad then 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] .. '.', 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 end
function STAGELOAD:Executing( Mission, Client, Task ) function STAGELOAD:Executing( Mission, Client, Task )
self:T() self:F()
-- If the Cargo is ready to be loaded, load it into the Client. -- If the Cargo is ready to be loaded, load it into the Client.
if not Task.IsSlingLoad then 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 if Task.Cargo:OnBoarded( Client, Task.CurrentCargoZone ) then
@@ -553,12 +553,12 @@ self:T()
if Cargo:IsSlingLoad() then if Cargo:IsSlingLoad() then
local CargoStatic = StaticObject.getByName( Cargo.CargoStaticName ) local CargoStatic = StaticObject.getByName( Cargo.CargoStaticName )
if CargoStatic then 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 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 ) local CargoStaticHeight = routines.GetUnitHeight( CargoStatic )
if CargoStaticHeight > 5 then if CargoStaticHeight > 5 then
trace.i(self.ClassName, "Cargo is airborne.") self:T( "Cargo is airborne.")
Cargo:StatusLoaded() Cargo:StatusLoaded()
Task.Cargo = Cargo 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.', 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 end
function STAGELOAD:Validate( Mission, Client, Task ) function STAGELOAD:Validate( Mission, Client, Task )
self:T() self:F()
self:T( "Task.CurrentLandingZoneName = " .. Task.CurrentLandingZoneName ) self:T( "Task.CurrentLandingZoneName = " .. Task.CurrentLandingZoneName )
@@ -635,18 +635,18 @@ STAGEDONE = {
function STAGEDONE:New() function STAGEDONE:New()
local self = BASE:Inherit( self, STAGE:New() ) local self = BASE:Inherit( self, STAGE:New() )
self:T() self:F()
self.StageType = 'AI' self.StageType = 'AI'
return self return self
end end
function STAGEDONE:Execute( Mission, Client, Task ) function STAGEDONE:Execute( Mission, Client, Task )
self:T() self:F()
end end
function STAGEDONE:Validate( Mission, Client, Task ) function STAGEDONE:Validate( Mission, Client, Task )
self:T() self:F()
Task:Done() Task:Done()
@@ -661,20 +661,20 @@ STAGEARRIVE = {
function STAGEARRIVE:New() function STAGEARRIVE:New()
local self = BASE:Inherit( self, STAGE:New() ) local self = BASE:Inherit( self, STAGE:New() )
self:T() self:F()
self.StageType = 'CLIENT' self.StageType = 'CLIENT'
return self return self
end end
function STAGEARRIVE:Execute( Mission, Client, Task ) 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" ) Client:Message( 'We have arrived at ' .. Task.CurrentLandingZoneName .. ".", self.MSG.TIME, Mission.Name .. "/Stage", "Co-Pilot: Arrived" )
end end
function STAGEARRIVE:Validate( Mission, Client, Task ) function STAGEARRIVE:Validate( Mission, Client, Task )
self:T() self:F()
Task.CurrentLandingZoneID = routines.IsUnitInZones( Client:GetClientGroupDCSUnit(), Task.LandingZones ) Task.CurrentLandingZoneID = routines.IsUnitInZones( Client:GetClientGroupDCSUnit(), Task.LandingZones )
if ( Task.CurrentLandingZoneID ) then if ( Task.CurrentLandingZoneID ) then
@@ -695,7 +695,7 @@ STAGEGROUPSDESTROYED = {
function STAGEGROUPSDESTROYED:New() function STAGEGROUPSDESTROYED:New()
local self = BASE:Inherit( self, STAGE:New() ) local self = BASE:Inherit( self, STAGE:New() )
self:T() self:F()
self.StageType = 'AI' self.StageType = 'AI'
return self return self
end end
@@ -707,7 +707,7 @@ end
--end --end
function STAGEGROUPSDESTROYED:Validate( Mission, Client, Task ) function STAGEGROUPSDESTROYED:Validate( Mission, Client, Task )
self:T() self:F()
if Task.MissionTask:IsGoalReached() then if Task.MissionTask:IsGoalReached() then
return 1 return 1
@@ -717,7 +717,7 @@ self:T()
end end
function STAGEGROUPSDESTROYED:Execute( Mission, Client, Task ) function STAGEGROUPSDESTROYED:Execute( Mission, Client, Task )
self:T() self:F()
self:T( { Task.ClassName, Task.Destroyed } ) self:T( { Task.ClassName, Task.Destroyed } )
--env.info( 'Event Table Task = ' .. tostring(Task) ) --env.info( 'Event Table Task = ' .. tostring(Task) )
+36 -39
View File
@@ -48,10 +48,9 @@ TASK = {
--- Instantiates a new TASK Base. Should never be used. Interface Class. --- Instantiates a new TASK Base. Should never be used. Interface Class.
-- @return TASK -- @return TASK
function TASK:New() function TASK:New()
trace.f(self.ClassName)
local self = BASE:Inherit( self, BASE:New() ) local self = BASE:Inherit( self, BASE:New() )
self:F()
-- assign Task default values during construction -- assign Task default values during construction
self.TaskBriefing = "Task: No Task." self.TaskBriefing = "Task: No Task."
self.Time = timer.getTime() self.Time = timer.getTime()
@@ -61,14 +60,14 @@ trace.f(self.ClassName)
end end
function TASK:SetStage( StageSequenceIncrement ) function TASK:SetStage( StageSequenceIncrement )
trace.f(self.ClassName, { StageSequenceIncrement } ) self:F( { StageSequenceIncrement } )
local Valid = false local Valid = false
if StageSequenceIncrement ~= 0 then if StageSequenceIncrement ~= 0 then
self.ActiveStage = self.ActiveStage + StageSequenceIncrement self.ActiveStage = self.ActiveStage + StageSequenceIncrement
if 1 <= self.ActiveStage and self.ActiveStage <= #self.Stages then if 1 <= self.ActiveStage and self.ActiveStage <= #self.Stages then
self.Stage = self.Stages[self.ActiveStage] self.Stage = self.Stages[self.ActiveStage]
trace.i( self.ClassName, { self.Stage.Name } ) self:T( { self.Stage.Name } )
self.Frequency = self.Stage.Frequency self.Frequency = self.Stage.Frequency
Valid = true Valid = true
else else
@@ -81,7 +80,7 @@ trace.f(self.ClassName, { StageSequenceIncrement } )
end end
function TASK:Init() function TASK:Init()
trace.f(self.ClassName) self:F()
self.ActiveStage = 0 self.ActiveStage = 0
self:SetStage(1) self:SetStage(1)
self.TaskDone = false self.TaskDone = false
@@ -92,7 +91,7 @@ end
--- Get progress of a TASK. --- Get progress of a TASK.
-- @return string GoalsText -- @return string GoalsText
function TASK:GetGoalProgress() function TASK:GetGoalProgress()
trace.f(self.ClassName) self:F()
local GoalsText = "" local GoalsText = ""
for GoalVerb, GoalVerbData in pairs( self.GoalTasks ) do for GoalVerb, GoalVerbData in pairs( self.GoalTasks ) do
@@ -116,7 +115,7 @@ end
-- @param MISSION Mission Group structure describing the Mission. -- @param MISSION Mission Group structure describing the Mission.
-- @param CLIENT Client Group structure describing the Client. -- @param CLIENT Client Group structure describing the Client.
function TASK:ShowGoalProgress( Mission, Client ) function TASK:ShowGoalProgress( Mission, Client )
trace.f(self.ClassName) self:F()
local GoalsText = "" local GoalsText = ""
for GoalVerb, GoalVerbData in pairs( self.GoalTasks ) do for GoalVerb, GoalVerbData in pairs( self.GoalTasks ) do
@@ -138,32 +137,32 @@ end
--- Sets a TASK to status Done. --- Sets a TASK to status Done.
function TASK:Done() function TASK:Done()
trace.f(self.ClassName) self:F()
self.TaskDone = true self.TaskDone = true
end end
--- Returns if a TASK is done. --- Returns if a TASK is done.
-- @return bool -- @return bool
function TASK:IsDone() function TASK:IsDone()
trace.i( self.ClassName, self.TaskDone ) self:F( self.TaskDone )
return self.TaskDone return self.TaskDone
end end
--- Sets a TASK to status failed. --- Sets a TASK to status failed.
function TASK:Failed() function TASK:Failed()
trace.f(self.ClassName) self:F()
self.TaskFailed = true self.TaskFailed = true
end end
--- Returns if a TASk has failed. --- Returns if a TASk has failed.
-- @return bool -- @return bool
function TASK:IsFailed() function TASK:IsFailed()
trace.i( self.ClassName, self.TaskFailed ) self:F( self.TaskFailed )
return self.TaskFailed return self.TaskFailed
end end
function TASK:Reset( Mission, Client ) function TASK:Reset( Mission, Client )
trace.f(self.ClassName) self:F()
self.ExecuteStage = _TransportExecuteStage.NONE self.ExecuteStage = _TransportExecuteStage.NONE
end end
@@ -177,7 +176,7 @@ end
-- @param ?string GoalVerb is the name of the Goal of the TASK. -- @param ?string GoalVerb is the name of the Goal of the TASK.
-- @return bool -- @return bool
function TASK:Goal( GoalVerb ) function TASK:Goal( GoalVerb )
trace.f(self.ClassName) self:F()
if not GoalVerb then if not GoalVerb then
GoalVerb = self.GoalVerb GoalVerb = self.GoalVerb
end end
@@ -192,7 +191,7 @@ end
-- @param number GoalTotal is the number of times the GoalVerb needs to be achieved. -- @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. -- @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 ) function TASK:SetGoalTotal( GoalTotal, GoalVerb )
trace.f(self.ClassName, { GoalTotal, GoalVerb } ) self:F( { GoalTotal, GoalVerb } )
if not GoalVerb then if not GoalVerb then
GoalVerb = self.GoalVerb GoalVerb = self.GoalVerb
@@ -207,7 +206,7 @@ end
--- Gets the total of Goals to be achieved within the TASK of the GoalVerb. --- 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. -- @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 ) function TASK:GetGoalTotal( GoalVerb )
trace.f(self.ClassName) self:F()
if not GoalVerb then if not GoalVerb then
GoalVerb = self.GoalVerb GoalVerb = self.GoalVerb
end 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. -- @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 -- @return TASK
function TASK:SetGoalCount( GoalCount, GoalVerb ) function TASK:SetGoalCount( GoalCount, GoalVerb )
trace.f(self.ClassName) self:F()
if not GoalVerb then if not GoalVerb then
GoalVerb = self.GoalVerb GoalVerb = self.GoalVerb
end 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. -- @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 -- @return TASK
function TASK:IncreaseGoalCount( GoalCountIncrease, GoalVerb ) function TASK:IncreaseGoalCount( GoalCountIncrease, GoalVerb )
trace.f(self.ClassName) self:F()
if not GoalVerb then if not GoalVerb then
GoalVerb = self.GoalVerb GoalVerb = self.GoalVerb
end 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. -- @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 -- @return TASK
function TASK:GetGoalCount( GoalVerb ) function TASK:GetGoalCount( GoalVerb )
trace.f(self.ClassName) self:F()
if not GoalVerb then if not GoalVerb then
GoalVerb = self.GoalVerb GoalVerb = self.GoalVerb
end 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. -- @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 -- @return TASK
function TASK:GetGoalPercentage( GoalVerb ) function TASK:GetGoalPercentage( GoalVerb )
trace.f(self.ClassName) self:F()
if not GoalVerb then if not GoalVerb then
GoalVerb = self.GoalVerb GoalVerb = self.GoalVerb
end end
@@ -285,10 +284,10 @@ function TASK:IsGoalReached( )
local GoalReached = true local GoalReached = true
for GoalVerb, Goals in pairs( self.GoalTasks ) do for GoalVerb, Goals in pairs( self.GoalTasks ) do
trace.i( self.ClassName, { "GoalVerb", GoalVerb } ) self:T( { "GoalVerb", GoalVerb } )
if self:Goal( GoalVerb ) then if self:Goal( GoalVerb ) then
local GoalToDo = self:GetGoalTotal( GoalVerb ) - self:GetGoalCount( GoalVerb ) local GoalToDo = self:GetGoalTotal( GoalVerb ) - self:GetGoalCount( GoalVerb )
trace.i( self.ClassName, "GoalToDo = " .. GoalToDo ) self:T( "GoalToDo = " .. GoalToDo )
if GoalToDo <= 0 then if GoalToDo <= 0 then
else else
GoalReached = false GoalReached = false
@@ -299,7 +298,7 @@ function TASK:IsGoalReached( )
end end
end end
trace.i( self.ClassName, GoalReached ) self:T( GoalReached )
return GoalReached return GoalReached
end end
@@ -308,7 +307,7 @@ end
-- @param string GoalTask is a text describing the Goal of the TASK to be achieved. -- @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. -- @param number GoalIncrease is a number by which the Goal achievement is increasing.
function TASK:AddGoalCompletion( GoalVerb, GoalTask, GoalIncrease ) function TASK:AddGoalCompletion( GoalVerb, GoalTask, GoalIncrease )
trace.f( self.ClassName, { GoalVerb, GoalTask, GoalIncrease } ) self:F( { GoalVerb, GoalTask, GoalIncrease } )
if self:Goal( GoalVerb ) then if self:Goal( GoalVerb ) then
self.GoalTasks[GoalVerb].Goals[#self.GoalTasks[GoalVerb].Goals+1] = GoalTask 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. -- @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 -- @return string Goals
function TASK:GetGoalCompletion( GoalVerb ) function TASK:GetGoalCompletion( GoalVerb )
trace.f( self.ClassName, { GoalVerb } ) self:F( { GoalVerb } )
if self:Goal( GoalVerb ) then if self:Goal( GoalVerb ) then
local Goals = "" local Goals = ""
@@ -331,14 +330,12 @@ trace.f( self.ClassName, { GoalVerb } )
end end
function TASK.MenuAction( Parameter ) function TASK.MenuAction( Parameter )
trace.menu("TASK","MenuAction")
trace.l( "TASK", "MenuAction" )
Parameter.ReferenceTask.ExecuteStage = _TransportExecuteStage.EXECUTING Parameter.ReferenceTask.ExecuteStage = _TransportExecuteStage.EXECUTING
Parameter.ReferenceTask.Cargo = Parameter.CargoTask Parameter.ReferenceTask.Cargo = Parameter.CargoTask
end end
function TASK:StageExecute() function TASK:StageExecute()
trace.f(self.ClassName) self:F()
local Execute = false local Execute = false
@@ -357,7 +354,7 @@ end
--- Work function to set signal events within a TASK. --- Work function to set signal events within a TASK.
function TASK:AddSignal( SignalUnitNames, SignalType, SignalColor, SignalHeight ) function TASK:AddSignal( SignalUnitNames, SignalType, SignalColor, SignalHeight )
trace.f(self.ClassName) self:F()
local Valid = true 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 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... -- @param number SignalHeight Altitude that the Signal should be fired...
function TASK:AddSmokeRed( SignalUnitNames, SignalHeight ) function TASK:AddSmokeRed( SignalUnitNames, SignalHeight )
trace.f(self.ClassName) self:F()
self:AddSignal( SignalUnitNames, TASK.SIGNAL.TYPE.SMOKE, TASK.SIGNAL.COLOR.RED, SignalHeight ) self:AddSignal( SignalUnitNames, TASK.SIGNAL.TYPE.SMOKE, TASK.SIGNAL.COLOR.RED, SignalHeight )
end 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 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... -- @param number SignalHeight Altitude that the Signal should be fired...
function TASK:AddSmokeGreen( SignalUnitNames, SignalHeight ) function TASK:AddSmokeGreen( SignalUnitNames, SignalHeight )
trace.f(self.ClassName) self:F()
self:AddSignal( SignalUnitNames, TASK.SIGNAL.TYPE.SMOKE, TASK.SIGNAL.COLOR.GREEN, SignalHeight ) self:AddSignal( SignalUnitNames, TASK.SIGNAL.TYPE.SMOKE, TASK.SIGNAL.COLOR.GREEN, SignalHeight )
end 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 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... -- @param number SignalHeight Altitude that the Signal should be fired...
function TASK:AddSmokeBlue( SignalUnitNames, SignalHeight ) function TASK:AddSmokeBlue( SignalUnitNames, SignalHeight )
trace.f(self.ClassName) self:F()
self:AddSignal( SignalUnitNames, TASK.SIGNAL.TYPE.SMOKE, TASK.SIGNAL.COLOR.BLUE, SignalHeight ) self:AddSignal( SignalUnitNames, TASK.SIGNAL.TYPE.SMOKE, TASK.SIGNAL.COLOR.BLUE, SignalHeight )
end 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 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... -- @param number SignalHeight Altitude that the Signal should be fired...
function TASK:AddSmokeWhite( SignalUnitNames, SignalHeight ) function TASK:AddSmokeWhite( SignalUnitNames, SignalHeight )
trace.f(self.ClassName) self:F()
self:AddSignal( SignalUnitNames, TASK.SIGNAL.TYPE.SMOKE, TASK.SIGNAL.COLOR.WHITE, SignalHeight ) self:AddSignal( SignalUnitNames, TASK.SIGNAL.TYPE.SMOKE, TASK.SIGNAL.COLOR.WHITE, SignalHeight )
end 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 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... -- @param number SignalHeight Altitude that the Signal should be fired...
function TASK:AddSmokeOrange( SignalUnitNames, SignalHeight ) function TASK:AddSmokeOrange( SignalUnitNames, SignalHeight )
trace.f(self.ClassName) self:F()
self:AddSignal( SignalUnitNames, TASK.SIGNAL.TYPE.SMOKE, TASK.SIGNAL.COLOR.ORANGE, SignalHeight ) self:AddSignal( SignalUnitNames, TASK.SIGNAL.TYPE.SMOKE, TASK.SIGNAL.COLOR.ORANGE, SignalHeight )
end 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 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... -- @param number SignalHeight Altitude that the Signal should be fired...
function TASK:AddFlareRed( SignalUnitNames, SignalHeight ) function TASK:AddFlareRed( SignalUnitNames, SignalHeight )
trace.f(self.ClassName) self:F()
self:AddSignal( SignalUnitNames, TASK.SIGNAL.TYPE.FLARE, TASK.SIGNAL.COLOR.RED, SignalHeight ) self:AddSignal( SignalUnitNames, TASK.SIGNAL.TYPE.FLARE, TASK.SIGNAL.COLOR.RED, SignalHeight )
end 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 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... -- @param number SignalHeight Altitude that the Signal should be fired...
function TASK:AddFlareGreen( SignalUnitNames, SignalHeight ) function TASK:AddFlareGreen( SignalUnitNames, SignalHeight )
trace.f(self.ClassName) self:F()
self:AddSignal( SignalUnitNames, TASK.SIGNAL.TYPE.FLARE, TASK.SIGNAL.COLOR.GREEN, SignalHeight ) self:AddSignal( SignalUnitNames, TASK.SIGNAL.TYPE.FLARE, TASK.SIGNAL.COLOR.GREEN, SignalHeight )
end 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 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... -- @param number SignalHeight Altitude that the Signal should be fired...
function TASK:AddFlareBlue( SignalUnitNames, SignalHeight ) function TASK:AddFlareBlue( SignalUnitNames, SignalHeight )
trace.f(self.ClassName) self:F()
self:AddSignal( SignalUnitNames, TASK.SIGNAL.TYPE.FLARE, TASK.SIGNAL.COLOR.BLUE, SignalHeight ) self:AddSignal( SignalUnitNames, TASK.SIGNAL.TYPE.FLARE, TASK.SIGNAL.COLOR.BLUE, SignalHeight )
end 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 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... -- @param number SignalHeight Altitude that the Signal should be fired...
function TASK:AddFlareWhite( SignalUnitNames, SignalHeight ) function TASK:AddFlareWhite( SignalUnitNames, SignalHeight )
trace.f(self.ClassName) self:F()
self:AddSignal( SignalUnitNames, TASK.SIGNAL.TYPE.FLARE, TASK.SIGNAL.COLOR.WHITE, SignalHeight ) self:AddSignal( SignalUnitNames, TASK.SIGNAL.TYPE.FLARE, TASK.SIGNAL.COLOR.WHITE, SignalHeight )
end 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 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... -- @param number SignalHeight Altitude that the Signal should be fired...
function TASK:AddFlareOrange( SignalUnitNames, SignalHeight ) function TASK:AddFlareOrange( SignalUnitNames, SignalHeight )
trace.f(self.ClassName) self:F()
self:AddSignal( SignalUnitNames, TASK.SIGNAL.TYPE.FLARE, TASK.SIGNAL.COLOR.ORANGE, SignalHeight ) self:AddSignal( SignalUnitNames, TASK.SIGNAL.TYPE.FLARE, TASK.SIGNAL.COLOR.ORANGE, SignalHeight )
end end
+11 -11
View File
@@ -21,7 +21,7 @@ UNIT = {
function UNIT:New( DCSUnit ) function UNIT:New( DCSUnit )
local self = BASE:Inherit( self, BASE:New() ) local self = BASE:Inherit( self, BASE:New() )
self:T( DCSUnit:getName() ) self:F( DCSUnit:getName() )
self.DCSUnit = DCSUnit self.DCSUnit = DCSUnit
self.UnitName = DCSUnit:getName() self.UnitName = DCSUnit:getName()
@@ -31,39 +31,39 @@ function UNIT:New( DCSUnit )
end end
function UNIT:IsAlive() function UNIT:IsAlive()
self:T( self.UnitName ) self:F( self.UnitName )
return ( self.DCSUnit and self.DCSUnit:isExist() ) return ( self.DCSUnit and self.DCSUnit:isExist() )
end end
function UNIT:GetDCSUnit() function UNIT:GetDCSUnit()
self:T( self.DCSUnit ) self:F( self.DCSUnit )
return self.DCSUnit return self.DCSUnit
end end
function UNIT:GetID() function UNIT:GetID()
self:T( self.UnitID ) self:F( self.UnitID )
return self.UnitID return self.UnitID
end end
function UNIT:GetName() function UNIT:GetName()
self:T( self.UnitName ) self:F( self.UnitName )
return self.UnitName return self.UnitName
end end
function UNIT:GetTypeName() function UNIT:GetTypeName()
self:T( self.UnitName ) self:F( self.UnitName )
return self.DCSUnit:getTypeName() return self.DCSUnit:getTypeName()
end end
function UNIT:GetPrefix() function UNIT:GetPrefix()
self:T( self.UnitName ) self:F( self.UnitName )
local UnitPrefix = string.match( self.UnitName, ".*#" ):sub( 1, -2 ) local UnitPrefix = string.match( self.UnitName, ".*#" ):sub( 1, -2 )
self:T( UnitPrefix ) self:T( UnitPrefix )
@@ -73,14 +73,14 @@ end
function UNIT:GetCallSign() function UNIT:GetCallSign()
self:T( self.UnitName ) self:F( self.UnitName )
return self.DCSUnit:getCallsign() return self.DCSUnit:getCallsign()
end end
function UNIT:GetPointVec2() function UNIT:GetPointVec2()
self:T( self.UnitName ) self:F( self.UnitName )
local UnitPos = self.DCSUnit:getPosition().p local UnitPos = self.DCSUnit:getPosition().p
@@ -94,7 +94,7 @@ end
function UNIT:GetPositionVec3() function UNIT:GetPositionVec3()
self:T( self.UnitName ) self:F( self.UnitName )
local UnitPos = self.DCSUnit:getPosition().p local UnitPos = self.DCSUnit:getPosition().p
@@ -103,7 +103,7 @@ function UNIT:GetPositionVec3()
end end
function UNIT:OtherUnitInRadius( AwaitUnit, Radius ) function UNIT:OtherUnitInRadius( AwaitUnit, Radius )
self:T( { self.UnitName, AwaitUnit.UnitName, Radius } ) self:F( { self.UnitName, AwaitUnit.UnitName, Radius } )
local UnitPos = self:GetPositionVec3() local UnitPos = self:GetPositionVec3()
local AwaitUnitPos = AwaitUnit:GetPositionVec3() local AwaitUnitPos = AwaitUnit:GetPositionVec3()
+6 -8
View File
@@ -13,9 +13,8 @@ ZONE = {
} }
function ZONE:New( ZoneName ) function ZONE:New( ZoneName )
trace.f( self.ClassName, ZoneName )
local self = BASE:Inherit( self, BASE:New() ) local self = BASE:Inherit( self, BASE:New() )
self:F( ZoneName )
local Zone = trigger.misc.getZone( ZoneName ) local Zone = trigger.misc.getZone( ZoneName )
@@ -31,7 +30,7 @@ trace.f( self.ClassName, ZoneName )
end end
function ZONE:GetPointVec2() function ZONE:GetPointVec2()
self:T( self.ZoneName ) self:F( self.ZoneName )
local Zone = trigger.misc.getZone( self.ZoneName ) local Zone = trigger.misc.getZone( self.ZoneName )
local Point = { x = Zone.point.x, y = Zone.point.z } local Point = { x = Zone.point.x, y = Zone.point.z }
@@ -42,7 +41,7 @@ function ZONE:GetPointVec2()
end end
function ZONE:GetRandomPoint() function ZONE:GetRandomPoint()
trace.f( self.ClassName, self.ZoneName ) self:F( self.ZoneName )
local Point = {} 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.x = Zone.point.x + math.random( Zone.radius * -1, Zone.radius )
Point.y = Zone.point.z + math.random( Zone.radius * -1, Zone.radius ) Point.y = Zone.point.z + math.random( Zone.radius * -1, Zone.radius )
trace.i( self.ClassName, { Zone } ) self:T( { Zone, Point } )
trace.i( self.ClassName, { Point } )
return Point return Point
end end
function ZONE:GetRadius() function ZONE:GetRadius()
trace.f( self.ClassName, self.ZoneName ) self:F( self.ZoneName )
local Zone = trigger.misc.getZone( self.ZoneName ) local Zone = trigger.misc.getZone( self.ZoneName )
trace.i( self.ClassName, { Zone } ) self:T( { Zone } )
return Zone.radius return Zone.radius
end end
View File