2015-04-12 02:21:33 +00:00
|
|
|
/*
|
|
|
|
* Author: PabstMirror
|
|
|
|
* Interface to allow external modules to safely adjust pain levels.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: The patient <OBJECT>
|
|
|
|
* 1: Added ammount of pain (can be negative) <NUMBER>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* The new pain level <NUMBER>
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [guy, 0.5] call ace_medical_fnc_adjustPainLevel
|
|
|
|
*
|
|
|
|
* Public: Yes
|
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-08-22 14:25:10 +00:00
|
|
|
params ["_unit", "_addedPain"];
|
2015-04-12 02:21:33 +00:00
|
|
|
//Only run on local units:
|
|
|
|
if (!local _unit) exitWith {ERROR("unit is not local");};
|
2015-09-05 22:31:14 +00:00
|
|
|
TRACE_3("ACE_DEBUG: adjustPainLevel Called",_unit, _pain, _addedPain);
|
2015-04-12 02:21:33 +00:00
|
|
|
|
|
|
|
//Ignore if medical system disabled:
|
|
|
|
if (GVAR(level) == 0) exitWith {};
|
|
|
|
|
2016-06-13 00:34:56 +00:00
|
|
|
private _pain = ((_unit getVariable [QGVAR(pain), 0]) + _addedPain) max 0;
|
2015-04-12 02:21:33 +00:00
|
|
|
|
|
|
|
_unit setVariable [QGVAR(pain), _pain];
|
|
|
|
|
|
|
|
//Start up the vital watching (if not already running)
|
2016-02-28 23:12:56 +00:00
|
|
|
[_unit] call FUNC(addVitalLoop);
|
2015-04-12 02:21:33 +00:00
|
|
|
|
2016-06-13 00:34:56 +00:00
|
|
|
_pain;
|