mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
CARGO
This commit is contained in:
parent
b61cfc7390
commit
ae6613fae1
@ -1,4 +1,4 @@
|
|||||||
--- **AI** -- (R2.4) - Models the intelligent transportation of infantry and other cargo.
|
--- **AI** - Models the intelligent transportation of infantry and other cargo.
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
@ -35,10 +35,9 @@ AI_CARGO = {
|
|||||||
|
|
||||||
--- Creates a new AI_CARGO object.
|
--- Creates a new AI_CARGO object.
|
||||||
-- @param #AI_CARGO self
|
-- @param #AI_CARGO self
|
||||||
-- @param Wrapper.Group#GROUP Carrier
|
-- @param Wrapper.Group#GROUP Carrier Cargo carrier group.
|
||||||
-- @param Core.Set#SET_CARGO CargoSet
|
-- @param Core.Set#SET_CARGO CargoSet Set of cargo(s) to transport.
|
||||||
-- @param #number CombatRadius
|
-- @return #AI_CARGO self
|
||||||
-- @return #AI_CARGO
|
|
||||||
function AI_CARGO:New( Carrier, CargoSet )
|
function AI_CARGO:New( Carrier, CargoSet )
|
||||||
|
|
||||||
local self = BASE:Inherit( self, FSM_CONTROLLABLE:New( Carrier ) ) -- #AI_CARGO
|
local self = BASE:Inherit( self, FSM_CONTROLLABLE:New( Carrier ) ) -- #AI_CARGO
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
--- **AI** -- (R2.4) - Models the intelligent transportation of infantry and other cargo.
|
--- **AI** - Models the intelligent transportation of cargo using ground vehicles.
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
@ -157,6 +157,45 @@ function AI_CARGO_APC:SetCarrier( CargoCarrier )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Set whether or not the carrier will use roads to *pickup* and *deploy* the cargo.
|
||||||
|
-- @param #AI_CARGO_APC self
|
||||||
|
-- @param #boolean Offroad If true, carrier will not use roads. If `nil` or `false` the carrier will use roads when available.
|
||||||
|
-- @param #number Formation Offroad formation used. Default is `ENUMS.Formation.Vehicle.Offroad`.
|
||||||
|
-- @return #AI_CARGO_APC self
|
||||||
|
function AI_CARGO_APC:SetOffRoad(Offroad, Formation)
|
||||||
|
|
||||||
|
self:SetPickupOffRoad(Offroad, Formation)
|
||||||
|
self:SetDeployOffRoad(Offroad, Formation)
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Set whether the carrier will *not* use roads to *pickup* the cargo.
|
||||||
|
-- @param #AI_CARGO_APC self
|
||||||
|
-- @param #boolean Offroad If true, carrier will not use roads.
|
||||||
|
-- @param #number Formation Offroad formation used. Default is `ENUMS.Formation.Vehicle.Offroad`.
|
||||||
|
-- @return #AI_CARGO_APC self
|
||||||
|
function AI_CARGO_APC:SetPickupOffRoad(Offroad, Formation)
|
||||||
|
|
||||||
|
self.pickupOffroad=Offroad
|
||||||
|
self.pickupFormation=Formation or ENUMS.Formation.Vehicle.OffRoad
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Set whether the carrier will *not* use roads to *deploy* the cargo.
|
||||||
|
-- @param #AI_CARGO_APC self
|
||||||
|
-- @param #boolean Offroad If true, carrier will not use roads.
|
||||||
|
-- @param #number Formation Offroad formation used. Default is `ENUMS.Formation.Vehicle.Offroad`.
|
||||||
|
-- @return #AI_CARGO_APC self
|
||||||
|
function AI_CARGO_APC:SetDeployOffRoad(Offroad, Formation)
|
||||||
|
|
||||||
|
self.deployOffroad=Offroad
|
||||||
|
self.deployFormation=Formation or ENUMS.Formation.Vehicle.OffRoad
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Find a free Carrier within a radius.
|
--- Find a free Carrier within a radius.
|
||||||
-- @param #AI_CARGO_APC self
|
-- @param #AI_CARGO_APC self
|
||||||
@ -350,10 +389,13 @@ function AI_CARGO_APC:onafterFollow( APC, From, Event, To )
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Pickup task function. Triggers Load event.
|
||||||
--- @param #AI_CARGO_APC
|
-- @param Wrapper.Group#GROUP APC The cargo carrier group.
|
||||||
-- @param Wrapper.Group#GROUP APC
|
-- @param #AI_CARGO_APC sel `AI_CARGO_APC` class.
|
||||||
function AI_CARGO_APC._Pickup( APC, self, Coordinate, Speed, PickupZone )
|
-- @param Core.Point#COORDINATE Coordinate. The coordinate (not used).
|
||||||
|
-- @param #number Speed Speed (not used).
|
||||||
|
-- @param Core.Zone#ZONE PickupZone Pickup zone.
|
||||||
|
function AI_CARGO_APC._Pickup(APC, self, Coordinate, Speed, PickupZone)
|
||||||
|
|
||||||
APC:F( { "AI_CARGO_APC._Pickup:", APC:GetName() } )
|
APC:F( { "AI_CARGO_APC._Pickup:", APC:GetName() } )
|
||||||
|
|
||||||
@ -362,8 +404,12 @@ function AI_CARGO_APC._Pickup( APC, self, Coordinate, Speed, PickupZone )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Deploy task function. Triggers Unload event.
|
||||||
function AI_CARGO_APC._Deploy( APC, self, Coordinate, DeployZone )
|
-- @param Wrapper.Group#GROUP APC The cargo carrier group.
|
||||||
|
-- @param #AI_CARGO_APC self `AI_CARGO_APC` class.
|
||||||
|
-- @param Core.Point#COORDINATE Coordinate. The coordinate (not used).
|
||||||
|
-- @param Core.Zone#ZONE DeployZone Deploy zone.
|
||||||
|
function AI_CARGO_APC._Deploy(APC, self, Coordinate, DeployZone)
|
||||||
|
|
||||||
APC:F( { "AI_CARGO_APC._Deploy:", APC } )
|
APC:F( { "AI_CARGO_APC._Deploy:", APC } )
|
||||||
|
|
||||||
@ -392,12 +438,20 @@ function AI_CARGO_APC:onafterPickup( APC, From, Event, To, Coordinate, Speed, He
|
|||||||
self.RoutePickup = true
|
self.RoutePickup = true
|
||||||
|
|
||||||
local _speed=Speed or APC:GetSpeedMax()*0.5
|
local _speed=Speed or APC:GetSpeedMax()*0.5
|
||||||
|
|
||||||
|
-- Route on road.
|
||||||
|
local Waypoints = {}
|
||||||
|
|
||||||
|
if self.pickupOffroad then
|
||||||
|
Waypoints[1]=APC:GetCoordinate():WaypointGround(Speed, self.pickupFormation)
|
||||||
|
Waypoints[2]=Coordinate:WaypointGround(_speed, self.pickupFormation, DCSTasks)
|
||||||
|
else
|
||||||
|
Waypoints=APC:TaskGroundOnRoad(Coordinate, _speed, ENUMS.Formation.Vehicle.OffRoad, true)
|
||||||
|
end
|
||||||
|
|
||||||
local Waypoints = APC:TaskGroundOnRoad( Coordinate, _speed, "Line abreast", true )
|
|
||||||
|
|
||||||
local TaskFunction = APC:TaskFunction( "AI_CARGO_APC._Pickup", self, Coordinate, Speed, PickupZone )
|
local TaskFunction = APC:TaskFunction( "AI_CARGO_APC._Pickup", self, Coordinate, Speed, PickupZone )
|
||||||
|
|
||||||
self:F({Waypoints = Waypoints})
|
|
||||||
local Waypoint = Waypoints[#Waypoints]
|
local Waypoint = Waypoints[#Waypoints]
|
||||||
APC:SetTaskWaypoint( Waypoint, TaskFunction ) -- Set for the given Route at Waypoint 2 the TaskRouteToZone.
|
APC:SetTaskWaypoint( Waypoint, TaskFunction ) -- Set for the given Route at Waypoint 2 the TaskRouteToZone.
|
||||||
|
|
||||||
@ -434,7 +488,14 @@ function AI_CARGO_APC:onafterDeploy( APC, From, Event, To, Coordinate, Speed, He
|
|||||||
_speed=math.min(_speed, speedmax)
|
_speed=math.min(_speed, speedmax)
|
||||||
|
|
||||||
-- Route on road.
|
-- Route on road.
|
||||||
local Waypoints = APC:TaskGroundOnRoad(Coordinate, _speed, "Line abreast", true)
|
local Waypoints = {}
|
||||||
|
|
||||||
|
if self.deployOffroad then
|
||||||
|
Waypoints[1]=APC:GetCoordinate():WaypointGround(Speed, self.deployFormation)
|
||||||
|
Waypoints[2]=Coordinate:WaypointGround(_speed, self.deployFormation, DCSTasks)
|
||||||
|
else
|
||||||
|
Waypoints=APC:TaskGroundOnRoad(Coordinate, _speed, ENUMS.Formation.Vehicle.OffRoad, true)
|
||||||
|
end
|
||||||
|
|
||||||
-- Task function
|
-- Task function
|
||||||
local TaskFunction = APC:TaskFunction( "AI_CARGO_APC._Deploy", self, Coordinate, DeployZone )
|
local TaskFunction = APC:TaskFunction( "AI_CARGO_APC._Deploy", self, Coordinate, DeployZone )
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
--- **AI** -- (R2.4) - Models the intelligent transportation of infantry (cargo).
|
--- **AI** - Models the intelligent transportation of cargo using airplanes.
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
@ -408,9 +408,6 @@ function AI_CARGO_AIRPLANE:onafterUnload( Airplane, From, Event, To, DeployZone
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Route the airplane from one airport or it's current position to another airbase.
|
--- Route the airplane from one airport or it's current position to another airbase.
|
||||||
-- @param #AI_CARGO_AIRPLANE self
|
-- @param #AI_CARGO_AIRPLANE self
|
||||||
-- @param Wrapper.Group#GROUP Airplane Airplane group to be routed.
|
-- @param Wrapper.Group#GROUP Airplane Airplane group to be routed.
|
||||||
@ -438,14 +435,10 @@ function AI_CARGO_AIRPLANE:Route( Airplane, Airbase, Speed, Height, Uncontrolled
|
|||||||
|
|
||||||
-- To point.
|
-- To point.
|
||||||
local AirbasePointVec2 = Airbase:GetPointVec2()
|
local AirbasePointVec2 = Airbase:GetPointVec2()
|
||||||
local ToWaypoint = AirbasePointVec2:WaypointAir(
|
local ToWaypoint = AirbasePointVec2:WaypointAir(POINT_VEC3.RoutePointAltType.BARO, "Land", "Landing", Speed or Airplane:GetSpeedMax()*0.8, true, Airbase)
|
||||||
POINT_VEC3.RoutePointAltType.BARO,
|
|
||||||
"Land",
|
--ToWaypoint["airdromeId"] = Airbase:GetID()
|
||||||
"Landing",
|
--ToWaypoint["speed_locked"] = true
|
||||||
Speed or Airplane:GetSpeedMax()*0.8
|
|
||||||
)
|
|
||||||
ToWaypoint["airdromeId"] = Airbase:GetID()
|
|
||||||
ToWaypoint["speed_locked"] = true
|
|
||||||
|
|
||||||
|
|
||||||
-- If self.Airbase~=nil then group is currently at an airbase, where it should be respawned.
|
-- If self.Airbase~=nil then group is currently at an airbase, where it should be respawned.
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
--- **AI** -- (R2.4) - Models the intelligent transportation of infantry and other cargo.
|
--- **AI** - Models the intelligent transportation of infantry and other cargo.
|
||||||
--
|
--
|
||||||
-- ## Features:
|
-- ## Features:
|
||||||
--
|
--
|
||||||
@ -1104,7 +1104,7 @@ function AI_CARGO_DISPATCHER:onafterMonitor()
|
|||||||
-- The Pickup sequence ...
|
-- The Pickup sequence ...
|
||||||
-- Check if this Carrier need to go and Pickup something...
|
-- Check if this Carrier need to go and Pickup something...
|
||||||
-- So, if the cargo bay is not full yet with cargo to be loaded ...
|
-- So, if the cargo bay is not full yet with cargo to be loaded ...
|
||||||
self:I( { Carrier = CarrierGroupName, IsRelocating = AI_Cargo:IsRelocating(), IsTransporting = AI_Cargo:IsTransporting() } )
|
self:T( { Carrier = CarrierGroupName, IsRelocating = AI_Cargo:IsRelocating(), IsTransporting = AI_Cargo:IsTransporting() } )
|
||||||
if AI_Cargo:IsRelocating() == false and AI_Cargo:IsTransporting() == false then
|
if AI_Cargo:IsRelocating() == false and AI_Cargo:IsTransporting() == false then
|
||||||
-- ok, so there is a free Carrier
|
-- ok, so there is a free Carrier
|
||||||
-- now find the first cargo that is Unloaded
|
-- now find the first cargo that is Unloaded
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
--- **AI** -- (2.4) - Models the intelligent transportation of infantry and other cargo using APCs.
|
--- **AI** - Models the intelligent transportation of infantry and other cargo using APCs.
|
||||||
--
|
--
|
||||||
-- ## Features:
|
-- ## Features:
|
||||||
--
|
--
|
||||||
@ -181,25 +181,36 @@ function AI_CARGO_DISPATCHER_APC:New( APCSet, CargoSet, PickupZoneSet, DeployZon
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- AI cargo
|
||||||
|
-- @param #AI_CARGO_DISPATCHER_APC self
|
||||||
|
-- @param Wrapper.Group#GROUP APC The APC carrier.
|
||||||
|
-- @param Core.Set#SET_CARGO CargoSet Cargo set.
|
||||||
|
-- @return AI.AI_Cargo_APC#AI_CARGO_DISPATCHER_APC AI cargo APC object.
|
||||||
function AI_CARGO_DISPATCHER_APC:AICargo( APC, CargoSet )
|
function AI_CARGO_DISPATCHER_APC:AICargo( APC, CargoSet )
|
||||||
|
|
||||||
return AI_CARGO_APC:New( APC, CargoSet, self.CombatRadius )
|
local aicargoapc=AI_CARGO_APC:New(APC, CargoSet, self.CombatRadius)
|
||||||
|
|
||||||
|
aicargoapc:SetDeployOffRoad(self.deployOffroad, self.deployFormation)
|
||||||
|
aicargoapc:SetPickupOffRoad(self.pickupOffroad, self.pickupFormation)
|
||||||
|
|
||||||
|
return aicargoapc
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Enable/Disable unboarding of cargo (infantry) when enemies are nearby (to help defend the carrier).
|
--- Enable/Disable unboarding of cargo (infantry) when enemies are nearby (to help defend the carrier).
|
||||||
-- This is only valid for APCs and trucks etc, thus ground vehicles.
|
-- This is only valid for APCs and trucks etc, thus ground vehicles.
|
||||||
-- @param #AI_CARGO_DISPATCHER_APC self
|
-- @param #AI_CARGO_DISPATCHER_APC self
|
||||||
-- @param #number CombatRadius Provide the combat radius to defend the carrier by unboarding the cargo when enemies are nearby.
|
-- @param #number CombatRadius Provide the combat radius to defend the carrier by unboarding the cargo when enemies are nearby.
|
||||||
-- When the combat radius is 0, no defense will happen of the carrier.
|
-- When the combat radius is 0 (default), no defense will happen of the carrier.
|
||||||
-- When the combat radius is not provided, no defense will happen!
|
-- When the combat radius is not provided, no defense will happen!
|
||||||
-- @return #AI_CARGO_DISPATCHER_APC
|
-- @return #AI_CARGO_DISPATCHER_APC
|
||||||
-- @usage
|
-- @usage
|
||||||
--
|
--
|
||||||
-- -- Disembark the infantry when the carrier is under attack.
|
-- -- Disembark the infantry when the carrier is under attack.
|
||||||
-- AICargoDispatcher:SetCombatRadius( true )
|
-- AICargoDispatcher:SetCombatRadius( 500 )
|
||||||
--
|
--
|
||||||
-- -- Keep the cargo in the carrier when the carrier is under attack.
|
-- -- Keep the cargo in the carrier when the carrier is under attack.
|
||||||
-- AICargoDispatcher:SetCombatRadius( false )
|
-- AICargoDispatcher:SetCombatRadius( 0 )
|
||||||
function AI_CARGO_DISPATCHER_APC:SetCombatRadius( CombatRadius )
|
function AI_CARGO_DISPATCHER_APC:SetCombatRadius( CombatRadius )
|
||||||
|
|
||||||
self.CombatRadius = CombatRadius or 0
|
self.CombatRadius = CombatRadius or 0
|
||||||
@ -207,3 +218,41 @@ function AI_CARGO_DISPATCHER_APC:SetCombatRadius( CombatRadius )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Set whether the carrier will *not* use roads to *pickup* and *deploy* the cargo.
|
||||||
|
-- @param #AI_CARGO_DISPATCHER_APC self
|
||||||
|
-- @param #boolean Offroad If true, carrier will not use roads.
|
||||||
|
-- @param #number Formation Offroad formation used. Default is `ENUMS.Formation.Vehicle.Offroad`.
|
||||||
|
-- @return #AI_CARGO_DISPATCHER_APC self
|
||||||
|
function AI_CARGO_DISPATCHER_APC:SetOffRoad(Offroad, Formation)
|
||||||
|
|
||||||
|
self:SetPickupOffRoad(Offroad, Formation)
|
||||||
|
self:SetDeployOffRoad(Offroad, Formation)
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Set whether the carrier will *not* use roads to *pickup* the cargo.
|
||||||
|
-- @param #AI_CARGO_DISPATCHER_APC self
|
||||||
|
-- @param #boolean Offroad If true, carrier will not use roads.
|
||||||
|
-- @param #number Formation Offroad formation used. Default is `ENUMS.Formation.Vehicle.Offroad`.
|
||||||
|
-- @return #AI_CARGO_DISPATCHER_APC self
|
||||||
|
function AI_CARGO_DISPATCHER_APC:SetPickupOffRoad(Offroad, Formation)
|
||||||
|
|
||||||
|
self.pickupOffroad=Offroad
|
||||||
|
self.pickupFormation=Formation or ENUMS.Formation.Vehicle.OffRoad
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Set whether the carrier will *not* use roads to *deploy* the cargo.
|
||||||
|
-- @param #AI_CARGO_DISPATCHER_APC self
|
||||||
|
-- @param #boolean Offroad If true, carrier will not use roads.
|
||||||
|
-- @param #number Formation Offroad formation used. Default is `ENUMS.Formation.Vehicle.Offroad`.
|
||||||
|
-- @return #AI_CARGO_DISPATCHER_APC self
|
||||||
|
function AI_CARGO_DISPATCHER_APC:SetDeployOffRoad(Offroad, Formation)
|
||||||
|
|
||||||
|
self.deployOffroad=Offroad
|
||||||
|
self.deployFormation=Formation or ENUMS.Formation.Vehicle.OffRoad
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
@ -1,4 +1,4 @@
|
|||||||
--- **AI** -- (R2.4) - Models the intelligent transportation of infantry (cargo).
|
--- **AI** - Models the intelligent transportation of cargo using helicopters.
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
@ -364,26 +364,11 @@ function AI_CARGO_HELICOPTER:onafterOrbit( Helicopter, From, Event, To, Coordina
|
|||||||
|
|
||||||
local Route = {}
|
local Route = {}
|
||||||
|
|
||||||
-- local CoordinateFrom = Helicopter:GetCoordinate()
|
|
||||||
-- local WaypointFrom = CoordinateFrom:WaypointAir(
|
|
||||||
-- "RADIO",
|
|
||||||
-- POINT_VEC3.RoutePointType.TurningPoint,
|
|
||||||
-- POINT_VEC3.RoutePointAction.TurningPoint,
|
|
||||||
-- Speed,
|
|
||||||
-- true
|
|
||||||
-- )
|
|
||||||
-- Route[#Route+1] = WaypointFrom
|
|
||||||
local CoordinateTo = Coordinate
|
local CoordinateTo = Coordinate
|
||||||
local landheight = CoordinateTo:GetLandHeight() -- get target height
|
local landheight = CoordinateTo:GetLandHeight() -- get target height
|
||||||
CoordinateTo.y = landheight + 50 -- flight height should be 50m above ground
|
CoordinateTo.y = landheight + 50 -- flight height should be 50m above ground
|
||||||
|
|
||||||
local WaypointTo = CoordinateTo:WaypointAir(
|
local WaypointTo = CoordinateTo:WaypointAir("RADIO", POINT_VEC3.RoutePointType.TurningPoint, POINT_VEC3.RoutePointAction.TurningPoint, 50, true)
|
||||||
"RADIO",
|
|
||||||
POINT_VEC3.RoutePointType.TurningPoint,
|
|
||||||
POINT_VEC3.RoutePointAction.TurningPoint,
|
|
||||||
50,
|
|
||||||
true
|
|
||||||
)
|
|
||||||
Route[#Route+1] = WaypointTo
|
Route[#Route+1] = WaypointTo
|
||||||
|
|
||||||
local Tasks = {}
|
local Tasks = {}
|
||||||
@ -393,7 +378,7 @@ function AI_CARGO_HELICOPTER:onafterOrbit( Helicopter, From, Event, To, Coordina
|
|||||||
Route[#Route+1] = WaypointTo
|
Route[#Route+1] = WaypointTo
|
||||||
|
|
||||||
-- Now route the helicopter
|
-- Now route the helicopter
|
||||||
Helicopter:Route( Route, 0 )
|
Helicopter:Route(Route, 0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -422,7 +407,6 @@ function AI_CARGO_HELICOPTER:onafterDeployed( Helicopter, From, Event, To, Deplo
|
|||||||
|
|
||||||
self:GetParent( self, AI_CARGO_HELICOPTER ).onafterDeployed( self, Helicopter, From, Event, To, DeployZone )
|
self:GetParent( self, AI_CARGO_HELICOPTER ).onafterDeployed( self, Helicopter, From, Event, To, DeployZone )
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- On after Pickup event.
|
--- On after Pickup event.
|
||||||
@ -453,26 +437,14 @@ function AI_CARGO_HELICOPTER:onafterPickup( Helicopter, From, Event, To, Coordin
|
|||||||
local CoordinateFrom = Helicopter:GetCoordinate()
|
local CoordinateFrom = Helicopter:GetCoordinate()
|
||||||
|
|
||||||
--- Create a route point of type air.
|
--- Create a route point of type air.
|
||||||
local WaypointFrom = CoordinateFrom:WaypointAir(
|
local WaypointFrom = CoordinateFrom:WaypointAir("RADIO", POINT_VEC3.RoutePointType.TurningPoint, POINT_VEC3.RoutePointAction.TurningPoint, _speed, true)
|
||||||
"RADIO",
|
|
||||||
POINT_VEC3.RoutePointType.TurningPoint,
|
|
||||||
POINT_VEC3.RoutePointAction.TurningPoint,
|
|
||||||
_speed,
|
|
||||||
true
|
|
||||||
)
|
|
||||||
|
|
||||||
--- Create a route point of type air.
|
--- Create a route point of type air.
|
||||||
local CoordinateTo = Coordinate
|
local CoordinateTo = Coordinate
|
||||||
local landheight = CoordinateTo:GetLandHeight() -- get target height
|
local landheight = CoordinateTo:GetLandHeight() -- get target height
|
||||||
CoordinateTo.y = landheight + 50 -- flight height should be 50m above ground
|
CoordinateTo.y = landheight + 50 -- flight height should be 50m above ground
|
||||||
|
|
||||||
local WaypointTo = CoordinateTo:WaypointAir(
|
local WaypointTo = CoordinateTo:WaypointAir("RADIO", POINT_VEC3.RoutePointType.TurningPoint, POINT_VEC3.RoutePointAction.TurningPoint,_speed, true)
|
||||||
"RADIO",
|
|
||||||
POINT_VEC3.RoutePointType.TurningPoint,
|
|
||||||
POINT_VEC3.RoutePointAction.TurningPoint,
|
|
||||||
_speed,
|
|
||||||
true
|
|
||||||
)
|
|
||||||
|
|
||||||
Route[#Route+1] = WaypointFrom
|
Route[#Route+1] = WaypointFrom
|
||||||
Route[#Route+1] = WaypointTo
|
Route[#Route+1] = WaypointTo
|
||||||
@ -532,13 +504,7 @@ function AI_CARGO_HELICOPTER:onafterDeploy( Helicopter, From, Event, To, Coordin
|
|||||||
|
|
||||||
--- Create a route point of type air.
|
--- Create a route point of type air.
|
||||||
local CoordinateFrom = Helicopter:GetCoordinate()
|
local CoordinateFrom = Helicopter:GetCoordinate()
|
||||||
local WaypointFrom = CoordinateFrom:WaypointAir(
|
local WaypointFrom = CoordinateFrom:WaypointAir("RADIO", POINT_VEC3.RoutePointType.TurningPoint, POINT_VEC3.RoutePointAction.TurningPoint, _speed, true)
|
||||||
"RADIO",
|
|
||||||
POINT_VEC3.RoutePointType.TurningPoint,
|
|
||||||
POINT_VEC3.RoutePointAction.TurningPoint,
|
|
||||||
_speed,
|
|
||||||
true
|
|
||||||
)
|
|
||||||
Route[#Route+1] = WaypointFrom
|
Route[#Route+1] = WaypointFrom
|
||||||
Route[#Route+1] = WaypointFrom
|
Route[#Route+1] = WaypointFrom
|
||||||
|
|
||||||
@ -548,13 +514,7 @@ function AI_CARGO_HELICOPTER:onafterDeploy( Helicopter, From, Event, To, Coordin
|
|||||||
local landheight = CoordinateTo:GetLandHeight() -- get target height
|
local landheight = CoordinateTo:GetLandHeight() -- get target height
|
||||||
CoordinateTo.y = landheight + 50 -- flight height should be 50m above ground
|
CoordinateTo.y = landheight + 50 -- flight height should be 50m above ground
|
||||||
|
|
||||||
local WaypointTo = CoordinateTo:WaypointAir(
|
local WaypointTo = CoordinateTo:WaypointAir("RADIO", POINT_VEC3.RoutePointType.TurningPoint, POINT_VEC3.RoutePointAction.TurningPoint, _speed, true)
|
||||||
"RADIO",
|
|
||||||
POINT_VEC3.RoutePointType.TurningPoint,
|
|
||||||
POINT_VEC3.RoutePointAction.TurningPoint,
|
|
||||||
_speed,
|
|
||||||
true
|
|
||||||
)
|
|
||||||
|
|
||||||
Route[#Route+1] = WaypointTo
|
Route[#Route+1] = WaypointTo
|
||||||
Route[#Route+1] = WaypointTo
|
Route[#Route+1] = WaypointTo
|
||||||
@ -564,7 +524,9 @@ function AI_CARGO_HELICOPTER:onafterDeploy( Helicopter, From, Event, To, Coordin
|
|||||||
|
|
||||||
local Tasks = {}
|
local Tasks = {}
|
||||||
|
|
||||||
|
-- The _Deploy function does not exist.
|
||||||
Tasks[#Tasks+1] = Helicopter:TaskFunction( "AI_CARGO_HELICOPTER._Deploy", self, Coordinate, DeployZone )
|
Tasks[#Tasks+1] = Helicopter:TaskFunction( "AI_CARGO_HELICOPTER._Deploy", self, Coordinate, DeployZone )
|
||||||
|
|
||||||
Tasks[#Tasks+1] = Helicopter:TaskOrbitCircle( math.random( 30, 100 ), _speed, CoordinateTo:GetRandomCoordinateInRadius( 800, 500 ) )
|
Tasks[#Tasks+1] = Helicopter:TaskOrbitCircle( math.random( 30, 100 ), _speed, CoordinateTo:GetRandomCoordinateInRadius( 800, 500 ) )
|
||||||
|
|
||||||
--Tasks[#Tasks+1] = Helicopter:TaskLandAtVec2( CoordinateTo:GetVec2() )
|
--Tasks[#Tasks+1] = Helicopter:TaskLandAtVec2( CoordinateTo:GetVec2() )
|
||||||
@ -607,13 +569,8 @@ function AI_CARGO_HELICOPTER:onafterHome( Helicopter, From, Event, To, Coordinat
|
|||||||
|
|
||||||
--- Create a route point of type air.
|
--- Create a route point of type air.
|
||||||
local CoordinateFrom = Helicopter:GetCoordinate()
|
local CoordinateFrom = Helicopter:GetCoordinate()
|
||||||
local WaypointFrom = CoordinateFrom:WaypointAir(
|
|
||||||
"RADIO",
|
local WaypointFrom = CoordinateFrom:WaypointAir("RADIO", POINT_VEC3.RoutePointType.TurningPoint, POINT_VEC3.RoutePointAction.TurningPoint, Speed, true)
|
||||||
POINT_VEC3.RoutePointType.TurningPoint,
|
|
||||||
POINT_VEC3.RoutePointAction.TurningPoint,
|
|
||||||
Speed ,
|
|
||||||
true
|
|
||||||
)
|
|
||||||
Route[#Route+1] = WaypointFrom
|
Route[#Route+1] = WaypointFrom
|
||||||
|
|
||||||
--- Create a route point of type air.
|
--- Create a route point of type air.
|
||||||
@ -621,13 +578,7 @@ function AI_CARGO_HELICOPTER:onafterHome( Helicopter, From, Event, To, Coordinat
|
|||||||
local landheight = CoordinateTo:GetLandHeight() -- get target height
|
local landheight = CoordinateTo:GetLandHeight() -- get target height
|
||||||
CoordinateTo.y = landheight + 50 -- flight height should be 50m above ground
|
CoordinateTo.y = landheight + 50 -- flight height should be 50m above ground
|
||||||
|
|
||||||
local WaypointTo = CoordinateTo:WaypointAir(
|
local WaypointTo = CoordinateTo:WaypointAir("RADIO", POINT_VEC3.RoutePointType.TurningPoint, POINT_VEC3.RoutePointAction.TurningPoint, Speed, true)
|
||||||
"RADIO",
|
|
||||||
POINT_VEC3.RoutePointType.TurningPoint,
|
|
||||||
POINT_VEC3.RoutePointAction.TurningPoint,
|
|
||||||
Speed ,
|
|
||||||
true
|
|
||||||
)
|
|
||||||
|
|
||||||
Route[#Route+1] = WaypointTo
|
Route[#Route+1] = WaypointTo
|
||||||
|
|
||||||
@ -642,7 +593,7 @@ function AI_CARGO_HELICOPTER:onafterHome( Helicopter, From, Event, To, Coordinat
|
|||||||
Route[#Route+1] = WaypointTo
|
Route[#Route+1] = WaypointTo
|
||||||
|
|
||||||
-- Now route the helicopter
|
-- Now route the helicopter
|
||||||
Helicopter:Route( Route, 0 )
|
Helicopter:Route(Route, 0)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
--- **Core** -- Management of CARGO logistics, that can be transported from and to transportation carriers.
|
--- **Cargo** - Management of CARGO logistics, that can be transported from and to transportation carriers.
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
--- **Cargo** -- Management of grouped cargo logistics, which are based on a @{Wrapper.Group} object.
|
--- **Cargo** - Management of grouped cargo logistics, which are based on a @{Wrapper.Group} object.
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
--- **Cargo** -- Management of single cargo logistics, which are based on a @{Wrapper.Unit} object.
|
--- **Cargo** - Management of single cargo logistics, which are based on a @{Wrapper.Unit} object.
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user