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 Interaction to take another players launcher #10541

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
8 changes: 8 additions & 0 deletions addons/interaction/CfgVehicles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ class CfgVehicles {
};
};

class ACE_TakeLauncher {
displayName = CSTRING(takeLauncher);
condition = QUOTE([ARR_3(_player,_target,(secondaryWeapon _target))] call FUNC(canTakeLauncher));
statement = QUOTE([ARR_3(_player,_target,(secondaryWeapon _target))] call FUNC(takeLauncher));
exceptions[] = {"isNotSwimming"};
showDisabled = 0;
};

class ACE_PassThrowable {
displayName = CSTRING(PassThrowable);
condition = QUOTE([ARR_3(_player,_target,(currentThrowable _player) param [ARR_2(0,'')])] call FUNC(canPassThrowable));
Expand Down
2 changes: 2 additions & 0 deletions addons/interaction/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ PREP(pullOutBody);
PREP(canRenameGroup);
PREP(renameGroupUI);
PREP(renameGroup);
PREP(canTakeLauncher);
PREP(takeLauncher);

// Weapon Attachments
PREP(getWeaponAttachmentsActions);
Expand Down
28 changes: 28 additions & 0 deletions addons/interaction/functions/fnc_canTakeLauncher.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "..\script_component.hpp"
/*
* Author: Timi007, Cplhardcore
* Checks if target unit can accept given launcher.
* Does not check if the launcher exists in the inventory of the player.
*
* Arguments:
* 0: Unit that passes the launcher <OBJECT>
* 1: Unit to pass the launcher to <OBJECT>
* 2: launcher classname <STRING>
Cplhardcore marked this conversation as resolved.
Show resolved Hide resolved
*
* Return Value:
* Unit can pass launcher <BOOL>
*
* Example:
* [_player, _target, "launch_NLAW_F"] call ace_interaction_fnc_canTakeLauncher
*
* Public: No
*/

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

if (!GVAR(enableLauncherTaking)) exitWith {false};
if (_launcher isEqualTo "") exitWith {false};
if ((!isNull objectParent _target) && {(vehicle _player) isNotEqualTo (vehicle _target)}) exitWith {false};
Cplhardcore marked this conversation as resolved.
Show resolved Hide resolved
private _hasLauncher = secondaryWeapon _player;
if (_hasLauncher != "") exitWith {false};
true
46 changes: 46 additions & 0 deletions addons/interaction/functions/fnc_takeLauncher.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include "..\script_component.hpp"
/*
* Author: Timi007. Cplhardcore
* Pass launcher to another unit.
*
* Arguments:
* 0: Unit that passes the launcher <OBJECT>
* 1: Unit to pass the launcher to <OBJECT>
* 2: launcher classname <STRING>
Cplhardcore marked this conversation as resolved.
Show resolved Hide resolved
* 3: Play passing animation <BOOL> (default: true)
*
* Return Value:
* None
*
* Example:
* [_player, _target, "launch_NLAW_F"] call ace_interaction_fnc_passLauncher
*
* Public: No
*/

params ["_player", "_target", "_launcher", ["_animate", true, [true]]];
TRACE_4("Pass launcher params",_player,_target,_launcher,_animate);

if (_launcher isEqualTo "") exitWith {ERROR("No launcher specified.")};
private _hasLauncher = secondaryWeapon _player;
if (_hasLauncher == "") exitWith {ERROR("Cannot add launcher to target due to lack of inventory space.")};
Cplhardcore marked this conversation as resolved.
Show resolved Hide resolved

private _CfgWeapons = configFile >> "CfgWeapons" >> _launcher;
Cplhardcore marked this conversation as resolved.
Show resolved Hide resolved
private _attachments = _target weaponAccessories _launcher;
private _launcherAmmo = (currentMagazine _unit) select {
_x in getArray (configFile >> "CfgWeapons" >> _launcherClassname >> "magazines")
};
johnb432 marked this conversation as resolved.
Show resolved Hide resolved
_target removeWeapon _launcher;
{
_unit removeMagazine _x;
} forEach _launcherAmmo;

_player addWeapon _launcher;
Cplhardcore marked this conversation as resolved.
Show resolved Hide resolved
{_player addSecondaryWeaponItem _x;} forEach _attachments;
{_unit addMagazine _x;} forEach _launcherAmmo;

if (_animate) then {[_player, "PutDown"] call EFUNC(common,doGesture)};

private _playerName = [_player] call EFUNC(common,getName);
private _displayName = getText (_cfgWeapons >> "displayName");
johnb432 marked this conversation as resolved.
Show resolved Hide resolved
[QEGVAR(common,displayTextStructured), [[LSTRING(PassLauncherHint), _playerName, _displayName], 1.5, _target], [_target]] call CBA_fnc_targetEvent;
7 changes: 7 additions & 0 deletions addons/interaction/initSettings.inc.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,10 @@
[[0, 1, 2], [ELSTRING(common,Never), LSTRING(interactWithEnemyCrew_allowCSW), ELSTRING(common,Always)], 0],
true
] call CBA_fnc_addSetting;

[
QGVAR(enableLauncherTaking), "CHECKBOX",
LSTRING(takeLauncherSetting),
format ["ACE %1", LLSTRING(DisplayName)],
true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Not a fan of the default value, imo it should be off.
  2. This should be a synced setting imo.

] call CBA_fnc_addSetting;
9 changes: 9 additions & 0 deletions addons/interaction/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1425,5 +1425,14 @@
<Japanese>インタラクションから使用中の武器に対してのアタッチメント取り外しを可能にします。</Japanese>
<Chinesesimp>启用当前武器的附加/拆卸武器配件的动作。</Chinesesimp>
</Key>
<Key ID="STR_ACE_Interaction_takeLauncher">
<English>Take Launcher</English>
</Key>
<Key ID="STR_ACE_Interaction_takeLauncherSetting">
<English>Allow people to take Launchers</English>
</Key>
<Key ID="STR_ACE_Interaction_PassLauncherHint">
<English>You took %1's %2</English>
</Key>
</Package>
</Project>
Loading