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

Dragging - Improve weapon reselect behaviour #9052

Merged
merged 2 commits into from
Feb 14, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions addons/common/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ PREP(getDefaultAnim);
PREP(getDefinedVariable);
PREP(getDefinedVariableDefault);
PREP(getDefinedVariableInfo);
PREP(getFiremodeIndex);
PREP(getFirstObjectIntersection);
PREP(getFirstTerrainIntersection);
PREP(getGunner);
Expand Down
31 changes: 31 additions & 0 deletions addons/common/functions/fnc_getFiremodeIndex.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include "script_component.hpp"
/*
* Author: PabstMirror
* Get the firemode index of the weapon for use with "SwitchWeapon"
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Muzzle <STRING> (Optional)
* 2: Firemode <STRING> (Optional)
*
* Return Value:
* Weapon/Mode index <NUMBER>
*
* Example:
* [player] call ace_common_fnc_getFiremodeIndex
*
* Public: Yes
*/

params ["_unit"];
(weaponState _unit) params ["", "_currentMuzzle", "_currentFiremode"];
params ["", ["_muzzle", _currentMuzzle], ["_firemode", _currentFireMode]];

private _weapons = _unit weaponsInfo [_muzzle, false];
private _index = -1;
{
_x params ["_xIndex", "", "", "", "_xFiremode"];
if (_xFiremode == _firemode) exitWith { _index = _xIndex; };
} forEach _weapons;

_index
7 changes: 6 additions & 1 deletion addons/dragging/functions/fnc_dropObject_carry.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,12 @@ if (_target isKindOf "CAManBase" || {animationState _unit in CARRY_ANIMATIONS})
_unit removeWeapon "ACE_FakePrimaryWeapon";

// reselect weapon and re-enable sprint
_unit selectWeapon primaryWeapon _unit;
private _previousWeaponIndex = _unit getVariable [QGVAR(previousWeapon), -1];
_unit setVariable [QGVAR(previousWeapon), nil, true];

if (_previousWeaponIndex != -1) then {
_unit action ["SwitchWeapon", _unit, _unit, _previousWeaponIndex];
};
PabstMirror marked this conversation as resolved.
Show resolved Hide resolved

[_unit, "forceWalk", "ACE_dragging", false] call EFUNC(common,statusEffect_set);
[_unit, "blockThrow", "ACE_dragging", false] call EFUNC(common,statusEffect_set);
Expand Down
4 changes: 2 additions & 2 deletions addons/dragging/functions/fnc_startCarry.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ if (_target isKindOf "CAManBase") then {
_timer = CBA_missionTime + 10;

} else {

// select no weapon and stop sprinting
private _previousWeaponIndex = [_unit] call EFUNC(common,getFiremodeIndex);
_unit setVariable [QGVAR(previousWeapon), _previousWeaponIndex, true];
_unit action ["SwitchWeapon", _unit, _unit, 299];
[_unit, "AmovPercMstpSnonWnonDnon", 0] call EFUNC(common,doAnimation);

[_unit, "forceWalk", "ACE_dragging", true] call EFUNC(common,statusEffect_set);

};

[_unit, "blockThrow", "ACE_dragging", true] call EFUNC(common,statusEffect_set);
Expand Down