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:
158
Moose Development/Old/DeployTask.lua
Normal file
158
Moose Development/Old/DeployTask.lua
Normal file
@@ -0,0 +1,158 @@
|
||||
--- 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
|
||||
81
Moose Development/Old/DestroyBaseTask.lua
Normal file
81
Moose Development/Old/DestroyBaseTask.lua
Normal file
@@ -0,0 +1,81 @@
|
||||
--- 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
|
||||
57
Moose Development/Old/DestroyGroupsTask.lua
Normal file
57
Moose Development/Old/DestroyGroupsTask.lua
Normal file
@@ -0,0 +1,57 @@
|
||||
--- 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
|
||||
41
Moose Development/Old/DestroyRadarsTask.lua
Normal file
41
Moose Development/Old/DestroyRadarsTask.lua
Normal file
@@ -0,0 +1,41 @@
|
||||
--- 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
|
||||
52
Moose Development/Old/DestroyUnitTypesTask.lua
Normal file
52
Moose Development/Old/DestroyUnitTypesTask.lua
Normal file
@@ -0,0 +1,52 @@
|
||||
--- 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
|
||||
33
Moose Development/Old/GoHomeTask.lua
Normal file
33
Moose Development/Old/GoHomeTask.lua
Normal file
@@ -0,0 +1,33 @@
|
||||
--- 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
|
||||
25
Moose Development/Old/NoTask.lua
Normal file
25
Moose Development/Old/NoTask.lua
Normal file
@@ -0,0 +1,25 @@
|
||||
--- 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
|
||||
153
Moose Development/Old/PickupTask.lua
Normal file
153
Moose Development/Old/PickupTask.lua
Normal file
@@ -0,0 +1,153 @@
|
||||
--- 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
|
||||
|
||||
41
Moose Development/Old/RouteTask.lua
Normal file
41
Moose Development/Old/RouteTask.lua
Normal file
@@ -0,0 +1,41 @@
|
||||
--- 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
|
||||
|
||||
Reference in New Issue
Block a user