mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Adv Fatigue - Make stamina penalty for weapon raised/ready scale with weapon inertia (#8669)
* Stamina penalty for weapon raised/ready is scaled by weapon inertia * Newline * Tabs my editor hates me * Use format * Improved item validation and caching
This commit is contained in:
parent
8319dafcba
commit
4a3ad40c04
@ -2,6 +2,7 @@ PREP(addDutyFactor);
|
||||
PREP(createStaminaBar);
|
||||
PREP(getAnimDuty);
|
||||
PREP(getMetabolicCosts);
|
||||
PREP(getWeaponInertia);
|
||||
PREP(handleEffects);
|
||||
PREP(handlePlayerChanged);
|
||||
PREP(handleStaminaBar);
|
||||
|
@ -19,6 +19,11 @@ if (!hasInterface) exitWith {};
|
||||
};
|
||||
}] call EFUNC(common,arithmeticSetSource);
|
||||
|
||||
// recheck weapon inertia after weapon swap, change of attachments or switching unit
|
||||
["weapon", {[ACE_player] call FUNC(getWeaponInertia)}, true] call CBA_fnc_addPlayerEventHandler;
|
||||
["loadout", {[ACE_player] call FUNC(getWeaponInertia)}, true] call CBA_fnc_addPlayerEventHandler;
|
||||
["unit", {[ACE_player] call FUNC(getWeaponInertia)}, true] call CBA_fnc_addPlayerEventHandler;
|
||||
|
||||
["CBA_settingsInitialized", {
|
||||
if (!GVAR(enabled)) exitWith {};
|
||||
|
||||
|
@ -11,5 +11,7 @@ PREP_RECOMPILE_END;
|
||||
GVAR(staminaBarWidth) = 10 * (((safezoneW / safezoneH) min 1.2) / 40);
|
||||
GVAR(dutyList) = createHashMap;
|
||||
GVAR(setAnimExclusions) = [];
|
||||
GVAR(inertia) = 0;
|
||||
GVAR(inertiaCache) = createHashMap;
|
||||
|
||||
ADDON = true;
|
||||
|
@ -37,13 +37,14 @@ if (_animType in ["idl", "mov", "adj"]) then {
|
||||
};
|
||||
};
|
||||
|
||||
if (currentWeapon _unit != handgunWeapon _unit) then {
|
||||
if (currentWeapon _unit != "") then {
|
||||
if (_animName select [13, 3] == "ras") then {
|
||||
// low ready jog
|
||||
_duty = _duty * 1.2;
|
||||
if (_animName select [9, 3] == "tac") then {
|
||||
// high ready jog/walk
|
||||
_duty = _duty * 1.5;
|
||||
_duty = _duty * (1 + 0.8*GVAR(inertia));
|
||||
} else {
|
||||
// low ready jog
|
||||
_duty = _duty * (1 + 0.2*GVAR(inertia));
|
||||
};
|
||||
};
|
||||
};
|
||||
|
38
addons/advanced_fatigue/functions/fnc_getWeaponInertia.sqf
Normal file
38
addons/advanced_fatigue/functions/fnc_getWeaponInertia.sqf
Normal file
@ -0,0 +1,38 @@
|
||||
#include "script_component.hpp"
|
||||
/*
|
||||
* Author: Pterolatypus
|
||||
* Calculates total weapon inertia, accounting for attachments.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* Total inertia <NUMBER>
|
||||
*
|
||||
* Example:
|
||||
* [ACE_player] call ace_advanced_fatigue_fnc_getWeaponInertia
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
params [["_unit", ACE_player, [objNull]]];
|
||||
|
||||
private _cache = GVAR(inertiaCache);
|
||||
private _weapon = currentWeapon _unit;
|
||||
private _weaponAndItems = [_weapon] + (_unit weaponAccessories _weapon);
|
||||
|
||||
private _inertia = _cache get _weaponAndItems;
|
||||
if (isNil "_inertia") then {
|
||||
_inertia = 0;
|
||||
private _cfgWeapons = configFile >> "CfgWeapons";
|
||||
{
|
||||
// if item is "" or inertia property is undefined, just ignore it
|
||||
private _itemInertia = getNumber (_cfgWeapons >> _x >> "inertia");
|
||||
if (isNil "_itemInertia") then { continue };
|
||||
|
||||
_inertia = _inertia + _itemInertia;
|
||||
} forEach _weaponAndItems;
|
||||
_cache set [_weaponAndItems, _inertia];
|
||||
};
|
||||
|
||||
GVAR(inertia) = _inertia;
|
||||
_inertia
|
Loading…
Reference in New Issue
Block a user