diff --git a/Moose Development/Moose/Actions/Act_Route.lua b/Moose Development/Moose/Actions/Act_Route.lua index e50c3ffcc..cbf089140 100644 --- a/Moose Development/Moose/Actions/Act_Route.lua +++ b/Moose Development/Moose/Actions/Act_Route.lua @@ -123,16 +123,21 @@ do -- ACT_ROUTE --- Set a Cancel Menu item. -- @param #ACT_ROUTE self -- @return #ACT_ROUTE - function ACT_ROUTE:SetMenuCancel( MenuGroup, MenuText, ParentMenu, MenuTime ) + function ACT_ROUTE:SetMenuCancel( MenuGroup, MenuText, ParentMenu ) - MENU_GROUP_COMMAND:New( + local MenuTime = timer.getTime() + 1 + + self.CancelMenuGroupCommand = MENU_GROUP_COMMAND:New( MenuGroup, MenuText, ParentMenu, self.MenuCancel, self - ):SetTime(MenuTime) - + ):SetTime( MenuTime ) + + ParentMenu:SetTime( MenuTime ) + ParentMenu:Remove( MenuTime ) + return self end @@ -206,7 +211,9 @@ do -- ACT_ROUTE function ACT_ROUTE:MenuCancel() - self:Cancel() + self:F("Cancelled") + self.CancelMenuGroupCommand:Remove() + self:__Cancel( 1 ) end --- Task Events diff --git a/Moose Development/Moose/Cargo/Cargo.lua b/Moose Development/Moose/Cargo/Cargo.lua index cacd5fa64..52ad16b29 100644 --- a/Moose Development/Moose/Cargo/Cargo.lua +++ b/Moose Development/Moose/Cargo/Cargo.lua @@ -258,7 +258,6 @@ do -- CARGO self:AddTransition( "*", "Destroyed", "Destroyed" ) self:AddTransition( "*", "Respawn", "UnLoaded" ) - self.Type = Type self.Name = Name self.Weight = Weight or 0 @@ -268,6 +267,9 @@ do -- CARGO self.Slingloadable = false self.Moveable = false self.Containable = false + self.LoadAction = "" + + self.CargoLimit = 0 self.LoadRadius = LoadRadius or 500 self.NearRadius = NearRadius or 25 @@ -293,6 +295,12 @@ do -- CARGO return CargoFound end + --- Check if the cargo can be Slingloaded. + -- @param #CARGO self + function CARGO:CanSlingload() + return false + end + --- Check if the cargo can be Boarded. -- @param #CARGO self function CARGO:CanBoard() @@ -317,9 +325,6 @@ do -- CARGO return true end - - - --- Destroy the cargo. -- @param #CARGO self @@ -354,13 +359,26 @@ do -- CARGO function CARGO:GetCount() return 1 end - + --- Get the type of the Cargo. -- @param #CARGO self -- @return #string The type of the Cargo. function CARGO:GetType() return self.Type end + + + --- Get the coalition of the Cargo. + -- @param #CARGO self + -- @return Coalition + function CARGO:GetCoalition() + if self:IsLoaded() then + return self.CargoCarrier:GetCoalition() + else + return self.CargoObject:GetCoalition() + end + end + --- Get the current coordinates of the Cargo. -- @param #CARGO self @@ -543,7 +561,7 @@ do -- CARGO -- @param Core.Point#Coordinate Coordinate -- @return #boolean true if the CargoGroup is within the loading radius. function CARGO:IsInLoadRadius( Coordinate ) - self:F( { Coordinate } ) + self:F( { Coordinate, LoadRadius = self.LoadRadius } ) local Distance = 0 if self:IsUnLoaded() then @@ -792,6 +810,32 @@ do -- CARGO_REPRESENTABLE return self end + --- Send a message to a @{Group} through a communication channel near the cargo. + -- @param #CARGO_REPRESENTABLE self + -- @param #string Message + -- @param Wrapper.Group#GROUP TaskGroup + -- @param #sring Name (optional) The name of the Group used as a prefix for the message to the Group. If not provided, there will be nothing shown. + function CARGO_REPRESENTABLE:MessageToGroup( Message, TaskGroup, Name ) + + local CoordinateZone = ZONE_RADIUS:New( "Zone" , self:GetCoordinate():GetVec2(), 500 ) + CoordinateZone:Scan( { Object.Category.UNIT } ) + for _, DCSUnit in pairs( CoordinateZone:GetScannedUnits() ) do + local NearUnit = UNIT:Find( DCSUnit ) + self:F({NearUnit=NearUnit}) + local NearUnitCoalition = NearUnit:GetCoalition() + local CargoCoalition = self:GetCoalition() + if NearUnitCoalition == CargoCoalition then + local Attributes = NearUnit:GetDesc() + self:F({Desc=Attributes}) + if NearUnit:HasAttribute( "Trucks" ) then + MESSAGE:New( Message, 20, NearUnit:GetCallsign() .. " reporting - Cargo " .. self:GetName() ):ToGroup( TaskGroup ) + break + end + end + end + + end + end -- CARGO_REPRESENTABLE @@ -825,7 +869,7 @@ do -- CARGO_REPORTABLE -- @param #sring Name (optional) The name of the Group used as a prefix for the message to the Group. If not provided, there will be nothing shown. function CARGO_REPORTABLE:MessageToGroup( Message, TaskGroup, Name ) - MESSAGE:New( Message, 20, "Cargo " .. self:GetName() ):ToGroup( TaskGroup ) + MESSAGE:New( Message, 20, "Cargo " .. self:GetName() .. " reporting" ):ToGroup( TaskGroup ) end diff --git a/Moose Development/Moose/Cargo/CargoCrate.lua b/Moose Development/Moose/Cargo/CargoCrate.lua index 44ef41af6..1edd1c167 100644 --- a/Moose Development/Moose/Cargo/CargoCrate.lua +++ b/Moose Development/Moose/Cargo/CargoCrate.lua @@ -50,7 +50,7 @@ do -- CARGO_CRATE self:F( { Type, Name, NearRadius } ) self.CargoObject = CargoStatic - + self:T( self.ClassName ) -- Cargo objects are added to the _DATABASE and SET_CARGO objects. @@ -134,12 +134,32 @@ do -- CARGO_CRATE return false end + --- Check if Cargo Crate is in the radius for the Cargo to be reported. + -- @param #CARGO self + -- @param Core.Point#Coordinate Coordinate + -- @return #boolean true if the Cargo Crate is within the report radius. + function CARGO_CRATE:IsInReportRadius( Coordinate ) + self:F( { Coordinate, LoadRadius = self.LoadRadius } ) + + local Distance = 0 + if self:IsUnLoaded() then + Distance = Coordinate:DistanceFromPointVec2( self.CargoObject:GetPointVec2() ) + self:T( Distance ) + if Distance <= self.LoadRadius then + return true + end + end + + return false + end + + --- Check if Cargo Crate is in the radius for the Cargo to be Boarded or Loaded. -- @param #CARGO self -- @param Core.Point#Coordinate Coordinate -- @return #boolean true if the Cargo Crate is within the loading radius. function CARGO_CRATE:IsInLoadRadius( Coordinate ) - self:F( { Coordinate } ) + self:F( { Coordinate, LoadRadius = self.NearRadius } ) local Distance = 0 if self:IsUnLoaded() then diff --git a/Moose Development/Moose/Cargo/CargoGroup.lua b/Moose Development/Moose/Cargo/CargoGroup.lua index 07806b45c..57ec3a0af 100644 --- a/Moose Development/Moose/Cargo/CargoGroup.lua +++ b/Moose Development/Moose/Cargo/CargoGroup.lua @@ -95,6 +95,7 @@ function CARGO_GROUP:New( CargoGroup, Type, Name, LoadRadius ) self:SetWeight( WeightGroup ) + self.CargoLimit = 10 self:T( { "Weight Cargo", WeightGroup } ) diff --git a/Moose Development/Moose/Cargo/CargoSlingload.lua b/Moose Development/Moose/Cargo/CargoSlingload.lua index 91f69f873..f8be5c183 100644 --- a/Moose Development/Moose/Cargo/CargoSlingload.lua +++ b/Moose Development/Moose/Cargo/CargoSlingload.lua @@ -66,6 +66,12 @@ do -- CARGO_SLINGLOAD end + --- Check if the cargo can be Slingloaded. + -- @param #CARGO self + function CARGO:CanSlingload() + return true + end + --- Check if the cargo can be Boarded. -- @param #CARGO_SLINGLOAD self function CARGO_SLINGLOAD:CanBoard() @@ -91,6 +97,26 @@ do -- CARGO_SLINGLOAD end + --- Check if Cargo Crate is in the radius for the Cargo to be reported. + -- @param #CARGO_SLINGLOAD self + -- @param Core.Point#Coordinate Coordinate + -- @return #boolean true if the Cargo Crate is within the report radius. + function CARGO_SLINGLOAD:IsInReportRadius( Coordinate ) + self:F( { Coordinate, LoadRadius = self.LoadRadius } ) + + local Distance = 0 + if self:IsUnLoaded() then + Distance = Coordinate:DistanceFromPointVec2( self.CargoObject:GetPointVec2() ) + self:T( Distance ) + if Distance <= self.LoadRadius then + return true + end + end + + return false + end + + --- Check if Cargo Slingload is in the radius for the Cargo to be Boarded or Loaded. -- @param #CARGO_SLINGLOAD self -- @param Core.Point#Coordinate Coordinate diff --git a/Moose Development/Moose/Core/Event.lua b/Moose Development/Moose/Core/Event.lua index a21911627..c68fec80b 100644 --- a/Moose Development/Moose/Core/Event.lua +++ b/Moose Development/Moose/Core/Event.lua @@ -174,6 +174,7 @@ EVENT = { ClassName = "EVENT", ClassID = 0, + MissionEnd = false, } world.event.S_EVENT_NEW_CARGO = world.event.S_EVENT_MAX + 1000 @@ -748,8 +749,13 @@ function EVENT:onEvent( Event ) if self and self.Events and self.Events[Event.id] and + self.MissionEnd == false and ( Event.initiator ~= nil or ( Event.initiator == nil and Event.id ~= EVENTS.PlayerLeaveUnit ) ) then + if Event.id and Event.id == EVENTS.MissionEnd then + self.MissionEnd = true + end + if Event.initiator then Event.IniObjectCategory = Event.initiator:getCategory() diff --git a/Moose Development/Moose/Core/Fsm.lua b/Moose Development/Moose/Core/Fsm.lua index 0c49c79e3..efcea3aee 100644 --- a/Moose Development/Moose/Core/Fsm.lua +++ b/Moose Development/Moose/Core/Fsm.lua @@ -724,6 +724,10 @@ do -- FSM return self.current end + function FSM:GetCurrentState() + return self.current + end + function FSM:Is( State ) return self.current == State diff --git a/Moose Development/Moose/Tasking/Task_CARGO.lua b/Moose Development/Moose/Tasking/Task_CARGO.lua index 933413ebc..2cb400dd8 100644 --- a/Moose Development/Moose/Tasking/Task_CARGO.lua +++ b/Moose Development/Moose/Tasking/Task_CARGO.lua @@ -167,6 +167,61 @@ do -- TASK_CARGO self.DeployZones = {} -- setmetatable( {}, { __mode = "v" } ) -- weak table on value + self:AddTransition( "*", "Deployed", "*" ) + + --- Deployed Handler OnBefore for Type + -- @function [parent=#Type] OnBeforeDeployed + -- @param #Type self + -- @param #string From + -- @param #string Event + -- @param #string To + -- @return #boolean + + --- Deployed Handler OnAfter for Type + -- @function [parent=#Type] OnAfterDeployed + -- @param #Type self + -- @param #string From + -- @param #string Event + -- @param #string To + + --- Deployed Trigger for Type + -- @function [parent=#Type] Deployed + -- @param #Type self + + --- Deployed Asynchronous Trigger for Type + -- @function [parent=#Type] __Deployed + -- @param #Type self + -- @param #number Delay + + + self:AddTransition( "*", "PickedUp", "*" ) + + --- PickedUp Handler OnBefore for Type + -- @function [parent=#Type] OnBeforePickedUp + -- @param #Type self + -- @param #string From + -- @param #string Event + -- @param #string To + -- @return #boolean + + --- PickedUp Handler OnAfter for Type + -- @function [parent=#Type] OnAfterPickedUp + -- @param #Type self + -- @param #string From + -- @param #string Event + -- @param #string To + + --- PickedUp Trigger for Type + -- @function [parent=#Type] PickedUp + -- @param #Type self + + --- PickedUp Asynchronous Trigger for Type + -- @function [parent=#Type] __PickedUp + -- @param #Type self + -- @param #number Delay + + + local Fsm = self:GetUnitProcess() @@ -174,17 +229,17 @@ do -- TASK_CARGO Fsm:AddProcess ( "Planned", "Accept", ACT_ASSIGN_ACCEPT:New( self.TaskBriefing ), { Assigned = "SelectAction", Rejected = "Reject" } ) - Fsm:AddTransition( { "Planned", "Assigned", "WaitingForCommand", "ArrivedAtPickup", "ArrivedAtDeploy", "Boarded", "UnBoarded", "Loaded", "UnLoaded", "Landed", "Boarding" }, "SelectAction", "*" ) + Fsm:AddTransition( { "Planned", "Assigned", "Cancelled", "WaitingForCommand", "ArrivedAtPickup", "ArrivedAtDeploy", "Boarded", "UnBoarded", "Loaded", "UnLoaded", "Landed", "Boarding" }, "SelectAction", "*" ) Fsm:AddTransition( "*", "RouteToPickup", "RoutingToPickup" ) Fsm:AddProcess ( "RoutingToPickup", "RouteToPickupPoint", ACT_ROUTE_POINT:New(), { Arrived = "ArriveAtPickup", Cancelled = "CancelRouteToPickup" } ) Fsm:AddTransition( "Arrived", "ArriveAtPickup", "ArrivedAtPickup" ) - Fsm:AddTransition( "Cancelled", "CancelRouteToPickup", "WaitingForCommand" ) + Fsm:AddTransition( "Cancelled", "CancelRouteToPickup", "Cancelled" ) Fsm:AddTransition( "*", "RouteToDeploy", "RoutingToDeploy" ) Fsm:AddProcess ( "RoutingToDeploy", "RouteToDeployZone", ACT_ROUTE_ZONE:New(), { Arrived = "ArriveAtDeploy", Cancelled = "CancelRouteToDeploy" } ) Fsm:AddTransition( "Arrived", "ArriveAtDeploy", "ArrivedAtDeploy" ) - Fsm:AddTransition( "Cancelled", "CancelRouteToDeploy", "WaitingForCommand" ) + Fsm:AddTransition( "Cancelled", "CancelRouteToDeploy", "Cancelled" ) Fsm:AddTransition( { "ArrivedAtPickup", "ArrivedAtDeploy", "Landing" }, "Land", "Landing" ) Fsm:AddTransition( "Landing", "Landed", "Landed" ) @@ -249,7 +304,7 @@ do -- TASK_CARGO self:F( { CargoUnloaded = Cargo:IsUnLoaded(), CargoLoaded = Cargo:IsLoaded(), CargoItemCount = CargoItemCount } ) if Cargo:IsUnLoaded() then - if CargoItemCount <= Task.CargoLimit then + if CargoItemCount < 1 then if Cargo:IsInReportRadius( TaskUnit:GetPointVec2() ) then local NotInDeployZones = true for DeployZoneName, DeployZone in pairs( Task.DeployZones ) do @@ -261,18 +316,26 @@ do -- TASK_CARGO if not TaskUnit:InAir() then if Cargo:CanBoard() == true then if Cargo:IsInLoadRadius( TaskUnit:GetPointVec2() ) then - Cargo:Report( "Reporting for boarding at " .. Cargo:GetCoordinate():ToString( TaskUnit:GetGroup() ), "board", TaskUnit:GetGroup() ) + Cargo:Report( "ready for boarding at " .. Cargo:GetCoordinate():ToString( TaskUnit:GetGroup() ), "board", TaskUnit:GetGroup() ) MENU_GROUP_COMMAND:New( TaskUnit:GetGroup(), "Board cargo " .. Cargo.Name, TaskUnit.Menu, self.MenuBoardCargo, self, Cargo ):SetTime(MenuTime) else - Cargo:Report( "Reporting at " .. Cargo:GetCoordinate():ToString( TaskUnit:GetGroup() ), "reporting", TaskUnit:GetGroup() ) + Cargo:Report( "Board at " .. Cargo:GetCoordinate():ToString( TaskUnit:GetGroup() ), "reporting", TaskUnit:GetGroup() ) end else if Cargo:CanLoad() == true then if Cargo:IsInLoadRadius( TaskUnit:GetPointVec2() ) then - Cargo:Report( "Reporting for loading at " .. Cargo:GetCoordinate():ToString( TaskUnit:GetGroup() ), "load", TaskUnit:GetGroup() ) + Cargo:Report( "ready for loading at " .. Cargo:GetCoordinate():ToString( TaskUnit:GetGroup() ), "load", TaskUnit:GetGroup() ) MENU_GROUP_COMMAND:New( TaskUnit:GetGroup(), "Load cargo " .. Cargo.Name, TaskUnit.Menu, self.MenuLoadCargo, self, Cargo ):SetTime(MenuTime) else - Cargo:Report( "Reporting at " .. Cargo:GetCoordinate():ToString( TaskUnit:GetGroup() ), "reporting", TaskUnit:GetGroup() ) + Cargo:Report( "Load at " .. Cargo:GetCoordinate():ToString( TaskUnit:GetGroup() ), "reporting", TaskUnit:GetGroup() ) + end + else + if Cargo:CanSlingload() == true then + if Cargo:IsInLoadRadius( TaskUnit:GetPointVec2() ) then + Cargo:Report( "ready for slingloading at " .. Cargo:GetCoordinate():ToString( TaskUnit:GetGroup() ), "slingload", TaskUnit:GetGroup() ) + else + Cargo:Report( "Slingload at " .. Cargo:GetCoordinate():ToString( TaskUnit:GetGroup() ), "reporting", TaskUnit:GetGroup() ) + end end end end @@ -282,9 +345,13 @@ do -- TASK_CARGO end end else - MENU_GROUP_COMMAND:New( TaskUnit:GetGroup(), "Route to Pickup cargo " .. Cargo.Name, TaskUnit.Menu, self.MenuRouteToPickup, self, Cargo ):SetTime(MenuTime) - TaskUnit.Menu:SetTime( MenuTime ) - Cargo:ReportResetAll( TaskUnit:GetGroup() ) + if self:Is( "RoutingToPickup" ) then + else + self:F("route menu set") + MENU_GROUP_COMMAND:New( TaskUnit:GetGroup(), "Route to Pickup cargo " .. Cargo.Name, TaskUnit.Menu, self.MenuRouteToPickup, self, Cargo ):SetTime(MenuTime) + TaskUnit.Menu:SetTime( MenuTime ) + Cargo:ReportResetAll( TaskUnit:GetGroup() ) + end end end -- Cargo in deployzones are flagged as deployed. @@ -390,7 +457,7 @@ do -- TASK_CARGO self:F( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } ) if Cargo:IsAlive() then - self.Cargo = Cargo -- Core.Cargo#CARGO + self.Cargo = Cargo -- Cargo.Cargo#CARGO Task:SetCargoPickup( self.Cargo, TaskUnit ) self:__RouteToPickupPoint( -0.1 ) end @@ -405,7 +472,6 @@ do -- TASK_CARGO function Fsm:onafterArriveAtPickup( TaskUnit, Task ) self:F( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } ) if self.Cargo:IsAlive() then - self.Cargo:Smoke( Task:GetSmokeColor(), 15 ) if TaskUnit:IsAir() then Task:GetMission():GetCommandCenter():MessageToGroup( "Land", TaskUnit:GetGroup() ) self:__Land( -0.1, "Pickup" ) @@ -422,6 +488,7 @@ do -- TASK_CARGO function Fsm:onafterCancelRouteToPickup( TaskUnit, Task ) self:F( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } ) + Task:GetMission():GetCommandCenter():MessageToGroup( "Cancelled routing to Cargo " .. self.Cargo:GetName(), TaskUnit:GetGroup() ) self:__SelectAction( -0.1 ) end @@ -459,6 +526,7 @@ do -- TASK_CARGO function Fsm:onafterCancelRouteToDeploy( TaskUnit, Task ) self:F( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } ) + Task:GetMission():GetCommandCenter():MessageToGroup( "Cancelled routing to deploy zone " .. self.DeployZone:GetName(), TaskUnit:GetGroup() ) self:__SelectAction( -0.1 ) end @@ -471,7 +539,7 @@ do -- TASK_CARGO self:F( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } ) if self.Cargo:IsAlive() then - if self.Cargo:IsInLoadRadius( TaskUnit:GetPointVec2() ) then + if self.Cargo:IsInReportRadius( TaskUnit:GetPointVec2() ) then if TaskUnit:InAir() then self:__Land( -10, Action ) else @@ -480,9 +548,9 @@ do -- TASK_CARGO end else if Action == "Pickup" then - self:__RouteToPickupZone( -0.1 ) + self:__RouteToPickup( -0.1, self.Cargo ) else - self:__RouteToDeployZone( -0.1 ) + self:__RouteToDeploy( -0.1, self.Cargo ) end end end @@ -495,7 +563,7 @@ do -- TASK_CARGO self:F( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } ) if self.Cargo:IsAlive() then - if self.Cargo:IsInLoadRadius( TaskUnit:GetPointVec2() ) then + if self.Cargo:IsInReportRadius( TaskUnit:GetPointVec2() ) then if TaskUnit:InAir() then self:__Land( -0.1, Action ) else @@ -503,9 +571,9 @@ do -- TASK_CARGO end else if Action == "Pickup" then - self:__RouteToPickupZone( -0.1 ) + self:__RouteToPickup( -0.1, self.Cargo ) else - self:__RouteToDeployZone( -0.1 ) + self:__RouteToDeploy( -0.1, self.Cargo ) end end end @@ -518,8 +586,7 @@ do -- TASK_CARGO self:F( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } ) if Cargo and Cargo:IsAlive() then - self.Cargo = Cargo -- Core.Cargo#CARGO_GROUP - self:__Board( -0.1 ) + self:__Board( -0.1, Cargo ) end end @@ -527,22 +594,22 @@ do -- TASK_CARGO --- @param #FSM_PROCESS self -- @param Wrapper.Unit#UNIT TaskUnit -- @param Tasking.Task_Cargo#TASK_CARGO Task - function Fsm:onafterBoard( TaskUnit, Task ) + function Fsm:onafterBoard( TaskUnit, Task, From, Event, To, Cargo ) self:F( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } ) - function self.Cargo:OnEnterLoaded( From, Event, To, TaskUnit, TaskProcess ) + function Cargo:OnEnterLoaded( From, Event, To, TaskUnit, TaskProcess ) self:F({From, Event, To, TaskUnit, TaskProcess }) - TaskProcess:__Boarded( 0.1 ) + TaskProcess:__Boarded( 0.1, self ) end - if self.Cargo:IsAlive() then - if self.Cargo:IsInLoadRadius( TaskUnit:GetPointVec2() ) then + if Cargo:IsAlive() then + if Cargo:IsInLoadRadius( TaskUnit:GetPointVec2() ) then if TaskUnit:InAir() then --- ABORT the boarding. Split group if any and go back to select action. else - self.Cargo:MessageToGroup( "Boarding ...", TaskUnit:GetGroup() ) - if not self.Cargo:IsBoarding() then - self.Cargo:Board( TaskUnit, 20, self ) + Cargo:MessageToGroup( "Boarding ...", TaskUnit:GetGroup() ) + if not Cargo:IsBoarding() then + Cargo:Board( TaskUnit, 20, self ) end end else @@ -555,14 +622,16 @@ do -- TASK_CARGO --- @param #FSM_PROCESS self -- @param Wrapper.Unit#UNIT TaskUnit -- @param Tasking.Task_Cargo#TASK_CARGO Task - function Fsm:onafterBoarded( TaskUnit, Task ) + function Fsm:onafterBoarded( TaskUnit, Task, From, Event, To, Cargo ) + self:F( { Cargo = Cargo } ) + local TaskUnitName = TaskUnit:GetName() self:F( { TaskUnit = TaskUnitName, Task = Task and Task:GetClassNameAndID() } ) - - self.Cargo:MessageToGroup( "Boarded ...", TaskUnit:GetGroup() ) - self:Load( self.Cargo ) + Cargo:MessageToGroup( "Boarded ...", TaskUnit:GetGroup() ) + + self:__Load( -0.1, Cargo ) end @@ -570,26 +639,26 @@ do -- TASK_CARGO --- @param #FSM_PROCESS self -- @param Wrapper.Unit#UNIT TaskUnit -- @param Tasking.Task_Cargo#TASK_CARGO Task - function Fsm:onafterLoad( TaskUnit, Task, From, Event, To, Cargo ) + function Fsm:onenterLoaded( TaskUnit, Task, From, Event, To, Cargo ) + + self:F( { Cargo = Cargo } ) + + self:F( { Cargo = Cargo } ) + + self:F( { Cargo = Cargo } ) local TaskUnitName = TaskUnit:GetName() self:F( { TaskUnit = TaskUnitName, Task = Task and Task:GetClassNameAndID() } ) if not Cargo:IsLoaded() then Cargo:Load( TaskUnit ) - TaskUnit:AddCargo( Cargo ) end + Cargo:MessageToGroup( "Loaded ...", TaskUnit:GetGroup() ) + TaskUnit:AddCargo( Cargo ) + self:__SelectAction( 1 ) - -- TODO:I need to find a more decent solution for this. - Task:E( { CargoPickedUp = Task.CargoPickedUp } ) - if Cargo:IsAlive() then - if Task.CargoPickedUp then - Task:CargoPickedUp( TaskUnit, Cargo ) - end - end - end @@ -640,9 +709,9 @@ do -- TASK_CARGO if self.Cargo:IsAlive() then self.Cargo:MessageToGroup( "UnBoarding ...", TaskUnit:GetGroup() ) if DeployZone then - self.Cargo:UnBoard( DeployZone:GetPointVec2(), 400, self ) + self.Cargo:UnBoard( DeployZone:GetCoordinate():GetRandomCoordinateInRadius( 25, 10 ), 400, self ) else - self.Cargo:UnBoard( TaskUnit:GetPointVec2():AddX(60), 400, self ) + self.Cargo:UnBoard( TaskUnit:GetCoordinate():GetRandomCoordinateInRadius( 25, 10 ), 400, self ) end end end @@ -673,9 +742,9 @@ do -- TASK_CARGO if not Cargo:IsUnLoaded() then if DeployZone then - Cargo:UnLoad( DeployZone:GetPointVec2(), 400, self ) + Cargo:UnLoad( DeployZone:GetCoordinate():GetRandomCoordinateInRadius( 25, 10 ), 400, self ) else - Cargo:UnLoad( TaskUnit:GetPointVec2():AddX(60), 400, self ) + Cargo:UnLoad( TaskUnit:GetCoordinate():GetRandomCoordinateInRadius( 25, 10 ), 400, self ) end end TaskUnit:RemoveCargo( Cargo ) @@ -752,6 +821,7 @@ do -- TASK_CARGO ActRouteCargo:SetRange( Cargo:GetLoadRadius() ) ActRouteCargo:SetMenuCancel( TaskUnit:GetGroup(), "Cancel Routing to Cargo " .. Cargo:GetName(), TaskUnit.Menu ) ActRouteCargo:Start() + return self end @@ -769,6 +839,7 @@ do -- TASK_CARGO ActRouteDeployZone:SetZone( DeployZone ) ActRouteDeployZone:SetMenuCancel( TaskUnit:GetGroup(), "Cancel Routing to Deploy Zone" .. DeployZone:GetName(), TaskUnit.Menu ) ActRouteDeployZone:Start() + return self end diff --git a/Moose Development/Moose/Tasking/Task_Cargo_Dispatcher.lua b/Moose Development/Moose/Tasking/Task_Cargo_Dispatcher.lua index ca96b2d87..11c9feede 100644 --- a/Moose Development/Moose/Tasking/Task_Cargo_Dispatcher.lua +++ b/Moose Development/Moose/Tasking/Task_Cargo_Dispatcher.lua @@ -429,17 +429,17 @@ do -- TASK_CARGO_DISPATCHER --- Add a Transport task to transport cargo from fixed locations to a deployment zone. -- @param #TASK_CARGO_DISPATCHER self - -- @param #string TransportTaskName (optional) The name of the transport task. + -- @param #string TaskName (optional) The name of the transport task. -- @param Core.SetCargo#SET_CARGO SetCargo The SetCargo to be transported. -- @param #string Briefing The briefing of the task transport to be shown to the player. -- @return #TASK_CARGO_DISPATCHER -- @usage -- -- -- Add a Transport task to transport cargo of different types to a Transport Deployment Zone. - function TASK_CARGO_DISPATCHER:AddTransportTask( TransportTaskName, SetCargo, Briefing ) + function TASK_CARGO_DISPATCHER:AddTransportTask( TaskName, SetCargo, Briefing ) self.TransportCount = self.TransportCount + 1 - local TaskName = string.format( ( TransportTaskName or "Transport" ) .. ".%03d", self.TransportCount ) + local TaskName = string.format( ( TaskName or "Transport" ) .. ".%03d", self.TransportCount ) self.Transport[TaskName] = {} self.Transport[TaskName].SetCargo = SetCargo @@ -452,13 +452,15 @@ do -- TASK_CARGO_DISPATCHER --- Define one deploy zone for the Transport tasks. -- @param #TASK_CARGO_DISPATCHER self - -- @param #string TransportTaskName (optional) The name of the Transport task. + -- @param #string TaskName (optional) The name of the Transport task. -- @param TransportDeployZone A Transport deploy zone. -- @return #TASK_CARGO_DISPATCHER - function TASK_CARGO_DISPATCHER:SetTransportDeployZone( TransportTaskName, TransportDeployZone ) + function TASK_CARGO_DISPATCHER:SetTransportDeployZone( TaskName, TransportDeployZone ) - if TransportTaskName then - self.Transport[TransportTaskName].DeployZones = { TransportDeployZone } + if self.Transport[TaskName] then + self.Transport[TaskName].DeployZones = { TransportDeployZone } + else + error( "TaskName does not exist" ) end return self @@ -467,14 +469,16 @@ do -- TASK_CARGO_DISPATCHER --- Define the deploy zones for the Transport tasks. -- @param #TASK_CARGO_DISPATCHER self - -- @param #string TransportTaskName (optional) The name of the Transport task. + -- @param #string TaskName (optional) The name of the Transport task. -- @param TransportDeployZones A list of the Transport deploy zones. -- @return #TASK_CARGO_DISPATCHER -- - function TASK_CARGO_DISPATCHER:SetTransportDeployZones( TransportTaskName, TransportDeployZones ) + function TASK_CARGO_DISPATCHER:SetTransportDeployZones( TaskName, TransportDeployZones ) - if TransportTaskName then - self.Transport[TransportTaskName].DeployZones = TransportDeployZones + if self.Transport[TaskName] then + self.Transport[TaskName].DeployZones = TransportDeployZones + else + error( "TaskName does not exist" ) end return self diff --git a/Moose Development/Moose/Wrapper/Unit.lua b/Moose Development/Moose/Wrapper/Unit.lua index 219705f85..ed536a603 100644 --- a/Moose Development/Moose/Wrapper/Unit.lua +++ b/Moose Development/Moose/Wrapper/Unit.lua @@ -326,6 +326,9 @@ function UNIT:GetCallsign() if DCSUnit then local UnitCallSign = DCSUnit:getCallsign() + if UnitCallSign == "" then + UnitCallSign = DCSUnit:getName() + end return UnitCallSign end