#1571 - Handle Null Attached Objects

This commit is contained in:
PabstMirror 2015-08-29 11:47:56 -05:00
parent f6c752045c
commit d06680e2a0
2 changed files with 14 additions and 1 deletions

View File

@ -19,13 +19,21 @@
params ["_attachToVehicle", "_unit"];
TRACE_2("params",_attachToVehicle,_unit);
_attachedList = _attachToVehicle getVariable [QGVAR(attached), []];
if ((count _attachedList) == 0) exitWith {false};
private ["_inRange"];
_inRange = false;
{
_x params ["_xObject"];
if (isNull _xObject) exitWith {
TRACE_1("Null attached",_x);
_attachedList deleteAt _forEachIndex;
_attachToVehicle setVariable [QGVAR(attached), _attachedList, true];
};
if (((getPos _unit) distance2d (getPos _xObject)) < 4) exitWith {_inRange = true};
} forEach (_attachToVehicle getVariable [QGVAR(attached), []]);
} forEach _attachedList;
_inRange &&
{(_unit == _attachToVehicle) || {canStand _unit}} &&

View File

@ -29,6 +29,11 @@ if ((count _attachedList) == 0) exitWith {};
_x params ["_xObject"];
TRACE_2("detaching",_xObject,_deadUnit);
detach _xObject;
//If it's a vehicle, also delete the attached
if (!(_deadUnit isKindOf "CAManBase")) then {
_xObject setPos ((getPos _deadUnit) vectorAdd [0, 0, -1000]);
[{deleteVehicle (_this select 0)}, [_xObject], 2] call EFUNC(common,waitAndExecute);
};
} forEach _attachedList;
_deadUnit setVariable [QGVAR(attached), nil, true];