2016-10-05 22:54:57 +00:00
|
|
|
/*
|
|
|
|
* Author: Glowbal
|
|
|
|
* Handles full heal of a patient.
|
2016-07-15 10:23:47 +00:00
|
|
|
*
|
2016-10-05 22:54:57 +00:00
|
|
|
* Arguments:
|
|
|
|
* 0: The medic <OBJECT>
|
|
|
|
* 1: The patient <OBJECT>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* Succesful treatment started <BOOL>
|
|
|
|
*
|
|
|
|
* Public: No
|
2016-07-15 10:23:47 +00:00
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
|
|
|
params ["_caller", "_target"];
|
|
|
|
|
2016-12-05 20:34:20 +00:00
|
|
|
if (!alive _target) exitWith {};
|
|
|
|
|
|
|
|
private _fullHealLocation = EGVAR(medical,fullHealLocation_PAK);
|
|
|
|
private _partialHeal = _fullHealLocation > 0; // Full heal not everywhere
|
|
|
|
|
|
|
|
if (_partialHeal) then {
|
|
|
|
private _medFacility = ([_caller] call EFUNC(medical,isInMedicalFacility)) || {[_target] call EFUNC(medical,isInMedicalFacility)};
|
|
|
|
private _medVeh = ([_caller] call EFUNC(medical,isInMedicalVehicle)) || {[_target] call EFUNC(medical,isInMedicalVehicle)};
|
|
|
|
switch (_fullHealLocation) do {
|
|
|
|
case 1: { _partialHeal = !_medFacility; };
|
|
|
|
case 2: { _partialHeal = !_medVeh; };
|
|
|
|
case 3: { _partialHeal = !_medFacility && {!_medVeh}; };
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
if (_partialHeal) then {
|
|
|
|
private _partialHealCounter = _target getVariable [QGVAR(partialHealCounter), 0];
|
|
|
|
_partialHealCounter = _partialHealCounter + 1;
|
|
|
|
_target setVariable [QGVAR(partialHealCounter), _partialHealCounter, true];
|
|
|
|
|
|
|
|
private _effectiveness = (0 max EGVAR(medical,fieldEffectiveness_PAK) min 1) ^ _partialHealCounter;
|
|
|
|
private _persistentDamage = 1 - _effectiveness;
|
|
|
|
|
|
|
|
private _openWounds = _target getVariable [QEGVAR(medical,openWounds), []];
|
2016-12-07 17:53:12 +00:00
|
|
|
{
|
|
|
|
_x params ["", "", "", "", "_bleeding", "_damage"];
|
|
|
|
_x set [5, _damage min _persistentDamage];
|
|
|
|
} forEach _openWounds;
|
|
|
|
_target setVariable [QEGVAR(medical,openWounds), _openWounds, true];
|
|
|
|
|
2016-12-05 20:34:20 +00:00
|
|
|
private _bandagedWounds = _target getVariable [QEGVAR(medical,bandagedWounds), []];
|
2016-12-07 17:53:12 +00:00
|
|
|
{
|
|
|
|
_x params ["", "", "", "", "_bleeding", "_damage"];
|
|
|
|
_x set [5, _damage min _persistentDamage];
|
|
|
|
} forEach _bandagedWounds;
|
|
|
|
_target setVariable [QEGVAR(medical,bandagedWounds), _bandagedWounds, true];
|
|
|
|
|
2016-12-05 20:34:20 +00:00
|
|
|
private _stitchedWounds = _target getVariable [QEGVAR(medical,stitchedWounds), []];
|
|
|
|
{
|
|
|
|
_x params ["", "", "", "", "_bleeding", "_damage"];
|
2016-12-07 17:53:12 +00:00
|
|
|
_x set [5, _damage min _persistentDamage];
|
|
|
|
} forEach _stitchedWounds;
|
|
|
|
_target setVariable [QEGVAR(medical,stitchedWounds), _stitchedWounds, true];
|
2016-12-05 20:34:20 +00:00
|
|
|
|
|
|
|
// todo: only reset limping if leg damage was reduced enough
|
|
|
|
[_unit, false] call EFUNC(medical_engine,setLimping);
|
|
|
|
|
|
|
|
_target setDamage ((damage _target) min _persistentDamage);
|
|
|
|
} else {
|
2016-07-15 10:23:47 +00:00
|
|
|
_target setVariable [QEGVAR(medical,pain), 0, true];
|
2016-10-10 15:30:42 +00:00
|
|
|
_target setVariable [QEGVAR(medical,bloodVolume), DEFAULT_BLOOD_VOLUME, true];
|
2016-07-15 10:23:47 +00:00
|
|
|
|
|
|
|
// tourniquets
|
|
|
|
_target setVariable [QEGVAR(medical,tourniquets), [0,0,0,0,0,0], true];
|
|
|
|
|
|
|
|
// wounds and injuries
|
|
|
|
_target setVariable [QEGVAR(medical,openWounds), [], true];
|
|
|
|
_target setVariable [QEGVAR(medical,bandagedWounds), [], true];
|
2016-12-05 20:34:20 +00:00
|
|
|
_target setVariable [QEGVAR(medical,stitchedWounds), [], true];
|
2016-07-15 10:23:47 +00:00
|
|
|
|
|
|
|
// vitals
|
2016-12-06 19:42:10 +00:00
|
|
|
_target setVariable [QEGVAR(medical,heartRate), 80, true];
|
|
|
|
_target setVariable [QEGVAR(medical,heartRateAdjustments), [], true];
|
|
|
|
_target setVariable [QEGVAR(medical,bloodPressure), [80, 120], true];
|
|
|
|
_target setVariable [QEGVAR(medical,peripheralResistance), 100, true];
|
|
|
|
_target setVariable [QGVAR(peripheralResistanceAdjustments), [], true];
|
2016-07-15 10:23:47 +00:00
|
|
|
|
|
|
|
// IVs
|
2016-09-18 10:05:36 +00:00
|
|
|
_target setVariable [QEGVAR(medical,ivBags), nil, true];
|
2016-07-15 10:23:47 +00:00
|
|
|
|
|
|
|
// damage storage
|
|
|
|
_target setVariable [QEGVAR(medical,bodyPartStatus), [0,0,0,0,0,0], true];
|
|
|
|
|
|
|
|
// generic medical admin
|
|
|
|
_target setVariable [QEGVAR(medical,inCardiacArrest), false, true];
|
2016-12-05 20:34:20 +00:00
|
|
|
_target setVariable [QEGVAR(medical,isUnconscious), false, true];
|
2016-07-15 10:23:47 +00:00
|
|
|
_target setVariable [QEGVAR(medical,hasLostBlood), 0, true];
|
|
|
|
_target setVariable [QEGVAR(medical,isBleeding), false, true];
|
|
|
|
_target setVariable [QEGVAR(medical,hasPain), false, true];
|
|
|
|
_target setVariable [QEGVAR(medical,painSuppress), 0, true];
|
2016-12-06 19:42:10 +00:00
|
|
|
_target setVariable [QGVAR(painSuppressAdjustments), [], true];
|
2016-12-05 20:34:20 +00:00
|
|
|
_target setVariable [QGVAR(partialHealCounter), 0, true];
|
|
|
|
|
2016-07-15 10:23:47 +00:00
|
|
|
// medication
|
|
|
|
private _allUsedMedication = _target getVariable [QEGVAR(medical,allUsedMedication), []];
|
2016-10-05 22:54:57 +00:00
|
|
|
|
2016-07-15 10:23:47 +00:00
|
|
|
{
|
|
|
|
_target setVariable [_x select 0, nil];
|
|
|
|
} forEach _allUsedMedication;
|
|
|
|
|
2016-12-05 20:34:20 +00:00
|
|
|
[_unit, false] call EFUNC(medical_engine,setLimping);
|
|
|
|
|
2016-07-15 10:23:47 +00:00
|
|
|
// Resetting damage
|
|
|
|
_target setDamage 0;
|
|
|
|
};
|
2016-12-05 20:34:20 +00:00
|
|
|
|
|
|
|
[QEGVAR(medical,FullHeal), _target] call CBA_fnc_localEvent;
|
|
|
|
|
|
|
|
[_target, "activity", ELSTRING(medical,Activity_fullHeal), [[_caller, false, true] call EFUNC(common,getName)]] call FUNC(addToLog);
|
|
|
|
[_target, "activity_view", ELSTRING(medical,Activity_fullHeal), [[_caller, false, true] call EFUNC(common,getName)]] call FUNC(addToLog); // TODO expand message
|