Make RAT crudely predict where the ship will be at landing time instead of routing aircraft to where the ship is at spawn time.

This commit is contained in:
HawaiianRyan808
2026-02-06 13:54:12 -06:00
parent d5b7a2e168
commit 8bab24adbd
@@ -3042,6 +3042,14 @@ function RAT:_SetRoute(takeoff, landing, _departure, _destination, _waypoint)
if landing==RAT.wp.air then
local vec2=destination:GetRandomVec2()
Pdestination=COORDINATE:NewFromVec2(vec2)
elseif destination:IsShip() then
-- Crudely predict where the ship will be
local _ship = UNIT:FindByName(destination:GetName())
local _shipHeading = _ship:GetHeading()
Pdestination=destination:GetCoordinate()
local _transitTime = Pdeparture:Get2DDistance(Pdestination) / VxCruise
Pdestination.x = Pdestination.x + (_ship:GetGroundSpeed() * math.cos(math.rad(_shipHeading)) * _transitTime)
Pdestination.z = Pdestination.z + (_ship:GetGroundSpeed() * math.sin(math.rad(_shipHeading)) * _transitTime)
else
Pdestination=destination:GetCoordinate()
end