mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Dragging - Improve weapon reselect behaviour (#9052)
* Dragging - Improve weapon reselect behaviour * Add and use func to getFiremodeIndex --------- Co-authored-by: PabstMirror <pabstmirror@gmail.com>
This commit is contained in:
parent
86d79b2fc1
commit
67ebb15e07
@ -64,6 +64,7 @@ PREP(getDefaultAnim);
|
|||||||
PREP(getDefinedVariable);
|
PREP(getDefinedVariable);
|
||||||
PREP(getDefinedVariableDefault);
|
PREP(getDefinedVariableDefault);
|
||||||
PREP(getDefinedVariableInfo);
|
PREP(getDefinedVariableInfo);
|
||||||
|
PREP(getFiremodeIndex);
|
||||||
PREP(getFirstObjectIntersection);
|
PREP(getFirstObjectIntersection);
|
||||||
PREP(getFirstTerrainIntersection);
|
PREP(getFirstTerrainIntersection);
|
||||||
PREP(getGunner);
|
PREP(getGunner);
|
||||||
|
31
addons/common/functions/fnc_getFiremodeIndex.sqf
Normal file
31
addons/common/functions/fnc_getFiremodeIndex.sqf
Normal file
@ -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
|
@ -48,7 +48,12 @@ if (_target isKindOf "CAManBase" || {animationState _unit in CARRY_ANIMATIONS})
|
|||||||
_unit removeWeapon "ACE_FakePrimaryWeapon";
|
_unit removeWeapon "ACE_FakePrimaryWeapon";
|
||||||
|
|
||||||
// reselect weapon and re-enable sprint
|
// 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];
|
||||||
|
};
|
||||||
|
|
||||||
[_unit, "forceWalk", "ACE_dragging", false] call EFUNC(common,statusEffect_set);
|
[_unit, "forceWalk", "ACE_dragging", false] call EFUNC(common,statusEffect_set);
|
||||||
[_unit, "blockThrow", "ACE_dragging", false] call EFUNC(common,statusEffect_set);
|
[_unit, "blockThrow", "ACE_dragging", false] call EFUNC(common,statusEffect_set);
|
||||||
|
@ -51,13 +51,13 @@ if (_target isKindOf "CAManBase") then {
|
|||||||
_timer = CBA_missionTime + 10;
|
_timer = CBA_missionTime + 10;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// select no weapon and stop sprinting
|
// 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 action ["SwitchWeapon", _unit, _unit, 299];
|
||||||
[_unit, "AmovPercMstpSnonWnonDnon", 0] call EFUNC(common,doAnimation);
|
[_unit, "AmovPercMstpSnonWnonDnon", 0] call EFUNC(common,doAnimation);
|
||||||
|
|
||||||
[_unit, "forceWalk", "ACE_dragging", true] call EFUNC(common,statusEffect_set);
|
[_unit, "forceWalk", "ACE_dragging", true] call EFUNC(common,statusEffect_set);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
[_unit, "blockThrow", "ACE_dragging", true] call EFUNC(common,statusEffect_set);
|
[_unit, "blockThrow", "ACE_dragging", true] call EFUNC(common,statusEffect_set);
|
||||||
|
Loading…
Reference in New Issue
Block a user