ACE3/addons/dragging/functions/fnc_dragObject.sqf
Dániel Boros 026b94903e Dragging - Add new dragging animations (#7950)
* New custom animation added

* Adjusted CfgMoves and the script components

* New drop animation and key handler

* CBA settings and new ManActions added

* Adjustments to the drop animation

* Added translations and fixed some stuff

* Update CfgMovesBasic.hpp

* Fix translations

Co-authored-by: Elgin675 <elgin675@hotmail.com>
Co-authored-by: Blutze <37950828+Blutze@users.noreply.github.com>

* Use the same key to drop object

* Update addons/dragging/stringtable.xml

Co-authored-by: Jo David <github@jonathandavid.de>

* Fix French translation

Co-authored-by: Elgin675 <elgin675@hotmail.com>

* Lower the weapon accuracy of the drag animations

* Removed auto-switch to handgun

* Update fnc_startDrag.sqf

 - Holding a launcher breaks the firing animation.
 - Now the unit has to hold either a primary weapon or handgun.

* Handle the unit's current weapon

Co-authored-by: BaerMitUmlaut <BaerMitUmlaut@users.noreply.github.com>

* Update addons/dragging/functions/fnc_handlePlayerWeaponChanged.sqf

Co-authored-by: Filip Maciejewski <veteran29@users.noreply.github.com>

* Update addons/dragging/initSettings.sqf

Co-authored-by: Elgin675 <elgin675@hotmail.com>
Co-authored-by: Blutze <37950828+Blutze@users.noreply.github.com>
Co-authored-by: Jo David <github@jonathandavid.de>
Co-authored-by: BaerMitUmlaut <BaerMitUmlaut@users.noreply.github.com>
Co-authored-by: Filip Maciejewski <veteran29@users.noreply.github.com>
Co-authored-by: jonpas <jonpas33@gmail.com>
2021-05-23 16:38:43 -05:00

83 lines
2.4 KiB
Plaintext

#include "script_component.hpp"
/*
* Author: commy2, Malbryn
* Drag an object. Called from ace_dragging_fnc_startDrag
*
* Arguments:
* 0: Unit that should do the dragging <OBJECT>
* 1: Object to drag <OBJECT>
*
* Return Value:
* None
*
* Example:
* [player, cursorTarget] call ace_dragging_fnc_dragObject;
*
* Public: No
*/
params ["_unit", "_target"];
TRACE_2("params",_unit,_target);
// get attachTo offset and direction.
private _position = _target getVariable [QGVAR(dragPosition), [0, 0, 0]];
private _direction = _target getVariable [QGVAR(dragDirection), 0];
// add height offset of model
private _offset = (_target modelToWorldVisual [0, 0, 0] select 2) - (_unit modelToWorldVisual [0, 0, 0] select 2);
if (_target isKindOf "CAManBase") then {
_offset = 0;
};
_position = _position vectorAdd [0, 0, _offset];
// attach object
TRACE_3("attaching",_position,_offset,_direction);
_target attachTo [_unit, _position];
[QEGVAR(common,setDir), [_target, _direction], _target] call CBA_fnc_targetEvent;
if (_target isKindOf "CAManBase") then {
[_target, "AinjPpneMrunSnonWnonDb_still", 0, true] call EFUNC(common,doAnimation);
};
_unit setVariable [QGVAR(isDragging), true, true];
_unit setVariable [QGVAR(draggedObject), _target, true];
// add drop action
GVAR(unit) = _unit;
GVAR(releaseActionID) = [0xF1, [false, false, false], {
[GVAR(unit), GVAR(unit) getVariable [QGVAR(draggedObject), objNull]] call FUNC(dropObject);
}, "keydown", "", false, 0] call CBA_fnc_addKeyHandler;
// show mouse hint
["", localize LSTRING(Drop)] call EFUNC(interaction,showMouseHint);
// block firing
if !(GVAR(dragAndFire)) then {
_unit setVariable [QGVAR(blockFire), [
_unit, "DefaultAction",
{true},
{}
] call EFUNC(common,addActionEventHandler)];
};
// add anim changed EH
[_unit, "AnimChanged", FUNC(handleAnimChanged), [_unit]] call CBA_fnc_addBISEventHandler;
// check everything
[FUNC(dragObjectPFH), 0.5, [_unit, _target, CBA_missionTime]] call CBA_fnc_addPerFrameHandler;
// reset current dragging height.
GVAR(currentHeightChange) = 0;
// prevent UAVs from firing
private _UAVCrew = _target call EFUNC(common,getVehicleUAVCrew);
// fixes not being able to move when in combat pace
[_unit, "forceWalk", "ACE_dragging", true] call EFUNC(common,statusEffect_set);
if (_UAVCrew isNotEqualTo []) then {
{_target deleteVehicleCrew _x} count _UAVCrew;
_target setVariable [QGVAR(isUAV), true, true];
};