2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2015-03-18 00:36:56 +00:00
|
|
|
/*
|
|
|
|
* Author: L-H, commy2
|
|
|
|
* Handles raising and lowering the dragged weapon to be able to place it on top of objects.
|
|
|
|
*
|
2015-08-09 12:53:13 +00:00
|
|
|
* Arguments:
|
|
|
|
* 0: Scroll amount <NUMBER>
|
2015-03-18 00:36:56 +00:00
|
|
|
*
|
2015-08-09 12:53:13 +00:00
|
|
|
* Return Value:
|
|
|
|
* Handled or not. <BOOL>
|
|
|
|
*
|
2016-01-28 18:52:53 +00:00
|
|
|
* Example:
|
|
|
|
* [0.1] call ace_dragging_fnc_handleScrollWheel;
|
|
|
|
*
|
2015-08-09 12:53:13 +00:00
|
|
|
* Public: No
|
2015-03-18 00:36:56 +00:00
|
|
|
*/
|
|
|
|
|
2015-08-09 12:53:13 +00:00
|
|
|
params ["_scrollAmount"];
|
|
|
|
|
2016-01-28 18:52:53 +00:00
|
|
|
private _unit = ACE_player;
|
2015-03-18 00:36:56 +00:00
|
|
|
|
|
|
|
// EH is always assigned. Exit and don't overwrite input if not carrying
|
|
|
|
if !(_unit getVariable [QGVAR(isCarrying), false]) exitWith {false};
|
|
|
|
|
2016-01-28 18:52:53 +00:00
|
|
|
private _carriedItem = _unit getVariable [QGVAR(carriedObject), objNull];
|
2015-03-25 12:32:59 +00:00
|
|
|
|
2023-07-23 23:07:37 +00:00
|
|
|
// Disabled for persons
|
2015-03-25 12:32:59 +00:00
|
|
|
if (_carriedItem isKindOf "CAManBase") exitWith {false};
|
2015-03-18 00:36:56 +00:00
|
|
|
|
2024-03-26 12:50:21 +00:00
|
|
|
if (!CBA_events_control) then {
|
2023-07-23 23:07:37 +00:00
|
|
|
// Raise/lower
|
|
|
|
// Move carried item 15 cm per scroll interval
|
2020-04-20 15:45:59 +00:00
|
|
|
_scrollAmount = _scrollAmount * 0.15;
|
|
|
|
|
|
|
|
private _position = getPosASL _carriedItem;
|
|
|
|
private _maxHeight = (_unit modelToWorldVisualWorld [0, 0, 0]) select 2;
|
|
|
|
|
|
|
|
_position set [2, ((_position select 2) + _scrollAmount min (_maxHeight + 1.5)) max _maxHeight];
|
2015-03-18 00:36:56 +00:00
|
|
|
|
2023-07-23 23:07:37 +00:00
|
|
|
// Move up/down object and reattach at current position
|
2020-04-20 15:45:59 +00:00
|
|
|
detach _carriedItem;
|
2015-03-18 00:36:56 +00:00
|
|
|
|
2020-04-20 15:45:59 +00:00
|
|
|
// Uses this method of selecting position because setPosATL did not have immediate effect
|
|
|
|
private _positionChange = _position vectorDiff (getPosASL _carriedItem);
|
|
|
|
private _selectionPosition = _unit worldToModel (ASLtoAGL getPosWorld _carriedItem);
|
|
|
|
_selectionPosition = _selectionPosition vectorAdd _positionChange;
|
|
|
|
_carriedItem attachTo [_unit, _selectionPosition];
|
2017-06-04 17:46:49 +00:00
|
|
|
|
2023-07-23 23:07:37 +00:00
|
|
|
// Reset the carry direction
|
2020-04-20 15:45:59 +00:00
|
|
|
private _direction = _carriedItem getVariable [QGVAR(carryDirection_temp), _carriedItem getVariable [QGVAR(carryDirection), 0]];
|
|
|
|
[QEGVAR(common,setDir), [_carriedItem, _direction], _carriedItem] call CBA_fnc_targetEvent;
|
|
|
|
} else {
|
2023-07-23 23:07:37 +00:00
|
|
|
// Rotate
|
2020-04-20 15:45:59 +00:00
|
|
|
private _direction = _carriedItem getVariable [QGVAR(carryDirection_temp), _carriedItem getVariable [QGVAR(carryDirection), 0]];
|
|
|
|
_scrollAmount = _scrollAmount * 10;
|
|
|
|
_direction = _direction + _scrollAmount;
|
2023-07-23 23:07:37 +00:00
|
|
|
|
2020-04-20 15:45:59 +00:00
|
|
|
[QEGVAR(common,setDir), [_carriedItem, _direction], _carriedItem] call CBA_fnc_targetEvent;
|
|
|
|
_carriedItem setVariable [QGVAR(carryDirection_temp), _direction];
|
|
|
|
};
|
2016-03-02 00:49:41 +00:00
|
|
|
|
2015-03-18 00:36:56 +00:00
|
|
|
true
|