Lots of fixes for cargo + optimization of Stage Messages

This commit is contained in:
svenvandevelde 2016-02-25 14:52:16 +01:00
parent 9c2741e758
commit 6955d45840
14 changed files with 640 additions and 430 deletions

View File

@ -156,9 +156,20 @@ trace.f( self.ClassName, { EventTime, Initiator, IniUnitName, place, subplace }
subplace = subplace subplace = subplace
} }
world.onEvent( Event ) world.onEvent( Event )
end end
function BASE:CreateEventCrash( EventTime, Initiator )
trace.f( self.ClassName, { EventTime, Initiator } )
local Event = {
id = world.event.S_EVENT_CRASH,
time = EventTime,
initiator = Initiator,
}
world.onEvent( Event )
end
function BASE:onEvent(event) function BASE:onEvent(event)
--trace.f(self.ClassName, event ) --trace.f(self.ClassName, event )
@ -204,6 +215,6 @@ function BASE:T( Arguments )
local Line = DebugInfo.currentline local Line = DebugInfo.currentline
env.info( string.format( "%6d/%1s:%20s.%s\(%s\)" , Line, "T", self.ClassName, Function .. routines.utils.oneLineSerialize( Arguments ) ) ) env.info( string.format( "%6d/%1s:%20s.%s\(%s\)" , Line, "T", self.ClassName, Function, routines.utils.oneLineSerialize( Arguments ) ) )
end end
end end

View File

