Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update CBA_fnc_dropWeapon #1262

Merged
merged 1 commit into from
Dec 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 11 additions & 28 deletions addons/common/fnc_dropWeapon.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Function: CBA_fnc_dropWeapon

Description:
Drops a weapon.
Drops a weapon (including binocular).

Function which verifies existence of _item and _unit, returns false in case
of trouble, or when able to remove _item from _unit true in case of success
Expand All @@ -21,32 +21,23 @@ Examples:
(end)

Author:
?, commy2
commy2
---------------------------------------------------------------------------- */
SCRIPT(dropWeapon);

params [["_unit", objNull, [objNull]], ["_item", "", [""]]];

private _weaponInfo = (weaponsItems _unit select {_x select 0 == _item}) param [0, []];
private _return = [_unit, _item] call CBA_fnc_removeWeapon;

if (_return) then {
private _baseWeapon = _item call CBA_fnc_weaponComponents param [0, _item];

private _items = _weaponInfo;
_items deleteAt 0; // delete the weapon

private _magazines = [];
private _weaponInfo = [];

{
if (_x isEqualType []) then {
_magazines pushBack _x;
_items set [_forEachIndex, ""];
};
} forEach _items;
{
if (_x param [0, ""] == _item) exitWith {
_weaponInfo = _x;
};
} forEach weaponsItems _unit;

_items = _items - [""];
private _return = [_unit, _item] call CBA_fnc_removeWeapon;

if (_return) then {
_unit switchMove "ainvpknlmstpslaywrfldnon_1";

private _weaponHolder = nearestObject [_unit, "WeaponHolder"];
Expand All @@ -56,15 +47,7 @@ if (_return) then {
_weaponHolder setPosASL getPosASL _unit;
};

_weaponHolder addWeaponCargoGlobal [_baseWeapon, 1];

{
_weaponHolder addItemCargoGlobal [_x, 1];
} forEach _items;

{
_weaponHolder addMagazineAmmoCargo [_x select 0, 1, _x select 1];
} forEach _magazines;
_weaponHolder addWeaponWithAttachmentsCargoGlobal [_weaponInfo, 1];
};

_return
2 changes: 1 addition & 1 deletion addons/common/fnc_removeWeapon.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Function: CBA_fnc_removeWeapon

Description:
Remove a weapon.
Remove a weapon (including binocular).

Function which verifies existence of _item and _unit, returns false in case
of trouble, or when able to remove _item from _unit true in case of success.
Expand Down