mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Dragging - Improve featureCamera
handling (#9389)
* Update XEH_postInit.sqf * Update XEH_postInit.sqf * Update XEH_postInit.sqf * Different approach * Updated to new script_component * fix variable lookup --------- Co-authored-by: LinkIsGrim <salluci.lovi@gmail.com>
This commit is contained in:
parent
37be6130f2
commit
11664b0040
@ -19,6 +19,10 @@ PREP(handleUnconscious);
|
|||||||
PREP(initObject);
|
PREP(initObject);
|
||||||
PREP(initPerson);
|
PREP(initPerson);
|
||||||
PREP(isObjectOnObject);
|
PREP(isObjectOnObject);
|
||||||
|
PREP(pauseCarry);
|
||||||
|
PREP(pauseDrag);
|
||||||
|
PREP(resumeCarry);
|
||||||
|
PREP(resumeDrag);
|
||||||
PREP(setCarryable);
|
PREP(setCarryable);
|
||||||
PREP(setDraggable);
|
PREP(setDraggable);
|
||||||
PREP(startCarry);
|
PREP(startCarry);
|
||||||
|
@ -81,4 +81,27 @@ if (isNil QGVAR(maxWeightCarryRun)) then {
|
|||||||
};
|
};
|
||||||
}] call CBA_fnc_addEventHandler;
|
}] call CBA_fnc_addEventHandler;
|
||||||
|
|
||||||
|
// When changing cameras, drop carried and dragged objects
|
||||||
|
["featureCamera", {
|
||||||
|
params ["_unit", "_camera"];
|
||||||
|
|
||||||
|
// Unit can either drag or carry, functions themselves handle which ones are executed
|
||||||
|
switch (_camera) do {
|
||||||
|
// Default camera
|
||||||
|
case "": {
|
||||||
|
_unit call FUNC(resumeDrag);
|
||||||
|
_unit call FUNC(resumeCarry);
|
||||||
|
};
|
||||||
|
// Arsenals make the unit change animations, which makes the unit drop dragged/carried objects regardless
|
||||||
|
case "arsenal";
|
||||||
|
case "ace_arsenal": {
|
||||||
|
_unit call FUNC(handleKilled);
|
||||||
|
};
|
||||||
|
default {
|
||||||
|
_unit call FUNC(pauseDrag);
|
||||||
|
_unit call FUNC(pauseCarry);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}] call CBA_fnc_addPlayerEventHandler;
|
||||||
|
|
||||||
#include "initKeybinds.sqf"
|
#include "initKeybinds.sqf"
|
||||||
|
@ -53,6 +53,11 @@ if !(alive _target && {_unit distance _target <= 10} && {_unit getHitPointDamage
|
|||||||
_idPFH call CBA_fnc_removePerFrameHandler;
|
_idPFH call CBA_fnc_removePerFrameHandler;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private _previousHint = _unit getVariable [QGVAR(hint), []];
|
||||||
|
|
||||||
|
// If paused, don't show mouse button hints
|
||||||
|
if (_previousHint isEqualType "") exitWith {};
|
||||||
|
|
||||||
// Mouse hint
|
// Mouse hint
|
||||||
private _hintLMB = LLSTRING(Drop);
|
private _hintLMB = LLSTRING(Drop);
|
||||||
getCursorObjectParams params ["_cursorObject", "", "_distance"];
|
getCursorObjectParams params ["_cursorObject", "", "_distance"];
|
||||||
@ -81,7 +86,7 @@ if (_target isKindOf "CAManBase") then {
|
|||||||
|
|
||||||
private _hint = [_hintLMB, "", _hintMMB];
|
private _hint = [_hintLMB, "", _hintMMB];
|
||||||
|
|
||||||
if (_hint isNotEqualTo (_unit getVariable [QGVAR(hint), []])) then {
|
if (_hint isNotEqualTo _previousHint) then {
|
||||||
_unit setVariable [QGVAR(hint), _hint];
|
_unit setVariable [QGVAR(hint), _hint];
|
||||||
_hint call EFUNC(interaction,showMouseHint);
|
_hint call EFUNC(interaction,showMouseHint);
|
||||||
};
|
};
|
||||||
|
@ -20,7 +20,10 @@ params ["_unit", "_target"];
|
|||||||
TRACE_2("params",_unit,_target);
|
TRACE_2("params",_unit,_target);
|
||||||
|
|
||||||
// Remove drop action
|
// Remove drop action
|
||||||
[GVAR(releaseActionID), "keydown"] call CBA_fnc_removeKeyHandler;
|
if (!isNil QGVAR(releaseActionID)) then {
|
||||||
|
[GVAR(releaseActionID), "keydown"] call CBA_fnc_removeKeyHandler;
|
||||||
|
GVAR(releaseActionID) = nil;
|
||||||
|
};
|
||||||
|
|
||||||
// Stop blocking
|
// Stop blocking
|
||||||
if !(GVAR(dragAndFire)) then {
|
if !(GVAR(dragAndFire)) then {
|
||||||
|
@ -22,6 +22,7 @@ TRACE_1("params",_this);
|
|||||||
|
|
||||||
// Remove drop action
|
// Remove drop action
|
||||||
[_unit, "DefaultAction", _unit getVariable [QGVAR(releaseActionID), -1]] call EFUNC(common,removeActionEventHandler);
|
[_unit, "DefaultAction", _unit getVariable [QGVAR(releaseActionID), -1]] call EFUNC(common,removeActionEventHandler);
|
||||||
|
_unit setVariable [QGVAR(releaseActionID), nil];
|
||||||
|
|
||||||
private _inBuilding = _unit call FUNC(isObjectOnObject);
|
private _inBuilding = _unit call FUNC(isObjectOnObject);
|
||||||
|
|
||||||
|
34
addons/dragging/functions/fnc_pauseCarry.sqf
Normal file
34
addons/dragging/functions/fnc_pauseCarry.sqf
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#include "..\script_component.hpp"
|
||||||
|
/*
|
||||||
|
* Author: johnb43
|
||||||
|
* Removes user input affecting dragging.
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* 0: Unit <OBJECT>
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* player call ace_dragging_fnc_pauseCarry;
|
||||||
|
*
|
||||||
|
* Public: No
|
||||||
|
*/
|
||||||
|
|
||||||
|
params ["_unit"];
|
||||||
|
|
||||||
|
// If not carrying, don't do anything
|
||||||
|
if !(_unit getVariable [QGVAR(isCarrying), false]) exitWith {};
|
||||||
|
|
||||||
|
private _actionID = _unit getVariable QGVAR(releaseActionID);
|
||||||
|
|
||||||
|
// If action has already been removed, don't remove it again
|
||||||
|
if (isNil "_actionID") exitWith {};
|
||||||
|
|
||||||
|
// Remove drop action
|
||||||
|
[_unit, "DefaultAction", _actionID] call EFUNC(common,removeActionEventHandler);
|
||||||
|
_unit setVariable [QGVAR(releaseActionID), nil];
|
||||||
|
|
||||||
|
// Hide mouse hint
|
||||||
|
_unit setVariable [QGVAR(hint), "paused"];
|
||||||
|
call EFUNC(interaction,hideMouseHint);
|
31
addons/dragging/functions/fnc_pauseDrag.sqf
Normal file
31
addons/dragging/functions/fnc_pauseDrag.sqf
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#include "..\script_component.hpp"
|
||||||
|
/*
|
||||||
|
* Author: johnb43
|
||||||
|
* Removes user input affecting dragging.
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* 0: Unit <OBJECT>
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* player call ace_dragging_fnc_pauseDrag;
|
||||||
|
*
|
||||||
|
* Public: No
|
||||||
|
*/
|
||||||
|
|
||||||
|
params ["_unit"];
|
||||||
|
|
||||||
|
// If not dragging, don't do anything
|
||||||
|
if !(_unit getVariable [QGVAR(isDragging), false]) exitWith {};
|
||||||
|
|
||||||
|
// If action has already been removed, don't remove it again
|
||||||
|
if (isNil QGVAR(releaseActionID)) exitWith {};
|
||||||
|
|
||||||
|
// Remove drop action
|
||||||
|
[GVAR(releaseActionID), "keydown"] call CBA_fnc_removeKeyHandler;
|
||||||
|
GVAR(releaseActionID) = nil;
|
||||||
|
|
||||||
|
// Hide mouse hint
|
||||||
|
call EFUNC(interaction,hideMouseHint);
|
34
addons/dragging/functions/fnc_resumeCarry.sqf
Normal file
34
addons/dragging/functions/fnc_resumeCarry.sqf
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#include "..\script_component.hpp"
|
||||||
|
/*
|
||||||
|
* Author: johnb43
|
||||||
|
* Adds user input affecting carrying back.
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* 0: Unit <OBJECT>
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* player call ace_dragging_fnc_resumeCarry;
|
||||||
|
*
|
||||||
|
* Public: No
|
||||||
|
*/
|
||||||
|
|
||||||
|
params ["_unit"];
|
||||||
|
|
||||||
|
// If not dragging, don't do anything
|
||||||
|
if !(_unit getVariable [QGVAR(isCarrying), false]) exitWith {};
|
||||||
|
|
||||||
|
// If action is already present, don't add it again
|
||||||
|
if (!isNil {_unit getVariable QGVAR(releaseActionID)}) exitWith {};
|
||||||
|
|
||||||
|
// Remove drop action
|
||||||
|
_unit setVariable [QGVAR(releaseActionID), [
|
||||||
|
_unit, "DefaultAction",
|
||||||
|
{!isNull ((_this select 0) getVariable [QGVAR(carriedObject), objNull])},
|
||||||
|
{[_this select 0, (_this select 0) getVariable [QGVAR(carriedObject), objNull], true] call FUNC(dropObject_carry)}
|
||||||
|
] call EFUNC(common,addActionEventHandler)];
|
||||||
|
|
||||||
|
// Show mouse hint (done in FUNC(carryObjectPFH))
|
||||||
|
_unit setVariable [QGVAR(hint), nil];
|
32
addons/dragging/functions/fnc_resumeDrag.sqf
Normal file
32
addons/dragging/functions/fnc_resumeDrag.sqf
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#include "..\script_component.hpp"
|
||||||
|
/*
|
||||||
|
* Author: johnb43
|
||||||
|
* Adds user input affecting dragging back.
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* 0: Unit <OBJECT>
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* player call ace_dragging_fnc_resumeDrag;
|
||||||
|
*
|
||||||
|
* Public: No
|
||||||
|
*/
|
||||||
|
|
||||||
|
params ["_unit"];
|
||||||
|
|
||||||
|
// If not dragging, don't do anything
|
||||||
|
if !(_unit getVariable [QGVAR(isDragging), false]) exitWith {};
|
||||||
|
|
||||||
|
// If action is already present, don't add it again
|
||||||
|
if (!isNil QGVAR(releaseActionID)) exitWith {};
|
||||||
|
|
||||||
|
// Add drop action
|
||||||
|
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
|
||||||
|
["", LLSTRING(Drop)] call EFUNC(interaction,showMouseHint);
|
Loading…
Reference in New Issue
Block a user