mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
switch to 2.18 commands
This commit is contained in:
parent
c3853b22fc
commit
16e63df107
@ -10,6 +10,7 @@ PREP(readSettingsFromParamsArray);
|
|||||||
PREP(actionKeysNamesConverted);
|
PREP(actionKeysNamesConverted);
|
||||||
PREP(addCanInteractWithCondition);
|
PREP(addCanInteractWithCondition);
|
||||||
PREP(addLineToDebugDraw);
|
PREP(addLineToDebugDraw);
|
||||||
|
PREP(addReloadMutex);
|
||||||
PREP(addSwayFactor);
|
PREP(addSwayFactor);
|
||||||
PREP(addToInventory);
|
PREP(addToInventory);
|
||||||
PREP(addWeapon);
|
PREP(addWeapon);
|
||||||
|
@ -441,74 +441,23 @@ addMissionEventHandler ["PlayerViewChanged", {
|
|||||||
//////////////////////////////////////////////////
|
//////////////////////////////////////////////////
|
||||||
|
|
||||||
GVAR(isReloading) = false;
|
GVAR(isReloading) = false;
|
||||||
GVAR(reloadMutex_lastAction) = "";
|
|
||||||
|
|
||||||
["CAManBase", "GestureChanged", {
|
["unit", {
|
||||||
params ["_unit", "_gesture"];
|
params ["_newPlayer","_oldPlayer"];
|
||||||
if !(
|
|
||||||
_unit isEqualTo ACE_Player &&
|
|
||||||
{!GVAR(isReloading)} &&
|
|
||||||
{_gesture isNotEqualTo ""}
|
|
||||||
) exitWith {};
|
|
||||||
|
|
||||||
(weaponState ACE_player) params ["_weapon", "_muzzle"];
|
GVAR(isReloading) = ((weaponState _newPlayer) select 6) == 0; // Catch the new unit reloading
|
||||||
if (_weapon isEqualTo "") exitWith {};
|
if (GVAR(isReloading)) then {
|
||||||
|
private _unitMovesInfo = getUnitMovesInfo _newPlayer; // 6 - gesture elapsed time, 7 - gesture duration
|
||||||
|
[{
|
||||||
|
if (_this isEqualTo ACE_player) exitWith { // player might switch units again before reload finished
|
||||||
|
GVAR(isReloading) = false
|
||||||
|
};
|
||||||
|
}, _newPlayer, (_unitMovesInfo select 7) - (_unitMovesInfo select 6)] call CBA_fnc_waitAndExecute;
|
||||||
|
};
|
||||||
|
|
||||||
private _reloadAction = [_weapon, _muzzle] call FUNC(getReloadAction);
|
_oldPlayer call FUNC(removeReloadMutex);
|
||||||
|
_newPlayer call FUNC(addReloadMutex);
|
||||||
// gesture is always lowercase, skip empty reload actions (binoculars)
|
}, true] call CBA_fnc_addPlayerEventHandler;
|
||||||
if (_gesture isNotEqualTo _reloadAction || {_reloadAction isEqualTo ""}) exitWith {};
|
|
||||||
|
|
||||||
TRACE_2("Reloading, blocking gestures",weaponState ACE_Player,_gesture);
|
|
||||||
GVAR(isReloading) = true;
|
|
||||||
GVAR(reloadMutex_lastAction) = _gesture;
|
|
||||||
}] call CBA_fnc_addClassEventHandler;
|
|
||||||
|
|
||||||
["CAManBase", "GestureDone", {
|
|
||||||
params ["_unit", "_gesture"];
|
|
||||||
if !(
|
|
||||||
GVAR(isReloading) &&
|
|
||||||
{_unit isEqualTo ACE_Player} &&
|
|
||||||
{_gesture isEqualTo GVAR(reloadMutex_lastAction)}
|
|
||||||
) exitWith {};
|
|
||||||
|
|
||||||
GVAR(isReloading) = false;
|
|
||||||
GVAR(reloadMutex_lastAction) = "";
|
|
||||||
}] call CBA_fnc_addClassEventHandler;
|
|
||||||
|
|
||||||
// Some secondary weapons (mainly heavy launchers) have reloads as anims instead of gestures
|
|
||||||
["CAManBase", "AnimChanged", {
|
|
||||||
params ["_unit", "_anim"];
|
|
||||||
if !(
|
|
||||||
_unit isEqualTo ACE_Player &&
|
|
||||||
{!GVAR(isReloading)} &&
|
|
||||||
{currentWeapon ACE_Player isEqualTo secondaryWeapon ACE_Player}
|
|
||||||
) exitWith {};
|
|
||||||
|
|
||||||
(weaponState ACE_Player) params ["_weapon", "_muzzle"];
|
|
||||||
if (_weapon isEqualTo "") exitWith {};
|
|
||||||
|
|
||||||
private _reloadAction = [_weapon, _muzzle] call FUNC(getReloadAction);
|
|
||||||
|
|
||||||
// anim is always lowercase, skip empty reload actions (binoculars)
|
|
||||||
if (_anim isNotEqualTo _reloadAction || {_reloadAction isEqualTo ""}) exitWith {};
|
|
||||||
|
|
||||||
TRACE_2("Reloading with animation, blocking gestures",weaponState ACE_Player,_anim);
|
|
||||||
GVAR(isReloading) = true;
|
|
||||||
GVAR(reloadMutex_lastAction) = _anim;
|
|
||||||
}] call CBA_fnc_addClassEventHandler;
|
|
||||||
|
|
||||||
["CAManBase", "AnimDone", {
|
|
||||||
params ["_unit", "_anim"];
|
|
||||||
if !(
|
|
||||||
GVAR(isReloading) &&
|
|
||||||
{_unit isEqualTo ACE_Player} &&
|
|
||||||
{_anim isEqualTo GVAR(reloadMutex_lastAction)}
|
|
||||||
) exitWith {};
|
|
||||||
|
|
||||||
GVAR(isReloading) = false;
|
|
||||||
GVAR(reloadMutex_lastAction) = "";
|
|
||||||
}] call CBA_fnc_addClassEventHandler;
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////
|
//////////////////////////////////////////////////
|
||||||
// Start the sway loop
|
// Start the sway loop
|
||||||
|
71
addons/common/functions/fnc_addReloadMutex.sqf
Normal file
71
addons/common/functions/fnc_addReloadMutex.sqf
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
#include "..\script_component.hpp"
|
||||||
|
/*
|
||||||
|
* Author: LinkIsGrim
|
||||||
|
* Adds reload mutex to a player unit, sets variable to prevent gestures from being played during a reload animation
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* 0: Player unit <OBJECT>
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* None.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* ACE_player call ace_common_fnc_addReloadMutex
|
||||||
|
*
|
||||||
|
* Public: No
|
||||||
|
*/
|
||||||
|
|
||||||
|
params ["_unit"];
|
||||||
|
|
||||||
|
_unit setVariable [
|
||||||
|
QGVAR(reloadMutex_gestureEH),
|
||||||
|
_unit addEventHandler ["GestureChanged", {
|
||||||
|
params ["_unit", "_gesture"];
|
||||||
|
if (GVAR(isReloading) || _gesture == "") exitWith {}; // skip empty gesture (include empty reload actions for binoculars)
|
||||||
|
|
||||||
|
(weaponState ACE_player) params ["_weapon", "_muzzle"];
|
||||||
|
if (_weapon isEqualTo "") exitWith {};
|
||||||
|
|
||||||
|
private _reloadAction = [_weapon, _muzzle] call FUNC(getReloadAction);
|
||||||
|
|
||||||
|
// gesture is always lowercase
|
||||||
|
if (_gesture isNotEqualTo _reloadAction) exitWith {};
|
||||||
|
|
||||||
|
TRACE_2("Reloading, blocking gestures",weaponState ACE_Player,_gesture);
|
||||||
|
GVAR(isReloading) = true;
|
||||||
|
|
||||||
|
private _unitMovesInfo = getUnitMovesInfo _unit; // 6 - gesture elapsed time, 7 - gesture duration
|
||||||
|
[{
|
||||||
|
if (_this isEqualTo ACE_player) exitWith { // player might switch units again before reload finished
|
||||||
|
GVAR(isReloading) = false
|
||||||
|
};
|
||||||
|
}, _unit, (_unitMovesInfo select 7) - (_unitMovesInfo select 6)] call CBA_fnc_waitAndExecute;
|
||||||
|
}]
|
||||||
|
];
|
||||||
|
|
||||||
|
// Some secondary weapons (mainly heavy launchers) have reloads as anims instead of gestures
|
||||||
|
_unit setVariable [
|
||||||
|
QGVAR(reloadMutex_animEH),
|
||||||
|
_unit addEventHandler ["AnimChanged", {
|
||||||
|
params ["_unit", "_anim"];
|
||||||
|
if ((currentWeapon _unit isNotEqualTo secondaryWeapon _unit) || {GVAR(isReloading) || _anim == ""}) exitWith {};
|
||||||
|
|
||||||
|
(weaponState ACE_Player) params ["_weapon", "_muzzle"];
|
||||||
|
if (_weapon isEqualTo "") exitWith {};
|
||||||
|
|
||||||
|
private _reloadAction = [_weapon, _muzzle] call FUNC(getReloadAction);
|
||||||
|
|
||||||
|
// anim is always lowercase
|
||||||
|
if (_anim isNotEqualTo _reloadAction) exitWith {};
|
||||||
|
|
||||||
|
TRACE_2("Reloading with animation, blocking gestures",weaponState ACE_Player,_anim);
|
||||||
|
GVAR(isReloading) = true;
|
||||||
|
|
||||||
|
private _unitMovesInfo = getUnitMovesInfo _unit; // 1 - anim elapsed time, 2 - anim duration
|
||||||
|
[{
|
||||||
|
if (_this isEqualTo ACE_player) exitWith { // player might switch units again before reload finished
|
||||||
|
GVAR(isReloading) = false
|
||||||
|
};
|
||||||
|
}, _unit, (_unitMovesInfo select 2) - (_unitMovesInfo select 1)] call CBA_fnc_waitAndExecute;
|
||||||
|
}]
|
||||||
|
];
|
34
addons/common/functions/fnc_removeReloadMutex.sqf
Normal file
34
addons/common/functions/fnc_removeReloadMutex.sqf
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#include "..\script_component.hpp"
|
||||||
|
/*
|
||||||
|
* Author: LinkIsGrim
|
||||||
|
* Removes reload mutex from a player unit
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* 0: Player unit <OBJECT>
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* None.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* ACE_player call ace_common_fnc_removeReloadMutex
|
||||||
|
*
|
||||||
|
* Public: No
|
||||||
|
*/
|
||||||
|
|
||||||
|
params ["_unit"];
|
||||||
|
|
||||||
|
if (_unit isNil QGVAR(reloadMutex_gestureEH)) exitWith {
|
||||||
|
WARNING_1("removing reload mutex from unit %1 without eventhandlers - race condition?",_unit);
|
||||||
|
};
|
||||||
|
|
||||||
|
_unit removeEventHandler [
|
||||||
|
"GestureChanged",
|
||||||
|
_unit getVariable QGVAR(reloadMutex_gestureEH)
|
||||||
|
]
|
||||||
|
_unit setVariable [QGVAR(reloadMutex_gestureEH), nil].
|
||||||
|
|
||||||
|
_unit removeEventHandler [
|
||||||
|
"AnimChanged",
|
||||||
|
_unit getVariable QGVAR(reloadMutex_animEH)
|
||||||
|
]
|
||||||
|
_unit setVariable [QGVAR(reloadMutex_animEH), nil].
|
Loading…
Reference in New Issue
Block a user