Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interaction - Add "open backpack" action #10525

Merged
merged 19 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = 1.50;
DartRuffian marked this conversation as resolved.
Show resolved Hide resolved
condition = QUOTE([ARR_2(_player,_target)] call DFUNC(canOpenBackpack));
statement = QUOTE([ARR_2(_player,_target)] call DFUNC(openBackpack));
modifierFunction = QUOTE(call FUNC(modifyOpenBackpackAction));
exceptions[] = {"isNotSwimming"};
};
};

class ACE_SelfActions {
Expand Down
4 changes: 4 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,9 @@ PREP(canInteractWithCivilian);
PREP(canInteractWithVehicleCrew);
PREP(getDown);
PREP(sendAway);
PREP(canOpenBackpack);
PREP(openBackpack);
PREP(modifyOpenBackpackAction);
PREP(canJoinGroup);
PREP(modifyJoinGroupAction);
PREP(modifyTeamManagementAction);
Expand Down
27 changes: 27 additions & 0 deletions addons/interaction/functions/fnc_canOpenBackpack.sqf
johnb432 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#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 ["_player", "_target"];

private _backpackContainer = backpackContainer _target;

!isNull _backpackContainer &&
{!lockedInventory _backpackContainer} &&
{maxLoad _backpackContainer > 0} &&
{getNumber (configOf _backpackContainer >> "disableInventory") != 1} &&
{!(_target isKindOf QEGVAR(dragging,clone))}
johnb432 marked this conversation as resolved.
Show resolved Hide resolved
22 changes: 22 additions & 0 deletions addons/interaction/functions/fnc_getBackpackPos.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#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", "Memory"];
_position = _position vectorAdd [0, -0.2, 0.05];
DartRuffian marked this conversation as resolved.
Show resolved Hide resolved
_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];
21 changes: 21 additions & 0 deletions addons/interaction/functions/fnc_openBackpack.sqf
DartRuffian marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include "..\script_component.hpp"
/*
* Author: DartRuffian
* Opens a unit's backpack.
*
* Arguments:
* 0: Target <OBJECT>
* 1: Player <OBJECT>
*
* Return Value:
* None
*
* Example:
* [cursorObject, player] call ace_interaction_fnc_openBackpack
*
* Public: No
*/

params ["_player", "_target"];

_player action ["OpenBag", _target];