-
Notifications
You must be signed in to change notification settings - Fork 740
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
Cplhardcore
wants to merge
14
commits into
acemod:master
Choose a base branch
from
Cplhardcore:AT-Grab
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+133
−0
Open
Changes from 6 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
252332f
Initial
Cplhardcore b99c2d0
Delete fnc_passLauncher.sqf
Cplhardcore ddbe7f8
weee
Cplhardcore 5ce2e39
rework
Cplhardcore 0305f3f
Update fnc_takeLauncher.sqf
Cplhardcore a8c251a
Update fnc_takeLauncher.sqf
Cplhardcore 4d878a3
Update addons/interaction/functions/fnc_takeLauncher.sqf
Cplhardcore ec26dc6
Tabs to spaces
Cplhardcore 035a886
Update fnc_takeLauncher.sqf
Cplhardcore d4cf48c
Update addons/interaction/functions/fnc_takeLauncher.sqf
Cplhardcore 4a24432
Update addons/interaction/initSettings.inc.sqf
Cplhardcore 8a49044
Update addons/interaction/functions/fnc_takeLauncher.sqf
Cplhardcore 83ec64e
Update addons/interaction/functions/fnc_takeLauncher.sqf
Cplhardcore 32b594a
Update addons/interaction/initSettings.inc.sqf
Cplhardcore File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
* | ||
* Return Value: | ||
* Unit can pass launcher <BOOL> | ||
* | ||
* Example: | ||
* [_player, _target, "launch_NLAW_F"] call ace_interaction_fnc_canTakeLauncher | ||
* | ||
* Public: No | ||
*/ | ||
|
||
params ["_player", "_target"]; | ||
if (GVAR(enableLauncherTaking) && | ||
secondaryWeapon _target != "" && | ||
secondaryWeapon _player == "" && | ||
isNull objectParent _target && | ||
isNull objectParent _player && | ||
side _target == side _player) exitWith {true}; | ||
false | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#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> | ||
* | ||
* | ||
* Return Value: | ||
* None | ||
* | ||
* Example: | ||
* [_player, _target, "launch_NLAW_F"] call ace_interaction_fnc_passLauncher | ||
* | ||
* Public: No | ||
*/ | ||
params ["_player", "_target", "_launcher"]; | ||
TRACE_3("Take launcher params",_player,_target,_launcher); | ||
|
||
private _playerName = [_player] call EFUNC(common,getName); | ||
private _cfgWeapons = configFile >> "CfgWeapons" >> _launcher; | ||
private _displayName = getText (_cfgWeapons >> "displayName"); | ||
[QEGVAR(common,displayTextStructured), [[LSTRING(TakingLauncherHint), _playerName, _displayName], 1.5, _target], [_target]] call CBA_fnc_targetEvent; | ||
Cplhardcore marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if (_launcher isEqualTo "") exitWith {ERROR("No launcher specified.")}; | ||
if (secondaryWeapon _player != "") exitWith {ERROR("Cannot add launcher to target due to lack of inventory space.")}; | ||
Cplhardcore marked this conversation as resolved.
Show resolved
Hide resolved
|
||
[_player, _target, 0] call FUNC(tapShoulder); | ||
[GVAR(LauncherTime), | ||
[_player, _target, _launcher, _displayName], | ||
{ | ||
params ["_args"]; | ||
_args params ["_player", "_target", "_launcher", "_displayName"]; | ||
TRACE_4("launcher params",_player,_target,_launcher,_displayName); | ||
fn_getWeaponStates = | ||
{ | ||
params ["_target", "_launcher"]; | ||
private _origState = weaponState _target select [0,3]; | ||
private _muzzles = [_launcher] + (getArray (configFile >> "CfgWeapons" >> _launcher >> "muzzles") select { _x != "this" }); | ||
private _states = []; | ||
|
||
{ | ||
_target selectWeapon _x; | ||
_states pushBack weaponState _target; | ||
} forEach _muzzles; | ||
|
||
_target selectWeapon _origState; | ||
_states; | ||
}; | ||
|
||
|
||
private _result = [_target, _launcher] call fn_getWeaponStates; | ||
private _attachments = _target weaponAccessories _launcher; | ||
private _launcherAmmo = _result apply { _x select 3 }; | ||
private _launcherAmmoCount = _result apply { _x select 4 }; | ||
private _launcherMuzzle = _result apply { _x select 1 }; | ||
[_player, _launcher] call CBA_fnc_addWeaponWithoutItems; | ||
{_player addSecondaryWeaponItem _x;} forEach _attachments; | ||
for "_i" from 0 to (count _launcherMuzzle - 1) do { | ||
private _muzzle = _launcherMuzzle select _i; | ||
private _ammo = _launcherAmmo select _i; | ||
private _count = _launcherAmmoCount select _i; | ||
_player addWeaponItem [_launcher, [_ammo, _count, _muzzle]]; | ||
|
||
}; | ||
|
||
{_player addWeaponItem [_launcher, [_launcherAmmo, _launcherAmmoCount, _launcherMuzzle], true];} forEach _result; | ||
_target removeWeapon _launcher; | ||
[_player, "PutDown"] call EFUNC(common,doGesture); | ||
|
||
private _playerName = [_player] call EFUNC(common,getName); | ||
private _targetName = [_target] call EFUNC(common,getName); | ||
[QEGVAR(common,displayTextStructured), [[LSTRING(GaveLauncherHint), _playerName, _displayName], 1.5, _target], [_target]] call CBA_fnc_targetEvent; | ||
[QEGVAR(common,displayTextStructured), [[LSTRING(TookLauncherHint), _targetName, _displayName], 1.5, _player], [_player]] call CBA_fnc_targetEvent; | ||
Cplhardcore marked this conversation as resolved.
Show resolved
Hide resolved
|
||
[_player, _target, 0] call FUNC(tapShoulder); | ||
}, | ||
{}, LLSTRING(PassingLauncher)] call EFUNC(common,progressBar); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,3 +78,19 @@ | |
[[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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
] call CBA_fnc_addSetting; | ||
|
||
[ | ||
QGVAR(launcherTime), | ||
"SLIDER", | ||
Cplhardcore marked this conversation as resolved.
Show resolved
Hide resolved
|
||
LSTRING(takeLauncherTime), | ||
format ["ACE %1", LLSTRING(DisplayName)], | ||
[1, 20, 5, 0], | ||
true | ||
Cplhardcore marked this conversation as resolved.
Show resolved
Hide resolved
|
||
] call CBA_fnc_addSetting; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd personally also wrap every single statement in a lazy eval, but I haven't tested the performance impact.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this would work when the target is unconscious, as
side
changes. Imo would be better to check if the sides have friendly relations (using the sides of the group).