diff --git a/Moose Development/Moose/Core/Base.lua b/Moose Development/Moose/Core/Base.lua index e06eaf308..a40e4d729 100644 --- a/Moose Development/Moose/Core/Base.lua +++ b/Moose Development/Moose/Core/Base.lua @@ -4,10 +4,6 @@ -- -- === -- --- The @{#BASE} class is the core root class from where every other class in moose is derived. --- --- === --- -- ### Author: **Sven Van de Velde (FlightControl)** -- ### Contributions: -- diff --git a/Moose Development/Moose/Core/Database.lua b/Moose Development/Moose/Core/Database.lua index 788aa2c00..b4a9319b9 100644 --- a/Moose Development/Moose/Core/Database.lua +++ b/Moose Development/Moose/Core/Database.lua @@ -375,7 +375,12 @@ function DATABASE:Spawn( SpawnTemplate ) SpawnTemplate.CountryID = SpawnCountryID SpawnTemplate.CategoryID = SpawnCategoryID + -- Ensure that for the spawned group and its units, there are GROUP and UNIT objects created in the DATABASE. local SpawnGroup = self:AddGroup( SpawnTemplate.name ) + for UnitID, UnitData in pairs( SpawnTemplate.units ) do + self:AddUnit( UnitData.name ) + end + return SpawnGroup end diff --git a/Moose Development/Moose/Core/Point.lua b/Moose Development/Moose/Core/Point.lua index b3796752d..bb36cabe8 100644 --- a/Moose Development/Moose/Core/Point.lua +++ b/Moose Development/Moose/Core/Point.lua @@ -279,6 +279,14 @@ do -- COORDINATE return RandomVec3 end + + --- Return the height of the land at the coordinate. + -- @param #COORDINATE self + -- @return #number + function COORDINATE:GetLandHeight() + local Vec2 = { x = self.x, y = self.z } + return land.getHeight( Vec2 ) + end function COORDINATE:SetHeading( Heading ) diff --git a/Moose Development/Moose/Functional/CleanUp.lua b/Moose Development/Moose/Functional/CleanUp.lua index 79aa2dc6b..7b3a91c00 100644 --- a/Moose Development/Moose/Functional/CleanUp.lua +++ b/Moose Development/Moose/Functional/CleanUp.lua @@ -1,56 +1,99 @@ --- **Functional** -- The CLEANUP class keeps an area clean of crashing or colliding airplanes. It also prevents airplanes from firing within this area. -- +-- ![Banner Image](..\Presentations\CLEANUP\Dia1.JPG) +-- +-- === +-- +-- ### Author: **Sven Van de Velde (FlightControl)** +-- ### Contributions: +-- -- ==== +-- -- @module CleanUp - - - - - ---- The CLEANUP class. --- @type CLEANUP +--- @type CLEANUP -- @extends Core.Base#BASE +-- @field #map<#string,Wrapper.Airbase#AIRBASE> Airbases Map of Airbases. + +--- # CLEANUP, extends @{Base#BASE} +-- +-- The CLEANUP class keeps airbases clean, and tries to guarantee continuous airbase operations, even under combat. +-- +-- @field #CLEANUP CLEANUP = { ClassName = "CLEANUP", - ZoneNames = {}, - TimeInterval = 300, + TimeInterval = 0.2, CleanUpList = {}, + Airbases = {}, } --- Creates the main object which is handling the cleaning of the debris within the given Zone Names. -- @param #CLEANUP self --- @param #table ZoneNames Is a table of zone names where the debris should be cleaned. Also a single string can be passed with one zone name. --- @param #number TimeInterval The interval in seconds when the clean activity takes place. The default is 300 seconds, thus every 5 minutes. +-- @param #list<#string> AirbaseNames Is a table of airbase names where the debris should be cleaned. Also a single string can be passed with one airbase name. -- @return #CLEANUP -- @usage -- -- Clean these Zones. --- CleanUpAirports = CLEANUP:New( { 'CLEAN Tbilisi', 'CLEAN Kutaisi' }, 150 ) +-- CleanUpAirports = CLEANUP:New( { AIRBASE.Caucasus.Tbilisi, AIRBASE.Caucasus.Kutaisi ) -- or --- CleanUpTbilisi = CLEANUP:New( 'CLEAN Tbilisi', 150 ) --- CleanUpKutaisi = CLEANUP:New( 'CLEAN Kutaisi', 600 ) -function CLEANUP:New( ZoneNames, TimeInterval ) +-- CleanUpTbilisi = CLEANUP:New( AIRBASE.Caucasus.Tbilisi ) +-- CleanUpKutaisi = CLEANUP:New( AIRBASE.Caucasus.Kutaisi ) +function CLEANUP:New( AirbaseNames ) local self = BASE:Inherit( self, BASE:New() ) -- #CLEANUP - self:F( { ZoneNames, TimeInterval } ) + self:F( { AirbaseNames } ) - if type( ZoneNames ) == 'table' then - self.ZoneNames = ZoneNames + if type( AirbaseNames ) == 'table' then + for AirbaseID, AirbaseName in pairs( AirbaseNames ) do + self:AddAirbase( AirbaseName ) + end else - self.ZoneNames = { ZoneNames } - end - if TimeInterval then - self.TimeInterval = TimeInterval + local AirbaseName = AirbaseNames + self:AddAirbase( AirbaseName ) end self:HandleEvent( EVENTS.Birth ) - self.CleanUpScheduler = SCHEDULER:New( self, self._CleanUpScheduler, {}, 1, TimeInterval ) + self.CleanUpScheduler = SCHEDULER:New( self, self._CleanUpScheduler, {}, 1, self.TimeInterval ) return self end +--- Adds an airbase to the airbase validation list. +-- @param #CLEANUP self +-- @param #string AirbaseName +-- @return #CLEANUP +function CLEANUP:AddAirbase( AirbaseName ) + self.Airbases[AirbaseName] = AIRBASE:FindByName( AirbaseName ) + self:F({"Airbase:", AirbaseName, self.Airbases[AirbaseName]:GetDesc()}) + + return self +end + +--- Removes an airbase from the airbase validation list. +-- @param #CLEANUP self +-- @param #string AirbaseName +-- @return #CLEANUP +function CLEANUP:RemoveAirbase( AirbaseName ) + self.Airbases[AirbaseName] = nil + return self +end + + + +function CLEANUP:IsInAirbase( Vec2 ) + + local InAirbase = false + for AirbaseName, Airbase in pairs( self.Airbases ) do + local Airbase = Airbase -- Wrapper.Airbase#AIRBASE + if Airbase:GetZone():IsVec2InZone( Vec2 ) then + InAirbase = true + break; + end + end + + return InAirbase +end --- Destroys a group from the simulator, but checks first if it is still existing! -- @param #CLEANUP self @@ -65,29 +108,25 @@ function CLEANUP:_DestroyGroup( GroupObject, CleanUpGroupName ) end end ---- Destroys a @{DCSWrapper.Unit#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! -- @param #CLEANUP self --- @param Dcs.DCSWrapper.Unit#Unit CleanUpUnit The object to be destroyed. --- @param #string CleanUpUnitName The Unit name ... -function CLEANUP:_DestroyUnit( CleanUpUnit, CleanUpUnitName ) - self:F( { CleanUpUnit, CleanUpUnitName } ) +-- @param Wrapper.Unit#UNIT CleanUpUnit The object to be destroyed. +function CLEANUP:_DestroyUnit( CleanUpUnit ) + self:F( { CleanUpUnit } ) if CleanUpUnit then - local CleanUpGroup = Unit.getGroup(CleanUpUnit) + local CleanUpUnitName = CleanUpUnit:GetName() + local CleanUpGroup = CleanUpUnit:GetGroup() -- TODO Client bug in 1.5.3 - if CleanUpGroup and CleanUpGroup:isExist() then - local CleanUpGroupUnits = CleanUpGroup:getUnits() + if CleanUpGroup:IsAlive() then + local CleanUpGroupUnits = CleanUpGroup:GetUnits() if #CleanUpGroupUnits == 1 then - local CleanUpGroupName = CleanUpGroup:getName() - --self:CreateEventCrash( timer.getTime(), CleanUpUnit ) - CleanUpGroup:destroy() - self:T( { "Destroyed Group:", CleanUpGroupName } ) + local CleanUpGroupName = CleanUpGroup:GetName() + CleanUpGroup:Destroy() else - CleanUpUnit:destroy() - self:T( { "Destroyed Unit:", CleanUpUnitName } ) + CleanUpUnit:Destroy() end - self.CleanUpList[CleanUpUnitName] = nil -- Cleaning from the list - CleanUpUnit = nil + self.CleanUpList[CleanUpUnitName] = nil end end end @@ -107,7 +146,7 @@ end --- @param #CLEANUP self -- @param Core.Event#EVENTDATA EventData -function CLEANUP:_OnEventBirth( EventData ) +function CLEANUP:OnEventBirth( EventData ) self:F( { EventData } ) self.CleanUpList[EventData.IniDCSUnitName] = {} @@ -116,13 +155,13 @@ function CLEANUP:_OnEventBirth( EventData ) self.CleanUpList[EventData.IniDCSUnitName].CleanUpGroupName = EventData.IniDCSGroupName self.CleanUpList[EventData.IniDCSUnitName].CleanUpUnitName = EventData.IniDCSUnitName - EventData.IniUnit:HandleEvent( EVENTS.EngineShutdown , self._EventAddForCleanUp ) - EventData.IniUnit:HandleEvent( EVENTS.EngineStartup, self._EventAddForCleanUp ) - EventData.IniUnit:HandleEvent( EVENTS.Hit, self._EventAddForCleanUp ) - EventData.IniUnit:HandleEvent( EVENTS.PilotDead, self._EventCrash ) - EventData.IniUnit:HandleEvent( EVENTS.Dead, self._EventCrash ) - EventData.IniUnit:HandleEvent( EVENTS.Crash, self._EventCrash ) - EventData.IniUnit:HandleEvent( EVENTS.Shot, self._EventShot ) + self:HandleEvent( EVENTS.EngineShutdown , self._EventAddForCleanUp ) + self:HandleEvent( EVENTS.EngineStartup, self._EventAddForCleanUp ) + self:HandleEvent( EVENTS.Hit, self._EventAddForCleanUp ) + self:HandleEvent( EVENTS.PilotDead, self.OnEventCrash ) + self:HandleEvent( EVENTS.Dead, self.OnEventCrash ) + self:HandleEvent( EVENTS.Crash, self.OnEventCrash ) + self:HandleEvent( EVENTS.Shot, self.OnEventShot ) end @@ -130,7 +169,7 @@ end -- Crashed units go into a CleanUpList for removal. -- @param #CLEANUP self -- @param Dcs.DCSTypes#Event event -function CLEANUP:_EventCrash( Event ) +function CLEANUP:OnEventCrash( Event ) self:F( { Event } ) --TODO: This stuff is not working due to a DCS bug. Burning units cannot be destroyed. @@ -141,54 +180,53 @@ function CLEANUP:_EventCrash( Event ) -- self:T("after deactivateGroup") -- event.initiator:destroy() - self.CleanUpList[Event.IniDCSUnitName] = {} - self.CleanUpList[Event.IniDCSUnitName].CleanUpUnit = Event.IniDCSUnit - self.CleanUpList[Event.IniDCSUnitName].CleanUpGroup = Event.IniDCSGroup - self.CleanUpList[Event.IniDCSUnitName].CleanUpGroupName = Event.IniDCSGroupName - self.CleanUpList[Event.IniDCSUnitName].CleanUpUnitName = Event.IniDCSUnitName + if Event.IniDCSUnitName then + self.CleanUpList[Event.IniDCSUnitName] = {} + self.CleanUpList[Event.IniDCSUnitName].CleanUpUnit = Event.IniDCSUnit + self.CleanUpList[Event.IniDCSUnitName].CleanUpGroup = Event.IniDCSGroup + self.CleanUpList[Event.IniDCSUnitName].CleanUpGroupName = Event.IniDCSGroupName + self.CleanUpList[Event.IniDCSUnitName].CleanUpUnitName = Event.IniDCSUnitName + end end --- Detects if a unit shoots a missile. --- If this occurs within one of the zones, then the weapon used must be destroyed. +-- If this occurs within one of the airbases, then the weapon used must be destroyed. -- @param #CLEANUP self --- @param Dcs.DCSTypes#Event event -function CLEANUP:_EventShot( Event ) +-- @param Core.Event#EVENTDATA Event +function CLEANUP:OnEventShot( Event ) self:F( { Event } ) - -- Test if the missile was fired within one of the CLEANUP.ZoneNames. - local CurrentLandingZoneID = 0 - CurrentLandingZoneID = routines.IsUnitInZones( Event.IniDCSUnit, self.ZoneNames ) - if ( CurrentLandingZoneID ) then - -- Okay, the missile was fired within the CLEANUP.ZoneNames, destroy the fired weapon. - --_SEADmissile:destroy() - SCHEDULER:New( self, CLEANUP._DestroyMissile, { Event.Weapon }, 0.1 ) + -- Test if the missile was fired within one of the CLEANUP.AirbaseNames. + if self:IsInAirbase( Event.IniUnit:GetVec2() ) then + -- Okay, the missile was fired within the CLEANUP.AirbaseNames, destroy the fired weapon. + self:_DestroyMissile( Event.Weapon ) end 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 AirbaseNames. If this is the case, destroy the unit. -- @param #CLEANUP self --- @param Dcs.DCSTypes#Event event -function CLEANUP:_EventHitCleanUp( Event ) +-- @param Core.Event#EVENTDATA Event +function CLEANUP:OnEventHit( Event ) self:F( { Event } ) - if Event.IniDCSUnit then - if routines.IsUnitInZones( Event.IniDCSUnit, self.ZoneNames ) ~= nil then + if Event.IniUnit then + if self:IsInAirbase( Event.IniUnit:GetVec2() ) then self:T( { "Life: ", Event.IniDCSUnitName, ' = ', Event.IniDCSUnit:getLife(), "/", Event.IniDCSUnit:getLife0() } ) if Event.IniDCSUnit:getLife() < Event.IniDCSUnit:getLife0() then self:T( "CleanUp: Destroy: " .. Event.IniDCSUnitName ) - SCHEDULER:New( self, CLEANUP._DestroyUnit, { Event.IniDCSUnit }, 0.1 ) + CLEANUP:_DestroyUnit( Event.IniUnit ) end end end - if Event.TgtDCSUnit then - if routines.IsUnitInZones( Event.TgtDCSUnit, self.ZoneNames ) ~= nil then + if Event.TgtUnit then + if self:IsInAirbase( Event.TgtUnit:GetVec2() ) then self:T( { "Life: ", Event.TgtDCSUnitName, ' = ', Event.TgtDCSUnit:getLife(), "/", Event.TgtDCSUnit:getLife0() } ) if Event.TgtDCSUnit:getLife() < Event.TgtDCSUnit:getLife0() then self:T( "CleanUp: Destroy: " .. Event.TgtDCSUnitName ) - SCHEDULER:New( self, CLEANUP._DestroyUnit, { Event.TgtDCSUnit }, 0.1 ) + CLEANUP:_DestroyUnit( Event.TgtUnit ) end end end @@ -210,14 +248,16 @@ function CLEANUP:_AddForCleanUp( CleanUpUnit, CleanUpUnitName ) end ---- Detects if the Unit has an S_EVENT_ENGINE_SHUTDOWN or an S_EVENT_HIT within the given ZoneNames. If this is the case, add the Group to the CLEANUP List. +--- Detects if the Unit has an S_EVENT_ENGINE_SHUTDOWN or an S_EVENT_HIT within the given AirbaseNames. If this is the case, add the Group to the CLEANUP List. -- @param #CLEANUP self --- @param Dcs.DCSTypes#Event event +-- @param Core.Event#EVENTDATA Event function CLEANUP:_EventAddForCleanUp( Event ) + self:F({Event}) + if Event.IniDCSUnit then if self.CleanUpList[Event.IniDCSUnitName] == nil then - if routines.IsUnitInZones( Event.IniDCSUnit, self.ZoneNames ) ~= nil then + if self:IsInAirbase( Event.IniUnit:GetVec2() ) then self:_AddForCleanUp( Event.IniDCSUnit, Event.IniDCSUnitName ) end end @@ -225,7 +265,7 @@ function CLEANUP:_EventAddForCleanUp( Event ) if Event.TgtDCSUnit then if self.CleanUpList[Event.TgtDCSUnitName] == nil then - if routines.IsUnitInZones( Event.TgtDCSUnit, self.ZoneNames ) ~= nil then + if self:IsInAirbase( Event.TgtUnit:GetVec2() ) then self:_AddForCleanUp( Event.TgtDCSUnit, Event.TgtDCSUnitName ) end end @@ -233,64 +273,50 @@ function CLEANUP:_EventAddForCleanUp( Event ) end -local CleanUpSurfaceTypeText = { - "LAND", - "SHALLOW_WATER", - "WATER", - "ROAD", - "RUNWAY" - } --- At the defined time interval, CleanUp the Groups within the CleanUpList. -- @param #CLEANUP self function CLEANUP:_CleanUpScheduler() - self:F( { "CleanUp Scheduler" } ) local CleanUpCount = 0 for CleanUpUnitName, UnitData in pairs( self.CleanUpList ) do CleanUpCount = CleanUpCount + 1 - self:T( { CleanUpUnitName, UnitData } ) - local CleanUpUnit = Unit.getByName(UnitData.CleanUpUnitName) + local CleanUpUnit = UNIT:FindByName( CleanUpUnitName ) + local CleanUpDCSUnit = Unit.getByName( CleanUpUnitName ) local CleanUpGroupName = UnitData.CleanUpGroupName - local CleanUpUnitName = UnitData.CleanUpUnitName + if CleanUpUnit then - self:T( { "CleanUp Scheduler", "Checking:", CleanUpUnitName } ) + if _DATABASE:GetStatusGroup( CleanUpGroupName ) ~= "ReSpawn" then - local CleanUpUnitVec3 = CleanUpUnit:getPoint() - --self:T( CleanUpUnitVec3 ) - local CleanUpUnitVec2 = {} - CleanUpUnitVec2.x = CleanUpUnitVec3.x - CleanUpUnitVec2.y = CleanUpUnitVec3.z - --self:T( CleanUpUnitVec2 ) - local CleanUpSurfaceType = land.getSurfaceType(CleanUpUnitVec2) - --self:T( CleanUpSurfaceType ) - - if CleanUpUnit and CleanUpUnit:getLife() <= CleanUpUnit:getLife0() * 0.95 then - if CleanUpSurfaceType == land.SurfaceType.RUNWAY then - if CleanUpUnit:inAir() then - local CleanUpLandHeight = land.getHeight(CleanUpUnitVec2) - local CleanUpUnitHeight = CleanUpUnitVec3.y - CleanUpLandHeight - self:T( { "CleanUp Scheduler", "Height = " .. CleanUpUnitHeight } ) + + local CleanUpCoordinate = CleanUpUnit:GetCoordinate() + + if CleanUpDCSUnit and CleanUpDCSUnit:getLife() <= CleanUpDCSUnit:getLife0() * 0.95 then + if CleanUpUnit:IsAboveRunway() then + if CleanUpUnit:InAir() then + + local CleanUpLandHeight = CleanUpCoordinate:GetLandHeight() + local CleanUpUnitHeight = CleanUpCoordinate.y - CleanUpLandHeight + if CleanUpUnitHeight < 30 then self:T( { "CleanUp Scheduler", "Destroy " .. CleanUpUnitName .. " because below safe height and damaged." } ) - self:_DestroyUnit(CleanUpUnit, CleanUpUnitName) + self:_DestroyUnit( CleanUpUnit ) end else self:T( { "CleanUp Scheduler", "Destroy " .. CleanUpUnitName .. " because on runway and damaged." } ) - self:_DestroyUnit(CleanUpUnit, CleanUpUnitName) + self:_DestroyUnit(CleanUpUnit ) end end end -- Clean Units which are waiting for a very long time in the CleanUpZone. if CleanUpUnit then - local CleanUpUnitVelocity = CleanUpUnit:getVelocity() - local CleanUpUnitVelocityTotal = math.abs(CleanUpUnitVelocity.x) + math.abs(CleanUpUnitVelocity.y) + math.abs(CleanUpUnitVelocity.z) - if CleanUpUnitVelocityTotal < 1 then + local CleanUpUnitVelocity = CleanUpUnit:GetVelocityKMH() + if CleanUpUnitVelocity < 1 then if UnitData.CleanUpMoved then if UnitData.CleanUpTime + 180 <= timer.getTime() then self:T( { "CleanUp Scheduler", "Destroy due to not moving anymore " .. CleanUpUnitName } ) - self:_DestroyUnit(CleanUpUnit, CleanUpUnitName) + self:_DestroyUnit( CleanUpUnit ) end end else @@ -301,11 +327,11 @@ function CLEANUP:_CleanUpScheduler() else -- Do nothing ... - self.CleanUpList[CleanUpUnitName] = nil -- Not anymore in the DCSRTE + self.CleanUpList[CleanUpUnitName] = nil end else self:T( "CleanUp: Group " .. CleanUpUnitName .. " cannot be found in DCS RTE, removing ..." ) - self.CleanUpList[CleanUpUnitName] = nil -- Not anymore in the DCSRTE + self.CleanUpList[CleanUpUnitName] = nil end end self:T(CleanUpCount) diff --git a/Moose Development/Moose/Wrapper/Airbase.lua b/Moose Development/Moose/Wrapper/Airbase.lua index 58b0010b3..fab9998b3 100644 --- a/Moose Development/Moose/Wrapper/Airbase.lua +++ b/Moose Development/Moose/Wrapper/Airbase.lua @@ -149,6 +149,7 @@ function AIRBASE:Register( AirbaseName ) local self = BASE:Inherit( self, POSITIONABLE:New( AirbaseName ) ) self.AirbaseName = AirbaseName + self.AirbaseZone = ZONE_RADIUS:New( AirbaseName, self:GetVec2(), 8000 ) return self end @@ -185,5 +186,12 @@ function AIRBASE:GetDCSObject() return nil end +--- Get the airbase zone. +-- @param #AIRBASE self +-- @return Core.Zone#ZONE_RADIUS The zone radius of the airbase. +function AIRBASE:GetZone() + return self.AirbaseZone +end + diff --git a/docs/Documentation/AI_Patrol.html b/docs/Documentation/AI_Patrol.html index 43392b308..93a9f8ce6 100644 --- a/docs/Documentation/AI_Patrol.html +++ b/docs/Documentation/AI_Patrol.html @@ -926,9 +926,6 @@ Use the method AIPATROLZONE.M - -

This table contains the targets detected during patrol.

-
diff --git a/docs/Documentation/Airbase.html b/docs/Documentation/Airbase.html index 47a104aa6..d176bb9fc 100644 --- a/docs/Documentation/Airbase.html +++ b/docs/Documentation/Airbase.html @@ -157,6 +157,12 @@ AIRBASE:GetDCSObject() + + + + AIRBASE:GetZone() + +

Get the airbase zone.

@@ -317,6 +323,24 @@ self

+ +
+
+
+ + +AIRBASE:GetZone() + +
+
+ +

Get the airbase zone.

+ +

Return value

+ +

Core.Zone#ZONE_RADIUS: +The zone radius of the airbase.

+
diff --git a/docs/Documentation/Base.html b/docs/Documentation/Base.html index b3ba6c7bc..5d0f76673 100644 --- a/docs/Documentation/Base.html +++ b/docs/Documentation/Base.html @@ -114,10 +114,6 @@
-

The #BASE class is the core root class from where every other class in moose is derived.

- -
-

Author: Sven Van de Velde (FlightControl)

Contributions:

diff --git a/docs/Documentation/Cargo.html b/docs/Documentation/Cargo.html index d774a472f..0f74ec2a0 100644 --- a/docs/Documentation/Cargo.html +++ b/docs/Documentation/Cargo.html @@ -2934,6 +2934,7 @@ The range till cargo will board.

+ CARGO_UNIT.CargoCarrier @@ -3059,7 +3060,6 @@ The range till cargo will board.

- #number CARGO_UNIT.RunCount diff --git a/docs/Documentation/CleanUp.html b/docs/Documentation/CleanUp.html index 3433cec11..fe64315b1 100644 --- a/docs/Documentation/CleanUp.html +++ b/docs/Documentation/CleanUp.html @@ -110,13 +110,24 @@

It also prevents airplanes from firing within this area.

+

Banner Image

+
+

Author: Sven Van de Velde (FlightControl)

+

Contributions:

+ +
+ +

Global(s)

@@ -124,15 +135,15 @@

Type CLEANUP

CLEANUP +

CLEANUP, extends Base#BASE

+ +

The CLEANUP class keeps airbases clean, and tries to guarantee continuous airbase operations, even under combat.

- + - + @@ -142,21 +153,45 @@ - + + + + + - + - + + + + + + + + + + + + + @@ -184,39 +219,15 @@ - + - + - - - - - - - - - - - - - - - -
CLEANUP.ClassNameCLEANUP.< - +

string,Wrapper.Airbase#AIRBASE> Airbases Map of Airbases.

CLEANUP.CleanUpListCLEANUP:AddAirbase(AirbaseName) - +

Adds an airbase to the airbase validation list.

CLEANUP:New(ZoneNames, TimeInterval)CLEANUP:IsInAirbase(Vec2) + +
CLEANUP:New(<, AirbaseNames)

Creates the main object which is handling the cleaning of the debris within the given Zone Names.

CLEANUP.TimeIntervalCLEANUP:OnEventBirth(EventData)
CLEANUP.ZoneNamesCLEANUP:OnEventCrash(event, Event) - +

Detects if a crash event occurs.

+
CLEANUP:OnEventHit(Event) +

Detects if the Unit has an SEVENTHIT within the given AirbaseNames.

+
CLEANUP:OnEventShot(Event) +

Detects if a unit shoots a missile.

+
CLEANUP:RemoveAirbase(AirbaseName) +

Removes an airbase from the airbase validation list.

CLEANUP:_DestroyUnit(CleanUpUnit, CleanUpUnitName)CLEANUP:_DestroyUnit(CleanUpUnit) -

Destroys a DCSWrapper.Unit#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!

CLEANUP:_EventAddForCleanUp(event, Event)CLEANUP:_EventAddForCleanUp(Event) -

Detects if the Unit has an SEVENTENGINESHUTDOWN or an SEVENT_HIT within the given ZoneNames.

-
CLEANUP:_EventCrash(event, Event) -

Detects if a crash event occurs.

-
CLEANUP:_EventHitCleanUp(event, Event) -

Detects if the Unit has an SEVENTHIT within the given ZoneNames.

-
CLEANUP:_EventShot(event, Event) -

Detects if a unit shoots a missile.

-
CLEANUP:_OnEventBirth(EventData) - +

Detects if the Unit has an SEVENTENGINESHUTDOWN or an SEVENT_HIT within the given AirbaseNames.

@@ -232,6 +243,9 @@
+

CLEANUP, extends Base#BASE

+ +

The CLEANUP class keeps airbases clean, and tries to guarantee continuous airbase operations, even under combat.

@@ -239,34 +253,43 @@

Type CleanUp

Type CLEANUP

- -

The CLEANUP class.

- -

Field(s)

+

Field(s)

- #string - -CLEANUP.ClassName + #map + +CLEANUP.<
- +

string,Wrapper.Airbase#AIRBASE> Airbases Map of Airbases.

- - -CLEANUP.CleanUpList + +CLEANUP:AddAirbase(AirbaseName)
+

Adds an airbase to the airbase validation list.

+ +

Parameter

+
    +
  • + +

    #string AirbaseName :

    + +
  • +
+

Return value

+ +

#CLEANUP:

@@ -283,13 +306,34 @@ + +
+
+
+ + +CLEANUP:IsInAirbase(Vec2) + +
+
+ + + +

Parameter

+
    +
  • + +

    Vec2 :

    + +
  • +
-CLEANUP:New(ZoneNames, TimeInterval) +CLEANUP:New(<, AirbaseNames)
@@ -300,14 +344,13 @@
  • -

    #table ZoneNames : -Is a table of zone names where the debris should be cleaned. Also a single string can be passed with one zone name.

    +

    #list < : +string> AirbaseNames Is a table of airbase names where the debris should be cleaned. Also a single string can be passed with one airbase name.

  • -

    #number TimeInterval : -The interval in seconds when the clean activity takes place. The default is 300 seconds, thus every 5 minutes.

    +

    AirbaseNames :

@@ -318,37 +361,133 @@ The interval in seconds when the clean activity takes place. The default is 300

Usage:

 -- Clean these Zones.
-CleanUpAirports = CLEANUP:New( { 'CLEAN Tbilisi', 'CLEAN Kutaisi' }, 150 )
+CleanUpAirports = CLEANUP:New( { AIRBASE.Caucasus.Tbilisi, AIRBASE.Caucasus.Kutaisi )
 or
-CleanUpTbilisi = CLEANUP:New( 'CLEAN Tbilisi', 150 )
-CleanUpKutaisi = CLEANUP:New( 'CLEAN Kutaisi', 600 )
+CleanUpTbilisi = CLEANUP:New( AIRBASE.Caucasus.Tbilisi ) +CleanUpKutaisi = CLEANUP:New( AIRBASE.Caucasus.Kutaisi )
- - -CLEANUP.TimeInterval + +CLEANUP:OnEventBirth(EventData)
+

Parameter

+
- - -CLEANUP.ZoneNames + +CLEANUP:OnEventCrash(event, Event)
+

Detects if a crash event occurs.

+ + +

Crashed units go into a CleanUpList for removal.

+ +

Parameters

+ +
+
+
+
+ + +CLEANUP:OnEventHit(Event) + +
+
+ +

Detects if the Unit has an SEVENTHIT within the given AirbaseNames.

+ + +

If this is the case, destroy the unit.

+ +

Parameter

+ +
+
+
+
+ + +CLEANUP:OnEventShot(Event) + +
+
+ +

Detects if a unit shoots a missile.

+ + +

If this occurs within one of the airbases, then the weapon used must be destroyed.

+ +

Parameter

+ +
+
+
+
+ + +CLEANUP:RemoveAirbase(AirbaseName) + +
+
+ +

Removes an airbase from the airbase validation list.

+ +

Parameter

+
    +
  • + +

    #string AirbaseName :

    + +
  • +
+

Return value

+ +

#CLEANUP:

@@ -451,26 +590,20 @@ The groupname...

-CLEANUP:_DestroyUnit(CleanUpUnit, CleanUpUnitName) +CLEANUP:_DestroyUnit(CleanUpUnit)
-

Destroys a DCSWrapper.Unit#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!

-

Parameters

+

Parameter

@@ -479,140 +612,31 @@ The Unit name ...

-CLEANUP:_EventAddForCleanUp(event, Event) +CLEANUP:_EventAddForCleanUp(Event)
-

Detects if the Unit has an SEVENTENGINESHUTDOWN or an SEVENT_HIT within the given ZoneNames.

+

Detects if the Unit has an SEVENTENGINESHUTDOWN or an SEVENT_HIT within the given AirbaseNames.

If this is the case, add the Group to the CLEANUP List.

-

Parameters

- -
-
-
-
- - -CLEANUP:_EventCrash(event, Event) - -
-
- -

Detects if a crash event occurs.

- - -

Crashed units go into a CleanUpList for removal.

- -

Parameters

- -
-
-
-
- - -CLEANUP:_EventHitCleanUp(event, Event) - -
-
- -

Detects if the Unit has an SEVENTHIT within the given ZoneNames.

- - -

If this is the case, destroy the unit.

- -

Parameters

- -
-
-
-
- - -CLEANUP:_EventShot(event, Event) - -
-
- -

Detects if a unit shoots a missile.

- - -

If this occurs within one of the zones, then the weapon used must be destroyed.

- -

Parameters

- -
-
-
-
- - -CLEANUP:_OnEventBirth(EventData) - -
-
- - -

Parameter

+

Type list

+ +

Type map

+ diff --git a/docs/Documentation/Designate.html b/docs/Documentation/Designate.html index c0c7ee573..70e3562df 100644 --- a/docs/Documentation/Designate.html +++ b/docs/Documentation/Designate.html @@ -900,6 +900,7 @@ function below will use the range 1-7 just in case

+ DESIGNATE.LaserCodes diff --git a/docs/Documentation/Detection.html b/docs/Documentation/Detection.html index 141b7d951..d18ec397a 100644 --- a/docs/Documentation/Detection.html +++ b/docs/Documentation/Detection.html @@ -2393,7 +2393,6 @@ The index of the DetectedItem.

- #number DETECTION_BASE.DetectedItemCount @@ -2407,7 +2406,6 @@ The index of the DetectedItem.

- #number DETECTION_BASE.DetectedItemMax @@ -2565,7 +2563,7 @@ The index of the DetectedItem.

- #number + DETECTION_BASE.DetectionInterval diff --git a/docs/Documentation/Fsm.html b/docs/Documentation/Fsm.html index e0276d335..177f34281 100644 --- a/docs/Documentation/Fsm.html +++ b/docs/Documentation/Fsm.html @@ -1598,7 +1598,7 @@ A string defining the start state.

- + #string FSM._StartState @@ -1897,7 +1897,6 @@ A string defining the start state.

- FSM.current diff --git a/docs/Documentation/Mission.html b/docs/Documentation/Mission.html index 84ce45974..d34e8e4e1 100644 --- a/docs/Documentation/Mission.html +++ b/docs/Documentation/Mission.html @@ -133,6 +133,12 @@ MISSION:AbortUnit(PlayerUnit)

Aborts a PlayerUnit from the Mission.

+ + + + MISSION:AddPlayerName(PlayerName) + + @@ -211,6 +217,12 @@ MISSION:GetNextTaskID(Task)

Return the next Task ID to be completed within the Mission.

+ + + + MISSION:GetPlayerNames() + + @@ -294,13 +306,19 @@ MISSION:MenuReportBriefing(ReportGroup) - +

Reports the briefing.

MISSION:MenuReportPlayersPerTask(ReportGroup) + + + + MISSION:MenuReportPlayersProgress(ReportGroup) + + @@ -312,7 +330,7 @@ MISSION:MenuReportTasksSummary(ReportGroup) - +

Report the task summary.

@@ -499,6 +517,12 @@ MISSION:ReportPlayersPerTask(ReportGroup)

Create an active player report of the Mission.

+ + + + MISSION:ReportPlayersProgress(ReportGroup) + +

Create an Mission Progress report of the Mission.

@@ -644,6 +668,27 @@ The CLIENT or UNIT of the Player joining the Mission.

+ +MISSION:AddPlayerName(PlayerName) + +
+
+ + + +

Parameter

+
    +
  • + +

    PlayerName :

    + +
  • +
+
+
+
+
+ MISSION:AddScoring(Scoring) @@ -915,6 +960,19 @@ is the Task object.

Tasking.Task#TASK: The task added.

+ +
+
+
+ + +MISSION:GetPlayerNames() + +
+
+ + +
@@ -1242,13 +1300,14 @@ true if Unit is part of a Task in the Mission.

- +

Reports the briefing.

Parameter

  • -

    ReportGroup :

    +

    Wrapper.Group#GROUP ReportGroup : +The group to which the report needs to be sent.

@@ -1265,6 +1324,27 @@ true if Unit is part of a Task in the Mission.

+

Parameter

+ +
+
+
+
+ + +MISSION:MenuReportPlayersProgress(ReportGroup) + +
+
+ + +

Parameter

  • @@ -1311,7 +1391,7 @@ The status

- +

Report the task summary.

Parameter

    @@ -2283,6 +2363,42 @@ self

    #string:

    +
+
+
+
+ + +MISSION:ReportPlayersProgress(ReportGroup) + +
+
+ +

Create an Mission Progress report of the Mission.

+ + +

This reports provides a one liner per player of the mission achievements per task.

+ +
Mission "<MissionName>" - <MissionStatus> - Active Players Report
+ - Player <PlayerName>: Task <TaskName> <TaskStatus>: <Progress>
+ - Player <PlayerName>: Task <TaskName> <TaskStatus>: <Progress>
+ - ..
+
+ + +

Parameter

+
    +
  • + +

    ReportGroup :

    + +
  • +
+

Return value

+ +

#string:

+ +
diff --git a/docs/Documentation/Point.html b/docs/Documentation/Point.html index f204d56d9..ba2001e76 100644 --- a/docs/Documentation/Point.html +++ b/docs/Documentation/Point.html @@ -267,6 +267,12 @@ COORDINATE:GetDistanceText(Distance, Settings)

Provides a distance text expressed in the units of measurement.

+ + + + COORDINATE:GetLandHeight() + +

Return the height of the land at the coordinate.

@@ -1498,6 +1504,24 @@ The distance in meters.

#string: The distance text expressed in the units of measurement.

+ +
+
+
+ + +COORDINATE:GetLandHeight() + +
+
+ +

Return the height of the land at the coordinate.

+ +

Return value

+ +

#number:

+ +
diff --git a/docs/Documentation/Scoring.html b/docs/Documentation/Scoring.html index 1bf9e8bd7..3bf1d6c90 100644 --- a/docs/Documentation/Scoring.html +++ b/docs/Documentation/Scoring.html @@ -414,6 +414,12 @@ Various methods exist to configure:

SCORING.CoalitionChangePenalty + + + + SCORING.DisplayMessagePrefix + + @@ -642,6 +648,12 @@ Various methods exist to configure:

SCORING:SetCoalitionChangePenalty(CoalitionChangePenalty)

When a player changes the coalition, he can receive a penalty score.

+ + + + SCORING:SetDisplayMessagePrefix(DisplayMessagePrefix) + +

Set a prefix string that will be displayed at each scoring message sent.

@@ -1038,6 +1050,19 @@ The Score value.

+ +
+
+
+ + +SCORING.DisplayMessagePrefix + +
+
+ + +
@@ -1889,6 +1914,33 @@ The amount of penalty that is given.

#SCORING:

+ +
+
+
+ + +SCORING:SetDisplayMessagePrefix(DisplayMessagePrefix) + +
+
+ +

Set a prefix string that will be displayed at each scoring message sent.

+ +

Parameter

+
    +
  • + +

    #string DisplayMessagePrefix : +(Default="Scoring: ") The scoring prefix string.

    + +
  • +
+

Return value

+ +

#SCORING:

+ +
diff --git a/docs/Documentation/Spawn.html b/docs/Documentation/Spawn.html index 6161409ef..05a9cda85 100644 --- a/docs/Documentation/Spawn.html +++ b/docs/Documentation/Spawn.html @@ -822,6 +822,12 @@ and any spaces before and after the resulting name are removed.

SPAWN:_TranslateRotate(SpawnIndex, SpawnRootX, SpawnRootY, SpawnX, SpawnY, SpawnAngle) + + + + SPAWN.uncontrolled + + @@ -3147,7 +3153,7 @@ Spawn_BE_KA50 = SPAWN:New( 'BE KA-50@RAMP-Ground Defense' ):Schedule( 600, 0.5 ) -

Flag that indicates if all the Groups of the SpawnGroup need to be visible when Spawned.

+

When the first Spawn executes, all the Groups need to be made visible before start.

@@ -3727,6 +3733,20 @@ True = Continue Scheduler

+ +
+
+
+ + + +SPAWN.uncontrolled + +
+
+ + +
diff --git a/docs/Documentation/SpawnStatic.html b/docs/Documentation/SpawnStatic.html index d8aa5e633..bc91b9624 100644 --- a/docs/Documentation/SpawnStatic.html +++ b/docs/Documentation/SpawnStatic.html @@ -436,7 +436,6 @@ ptional) The name of the new static.

- #number SPAWNSTATIC.SpawnIndex diff --git a/docs/Documentation/Task.html b/docs/Documentation/Task.html index 1cf449b57..5ea8d8586 100644 --- a/docs/Documentation/Task.html +++ b/docs/Documentation/Task.html @@ -249,6 +249,12 @@ TASK:GetPlayerNames()

Create a list of the players in the Task.

+ + + + TASK:GetPlayerProgress(PlayerName) + + @@ -1329,6 +1335,27 @@ The total number of players in the task.

+ +TASK:GetPlayerProgress(PlayerName) + +
+
+ + + +

Parameter

+
    +
  • + +

    PlayerName :

    + +
  • +
+
+
+
+
+ TASK:GetProcessTemplate(ProcessName) @@ -3037,7 +3064,7 @@ Fsm#FSM_PROCESS

diff --git a/docs/Documentation/Task_A2A.html b/docs/Documentation/Task_A2A.html index 584ef585f..5cc0a0d9d 100644 --- a/docs/Documentation/Task_A2A.html +++ b/docs/Documentation/Task_A2A.html @@ -159,6 +159,12 @@ based on the tasking capabilities defined in Task#TA

Type TASK_A2A

+ + + + + + + + @@ -478,6 +490,19 @@ The task is given a name and a briefing, that is used in the menu structure and
+ +TASK_A2A:GetGoalTotal() + +
+
+ + + +
+
+
+
+ TASK_A2A:GetPlannedMenuText() @@ -671,6 +696,19 @@ If the TargetZone parameter is specified, the player will be routed to the cente

#TASK_A2A: self

+ +
+
+
+ + +TASK_A2A:SetGoalTotal() + +
+
+ + +
diff --git a/docs/Documentation/Task_A2G.html b/docs/Documentation/Task_A2G.html index 6b55b2294..058ae5687 100644 --- a/docs/Documentation/Task_A2G.html +++ b/docs/Documentation/Task_A2G.html @@ -159,6 +159,12 @@ based on the tasking capabilities defined in Task#TA

Type TASK_A2G

TASK_A2A:GetGoalTotal() + +
TASK_A2A:GetPlannedMenuText() @@ -192,6 +198,12 @@ based on the tasking capabilities defined in Task#TA TASK_A2A:New(Mission, SetAttack, TaskName, UnitSetTargets, TargetDistance, TargetZone, TargetSetUnit, TaskType, TaskBriefing)

Instantiates a new TASK_A2A.

+
TASK_A2A:SetGoalTotal() +
+ + + + + + + + @@ -468,6 +480,19 @@ based on detected enemy ground targets.

+ +TASK_A2G:GetGoalTotal() + +
+
+ + + +
+
+
+
+ TASK_A2G:GetPlannedMenuText() @@ -661,6 +686,19 @@ If the TargetZone parameter is specified, the player will be routed to the cente

#TASK_A2G: self

+ +
+
+
+ + +TASK_A2G:SetGoalTotal() + +
+
+ + +
diff --git a/docs/Documentation/Task_Cargo.html b/docs/Documentation/Task_Cargo.html index 8c17ced64..dda7b2ea9 100644 --- a/docs/Documentation/Task_Cargo.html +++ b/docs/Documentation/Task_Cargo.html @@ -510,7 +510,7 @@ based on the tasking capabilities defined in Task#TA
- + Core.Cargo#CARGO FSM_PROCESS.Cargo diff --git a/docs/Presentations/CLEANUP/Dia1.JPG b/docs/Presentations/CLEANUP/Dia1.JPG new file mode 100644 index 000000000..281e0d792 Binary files /dev/null and b/docs/Presentations/CLEANUP/Dia1.JPG differ diff --git a/docs/README.md b/docs/README.md index 2ecfc8809..a4b77627d 100644 --- a/docs/README.md +++ b/docs/README.md @@ -114,7 +114,7 @@ MOOSE Functional Classes provide various functions that are useful in mission de * [AIRBASEPOLICE](Documentation/AirbasePolice.html): Control the speed of players at the airbases. Speeding players are eliminated (does not work due to a bug in the DCS). -* [CLEANUP](Documentation/Cleanup.html): Keeps the airbases clean from clutter. (Only partly functional due to a bug in DCS, destroyed objects cannot be removed). +* [CLEANUP](Documentation/CleanUp.html): Keeps the airbases clean from clutter. (Only partly functional due to a bug in DCS, destroyed objects cannot be removed). ## 2.4. MOOSE Wrapper Classes
TASK_A2G:GetGoalTotal() + +
TASK_A2G:GetPlannedMenuText() @@ -192,6 +198,12 @@ based on the tasking capabilities defined in Task#TA TASK_A2G:New(Mission, SetGroup, TaskName, UnitSetTargets, TargetDistance, TargetZone, TargetSetUnit, TaskType, TaskBriefing)

Instantiates a new TASK_A2G.

+
TASK_A2G:SetGoalTotal() +