mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
#1571 - Handle Null Attached Objects
This commit is contained in:
parent
f6c752045c
commit
d06680e2a0
@ -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}} &&
|
||||
|
@ -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];
|
||||
|
Loading…
Reference in New Issue
Block a user