2016-07-15 10:23:47 +00:00
|
|
|
/*
|
|
|
|
* Author: Glowbal
|
|
|
|
* Handles the bandage of a patient.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: The target <OBJECT>
|
|
|
|
* 1: The impact <NUMBER>
|
|
|
|
* 2: Selection part number <NUMBER>
|
|
|
|
* 3: Injury index <NUMBER>
|
|
|
|
* 4: Injury <ARRAY>
|
|
|
|
* 5: Used Bandage type <STRING>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
|
|
|
params ["_target", "_impact", "_part", "_injuryIndex", "_injury", "_bandage"];
|
|
|
|
|
|
|
|
private _classID = _injury select 1;
|
2016-12-10 15:36:36 +00:00
|
|
|
private _bodyPartN = _injury select 2;
|
2016-09-27 09:05:38 +00:00
|
|
|
private _className = EGVAR(medical_damage,woundClassNames) select _classID;
|
2016-07-15 10:23:47 +00:00
|
|
|
|
|
|
|
// default, just in case..
|
|
|
|
private _reopeningChance = 0.1;
|
|
|
|
private _reopeningMinDelay = 120;
|
|
|
|
private _reopeningMaxDelay = 200;
|
|
|
|
|
|
|
|
// Get the default values for the used bandage
|
2016-10-20 11:38:26 +00:00
|
|
|
private _config = configFile >> QUOTE(ADDON) >> "Bandaging";
|
|
|
|
|
2016-07-15 10:23:47 +00:00
|
|
|
if (isClass (_config >> _bandage)) then {
|
2016-10-20 11:38:26 +00:00
|
|
|
_config = _config >> _bandage;
|
2016-07-15 10:23:47 +00:00
|
|
|
_reopeningChance = getNumber (_config >> "reopeningChance");
|
|
|
|
_reopeningMinDelay = getNumber (_config >> "reopeningMinDelay");
|
|
|
|
_reopeningMaxDelay = getNumber (_config >> "reopeningMaxDelay") max _reopeningMinDelay;
|
|
|
|
} else {
|
2016-08-22 19:06:52 +00:00
|
|
|
WARNING_2("No config for bandage [%1] config base [%2]", _bandage, _config);
|
2016-07-15 10:23:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if (isClass (_config >> _className)) then {
|
2016-10-20 11:38:26 +00:00
|
|
|
private _woundTreatmentConfig = _config >> _className;
|
|
|
|
|
2016-07-15 10:23:47 +00:00
|
|
|
if (isNumber (_woundTreatmentConfig >> "reopeningChance")) then {
|
|
|
|
_reopeningChance = getNumber (_woundTreatmentConfig >> "reopeningChance");
|
|
|
|
};
|
2016-10-20 11:38:26 +00:00
|
|
|
|
2016-07-15 10:23:47 +00:00
|
|
|
if (isNumber (_woundTreatmentConfig >> "reopeningMinDelay")) then {
|
|
|
|
_reopeningMinDelay = getNumber (_woundTreatmentConfig >> "reopeningMinDelay");
|
|
|
|
};
|
2016-10-20 11:38:26 +00:00
|
|
|
|
2016-07-15 10:23:47 +00:00
|
|
|
if (isNumber (_woundTreatmentConfig >> "reopeningMaxDelay")) then {
|
|
|
|
_reopeningMaxDelay = getNumber (_woundTreatmentConfig >> "reopeningMaxDelay") max _reopeningMinDelay;
|
|
|
|
};
|
|
|
|
} else {
|
2016-08-22 19:06:52 +00:00
|
|
|
WARNING_2("No config for wound type [%1] config base [%2]", _className, _config);
|
2016-07-15 10:23:47 +00:00
|
|
|
};
|
|
|
|
TRACE_5("configs",_bandage,_className,_reopeningChance,_reopeningMinDelay,_reopeningMaxDelay);
|
|
|
|
|
|
|
|
private _bandagedWounds = _target getVariable [QEGVAR(medical,bandagedWounds), []];
|
|
|
|
private _exist = false;
|
|
|
|
{
|
2016-12-10 15:36:36 +00:00
|
|
|
_x params ["", "_id", "_partN", "_amountOf"];
|
|
|
|
if (_id == _classID && {_partN == _bodyPartN}) exitWith {
|
|
|
|
_x set [3, _amountOf + _impact];
|
|
|
|
_bandagedWounds set [_forEachIndex, _x];
|
2016-07-15 10:23:47 +00:00
|
|
|
_exist = true;
|
|
|
|
};
|
2016-10-20 11:38:26 +00:00
|
|
|
} forEach _bandagedWounds;
|
2016-07-15 10:23:47 +00:00
|
|
|
|
2016-12-10 15:36:36 +00:00
|
|
|
if (!_exist) then {
|
|
|
|
private _bandagedInjury = +_injury;
|
2016-12-05 20:34:20 +00:00
|
|
|
_bandagedInjury set [3, _impact];
|
2016-10-20 11:38:26 +00:00
|
|
|
_bandagedWounds pushBack _bandagedInjury;
|
2016-07-15 10:23:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
_target setVariable [QEGVAR(medical,bandagedWounds), _bandagedWounds, true];
|
|
|
|
|
|
|
|
TRACE_1("",_reopeningChance);
|
|
|
|
// Check if we are ever going to reopen this
|
2016-10-20 11:38:26 +00:00
|
|
|
if (random 1 <= _reopeningChance) then {
|
|
|
|
private _delay = _reopeningMinDelay + random (_reopeningMaxDelay - _reopeningMinDelay);
|
2016-07-15 10:23:47 +00:00
|
|
|
TRACE_1("Will open",_delay);
|
|
|
|
[{
|
|
|
|
params ["_target", "_impact", "_part", "_injuryIndex", "_injury"];
|
|
|
|
TRACE_5("params",_target,_impact,_part,_injuryIndex,_injury);
|
|
|
|
|
2016-12-10 15:36:36 +00:00
|
|
|
private _openWounds = _target getVariable [QEGVAR(medical,openWounds), []];
|
|
|
|
if (count _openWounds - 1 < _injuryIndex) exitWith {};
|
|
|
|
|
|
|
|
_injury params ["", "_classID", "_bodyPartN"];
|
|
|
|
|
|
|
|
private _selectedInjury = _openWounds select _injuryIndex;
|
|
|
|
if (_selectedInjury select 1 == _classID && {_selectedInjury select 2 == _bodyPartN}) then { // matching the IDs
|
|
|
|
private _bandagedWounds = _target getVariable [QEGVAR(medical,bandagedWounds), []];
|
|
|
|
private _exist = false;
|
|
|
|
{
|
|
|
|
_x params ["", "_id", "_partN", "_amountOf"];
|
|
|
|
if (_id == _classID && {_partN == _bodyPartN}) exitWith {
|
|
|
|
_x set [3, 0 max (_amountOf - _impact)];
|
|
|
|
_bandagedWounds set [_forEachIndex, _x];
|
|
|
|
_exist = true;
|
2016-07-15 10:23:47 +00:00
|
|
|
};
|
2016-12-10 15:36:36 +00:00
|
|
|
} forEach _bandagedWounds;
|
|
|
|
|
|
|
|
if (_exist) then {
|
|
|
|
TRACE_2("Reopening Wound",_bandagedWounds,_openWounds);
|
|
|
|
_selectedInjury set [3, (_selectedInjury select 3) + _impact];
|
|
|
|
_openWounds set [_injuryIndex, _selectedInjury];
|
|
|
|
_target setVariable [QEGVAR(medical,bandagedWounds), _bandagedWounds, true];
|
|
|
|
_target setVariable [QEGVAR(medical,openWounds), _openWounds, true];
|
2016-07-15 10:23:47 +00:00
|
|
|
};
|
2016-12-10 15:36:36 +00:00
|
|
|
};
|
2016-07-15 10:23:47 +00:00
|
|
|
}, [_target, _impact, _part, _injuryIndex, +_injury], _delay] call CBA_fnc_waitAndExecute;
|
|
|
|
};
|