ACE3/addons/medical/functions/fnc_adjustPainLevel.sqf
SilentSpike 1dc934e1b1 Use macros for unit variables
Improves the way medical is storing variables in object space by having
a common list of variables names as macros. Makes the code a bit cleaner
and ensured consistency across components. Also a handy reference for
when working on medical to see what values are all stored.
2018-05-11 15:28:25 +01:00

31 lines
669 B
Plaintext

/*
* Author: PabstMirror
* Interface to allow external modules to affect the pain level
*
* Arguments:
* 0: The patient <OBJECT>
* 1: Desired pain level (0 .. 1) <NUMBER>
*
* Return Value:
* nothing
*
* Example:
* [guy, 0.5] call ace_medical_fnc_adjustPainLevel
*
* Public: Yes
*/
#include "script_component.hpp"
params ["_unit", "_desiredPainLevel"];
if (!local _unit) exitWith { ERROR("unit is not local"); };
TRACE_2("adjustPainLevel",_unit,_desiredPainLevel);
_desiredPainLevel = _desiredPainLevel * GVAR(painCoefficient);
private _pain = GET_PAIN(_unit);
_pain = 0 max (_pain max _desiredPainLevel) min 1;
_unit setVariable [VAR_PAIN, _pain];