Skip to content

Commit

Permalink
Interaction - Add open backpack action (#10525)
Browse files Browse the repository at this point in the history
Co-authored-by: PabstMirror <[email protected]>
Co-authored-by: johnb432 <[email protected]>
  • Loading branch information
3 people authored Dec 13, 2024
1 parent f6a38c4 commit 7aeb6b5
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 0 deletions.
9 changes: 9 additions & 0 deletions addons/interaction/CfgVehicles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,15 @@ class CfgVehicles {
statement = QUOTE([ARR_3(_player,_target,1)] call DFUNC(tapShoulder));
exceptions[] = {"isNotSwimming"};
};
class ACE_OpenBackpack {
displayName = "$STR_ACTION_OPEN_BAG";
position = QUOTE(call DFUNC(getBackpackPos));
distance = 3.0;
condition = QUOTE(call DFUNC(canOpenBackpack));
statement = QUOTE(_player action [ARR_2('OpenBag',_target)]);
modifierFunction = QUOTE(call FUNC(modifyOpenBackpackAction));
exceptions[] = {"isNotSwimming"};
};
};

class ACE_SelfActions {
Expand Down
3 changes: 3 additions & 0 deletions addons/interaction/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// interaction menu
PREP(addPassengerActions);
PREP(addPassengersActions);
PREP(getBackpackPos);
PREP(getInteractionDistance);
PREP(getVehiclePos);
PREP(getVehiclePosComplex);
Expand All @@ -18,6 +19,8 @@ PREP(canInteractWithCivilian);
PREP(canInteractWithVehicleCrew);
PREP(getDown);
PREP(sendAway);
PREP(canOpenBackpack);
PREP(modifyOpenBackpackAction);
PREP(canJoinGroup);
PREP(modifyJoinGroupAction);
PREP(modifyTeamManagementAction);
Expand Down
26 changes: 26 additions & 0 deletions addons/interaction/functions/fnc_canOpenBackpack.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include "..\script_component.hpp"
/*
* Author: DartRuffian
* Checks if the player can open a unit's backpack.
*
* Arguments:
* 0: Target <OBJECT>
* 1: Player <OBJECT>
*
* Return Value:
* None
*
* Example:
* [cursorObject, player] call ace_interaction_fnc_canOpenBackpack
*
* Public: No
*/

params ["_target", "_player"];

private _backpackContainer = backpackContainer _target;

!isNull _backpackContainer &&
{!lockedInventory _backpackContainer} &&
{maxLoad _backpackContainer > 0} &&
{getNumber (configOf _backpackContainer >> "disableInventory") != 1}
21 changes: 21 additions & 0 deletions addons/interaction/functions/fnc_getBackpackPos.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include "..\script_component.hpp"
/*
* Author: DartRuffian
* Return a suitable position for the action point for the target's backpack.
*
* Arguments:
* None (uses local variable _target)
*
* Return Value:
* Position of _target's backpack in model space <ARRAY>
*
* Example:
* call ace_interaction_fnc_getBackpackPos
*
* Public: No
*/

//IGNORE_PRIVATE_WARNING ["_target"];

private _position = _target selectionPosition "spine3";
(((_target selectionPosition "rightshoulder" vectorDiff _position) vectorCrossProduct (_target selectionPosition "leftshoulder" vectorDiff _position)) vectorMultiply 4) vectorAdd _position;
27 changes: 27 additions & 0 deletions addons/interaction/functions/fnc_modifyOpenBackpackAction.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include "..\script_component.hpp"
/*
* Author: DartRuffian
* Modifies the ACE_OpenBackpack action to show backpack name.
*
* Arguments:
* 0: Target <OBJECT>
* 1: Player <OBJECT>
* 2: Args <ANY>
* 3: Action Data <ARRAY>
*
* Return Value:
* None
*
* Example:
* [cursorObject, player, [], []] call ace_interaction_fnc_modifyOpenBackpackAction
*
* Public: No
*/

params ["_target", "_player", "", "_actionData"];

private _backpack = backpackContainer _target;
private _actionText = format [localize "STR_ACTION_OPEN_BAG", getText (configOf _backpack >> "displayName")];
TRACE_3("",_target,_backpack,_actionText);

_actionData set [1, _actionText];

0 comments on commit 7aeb6b5

Please sign in to comment.