Fix for unable to unload from driver seat.

Improvement for helo's on roof tops and boats.
#1728
This commit is contained in:
ViperMaul 2015-06-22 19:48:28 -07:00
parent ce0bbe60d3
commit 6b6ad93848

View File

@ -10,20 +10,28 @@
*
* Public: No
*/
//#define DEBUG_MODE_FULL
#define DEBUG_MODE_FULL
#include "script_component.hpp"
#define GROUP_SWITCH_ID QUOTE(FUNC(loadPerson))
private ["_loaded", "_emptyPos"];
private ["_loaded", "_emptyPos","_validVehiclestate"];
PARAMS_2(_unit,_vehicle);
_validVehiclestate = true;
if (driver _vehicle == _unit) exitwith {TRACE_1("Exiting on Failed Driver Check", driver _vehicle == _unit); false;};
TRACE_1("Vehicle Check", driver _vehicle == _unit);
if !(speed _vehicle <1 && (((getPos _vehicle) select 2) < 2)) exitwith {TRACE_1("Exiting on Failed speed check", getPosASL _vehicle == _unit); false;};
TRACE_1("getPosASL Vehicle Check", getPos _vehicle);
if (_vehicle isKindOf "Ship" ) then {
if !(speed _vehicle <1 && {(((getPosATL _vehicle) select 2) < 2)}) then {_validVehiclestate = false};
TRACE_1("SHIP Ground Check", getPosATL _vehicle );
_emptyPos = ((getPosASL _vehicle) call EFUNC(common,ASLtoPosition) findEmptyPosition [0, 13, typeof _unit]); // TODO: if spot is underwater pick another spot.
} else {
if !(speed _vehicle <1 && {isTouchingGround _vehicle}) then {_validVehiclestate = false};
TRACE_1("Vehicle Ground Check", isTouchingGround _vehicle);
_emptyPos = ((getPosASL _vehicle) call EFUNC(common,ASLtoPosition) findEmptyPosition [0, 13, typeof _unit]);
};
TRACE_1("getPosASL Vehicle Check", getPosASL _vehicle);
if (!_validVehiclestate) exitwith { diag_log format["Exiting on invalid vehicle state. Either moving or Not close enough on the ground. %1", getPos _vehicle]; false; };
_emptyPos = ((getPosASL _vehicle) call EFUNC(common,ASLtoPosition) findEmptyPosition [0, 13, typeof _unit]);
if (count _emptyPos == 0) exitwith {false}; //consider displaying text saying there are no safe places to exit the vehicle
unassignVehicle _unit;