From a08ed0e3076c1fca8b9515d13706f429f18907a1 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Mon, 1 May 2017 18:06:34 -0500 Subject: [PATCH] Fix refuel nozzle dropping to ground (#5119) --- addons/refuel/functions/fnc_dropNozzle.sqf | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/addons/refuel/functions/fnc_dropNozzle.sqf b/addons/refuel/functions/fnc_dropNozzle.sqf index 575d318068..80bf8896ab 100644 --- a/addons/refuel/functions/fnc_dropNozzle.sqf +++ b/addons/refuel/functions/fnc_dropNozzle.sqf @@ -19,13 +19,26 @@ #include "script_component.hpp" params [["_unit", objNull, [objNull]], ["_nozzle", objNull, [objNull]], ["_disconnectOnly", false, [false]]]; +TRACE_3("dropNozzle",_unit,_nozzle,_disconnectOnly); detach _nozzle; _nozzle setVariable [QGVAR(isRefueling), false, true]; if (_disconnectOnly) exitWith {}; _nozzle setVelocity [0, 0, 0]; -_nozzle setPosATL [(getPosATL _nozzle) select 0, (getPosATL _nozzle) select 1, 0.05]; + +private _groundPosition = getPosASL _nozzle; +private _posA = (getPosASL _nozzle) vectorAdd [0,0,0.05]; +private _posB = (getPosASL _nozzle) vectorAdd [0,0,-1000]; +private _intersections = lineIntersectsSurfaces [_posA, _posB, _unit, _nozzle, true, 1, "GEOM"]; +TRACE_1("",_intersections); +if (_intersections isEqualTo []) then { + _groundPosition set [2, (getTerrainHeightASL _groundPosition) vectorAdd [0,0,0.005]]; +} else { + _groundPosition = ((_intersections select 0) select 0) vectorAdd [0,0,0.005]; +}; +_nozzle setPosASL _groundPosition; +TRACE_1("finalPos",getPosATL _nozzle); if (isNull _unit) exitWith {}; _unit setVariable [QGVAR(isRefueling), false, true];