ACE3/addons/common/functions/fnc_addSwayFactor.sqf
Grim cc26f00df3
Common/Adv. Fatigue/Medical - Add unified sway calculation (#9226)
* fix adv fatigue sway interaction with medical

* change medical sway scaling

* move to common

* function header

* number tweaks

* baseline is always at least 1

* Add error msgs and warn if using old ACE_setCustomAimCoef

* Update addons/common/functions/fnc_addSwayFactor.sqf

---------

Co-authored-by: PabstMirror <pabstmirror@gmail.com>
2023-09-02 18:09:19 -04:00

36 lines
952 B
Plaintext

#include "script_component.hpp"
/*
* Author: LinkIsGrim
* Adds a factor to player sway calculation
*
* Arguments:
* 0: Type of factor, "baseline" or "multiplier" <STRING>
* 1: Factor function, must return number <CODE>
* 2: Factor ID, unique to type <STRING>
*
* Return Value:
* Factor added <BOOLEAN>
*
* Example:
* ["baseline", {1}, "ace_common"] call ace_common_fnc_addSwayFactor
*
* Public: Yes
*/
params ["_type", "_code", "_id"];
_type = toLower _type;
if !(_type in ["baseline", "multiplier"]) exitWith { ERROR_2("%1-%2 type unsupported",_type,_id); false };
if !((call _code) isEqualType 0) exitWith { ERROR_2("%1-%2 bad return type",_type,_id); false };
[missionNamespace, format ["ACE_setCustomAimCoef_%1", _type], _id, _code] call FUNC(arithmeticSetSource);
if (_type isEqualTo "baseline") then {
GVAR(swayFactorsBaseline) pushBackUnique [_id];
} else {
GVAR(swayFactorsMultiplier) pushBackUnique [_id];
};
true