@ -31,24 +31,25 @@ CARGO_ZONE = {
} }
} }
function CARGO_ZONE:New( CargoZoneName, CargoHostName ) function CARGO_ZONE:New( CargoZoneName, CargoHostName ) local self = BASE:Inherit( self, BASE:New() )
trace.f( self.ClassName, { CargoZoneName, CargoHostName } ) self:T( { CargoZoneName, CargoHostName } )
local self = BASE:Inherit( self, BASE:New() )
self.CargoZoneName = CargoZoneName self.CargoZoneName = CargoZoneName
self.CargoZone = trigger.misc.getZone( CargoZoneName ) self.CargoZone = trigger.misc.getZone( CargoZoneName )
if CargoHostName then if CargoHostName then
self.CargoHostName = CargoHostName self.CargoHostName = CargoHostName
self.CargoHostSpawn = SPAWN:New( CargoHostName ) self.CargoHostSpawn = SPAWN:New( CargoHostName )
end end
self:T( self.CargoZone )
return self return self
end end
function CARGO_ZONE:Spawn() function CARGO_ZONE:Spawn()
trace.f( self.ClassName, CargoHostSpawn ) self:T( CargoHostSpawn )
if self.CargoHostSpawn then if self.CargoHostSpawn then
local CargoHostGroup = Group.getByName( self.CargoHostSpawn:SpawnGroupName() ) local CargoHostGroup = Group.getByName( self.CargoHostSpawn:SpawnGroupName() )
@ -84,7 +85,7 @@ function CARGO_ZONE:GetHostUnit()
end end
function CARGO_ZONE:ReportCargosToClient( Client, CargoType ) function CARGO_ZONE:ReportCargosToClient( Client, CargoType )
trace.f( self.ClassName ) self:T()
local SignalUnit = self:GetHostUnit() local SignalUnit = self:GetHostUnit()
@ -95,23 +96,25 @@ trace.f( self.ClassName )
local HostMessage = "" local HostMessage = ""
local IsCargo = false local IsCargo = false
for CargoID, Cargo in pairs( Cargos ) do for CargoID, Cargo in pairs( CARGOS ) do
if Cargo.CargoType == Task.CargoType then if Cargo.CargoType == Task.CargoType then
HostMessage = HostMessage .. "\n - " .. Cargo.CargoName if Cargo:IsStatusNone() then
IsCargo = true HostMessage = HostMessage .. " - " .. Cargo.CargoName .. " - " .. Cargo.CargoType .. " (" .. Cargo.Weight .. "kg)" .. "\n"
IsCargo = true
end
end end
end end
if not IsCargo then if not IsCargo then
HostMessage = HostMessage .. "No Cargo Available." HostMessage = "No Cargo Available."
end end
Client:Message( RouteMessage, self.MSG.TIME, Mission.Name .. "/StageHosts." .. SignalUnitTypeName, SignalUnitTypeName .. ": Reporting Cargo", 10 ) Client:Message( HostMessage, 20, Mission.Name .. "/StageHosts." .. SignalUnitTypeName, SignalUnitTypeName .. ": Reporting Cargo", 10 )
end end
end end
function CARGO_ZONE:Signal() function CARGO_ZONE:Signal()
trace.f( self.ClassName ) self:T()
local Signalled = false local Signalled = false
@ -125,7 +128,7 @@ trace.f( self.ClassName )
if SignalUnit then if SignalUnit then
trace.i( self.ClassName, 'Signalling Unit' ) self:T( 'Signalling Unit' )
local SignalVehiclePos = SignalUnit:getPosition().p local SignalVehiclePos = SignalUnit:getPosition().p
SignalVehiclePos.y = SignalVehiclePos.y + 2 SignalVehiclePos.y = SignalVehiclePos.y + 2
@ -165,7 +168,7 @@ trace.f( self.ClassName )
end end
function CARGO_ZONE:WhiteSmoke() function CARGO_ZONE:WhiteSmoke()
trace.f( self.ClassName ) self:T()
self.SignalType = CARGO_ZONE.SIGNAL.TYPE.SMOKE self.SignalType = CARGO_ZONE.SIGNAL.TYPE.SMOKE
self.SignalColor = CARGO_ZONE.SIGNAL.COLOR.WHITE self.SignalColor = CARGO_ZONE.SIGNAL.COLOR.WHITE
@ -174,7 +177,7 @@ trace.f( self.ClassName )
end end
function CARGO_ZONE:BlueSmoke() function CARGO_ZONE:BlueSmoke()
trace.f( self.ClassName ) self:T()
self.SignalType = CARGO_ZONE.SIGNAL.TYPE.SMOKE self.SignalType = CARGO_ZONE.SIGNAL.TYPE.SMOKE
self.SignalColor = CARGO_ZONE.SIGNAL.COLOR.BLUE self.SignalColor = CARGO_ZONE.SIGNAL.COLOR.BLUE
@ -183,7 +186,7 @@ trace.f( self.ClassName )
end end
function CARGO_ZONE:RedSmoke() function CARGO_ZONE:RedSmoke()
trace.f( self.ClassName ) self:T()
self.SignalType = CARGO_ZONE.SIGNAL.TYPE.SMOKE self.SignalType = CARGO_ZONE.SIGNAL.TYPE.SMOKE
self.SignalColor = CARGO_ZONE.SIGNAL.COLOR.RED self.SignalColor = CARGO_ZONE.SIGNAL.COLOR.RED
@ -192,7 +195,7 @@ trace.f( self.ClassName )
end end
function CARGO_ZONE:OrangeSmoke() function CARGO_ZONE:OrangeSmoke()
trace.f( self.ClassName ) self:T()
self.SignalType = CARGO_ZONE.SIGNAL.TYPE.SMOKE self.SignalType = CARGO_ZONE.SIGNAL.TYPE.SMOKE
self.SignalColor = CARGO_ZONE.SIGNAL.COLOR.ORANGE self.SignalColor = CARGO_ZONE.SIGNAL.COLOR.ORANGE
@ -201,7 +204,7 @@ trace.f( self.ClassName )
end end
function CARGO_ZONE:GreenSmoke() function CARGO_ZONE:GreenSmoke()
trace.f( self.ClassName ) self:T()
self.SignalType = CARGO_ZONE.SIGNAL.TYPE.SMOKE self.SignalType = CARGO_ZONE.SIGNAL.TYPE.SMOKE
self.SignalColor = CARGO_ZONE.SIGNAL.COLOR.GREEN self.SignalColor = CARGO_ZONE.SIGNAL.COLOR.GREEN
@ -211,7 +214,7 @@ end
function CARGO_ZONE:WhiteFlare() function CARGO_ZONE:WhiteFlare()
trace.f( self.ClassName ) self:T()
self.SignalType = CARGO_ZONE.SIGNAL.TYPE.FLARE self.SignalType = CARGO_ZONE.SIGNAL.TYPE.FLARE
self.SignalColor = CARGO_ZONE.SIGNAL.COLOR.WHITE self.SignalColor = CARGO_ZONE.SIGNAL.COLOR.WHITE
@ -220,7 +223,7 @@ trace.f( self.ClassName )
end end
function CARGO_ZONE:RedFlare() function CARGO_ZONE:RedFlare()
trace.f( self.ClassName ) self:T()
self.SignalType = CARGO_ZONE.SIGNAL.TYPE.FLARE self.SignalType = CARGO_ZONE.SIGNAL.TYPE.FLARE
self.SignalColor = CARGO_ZONE.SIGNAL.COLOR.RED self.SignalColor = CARGO_ZONE.SIGNAL.COLOR.RED
@ -229,7 +232,7 @@ trace.f( self.ClassName )
end end
function CARGO_ZONE:GreenFlare() function CARGO_ZONE:GreenFlare()
trace.f( self.ClassName ) self:T()
self.SignalType = CARGO_ZONE.SIGNAL.TYPE.FLARE self.SignalType = CARGO_ZONE.SIGNAL.TYPE.FLARE
self.SignalColor = CARGO_ZONE.SIGNAL.COLOR.GREEN self.SignalColor = CARGO_ZONE.SIGNAL.COLOR.GREEN
@ -238,7 +241,7 @@ trace.f( self.ClassName )
end end
function CARGO_ZONE:YellowFlare() function CARGO_ZONE:YellowFlare()
trace.f( self.ClassName ) self:T()
self.SignalType = CARGO_ZONE.SIGNAL.TYPE.FLARE self.SignalType = CARGO_ZONE.SIGNAL.TYPE.FLARE
self.SignalColor = CARGO_ZONE.SIGNAL.COLOR.YELLOW self.SignalColor = CARGO_ZONE.SIGNAL.COLOR.YELLOW
@ -248,7 +251,7 @@ end
function CARGO_ZONE:GetCargoHostUnit() function CARGO_ZONE:GetCargoHostUnit()
trace.f( self.ClassName ) self:T()
local CargoHostUnit = Group.getByName( self.CargoHostSpawn:SpawnGroupName() ):getUnit(1) local CargoHostUnit = Group.getByName( self.CargoHostSpawn:SpawnGroupName() ):getUnit(1)
if CargoHostUnit and CargoHostUnit:isExist() then if CargoHostUnit and CargoHostUnit:isExist() then
@ -259,7 +262,7 @@ trace.f( self.ClassName )
end end
function CARGO_ZONE:GetCargoZoneName() function CARGO_ZONE:GetCargoZoneName()
trace.f( self.ClassName ) self:T()
return self.CargoZoneName return self.CargoZoneName
end end
@ -276,10 +279,9 @@ CARGO = {
} }
--- Add Cargo to the mission... Cargo functionality needs to be reworked a bit, so this is still under construction. I need to make a CARGO Class... --- Add Cargo to the mission... Cargo functionality needs to be reworked a bit, so this is still under construction. I need to make a CARGO Class...
function CARGO:New( CargoType, CargoName, CargoWeight ) function CARGO:New( CargoType, CargoName, CargoWeight ) local self = BASE:Inherit( self, BASE:New() )
trace.f( self.ClassName, { CargoType, CargoName, CargoWeight } ) self:T( { CargoType, CargoName, CargoWeight } )
local self = BASE:Inherit( self, BASE:New() )
self.CargoType = CargoType self.CargoType = CargoType
self.CargoName = CargoName self.CargoName = CargoName
@ -291,14 +293,14 @@ trace.f( self.ClassName, { CargoType, CargoName, CargoWeight } )
end end
function CARGO:Spawn() function CARGO:Spawn()
trace.f( self.ClassName ) self:T()
return self return self
end end
function CARGO:IsNear( Client, LandingZone ) function CARGO:IsNear( Client, LandingZone )
trace.f( self.ClassName ) self:T()
local Near = true local Near = true
@ -307,7 +309,7 @@ trace.f( self.ClassName )
end end
function CARGO:IsLoadedInClient() function CARGO:IsLoadedInClient()
trace.f( self.ClassName ) self:T()
if self:IsStatusLoaded() or self:IsStatusLoading() then if self:IsStatusLoaded() or self:IsStatusLoading() then
return self.CargoClient return self.CargoClient
@ -319,7 +321,7 @@ end
function CARGO:UnLoad( Client, TargetZoneName ) function CARGO:UnLoad( Client, TargetZoneName )
trace.f( self.ClassName ) self:T()
self:StatusUnLoaded() self:StatusUnLoaded()
@ -327,7 +329,7 @@ trace.f( self.ClassName )
end end
function CARGO:OnBoard( Client, LandingZone ) function CARGO:OnBoard( Client, LandingZone )
trace.f(self.ClassName ) self:T()
local Valid = true local Valid = true
@ -338,7 +340,7 @@ trace.f(self.ClassName )
end end
function CARGO:OnBoarded( Client, LandingZone ) function CARGO:OnBoarded( Client, LandingZone )
trace.f(self.ClassName ) self:T()
local OnBoarded = true local OnBoarded = true
@ -346,7 +348,7 @@ trace.f(self.ClassName )
end end
function CARGO:Load( Client ) function CARGO:Load( Client )
trace.f( self.ClassName ) self:T()
self:StatusLoaded( Client ) self:StatusLoaded( Client )
@ -354,18 +356,18 @@ trace.f( self.ClassName )
end end
function CARGO:IsLandingRequired() function CARGO:IsLandingRequired()
trace.f( self.ClassName ) self:T()
return true return true
end end
function CARGO:IsSlingLoad() function CARGO:IsSlingLoad()
trace.f( self.ClassName ) self:T()
return false return false
end end
function CARGO:StatusNone() function CARGO:StatusNone()
trace.f(self.ClassName ) self:T()
self.CargoClient = nil self.CargoClient = nil
self.CargoStatus = CARGO.STATUS.NONE self.CargoStatus = CARGO.STATUS.NONE
@ -374,16 +376,17 @@ trace.f(self.ClassName )
end end
function CARGO:StatusLoading( Client ) function CARGO:StatusLoading( Client )
trace.f(self.ClassName ) self:T()
self.CargoClient = Client self.CargoClient = Client
self.CargoStatus = CARGO.STATUS.LOADING self.CargoStatus = CARGO.STATUS.LOADING
self:T( "Cargo loaded in Client: " .. CargoClient:GetClientGroupName() )
return self return self
end end
function CARGO:StatusLoaded( Client ) function CARGO:StatusLoaded( Client )
trace.f(self.ClassName ) self:T()
self.CargoClient = Client self.CargoClient = Client
self.CargoStatus = CARGO.STATUS.LOADED self.CargoStatus = CARGO.STATUS.LOADED
@ -392,7 +395,7 @@ trace.f(self.ClassName )
end end
function CARGO:StatusUnLoaded() function CARGO:StatusUnLoaded()
trace.f(self.ClassName ) self:T()
self.CargoClient = nil self.CargoClient = nil
self.CargoStatus = CARGO.STATUS.UNLOADED self.CargoStatus = CARGO.STATUS.UNLOADED
@ -402,25 +405,25 @@ end
function CARGO:IsStatusNone() function CARGO:IsStatusNone()
trace.f(self.ClassName ) self:T()
return self.CargoStatus == CARGO.STATUS.NONE return self.CargoStatus == CARGO.STATUS.NONE
end end
function CARGO:IsStatusLoading() function CARGO:IsStatusLoading()
trace.f(self.ClassName ) self:T()
return self.CargoStatus == CARGO.STATUS.LOADING return self.CargoStatus == CARGO.STATUS.LOADING
end end
function CARGO:IsStatusLoaded() function CARGO:IsStatusLoaded()
trace.f(self.ClassName ) self:T()
return self.CargoStatus == CARGO.STATUS.LOADED return self.CargoStatus == CARGO.STATUS.LOADED
end end
function CARGO:IsStatusUnLoaded() function CARGO:IsStatusUnLoaded()
trace.f(self.ClassName ) self:T()
return self.CargoStatus == CARGO.STATUS.UNLOADED return self.CargoStatus == CARGO.STATUS.UNLOADED
end end
@ -431,12 +434,9 @@ CARGO_GROUP = {
} }
function CARGO_GROUP:New( CargoType, CargoName, CargoWeight, CargoGroupTemplate, CargoZone ) function CARGO_GROUP:New( CargoType, CargoName, CargoWeight, CargoGroupTemplate, CargoZone ) local self = BASE:Inherit( self, CARGO:New( CargoType, CargoName, CargoWeight ) )
trace.f( self.ClassName, { CargoType, CargoName, CargoWeight, CargoGroupTemplate, CargoZone } ) self:T( { CargoType, CargoName, CargoWeight, CargoGroupTemplate, CargoZone } )
-- Arrange meta tables
local self = BASE:Inherit( self, CARGO:New( CargoType, CargoName, CargoWeight ) )
self.CargoSpawn = SPAWN:New( CargoGroupTemplate ) self.CargoSpawn = SPAWN:New( CargoGroupTemplate )
self.CargoZone = CargoZone self.CargoZone = CargoZone
@ -447,7 +447,7 @@ trace.f( self.ClassName, { CargoType, CargoName, CargoWeight, CargoGroupTemplate
end end
function CARGO_GROUP:Spawn() function CARGO_GROUP:Spawn()
trace.f( self.ClassName ) self:T()
local SpawnCargo = true local SpawnCargo = true
@ -477,13 +477,13 @@ trace.f( self.ClassName )
self:StatusNone() self:StatusNone()
end end
trace.i( self.ClassName, { self.CargoGroupName, CARGOS[self.CargoName].CargoGroupName } ) self:T( { self.CargoGroupName, CARGOS[self.CargoName].CargoGroupName } )
return self return self
end end
function CARGO_GROUP:IsNear( Client, LandingZone ) function CARGO_GROUP:IsNear( Client, LandingZone )
trace.f( self.ClassName ) self:T()
local Near = false local Near = false
@ -498,8 +498,9 @@ trace.f( self.ClassName )
end end
function CARGO_GROUP:OnBoard( Client, LandingZone, OnBoardSide ) function CARGO_GROUP:OnBoard( Client, LandingZone, OnBoardSide )
trace.f(self.ClassName ) self:T()
local Valid = true local Valid = true
@ -517,12 +518,12 @@ trace.f(self.ClassName )
local Points = {} local Points = {}
trace.i( self.ClassName, 'CargoPos x = ' .. CargoPos.x .. " z = " .. CargoPos.z ) self:T( 'CargoPos x = ' .. CargoPos.x .. " z = " .. CargoPos.z )
trace.i( self.ClassName, 'CarrierPosMove x = ' .. CarrierPosMove.x .. " z = " .. CarrierPosMove.z ) self:T( 'CarrierPosMove x = ' .. CarrierPosMove.x .. " z = " .. CarrierPosMove.z )
Points[#Points+1] = routines.ground.buildWP( CargoPos, "Cone", 10 ) Points[#Points+1] = routines.ground.buildWP( CargoPos, "Cone", 10 )
trace.i( self.ClassName, 'Points[1] x = ' .. Points[1].x .. " y = " .. Points[1].y ) self:T( 'Points[1] x = ' .. Points[1].x .. " y = " .. Points[1].y )
if OnBoardSide == nil then if OnBoardSide == nil then
OnBoardSide = CLIENT.ONBOARDSIDE.NONE OnBoardSide = CLIENT.ONBOARDSIDE.NONE
@ -530,7 +531,7 @@ trace.f(self.ClassName )
if OnBoardSide == CLIENT.ONBOARDSIDE.LEFT then if OnBoardSide == CLIENT.ONBOARDSIDE.LEFT then
trace.i( self.ClassName, "TransportCargoOnBoard: Onboarding LEFT" ) self:T( "TransportCargoOnBoard: Onboarding LEFT" )
CarrierPosMove.z = CarrierPosMove.z - 25 CarrierPosMove.z = CarrierPosMove.z - 25
CarrierPosOnBoard.z = CarrierPosOnBoard.z - 5 CarrierPosOnBoard.z = CarrierPosOnBoard.z - 5
Points[#Points+1] = routines.ground.buildWP( CarrierPosMove, "Cone", 10 ) Points[#Points+1] = routines.ground.buildWP( CarrierPosMove, "Cone", 10 )
@ -538,7 +539,7 @@ trace.f(self.ClassName )
elseif OnBoardSide == CLIENT.ONBOARDSIDE.RIGHT then elseif OnBoardSide == CLIENT.ONBOARDSIDE.RIGHT then
trace.i( self.ClassName, "TransportCargoOnBoard: Onboarding RIGHT" ) self:T( "TransportCargoOnBoard: Onboarding RIGHT" )
CarrierPosMove.z = CarrierPosMove.z + 25 CarrierPosMove.z = CarrierPosMove.z + 25
CarrierPosOnBoard.z = CarrierPosOnBoard.z + 5 CarrierPosOnBoard.z = CarrierPosOnBoard.z + 5
Points[#Points+1] = routines.ground.buildWP( CarrierPosMove, "Cone", 10 ) Points[#Points+1] = routines.ground.buildWP( CarrierPosMove, "Cone", 10 )
@ -546,7 +547,7 @@ trace.f(self.ClassName )
elseif OnBoardSide == CLIENT.ONBOARDSIDE.BACK then elseif OnBoardSide == CLIENT.ONBOARDSIDE.BACK then
trace.i( self.ClassName, "TransportCargoOnBoard: Onboarding BACK" ) self:T( "TransportCargoOnBoard: Onboarding BACK" )
CarrierPosMove.x = CarrierPosMove.x - 25 CarrierPosMove.x = CarrierPosMove.x - 25
CarrierPosOnBoard.x = CarrierPosOnBoard.x - 5 CarrierPosOnBoard.x = CarrierPosOnBoard.x - 5
Points[#Points+1] = routines.ground.buildWP( CarrierPosMove, "Cone", 10 ) Points[#Points+1] = routines.ground.buildWP( CarrierPosMove, "Cone", 10 )
@ -554,7 +555,7 @@ trace.f(self.ClassName )
elseif OnBoardSide == CLIENT.ONBOARDSIDE.FRONT then elseif OnBoardSide == CLIENT.ONBOARDSIDE.FRONT then
trace.i( self.ClassName, "TransportCargoOnBoard: Onboarding FRONT" ) self:T( "TransportCargoOnBoard: Onboarding FRONT" )
CarrierPosMove.x = CarrierPosMove.x + 25 CarrierPosMove.x = CarrierPosMove.x + 25
CarrierPosOnBoard.x = CarrierPosOnBoard.x + 5 CarrierPosOnBoard.x = CarrierPosOnBoard.x + 5
Points[#Points+1] = routines.ground.buildWP( CarrierPosMove, "Cone", 10 ) Points[#Points+1] = routines.ground.buildWP( CarrierPosMove, "Cone", 10 )
@ -562,11 +563,11 @@ trace.f(self.ClassName )
elseif OnBoardSide == CLIENT.ONBOARDSIDE.NONE then elseif OnBoardSide == CLIENT.ONBOARDSIDE.NONE then
trace.i( self.ClassName, "TransportCargoOnBoard: Onboarding CENTRAL" ) self:T( "TransportCargoOnBoard: Onboarding CENTRAL" )
Points[#Points+1] = routines.ground.buildWP( CarrierPos, "Cone", 10 ) Points[#Points+1] = routines.ground.buildWP( CarrierPos, "Cone", 10 )
end end
trace.i( self.ClassName, "TransportCargoOnBoard: Routing " .. self.CargoGroupName ) self:T( "TransportCargoOnBoard: Routing " .. self.CargoGroupName )
routines.scheduleFunction( routines.goRoute, { self.CargoGroupName, Points}, timer.getTime() + 4 ) routines.scheduleFunction( routines.goRoute, { self.CargoGroupName, Points}, timer.getTime() + 4 )
@ -578,7 +579,7 @@ end
function CARGO_GROUP:OnBoarded( Client, LandingZone ) function CARGO_GROUP:OnBoarded( Client, LandingZone )
trace.f(self.ClassName ) self:T()
local OnBoarded = false local OnBoarded = false
@ -592,11 +593,12 @@ trace.f(self.ClassName )
return OnBoarded return OnBoarded
end end
function CARGO_GROUP:UnLoad( Client, TargetZoneName )
trace.f( self.ClassName )
trace.i( self.ClassName, 'self.CargoName = ' .. self.CargoName ) function CARGO_GROUP:UnLoad( Client, TargetZoneName )
trace.i( self.ClassName, 'self.CargoGroupName = ' .. self.CargoGroupName ) self:T()
self:T( 'self.CargoName = ' .. self.CargoName )
self:T( 'self.CargoGroupName = ' .. self.CargoGroupName )
self.CargoSpawn:FromCarrier( Client:GetClientGroupUnit(), TargetZoneName, self.CargoGroupName ) self.CargoSpawn:FromCarrier( Client:GetClientGroupUnit(), TargetZoneName, self.CargoGroupName )
@ -611,18 +613,11 @@ CARGO_PACKAGE = {
} }
function CARGO_PACKAGE:New( CargoType, CargoName, CargoWeight, CargoClientInitGroupName ) function CARGO_PACKAGE:New( CargoType, CargoName, CargoWeight, CargoClient ) local self = BASE:Inherit( self, CARGO:New( CargoType, CargoName, CargoWeight ) )
trace.f( self.ClassName, { CargoType, CargoName, CargoWeight, CargoClientInitGroupName } )
-- Arrange meta tables self:T( { CargoType, CargoName, CargoWeight, CargoClient.ClientName } )
local self = BASE:Inherit( self, CARGO:New( CargoType, CargoName, CargoWeight ) )
self.CargoClient = CargoClient
self.CargoClientInitGroupName = CargoClientInitGroupName
self.CargoClient = CLIENT:New( self.CargoClientInitGroupName )
self:StatusLoaded( self.CargoClient )
self.CargoClientInitGroupSpawn = SPAWN:New( self.CargoClientInitGroupName )
CARGOS[self.CargoName] = self CARGOS[self.CargoName] = self
@ -630,21 +625,28 @@ trace.f( self.ClassName, { CargoType, CargoName, CargoWeight, CargoClientInitGro
end end
function CARGO_PACKAGE:Spawn() function CARGO_PACKAGE:Spawn()
trace.f( self.ClassName ) self:T()
-- this needs to be checked thoroughly -- this needs to be checked thoroughly
local CargoClientInitGroup = self.CargoClient:ClientGroup()
if not CargoClientInitGroup then
if not self.CargoClientInitGroupSpawn then
self.CargoClientInitGroupSpawn = SPAWN:New( self.CargoClient:GetClientGroupName() )
end
self.CargoClientInitGroupSpawn:Spawn( self.CargoClient:GetClientGroupName() )
end
local SpawnCargo = true local SpawnCargo = true
trace.i( self.ClassName, self.CargoClientInitGroupName )
if self:IsStatusNone() then if self:IsStatusNone() then
elseif self:IsStatusLoading() or self:IsStatusLoaded() then elseif self:IsStatusLoading() or self:IsStatusLoaded() then
local Client = self:IsLoadedInClient() local CargoClientLoaded = self:IsLoadedInClient()
if Client and Client:ClientGroup() then if CargoClientLoaded and CargoClientLoaded:ClientGroup() then
SpawnCargo = false SpawnCargo = false
end end
@ -657,26 +659,21 @@ trace.f( self.ClassName )
end end
if SpawnCargo then if SpawnCargo then
self.CargoClient = CLIENT:New( self.CargoClientInitGroupName )
self:StatusLoaded( self.CargoClient ) self:StatusLoaded( self.CargoClient )
end end
local CargoClientInitGroup = Group.getByName( self.CargoClientInitGroupName )
if CargoClientInitGroup then
self.CargoClientInitGroupSpawn:Spawn( self.CargoClientInitGroupName )
end
return self return self
end end
function CARGO_PACKAGE:IsNear( Client, LandingZone ) function CARGO_PACKAGE:IsNear( Client, LandingZone )
trace.f( self.ClassName ) self:T()
local Near = false local Near = false
if self.CargoClient and self.CargoClient:ClientGroup() then if self.CargoClient and self.CargoClient:ClientGroup() then
trace.i( self.ClassName, self.CargoClient.ClientName ) self:T( self.CargoClient.ClientName )
trace.i( self.ClassName, 'Client Exists.' ) self:T( 'Client Exists.' )
if routines.IsUnitInRadius( self.CargoClient:GetClientGroupUnit(), Client:ClientPosition(), 150 ) then if routines.IsUnitInRadius( self.CargoClient:GetClientGroupUnit(), Client:ClientPosition(), 150 ) then
Near = true Near = true
@ -687,8 +684,9 @@ trace.f( self.ClassName )
end end
function CARGO_PACKAGE:OnBoard( Client, LandingZone, OnBoardSide ) function CARGO_PACKAGE:OnBoard( Client, LandingZone, OnBoardSide )
trace.f(self.ClassName ) self:T()
local Valid = true local Valid = true
@ -707,12 +705,12 @@ trace.f(self.ClassName )
local Points = {} local Points = {}
trace.i( self.ClassName, 'CargoPos x = ' .. CargoPos.x .. " z = " .. CargoPos.z ) self:T( 'CargoPos x = ' .. CargoPos.x .. " z = " .. CargoPos.z )
trace.i( self.ClassName, 'CarrierPosMove x = ' .. CarrierPosMove.x .. " z = " .. CarrierPosMove.z ) self:T( 'CarrierPosMove x = ' .. CarrierPosMove.x .. " z = " .. CarrierPosMove.z )
Points[#Points+1] = routines.ground.buildWP( CargoPos, "Cone", 10 ) Points[#Points+1] = routines.ground.buildWP( CargoPos, "Cone", 10 )
trace.i( self.ClassName, 'Points[1] x = ' .. Points[1].x .. " y = " .. Points[1].y ) self:T( 'Points[1] x = ' .. Points[1].x .. " y = " .. Points[1].y )
if OnBoardSide == nil then if OnBoardSide == nil then
OnBoardSide = CLIENT.ONBOARDSIDE.NONE OnBoardSide = CLIENT.ONBOARDSIDE.NONE
@ -720,7 +718,7 @@ trace.f(self.ClassName )
if OnBoardSide == CLIENT.ONBOARDSIDE.LEFT then if OnBoardSide == CLIENT.ONBOARDSIDE.LEFT then
trace.i( self.ClassName, "TransportCargoOnBoard: Onboarding LEFT" ) self:T( "TransportCargoOnBoard: Onboarding LEFT" )
CarrierPosMove.z = CarrierPosMove.z - 25 CarrierPosMove.z = CarrierPosMove.z - 25
CarrierPosOnBoard.z = CarrierPosOnBoard.z - 5 CarrierPosOnBoard.z = CarrierPosOnBoard.z - 5
CarrierPosMoveAway.z = CarrierPosMoveAway.z - 20 CarrierPosMoveAway.z = CarrierPosMoveAway.z - 20
@ -730,7 +728,7 @@ trace.f(self.ClassName )
elseif OnBoardSide == CLIENT.ONBOARDSIDE.RIGHT then elseif OnBoardSide == CLIENT.ONBOARDSIDE.RIGHT then
trace.i( self.ClassName, "TransportCargoOnBoard: Onboarding RIGHT" ) self:T( "TransportCargoOnBoard: Onboarding RIGHT" )
CarrierPosMove.z = CarrierPosMove.z + 25 CarrierPosMove.z = CarrierPosMove.z + 25
CarrierPosOnBoard.z = CarrierPosOnBoard.z + 5 CarrierPosOnBoard.z = CarrierPosOnBoard.z + 5
CarrierPosMoveAway.z = CarrierPosMoveAway.z + 20 CarrierPosMoveAway.z = CarrierPosMoveAway.z + 20
@ -740,7 +738,7 @@ trace.f(self.ClassName )
elseif OnBoardSide == CLIENT.ONBOARDSIDE.BACK then elseif OnBoardSide == CLIENT.ONBOARDSIDE.BACK then
trace.i( self.ClassName, "TransportCargoOnBoard: Onboarding BACK" ) self:T( "TransportCargoOnBoard: Onboarding BACK" )
CarrierPosMove.x = CarrierPosMove.x - 25 CarrierPosMove.x = CarrierPosMove.x - 25
CarrierPosOnBoard.x = CarrierPosOnBoard.x - 5 CarrierPosOnBoard.x = CarrierPosOnBoard.x - 5
CarrierPosMoveAway.x = CarrierPosMoveAway.x - 20 CarrierPosMoveAway.x = CarrierPosMoveAway.x - 20
@ -750,7 +748,7 @@ trace.f(self.ClassName )
elseif OnBoardSide == CLIENT.ONBOARDSIDE.FRONT then elseif OnBoardSide == CLIENT.ONBOARDSIDE.FRONT then
trace.i( self.ClassName, "TransportCargoOnBoard: Onboarding FRONT" ) self:T( "TransportCargoOnBoard: Onboarding FRONT" )
CarrierPosMove.x = CarrierPosMove.x + 25 CarrierPosMove.x = CarrierPosMove.x + 25
CarrierPosOnBoard.x = CarrierPosOnBoard.x + 5 CarrierPosOnBoard.x = CarrierPosOnBoard.x + 5
CarrierPosMoveAway.x = CarrierPosMoveAway.x + 20 CarrierPosMoveAway.x = CarrierPosMoveAway.x + 20
@ -760,7 +758,7 @@ trace.f(self.ClassName )
elseif OnBoardSide == CLIENT.ONBOARDSIDE.NONE then elseif OnBoardSide == CLIENT.ONBOARDSIDE.NONE then
trace.i( self.ClassName, "TransportCargoOnBoard: Onboarding FRONT" ) self:T( "TransportCargoOnBoard: Onboarding FRONT" )
CarrierPosMove.x = CarrierPosMove.x + 25 CarrierPosMove.x = CarrierPosMove.x + 25
CarrierPosOnBoard.x = CarrierPosOnBoard.x + 5 CarrierPosOnBoard.x = CarrierPosOnBoard.x + 5
CarrierPosMoveAway.x = CarrierPosMoveAway.x + 20 CarrierPosMoveAway.x = CarrierPosMoveAway.x + 20
@ -769,7 +767,7 @@ trace.f(self.ClassName )
Points[#Points+1] = routines.ground.buildWP( CarrierPosMoveAway, "Cone", 10 ) Points[#Points+1] = routines.ground.buildWP( CarrierPosMoveAway, "Cone", 10 )
end end
trace.i( self.ClassName, "Routing " .. CargoHostName ) self:T( "Routing " .. CargoHostName )
routines.scheduleFunction( routines.goRoute, { CargoHostName, Points}, timer.getTime() + 4 ) routines.scheduleFunction( routines.goRoute, { CargoHostName, Points}, timer.getTime() + 4 )
@ -779,7 +777,7 @@ end
function CARGO_PACKAGE:OnBoarded( Client, LandingZone ) function CARGO_PACKAGE:OnBoarded( Client, LandingZone )
trace.f(self.ClassName ) self:T()
local OnBoarded = false local OnBoarded = false
@ -797,11 +795,12 @@ trace.f(self.ClassName )
return OnBoarded return OnBoarded
end end
function CARGO_PACKAGE:UnLoad( Client, TargetZoneName )
trace.f( self.ClassName )
trace.i( self.ClassName, 'self.CargoName = ' .. self.CargoName ) function CARGO_PACKAGE:UnLoad( Client, TargetZoneName )
--trace.i( self.ClassName, 'self.CargoHostName = ' .. self.CargoHostName ) self:T()
self:T( 'self.CargoName = ' .. self.CargoName )
--self:T( 'self.CargoHostName = ' .. self.CargoHostName )
--self.CargoSpawn:FromCarrier( Client:ClientGroup(), TargetZoneName, self.CargoHostName ) --self.CargoSpawn:FromCarrier( Client:ClientGroup(), TargetZoneName, self.CargoHostName )
self:StatusUnLoaded() self:StatusUnLoaded()
@ -816,11 +815,10 @@ CARGO_SLINGLOAD = {
function CARGO_SLINGLOAD:New( CargoType, CargoName, CargoWeight, CargoZone, CargoHostName, CargoCountryID ) function CARGO_SLINGLOAD:New( CargoType, CargoName, CargoWeight, CargoZone, CargoHostName, CargoCountryID )
trace.f( self.ClassName, { CargoType, CargoName, CargoWeight, CargoZone, CargoHostName, CargoCountryID } )
-- Arrange meta tables
local self = BASE:Inherit( self, CARGO:New( CargoType, CargoName, CargoWeight ) ) local self = BASE:Inherit( self, CARGO:New( CargoType, CargoName, CargoWeight ) )
self:T( { CargoType, CargoName, CargoWeight, CargoZone, CargoHostName, CargoCountryID } )
self.CargoHostName = CargoHostName self.CargoHostName = CargoHostName
-- Cargo will be initialized around the CargoZone position. -- Cargo will be initialized around the CargoZone position.
@ -838,19 +836,21 @@ trace.f( self.ClassName, { CargoType, CargoName, CargoWeight, CargoZone, CargoHo
end end
function CARGO_SLINGLOAD:IsLandingRequired() function CARGO_SLINGLOAD:IsLandingRequired()
trace.f( self.ClassName ) self:T()
return false return false
end end
function CARGO_SLINGLOAD:IsSlingLoad() function CARGO_SLINGLOAD:IsSlingLoad()
trace.f( self.ClassName ) self:T()
return true return true
end end
function CARGO_SLINGLOAD:Spawn() function CARGO_SLINGLOAD:Spawn()
trace.f( self.ClassName ) self:T()
local Zone = trigger.misc.getZone( self.CargoZone ) local Zone = trigger.misc.getZone( self.CargoZone )
@ -858,7 +858,7 @@ trace.f( self.ClassName )
ZonePos.x = Zone.point.x + math.random( Zone.radius / 2 * -1, Zone.radius / 2 ) ZonePos.x = Zone.point.x + math.random( Zone.radius / 2 * -1, Zone.radius / 2 )
ZonePos.y = Zone.point.z + math.random( Zone.radius / 2 * -1, Zone.radius / 2 ) ZonePos.y = Zone.point.z + math.random( Zone.radius / 2 * -1, Zone.radius / 2 )
trace.i( self.ClassName, "Cargo Location = " .. ZonePos.x .. ", " .. ZonePos.y ) self:T( "Cargo Location = " .. ZonePos.x .. ", " .. ZonePos.y )
--[[ --[[
-- This does not work in 1.5.2. -- This does not work in 1.5.2.
@ -898,8 +898,9 @@ trace.f( self.ClassName )
return self return self
end end
function CARGO_SLINGLOAD:IsNear( Client, LandingZone ) function CARGO_SLINGLOAD:IsNear( Client, LandingZone )
trace.f( self.ClassName ) self:T()
local Near = false local Near = false
@ -908,7 +909,7 @@ end
function CARGO_SLINGLOAD:IsInLandingZone( Client, LandingZone ) function CARGO_SLINGLOAD:IsInLandingZone( Client, LandingZone )
trace.f( self.ClassName ) self:T()
local Near = false local Near = false
@ -923,9 +924,8 @@ trace.f( self.ClassName )
end end
function CARGO_SLINGLOAD:OnBoard( Client, LandingZone, OnBoardSide ) function CARGO_SLINGLOAD:OnBoard( Client, LandingZone, OnBoardSide )
trace.f(self.ClassName ) self:T()
local Valid = true local Valid = true
@ -935,34 +935,28 @@ end
function CARGO_SLINGLOAD:OnBoarded( Client, LandingZone ) function CARGO_SLINGLOAD:OnBoarded( Client, LandingZone )
trace.f(self.ClassName ) self:T()
local OnBoarded = false local OnBoarded = false
local CargoStaticUnit = StaticObject.getByName( self.CargoName ) local CargoStaticUnit = StaticObject.getByName( self.CargoName )
if CargoStaticUnit then if CargoStaticUnit then
if not routines.IsStaticInZones( CargoStaticUnit, LandingZone ) then if not routines.IsStaticInZones( CargoStaticUnit, LandingZone ) then
Onboarded = true OnBoarded = true
end end
end end
return OnBoarded return OnBoarded
end end
function CARGO_SLINGLOAD:UnLoad( Client, TargetZoneName )
trace.f( self.ClassName )
trace.i( self.ClassName, 'self.CargoName = ' .. self.CargoName ) function CARGO_SLINGLOAD:UnLoad( Client, TargetZoneName )
trace.i( self.ClassName, 'self.CargoGroupName = ' .. self.CargoGroupName ) self:T()
self:T( 'self.CargoName = ' .. self.CargoName )
self:T( 'self.CargoGroupName = ' .. self.CargoGroupName )
self:StatusUnLoaded() self:StatusUnLoaded()
return Cargo return Cargo
end end
--[[--
Internal Table to understand the form of the CARGO.
@table CARGO_TRANSPORT
--]]
CARGO_TRANSPORT = { UNIT = 1, SLING = 2, STATIC = 3, INVISIBLE = 4 }

View File

@ -44,10 +44,9 @@ CLIENT = {
-- Mission:AddClient( CLIENT:New( 'RU MI-8MTV2*RAMP-Deploy Troops 4' ):Transport() ) -- Mission:AddClient( CLIENT:New( 'RU MI-8MTV2*RAMP-Deploy Troops 4' ):Transport() )
function CLIENT:New( ClientName, ClientBriefing ) function CLIENT:New( ClientName, ClientBriefing )
trace.f( self.ClassName, { ClientName, ClientBriefing } )
-- Arrange meta tables
local self = BASE:Inherit( self, BASE:New() ) local self = BASE:Inherit( self, BASE:New() )
self:T()
self.ClientName = ClientName self.ClientName = ClientName
self:AddBriefing( ClientBriefing ) self:AddBriefing( ClientBriefing )
self.MessageSwitch = true self.MessageSwitch = true
@ -58,7 +57,7 @@ end
--- Resets a CLIENT. --- Resets a CLIENT.
-- @tparam string ClientName Name of the Group as defined within the Mission Editor. The Group must have a Unit with the type Client. -- @tparam string ClientName Name of the Group as defined within the Mission Editor. The Group must have a Unit with the type Client.
function CLIENT:Reset( ClientName ) function CLIENT:Reset( ClientName )
trace.f(self.ClassName) self:T()
self._Menus = {} self._Menus = {}
end end
@ -66,11 +65,11 @@ end
-- This function is modified to deal with a couple of bugs in DCS 1.5.3 -- This function is modified to deal with a couple of bugs in DCS 1.5.3
-- @treturn Group -- @treturn Group
function CLIENT:ClientGroup() function CLIENT:ClientGroup()
trace.f(self.ClassName) self:T()
-- local ClientData = Group.getByName( self.ClientName ) -- local ClientData = Group.getByName( self.ClientName )
-- if ClientData and ClientData:isExist() then -- if ClientData and ClientData:isExist() then
-- trace.i( self.ClassName, self.ClientName .. " : group found!" ) -- self:T( self.ClientName .. " : group found!" )
-- return ClientData -- return ClientData
-- else -- else
-- return nil -- return nil
@ -78,33 +77,33 @@ trace.f(self.ClassName)
local CoalitionsData = { AlivePlayersRed = coalition.getPlayers( coalition.side.RED ), AlivePlayersBlue = coalition.getPlayers( coalition.side.BLUE ) } local CoalitionsData = { AlivePlayersRed = coalition.getPlayers( coalition.side.RED ), AlivePlayersBlue = coalition.getPlayers( coalition.side.BLUE ) }
for CoalitionId, CoalitionData in pairs( CoalitionsData ) do for CoalitionId, CoalitionData in pairs( CoalitionsData ) do
trace.i( self.ClassName, CoalitionData ) self:T( { "CoalitionData:", CoalitionData } )
for UnitId, UnitData in pairs( CoalitionData ) do for UnitId, UnitData in pairs( CoalitionData ) do
trace.i( self.ClassName, UnitData ) self:T( { "UnitData:", UnitData } )
if UnitData and UnitData:isExist() then if UnitData and UnitData:isExist() then
local ClientGroup = Group.getByName( self.ClientName ) local ClientGroup = Group.getByName( self.ClientName )
if ClientGroup then if ClientGroup then
trace.i( self.ClassName, "ClientGroup = " .. self.ClientName ) self:T( "ClientGroup = " .. self.ClientName )
if ClientGroup:isExist() then if ClientGroup:isExist() then
if ClientGroup:getID() == UnitData:getGroup():getID() then if ClientGroup:getID() == UnitData:getGroup():getID() then
trace.i( self.ClassName, "Normal logic" ) self:T( "Normal logic" )
trace.i( self.ClassName, self.ClientName .. " : group found!" ) self:T( self.ClientName .. " : group found!" )
return ClientGroup return ClientGroup
end end
else else
-- Now we need to resolve the bugs in DCS 1.5 ... -- Now we need to resolve the bugs in DCS 1.5 ...
-- Consult the database for the units of the Client Group. (ClientGroup:getUnits() returns nil) -- Consult the database for the units of the Client Group. (ClientGroup:getUnits() returns nil)
trace.i( self.ClassName, "Bug 1.5 logic" ) self:T( "Bug 1.5 logic" )
local ClientUnits = _Database.Groups[self.ClientName].Units local ClientUnits = _Database.Groups[self.ClientName].Units
trace.i( self.ClassName, { ClientUnits[1].name, env.getValueDictByKey(ClientUnits[1].name) } ) self:T( { ClientUnits[1].name, env.getValueDictByKey(ClientUnits[1].name) } )
for ClientUnitID, ClientUnitData in pairs( ClientUnits ) do for ClientUnitID, ClientUnitData in pairs( ClientUnits ) do
trace.i( self.ClassName, { tonumber(UnitData:getID()), ClientUnitData.unitId } ) self:T( { tonumber(UnitData:getID()), ClientUnitData.unitId } )
if tonumber(UnitData:getID()) == ClientUnitData.unitId then if tonumber(UnitData:getID()) == ClientUnitData.unitId then
local ClientGroupTemplate = _Database.Groups[self.ClientName].Template local ClientGroupTemplate = _Database.Groups[self.ClientName].Template
self.ClientGroupID = ClientGroupTemplate.groupId self.ClientGroupID = ClientGroupTemplate.groupId
self.ClientGroupUnit = UnitData self.ClientGroupUnit = UnitData
trace.i( self.ClassName, self.ClientName .. " : group found in bug 1.5 resolvement logic!" ) self:T( self.ClientName .. " : group found in bug 1.5 resolvement logic!" )
return ClientGroup return ClientGroup
end end
end end
@ -119,10 +118,10 @@ trace.f(self.ClassName)
-- For non player clients -- For non player clients
local ClientGroup = Group.getByName( self.ClientName ) local ClientGroup = Group.getByName( self.ClientName )
if ClientGroup then if ClientGroup then
trace.i( self.ClassName, "ClientGroup = " .. self.ClientName ) self:T( "ClientGroup = " .. self.ClientName )
if ClientGroup:isExist() then if ClientGroup:isExist() then
trace.i( self.ClassName, "Normal logic" ) self:T( "Normal logic" )
trace.i( self.ClassName, self.ClientName .. " : group found!" ) self:T( self.ClientName .. " : group found!" )
return ClientGroup return ClientGroup
end end
end end
@ -135,7 +134,7 @@ end
function CLIENT:GetClientGroupID() function CLIENT:GetClientGroupID()
trace.f(self.ClassName) self:T()
ClientGroup = self:ClientGroup() ClientGroup = self:ClientGroup()
@ -150,10 +149,29 @@ trace.f(self.ClassName)
return nil return nil
end end
function CLIENT:GetClientGroupName()
self:T()
ClientGroup = self:ClientGroup()
if ClientGroup then
if ClientGroup:isExist() then
self:T( ClientGroup:getName() )
return ClientGroup:getName()
else
self:T( self.ClientName )
return self.ClientName
end
end
return nil
end
--- Returns the Unit of the @{CLIENT}. --- Returns the Unit of the @{CLIENT}.
-- @treturn Unit -- @treturn Unit
function CLIENT:GetClientGroupUnit() function CLIENT:GetClientGroupUnit()
trace.f(self.ClassName) self:T()
ClientGroup = self:ClientGroup() ClientGroup = self:ClientGroup()
@ -172,7 +190,7 @@ end
--- Returns the Position of the @{CLIENT}. --- Returns the Position of the @{CLIENT}.
-- @treturn Position -- @treturn Position
function CLIENT:ClientPosition() function CLIENT:ClientPosition()
--trace.f(self.ClassName) --self:T()
ClientGroupUnit = self:GetClientGroupUnit() ClientGroupUnit = self:GetClientGroupUnit()
@ -188,7 +206,7 @@ end
--- Transport defines that the Client is a Transport. --- Transport defines that the Client is a Transport.
-- @treturn CLIENT -- @treturn CLIENT
function CLIENT:Transport() function CLIENT:Transport()
trace.f(self.ClassName) self:T()
self.ClientTransport = true self.ClientTransport = true
return self return self
@ -198,7 +216,7 @@ end
-- @tparam string ClientBriefing is the text defining the Mission briefing. -- @tparam string ClientBriefing is the text defining the Mission briefing.
-- @treturn CLIENT -- @treturn CLIENT
function CLIENT:AddBriefing( ClientBriefing ) function CLIENT:AddBriefing( ClientBriefing )
trace.f(self.ClassName) self:T()
self.ClientBriefing = ClientBriefing self.ClientBriefing = ClientBriefing
return self return self
end end
@ -206,14 +224,14 @@ end
--- IsTransport returns if a Client is a transport. --- IsTransport returns if a Client is a transport.
-- @treturn bool -- @treturn bool
function CLIENT:IsTransport() function CLIENT:IsTransport()
trace.f(self.ClassName) self:T()
return self.ClientTransport return self.ClientTransport
end end
--- ShowCargo shows the @{CARGO} within the CLIENT to the Player. --- ShowCargo shows the @{CARGO} within the CLIENT to the Player.
-- The @{CARGO} is shown throught the MESSAGE system of DCS World. -- The @{CARGO} is shown throught the MESSAGE system of DCS World.
function CLIENT:ShowCargo() function CLIENT:ShowCargo()
trace.f( self.ClassName ) self:T()
local CargoMsg = "" local CargoMsg = ""
@ -244,7 +262,7 @@ end
-- @tparam string MessageCategory is the category of the message (the title). -- @tparam string MessageCategory is the category of the message (the title).
-- @tparam number MessageInterval is the interval in seconds between the display of the Message when the CLIENT is in the air. -- @tparam number MessageInterval is the interval in seconds between the display of the Message when the CLIENT is in the air.
function CLIENT:Message( Message, MessageDuration, MessageId, MessageCategory, MessageInterval ) function CLIENT:Message( Message, MessageDuration, MessageId, MessageCategory, MessageInterval )
trace.f( self.ClassName, { Message, MessageDuration, MessageId, MessageCategory, MessageInterval } ) self:T()
if not self.MenuMessages then if not self.MenuMessages then
if self:GetClientGroupID() then if self:GetClientGroupID() then

View File

@ -14,27 +14,25 @@ DEPLOYTASK = {
-- @tparam table{string,...}|string LandingZones Table or name of the zone(s) where Cargo is to be unloaded. -- @tparam table{string,...}|string LandingZones Table or name of the zone(s) where Cargo is to be unloaded.
-- @tparam CARGO_TYPE CargoType Type of the Cargo. -- @tparam CARGO_TYPE CargoType Type of the Cargo.
function DEPLOYTASK:New( CargoType ) function DEPLOYTASK:New( CargoType )
trace.f(self.ClassName) local self = BASE:Inherit( self, TASK:New() )
self:T()
-- Child holds the inherited instance of the DEPLOYTASK Class to the BASE class.
local Child = BASE:Inherit( self, TASK:New() )
local Valid = true local Valid = true
if Valid then if Valid then
Child.Name = 'Deploy Cargo' self.Name = 'Deploy Cargo'
Child.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.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."
Child.CargoType = CargoType self.CargoType = CargoType
Child.GoalVerb = CargoType .. " " .. self.GoalVerb self.GoalVerb = CargoType .. " " .. self.GoalVerb
Child.Stages = { STAGE_CARGO_INIT:New(), STAGE_CARGO_LOAD:New(), STAGEBRIEF:New(), STAGESTART:New(), STAGEROUTE:New(), STAGELANDING:New(), STAGELANDED:New(), STAGEUNLOAD:New(), STAGEDONE:New() } self.Stages = { STAGE_CARGO_INIT:New(), STAGE_CARGO_LOAD:New(), STAGEBRIEF:New(), STAGESTART:New(), STAGEROUTE:New(), STAGELANDING:New(), STAGELANDED:New(), STAGEUNLOAD:New(), STAGEDONE:New() }
Child.SetStage( Child, 1 ) self.SetStage( self, 1 )
end end
return Child return self
end end
function DEPLOYTASK:ToZone( LandingZone ) function DEPLOYTASK:ToZone( LandingZone )
trace.f(self.ClassName) self:T()
self.LandingZones.LandingZoneNames[LandingZone.CargoZoneName] = LandingZone.CargoZoneName self.LandingZones.LandingZoneNames[LandingZone.CargoZoneName] = LandingZone.CargoZoneName
self.LandingZones.LandingZones[LandingZone.CargoZoneName] = LandingZone self.LandingZones.LandingZones[LandingZone.CargoZoneName] = LandingZone
@ -44,7 +42,7 @@ end
function DEPLOYTASK:InitCargo( InitCargos ) function DEPLOYTASK:InitCargo( InitCargos )
trace.f( self.ClassName, { InitCargos } ) self:T( { InitCargos } )
if type( InitCargos ) == "table" then if type( InitCargos ) == "table" then
self.Cargos.InitCargos = InitCargos self.Cargos.InitCargos = InitCargos
@ -52,13 +50,12 @@ trace.f( self.ClassName, { InitCargos } )
self.Cargos.InitCargos = { InitCargos } self.Cargos.InitCargos = { InitCargos }
end end
return self return self
end end
function DEPLOYTASK:LoadCargo( LoadCargos ) function DEPLOYTASK:LoadCargo( LoadCargos )
trace.f( self.ClassName, { LoadCargos } ) self:T( { LoadCargos } )
if type( LoadCargos ) == "table" then if type( LoadCargos ) == "table" then
self.Cargos.LoadCargos = LoadCargos self.Cargos.LoadCargos = LoadCargos
@ -73,7 +70,7 @@ end
--- When the cargo is unloaded, it will move to the target zone name. --- When the cargo is unloaded, it will move to the target zone name.
-- @tparam string TargetZoneName Name of the Zone to where the Cargo should move after unloading. -- @tparam string TargetZoneName Name of the Zone to where the Cargo should move after unloading.
function DEPLOYTASK:SetCargoTargetZoneName( TargetZoneName ) function DEPLOYTASK:SetCargoTargetZoneName( TargetZoneName )
trace.f(self.ClassName) self:T()
local Valid = true local Valid = true
@ -88,7 +85,7 @@ trace.f(self.ClassName)
end end
function DEPLOYTASK:AddCargoMenus( Client, Cargos, TransportRadius ) function DEPLOYTASK:AddCargoMenus( Client, Cargos, TransportRadius )
trace.f( self.ClassName ) self:T()
local ClientGroupID = Client:GetClientGroupID() local ClientGroupID = Client:GetClientGroupID()
@ -135,7 +132,7 @@ trace.f( self.ClassName )
end end
function DEPLOYTASK:RemoveCargoMenus( Client ) function DEPLOYTASK:RemoveCargoMenus( Client )
trace.f(self.ClassName ) self:T()
local ClientGroupID = Client:GetClientGroupID() local ClientGroupID = Client:GetClientGroupID()
trace.i( self.ClassName, ClientGroupID ) trace.i( self.ClassName, ClientGroupID )

View File

@ -24,6 +24,74 @@ trace.f( self.ClassName, _Group:getName() )
return self return self
end end
function GROUP:GetName()
self:T( self.GroupName )
return self.GroupName
end
function GROUP:Destroy()
self:T( self.GroupName )
for Index, UnitData in pairs( self._Group:getUnits() ) do
self:CreateEventCrash( timer.getTime(), UnitData )
end
self._Group:destroy()
end
function GROUP:IsAir()
self:T()
local IsAirResult = self._Group:getCategory() == Group.Category.AIRPLANE or self._Group:getCategory() == Group.Category.HELICOPTER
self:T( IsAirResult )
return IsAirResult
end
function GROUP:AllOnGround()
self:T()
local AllOnGroundResult = true
for Index, UnitData in pairs( self._Group:getUnits() ) do
if UnitData:inAir() then
AllOnGroundResult = false
end
end
self:T( AllOnGroundResult )
return AllOnGroundResult
end
function GROUP:GetMaxVelocity()
self:T()
local MaxVelocity = 0
for Index, UnitData in pairs( self._Group:getUnits() ) do
local Velocity = UnitData:getVelocity()
local VelocityTotal = math.abs( Velocity.x ) + math.abs( Velocity.y ) + math.abs( Velocity.z )
if VelocityTotal < MaxVelocity then
MaxVelocity = VelocityTotal
end
end
return MaxVelocity
end
function GROUP:GetHeight()
self:T()
end
function GROUP:Land( Point, Duration ) function GROUP:Land( Point, Duration )
trace.f( self.ClassName, { self.GroupName, Point, Duration } ) trace.f( self.ClassName, { self.GroupName, Point, Duration } )

View File

@ -243,11 +243,12 @@ function MISSION:ShowBriefing( Client )
if not Client.ClientBriefingShown then if not Client.ClientBriefingShown then
Client.ClientBriefingShown = true Client.ClientBriefingShown = true
Client:Message( '(Press the keys [LEFT ALT]+[B] to view the briefing pages. Browse through the graphical briefing.)\n' .. local Briefing = self.MissionBriefing
self.MissionBriefing, 40, self.Name .. '/MissionBriefing', "Mission Command: Mission Briefing" )
if Client.ClientBriefing then if Client.ClientBriefing then
Client:Message( Client.ClientBriefing, 40, self.Name .. '/ClientBriefing', "Mission Command: Mission Briefing" ) Briefing = Briefing .. "\n" .. Client.ClientBriefing
end end
Briefing = Briefing .. "\n (Press [LEFT ALT]+[B] to view the graphical documentation.)"
Client:Message( Briefing, 30, self.Name .. '/MissionBriefing', "Command: Mission Briefing" )
end end
return Client return Client

View File

@ -16,30 +16,30 @@ PICKUPTASK = {
-- @tparam CARGO_TYPE CargoType Type of the Cargo. The type must be of the following Enumeration:.. -- @tparam CARGO_TYPE CargoType Type of the Cargo. The type must be of the following Enumeration:..
-- @tparam number OnBoardSide Reflects from which side the cargo Group will be on-boarded on the Carrier. -- @tparam number OnBoardSide Reflects from which side the cargo Group will be on-boarded on the Carrier.
function PICKUPTASK:New( CargoType, OnBoardSide ) function PICKUPTASK:New( CargoType, OnBoardSide )
trace.f(self.ClassName) local self = BASE:Inherit( self, TASK:New() )
self:T()
-- Child holds the inherited instance of the PICKUPTASK Class to the BASE class. -- self holds the inherited instance of the PICKUPTASK Class to the BASE class.
local Child = BASE:Inherit( self, TASK:New() )
local Valid = true local Valid = true
if Valid then if Valid then
Child.Name = 'Pickup Cargo' self.Name = 'Pickup Cargo'
Child.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.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."
Child.CargoType = CargoType self.CargoType = CargoType
Child.GoalVerb = CargoType .. " " .. Child.GoalVerb self.GoalVerb = CargoType .. " " .. self.GoalVerb
Child.OnBoardSide = OnBoardSide self.OnBoardSide = OnBoardSide
Child.IsLandingRequired = false -- required to decide whether the client needs to land or not self.IsLandingRequired = false -- required to decide whether the client needs to land or not
Child.IsSlingLoad = false -- Indicates whether the cargo is a sling load cargo self.IsSlingLoad = false -- Indicates whether the cargo is a sling load cargo
Child.Stages = { STAGE_CARGO_INIT:New(), STAGE_CARGO_LOAD:New(), STAGEBRIEF:New(), STAGESTART:New(), STAGEROUTE:New(), STAGELANDING:New(), STAGELANDED:New(), STAGELOAD:New(), STAGEDONE:New() } self.Stages = { STAGE_CARGO_INIT:New(), STAGE_CARGO_LOAD:New(), STAGEBRIEF:New(), STAGESTART:New(), STAGEROUTE:New(), STAGELANDING:New(), STAGELANDED:New(), STAGELOAD:New(), STAGEDONE:New() }
Child.SetStage( Child, 1 ) self.SetStage( self, 1 )
end end
return Child return self
end end
function PICKUPTASK:FromZone( LandingZone ) function PICKUPTASK:FromZone( LandingZone )
trace.f(self.ClassName) self:T()
self.LandingZones.LandingZoneNames[LandingZone.CargoZoneName] = LandingZone.CargoZoneName self.LandingZones.LandingZoneNames[LandingZone.CargoZoneName] = LandingZone.CargoZoneName
self.LandingZones.LandingZones[LandingZone.CargoZoneName] = LandingZone self.LandingZones.LandingZones[LandingZone.CargoZoneName] = LandingZone
@ -48,7 +48,7 @@ trace.f(self.ClassName)
end end
function PICKUPTASK:InitCargo( InitCargos ) function PICKUPTASK:InitCargo( InitCargos )
trace.f( self.ClassName, { InitCargos } ) self:T( { InitCargos } )
if type( InitCargos ) == "table" then if type( InitCargos ) == "table" then
self.Cargos.InitCargos = InitCargos self.Cargos.InitCargos = InitCargos
@ -60,7 +60,7 @@ trace.f( self.ClassName, { InitCargos } )
end end
function PICKUPTASK:LoadCargo( LoadCargos ) function PICKUPTASK:LoadCargo( LoadCargos )
trace.f( self.ClassName, { LoadCargos } ) self:T( { LoadCargos } )
if type( LoadCargos ) == "table" then if type( LoadCargos ) == "table" then
self.Cargos.LoadCargos = LoadCargos self.Cargos.LoadCargos = LoadCargos
@ -72,11 +72,11 @@ trace.f( self.ClassName, { LoadCargos } )
end end
function PICKUPTASK:AddCargoMenus( Client, Cargos, TransportRadius ) function PICKUPTASK:AddCargoMenus( Client, Cargos, TransportRadius )
trace.f( self.ClassName ) self:T()
for CargoID, Cargo in pairs( Cargos ) do for CargoID, Cargo in pairs( Cargos ) do
trace.i( self.ClassName, { Cargo.ClassName, Cargo.CargoName, Cargo.CargoType, Cargo:IsStatusNone(), Cargo:IsStatusLoaded(), Cargo:IsStatusLoading(), Cargo:IsStatusUnLoaded() } ) self:T( { Cargo.ClassName, Cargo.CargoName, Cargo.CargoType, Cargo:IsStatusNone(), Cargo:IsStatusLoaded(), Cargo:IsStatusLoading(), Cargo:IsStatusUnLoaded() } )
if Cargo:IsStatusNone() or ( Cargo:IsStatusLoaded() and Client ~= Cargo:IsLoadedInClient() ) then if Cargo:IsStatusNone() or ( Cargo:IsStatusLoaded() and Client ~= Cargo:IsLoadedInClient() ) then
@ -96,7 +96,7 @@ trace.f( self.ClassName )
self.TEXT[1] .. " " .. Cargo.CargoType, self.TEXT[1] .. " " .. Cargo.CargoType,
nil nil
) )
trace.i( self.ClassName, 'Added PickupMenu: ' .. self.TEXT[1] .. " " .. Cargo.CargoType ) self:T( 'Added PickupMenu: ' .. self.TEXT[1] .. " " .. Cargo.CargoType )
end end
if Client._Menus[Cargo.CargoType].PickupSubMenus == nil then if Client._Menus[Cargo.CargoType].PickupSubMenus == nil then
@ -110,7 +110,7 @@ trace.f( self.ClassName )
self.MenuAction, self.MenuAction,
{ ReferenceTask = self, CargoTask = Cargo } { ReferenceTask = self, CargoTask = Cargo }
) )
trace.i( self.ClassName, 'Added PickupSubMenu' .. Cargo.CargoType .. ":" .. Cargo.CargoName .. " ( " .. Cargo.CargoWeight .. "kg )" ) self:T( 'Added PickupSubMenu' .. Cargo.CargoType .. ":" .. Cargo.CargoName .. " ( " .. Cargo.CargoWeight .. "kg )" )
end end
end end
end end
@ -118,17 +118,17 @@ trace.f( self.ClassName )
end end
function PICKUPTASK:RemoveCargoMenus( Client ) function PICKUPTASK:RemoveCargoMenus( Client )
trace.f( self.ClassName ) self:T()
for MenuID, MenuData in pairs( Client._Menus ) do for MenuID, MenuData in pairs( Client._Menus ) do
for SubMenuID, SubMenuData in pairs( MenuData.PickupSubMenus ) do for SubMenuID, SubMenuData in pairs( MenuData.PickupSubMenus ) do
missionCommands.removeItemForGroup( Client:GetClientGroupID(), SubMenuData ) missionCommands.removeItemForGroup( Client:GetClientGroupID(), SubMenuData )
trace.i( self.ClassName, "Removed PickupSubMenu " ) self:T( "Removed PickupSubMenu " )
SubMenuData = nil SubMenuData = nil
end end
if MenuData.PickupMenu then if MenuData.PickupMenu then
missionCommands.removeItemForGroup( Client:GetClientGroupID(), MenuData.PickupMenu ) missionCommands.removeItemForGroup( Client:GetClientGroupID(), MenuData.PickupMenu )
trace.i( self.ClassName, "Removed PickupMenu " ) self:T( "Removed PickupMenu " )
MenuData.PickupMenu = nil MenuData.PickupMenu = nil
end end
end end
@ -138,7 +138,7 @@ end
function PICKUPTASK:HasFailed( ClientDead ) function PICKUPTASK:HasFailed( ClientDead )
trace.f(self.ClassName) self:T()
local TaskHasFailed = self.TaskFailed local TaskHasFailed = self.TaskFailed
return TaskHasFailed return TaskHasFailed

View File

@ -48,53 +48,69 @@ end
-- porting in Slmod's serialize_slmod2 -- porting in Slmod's serialize_slmod2
routines.utils.oneLineSerialize = function(tbl) -- serialization of a table all on a single line, no comments, made to replace old get_table_string function routines.utils.oneLineSerialize = function(tbl) -- serialization of a table all on a single line, no comments, made to replace old get_table_string function
if type(tbl) == 'table' then --function only works for tables!
local tbl_str = {} lookup_table = {}
local function _Serialize( tbl )
tbl_str[#tbl_str + 1] = '{' if type(tbl) == 'table' then --function only works for tables!
for ind,val in pairs(tbl) do -- serialize its fields if lookup_table[tbl] then
if type(ind) == "number" then return lookup_table[object]
tbl_str[#tbl_str + 1] = '['
tbl_str[#tbl_str + 1] = tostring(ind)
tbl_str[#tbl_str + 1] = ']='
else --must be a string
tbl_str[#tbl_str + 1] = '['
tbl_str[#tbl_str + 1] = routines.utils.basicSerialize(ind)
tbl_str[#tbl_str + 1] = ']='
end end
if ((type(val) == 'number') or (type(val) == 'boolean')) then local tbl_str = {}
tbl_str[#tbl_str + 1] = tostring(val)
tbl_str[#tbl_str + 1] = ',' lookup_table[tbl] = tbl_str
elseif type(val) == 'string' then
tbl_str[#tbl_str + 1] = routines.utils.basicSerialize(val) tbl_str[#tbl_str + 1] = '{'
tbl_str[#tbl_str + 1] = ','
elseif type(val) == 'nil' then -- won't ever happen, right? for ind,val in pairs(tbl) do -- serialize its fields
tbl_str[#tbl_str + 1] = 'nil,' if type(ind) == "number" then
elseif type(val) == 'table' then tbl_str[#tbl_str + 1] = '['
if ind == "__index" then tbl_str[#tbl_str + 1] = tostring(ind)
tbl_str[#tbl_str + 1] = "__index" tbl_str[#tbl_str + 1] = ']='
else --must be a string
tbl_str[#tbl_str + 1] = '['
tbl_str[#tbl_str + 1] = routines.utils.basicSerialize(ind)
tbl_str[#tbl_str + 1] = ']='
end
if ((type(val) == 'number') or (type(val) == 'boolean')) then
tbl_str[#tbl_str + 1] = tostring(val)
tbl_str[#tbl_str + 1] = ','
elseif type(val) == 'string' then
tbl_str[#tbl_str + 1] = routines.utils.basicSerialize(val)
tbl_str[#tbl_str + 1] = ','
elseif type(val) == 'nil' then -- won't ever happen, right?
tbl_str[#tbl_str + 1] = 'nil,'
elseif type(val) == 'table' then
if ind == "__index" then
tbl_str[#tbl_str + 1] = "__index"
tbl_str[#tbl_str + 1] = ',' --I think this is right, I just added it
else
tbl_str[#tbl_str + 1] = _Serialize(val)
tbl_str[#tbl_str + 1] = ',' --I think this is right, I just added it
end
elseif type(val) == 'function' then
tbl_str[#tbl_str + 1] = "function " .. tostring(ind)
tbl_str[#tbl_str + 1] = ',' --I think this is right, I just added it tbl_str[#tbl_str + 1] = ',' --I think this is right, I just added it
else else
tbl_str[#tbl_str + 1] = routines.utils.oneLineSerialize(val) env.info('unable to serialize value type ' .. routines.utils.basicSerialize(type(val)) .. ' at index ' .. tostring(ind))
tbl_str[#tbl_str + 1] = ',' --I think this is right, I just added it env.info( debug.traceback() )
end end
elseif type(val) == 'function' then
tbl_str[#tbl_str + 1] = "function " .. tostring(ind)
tbl_str[#tbl_str + 1] = ',' --I think this is right, I just added it
else
env.info('unable to serialize value type ' .. routines.utils.basicSerialize(type(val)) .. ' at index ' .. tostring(ind))
env.info( debug.traceback() )
end
end
tbl_str[#tbl_str + 1] = '}'
return table.concat(tbl_str)
else
return tostring(tbl)
end end
tbl_str[#tbl_str + 1] = '}'
return table.concat(tbl_str)
else
return tostring(tbl)
end end
local objectreturn = _Serialize(tbl)
return objectreturn
end end
--porting in Slmod's "safestring" basic serialize --porting in Slmod's "safestring" basic serialize

View File

@ -236,6 +236,37 @@ trace.f( self.ClassName )
return self return self
end end
function SPAWN:CleanUp( SpawnCleanUpInterval )
self:T()
self.SpawnCleanUpInterval = SpawnCleanUpInterval
self.SpawnCleanUpTimeStamps = {}
self.CleanUpFunction = routines.scheduleFunction( self._SpawnCleanUpScheduler, { self }, timer.getTime() + 1, 60 )
end
function SPAWN:_SpawnCleanUpScheduler()
self:T()
local SpawnGroup = self:GetFirstAliveGroup()
while SpawnGroup do
if SpawnGroup:AllOnGround() and SpawnGroup:GetMaxVelocity() < 1 then
if not self.SpawnCleanUpTimeStamps[SpawnGroup:GetName()] then
self.SpawnCleanUpTimeStamps[SpawnGroup:GetName()] = timer.getTime()
else
if self.SpawnCleanUpTimeStamps[SpawnGroup:GetName()] + self.SpawnCleanUpInterval < timer.getTime() then
SpawnGroup:Destroy()
end
end
else
self.SpawnCleanUpTimeStamps[SpawnGroup:GetName()] = nil
end
SpawnGroup = self:GetNextAliveGroup()
end
end
--- Will SPAWN a Group whenever you want to do this. --- Will SPAWN a Group whenever you want to do this.
-- Note that the configuration with the above functions will apply when calling this method: Maxima, Randomization of routes, Scheduler, ... -- Note that the configuration with the above functions will apply when calling this method: Maxima, Randomization of routes, Scheduler, ...
@ -441,7 +472,42 @@ function SPAWN:GetLastIndex()
end end
function SPAWN:GetLastGroup()
function SPAWN:GetFirstAliveGroup()
self:T()
self.SpawnIndex = 1
for SpawnIndex = 1, self.SpawnCount do
SpawnGroupName = self:SpawnGroupName( SpawnIndex )
SpawnGroup = Group.getByName( SpawnGroupName )
if SpawnGroup and SpawnGroup:isExist() then
self.SpawnIndex = SpawnIndex
return GROUP:New( SpawnGroup )
end
end
self.SpawnIndex = nil
return nil
end
function SPAWN:GetNextAliveGroup()
self:T()
self.SpawnIndex = self.SpawnIndex + 1
for SpawnIndex = self.SpawnIndex, self.SpawnCount do
SpawnGroupName = self:SpawnGroupName( SpawnIndex )
SpawnGroup = Group.getByName( SpawnGroupName )
if SpawnGroup and SpawnGroup:isExist() then
self.SpawnIndex = SpawnIndex
return GROUP:New( SpawnGroup )
end
end
self.SpawnIndex = nil
return nil
end
function SPAWN:GetLastAliveGroup()
trace.f( self.ClassName ) trace.f( self.ClassName )
local LastGroupName = self:SpawnGroupName( self:GetLastIndex() ) local LastGroupName = self:SpawnGroupName( self:GetLastIndex() )
@ -449,7 +515,6 @@ trace.f( self.ClassName )
return GROUP:New( Group.getByName( LastGroupName ) ) return GROUP:New( Group.getByName( LastGroupName ) )
end end
--- Will SPAWN a Group within a given ZoneName. --- Will SPAWN a Group within a given ZoneName.
-- @tparam string ZonePrefix is the name of the zone where the Group is to be SPAWNed. -- @tparam string ZonePrefix is the name of the zone where the Group is to be SPAWNed.
-- @treturn SpawnTemplate -- @treturn SpawnTemplate

View File

@ -27,13 +27,12 @@ STAGE = {
function STAGE:New() function STAGE:New()
trace.f(self.ClassName)
local self = BASE:Inherit( self, BASE:New() ) local self = BASE:Inherit( self, BASE:New() )
self:T()
return self return self
end end
function STAGE:Execute( Mission, Client, Task ) function STAGE:Execute( Mission, Client, Task )
trace.f(self.ClassName)
local Valid = true local Valid = true
@ -41,13 +40,10 @@ trace.f(self.ClassName)
end end
function STAGE:Executing( Mission, Client, Task ) function STAGE:Executing( Mission, Client, Task )
trace.f(self.ClassName)
end end
function STAGE:Validate( Mission, Client, Task ) function STAGE:Validate( Mission, Client, Task )
trace.f(self.ClassName)
local Valid = true local Valid = true
return Valid return Valid
@ -63,24 +59,23 @@ STAGEBRIEF = {
} }
function STAGEBRIEF:New() function STAGEBRIEF:New()
trace.f(self.ClassName) local self = BASE:Inherit( self, STAGE:New() )
-- Arrange meta tables self:T()
local Child = BASE:Inherit( self, STAGE:New() ) self.StageType = 'CLIENT'
Child.StageType = 'CLIENT' return self
return Child
end end
function STAGEBRIEF:Execute( Mission, Client, Task ) function STAGEBRIEF:Execute( Mission, Client, Task )
trace.f(self.ClassName)
local Valid = BASE:Inherited(self):Execute( Mission, Client, Task ) local Valid = BASE:Inherited(self):Execute( Mission, Client, Task )
self:T()
Mission:ShowBriefing( Client ) Mission:ShowBriefing( Client )
self.StageBriefingTime = timer.getTime() self.StageBriefingTime = timer.getTime()
return Valid return Valid
end end
function STAGEBRIEF:Validate( Mission, Client, Task ) function STAGEBRIEF:Validate( Mission, Client, Task )
trace.f(self.ClassName)
local Valid = STAGE:Validate( Mission, Client, Task ) local Valid = STAGE:Validate( Mission, Client, Task )
self:T()
if timer.getTime() - self.StageBriefingTime <= self.StageBriefingDuration then if timer.getTime() - self.StageBriefingTime <= self.StageBriefingDuration then
return 0 return 0
@ -101,27 +96,26 @@ STAGESTART = {
} }
function STAGESTART:New() function STAGESTART:New()
trace.f(self.ClassName) local self = BASE:Inherit( self, STAGE:New() )
-- Arrange meta tables self:T()
local Child = BASE:Inherit( self, STAGE:New() ) self.StageType = 'CLIENT'
Child.StageType = 'CLIENT' return self
return Child
end end
function STAGESTART:Execute( Mission, Client, Task ) function STAGESTART:Execute( Mission, Client, Task )
trace.f(self.ClassName) self:T()
local Valid = BASE:Inherited(self):Execute( Mission, Client, Task ) local Valid = BASE:Inherited(self):Execute( Mission, Client, Task )
if Task.TaskBriefing then if Task.TaskBriefing then
Client:Message( Task.TaskBriefing, 15, Mission.Name .. "/Stage", "Mission Command: Tasking" ) Client:Message( Task.TaskBriefing, 30, Mission.Name .. "/Stage", "Mission Command: Tasking" )
else else
Client:Message( 'Task ' .. Task.TaskNumber .. '.', 15, Mission.Name .. "/Stage", "Mission Command: Tasking" ) Client:Message( 'Task ' .. Task.TaskNumber .. '.', 30, Mission.Name .. "/Stage", "Mission Command: Tasking" )
end end
self.StageStartTime = timer.getTime() self.StageStartTime = timer.getTime()
return Valid return Valid
end end
function STAGESTART:Validate( Mission, Client, Task ) function STAGESTART:Validate( Mission, Client, Task )
trace.f(self.ClassName) self:T()
local Valid = STAGE:Validate( Mission, Client, Task ) local Valid = STAGE:Validate( Mission, Client, Task )
if timer.getTime() - self.StageStartTime <= self.StageStartDuration then if timer.getTime() - self.StageStartTime <= self.StageStartDuration then
@ -140,15 +134,14 @@ STAGE_CARGO_LOAD = {
} }
function STAGE_CARGO_LOAD:New() function STAGE_CARGO_LOAD:New()
trace.f(self.ClassName)
-- Arrange meta tables
local self = BASE:Inherit( self, STAGE:New() ) local self = BASE:Inherit( self, STAGE:New() )
self:T()
self.StageType = 'CLIENT' self.StageType = 'CLIENT'
return self return self
end end
function STAGE_CARGO_LOAD:Execute( Mission, Client, Task ) function STAGE_CARGO_LOAD:Execute( Mission, Client, Task )
trace.f(self.ClassName) self:T()
local Valid = BASE:Inherited(self):Execute( Mission, Client, Task ) local Valid = BASE:Inherited(self):Execute( Mission, Client, Task )
for LoadCargoID, LoadCargo in pairs( Task.Cargos.LoadCargos ) do for LoadCargoID, LoadCargo in pairs( Task.Cargos.LoadCargos ) do
@ -163,7 +156,7 @@ trace.f(self.ClassName)
end end
function STAGE_CARGO_LOAD:Validate( Mission, Client, Task ) function STAGE_CARGO_LOAD:Validate( Mission, Client, Task )
trace.f(self.ClassName) self:T()
local Valid = STAGE:Validate( Mission, Client, Task ) local Valid = STAGE:Validate( Mission, Client, Task )
return 1 return 1
@ -175,26 +168,26 @@ STAGE_CARGO_INIT = {
} }
function STAGE_CARGO_INIT:New() function STAGE_CARGO_INIT:New()
trace.f(self.ClassName)
-- Arrange meta tables
local self = BASE:Inherit( self, STAGE:New() ) local self = BASE:Inherit( self, STAGE:New() )
self:T()
self.StageType = 'CLIENT' self.StageType = 'CLIENT'
return self return self
end end
function STAGE_CARGO_INIT:Execute( Mission, Client, Task ) function STAGE_CARGO_INIT:Execute( Mission, Client, Task )
trace.f(self.ClassName) self:T()
local Valid = BASE:Inherited(self):Execute( Mission, Client, Task ) local Valid = BASE:Inherited(self):Execute( Mission, Client, Task )
for InitLandingZoneID, InitLandingZone in pairs( Task.LandingZones.LandingZones ) do for InitLandingZoneID, InitLandingZone in pairs( Task.LandingZones.LandingZones ) do
trace.i( self.ClassName, InitLandingZone ) self:T( InitLandingZone )
InitLandingZone:Spawn() InitLandingZone:Spawn()
end end
for InitCargoID, InitCargo in pairs( Task.Cargos.InitCargos ) do self:T( Task.Cargos.InitCargos )
trace.i( self.ClassName ) for InitCargoID, InitCargoData in pairs( Task.Cargos.InitCargos ) do
InitCargo:Spawn() self:T( { InitCargoData } )
InitCargoData:Spawn()
end end
return Valid return Valid
@ -202,7 +195,7 @@ end
function STAGE_CARGO_INIT:Validate( Mission, Client, Task ) function STAGE_CARGO_INIT:Validate( Mission, Client, Task )
trace.f(self.ClassName) self:T()
local Valid = STAGE:Validate( Mission, Client, Task ) local Valid = STAGE:Validate( Mission, Client, Task )
return 1 return 1
@ -218,9 +211,8 @@ STAGEROUTE = {
} }
function STAGEROUTE:New() function STAGEROUTE:New()
trace.f(self.ClassName)
-- Arrange meta tables
local self = BASE:Inherit( self, STAGE:New() ) local self = BASE:Inherit( self, STAGE:New() )
self:T()
self.StageType = 'CLIENT' self.StageType = 'CLIENT'
self.MessageSwitch = true self.MessageSwitch = true
return self return self
@ -228,10 +220,11 @@ end
function STAGEROUTE:Execute( Mission, Client, Task ) function STAGEROUTE:Execute( Mission, Client, Task )
trace.f(self.ClassName) self:T()
local Valid = BASE:Inherited(self):Execute( Mission, Client, Task ) local Valid = BASE:Inherited(self):Execute( Mission, Client, Task )
local RouteMessage = "Fly to " local RouteMessage = "Fly to "
self:T( Task.LandingZones )
for LandingZoneID, LandingZoneName in pairs( Task.LandingZones.LandingZoneNames ) do for LandingZoneID, LandingZoneName in pairs( Task.LandingZones.LandingZoneNames ) do
RouteMessage = RouteMessage .. LandingZoneName .. ' at ' .. routines.getBRStringZone( { zone = LandingZoneName, ref = Client:GetClientGroupUnit():getPoint(), true, true } ) .. ' km. ' RouteMessage = RouteMessage .. LandingZoneName .. ' at ' .. routines.getBRStringZone( { zone = LandingZoneName, ref = Client:GetClientGroupUnit():getPoint(), true, true } ) .. ' km. '
end end
@ -245,11 +238,11 @@ trace.f(self.ClassName)
end end
function STAGEROUTE:Validate( Mission, Client, Task ) function STAGEROUTE:Validate( Mission, Client, Task )
trace.f(self.ClassName) self:T()
local Valid = STAGE:Validate( Mission, Client, Task ) local Valid = STAGE:Validate( Mission, Client, Task )
-- check if the Client is in the landing zone -- check if the Client is in the landing zone
trace.i( self.ClassName, Task.LandingZones.LandingZoneNames ) self:T( Task.LandingZones.LandingZoneNames )
Task.CurrentLandingZoneName = routines.IsUnitInZones( Client:GetClientGroupUnit(), Task.LandingZones.LandingZoneNames ) Task.CurrentLandingZoneName = routines.IsUnitInZones( Client:GetClientGroupUnit(), Task.LandingZones.LandingZoneNames )
if Task.CurrentLandingZoneName then if Task.CurrentLandingZoneName then
@ -279,15 +272,14 @@ STAGELANDING = {
} }
function STAGELANDING:New() function STAGELANDING:New()
trace.f(self.ClassName) local self = BASE:Inherit( self, STAGE:New() )
-- Arrange meta tables self:T()
local Child = BASE:Inherit( self, STAGE:New() ) self.StageType = 'CLIENT'
Child.StageType = 'CLIENT' return self
return Child
end end
function STAGELANDING:Execute( Mission, Client, Task ) function STAGELANDING:Execute( Mission, Client, Task )
trace.f(self.ClassName) self:T()
Client:Message( "We have arrived at the landing zone.", self.MSG.TIME, Mission.Name .. "/StageArrived", "Co-Pilot: Arrived", 10 ) Client:Message( "We have arrived at the landing zone.", self.MSG.TIME, Mission.Name .. "/StageArrived", "Co-Pilot: Arrived", 10 )
@ -307,12 +299,12 @@ trace.f(self.ClassName)
if Cargo.CargoType == Task.CargoType then if Cargo.CargoType == Task.CargoType then
if Cargo:IsLandingRequired() then if Cargo:IsLandingRequired() then
trace.i( self.ClassName, "Task for cargo " .. Cargo.CargoType .. " requires landing.") self:T( "Task for cargo " .. Cargo.CargoType .. " requires landing.")
Task.IsLandingRequired = true Task.IsLandingRequired = true
end end
if Cargo:IsSlingLoad() then if Cargo:IsSlingLoad() then
trace.i( self.ClassName, "Task for cargo " .. Cargo.CargoType .. " is a slingload.") self:T( "Task for cargo " .. Cargo.CargoType .. " is a slingload.")
Task.IsSlingLoad = true Task.IsSlingLoad = true
end end
@ -337,13 +329,13 @@ trace.f(self.ClassName)
end end
function STAGELANDING:Validate( Mission, Client, Task ) function STAGELANDING:Validate( Mission, Client, Task )
trace.f(self.ClassName) self:T()
Task.CurrentLandingZoneName = routines.IsUnitInZones( Client:GetClientGroupUnit(), Task.LandingZones.LandingZoneNames ) Task.CurrentLandingZoneName = routines.IsUnitInZones( Client:GetClientGroupUnit(), Task.LandingZones.LandingZoneNames )
if Task.CurrentLandingZoneName then if Task.CurrentLandingZoneName then
-- Client is in de landing zone. -- Client is in de landing zone.
trace.i( self.ClassName, Task.CurrentLandingZoneName ) self:T( Task.CurrentLandingZoneName )
Task.CurrentLandingZone = Task.LandingZones.LandingZones[Task.CurrentLandingZoneName].CargoZone Task.CurrentLandingZone = Task.LandingZones.LandingZones[Task.CurrentLandingZoneName].CargoZone
Task.CurrentCargoZone = Task.LandingZones.LandingZones[Task.CurrentLandingZoneName] Task.CurrentCargoZone = Task.LandingZones.LandingZones[Task.CurrentLandingZoneName]
@ -380,15 +372,14 @@ STAGELANDED = {
} }
function STAGELANDED:New() function STAGELANDED:New()
trace.f(self.ClassName) local self = BASE:Inherit( self, STAGE:New() )
-- Arrange meta tables self:T()
local Child = BASE:Inherit( self, STAGE:New() ) self.StageType = 'CLIENT'
Child.StageType = 'CLIENT' return self
return Child
end end
function STAGELANDED:Execute( Mission, Client, Task ) function STAGELANDED:Execute( Mission, Client, Task )
trace.f(self.ClassName) self:T()
if Task.IsLandingRequired then if Task.IsLandingRequired then
Client:Message( 'We have landed within the landing zone. Use the radio menu (F10) to ' .. Task.TEXT[1] .. ' the ' .. Task.CargoType .. '.', Client:Message( 'We have landed within the landing zone. Use the radio menu (F10) to ' .. Task.TEXT[1] .. ' the ' .. Task.CargoType .. '.',
@ -404,17 +395,17 @@ end
function STAGELANDED:Validate( Mission, Client, Task ) function STAGELANDED:Validate( Mission, Client, Task )
trace.f(self.ClassName) self:T()
if not routines.IsUnitInZones( Client:GetClientGroupUnit(), Task.CurrentLandingZoneName ) then if not routines.IsUnitInZones( Client:GetClientGroupUnit(), Task.CurrentLandingZoneName ) then
trace.i( self.ClassName, "Client is not anymore in the landing zone, go back to stage Route, and remove cargo menus." ) self:T( "Client is not anymore in the landing zone, go back to stage Route, and remove cargo menus." )
Task.Signalled = false Task.Signalled = false
Task:RemoveCargoMenus( Client ) Task:RemoveCargoMenus( Client )
return -2 return -2
end end
if Task.IsLandingRequired and Client:GetClientGroupUnit():inAir() then if Task.IsLandingRequired and Client:GetClientGroupUnit():inAir() then
trace.i( self.ClassName, "Client went back in the air. Go back to stage Landing." ) self:T( "Client went back in the air. Go back to stage Landing." )
Task.Signalled = false Task.Signalled = false
return -1 return -1
end end
@ -436,22 +427,21 @@ STAGEUNLOAD = {
} }
function STAGEUNLOAD:New() function STAGEUNLOAD:New()
trace.f(self.ClassName) local self = BASE:Inherit( self, STAGE:New() )
-- Arrange meta tables self:T()
local Child = BASE:Inherit( self, STAGE:New() ) self.StageType = 'CLIENT'
Child.StageType = 'CLIENT' return self
return Child
end end
function STAGEUNLOAD:Execute( Mission, Client, Task ) function STAGEUNLOAD:Execute( Mission, Client, Task )
trace.f(self.ClassName) self:T()
Client:Message( 'The ' .. Task.CargoType .. ' are being ' .. Task.TEXT[2] .. ' within the landing zone. Wait until the helicopter is ' .. Task.TEXT[3] .. '.', Client:Message( 'The ' .. Task.CargoType .. ' are being ' .. Task.TEXT[2] .. ' within the landing zone. Wait until the helicopter is ' .. Task.TEXT[3] .. '.',
self.MSG.TIME, Mission.Name .. "/StageUnLoad", "Co-Pilot: Unload" ) self.MSG.TIME, Mission.Name .. "/StageUnLoad", "Co-Pilot: Unload" )
Task:RemoveCargoMenus( Client ) Task:RemoveCargoMenus( Client )
end end
function STAGEUNLOAD:Executing( Mission, Client, Task ) function STAGEUNLOAD:Executing( Mission, Client, Task )
trace.f(self.ClassName) self:T()
env.info( 'STAGEUNLOAD:Executing() Task.Cargo.CargoName = ' .. Task.Cargo.CargoName ) env.info( 'STAGEUNLOAD:Executing() Task.Cargo.CargoName = ' .. Task.Cargo.CargoName )
local TargetZoneName local TargetZoneName
@ -471,7 +461,7 @@ trace.f(self.ClassName)
end end
function STAGEUNLOAD:Validate( Mission, Client, Task ) function STAGEUNLOAD:Validate( Mission, Client, Task )
trace.f(self.ClassName) self:T()
env.info( 'STAGEUNLOAD:Validate()' ) env.info( 'STAGEUNLOAD:Validate()' )
if routines.IsUnitInZones( Client:GetClientGroupUnit(), Task.CurrentLandingZoneName ) then if routines.IsUnitInZones( Client:GetClientGroupUnit(), Task.CurrentLandingZoneName ) then
@ -509,15 +499,14 @@ STAGELOAD = {
} }
function STAGELOAD:New() function STAGELOAD:New()
trace.f(self.ClassName) local self = BASE:Inherit( self, STAGE:New() )
-- Arrange meta tables self:T()
local Child = BASE:Inherit( self, STAGE:New() ) self.StageType = 'CLIENT'
Child.StageType = 'CLIENT' return self
return Child
end end
function STAGELOAD:Execute( Mission, Client, Task ) function STAGELOAD:Execute( Mission, Client, Task )
trace.f(self.ClassName) self:T()
if not Task.IsSlingLoad then if not Task.IsSlingLoad then
Client:Message( 'The ' .. Task.CargoType .. ' are being ' .. Task.TEXT[2] .. ' within the landing zone. Wait until the helicopter is ' .. Task.TEXT[3] .. '.', Client:Message( 'The ' .. Task.CargoType .. ' are being ' .. Task.TEXT[2] .. ' within the landing zone. Wait until the helicopter is ' .. Task.TEXT[3] .. '.',
@ -532,7 +521,7 @@ trace.f(self.ClassName)
end end
function STAGELOAD:Executing( Mission, Client, Task ) function STAGELOAD:Executing( Mission, Client, Task )
trace.f(self.ClassName) self:T()
-- If the Cargo is ready to be loaded, load it into the Client. -- If the Cargo is ready to be loaded, load it into the Client.
@ -556,7 +545,7 @@ trace.f(self.ClassName)
Client:Message( "Hook the " .. Task.CargoNames .. " onto the helicopter " .. Task.TEXT[3] .. " within the landing zone.", Client:Message( "Hook the " .. Task.CargoNames .. " onto the helicopter " .. Task.TEXT[3] .. " within the landing zone.",
_TransportStageMsgTime.EXECUTING, Mission.Name .. "/STAGELOAD.LOADING.1." .. Task.HostUnitName, Task.HostUnitName .. " (" .. Task.HostUnitTypeName .. ")" .. ":", 10 ) _TransportStageMsgTime.EXECUTING, Mission.Name .. "/STAGELOAD.LOADING.1." .. Task.HostUnitName, Task.HostUnitName .. " (" .. Task.HostUnitTypeName .. ")" .. ":", 10 )
for CargoID, Cargo in pairs( CARGOS ) do for CargoID, Cargo in pairs( CARGOS ) do
trace.i( self.ClassName, "Cargo.CargoName = " .. Cargo.CargoName ) self:T( "Cargo.CargoName = " .. Cargo.CargoName )
if Cargo:IsSlingLoad() then if Cargo:IsSlingLoad() then
local CargoStatic = StaticObject.getByName( Cargo.CargoStaticName ) local CargoStatic = StaticObject.getByName( Cargo.CargoStaticName )
@ -575,7 +564,7 @@ trace.f(self.ClassName)
break break
end end
else else
trace.i( self.ClassName, "Cargo not found in the DCS simulator." ) self:T( "Cargo not found in the DCS simulator." )
end end
end end
end end
@ -584,9 +573,9 @@ trace.f(self.ClassName)
end end
function STAGELOAD:Validate( Mission, Client, Task ) function STAGELOAD:Validate( Mission, Client, Task )
trace.f(self.ClassName) self:T()
trace.i( self.ClassName, "Task.CurrentLandingZoneName = " .. Task.CurrentLandingZoneName ) self:T( "Task.CurrentLandingZoneName = " .. Task.CurrentLandingZoneName )
if not Task.IsSlingLoad then if not Task.IsSlingLoad then
if not routines.IsUnitInZones( Client:GetClientGroupUnit(), Task.CurrentLandingZoneName ) then if not routines.IsUnitInZones( Client:GetClientGroupUnit(), Task.CurrentLandingZoneName ) then
@ -634,93 +623,6 @@ trace.f(self.ClassName)
return 0 return 0
end end
STAGE_SLINGLOAD_HOOK = {
ClassName = "STAGE_SLINGLOAD_HOOK",
MSG = { ID = "SlingLoadHook", TIME = 10 },
Name = "SlingLoadHook"
}
function STAGE_SLINGLOAD_HOOK:New()
trace.f(self.ClassName)
-- Arrange meta tables
local self = BASE:Inherit( self, STAGE:New() )
self.StageType = 'CLIENT'
return self
end
function STAGE_SLINGLOAD_HOOK:Execute( Mission, Client, Task )
trace.f(self.ClassName)
Client:Message( 'Hook the Cargo onto the helicopter, and fly out the pick-up zone. Due to a bug in DCS world it cannot be chacked (for the moment) ' ..
'if the cargo is in our out of the zone and attached to your helicopter...', self.MSG.TIME, Mission.Name .. "/Stage", "Co-Pilot: Hook" )
end
function STAGE_SLINGLOAD_HOOK:Validate( Mission, Client, Task )
trace.f(self.ClassName)
for CargoID, CargoName in pairs( Task.CargoPrefixes ) do
env.info( CargoName )
if StaticObject.getByName( CargoName ):inAir() then
Task.CargoName = CargoName
Task.CargoID = CargoID
Client:Message( 'Co-Pilot: The Cargo has been successfully hooked onto the helicopter within the landing zone.', self.MSG.TIME, Mission.Name .. "/StageSuccess" )
break
end
end
if Task.CargoName then
if routines.IsStaticInZones( StaticObject.getByName( Task.CargoName ), Task.CurrentLandingZoneName ) then
else
return 1
end
end
return 1
end
STAGE_SLINGLOAD_UNHOOK = {
ClassName = "STAGE_SLINGLOAD_UNHOOK",
MSG = { ID = "SlingLoadUnHook", TIME = 10 },
Name = "SlingLoadUnHook"
}
function STAGE_SLINGLOAD_UNHOOK:New()
trace.f(self.ClassName)
-- Arrange meta tables
local self = BASE:Inherit( self, STAGE:New() )
self.StageType = 'CLIENT'
return self
end
function STAGE_SLINGLOAD_UNHOOK:Execute( Mission, Client, Task )
trace.f(self.ClassName)
Client:Message( 'Deploy the Cargo in the Landing Zone and unhook the cargo, and fly out of the drop zone.', self.MSG.TIME, Mission.Name .. "/StageUnhook", "Co-Pilot: Unhook" )
end
function STAGE_SLINGLOAD_UNHOOK:Validate( Mission, Client, Task )
trace.f(self.ClassName)
for CargoID, CargoName in pairs( Task.CargoPrefixes ) do
if StaticObject.getByName( CargoName ):inAir() then
Task.CargoName = CargoName
Task.CargoID = CargoID
Client:Message( 'Co-Pilot: Drop the cargo within the landing zone and unhook.', self.MSG.TIME, Mission.Name .. "/Stage" )
break
end
end
if Task.CargoName then
if not StaticObject.getByName( Task.CargoName ):inAir() then
if routines.IsUnitInZones( Client:GetClientGroupUnit(), Task.CurrentLandingZoneName ) then
else
Client:Message( 'Co-Pilot: The Cargo is Dropped in the Landing Zone, and You have flown outside of the landing zone.', self.MSG.TIME, Mission.Name .. "/Stage" )
return 1
end
end
end
return 1
end
STAGEDONE = { STAGEDONE = {
ClassName = "STAGEDONE", ClassName = "STAGEDONE",
@ -729,20 +631,19 @@ STAGEDONE = {
} }
function STAGEDONE:New() function STAGEDONE:New()
trace.f(self.ClassName) local self = BASE:Inherit( self, STAGE:New() )
-- Arrange meta tables self:T()
local Child = BASE:Inherit( self, STAGE:New() ) self.StageType = 'AI'
Child.StageType = 'AI' return self
return Child
end end
function STAGEDONE:Execute( Mission, Client, Task ) function STAGEDONE:Execute( Mission, Client, Task )
trace.f(self.ClassName) self:T()
end end
function STAGEDONE:Validate( Mission, Client, Task ) function STAGEDONE:Validate( Mission, Client, Task )
trace.f(self.ClassName) self:T()
Task:Done() Task:Done()
@ -756,22 +657,21 @@ STAGEARRIVE = {
} }
function STAGEARRIVE:New() function STAGEARRIVE:New()
trace.f(self.ClassName) local self = BASE:Inherit( self, STAGE:New() )
-- Arrange meta tables self:T()
local Child = BASE:Inherit( self, STAGE:New() ) self.StageType = 'CLIENT'
Child.StageType = 'CLIENT' return self
return Child
end end
function STAGEARRIVE:Execute( Mission, Client, Task ) function STAGEARRIVE:Execute( Mission, Client, Task )
trace.f(self.ClassName) self:T()
Client:Message( 'We have arrived at ' .. Task.CurrentLandingZoneName .. ".", self.MSG.TIME, Mission.Name .. "/Stage", "Co-Pilot: Arrived" ) Client:Message( 'We have arrived at ' .. Task.CurrentLandingZoneName .. ".", self.MSG.TIME, Mission.Name .. "/Stage", "Co-Pilot: Arrived" )
end end
function STAGEARRIVE:Validate( Mission, Client, Task ) function STAGEARRIVE:Validate( Mission, Client, Task )
trace.f(self.ClassName) self:T()
Task.CurrentLandingZoneID = routines.IsUnitInZones( Client:GetClientGroupUnit(), Task.LandingZones ) Task.CurrentLandingZoneID = routines.IsUnitInZones( Client:GetClientGroupUnit(), Task.LandingZones )
if ( Task.CurrentLandingZoneID ) then if ( Task.CurrentLandingZoneID ) then
@ -791,11 +691,10 @@ STAGEGROUPSDESTROYED = {
} }
function STAGEGROUPSDESTROYED:New() function STAGEGROUPSDESTROYED:New()
trace.f(self.ClassName) local self = BASE:Inherit( self, STAGE:New() )
-- Arrange meta tables self:T()
local Child = BASE:Inherit( self, STAGE:New() ) self.StageType = 'AI'
Child.StageType = 'AI' return self
return Child
end end
--function STAGEGROUPSDESTROYED:Execute( Mission, Client, Task ) --function STAGEGROUPSDESTROYED:Execute( Mission, Client, Task )
@ -805,7 +704,7 @@ end
--end --end
function STAGEGROUPSDESTROYED:Validate( Mission, Client, Task ) function STAGEGROUPSDESTROYED:Validate( Mission, Client, Task )
trace.f(self.ClassName) self:T()
if Task.MissionTask:IsGoalReached() then if Task.MissionTask:IsGoalReached() then
return 1 return 1
@ -815,8 +714,8 @@ trace.f(self.ClassName)
end end
function STAGEGROUPSDESTROYED:Execute( Mission, Client, Task ) function STAGEGROUPSDESTROYED:Execute( Mission, Client, Task )
trace.f(self.ClassName) self:T()
trace.i( self.ClassName, { Task.ClassName, Task.Destroyed } ) self:T( { Task.ClassName, Task.Destroyed } )
--env.info( 'Event Table Task = ' .. tostring(Task) ) --env.info( 'Event Table Task = ' .. tostring(Task) )
end end

View File

@ -0,0 +1,126 @@
Include.File( "Mission" )
Include.File( "Client" )
Include.File( "DeployTask" )
Include.File( "PickupTask" )
Include.File( "DestroyGroupsTask" )
Include.File( "DestroyRadarsTask" )
Include.File( "DestroyUnitTypesTask" )
Include.File( "GoHomeTask" )
Include.File( "Spawn" )
Include.File( "Movement" )
Include.File( "Sead" )
Include.File( "CleanUp" )
do
local Mission = MISSION:New( 'Pickup', 'Operational', 'Pickup Troops', 'NATO' )
Mission:AddClient( CLIENT:New( 'DE Pickup Test 1' ):Transport() )
Mission:AddClient( CLIENT:New( 'DE Pickup Test 2' ):Transport() )
local CargoTable = {}
local EngineerNames = { "Alpha", "Beta", "Gamma", "Delta", "Theta" }
Cargo_Pickup_Zone_1 = CARGO_ZONE:New( 'Pickup Zone 1', 'DE Communication Center 1' ):BlueSmoke()
Cargo_Pickup_Zone_2 = CARGO_ZONE:New( 'Pickup Zone 2', 'DE Communication Center 2' ):RedSmoke()
for CargoItem = 1, 2 do
CargoTable[CargoItem] = CARGO_GROUP:New( 'Engineers', 'Team ' .. EngineerNames[CargoItem], math.random( 70, 100 ) * 3, 'DE Infantry', Cargo_Pickup_Zone_1 )
end
for CargoItem = 3, 5 do
CargoTable[CargoItem] = CARGO_GROUP:New( 'Engineers', 'Team ' .. EngineerNames[CargoItem], math.random( 70, 100 ) * 3, 'DE Infantry', Cargo_Pickup_Zone_2 )
end
--Cargo_Package = CARGO_INVISIBLE:New( 'Letter', 0.1, 'DE Secret Agent', 'Pickup Zone Package' )
--Cargo_Goods = CARGO_STATIC:New( 'Goods', 20, 'Goods', 'Pickup Zone Goods', 'DE Collection Point' )
--Cargo_SlingLoad = CARGO_SLING:New( 'Basket', 40, 'Basket', 'Pickup Zone Sling Load', 'DE Cargo Guard' )
-- Assign the Pickup Task
local PickupTask = PICKUPTASK:New( 'Engineers', CLIENT.ONBOARDSIDE.LEFT )
PickupTask:FromZone( Cargo_Pickup_Zone_1 )
PickupTask:FromZone( Cargo_Pickup_Zone_2 )
PickupTask:InitCargo( CargoTable )
PickupTask:SetGoalTotal( 3 )
Mission:AddTask( PickupTask, 1 )
Cargo_Deploy_Zone_1 = CARGO_ZONE:New( 'Deploy Zone 1', 'DE Communication Center 3' ):RedFlare()
Cargo_Deploy_Zone_2 = CARGO_ZONE:New( 'Deploy Zone 2', 'DE Communication Center 4' ):WhiteFlare()
-- Assign the Pickup Task
local DeployTask = DEPLOYTASK:New( 'Engineers' )
DeployTask:ToZone( Cargo_Deploy_Zone_1 )
DeployTask:ToZone( Cargo_Deploy_Zone_2 )
DeployTask:SetGoalTotal( 3 )
Mission:AddTask( DeployTask, 2 )
MISSIONSCHEDULER.AddMission( Mission )
end
do
local Mission = MISSION:New( 'Deliver secret letter', 'Operational', 'Pickup letter to the commander.', 'NATO' )
Mission:AddClient( CLIENT:New( 'BE Package Test 1' ):Transport() )
Mission:AddClient( CLIENT:New( 'BE Package Test 2' ):Transport() )
Mission:AddClient( CLIENT:New( 'DE Pickup Test 1' ):Transport() )
Mission:AddClient( CLIENT:New( 'DE Pickup Test 2' ):Transport() )
Package_Pickup_Zone = CARGO_ZONE:New( 'Package Pickup Zone', 'DE Guard' ):GreenSmoke()
Cargo_Package = CARGO_PACKAGE:New( 'Letter', 'Letter to Command', 0.1, 'DE Guard' )
--Cargo_Goods = CARGO_STATIC:New( 'Goods', 20, 'Goods', 'Pickup Zone Goods', 'DE Collection Point' )
--Cargo_SlingLoad = CARGO_SLING:New( 'Basket', 40, 'Basket', 'Pickup Zone Sling Load', 'DE Cargo Guard' )
-- Assign the Pickup Task
local PickupTask = PICKUPTASK:New( 'Letter', CLIENT.ONBOARDSIDE.FRONT )
PickupTask:FromZone( Package_Pickup_Zone )
PickupTask:InitCargo( { Cargo_Package } )
PickupTask:SetGoalTotal( 1 )
Mission:AddTask( PickupTask, 1 )
Package_Deploy_Zone = CARGO_ZONE:New( 'Package Deploy Zone', 'DE Secret Car' ):GreenFlare()
-- Assign the Pickup Task
local DeployTask = DEPLOYTASK:New( 'Letter' )
DeployTask:ToZone( Package_Deploy_Zone )
DeployTask:SetGoalTotal( 1 )
Mission:AddTask( DeployTask, 2 )
MISSIONSCHEDULER.AddMission( Mission )
end
do
local Mission = MISSION:New( 'Sling load Cargo', 'Operational', 'Sling Load Cargo to Deploy Zone.', 'NATO' )
Mission:AddClient( CLIENT:New( 'Sling Load Test Client 1' ):Transport() )
Mission:AddClient( CLIENT:New( 'Sling Load Test Client 2' ):Transport() )
Sling_Load_Pickup_Zone = CARGO_ZONE:New( 'Sling Load Pickup Zone', 'Sling Load Guard' ):RedSmoke()
Cargo_Sling_Load = CARGO_SLINGLOAD:New( 'Sling', 'Food Boxes', 200, 'Sling Load Pickup Zone', 'Sling Load Guard', country.id.USA )
--Cargo_Goods = CARGO_STATIC:New( 'Goods', 20, 'Goods', 'Pickup Zone Goods', 'DE Collection Point' )
--Cargo_SlingLoad = CARGO_SLING:New( 'Basket', 40, 'Basket', 'Pickup Zone Sling Load', 'DE Cargo Guard' )
-- Assign the Pickup Task
local PickupTask = PICKUPTASK:New( 'Sling', CLIENT.ONBOARDSIDE.FRONT )
PickupTask:FromZone( Sling_Load_Pickup_Zone )
PickupTask:InitCargo( { Cargo_Sling_Load } )
PickupTask:SetGoalTotal( 1 )
Mission:AddTask( PickupTask, 1 )
MISSIONSCHEDULER.AddMission( Mission )
end
-- MISSION SCHEDULER STARTUP
MISSIONSCHEDULER.Start()
MISSIONSCHEDULER.ReportMenu()
MISSIONSCHEDULER.ReportMissionsHide()
env.info( "Test Mission loaded" )

Binary file not shown.

View File

@ -0,0 +1,15 @@
Include.File( "Spawn" )
SpawnTest = SPAWN:New( 'TEST' ):Schedule( 1, 1, 15, 0.4 ):Repeat()
SpawnTestPlane = SPAWN:New( 'TESTPLANE' ):Schedule( 1, 1, 15, 0.4 ):RepeatOnLanding()
SpawnTestShipPlane = SPAWN:New( 'SHIPPLANE' ):Schedule( 1, 1, 15, 0.4 ):RepeatOnLanding()
SpawnTestShipHeli = SPAWN:New( 'SHIPHELI' ):Schedule( 1, 1, 15, 0.4 ):RepeatOnLanding()
SpawnCH53E = SPAWN:New( 'VEHICLE' )
SpawnTestHelicopterCleanUp = SPAWN:New( "TEST_HELI_CLEANUP" ):Limit( 3, 100 ):Schedule( 10, 0 ):RandomizeRoute( 1, 1, 1000 ):CleanUp( 180 )
SpawnTestVehiclesCleanUp = SPAWN:New( "TEST_AAA_CLEANUP" ):Limit( 3, 100 ):Schedule( 10, 0 ):RandomizeRoute( 1, 1, 1000 )

Binary file not shown.