mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Progress
- Removed the old classes and moved into an "Old" folder in the Moose/Development folder. -- Cleaned Moose.lua + Documented class types -- Cleaned Create_Moose.bat + Documented class types - Extend the ZONE_BASE class with a probability randomization factor, that can be used for zone randomization purposes. - Documented the Zone module classes. - Changed and removed the POINT_VEC3 SmokeColor and FlareColor structure. Replaced with SMOKECOLOR and FLARECOLOR types. -- Replaced also code in test missions with SMOKECOLOR and FLARECOLOR references. - Renamed UnControlled() method to InitUnControlled method.
This commit is contained in:
@@ -1,158 +0,0 @@
|
||||
--- A DEPLOYTASK orchestrates the deployment of CARGO within a specific landing zone.
|
||||
-- @module DEPLOYTASK
|
||||
|
||||
|
||||
|
||||
--- A DeployTask
|
||||
-- @type DEPLOYTASK
|
||||
DEPLOYTASK = {
|
||||
ClassName = "DEPLOYTASK",
|
||||
TEXT = { "Deploy", "deployed", "unloaded" },
|
||||
GoalVerb = "Deployment"
|
||||
}
|
||||
|
||||
|
||||
--- Creates a new DEPLOYTASK object, which models the sequence of STAGEs to unload a cargo.
|
||||
-- @function [parent=#DEPLOYTASK] New
|
||||
-- @param #string CargoType Type of the Cargo.
|
||||
-- @return #DEPLOYTASK The created DeployTask
|
||||
function DEPLOYTASK:New( CargoType )
|
||||
local self = BASE:Inherit( self, TASK:New() )
|
||||
self:F()
|
||||
|
||||
local Valid = true
|
||||
|
||||
if Valid then
|
||||
self.Name = 'Deploy Cargo'
|
||||
self.TaskBriefing = "Fly to one of the indicated landing zones and deploy " .. CargoType .. ". Your co-pilot will provide you with the directions (required flight angle in degrees) and the distance (in km) to the deployment zone."
|
||||
self.CargoType = CargoType
|
||||
self.GoalVerb = CargoType .. " " .. self.GoalVerb
|
||||
self.Stages = { STAGE_CARGO_INIT:New(), STAGE_CARGO_LOAD:New(), STAGEBRIEF:New(), STAGESTART:New(), STAGEROUTE:New(), STAGELANDING:New(), STAGELANDED:New(), STAGEUNLOAD:New(), STAGEDONE:New() }
|
||||
self.SetStage( self, 1 )
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
function DEPLOYTASK:ToZone( LandingZone )
|
||||
self:F()
|
||||
|
||||
self.LandingZones.LandingZoneNames[LandingZone.CargoZoneName] = LandingZone.CargoZoneName
|
||||
self.LandingZones.LandingZones[LandingZone.CargoZoneName] = LandingZone
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
function DEPLOYTASK:InitCargo( InitCargos )
|
||||
self:F( { InitCargos } )
|
||||
|
||||
if type( InitCargos ) == "table" then
|
||||
self.Cargos.InitCargos = InitCargos
|
||||
else
|
||||
self.Cargos.InitCargos = { InitCargos }
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
function DEPLOYTASK:LoadCargo( LoadCargos )
|
||||
self:F( { LoadCargos } )
|
||||
|
||||
if type( LoadCargos ) == "table" then
|
||||
self.Cargos.LoadCargos = LoadCargos
|
||||
else
|
||||
self.Cargos.LoadCargos = { LoadCargos }
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- When the cargo is unloaded, it will move to the target zone name.
|
||||
-- @param string TargetZoneName Name of the Zone to where the Cargo should move after unloading.
|
||||
function DEPLOYTASK:SetCargoTargetZoneName( TargetZoneName )
|
||||
self:F()
|
||||
|
||||
local Valid = true
|
||||
|
||||
Valid = routines.ValidateString( TargetZoneName, "TargetZoneName", Valid )
|
||||
|
||||
if Valid then
|
||||
self.TargetZoneName = TargetZoneName
|
||||
end
|
||||
|
||||
return Valid
|
||||
|
||||
end
|
||||
|
||||
function DEPLOYTASK:AddCargoMenus( Client, Cargos, TransportRadius )
|
||||
self:F()
|
||||
|
||||
local ClientGroupID = Client:GetClientGroupID()
|
||||
|
||||
self:T( ClientGroupID )
|
||||
|
||||
for CargoID, Cargo in pairs( Cargos ) do
|
||||
|
||||
self:T( { Cargo.ClassName, Cargo.CargoName, Cargo.CargoType, Cargo.CargoWeight } )
|
||||
|
||||
if Cargo:IsStatusLoaded() and Client == Cargo:IsLoadedInClient() then
|
||||
|
||||
if Client._Menus[Cargo.CargoType] == nil then
|
||||
Client._Menus[Cargo.CargoType] = {}
|
||||
end
|
||||
|
||||
if not Client._Menus[Cargo.CargoType].DeployMenu then
|
||||
Client._Menus[Cargo.CargoType].DeployMenu = missionCommands.addSubMenuForGroup(
|
||||
ClientGroupID,
|
||||
self.TEXT[1] .. " " .. Cargo.CargoType,
|
||||
nil
|
||||
)
|
||||
self:T( 'Added DeployMenu ' .. self.TEXT[1] )
|
||||
end
|
||||
|
||||
if Client._Menus[Cargo.CargoType].DeploySubMenus == nil then
|
||||
Client._Menus[Cargo.CargoType].DeploySubMenus = {}
|
||||
end
|
||||
|
||||
if Client._Menus[Cargo.CargoType].DeployMenu == nil then
|
||||
self:T( 'deploymenu is nil' )
|
||||
end
|
||||
|
||||
Client._Menus[Cargo.CargoType].DeploySubMenus[ #Client._Menus[Cargo.CargoType].DeploySubMenus + 1 ] = missionCommands.addCommandForGroup(
|
||||
ClientGroupID,
|
||||
Cargo.CargoName .. " ( " .. Cargo.CargoWeight .. "kg )",
|
||||
Client._Menus[Cargo.CargoType].DeployMenu,
|
||||
self.MenuAction,
|
||||
{ ReferenceTask = self, CargoTask = Cargo }
|
||||
)
|
||||
self:T( 'Added DeploySubMenu ' .. Cargo.CargoType .. ":" .. Cargo.CargoName .. " ( " .. Cargo.CargoWeight .. "kg )" )
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function DEPLOYTASK:RemoveCargoMenus( Client )
|
||||
self:F()
|
||||
|
||||
local ClientGroupID = Client:GetClientGroupID()
|
||||
self:T( ClientGroupID )
|
||||
|
||||
for MenuID, MenuData in pairs( Client._Menus ) do
|
||||
if MenuData.DeploySubMenus ~= nil then
|
||||
for SubMenuID, SubMenuData in pairs( MenuData.DeploySubMenus ) do
|
||||
missionCommands.removeItemForGroup( ClientGroupID, SubMenuData )
|
||||
self:T( "Removed DeploySubMenu " )
|
||||
SubMenuData = nil
|
||||
end
|
||||
end
|
||||
if MenuData.DeployMenu then
|
||||
missionCommands.removeItemForGroup( ClientGroupID, MenuData.DeployMenu )
|
||||
self:T( "Removed DeployMenu " )
|
||||
MenuData.DeployMenu = nil
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,81 +0,0 @@
|
||||
--- A DESTROYBASETASK will monitor the destruction of Groups and Units. This is a BASE class, other classes are derived from this class.
|
||||
-- @module DESTROYBASETASK
|
||||
-- @see DESTROYGROUPSTASK
|
||||
-- @see DESTROYUNITTYPESTASK
|
||||
-- @see DESTROY_RADARS_TASK
|
||||
|
||||
|
||||
|
||||
--- The DESTROYBASETASK class
|
||||
-- @type DESTROYBASETASK
|
||||
DESTROYBASETASK = {
|
||||
ClassName = "DESTROYBASETASK",
|
||||
Destroyed = 0,
|
||||
GoalVerb = "Destroy",
|
||||
DestroyPercentage = 100,
|
||||
}
|
||||
|
||||
--- Creates a new DESTROYBASETASK.
|
||||
-- @param #DESTROYBASETASK self
|
||||
-- @param #string DestroyGroupType Text describing the group to be destroyed. f.e. "Radar Installations", "Ships", "Vehicles", "Command Centers".
|
||||
-- @param #string DestroyUnitType Text describing the unit types to be destroyed. f.e. "SA-6", "Row Boats", "Tanks", "Tents".
|
||||
-- @param #list<#string> DestroyGroupPrefixes Table of Prefixes of the Groups to be destroyed before task is completed.
|
||||
-- @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 DESTROYBASETASK
|
||||
function DESTROYBASETASK:New( DestroyGroupType, DestroyUnitType, DestroyGroupPrefixes, DestroyPercentage )
|
||||
local self = BASE:Inherit( self, TASK:New() )
|
||||
self:F()
|
||||
|
||||
self.Name = 'Destroy'
|
||||
self.Destroyed = 0
|
||||
self.DestroyGroupPrefixes = DestroyGroupPrefixes
|
||||
self.DestroyGroupType = DestroyGroupType
|
||||
self.DestroyUnitType = DestroyUnitType
|
||||
if DestroyPercentage then
|
||||
self.DestroyPercentage = DestroyPercentage
|
||||
end
|
||||
self.TaskBriefing = "Task: Destroy " .. DestroyGroupType .. "."
|
||||
self.Stages = { STAGEBRIEF:New(), STAGESTART:New(), STAGEGROUPSDESTROYED:New(), STAGEDONE:New() }
|
||||
self.SetStage( self, 1 )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Handle the S_EVENT_DEAD events to validate the destruction of units for the task monitoring.
|
||||
-- @param #DESTROYBASETASK self
|
||||
-- @param Event#EVENTDATA Event structure of MOOSE.
|
||||
function DESTROYBASETASK:EventDead( Event )
|
||||
self:F( { Event } )
|
||||
|
||||
if Event.IniDCSUnit then
|
||||
local DestroyUnit = Event.IniDCSUnit
|
||||
local DestroyUnitName = Event.IniDCSUnitName
|
||||
local DestroyGroup = Event.IniDCSGroup
|
||||
local DestroyGroupName = Event.IniDCSGroupName
|
||||
|
||||
--TODO: I need to fix here if 2 groups in the mission have a similar name with GroupPrefix equal, then i should differentiate for which group the goal was reached!
|
||||
--I may need to test if for the goalverb that group goal was reached or something. Need to think about it a bit more ...
|
||||
local UnitsDestroyed = 0
|
||||
for DestroyGroupPrefixID, DestroyGroupPrefix in pairs( self.DestroyGroupPrefixes ) do
|
||||
self:T( DestroyGroupPrefix )
|
||||
if string.find( DestroyGroupName, DestroyGroupPrefix, 1, true ) then
|
||||
self:T( BASE:Inherited(self).ClassName )
|
||||
UnitsDestroyed = self:ReportGoalProgress( DestroyGroup, DestroyUnit )
|
||||
self:T( UnitsDestroyed )
|
||||
end
|
||||
end
|
||||
|
||||
self:T( { UnitsDestroyed } )
|
||||
self:IncreaseGoalCount( UnitsDestroyed, self.GoalVerb )
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--- Validate task completeness of DESTROYBASETASK.
|
||||
-- @param DestroyGroup Group structure describing the group to be evaluated.
|
||||
-- @param DestroyUnit Unit structure describing the Unit to be evaluated.
|
||||
function DESTROYBASETASK:ReportGoalProgress( DestroyGroup, DestroyUnit )
|
||||
self:F()
|
||||
|
||||
return 0
|
||||
end
|
||||
@@ -1,57 +0,0 @@
|
||||
--- DESTROYGROUPSTASK
|
||||
-- @module DESTROYGROUPSTASK
|
||||
|
||||
|
||||
|
||||
--- The DESTROYGROUPSTASK class
|
||||
-- @type
|
||||
DESTROYGROUPSTASK = {
|
||||
ClassName = "DESTROYGROUPSTASK",
|
||||
GoalVerb = "Destroy Groups",
|
||||
}
|
||||
|
||||
--- Creates a new DESTROYGROUPSTASK.
|
||||
-- @param #DESTROYGROUPSTASK self
|
||||
-- @param #string DestroyGroupType String describing the group to be destroyed.
|
||||
-- @param #string DestroyUnitType String describing the unit to be destroyed.
|
||||
-- @param #list<#string> DestroyGroupNames Table of string containing the name of the groups to be destroyed before task is completed.
|
||||
-- @param #number DestroyPercentage defines the %-tage that needs to be destroyed to achieve mission success. eg. If in the Group there are 10 units, then a value of 75 would require 8 units to be destroyed from the Group to complete the @{TASK}.
|
||||
---@return DESTROYGROUPSTASK
|
||||
function DESTROYGROUPSTASK:New( DestroyGroupType, DestroyUnitType, DestroyGroupNames, DestroyPercentage )
|
||||
local self = BASE:Inherit( self, DESTROYBASETASK:New( DestroyGroupType, DestroyUnitType, DestroyGroupNames, DestroyPercentage ) )
|
||||
self:F()
|
||||
|
||||
self.Name = 'Destroy Groups'
|
||||
self.GoalVerb = "Destroy " .. DestroyGroupType
|
||||
|
||||
_EVENTDISPATCHER:OnDead( self.EventDead , self )
|
||||
_EVENTDISPATCHER:OnCrash( self.EventDead , self )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Report Goal Progress.
|
||||
-- @param #DESTROYGROUPSTASK self
|
||||
-- @param DCSGroup#Group DestroyGroup Group structure describing the group to be evaluated.
|
||||
-- @param DCSUnit#Unit DestroyUnit Unit structure describing the Unit to be evaluated.
|
||||
-- @return #number The DestroyCount reflecting the amount of units destroyed within the group.
|
||||
function DESTROYGROUPSTASK:ReportGoalProgress( DestroyGroup, DestroyUnit )
|
||||
self:F( { DestroyGroup, DestroyUnit, self.DestroyPercentage } )
|
||||
|
||||
local DestroyGroupSize = DestroyGroup:getSize() - 1 -- When a DEAD event occurs, the getSize is still one larger than the destroyed unit.
|
||||
local DestroyGroupInitialSize = DestroyGroup:getInitialSize()
|
||||
self:T( { DestroyGroupSize, DestroyGroupInitialSize - ( DestroyGroupInitialSize * self.DestroyPercentage / 100 ) } )
|
||||
|
||||
local DestroyCount = 0
|
||||
if DestroyGroup then
|
||||
if DestroyGroupSize <= DestroyGroupInitialSize - ( DestroyGroupInitialSize * self.DestroyPercentage / 100 ) then
|
||||
DestroyCount = 1
|
||||
end
|
||||
else
|
||||
DestroyCount = 1
|
||||
end
|
||||
|
||||
self:T( DestroyCount )
|
||||
|
||||
return DestroyCount
|
||||
end
|
||||
@@ -1,41 +0,0 @@
|
||||
--- Task class to destroy radar installations.
|
||||
-- @module DESTROYRADARSTASK
|
||||
|
||||
|
||||
|
||||
--- The DESTROYRADARS class
|
||||
-- @type
|
||||
DESTROYRADARSTASK = {
|
||||
ClassName = "DESTROYRADARSTASK",
|
||||
GoalVerb = "Destroy Radars"
|
||||
}
|
||||
|
||||
--- Creates a new DESTROYRADARSTASK.
|
||||
-- @param table{string,...} DestroyGroupNames Table of string containing the group names of which the radars are be destroyed.
|
||||
-- @return DESTROYRADARSTASK
|
||||
function DESTROYRADARSTASK:New( DestroyGroupNames )
|
||||
local self = BASE:Inherit( self, DESTROYGROUPSTASK:New( 'radar installations', 'radars', DestroyGroupNames ) )
|
||||
self:F()
|
||||
|
||||
self.Name = 'Destroy Radars'
|
||||
|
||||
_EVENTDISPATCHER:OnDead( self.EventDead , self )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Report Goal Progress.
|
||||
-- @param Group DestroyGroup Group structure describing the group to be evaluated.
|
||||
-- @param Unit DestroyUnit Unit structure describing the Unit to be evaluated.
|
||||
function DESTROYRADARSTASK:ReportGoalProgress( DestroyGroup, DestroyUnit )
|
||||
self:F( { DestroyGroup, DestroyUnit } )
|
||||
|
||||
local DestroyCount = 0
|
||||
if DestroyUnit and DestroyUnit:hasSensors( Unit.SensorType.RADAR, Unit.RadarType.AS ) then
|
||||
if DestroyUnit and DestroyUnit:getLife() <= 1.0 then
|
||||
self:T( 'Destroyed a radar' )
|
||||
DestroyCount = 1
|
||||
end
|
||||
end
|
||||
return DestroyCount
|
||||
end
|
||||
@@ -1,52 +0,0 @@
|
||||
--- Set TASK to destroy certain unit types.
|
||||
-- @module DESTROYUNITTYPESTASK
|
||||
|
||||
|
||||
|
||||
--- The DESTROYUNITTYPESTASK class
|
||||
-- @type
|
||||
DESTROYUNITTYPESTASK = {
|
||||
ClassName = "DESTROYUNITTYPESTASK",
|
||||
GoalVerb = "Destroy",
|
||||
}
|
||||
|
||||
--- Creates a new DESTROYUNITTYPESTASK.
|
||||
-- @param string DestroyGroupType String describing the group to be destroyed. f.e. "Radar Installations", "Fleet", "Batallion", "Command Centers".
|
||||
-- @param string DestroyUnitType String describing the unit to be destroyed. f.e. "radars", "ships", "tanks", "centers".
|
||||
-- @param table{string,...} DestroyGroupNames Table of string containing the group names of which the radars are be destroyed.
|
||||
-- @param string DestroyUnitTypes Table of string containing the type names of the units to achieve mission success.
|
||||
-- @return DESTROYUNITTYPESTASK
|
||||
function DESTROYUNITTYPESTASK:New( DestroyGroupType, DestroyUnitType, DestroyGroupNames, DestroyUnitTypes )
|
||||
local self = BASE:Inherit( self, DESTROYBASETASK:New( DestroyGroupType, DestroyUnitType, DestroyGroupNames ) )
|
||||
self:F( { DestroyGroupType, DestroyUnitType, DestroyGroupNames, DestroyUnitTypes } )
|
||||
|
||||
if type(DestroyUnitTypes) == 'table' then
|
||||
self.DestroyUnitTypes = DestroyUnitTypes
|
||||
else
|
||||
self.DestroyUnitTypes = { DestroyUnitTypes }
|
||||
end
|
||||
|
||||
self.Name = 'Destroy Unit Types'
|
||||
self.GoalVerb = "Destroy " .. DestroyGroupType
|
||||
|
||||
_EVENTDISPATCHER:OnDead( self.EventDead , self )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Report Goal Progress.
|
||||
-- @param Group DestroyGroup Group structure describing the group to be evaluated.
|
||||
-- @param Unit DestroyUnit Unit structure describing the Unit to be evaluated.
|
||||
function DESTROYUNITTYPESTASK:ReportGoalProgress( DestroyGroup, DestroyUnit )
|
||||
self:F( { DestroyGroup, DestroyUnit } )
|
||||
|
||||
local DestroyCount = 0
|
||||
for UnitTypeID, UnitType in pairs( self.DestroyUnitTypes ) do
|
||||
if DestroyUnit and DestroyUnit:getTypeName() == UnitType then
|
||||
if DestroyUnit and DestroyUnit:getLife() <= 1.0 then
|
||||
DestroyCount = DestroyCount + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
return DestroyCount
|
||||
end
|
||||
@@ -1,33 +0,0 @@
|
||||
--- A GOHOMETASK orchestrates the travel back to the home base, which is a specific zone defined within the ME.
|
||||
-- @module GOHOMETASK
|
||||
|
||||
--- The GOHOMETASK class
|
||||
-- @type
|
||||
GOHOMETASK = {
|
||||
ClassName = "GOHOMETASK",
|
||||
}
|
||||
|
||||
--- Creates a new GOHOMETASK.
|
||||
-- @param table{string,...}|string LandingZones Table of Landing Zone names where Home(s) are located.
|
||||
-- @return GOHOMETASK
|
||||
function GOHOMETASK:New( LandingZones )
|
||||
local self = BASE:Inherit( self, TASK:New() )
|
||||
self:F( { LandingZones } )
|
||||
local Valid = true
|
||||
|
||||
Valid = routines.ValidateZone( LandingZones, "LandingZones", Valid )
|
||||
|
||||
if Valid then
|
||||
self.Name = 'Fly Home'
|
||||
self.TaskBriefing = "Task: Fly back to your home base. Your co-pilot will provide you with the directions (required flight angle in degrees) and the distance (in km) to your home base."
|
||||
if type( LandingZones ) == "table" then
|
||||
self.LandingZones = LandingZones
|
||||
else
|
||||
self.LandingZones = { LandingZones }
|
||||
end
|
||||
self.Stages = { STAGEBRIEF:New(), STAGESTART:New(), STAGEROUTE:New(), STAGEARRIVE:New(), STAGEDONE:New() }
|
||||
self.SetStage( self, 1 )
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
@@ -1,7 +1,10 @@
|
||||
--- The main include file for the MOOSE system.
|
||||
|
||||
--- Core Routines
|
||||
Include.File( "Routines" )
|
||||
Include.File( "Utils" )
|
||||
|
||||
--- Core Classes
|
||||
Include.File( "Base" )
|
||||
Include.File( "Object" )
|
||||
Include.File( "Identifiable" )
|
||||
@@ -19,21 +22,11 @@ Include.File( "Airbase" )
|
||||
Include.File( "Database" )
|
||||
Include.File( "Set" )
|
||||
Include.File( "Point" )
|
||||
Include.File( "Moose" )
|
||||
Include.File( "Scoring" )
|
||||
|
||||
--- Functional Classes
|
||||
Include.File( "Cargo" )
|
||||
Include.File( "Message" )
|
||||
Include.File( "Stage" )
|
||||
Include.File( "Task" )
|
||||
Include.File( "GoHomeTask" )
|
||||
Include.File( "DestroyBaseTask" )
|
||||
Include.File( "DestroyGroupsTask" )
|
||||
Include.File( "DestroyRadarsTask" )
|
||||
Include.File( "DestroyUnitTypesTask" )
|
||||
Include.File( "PickupTask" )
|
||||
Include.File( "DeployTask" )
|
||||
Include.File( "NoTask" )
|
||||
Include.File( "RouteTask" )
|
||||
Include.File( "Mission" )
|
||||
Include.File( "CleanUp" )
|
||||
Include.File( "Spawn" )
|
||||
@@ -44,8 +37,9 @@ Include.File( "MissileTrainer" )
|
||||
Include.File( "PatrolZone" )
|
||||
Include.File( "AIBalancer" )
|
||||
Include.File( "AirbasePolice" )
|
||||
|
||||
Include.File( "Detection" )
|
||||
|
||||
--- Task Handling Classes
|
||||
Include.File( "DetectionManager" )
|
||||
|
||||
Include.File( "StateMachine" )
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
|
||||
local Mission = MISSION:New( "Pickup Cargo", "High", "Test for Cargo Pickup", coalition.side.RED )
|
||||
|
||||
local CargoEngineer = UNIT:FindByName( "Engineer" )
|
||||
local InfantryCargo = CARGO_UNIT:New( Mission, CargoEngineer, "Engineer", "Engineer Sven", "81", 2000, 300 )
|
||||
|
||||
local CargoCarrier = UNIT:FindByName( "CargoCarrier" )
|
||||
InfantryCargo:OnBoard( CargoCarrier )
|
||||
@@ -1,25 +0,0 @@
|
||||
--- A NOTASK is a dummy activity... But it will show a Mission Briefing...
|
||||
-- @module NOTASK
|
||||
|
||||
--- The NOTASK class
|
||||
-- @type
|
||||
NOTASK = {
|
||||
ClassName = "NOTASK",
|
||||
}
|
||||
|
||||
--- Creates a new NOTASK.
|
||||
function NOTASK:New()
|
||||
local self = BASE:Inherit( self, TASK:New() )
|
||||
self:F()
|
||||
|
||||
local Valid = true
|
||||
|
||||
if Valid then
|
||||
self.Name = 'Nothing'
|
||||
self.TaskBriefing = "Task: Execute your mission."
|
||||
self.Stages = { STAGEBRIEF:New(), STAGESTART:New(), STAGEDONE:New() }
|
||||
self.SetStage( self, 1 )
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
@@ -1,153 +0,0 @@
|
||||
--- A PICKUPTASK orchestrates the loading of CARGO at a specific landing zone.
|
||||
-- @module PICKUPTASK
|
||||
-- @parent TASK
|
||||
|
||||
--- The PICKUPTASK class
|
||||
-- @type
|
||||
PICKUPTASK = {
|
||||
ClassName = "PICKUPTASK",
|
||||
TEXT = { "Pick-Up", "picked-up", "loaded" },
|
||||
GoalVerb = "Pick-Up"
|
||||
}
|
||||
|
||||
--- Creates a new PICKUPTASK.
|
||||
-- @param table{string,...}|string LandingZones Table of Zone names where Cargo is to be loaded.
|
||||
-- @param CARGO_TYPE CargoType Type of the Cargo. The type must be of the following Enumeration:..
|
||||
-- @param number OnBoardSide Reflects from which side the cargo Group will be on-boarded on the Carrier.
|
||||
function PICKUPTASK:New( CargoType, OnBoardSide )
|
||||
local self = BASE:Inherit( self, TASK:New() )
|
||||
self:F()
|
||||
|
||||
-- self holds the inherited instance of the PICKUPTASK Class to the BASE class.
|
||||
|
||||
local Valid = true
|
||||
|
||||
if Valid then
|
||||
self.Name = 'Pickup Cargo'
|
||||
self.TaskBriefing = "Task: Fly to the indicated landing zones and pickup " .. CargoType .. ". Your co-pilot will provide you with the directions (required flight angle in degrees) and the distance (in km) to the pickup zone."
|
||||
self.CargoType = CargoType
|
||||
self.GoalVerb = CargoType .. " " .. self.GoalVerb
|
||||
self.OnBoardSide = OnBoardSide
|
||||
self.IsLandingRequired = true -- required to decide whether the client needs to land or not
|
||||
self.IsSlingLoad = false -- Indicates whether the cargo is a sling load cargo
|
||||
self.Stages = { STAGE_CARGO_INIT:New(), STAGE_CARGO_LOAD:New(), STAGEBRIEF:New(), STAGESTART:New(), STAGEROUTE:New(), STAGELANDING:New(), STAGELANDED:New(), STAGELOAD:New(), STAGEDONE:New() }
|
||||
self.SetStage( self, 1 )
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
function PICKUPTASK:FromZone( LandingZone )
|
||||
self:F()
|
||||
|
||||
self.LandingZones.LandingZoneNames[LandingZone.CargoZoneName] = LandingZone.CargoZoneName
|
||||
self.LandingZones.LandingZones[LandingZone.CargoZoneName] = LandingZone
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
function PICKUPTASK:InitCargo( InitCargos )
|
||||
self:F( { InitCargos } )
|
||||
|
||||
if type( InitCargos ) == "table" then
|
||||
self.Cargos.InitCargos = InitCargos
|
||||
else
|
||||
self.Cargos.InitCargos = { InitCargos }
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
function PICKUPTASK:LoadCargo( LoadCargos )
|
||||
self:F( { LoadCargos } )
|
||||
|
||||
if type( LoadCargos ) == "table" then
|
||||
self.Cargos.LoadCargos = LoadCargos
|
||||
else
|
||||
self.Cargos.LoadCargos = { LoadCargos }
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
function PICKUPTASK:AddCargoMenus( Client, Cargos, TransportRadius )
|
||||
self:F()
|
||||
|
||||
for CargoID, Cargo in pairs( Cargos ) do
|
||||
|
||||
self:T( { Cargo.ClassName, Cargo.CargoName, Cargo.CargoType, Cargo:IsStatusNone(), Cargo:IsStatusLoaded(), Cargo:IsStatusLoading(), Cargo:IsStatusUnLoaded() } )
|
||||
|
||||
-- If the Cargo has no status, allow the menu option.
|
||||
if Cargo:IsStatusNone() or ( Cargo:IsStatusLoading() and Client == Cargo:IsLoadingToClient() ) then
|
||||
|
||||
local MenuAdd = false
|
||||
if Cargo:IsNear( Client, self.CurrentCargoZone ) then
|
||||
MenuAdd = true
|
||||
end
|
||||
|
||||
if MenuAdd then
|
||||
if Client._Menus[Cargo.CargoType] == nil then
|
||||
Client._Menus[Cargo.CargoType] = {}
|
||||
end
|
||||
|
||||
if not Client._Menus[Cargo.CargoType].PickupMenu then
|
||||
Client._Menus[Cargo.CargoType].PickupMenu = missionCommands.addSubMenuForGroup(
|
||||
Client:GetClientGroupID(),
|
||||
self.TEXT[1] .. " " .. Cargo.CargoType,
|
||||
nil
|
||||
)
|
||||
self:T( 'Added PickupMenu: ' .. self.TEXT[1] .. " " .. Cargo.CargoType )
|
||||
end
|
||||
|
||||
if Client._Menus[Cargo.CargoType].PickupSubMenus == nil then
|
||||
Client._Menus[Cargo.CargoType].PickupSubMenus = {}
|
||||
end
|
||||
|
||||
Client._Menus[Cargo.CargoType].PickupSubMenus[ #Client._Menus[Cargo.CargoType].PickupSubMenus + 1 ] = missionCommands.addCommandForGroup(
|
||||
Client:GetClientGroupID(),
|
||||
Cargo.CargoName .. " ( " .. Cargo.CargoWeight .. "kg )",
|
||||
Client._Menus[Cargo.CargoType].PickupMenu,
|
||||
self.MenuAction,
|
||||
{ ReferenceTask = self, CargoTask = Cargo }
|
||||
)
|
||||
self:T( 'Added PickupSubMenu' .. Cargo.CargoType .. ":" .. Cargo.CargoName .. " ( " .. Cargo.CargoWeight .. "kg )" )
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function PICKUPTASK:RemoveCargoMenus( Client )
|
||||
self:F()
|
||||
|
||||
for MenuID, MenuData in pairs( Client._Menus ) do
|
||||
for SubMenuID, SubMenuData in pairs( MenuData.PickupSubMenus ) do
|
||||
missionCommands.removeItemForGroup( Client:GetClientGroupID(), SubMenuData )
|
||||
self:T( "Removed PickupSubMenu " )
|
||||
SubMenuData = nil
|
||||
end
|
||||
if MenuData.PickupMenu then
|
||||
missionCommands.removeItemForGroup( Client:GetClientGroupID(), MenuData.PickupMenu )
|
||||
self:T( "Removed PickupMenu " )
|
||||
MenuData.PickupMenu = nil
|
||||
end
|
||||
end
|
||||
|
||||
for CargoID, Cargo in pairs( CARGOS ) do
|
||||
self:T( { Cargo.ClassName, Cargo.CargoName, Cargo.CargoType, Cargo:IsStatusNone(), Cargo:IsStatusLoaded(), Cargo:IsStatusLoading(), Cargo:IsStatusUnLoaded() } )
|
||||
if Cargo:IsStatusLoading() and Client == Cargo:IsLoadingToClient() then
|
||||
Cargo:StatusNone()
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
function PICKUPTASK:HasFailed( ClientDead )
|
||||
self:F()
|
||||
|
||||
local TaskHasFailed = self.TaskFailed
|
||||
return TaskHasFailed
|
||||
end
|
||||
|
||||
@@ -35,25 +35,12 @@
|
||||
-- @field #number y The y coordinate in 3D space.
|
||||
-- @field #number z The z coordiante in 3D space.
|
||||
-- @field #POINT_VEC3.SmokeColor SmokeColor
|
||||
-- @field #POINT_VEC3.FlareColor FlareColor
|
||||
-- @field Utils#FLARECOLOR FlareColor
|
||||
-- @field #POINT_VEC3.RoutePointAltType RoutePointAltType
|
||||
-- @field #POINT_VEC3.RoutePointType RoutePointType
|
||||
-- @field #POINT_VEC3.RoutePointAction RoutePointAction
|
||||
POINT_VEC3 = {
|
||||
ClassName = "POINT_VEC3",
|
||||
SmokeColor = {
|
||||
Green = trigger.smokeColor.Green,
|
||||
Red = trigger.smokeColor.Red,
|
||||
White = trigger.smokeColor.White,
|
||||
Orange = trigger.smokeColor.Orange,
|
||||
Blue = trigger.smokeColor.Blue
|
||||
},
|
||||
FlareColor = {
|
||||
Green = trigger.flareColor.Green,
|
||||
Red = trigger.flareColor.Red,
|
||||
White = trigger.flareColor.White,
|
||||
Yellow = trigger.flareColor.Yellow
|
||||
},
|
||||
Metric = true,
|
||||
RoutePointAltType = {
|
||||
BARO = "BARO",
|
||||
@@ -78,43 +65,18 @@ POINT_VEC2 = {
|
||||
|
||||
do -- POINT_VEC3
|
||||
|
||||
--- SmokeColor
|
||||
-- @type POINT_VEC3.SmokeColor
|
||||
-- @field Green
|
||||
-- @field Red
|
||||
-- @field White
|
||||
-- @field Orange
|
||||
-- @field Blue
|
||||
|
||||
|
||||
|
||||
--- FlareColor
|
||||
-- @type POINT_VEC3.FlareColor
|
||||
-- @field Green
|
||||
-- @field Red
|
||||
-- @field White
|
||||
-- @field Yellow
|
||||
|
||||
|
||||
|
||||
--- RoutePoint AltTypes
|
||||
-- @type POINT_VEC3.RoutePointAltType
|
||||
-- @field BARO "BARO"
|
||||
|
||||
|
||||
|
||||
--- RoutePoint Types
|
||||
-- @type POINT_VEC3.RoutePointType
|
||||
-- @field TurningPoint "Turning Point"
|
||||
|
||||
|
||||
|
||||
--- RoutePoint Actions
|
||||
-- @type POINT_VEC3.RoutePointAction
|
||||
-- @field TurningPoint "Turning Point"
|
||||
|
||||
|
||||
|
||||
-- Constructor.
|
||||
|
||||
--- Create a new POINT_VEC3 object.
|
||||
@@ -490,7 +452,7 @@ end
|
||||
|
||||
--- Smokes the point in a color.
|
||||
-- @param #POINT_VEC3 self
|
||||
-- @param Point#POINT_VEC3.SmokeColor SmokeColor
|
||||
-- @param Utils#SMOKECOLOR SmokeColor
|
||||
function POINT_VEC3:Smoke( SmokeColor )
|
||||
self:F2( { SmokeColor } )
|
||||
trigger.action.smoke( self:GetVec3(), SmokeColor )
|
||||
@@ -500,40 +462,40 @@ end
|
||||
-- @param #POINT_VEC3 self
|
||||
function POINT_VEC3:SmokeGreen()
|
||||
self:F2()
|
||||
self:Smoke( POINT_VEC3.SmokeColor.Green )
|
||||
self:Smoke( SMOKECOLOR.Green )
|
||||
end
|
||||
|
||||
--- Smoke the POINT_VEC3 Red.
|
||||
-- @param #POINT_VEC3 self
|
||||
function POINT_VEC3:SmokeRed()
|
||||
self:F2()
|
||||
self:Smoke( POINT_VEC3.SmokeColor.Red )
|
||||
self:Smoke( SMOKECOLOR.Red )
|
||||
end
|
||||
|
||||
--- Smoke the POINT_VEC3 White.
|
||||
-- @param #POINT_VEC3 self
|
||||
function POINT_VEC3:SmokeWhite()
|
||||
self:F2()
|
||||
self:Smoke( POINT_VEC3.SmokeColor.White )
|
||||
self:Smoke( SMOKECOLOR.White )
|
||||
end
|
||||
|
||||
--- Smoke the POINT_VEC3 Orange.
|
||||
-- @param #POINT_VEC3 self
|
||||
function POINT_VEC3:SmokeOrange()
|
||||
self:F2()
|
||||
self:Smoke( POINT_VEC3.SmokeColor.Orange )
|
||||
self:Smoke( SMOKECOLOR.Orange )
|
||||
end
|
||||
|
||||
--- Smoke the POINT_VEC3 Blue.
|
||||
-- @param #POINT_VEC3 self
|
||||
function POINT_VEC3:SmokeBlue()
|
||||
self:F2()
|
||||
self:Smoke( POINT_VEC3.SmokeColor.Blue )
|
||||
self:Smoke( SMOKECOLOR.Blue )
|
||||
end
|
||||
|
||||
--- Flares the point in a color.
|
||||
-- @param #POINT_VEC3 self
|
||||
-- @param Point#POINT_VEC3.FlareColor
|
||||
-- @param Utils#FLARECOLOR FlareColor
|
||||
-- @param DCSTypes#Azimuth (optional) Azimuth The azimuth of the flare direction. The default azimuth is 0.
|
||||
function POINT_VEC3:Flare( FlareColor, Azimuth )
|
||||
self:F2( { FlareColor } )
|
||||
@@ -545,7 +507,7 @@ end
|
||||
-- @param DCSTypes#Azimuth (optional) Azimuth The azimuth of the flare direction. The default azimuth is 0.
|
||||
function POINT_VEC3:FlareWhite( Azimuth )
|
||||
self:F2( Azimuth )
|
||||
self:Flare( POINT_VEC3.FlareColor.White, Azimuth )
|
||||
self:Flare( FLARECOLOR.White, Azimuth )
|
||||
end
|
||||
|
||||
--- Flare the POINT_VEC3 Yellow.
|
||||
@@ -553,7 +515,7 @@ end
|
||||
-- @param DCSTypes#Azimuth (optional) Azimuth The azimuth of the flare direction. The default azimuth is 0.
|
||||
function POINT_VEC3:FlareYellow( Azimuth )
|
||||
self:F2( Azimuth )
|
||||
self:Flare( POINT_VEC3.FlareColor.Yellow, Azimuth )
|
||||
self:Flare( FLARECOLOR.Yellow, Azimuth )
|
||||
end
|
||||
|
||||
--- Flare the POINT_VEC3 Green.
|
||||
@@ -561,14 +523,14 @@ end
|
||||
-- @param DCSTypes#Azimuth (optional) Azimuth The azimuth of the flare direction. The default azimuth is 0.
|
||||
function POINT_VEC3:FlareGreen( Azimuth )
|
||||
self:F2( Azimuth )
|
||||
self:Flare( POINT_VEC3.FlareColor.Green, Azimuth )
|
||||
self:Flare( FLARECOLOR.Green, Azimuth )
|
||||
end
|
||||
|
||||
--- Flare the POINT_VEC3 Red.
|
||||
-- @param #POINT_VEC3 self
|
||||
function POINT_VEC3:FlareRed( Azimuth )
|
||||
self:F2( Azimuth )
|
||||
self:Flare( POINT_VEC3.FlareColor.Red, Azimuth )
|
||||
self:Flare( FLARECOLOR.Red, Azimuth )
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
--- A ROUTETASK orchestrates the travel to a specific zone defined within the ME.
|
||||
-- @module ROUTETASK
|
||||
|
||||
--- The ROUTETASK class
|
||||
-- @type
|
||||
ROUTETASK = {
|
||||
ClassName = "ROUTETASK",
|
||||
GoalVerb = "Route",
|
||||
}
|
||||
|
||||
--- Creates a new ROUTETASK.
|
||||
-- @param table{sring,...}|string LandingZones Table of Zone Names where the target is located.
|
||||
-- @param string TaskBriefing (optional) Defines a text describing the briefing of the task.
|
||||
-- @return ROUTETASK
|
||||
function ROUTETASK:New( LandingZones, TaskBriefing )
|
||||
local self = BASE:Inherit( self, TASK:New() )
|
||||
self:F( { LandingZones, TaskBriefing } )
|
||||
|
||||
local Valid = true
|
||||
|
||||
Valid = routines.ValidateZone( LandingZones, "LandingZones", Valid )
|
||||
|
||||
if Valid then
|
||||
self.Name = 'Route To Zone'
|
||||
if TaskBriefing then
|
||||
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
|
||||
self.TaskBriefing = "Task: Fly to specified zone(s). Your co-pilot will provide you with the directions (required flight angle in degrees) and the distance (in km) to the target objective."
|
||||
end
|
||||
if type( LandingZones ) == "table" then
|
||||
self.LandingZones = LandingZones
|
||||
else
|
||||
self.LandingZones = { LandingZones }
|
||||
end
|
||||
self.Stages = { STAGEBRIEF:New(), STAGESTART:New(), STAGEROUTE:New(), STAGEARRIVE:New(), STAGEDONE:New() }
|
||||
self.SetStage( self, 1 )
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
@@ -218,13 +218,12 @@
|
||||
--
|
||||
-- ====
|
||||
--
|
||||
-- ### Contributions:
|
||||
--
|
||||
-- * Mechanist : Concept & Testing
|
||||
--
|
||||
-- ### Authors:
|
||||
--
|
||||
-- * FlightControl : Design & Programming
|
||||
--
|
||||
-- ### Contributions:
|
||||
--
|
||||
--
|
||||
-- @module Set
|
||||
|
||||
|
||||
@@ -87,13 +87,25 @@
|
||||
-- This models AI that has succesfully returned to their airbase, to restart their combat activities.
|
||||
-- Check the @{#SPAWN.CleanUp} for further info.
|
||||
--
|
||||
-- 1.6) Call a function new GROUP is spawned.
|
||||
-- ------------------------------------------
|
||||
-- When using the SpawnScheduled class, new GROUPs are created following the schedule timing parameters.
|
||||
-- However, when a new GROUP is spawned, you maybe want to execute actions with that group spawned.
|
||||
-- To achieve this functionality, utilize the @{#SPAWN.OnSpawn}( **function( SpawnedGroup ) end ** ) method, which takes a function as a parameter that you can define locally at the
|
||||
-- OnSpawn() method utilization. Whenever a new GROUP is spawned, the function that is given as a parameter to OnSpawn() will be called.
|
||||
-- This function requires one parameter to be declared, containing the just spawned GROUP object. For an example, consult to function.
|
||||
-- 1.6) Catch the @{Group} Spawn event.
|
||||
-- ------------------------------------
|
||||
-- When using the SpawnScheduled method, new @{Group}s are created following the schedule timing parameters.
|
||||
-- When a new @{Group} is spawned, you maybe want to execute actions with that group spawned at the spawn event.
|
||||
-- To SPAWN class supports this functionality through the @{#SPAWN.OnSpawnGroup}( **function( SpawnedGroup ) end ** ) method, which takes a function as a parameter that you can define locally.
|
||||
-- Whenever a new @{Group} is spawned, the given function is called, and the @{Group} that was just spawned, is given as a parameter.
|
||||
-- As a result, your spawn event handling function requires one parameter to be declared, which will contain the spawned @{Group} object.
|
||||
-- A coding example is provided at the description of the @{#SPAWN.OnSpawnGroup}( **function( SpawnedGroup ) end ** ) method.
|
||||
--
|
||||
-- ====
|
||||
--
|
||||
-- ### Contributions:
|
||||
--
|
||||
-- * Aaron:
|
||||
--
|
||||
-- ### Authors:
|
||||
--
|
||||
-- * FlightControl : Design & Programming
|
||||
--
|
||||
--
|
||||
-- @module Spawn
|
||||
-- @author FlightControl
|
||||
@@ -116,7 +128,7 @@ SPAWN = {
|
||||
|
||||
|
||||
|
||||
--- Creates the main object to spawn a GROUP defined in the DCS ME.
|
||||
--- Creates the main object to spawn a @{Group} defined in the DCS ME.
|
||||
-- @param #SPAWN self
|
||||
-- @param #string SpawnTemplatePrefix is the name of the Group in the ME that defines the Template. Each new group will have the name starting with SpawnTemplatePrefix.
|
||||
-- @return #SPAWN
|
||||
@@ -735,7 +747,7 @@ end
|
||||
-- The **first waypoint** (where the group is spawned) is replaced with the zone location coordinates.
|
||||
-- @param #SPAWN self
|
||||
-- @param Zone#ZONE Zone The zone where the group is to be spawned.
|
||||
-- @param #boolean RandomizeGroup (optional) Randomization of the @{GROUP} position in the zone.
|
||||
-- @param #boolean RandomizeGroup (optional) Randomization of the @{Group} position in the zone.
|
||||
-- @param #number SpawnIndex (optional) The index which group to spawn within the given zone.
|
||||
-- @return Group#GROUP that was spawned.
|
||||
-- @return #nil when nothing was spawned.
|
||||
@@ -753,13 +765,11 @@ function SPAWN:SpawnInZone( Zone, RandomizeGroup, SpawnIndex )
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
--- Will spawn a plane group in uncontrolled mode...
|
||||
--- (AIR) Will spawn a plane group in uncontrolled mode...
|
||||
-- This will be similar to the uncontrolled flag setting in the ME.
|
||||
-- @param #SPAWN self
|
||||
-- @return #SPAWN self
|
||||
function SPAWN:UnControlled()
|
||||
function SPAWN:InitUnControlled()
|
||||
self:F( { self.SpawnTemplatePrefix } )
|
||||
|
||||
self.SpawnUnControlled = true
|
||||
@@ -796,12 +806,12 @@ function SPAWN:SpawnGroupName( SpawnIndex )
|
||||
|
||||
end
|
||||
|
||||
--- Will find the first alive GROUP it has spawned, and return the alive GROUP object and the first Index where the first alive GROUP object has been found.
|
||||
--- Will find the first alive @{Group} it has spawned, and return the alive @{Group} object and the first Index where the first alive @{Group} object has been found.
|
||||
-- @param #SPAWN self
|
||||
-- @return Group#GROUP, #number The GROUP object found, the new Index where the group was found.
|
||||
-- @return Group#GROUP, #number The @{Group} object found, the new Index where the group was found.
|
||||
-- @return #nil, #nil When no group is found, #nil is returned.
|
||||
-- @usage
|
||||
-- -- Find the first alive GROUP object of the SpawnPlanes SPAWN object GROUP collection that it has spawned during the mission.
|
||||
-- -- Find the first alive @{Group} object of the SpawnPlanes SPAWN object @{Group} collection that it has spawned during the mission.
|
||||
-- local GroupPlane, Index = SpawnPlanes:GetFirstAliveGroup()
|
||||
-- while GroupPlane ~= nil do
|
||||
-- -- Do actions with the GroupPlane object.
|
||||
@@ -821,13 +831,13 @@ function SPAWN:GetFirstAliveGroup()
|
||||
end
|
||||
|
||||
|
||||
--- Will find the next alive GROUP object from a given Index, and return a reference to the alive GROUP object and the next Index where the alive GROUP has been found.
|
||||
--- Will find the next alive @{Group} object from a given Index, and return a reference to the alive @{Group} object and the next Index where the alive @{Group} has been found.
|
||||
-- @param #SPAWN self
|
||||
-- @param #number SpawnIndexStart A Index holding the start position to search from. This function can also be used to find the first alive GROUP object from the given Index.
|
||||
-- @return Group#GROUP, #number The next alive GROUP object found, the next Index where the next alive GROUP object was found.
|
||||
-- @return #nil, #nil When no alive GROUP object is found from the start Index position, #nil is returned.
|
||||
-- @param #number SpawnIndexStart A Index holding the start position to search from. This function can also be used to find the first alive @{Group} object from the given Index.
|
||||
-- @return Group#GROUP, #number The next alive @{Group} object found, the next Index where the next alive @{Group} object was found.
|
||||
-- @return #nil, #nil When no alive @{Group} object is found from the start Index position, #nil is returned.
|
||||
-- @usage
|
||||
-- -- Find the first alive GROUP object of the SpawnPlanes SPAWN object GROUP collection that it has spawned during the mission.
|
||||
-- -- Find the first alive @{Group} object of the SpawnPlanes SPAWN object @{Group} collection that it has spawned during the mission.
|
||||
-- local GroupPlane, Index = SpawnPlanes:GetFirstAliveGroup()
|
||||
-- while GroupPlane ~= nil do
|
||||
-- -- Do actions with the GroupPlane object.
|
||||
@@ -847,12 +857,12 @@ function SPAWN:GetNextAliveGroup( SpawnIndexStart )
|
||||
return nil, nil
|
||||
end
|
||||
|
||||
--- Will find the last alive GROUP object, and will return a reference to the last live GROUP object and the last Index where the last alive GROUP object has been found.
|
||||
--- Will find the last alive @{Group} object, and will return a reference to the last live @{Group} object and the last Index where the last alive @{Group} object has been found.
|
||||
-- @param #SPAWN self
|
||||
-- @return Group#GROUP, #number The last alive GROUP object found, the last Index where the last alive GROUP object was found.
|
||||
-- @return #nil, #nil When no alive GROUP object is found, #nil is returned.
|
||||
-- @return Group#GROUP, #number The last alive @{Group} object found, the last Index where the last alive @{Group} object was found.
|
||||
-- @return #nil, #nil When no alive @{Group} object is found, #nil is returned.
|
||||
-- @usage
|
||||
-- -- Find the last alive GROUP object of the SpawnPlanes SPAWN object GROUP collection that it has spawned during the mission.
|
||||
-- -- Find the last alive @{Group} object of the SpawnPlanes SPAWN object @{Group} collection that it has spawned during the mission.
|
||||
-- local GroupPlane, Index = SpawnPlanes:GetLastAliveGroup()
|
||||
-- if GroupPlane then -- GroupPlane can be nil!!!
|
||||
-- -- Do actions with the GroupPlane object.
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
--- This module contains derived utilities taken from the MIST framework,
|
||||
-- which are excellent tools to be reused in an OO environment!.
|
||||
--
|
||||
-- ### Authors:
|
||||
--
|
||||
-- * Grimes : Design & Programming of the MIST framework.
|
||||
--
|
||||
-- ### Contributions:
|
||||
--
|
||||
-- * FlightControl : Rework to OO framework
|
||||
--
|
||||
-- @module Utils
|
||||
|
||||
|
||||
--- @type SMOKECOLOR
|
||||
-- @field Green
|
||||
|
||||
@@ -22,46 +22,94 @@
|
||||
-- * @{Zone#ZONE_GROUP}: The ZONE_GROUP class defines by a zone around a @{Group#GROUP} with a radius.
|
||||
-- * @{Zone#ZONE_POLYGON}: The ZONE_POLYGON class defines by a sequence of @{Group#GROUP} waypoints within the Mission Editor, forming a polygon.
|
||||
--
|
||||
-- Each zone implements two polymorphic functions defined in @{Zone#ZONE_BASE}:
|
||||
--
|
||||
-- * @{#ZONE_BASE.IsPointVec2InZone}: Returns if a location is within the zone.
|
||||
-- * @{#ZONE_BASE.IsPointVec3InZone}: Returns if a point is within the zone.
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- 1) @{Zone#ZONE_BASE} class, extends @{Base#BASE}
|
||||
-- ================================================
|
||||
-- The ZONE_BASE class defining the base for all other zone classes.
|
||||
-- This class is an abstract BASE class for derived classes, and is not meant to be instantiated.
|
||||
--
|
||||
-- ### 1.1) Each zone implements two polymorphic functions defined in @{Zone#ZONE_BASE}:
|
||||
--
|
||||
-- * @{#ZONE_BASE.IsPointVec2InZone}(): Returns if a @{Point#POINT_VEC2} is within the zone.
|
||||
-- * @{#ZONE_BASE.IsPointVec3InZone}(): Returns if a @{Point#POINT_VEC3} is within the zone.
|
||||
--
|
||||
-- ### 1.2) A zone has a probability factor that can be set to randomize a selection between zones:
|
||||
--
|
||||
-- * @{#ZONE_BASE.SetRandomizeProbability}(): Set the randomization probability of a zone to be selected, taking a value between 0 and 1 ( 0 = 0%, 1 = 100% )
|
||||
-- * @{#ZONE_BASE.GetRandomizeProbability}(): Get the randomization probability of a zone to be selected, passing a value between 0 and 1 ( 0 = 0%, 1 = 100% )
|
||||
-- * @{#ZONE_BASE.GetZoneRandomize}(): Get the zone taking into account the randomization probability. nil is returned if this zone is not a candidate.
|
||||
--
|
||||
-- ### 1.3) A zone manages Vectors:
|
||||
--
|
||||
-- * @{#ZONE_BASE.GetVec2}(): Returns the @{DCSTypes#Vec2} coordinate of the zone.
|
||||
-- * @{#ZONE_BASE.GetRandomVec2}(): Define a random @{DCSTypes#Vec2} within the zone.
|
||||
--
|
||||
-- ### 1.4) A zone has a bounding square:
|
||||
--
|
||||
-- * @{#ZONE_BASE.GetBoundingSquare}(): Get the outer most bounding square of the zone.
|
||||
--
|
||||
-- ### 1.5) A zone can be marked:
|
||||
--
|
||||
-- * @{#ZONE_BASE.SmokeZone}(): Smokes the zone boundaries in a color.
|
||||
-- * @{#ZONE_BASE.FlareZone}(): Flares the zone boundaries in a color.
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- 2) @{Zone#ZONE_RADIUS} class, extends @{Zone#ZONE_BASE}
|
||||
-- =======================================================
|
||||
-- The ZONE_RADIUS class defined by a zone name, a location and a radius.
|
||||
-- This class implements the inherited functions from Zone#ZONE_BASE taking into account the own zone format and properties.
|
||||
--
|
||||
-- ### 2.1) @{Zone#ZONE_RADIUS} constructor:
|
||||
--
|
||||
-- * @{#ZONE_BASE.New}(): Constructor.
|
||||
--
|
||||
-- ### 2.2) Manage the radius of the zone:
|
||||
--
|
||||
-- * @{#ZONE_BASE.SetRadius}(): Sets the radius of the zone.
|
||||
-- * @{#ZONE_BASE.GetRadius}(): Returns the radius of the zone.
|
||||
--
|
||||
-- ### 2.3) Manage the location of the zone:
|
||||
--
|
||||
-- * @{#ZONE_BASE.SetVec2}(): Sets the @{DCSTypes#Vec2} of the zone.
|
||||
-- * @{#ZONE_BASE.GetVec2}(): Returns the @{DCSTypes#Vec2} of the zone.
|
||||
-- * @{#ZONE_BASE.GetVec3}(): Returns the @{DCSTypes#Vec3} of the zone, taking an additional height parameter.
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- 3) @{Zone#ZONE} class, extends @{Zone#ZONE_RADIUS}
|
||||
-- ==========================================
|
||||
-- The ZONE class, defined by the zone name as defined within the Mission Editor.
|
||||
-- This class implements the inherited functions from {Zone#ZONE_RADIUS} taking into account the own zone format and properties.
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- 4) @{Zone#ZONE_UNIT} class, extends @{Zone#ZONE_RADIUS}
|
||||
-- =======================================================
|
||||
-- The ZONE_UNIT class defined by a zone around a @{Unit#UNIT} with a radius.
|
||||
-- This class implements the inherited functions from @{Zone#ZONE_RADIUS} taking into account the own zone format and properties.
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- 5) @{Zone#ZONE_GROUP} class, extends @{Zone#ZONE_RADIUS}
|
||||
-- =======================================================
|
||||
-- The ZONE_GROUP class defines by a zone around a @{Group#GROUP} with a radius. The current leader of the group defines the center of the zone.
|
||||
-- This class implements the inherited functions from @{Zone#ZONE_RADIUS} taking into account the own zone format and properties.
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- 6) @{Zone#ZONE_POLYGON} class, extends @{Zone#ZONE_BASE}
|
||||
-- 6) @{Zone#ZONE_POLYGON_BASE} class, extends @{Zone#ZONE_BASE}
|
||||
-- ========================================================
|
||||
-- The ZONE_POLYGON_BASE class defined by a sequence of @{Group#GROUP} waypoints within the Mission Editor, forming a polygon.
|
||||
-- This class implements the inherited functions from @{Zone#ZONE_RADIUS} taking into account the own zone format and properties.
|
||||
-- This class is an abstract BASE class for derived classes, and is not meant to be instantiated.
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- 7) @{Zone#ZONE_POLYGON} class, extends @{Zone#ZONE_POLYGON_BASE}
|
||||
-- ================================================================
|
||||
-- The ZONE_POLYGON class defined by a sequence of @{Group#GROUP} waypoints within the Mission Editor, forming a polygon.
|
||||
-- This class implements the inherited functions from @{Zone#ZONE_RADIUS} taking into account the own zone format and properties.
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
@@ -72,9 +120,12 @@
|
||||
--- The ZONE_BASE class
|
||||
-- @type ZONE_BASE
|
||||
-- @field #string ZoneName Name of the zone.
|
||||
-- @field #number RandomizationProbability A value between 0 and 1. 0 = 0% and 1 = 100% probability.
|
||||
-- @extends Base#BASE
|
||||
ZONE_BASE = {
|
||||
ClassName = "ZONE_BASE",
|
||||
ZoneName = "",
|
||||
RandomizationProbability = 1,
|
||||
}
|
||||
|
||||
|
||||
@@ -121,7 +172,7 @@ function ZONE_BASE:IsPointVec3InZone( Vec3 )
|
||||
return InZone
|
||||
end
|
||||
|
||||
--- Returns the Vec2 coordinate of the zone.
|
||||
--- Returns the @{DCSTypes#Vec2} coordinate of the zone.
|
||||
-- @param #ZONE_BASE self
|
||||
-- @return #nil.
|
||||
function ZONE_BASE:GetVec2()
|
||||
@@ -153,6 +204,39 @@ function ZONE_BASE:SmokeZone( SmokeColor )
|
||||
|
||||
end
|
||||
|
||||
--- Set the randomization probability of a zone to be selected.
|
||||
-- @param #ZONE_BASE self
|
||||
-- @param RandomizationProbability A value between 0 and 1. 0 = 0% and 1 = 100% probability.
|
||||
function ZONE_BASE:SetRandomizationProbability( RandomizationProbability )
|
||||
self:F2( RandomizationProbability )
|
||||
|
||||
self.RandomizationProbability = RandomizationProbability or 1
|
||||
end
|
||||
|
||||
--- Get the randomization probability of a zone to be selected.
|
||||
-- @param #ZONE_BASE self
|
||||
-- @return #number A value between 0 and 1. 0 = 0% and 1 = 100% probability.
|
||||
function ZONE_BASE:GetRandomizationProbability()
|
||||
self:F2()
|
||||
|
||||
return self.RandomizationProbability
|
||||
end
|
||||
|
||||
--- Get the zone taking into account the randomization probability of a zone to be selected.
|
||||
-- @param #ZONE_BASE self
|
||||
-- @return #ZONE_BASE The zone is selected taking into account the randomization probability factor.
|
||||
-- @return #nil The zone is not selected taking into account the randomization probability factor.
|
||||
function ZONE_BASE:GetZoneRandomized()
|
||||
self:F2()
|
||||
|
||||
local Randomization = math.random()
|
||||
if Randomization <= self.RandomizationProbability then
|
||||
return self
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--- The ZONE_RADIUS class, defined by a zone name, a location and a radius.
|
||||
-- @type ZONE_RADIUS
|
||||
@@ -163,7 +247,7 @@ ZONE_RADIUS = {
|
||||
ClassName="ZONE_RADIUS",
|
||||
}
|
||||
|
||||
--- Constructor of ZONE_RADIUS, taking the zone name, the zone location and a radius.
|
||||
--- Constructor of @{#ZONE_RADIUS}, taking the zone name, the zone location and a radius.
|
||||
-- @param #ZONE_RADIUS self
|
||||
-- @param #string ZoneName Name of the zone.
|
||||
-- @param DCSTypes#Vec2 Vec2 The location of the zone.
|
||||
@@ -208,7 +292,7 @@ end
|
||||
|
||||
--- Flares the zone boundaries in a color.
|
||||
-- @param #ZONE_RADIUS self
|
||||
-- @param #POINT_VEC3.FlareColor FlareColor The flare color.
|
||||
-- @param Utils#FLARECOLOR FlareColor The flare color.
|
||||
-- @param #number Points (optional) The amount of points in the circle.
|
||||
-- @param DCSTypes#Azimuth Azimuth (optional) Azimuth The azimuth of the flare.
|
||||
-- @return #ZONE_RADIUS self
|
||||
@@ -257,7 +341,7 @@ function ZONE_RADIUS:SetRadius( Radius )
|
||||
return self.Radius
|
||||
end
|
||||
|
||||
--- Returns the location of the zone.
|
||||
--- Returns the @{DCSTypes#Vec2} of the zone.
|
||||
-- @param #ZONE_RADIUS self
|
||||
-- @return DCSTypes#Vec2 The location of the zone.
|
||||
function ZONE_RADIUS:GetVec2()
|
||||
@@ -268,11 +352,11 @@ function ZONE_RADIUS:GetVec2()
|
||||
return self.Vec2
|
||||
end
|
||||
|
||||
--- Sets the location of the zone.
|
||||
--- Sets the @{DCSTypes#Vec2} of the zone.
|
||||
-- @param #ZONE_RADIUS self
|
||||
-- @param DCSTypes#Vec2 Vec2 The new location of the zone.
|
||||
-- @return DCSTypes#Vec2 The new location of the zone.
|
||||
function ZONE_RADIUS:SetPointVec2( Vec2 )
|
||||
function ZONE_RADIUS:SetVec2( Vec2 )
|
||||
self:F2( self.ZoneName )
|
||||
|
||||
self.Vec2 = Vec2
|
||||
|
||||
Reference in New Issue
Block a user