diff --git a/Moose Development/Moose/Core/Cargo.lua b/Moose Development/Moose/Core/Cargo.lua index 78f8f9c52..42486f980 100644 --- a/Moose Development/Moose/Core/Cargo.lua +++ b/Moose Development/Moose/Core/Cargo.lua @@ -233,7 +233,7 @@ do -- CARGO -- @return #CARGO function CARGO:New( Type, Name, Weight ) - local self = BASE:Inherit( self, FSM:New() ) -- Core.Fsm#FSM + local self = BASE:Inherit( self, FSM:New() ) -- #CARGO self:F( { Type, Name, Weight } ) self:SetStartState( "UnLoaded" ) @@ -364,13 +364,16 @@ do -- CARGO_REPRESENTABLE --- @type CARGO_REPRESENTABLE -- @extends #CARGO + -- @field test + + --- + -- @field #CARGO_REPRESENTABLE CARGO_REPRESENTABLE CARGO_REPRESENTABLE = { ClassName = "CARGO_REPRESENTABLE" } --- CARGO_REPRESENTABLE Constructor. -- @param #CARGO_REPRESENTABLE self - -- @param Wrapper.Controllable#Controllable CargoObject -- @param #string Type -- @param #string Name -- @param #number Weight @@ -378,7 +381,7 @@ do -- CARGO_REPRESENTABLE -- @param #number NearRadius (optional) -- @return #CARGO_REPRESENTABLE function CARGO_REPRESENTABLE:New( CargoObject, Type, Name, Weight, ReportRadius, NearRadius ) - local self = BASE:Inherit( self, CARGO:New( Type, Name, Weight, ReportRadius, NearRadius ) ) -- #CARGO + local self = BASE:Inherit( self, CARGO:New( Type, Name, Weight, ReportRadius, NearRadius ) ) -- #CARGO_REPRESENTABLE self:F( { Type, Name, Weight, ReportRadius, NearRadius } ) return self @@ -482,7 +485,8 @@ end do -- CARGO_UNIT - --- @type CARGO_UNIT + --- Hello + -- @type CARGO_UNIT -- @extends #CARGO_REPRESENTABLE --- # CARGO\_UNIT class, extends @{#CARGO_REPRESENTABLE} @@ -543,31 +547,40 @@ function CARGO_UNIT:onenterUnBoarding( From, Event, To, ToPointVec2, NearRadius NearRadius = NearRadius or 25 local Angle = 180 - local Speed = 10 - local DeployDistance = 5 + local Speed = 60 + local DeployDistance = 9 local RouteDistance = 60 if From == "Loaded" then - local CargoCarrierPointVec2 = self.CargoCarrier:GetPointVec2() + local CargoCarrier = self.CargoCarrier -- Wrapper.Controllable#CONTROLLABLE + + local CargoCarrierPointVec2 = CargoCarrier:GetPointVec2() local CargoCarrierHeading = self.CargoCarrier:GetHeading() -- Get Heading of object in degrees. local CargoDeployHeading = ( ( CargoCarrierHeading + Angle ) >= 360 ) and ( CargoCarrierHeading + Angle - 360 ) or ( CargoCarrierHeading + Angle ) - local CargoDeployPointVec2 = CargoCarrierPointVec2:Translate( DeployDistance, CargoDeployHeading ) - local CargoRoutePointVec2 = CargoCarrierPointVec2:Translate( RouteDistance, CargoDeployHeading ) + + local CargoRoutePointVec2 = CargoCarrierPointVec2:Translate( RouteDistance, CargoDeployHeading ) + + -- if there is no ToPointVec2 given, then use the CargoRoutePointVec2 ToPointVec2 = ToPointVec2 or CargoRoutePointVec2 + local DirectionVec3 = CargoCarrierPointVec2:GetDirectionVec3(ToPointVec2) + local Angle = CargoCarrierPointVec2:GetAngleDegrees(DirectionVec3) + + local CargoDeployPointVec2 = CargoCarrierPointVec2:Translate( DeployDistance, Angle ) local FromPointVec2 = CargoCarrierPointVec2 -- Respawn the group... if self.CargoObject then - self.CargoObject:ReSpawn( CargoDeployPointVec2:GetRandomVec3InRadius(10,15), CargoDeployHeading ) + self.CargoObject:ReSpawn( CargoDeployPointVec2:GetVec3(), CargoDeployHeading ) self.CargoCarrier = nil local Points = {} - Points[#Points+1] = FromPointVec2:RoutePointGround( Speed ) - Points[#Points+1] = ToPointVec2:RoutePointGround( Speed ) + Points[#Points+1] = CargoCarrierPointVec2:RoutePointGround( Speed ) + + Points[#Points+1] = ToPointVec2:RoutePointGround( Speed ) local TaskRoute = self.CargoObject:TaskRoute( Points ) self.CargoObject:SetTask( TaskRoute, 1 ) diff --git a/Moose Development/Moose/Core/Point.lua b/Moose Development/Moose/Core/Point.lua index 3df7bdbfb..6b06bfe75 100644 --- a/Moose Development/Moose/Core/Point.lua +++ b/Moose Development/Moose/Core/Point.lua @@ -399,11 +399,11 @@ function POINT_VEC3:GetNorthCorrectionRadians() end ---- Return a direction in radians from the POINT_VEC3 using a direction vector in Vec3 format. +--- Return an angle in radians from the POINT_VEC3 using a direction vector in Vec3 format. -- @param #POINT_VEC3 self -- @param Dcs.DCSTypes#Vec3 DirectionVec3 The direction vector in Vec3 format. --- @return #number DirectionRadians The direction in radians. -function POINT_VEC3:GetDirectionRadians( DirectionVec3 ) +-- @return #number DirectionRadians The angle in radians. +function POINT_VEC3:GetAngleRadians( DirectionVec3 ) local DirectionRadians = math.atan2( DirectionVec3.z, DirectionVec3.x ) --DirectionRadians = DirectionRadians + self:GetNorthCorrectionRadians() if DirectionRadians < 0 then @@ -412,6 +412,17 @@ function POINT_VEC3:GetDirectionRadians( DirectionVec3 ) return DirectionRadians end +--- Return an angle in degrees from the POINT_VEC3 using a direction vector in Vec3 format. +-- @param #POINT_VEC3 self +-- @param Dcs.DCSTypes#Vec3 DirectionVec3 The direction vector in Vec3 format. +-- @return #number DirectionRadians The angle in degrees. +function POINT_VEC3:GetAngleDegrees( DirectionVec3 ) + local AngleRadians = self:GetAngleRadians(DirectionVec3) + local Angle = UTILS.ToDegree( AngleRadians ) + return Angle +end + + --- Return the 2D distance in meters between the target POINT_VEC3 and the POINT_VEC3. -- @param #POINT_VEC3 self -- @param #POINT_VEC3 TargetPointVec3 The target POINT_VEC3. @@ -482,7 +493,7 @@ end -- @return #string The BR text. function POINT_VEC3:GetBRText( TargetPointVec3 ) local DirectionVec3 = self:GetDirectionVec3( TargetPointVec3 ) - local AngleRadians = self:GetDirectionRadians( DirectionVec3 ) + local AngleRadians = self:GetAngleRadians( DirectionVec3 ) local Distance = self:Get2DDistance( TargetPointVec3 ) return self:ToStringBR( AngleRadians, Distance ) end diff --git a/Moose Development/Moose/Tasking/Task_CARGO.lua b/Moose Development/Moose/Tasking/Task_CARGO.lua index f9cd9a034..72f65f51d 100644 --- a/Moose Development/Moose/Tasking/Task_CARGO.lua +++ b/Moose Development/Moose/Tasking/Task_CARGO.lua @@ -181,7 +181,7 @@ do -- TASK_CARGO Fsm:AddProcess ( "Planned", "Accept", ACT_ASSIGN_ACCEPT:New( self.TaskBriefing ), { Assigned = "SelectAction", Rejected = "Reject" } ) - Fsm:AddTransition( "*", "SelectAction", "WaitingForCommand" ) + Fsm:AddTransition( { "Assigned", "WaitingForCommand", "ArrivedAtPickup", "ArrivedAtDeploy", "Boarded", "UnBoarded" }, "SelectAction", "WaitingForCommand" ) Fsm:AddTransition( "WaitingForCommand", "RouteToPickup", "RoutingToPickup" ) Fsm:AddProcess ( "RoutingToPickup", "RouteToPickupPoint", ACT_ROUTE_POINT:New(), { Arrived = "ArriveAtPickup" } ) diff --git a/Moose Mission Setup/Moose.lua b/Moose Mission Setup/Moose.lua index 63a8ca8f2..53e72fc3d 100644 --- a/Moose Mission Setup/Moose.lua +++ b/Moose Mission Setup/Moose.lua @@ -1,5 +1,5 @@ env.info( '*** MOOSE DYNAMIC INCLUDE START *** ' ) -env.info( 'Moose Generation Timestamp: 20170415_1213' ) +env.info( 'Moose Generation Timestamp: 20170416_0614' ) local base = _G