Skip to content

Commit

Permalink
Chemlights no longer re-add to inventory on remove.
Browse files Browse the repository at this point in the history
Items are detached prior to being deleted, to avoid objNull attaches.
  • Loading branch information
voiperr committed Jun 14, 2016
1 parent 11dc3bd commit b69aa85
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions addons/attach/functions/fnc_detach.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
params ["_attachToVehicle","_unit"],
TRACE_2("params",_attachToVehicle,_unit);

private ["_attachedList", "_itemDisplayName", "_attachedObject", "_attachedIndex", "_itemName", "_minDistance"];
private ["_attachedList", "_itemDisplayName", "_attachedObject", "_attachedIndex", "_itemName", "_minDistance", "_isChemlight"];

_attachedList = _attachToVehicle getVariable [QGVAR(attached), []];

Expand All @@ -44,13 +44,18 @@ _minDistance = 1000;
// Check if unit has an attached item
if (isNull _attachedObject || {_itemName == ""}) exitWith {ERROR("Could not find attached object")};

// Check if item is a chemlight
_isChemlight = _attachedObject isKindOf "Chemlight_base";

// Exit if can't add the item
if !(_unit canAdd _itemName) exitWith {
if (!(_unit canAdd _itemName) && {!_isChemlight}) exitWith {
[localize LSTRING(Inventory_Full)] call EFUNC(common,displayTextStructured);
};

// Add item to inventory
_unit addItem _itemName;
// Add item to inventory (unless it's a chemlight)
if (!_isChemlight) then {
_unit addItem _itemName;
};

if (toLower _itemName in ["b_ir_grenade", "o_ir_grenade", "i_ir_grenade"]) then {
// Hack for dealing with X_IR_Grenade effect not dissapearing on deleteVehicle
Expand All @@ -60,6 +65,7 @@ if (toLower _itemName in ["b_ir_grenade", "o_ir_grenade", "i_ir_grenade"]) then
[{deleteVehicle (_this select 0)}, [_attachedObject], 2] call CBA_fnc_waitAndExecute;
} else {
// Delete attached item
detach _attachedObject;
deleteVehicle _attachedObject;
};

Expand Down

0 comments on commit b69aa85

Please sign in to comment.