mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Work in progress. Reworking complete CARGO logic... Partly working now ...
This commit is contained in:
324
Moose/Stage.lua
324
Moose/Stage.lua
@@ -56,10 +56,10 @@ end
|
||||
|
||||
STAGEBRIEF = {
|
||||
ClassName = "BRIEF",
|
||||
MSG = { ID = "Brief", TIME = 30 },
|
||||
MSG = { ID = "Brief", TIME = 1 },
|
||||
Name = "Brief",
|
||||
StageBriefingTime = 0,
|
||||
StageBriefingDuration = 30
|
||||
StageBriefingDuration = 1
|
||||
}
|
||||
|
||||
function STAGEBRIEF:New()
|
||||
@@ -94,10 +94,10 @@ end
|
||||
|
||||
STAGESTART = {
|
||||
ClassName = "START",
|
||||
MSG = { ID = "Start", TIME = 30 },
|
||||
MSG = { ID = "Start", TIME = 1 },
|
||||
Name = "Start",
|
||||
StageStartTime = 0,
|
||||
StageStartDuration = 30
|
||||
StageStartDuration = 1
|
||||
}
|
||||
|
||||
function STAGESTART:New()
|
||||
@@ -135,6 +135,81 @@ trace.f(self.ClassName)
|
||||
|
||||
end
|
||||
|
||||
STAGE_CARGO_LOAD = {
|
||||
ClassName = "STAGE_CARGO_LOAD"
|
||||
}
|
||||
|
||||
function STAGE_CARGO_LOAD:New()
|
||||
trace.f(self.ClassName)
|
||||
-- Arrange meta tables
|
||||
local self = BASE:Inherit( self, STAGE:New() )
|
||||
self.StageType = 'CLIENT'
|
||||
return self
|
||||
end
|
||||
|
||||
function STAGE_CARGO_LOAD:Execute( Mission, Client, Task )
|
||||
trace.f(self.ClassName)
|
||||
local Valid = BASE:Inherited(self):Execute( Mission, Client, Task )
|
||||
|
||||
for LoadCargoID, LoadCargo in pairs( Task.Cargos.LoadCargos ) do
|
||||
LoadCargo:Load( Client )
|
||||
end
|
||||
|
||||
if Client:IsTransport() then
|
||||
Client:ShowCargo()
|
||||
end
|
||||
|
||||
return Valid
|
||||
end
|
||||
|
||||
function STAGE_CARGO_LOAD:Validate( Mission, Client, Task )
|
||||
trace.f(self.ClassName)
|
||||
local Valid = STAGE:Validate( Mission, Client, Task )
|
||||
|
||||
return 1
|
||||
end
|
||||
|
||||
|
||||
STAGE_CARGO_INIT = {
|
||||
ClassName = "STAGE_CARGO_INIT"
|
||||
}
|
||||
|
||||
function STAGE_CARGO_INIT:New()
|
||||
trace.f(self.ClassName)
|
||||
-- Arrange meta tables
|
||||
local self = BASE:Inherit( self, STAGE:New() )
|
||||
self.StageType = 'CLIENT'
|
||||
return self
|
||||
end
|
||||
|
||||
function STAGE_CARGO_INIT:Execute( Mission, Client, Task )
|
||||
trace.f(self.ClassName)
|
||||
local Valid = BASE:Inherited(self):Execute( Mission, Client, Task )
|
||||
|
||||
for InitLandingZoneID, InitLandingZone in pairs( Task.LandingZones.LandingZones ) do
|
||||
trace.i( self.ClassName, InitLandingZone )
|
||||
InitLandingZone:Spawn()
|
||||
end
|
||||
|
||||
|
||||
for InitCargoID, InitCargo in pairs( Task.Cargos.InitCargos ) do
|
||||
trace.i( self.ClassName )
|
||||
InitCargo:Spawn()
|
||||
end
|
||||
|
||||
return Valid
|
||||
end
|
||||
|
||||
|
||||
function STAGE_CARGO_INIT:Validate( Mission, Client, Task )
|
||||
trace.f(self.ClassName)
|
||||
local Valid = STAGE:Validate( Mission, Client, Task )
|
||||
|
||||
return 1
|
||||
end
|
||||
|
||||
|
||||
|
||||
STAGEROUTE = {
|
||||
ClassName = "STAGEROUTE",
|
||||
MSG = { ID = "Route", TIME = 1 },
|
||||
@@ -156,15 +231,12 @@ function STAGEROUTE:Execute( Mission, Client, Task )
|
||||
trace.f(self.ClassName)
|
||||
local Valid = BASE:Inherited(self):Execute( Mission, Client, Task )
|
||||
|
||||
if type( Task.LandingZones) == "table" then
|
||||
local RouteMessage = "Fly to "
|
||||
for LandingZoneID, LandingZoneName in pairs( Task.LandingZones ) do
|
||||
RouteMessage = RouteMessage .. LandingZoneName .. ' at ' .. routines.getBRStringZone( { zone = LandingZoneName, ref = Client:ClientGroup():getUnit(1):getPoint(), true, true } ) .. ' km. '
|
||||
end
|
||||
Client:Message( RouteMessage, self.MSG.TIME, Mission.Name .. "/StageRoute", "Co-Pilot: Route", 10 )
|
||||
else
|
||||
Client:Message( "Fly to " .. Task.LandingZones .. ' at ' .. routines.getBRStringZone( { zone = Task.LandingZones, ref = Client:ClientGroup():getUnit(1):getPoint(), true, true } ) .. ' km. ', self.MSG.TIME, Mission.Name .. "/StageRoute", "Co-Pilot: Route", 1 )
|
||||
local RouteMessage = "Fly to "
|
||||
for LandingZoneID, LandingZoneName in pairs( Task.LandingZones.LandingZoneNames ) do
|
||||
RouteMessage = RouteMessage .. LandingZoneName .. ' at ' .. routines.getBRStringZone( { zone = LandingZoneName, ref = Client:ClientGroup():getUnit(1):getPoint(), true, true } ) .. ' km. '
|
||||
end
|
||||
Client:Message( RouteMessage, self.MSG.TIME, Mission.Name .. "/StageRoute", "Co-Pilot: Route", 10 )
|
||||
|
||||
if Client:IsTransport() then
|
||||
Client:ShowCargo()
|
||||
end
|
||||
@@ -174,56 +246,27 @@ end
|
||||
|
||||
function STAGEROUTE:Validate( Mission, Client, Task )
|
||||
trace.f(self.ClassName)
|
||||
local Valid = STAGE:Validate( Mission, Client, Task )
|
||||
local Valid = STAGE:Validate( Mission, Client, Task )
|
||||
|
||||
-- check if the Client is in the landing zone
|
||||
trace.i( self.ClassName, Task.LandingZones.LandingZoneNames )
|
||||
Task.CurrentLandingZoneName = routines.IsUnitInZones( Client:ClientUnit(), Task.LandingZones.LandingZoneNames )
|
||||
|
||||
if Task.CurrentLandingZoneName then
|
||||
|
||||
-- check if this carrier is in the landing zone
|
||||
Task.CurrentLandingZoneID = routines.IsUnitInZones( Client:ClientGroup():getUnits()[1], Task.LandingZones )
|
||||
if ( Task.CurrentLandingZoneID ) then
|
||||
if not Task.Signalled then
|
||||
|
||||
if Task.LandingZoneSignalType then
|
||||
env.info( 'TransportSchedule: Task.LandingZoneSignalType = ' .. Task.LandingZoneSignalType.TEXT )
|
||||
if Task.LandingZoneSignalUnitNames then
|
||||
local LandingZoneSignalUnit = Task.LandingZoneSignalUnitNames[Task.CurrentLandingZoneID]
|
||||
trace.i( self.ClassName, 'LandingZoneSignalUnit = ' .. LandingZoneSignalUnit )
|
||||
|
||||
local SignalUnit = Unit.getByName(LandingZoneSignalUnit)
|
||||
if SignalUnit == nil then
|
||||
SignalUnit = StaticObject.getByName( LandingZoneSignalUnit )
|
||||
end
|
||||
if SignalUnit ~= nil then
|
||||
trace.i( self.ClassName, 'Signalling Unit' )
|
||||
local SignalVehiclePos = SignalUnit:getPosition().p
|
||||
SignalVehiclePos.y = SignalVehiclePos.y + Task.LandingZoneSignalHeight
|
||||
if Task.LandingZoneSignalType.ID == Task.SIGNAL.TYPE.SMOKE.ID then
|
||||
trigger.action.smoke( SignalVehiclePos, Task.LandingZoneSignalColor.COLOR )
|
||||
elseif Task.LandingZoneSignalType.ID == Task.SIGNAL.TYPE.FLARE.ID then
|
||||
trigger.action.signalFlare( SignalVehiclePos, Task.LandingZoneSignalColor.COLOR, 0 )
|
||||
end
|
||||
end
|
||||
else
|
||||
env.info( 'TransportSchedule: Signaling landing zone ' )
|
||||
|
||||
local LandingZone = trigger.misc.getZone( Task.LandingZones [ Task.CurrentLandingZoneID ] )
|
||||
local CurrentPosition = { x = LandingZone.point.x, y = LandingZone.point.z }
|
||||
LandingZone.point.y = land.getHeight( CurrentPosition ) + 10
|
||||
|
||||
if Task.LandingZoneSignalType.ID == Task.SIGNAL.TYPE.SMOKE.ID then
|
||||
env.info( 'TransportSchedule: Smoking zone x = ' .. LandingZone.point.x .. ' y = ' .. LandingZone.point.y .. ' z = ' .. LandingZone.point.z )
|
||||
trigger.action.smoke( LandingZone.point, Task.LandingZoneSignalColor.COLOR )
|
||||
elseif Task.LandingZoneSignalType.ID == Task.SIGNAL.TYPE.SMOKE.FLARE.ID then
|
||||
env.info( 'TransportSchedule: Flaring zone x = ' .. LandingZone.point.x .. ' y = ' .. LandingZone.point.y .. ' z = ' .. LandingZone.point.z )
|
||||
trigger.action.signalFlare( LandingZone.point, Task.LandingZoneSignalColor.COLOR, 0 )
|
||||
end
|
||||
Task.CurrentLandingZone = Task.LandingZones.LandingZones[Task.CurrentLandingZoneName].CargoZone
|
||||
Task.CurrentCargoZone = Task.LandingZones.LandingZones[Task.CurrentLandingZoneName]
|
||||
|
||||
if Task.CurrentCargoZone then
|
||||
if not Task.Signalled then
|
||||
Task.Signalled = Task.CurrentCargoZone:Signal()
|
||||
end
|
||||
end
|
||||
self.Signalled = true
|
||||
|
||||
return 1
|
||||
end
|
||||
return 1
|
||||
end
|
||||
|
||||
return 0
|
||||
|
||||
return 0
|
||||
end
|
||||
|
||||
STAGELANDING = {
|
||||
@@ -244,27 +287,49 @@ end
|
||||
function STAGELANDING:Execute( Mission, Client, Task )
|
||||
trace.f(self.ClassName)
|
||||
|
||||
Client:Message( 'We have arrived at ' .. Task.LandingZones[Task.CurrentLandingZoneID] .. '. Land the helicopter to ' .. Task.TEXT[1] .. ' the ' .. Task.CargoType.TEXT .. '.',
|
||||
self.MSG.TIME, Mission.Name .. "/Stage", "Co-Pilot: Landing" )
|
||||
Client:Message( 'We have arrived at ' .. Task.CurrentLandingZoneName .. '. Land the helicopter to ' .. Task.TEXT[1] .. ' the ' .. Task.CargoType .. '.',
|
||||
self.MSG.TIME, Mission.Name .. "/StageLanding", "Co-Pilot: Landing", 10 )
|
||||
|
||||
end
|
||||
|
||||
function STAGELANDING:Validate( Mission, Client, Task )
|
||||
trace.f(self.ClassName)
|
||||
|
||||
if routines.IsUnitInZones( Client:ClientGroup():getUnits()[1], Task.LandingZones[Task.CurrentLandingZoneID] ) then
|
||||
else
|
||||
Task.Signalled = false
|
||||
Task:RemoveCargoMenus( Client )
|
||||
return -1
|
||||
end
|
||||
if routines.IsUnitInZones( Client:ClientUnit(), Task.CurrentLandingZoneName ) then
|
||||
-- check if the Client is in the landing zone
|
||||
trace.i( self.ClassName, Task.LandingZones.LandingZoneNames )
|
||||
Task.CurrentLandingZoneName = routines.IsUnitInZones( Client:ClientUnit(), Task.LandingZones.LandingZoneNames )
|
||||
|
||||
if Task.CurrentLandingZoneName then
|
||||
|
||||
Task.CurrentLandingZone = Task.LandingZones.LandingZones[Task.CurrentLandingZoneName].CargoZone
|
||||
Task.CurrentCargoZone = Task.LandingZones.LandingZones[Task.CurrentLandingZoneName]
|
||||
|
||||
if Task.CurrentCargoZone then
|
||||
if not Task.Signalled then
|
||||
Task.Signalled = Task.CurrentCargoZone:Signal()
|
||||
end
|
||||
end
|
||||
else
|
||||
if Task.CurrentLandingZone then
|
||||
Task.CurrentLandingZone = nil
|
||||
end
|
||||
if Task.CurrentCargoZone then
|
||||
Task.CurrentCargoZone = nil
|
||||
end
|
||||
end
|
||||
else
|
||||
Task.Signalled = false
|
||||
Task:RemoveCargoMenus( Client )
|
||||
return -1
|
||||
end
|
||||
|
||||
if not Client:ClientGroup():getUnits()[1]:inAir() then
|
||||
else
|
||||
return 0
|
||||
end
|
||||
if not Client:ClientUnit():inAir() then
|
||||
else
|
||||
return 0
|
||||
end
|
||||
|
||||
return 1
|
||||
return 1
|
||||
end
|
||||
|
||||
STAGELANDED = {
|
||||
@@ -284,10 +349,10 @@ end
|
||||
|
||||
function STAGELANDED:Execute( Mission, Client, Task )
|
||||
trace.f(self.ClassName)
|
||||
Client:Message( 'We have landed within the landing zone. Use the radio menu (F10) to ' .. Task.TEXT[1] .. ' the ' .. Task.CargoType.TEXT .. '.', self.MSG.TIME, Mission.Name .. "/Stage", "Co-Pilot: Landed" )
|
||||
Client:Message( 'We have landed within the landing zone. Use the radio menu (F10) to ' .. Task.TEXT[1] .. ' the ' .. Task.CargoType .. '.', self.MSG.TIME, Mission.Name .. "/StageLanded", "Co-Pilot: Landed" )
|
||||
if not self.MenusAdded then
|
||||
Task:RemoveCargoMenus( Client )
|
||||
Task:AddCargoMenus( Client, Mission._Cargos, 250 )
|
||||
Task:AddCargoMenus( Client, CARGOS, 250 )
|
||||
end
|
||||
end
|
||||
|
||||
@@ -296,14 +361,14 @@ end
|
||||
function STAGELANDED:Validate( Mission, Client, Task )
|
||||
trace.f(self.ClassName)
|
||||
|
||||
if routines.IsUnitInZones( Client:ClientGroup():getUnits()[1], Task.LandingZones[Task.CurrentLandingZoneID] ) then
|
||||
if routines.IsUnitInZones( Client:ClientUnit(), Task.CurrentLandingZoneName ) then
|
||||
else
|
||||
Task.Signalled = false
|
||||
Task:RemoveCargoMenus( Client )
|
||||
return -2
|
||||
end
|
||||
|
||||
if not Client:ClientGroup():getUnits()[1]:inAir() then
|
||||
if not Client:ClientUnit():inAir() then
|
||||
else
|
||||
Task.Signalled = false
|
||||
return -1
|
||||
@@ -333,33 +398,24 @@ end
|
||||
|
||||
function STAGEUNLOAD:Execute( Mission, Client, Task )
|
||||
trace.f(self.ClassName)
|
||||
Client:Message( 'The ' .. Task.CargoType.TEXT .. ' are being ' .. Task.TEXT[2] .. ' within the landing zone. Wait until the helicopter is ' .. Task.TEXT[3] .. '.',
|
||||
self.MSG.TIME, Mission.Name .. "/Stage", "Co-Pilot: Unload" )
|
||||
Task:RemoveCargoMenus( Client )
|
||||
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" )
|
||||
Task:RemoveCargoMenus( Client )
|
||||
end
|
||||
|
||||
function STAGEUNLOAD:Executing( Mission, Client, Task )
|
||||
trace.f(self.ClassName)
|
||||
env.info( 'STAGEUNLOAD:Executing() Task.CargoName = ' .. Task.CargoName )
|
||||
local Cargo = Client:RemoveCargo( Task.CargoName )
|
||||
if Cargo then
|
||||
env.info( 'STAGEUNLOAD:Executing() Cargo.CargoName = ' .. Cargo.CargoName )
|
||||
env.info( 'STAGEUNLOAD:Executing() Cargo.CargoGroupName = ' .. Cargo.CargoGroupName )
|
||||
env.info( 'STAGEUNLOAD:Executing() Mission._Cargos[Cargo.CargoName].CargoGroupTemplate = ' .. Mission._Cargos[Cargo.CargoName].CargoGroupTemplate )
|
||||
|
||||
if Cargo.CargoType.TRANSPORT == CARGO_TRANSPORT.UNIT then
|
||||
if Cargo.CargoName then
|
||||
if Task.TargetZoneName then
|
||||
SPAWN:New( Mission._Cargos[Cargo.CargoName].CargoGroupTemplate ):FromCarrier ( Client:ClientGroup(),
|
||||
Task.TargetZoneName,
|
||||
Mission._Cargos[Cargo.CargoName].CargoGroupName )
|
||||
else
|
||||
SPAWN:New( Mission._Cargos[Cargo.CargoName].CargoGroupTemplate ):FromCarrier ( Client:ClientGroup(),
|
||||
Task.LandingZones[Task.CurrentLandingZoneID],
|
||||
Mission._Cargos[Cargo.CargoName].CargoGroupName )
|
||||
end
|
||||
end
|
||||
end
|
||||
env.info( 'STAGEUNLOAD:Executing() Task.Cargo.CargoName = ' .. Task.Cargo.CargoName )
|
||||
|
||||
local TargetZoneName
|
||||
|
||||
if Task.TargetZoneName then
|
||||
TargetZoneName = Task.TargetZoneName
|
||||
else
|
||||
TargetZoneName = Task.CurrentLandingZoneName
|
||||
end
|
||||
|
||||
if Task.Cargo:UnLoad( Client, TargetZoneName ) then
|
||||
Task.ExecuteStage = _TransportExecuteStage.SUCCESS
|
||||
Client:ShowCargo()
|
||||
end
|
||||
@@ -369,27 +425,27 @@ function STAGEUNLOAD:Validate( Mission, Client, Task )
|
||||
trace.f(self.ClassName)
|
||||
env.info( 'STAGEUNLOAD:Validate()' )
|
||||
|
||||
if routines.IsUnitInZones( Client:ClientGroup():getUnits()[1], Task.LandingZones[Task.CurrentLandingZoneID] ) then
|
||||
if routines.IsUnitInZones( Client:ClientUnit(), Task.CurrentLandingZoneName ) then
|
||||
else
|
||||
Task.ExecuteStage = _TransportExecuteStage.FAILED
|
||||
Task:RemoveCargoMenus( Client )
|
||||
Client:Message( 'The ' .. Task.CargoType.TEXT .. " haven't been successfully " .. Task.TEXT[3] .. ' within the landing zone. Task and mission has failed.',
|
||||
Client:Message( 'The ' .. Task.CargoType .. " haven't been successfully " .. Task.TEXT[3] .. ' within the landing zone. Task and mission has failed.',
|
||||
_TransportStageMsgTime.DONE, Mission.Name .. "/StageFailure", "Co-Pilot: Unload" )
|
||||
return 1
|
||||
end
|
||||
|
||||
if not Client:ClientGroup():getUnits()[1]:inAir() then
|
||||
if not Client:ClientUnit():inAir() then
|
||||
else
|
||||
Task.ExecuteStage = _TransportExecuteStage.FAILED
|
||||
Task:RemoveCargoMenus( Client )
|
||||
Client:Message( 'The ' .. Task.CargoType.TEXT .. " haven't been successfully " .. Task.TEXT[3] .. ' within the landing zone. Task and mission has failed.',
|
||||
Client:Message( 'The ' .. Task.CargoType .. " haven't been successfully " .. Task.TEXT[3] .. ' within the landing zone. Task and mission has failed.',
|
||||
_TransportStageMsgTime.DONE, Mission.Name .. "/StageFailure", "Co-Pilot: Unload" )
|
||||
return 1
|
||||
end
|
||||
|
||||
if Task.ExecuteStage == _TransportExecuteStage.SUCCESS then
|
||||
Client:Message( 'The ' .. Task.CargoType.TEXT .. ' have been sucessfully ' .. Task.TEXT[3] .. ' within the landing zone.', _TransportStageMsgTime.DONE, Mission.Name .. "/Stage", "Co-Pilot: Unload" )
|
||||
Mission._Cargos[Task.CargoName].Status = CARGOSTATUS.UNLOADED
|
||||
Client:Message( 'The ' .. Task.CargoType .. ' have been sucessfully ' .. Task.TEXT[3] .. ' within the landing zone.', _TransportStageMsgTime.DONE, Mission.Name .. "/Stage", "Co-Pilot: Unload" )
|
||||
Task.Cargo:StatusUnLoaded()
|
||||
Task:RemoveCargoMenus( Client )
|
||||
Task.MissionTask:AddGoalCompletion( Task.MissionTask.GoalVerb, Task.CargoName, 1 ) -- We set the cargo as one more goal completed in the mission.
|
||||
return 1
|
||||
@@ -414,68 +470,63 @@ end
|
||||
|
||||
function STAGELOAD:Execute( Mission, Client, Task )
|
||||
trace.f(self.ClassName)
|
||||
Client:Message( 'The ' .. Task.CargoType.TEXT .. ' are being ' .. Task.TEXT[2] .. ' within the landing zone. Wait until the helicopter is ' .. Task.TEXT[3] .. '.',
|
||||
_TransportStageMsgTime.EXECUTING, Mission.Name .. "/Stage", "Co-Pilot: Load" )
|
||||
Client:Message( 'The ' .. Task.CargoType .. ' are being ' .. Task.TEXT[2] .. ' within the landing zone. Wait until the helicopter is ' .. Task.TEXT[3] .. '.',
|
||||
_TransportStageMsgTime.EXECUTING, Mission.Name .. "/StageLoad", "Co-Pilot: Load" )
|
||||
|
||||
-- Route the cargo to the Carrier
|
||||
if Mission._Cargos[Task.CargoName].CargoType.TRANSPORT == CARGO_TRANSPORT.UNIT then
|
||||
Task:OnBoardCargo( Client:ClientGroup(), Mission._Cargos )
|
||||
Task.ExecuteStage = _TransportExecuteStage.EXECUTING
|
||||
else
|
||||
-- Add the group to the internal cargo;
|
||||
Client:AddCargo( Task.CargoName, Mission._Cargos[Task.CargoName].CargoGroupName, Mission._Cargos[Task.CargoName].CargoType, Mission._Cargos[Task.CargoName].CargoWeight, Mission._Cargos[Task.CargoName].CargoGroupTemplate )
|
||||
Task.ExecuteStage = _TransportExecuteStage.SUCCESS
|
||||
end
|
||||
Task.Cargo:OnBoard( Client, Task.CurrentCargoZone, Task.OnBoardSide )
|
||||
Task.ExecuteStage = _TransportExecuteStage.EXECUTING
|
||||
end
|
||||
|
||||
function STAGELOAD:Executing( Mission, Client, Task )
|
||||
trace.f(self.ClassName)
|
||||
|
||||
-- Remove the loaded object from the battle zone.
|
||||
-- If the Cargo is ready to be loaded, load it into the Client.
|
||||
|
||||
if routines.IsPartOfGroupInRadius( Group.getByName(Mission._Cargos[Task.CargoName].CargoGroupName), Client:ClientGroup(), 75 ) then
|
||||
routines.DestroyGroupInRadiusFromGroup( Group.getByName(Mission._Cargos[Task.CargoName].CargoGroupName), Client:ClientGroup(), 75 )
|
||||
env.info('trying to remove cargo')
|
||||
|
||||
-- Add the group to the internal cargo;
|
||||
Client:AddCargo( Task.CargoName, Mission._Cargos[Task.CargoName].CargoGroupName, Mission._Cargos[Task.CargoName].CargoType, Mission._Cargos[Task.CargoName].CargoWeight, Mission._Cargos[Task.CargoName].CargoGroupTemplate )
|
||||
trace.i(self.ClassName, Task.Cargo)
|
||||
|
||||
-- Message to the pilot that cargo has been loaded.
|
||||
Client:Message( "The cargo " .. Task.CargoName .. " has been loaded in our helicopter.", 20, Mission.Name .. "/Stage", "Co-Pilot: Load" )
|
||||
Task.ExecuteStage = _TransportExecuteStage.SUCCESS
|
||||
Client:ShowCargo()
|
||||
end
|
||||
if Task.Cargo:OnBoarded( Client, Task.CurrentCargoZone ) then
|
||||
|
||||
-- Load the Cargo onto the Client
|
||||
Task.Cargo:Load( Client )
|
||||
|
||||
-- Message to the pilot that cargo has been loaded.
|
||||
Client:Message( "The cargo " .. Task.Cargo.CargoName .. " has been loaded in our helicopter.", 20, Mission.Name .. "/StageLoad", "Co-Pilot: Load" )
|
||||
Task.ExecuteStage = _TransportExecuteStage.SUCCESS
|
||||
|
||||
Client:ShowCargo()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function STAGELOAD:Validate( Mission, Client, Task )
|
||||
trace.f(self.ClassName)
|
||||
if routines.IsUnitInZones( Client:ClientGroup():getUnits()[1], Task.LandingZones[Task.CurrentLandingZoneID] ) then
|
||||
if routines.IsUnitInZones( Client:ClientUnit(), Task.CurrentLandingZoneName ) then
|
||||
else
|
||||
Task:RemoveCargoMenus( Client )
|
||||
Task.ExecuteStage = _TransportExecuteStage.FAILED
|
||||
Task.CargoName = nil
|
||||
Client:Message( "The " .. Task.CargoType.TEXT .. " loading has been aborted. You flew outside the pick-up zone while loading. ",
|
||||
Client:Message( "The " .. Task.CargoType .. " loading has been aborted. You flew outside the pick-up zone while loading. ",
|
||||
_TransportStageMsgTime.DONE, Mission.Name .. "/StageSuccess", "Co-Pilot: Load" )
|
||||
return 1
|
||||
end
|
||||
|
||||
if not Client:ClientGroup():getUnits()[1]:inAir() then
|
||||
if not Client:ClientUnit():inAir() then
|
||||
else
|
||||
-- The carrier is back in the air, undo the loading process.
|
||||
Task:RemoveCargoMenus( Client )
|
||||
Task.ExecuteStage = _TransportExecuteStage.NONE
|
||||
Task.CargoName = nil
|
||||
Client:Message( "The " .. Task.CargoType.TEXT .. " loading has been aborted. Land the helicopter and load the cargo. Don't fly outside the pick-up zone. ",
|
||||
Client:Message( "The " .. Task.CargoType .. " loading has been aborted. Land the helicopter and load the cargo. Don't fly outside the pick-up zone. ",
|
||||
_TransportStageMsgTime.DONE, Mission.Name .. "/StageSuccess", "Co-Pilot: Load" )
|
||||
return -1
|
||||
end
|
||||
|
||||
if Task.ExecuteStage == _TransportExecuteStage.SUCCESS then
|
||||
Mission._Cargos[Task.CargoName].Status = CARGOSTATUS.LOADED
|
||||
Task.Cargo:StatusLoaded()
|
||||
Task:RemoveCargoMenus( Client )
|
||||
Client:Message( 'Co-Pilot: The ' .. Task.CargoType.TEXT .. ' have been sucessfully ' .. Task.TEXT[3] .. ' within the landing zone.',
|
||||
_TransportStageMsgTime.DONE, Mission.Name .. "/Stage", "Co-Pilot: Load" )
|
||||
Client:Message( 'Co-Pilot: The ' .. Task.CargoType .. ' have been sucessfully ' .. Task.TEXT[3] .. ' within the landing zone.',
|
||||
_TransportStageMsgTime.DONE, Mission.Name .. "/StageLoaded", "Co-Pilot: Load" )
|
||||
Task.MissionTask:AddGoalCompletion( Task.MissionTask.GoalVerb, Task.CargoName, 1 )
|
||||
return 1
|
||||
end
|
||||
@@ -518,9 +569,8 @@ trace.f(self.ClassName)
|
||||
end
|
||||
|
||||
if Task.CargoName then
|
||||
if routines.IsStaticInZones( StaticObject.getByName( Task.CargoName ), Task.LandingZones[Task.CurrentLandingZoneID] ) then
|
||||
if routines.IsStaticInZones( StaticObject.getByName( Task.CargoName ), Task.CurrentLandingZoneName ) then
|
||||
else
|
||||
Mission._Cargos[Task.CargoName].Status = CARGOSTATUS.LOADED
|
||||
return 1
|
||||
end
|
||||
end
|
||||
@@ -561,7 +611,7 @@ trace.f(self.ClassName)
|
||||
|
||||
if Task.CargoName then
|
||||
if not StaticObject.getByName( Task.CargoName ):inAir() then
|
||||
if routines.IsUnitInZones( Client:ClientGroup():getUnits()[1], Task.LandingZones[Task.CurrentLandingZoneID] ) then
|
||||
if routines.IsUnitInZones( Client:ClientUnit(), 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
|
||||
@@ -616,14 +666,14 @@ end
|
||||
function STAGEARRIVE:Execute( Mission, Client, Task )
|
||||
trace.f(self.ClassName)
|
||||
|
||||
Client:Message( 'We have arrived at ' .. Task.LandingZones[Task.CurrentLandingZoneID] .. ".", 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
|
||||
|
||||
function STAGEARRIVE:Validate( Mission, Client, Task )
|
||||
trace.f(self.ClassName)
|
||||
|
||||
Task.CurrentLandingZoneID = routines.IsUnitInZones( Client:ClientGroup():getUnits()[1], Task.LandingZones )
|
||||
Task.CurrentLandingZoneID = routines.IsUnitInZones( Client:ClientUnit(), Task.LandingZones )
|
||||
if ( Task.CurrentLandingZoneID ) then
|
||||
else
|
||||
return -1
|
||||
|
||||
Reference in New Issue
Block a user