ACE3/addons/dragging/initKeybinds.sqf
johnb432 dbe372cb48
Dragging - Improve code (#9271)
* Code cleanup

* Moved keybinds to initKeybinds.sqf

* Update addons/dragging/initKeybinds.sqf

Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>

* Update addons/dragging/functions/fnc_carryObject.sqf

Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>

* Update addons/dragging/functions/fnc_getWeight.sqf

Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>

* Rephrasing and adjustments for dragging

---------

Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>
2023-07-24 02:07:37 +03:00

59 lines
2.1 KiB
Plaintext

// Add Keybinds
["ACE3 Common", QGVAR(drag), LLSTRING(DragKeybind), {
private _player = ACE_player;
if (!alive _player) exitWith {false};
if !([_player, objNull, ["isNotDragging", "isNotCarrying", "isNotSwimming"]] call EFUNC(common,canInteractWith)) exitWith {false};
// If we are drag/carrying something right now then just drop it:
if (_player getVariable [QGVAR(isDragging), false]) exitWith {
[_player, _player getVariable [QGVAR(draggedObject), objNull]] call FUNC(dropObject);
false
};
if (_player getVariable [QGVAR(isCarrying), false]) exitWith {
[_player, _player getVariable [QGVAR(carriedObject), objNull]] call FUNC(dropObject_carry);
false
};
private _cursorObject = cursorObject;
if (isNull _cursorObject || {(_cursorObject distance _player) > 2.6}) exitWith {false};
if !([_player, _cursorObject] call FUNC(canDrag)) exitWith {false};
[_player, _cursorObject] call FUNC(startDrag);
false
}, {}, [-1, [false, false, false]]] call CBA_fnc_addKeybind; // UNBOUND
["ACE3 Common", QGVAR(carry), LLSTRING(CarryKeybind), {
private _player = ACE_player;
if (!alive _player) exitWith {false};
if !([_player, objNull, ["isNotDragging", "isNotCarrying"]] call EFUNC(common,canInteractWith)) exitWith {false};
// If we are drag/carrying something right now then just drop it:
if (_player getVariable [QGVAR(isDragging), false]) exitWith {
[_player, _player getVariable [QGVAR(draggedObject), objNull]] call FUNC(dropObject);
false
};
if (_player getVariable [QGVAR(isCarrying), false]) exitWith {
[_player, _player getVariable [QGVAR(carriedObject), objNull], true] call FUNC(dropObject_carry);
false
};
private _cursorObject = cursorObject;
if (isNull _cursorObject || {(_cursorObject distance _player) > 2.6}) exitWith {false};
if !([_player, _cursorObject] call FUNC(canCarry)) exitWith {false};
[_player, _cursorObject] call FUNC(startCarry);
false
}, {}, [-1, [false, false, false]]] call CBA_fnc_addKeybind; // UNBOUND