ACE3/addons/malyutka/functions/fnc_onMouseButtonDown.sqf
Brandon Danyluk fc7b310529 Add realistic 9m14 behaviour
the 9m14 control joystick can attach 4 9m14 launchers at a time. Replicate that here
2021-05-08 02:48:40 -06:00

49 lines
1.2 KiB
Plaintext

#include "script_component.hpp"
/*
* Author: Brandon (TCVM)
* Handles mouse interaction when carrying plug
*
* Arguments:
* None
*
* Return Value:
* None
*
* Example:
* [player, plug] call ace_malyutka_fnc_onMouseButtonDown
*
* Public: No
*/
params ["", "_button"];
private _unit = ACE_PLAYER;
private _plug = _unit getVariable [QGVAR(carryingPlug), objNull];
if (_button > 1 || _plug isEqualTo objNull) exitWith {
};
if (_button == 1) then {
// RMB
_plug setVariable [QGVAR(dropped), true];
} else {
// LMB
getCursorObjectParams params ["_cursorObject", "", "_distance"];
if (!isNull _cursorObject && {_distance < ATTACH_DISTANCE}) then {
if (
_cursorObject isKindOf QGVAR(9m14_joystick) &&
{ ([_suitcase, _cursorObject] call FUNC(canAttachPlug)) }
) then {
[_plug getVariable QGVAR(origin), _cursorObject] call FUNC(attachPlug);
_plug setVariable [QGVAR(dropped), true];
};
if (
_cursorObject isKindOf QGVAR(9m14) &&
{ _cursorObject isEqualTo (_plug getVariable QGVAR(origin)) }
) then {
[_plug, _cursorObject] call FUNC(returnPlug);
};
};
};