ACE3/addons/dragging/functions/fnc_handlePlayerWeaponChanged.sqf

45 lines
1.2 KiB
Plaintext
Raw Normal View History

#include "..\script_component.hpp"
2015-08-09 12:53:13 +00:00
/*
* Author: commy2
* Handles the weapon changed event.
2015-08-09 12:53:13 +00:00
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Weapon <STRING>
*
* Return Value:
* None
*
* Example:
* [player, primaryWeapon player] call ace_dragging_fnc_handlePlayerWeaponChanged;
2015-08-09 12:53:13 +00:00
*
* Public: No
*/
2015-03-18 14:42:33 +00:00
2015-08-09 12:53:13 +00:00
params ["_unit", "_weapon"];
2016-01-28 18:52:53 +00:00
TRACE_2("params",_unit,_weapon);
2015-03-18 14:42:33 +00:00
if (_unit getVariable [QGVAR(isDragging), false]) then {
// Drop dragged object when changing weapon
2021-04-20 11:33:58 +00:00
if (_weapon != _unit getVariable [QGVAR(currentWeapon), ""]) then {
2016-01-28 18:52:53 +00:00
private _draggedObject = _unit getVariable [QGVAR(draggedObject), objNull];
2015-03-18 14:42:33 +00:00
[_unit, _draggedObject] call FUNC(dropObject);
};
};
if (_unit getVariable [QGVAR(isCarrying), false]) then {
2016-01-28 18:52:53 +00:00
private _carriedObject = _unit getVariable [QGVAR(carriedObject), objNull];
2015-03-18 14:42:33 +00:00
2015-03-25 12:32:59 +00:00
if (_carriedObject isKindOf "CAManBase") then {
if (_weapon != primaryWeapon _unit) then {
[_unit, _carriedObject] call FUNC(dropObject_carry);
};
} else {
// Drop carried object when selecting any weapon
2015-03-25 12:32:59 +00:00
if (_weapon != "") then {
[_unit, _carriedObject] call FUNC(dropObject_carry);
};
};
2015-03-18 14:42:33 +00:00
};