mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Update AI_Cargo_Helicopter.lua
Removed unnecessary FSM transitions, added height to Waypoints to avoid (blue) Helis to creep over the ground
This commit is contained in:
parent
49d7d9ee2e
commit
c51a65f058
@ -62,14 +62,15 @@ function AI_CARGO_HELICOPTER:New( Helicopter, CargoSet )
|
|||||||
local self = BASE:Inherit( self, AI_CARGO:New( Helicopter, CargoSet ) ) -- #AI_CARGO_HELICOPTER
|
local self = BASE:Inherit( self, AI_CARGO:New( Helicopter, CargoSet ) ) -- #AI_CARGO_HELICOPTER
|
||||||
|
|
||||||
self.Zone = ZONE_GROUP:New( Helicopter:GetName(), Helicopter, 300 )
|
self.Zone = ZONE_GROUP:New( Helicopter:GetName(), Helicopter, 300 )
|
||||||
|
|
||||||
self:SetStartState( "Unloaded" )
|
self:SetStartState( "Unloaded" )
|
||||||
|
|
||||||
self:AddTransition( "Unloaded", "Pickup", "*" )
|
self:AddTransition( "Unloaded", "Pickup", "*" )
|
||||||
self:AddTransition( "Loaded", "Deploy", "*" )
|
self:AddTransition( "Loaded", "Deploy", "*" )
|
||||||
|
--[[
|
||||||
self:AddTransition( { "Unloaded", "Loading" }, "Load", "Boarding" )
|
self:AddTransition( { "Unloaded", "Loading" }, "Load", "Boarding" )
|
||||||
self:AddTransition( "Boarding", "Board", "Boarding" )
|
self:AddTransition( "Boarding", "Board", "Boarding" )
|
||||||
self:AddTransition( "Boarding", "Loaded", "Boarding" )
|
self:AddTransition( "Boarding", "Loaded", "Loaded" )
|
||||||
self:AddTransition( "Boarding", "PickedUp", "Loaded" )
|
self:AddTransition( "Boarding", "PickedUp", "Loaded" )
|
||||||
self:AddTransition( "Boarding", "Deploy", "Loaded" )
|
self:AddTransition( "Boarding", "Deploy", "Loaded" )
|
||||||
self:AddTransition( "Loaded", "Unload", "Unboarding" )
|
self:AddTransition( "Loaded", "Unload", "Unboarding" )
|
||||||
@ -77,7 +78,11 @@ function AI_CARGO_HELICOPTER:New( Helicopter, CargoSet )
|
|||||||
self:AddTransition( "Unboarding", "Unloaded", "Unboarding" )
|
self:AddTransition( "Unboarding", "Unloaded", "Unboarding" )
|
||||||
self:AddTransition( "Unboarding", "Deployed", "Unloaded" )
|
self:AddTransition( "Unboarding", "Deployed", "Unloaded" )
|
||||||
self:AddTransition( "Unboarding", "Pickup", "Unloaded" )
|
self:AddTransition( "Unboarding", "Pickup", "Unloaded" )
|
||||||
|
--]]
|
||||||
|
self:AddTransition( "Boarding", "Loaded", "Loaded" )
|
||||||
|
self:AddTransition( "Unboarding", "Pickup", "Unloaded" )
|
||||||
|
self:AddTransition( "Unloaded", "Unboard", "Unloaded" )
|
||||||
|
self:AddTransition( "Unloaded", "Unloaded", "Unloaded" )
|
||||||
self:AddTransition( "*", "Landed", "*" )
|
self:AddTransition( "*", "Landed", "*" )
|
||||||
self:AddTransition( "*", "Queue", "*" )
|
self:AddTransition( "*", "Queue", "*" )
|
||||||
self:AddTransition( "*", "Orbit" , "*" )
|
self:AddTransition( "*", "Orbit" , "*" )
|
||||||
@ -309,7 +314,11 @@ function AI_CARGO_HELICOPTER:onafterQueue( Helicopter, From, Event, To, Coordina
|
|||||||
-- true
|
-- true
|
||||||
-- )
|
-- )
|
||||||
-- Route[#Route+1] = WaypointFrom
|
-- Route[#Route+1] = WaypointFrom
|
||||||
local CoordinateTo = Coordinate
|
local CoordinateTo = Coordinate
|
||||||
|
|
||||||
|
local landheight = CoordinateTo:GetLandHeight() -- get target height
|
||||||
|
CoordinateTo.y = landheight + 50 -- flight height should be 50m above ground
|
||||||
|
|
||||||
local WaypointTo = CoordinateTo:WaypointAir(
|
local WaypointTo = CoordinateTo:WaypointAir(
|
||||||
"RADIO",
|
"RADIO",
|
||||||
POINT_VEC3.RoutePointType.TurningPoint,
|
POINT_VEC3.RoutePointType.TurningPoint,
|
||||||
@ -363,7 +372,10 @@ function AI_CARGO_HELICOPTER:onafterOrbit( Helicopter, From, Event, To, Coordina
|
|||||||
-- true
|
-- true
|
||||||
-- )
|
-- )
|
||||||
-- Route[#Route+1] = WaypointFrom
|
-- Route[#Route+1] = WaypointFrom
|
||||||
local CoordinateTo = Coordinate
|
local CoordinateTo = Coordinate
|
||||||
|
local landheight = CoordinateTo:GetLandHeight() -- get target height
|
||||||
|
CoordinateTo.y = landheight + 50 -- flight height should be 50m above ground
|
||||||
|
|
||||||
local WaypointTo = CoordinateTo:WaypointAir(
|
local WaypointTo = CoordinateTo:WaypointAir(
|
||||||
"RADIO",
|
"RADIO",
|
||||||
POINT_VEC3.RoutePointType.TurningPoint,
|
POINT_VEC3.RoutePointType.TurningPoint,
|
||||||
@ -423,7 +435,8 @@ end
|
|||||||
-- @param #number Height Height in meters to move to the pickup coordinate. This parameter is ignored for APCs.
|
-- @param #number Height Height in meters to move to the pickup coordinate. This parameter is ignored for APCs.
|
||||||
-- @param Core.Zone#ZONE PickupZone (optional) The zone where the cargo will be picked up. The PickupZone can be nil, if there wasn't any PickupZoneSet provided.
|
-- @param Core.Zone#ZONE PickupZone (optional) The zone where the cargo will be picked up. The PickupZone can be nil, if there wasn't any PickupZoneSet provided.
|
||||||
function AI_CARGO_HELICOPTER:onafterPickup( Helicopter, From, Event, To, Coordinate, Speed, Height, PickupZone )
|
function AI_CARGO_HELICOPTER:onafterPickup( Helicopter, From, Event, To, Coordinate, Speed, Height, PickupZone )
|
||||||
|
self:F({Coordinate, Speed, Height, PickupZone })
|
||||||
|
|
||||||
if Helicopter and Helicopter:IsAlive() ~= nil then
|
if Helicopter and Helicopter:IsAlive() ~= nil then
|
||||||
|
|
||||||
Helicopter:Activate()
|
Helicopter:Activate()
|
||||||
@ -437,7 +450,6 @@ function AI_CARGO_HELICOPTER:onafterPickup( Helicopter, From, Event, To, Coordin
|
|||||||
|
|
||||||
--- Calculate the target route point.
|
--- Calculate the target route point.
|
||||||
local CoordinateFrom = Helicopter:GetCoordinate()
|
local CoordinateFrom = Helicopter:GetCoordinate()
|
||||||
local CoordinateTo = Coordinate
|
|
||||||
|
|
||||||
--- Create a route point of type air.
|
--- Create a route point of type air.
|
||||||
local WaypointFrom = CoordinateFrom:WaypointAir(
|
local WaypointFrom = CoordinateFrom:WaypointAir(
|
||||||
@ -449,6 +461,10 @@ function AI_CARGO_HELICOPTER:onafterPickup( Helicopter, From, Event, To, Coordin
|
|||||||
)
|
)
|
||||||
|
|
||||||
--- Create a route point of type air.
|
--- Create a route point of type air.
|
||||||
|
local CoordinateTo = Coordinate
|
||||||
|
local landheight = CoordinateTo:GetLandHeight() -- get target height
|
||||||
|
CoordinateTo.y = landheight + 50 -- flight height should be 50m above ground
|
||||||
|
|
||||||
local WaypointTo = CoordinateTo:WaypointAir(
|
local WaypointTo = CoordinateTo:WaypointAir(
|
||||||
"RADIO",
|
"RADIO",
|
||||||
POINT_VEC3.RoutePointType.TurningPoint,
|
POINT_VEC3.RoutePointType.TurningPoint,
|
||||||
@ -526,7 +542,11 @@ function AI_CARGO_HELICOPTER:onafterDeploy( Helicopter, From, Event, To, Coordin
|
|||||||
Route[#Route+1] = WaypointFrom
|
Route[#Route+1] = WaypointFrom
|
||||||
|
|
||||||
--- 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
|
||||||
|
CoordinateTo.y = landheight + 50 -- flight height should be 50m above ground
|
||||||
|
|
||||||
local WaypointTo = CoordinateTo:WaypointAir(
|
local WaypointTo = CoordinateTo:WaypointAir(
|
||||||
"RADIO",
|
"RADIO",
|
||||||
POINT_VEC3.RoutePointType.TurningPoint,
|
POINT_VEC3.RoutePointType.TurningPoint,
|
||||||
@ -596,7 +616,10 @@ function AI_CARGO_HELICOPTER:onafterHome( Helicopter, From, Event, To, Coordinat
|
|||||||
Route[#Route+1] = WaypointFrom
|
Route[#Route+1] = WaypointFrom
|
||||||
|
|
||||||
--- 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
|
||||||
|
CoordinateTo.y = landheight + 50 -- flight height should be 50m above ground
|
||||||
|
|
||||||
local WaypointTo = CoordinateTo:WaypointAir(
|
local WaypointTo = CoordinateTo:WaypointAir(
|
||||||
"RADIO",
|
"RADIO",
|
||||||
POINT_VEC3.RoutePointType.TurningPoint,
|
POINT_VEC3.RoutePointType.TurningPoint,
|
||||||
@ -623,3 +646,4 @@ function AI_CARGO_HELICOPTER:onafterHome( Helicopter, From, Event, To, Coordinat
|
|||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user