Dragging - Improve carrying by allowing carried object to be loaded into vehicle by key or mouse (#9138)

* load carried object

* check for medical loaded

* space

Co-authored-by: Jouni Järvinen <rautamiekka@users.noreply.github.com>

* consolidate mouse hint in pfh

---------

Co-authored-by: Jouni Järvinen <rautamiekka@users.noreply.github.com>
This commit is contained in:
Ampersand 2023-06-23 08:11:16 -04:00 committed by GitHub
parent b75d20634b
commit e5654914cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 57 additions and 14 deletions

View File

@ -65,7 +65,7 @@ if (isNil "ACE_maxWeightCarry") then {
false
};
if (ACE_player getVariable [QGVAR(isCarrying), false]) exitWith {
[ACE_player, ACE_player getVariable [QGVAR(carriedObject), objNull]] call FUNC(dropObject_carry);
[ACE_player, ACE_player getVariable [QGVAR(carriedObject), objNull], true] call FUNC(dropObject_carry);
false
};

View File

@ -53,19 +53,12 @@ _unit setVariable [QGVAR(carriedObject), _target, true];
_unit setVariable [QGVAR(ReleaseActionID), [
_unit, "DefaultAction",
{!isNull ((_this select 0) getVariable [QGVAR(carriedObject), objNull])},
{[_this select 0, (_this select 0) getVariable [QGVAR(carriedObject), objNull]] call FUNC(dropObject_carry)}
{[_this select 0, (_this select 0) getVariable [QGVAR(carriedObject), objNull], true] call FUNC(dropObject_carry)}
] call EFUNC(common,addActionEventHandler)];
// add anim changed EH
[_unit, "AnimChanged", FUNC(handleAnimChanged), [_unit]] call CBA_fnc_addBISEventHandler;
// show mouse hint
if (_target isKindOf "CAManBase") then {
[localize LSTRING(Drop), "", ""] call EFUNC(interaction,showMouseHint);
} else {
[localize LSTRING(Drop), "", localize LSTRING(RaiseLowerRotate)] call EFUNC(interaction,showMouseHint);
};
// check everything
[FUNC(carryObjectPFH), 0.5, [_unit, _target, CBA_missionTime]] call CBA_fnc_addPerFrameHandler;

View File

@ -28,11 +28,13 @@ _args params ["_unit", "_target", "_startTime"];
if !(_unit getVariable [QGVAR(isCarrying), false]) exitWith {
TRACE_2("carry false",_unit,_target);
_unit setVariable [QGVAR(hint), nil];
[] call EFUNC(interaction,hideMouseHint);
[_idPFH] call CBA_fnc_removePerFrameHandler;
};
// drop if the crate is destroyed OR (target moved away from carrier (weapon disasembled))
if (!alive _target || {_unit distance _target > 10}) then {
if (!alive _target || {_unit distance _target > 10}) exitWith {
TRACE_2("dead/distance",_unit,_target);
if ((_unit distance _target > 10) && {(CBA_missionTime - _startTime) < 1}) exitWith {
//attachTo seems to have some kind of network delay and target can return an odd position during the first few frames,
@ -40,5 +42,36 @@ if (!alive _target || {_unit distance _target > 10}) then {
TRACE_3("ignoring bad distance at start",_unit distance _target,_startTime,CBA_missionTime);
};
[_unit, _target] call FUNC(dropObject_carry);
_unit setVariable [QGVAR(hint), nil];
[] call EFUNC(interaction,hideMouseHint);
[_idPFH] call CBA_fnc_removePerFrameHandler;
};
// Mouse hint
private _hintLMB = localize LSTRING(Drop);
getCursorObjectParams params ["_cursorObject", "", "_distance"];
if (
!isNull _cursorObject
&& {_distance < MAX_LOAD_DISTANCE}
&& {([_unit, _cursorObject, ["isNotCarrying"]] call EFUNC(common,canInteractWith))}
&& {
if (_target isKindOf "CAManBase") then {
[_cursorObject, 0, true] call EFUNC(common,nearestVehiclesFreeSeat) isNotEqualTo []
} else {
[_target, _cursorObject] call EFUNC(cargo,canLoadItemIn)
}
}
) then {
_hintLMB = localize ELSTRING(Cargo,loadObject);
};
private _hintMMB = localize LSTRING(RaiseLowerRotate);
if (_target isKindOf "CAManBase") then {
_hintMMB = "";
};
private _hint = [_hintLMB, "", _hintMMB];
if (_hint isNotEqualTo (_unit getVariable [QGVAR(hint), []])) then {
_unit setVariable [QGVAR(hint), _hint];
_hint call EFUNC(interaction,showMouseHint);
};

View File

@ -16,7 +16,7 @@
* Public: No
*/
params ["_unit", "_target"];
params ["_unit", "_target", ["_tryLoad", false]];
TRACE_1("params",_this);
// remove drop action
@ -63,9 +63,6 @@ if (_inBuilding) then {
_target setPosASL (getPosASL _target vectorAdd [0, 0, 0.05]);
};
// hide mouse hint
[] call EFUNC(interaction,hideMouseHint);
_unit setVariable [QGVAR(isCarrying), false, true];
_unit setVariable [QGVAR(carriedObject), objNull, true];
@ -91,3 +88,21 @@ if (_mass != 0) then {
// reset temp direction
_target setVariable [QGVAR(carryDirection_temp), nil];
// try loading into vehicle
if (_tryLoad && {!isNull cursorObject} && {([ACE_player, cursorObject, []] call EFUNC(common,canInteractWith))}) then {
if (_target isKindOf "CAManBase") then {
private _vehicles = [cursorObject, 0, true] call EFUNC(common,nearestVehiclesFreeSeat);
if ([cursorObject] isEqualTo _vehicles) then {
if (["ACE_Medical"] call EFUNC(common,isModLoaded)) then {
[_unit, _target, cursorObject] call EFUNC(medical_treatment,loadUnit);
} else {
[_unit, _target, cursorObject] call EFUNC(common,loadPerson);
};
};
} else {
if ([_target, cursorObject] call EFUNC(cargo,canLoadItemIn)) then {
[player, _target, cursorObject] call EFUNC(cargo,startLoadIn);
};
};
};

View File

@ -16,5 +16,7 @@
#include "\z\ace\addons\main\script_macros.hpp"
#define MAX_LOAD_DISTANCE 5
#define DRAG_ANIMATIONS ["amovpercmstpslowwrfldnon_acinpknlmwlkslowwrfldb_2", "amovpercmstpsraswpstdnon_acinpknlmwlksnonwpstdb_2", "amovpercmstpsnonwnondnon_acinpknlmwlksnonwnondb_2", "acinpknlmstpsraswrfldnon", "acinpknlmstpsnonwpstdnon", "acinpknlmstpsnonwnondnon", "acinpknlmwlksraswrfldb", "acinpknlmwlksnonwnondb", "ace_dragging", "ace_dragging_static", "ace_dragging_drop"]
#define CARRY_ANIMATIONS ["acinpercmstpsnonwnondnon", "acinpknlmstpsnonwnondnon_acinpercmrunsnonwnondnon"]