2015-04-05 17:26:33 +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"
|
|
|
|
|
2015-08-22 14:25:10 +00:00
|
|
|
private ["_className", "_reopeningChance", "_reopeningMinDelay", "_reopeningMaxDelay", "_config", "_woundTreatmentConfig", "_bandagedWounds", "_exist", "_injuryId", "_existingInjury", "_delay", "_openWounds", "_selectedInjury", "_bandagedInjury"];
|
|
|
|
params ["_target", "_impact", "_part", "_injuryIndex", "_injury", "_bandage"];
|
2015-04-05 17:26:33 +00:00
|
|
|
|
2015-08-22 14:25:10 +00:00
|
|
|
_injury parmas ["_classID", "_injuryType"];
|
2015-04-05 17:26:33 +00:00
|
|
|
_className = GVAR(woundClassNames) select _classID;
|
|
|
|
|
|
|
|
// default, just in case..
|
|
|
|
_reopeningChance = 0.1;
|
|
|
|
_reopeningMinDelay = 120;
|
|
|
|
_reopeningMaxDelay = 200;
|
|
|
|
|
|
|
|
// Get the default values for the used bandage
|
|
|
|
_config = (ConfigFile >> "ACE_Medical_Advanced" >> "Treatment" >> "Bandaging");
|
|
|
|
if (isClass (_config >> _bandage)) then {
|
|
|
|
_config = (_config >> _bandage);
|
2015-04-06 16:22:43 +00:00
|
|
|
_reopeningChance = getNumber (_config >> "reopeningChance");
|
|
|
|
_reopeningMinDelay = getNumber (_config >> "reopeningMinDelay");
|
|
|
|
_reopeningMaxDelay = getNumber (_config >> "reopeningMaxDelay") max _reopeningMinDelay;
|
2015-04-05 17:26:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if (isClass (_config >> _className)) then {
|
|
|
|
_woundTreatmentConfig = (_config >> _className);
|
|
|
|
if (isNumber (_woundTreatmentConfig >> "reopeningChance")) then {
|
2015-04-06 16:22:43 +00:00
|
|
|
_reopeningChance = getNumber (_woundTreatmentConfig >> "reopeningChance");
|
|
|
|
};
|
2015-04-05 17:26:33 +00:00
|
|
|
if (isNumber (_woundTreatmentConfig >> "reopeningMinDelay")) then {
|
2015-04-06 16:22:43 +00:00
|
|
|
_reopeningMinDelay = getNumber (_woundTreatmentConfig >> "reopeningMinDelay");
|
|
|
|
};
|
2015-04-05 17:26:33 +00:00
|
|
|
if (isNumber (_woundTreatmentConfig >> "reopeningMaxDelay")) then {
|
2015-04-06 16:22:43 +00:00
|
|
|
_reopeningMaxDelay = getNumber (_woundTreatmentConfig >> "reopeningMaxDelay") max _reopeningMinDelay;
|
|
|
|
};
|
2015-04-05 17:26:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
_bandagedWounds = _target getvariable [QGVAR(bandagedWounds), []];
|
|
|
|
_exist = false;
|
2015-04-15 17:45:42 +00:00
|
|
|
_bandagedInjury = [];
|
2015-04-05 17:26:33 +00:00
|
|
|
{
|
2015-08-22 14:25:10 +00:00
|
|
|
_x params ["", "_injuryTypeX", "_injuryX"];
|
|
|
|
if (_injuryTypeX == _injuryType && _injuryTypeX == (_injury select 2)) exitwith {
|
2015-04-06 16:22:43 +00:00
|
|
|
_exist = true;
|
|
|
|
_existingInjury = _x;
|
|
|
|
_existingInjury set [3, (_existingInjury select 3) + _impact];
|
|
|
|
_bandagedWounds set [_foreachIndex, _existingInjury];
|
2015-04-15 17:45:42 +00:00
|
|
|
|
|
|
|
_bandagedInjury = _existingInjury;
|
2015-04-06 16:22:43 +00:00
|
|
|
};
|
2015-08-22 14:25:10 +00:00
|
|
|
} foreach _bandagedWounds;
|
2015-04-05 17:26:33 +00:00
|
|
|
|
|
|
|
if !(_exist) then {
|
2015-04-06 16:22:43 +00:00
|
|
|
// [ID, classID, bodypart, percentage treated, bloodloss rate]
|
2015-06-20 10:38:12 +00:00
|
|
|
_bandagedInjury = [_injury select 0, _injury select 1, _injury select 2, _impact, _injury select 4];
|
2015-04-15 17:45:42 +00:00
|
|
|
_bandagedWounds pushback _bandagedInjury;
|
|
|
|
};
|
|
|
|
|
2015-06-20 10:38:12 +00:00
|
|
|
_target setvariable [QGVAR(bandagedWounds), _bandagedWounds, true];
|
2015-04-05 17:26:33 +00:00
|
|
|
|
|
|
|
// Check if we are ever going to reopen this
|
|
|
|
if (random(1) <= _reopeningChance) then {
|
2015-04-06 16:22:43 +00:00
|
|
|
_delay = _reopeningMinDelay + random(_reopeningMaxDelay - _reopeningMinDelay);
|
|
|
|
[{
|
2015-08-22 14:25:10 +00:00
|
|
|
private ["_bandage", "_openWounds", "_selectedInjury","_bandagedWounds","_exist"];
|
|
|
|
params ["_target", "_impact", "_part", "_injuryIndex", "_injury"];
|
2015-04-05 17:26:33 +00:00
|
|
|
|
2015-06-20 10:38:12 +00:00
|
|
|
//if (alive _target) then {
|
2015-04-06 16:22:43 +00:00
|
|
|
_openWounds = _target getvariable [QGVAR(openWounds), []];
|
|
|
|
if ((count _openWounds)-1 < _injuryIndex) exitwith {};
|
|
|
|
_selectedInjury = _openWounds select _injuryIndex;
|
2015-06-20 10:38:12 +00:00
|
|
|
if (_selectedInjury select 1 == _injury select 1 && (_selectedInjury select 2) == (_injury select 2)) then { // matching the IDs
|
2015-04-06 16:22:43 +00:00
|
|
|
_selectedInjury set [3, (_selectedInjury select 3) + _impact];
|
|
|
|
_openWounds set [_injuryIndex, _selectedInjury];
|
2015-06-20 10:38:12 +00:00
|
|
|
|
2015-04-06 16:22:43 +00:00
|
|
|
_bandagedWounds = _target getvariable [QGVAR(bandagedWounds), []];
|
|
|
|
_exist = false;
|
2015-06-20 10:38:12 +00:00
|
|
|
_injuryId = _injury select 1;
|
2015-04-06 16:22:43 +00:00
|
|
|
{
|
2015-08-22 14:25:10 +00:00
|
|
|
_x params ["_injuryIdX", "_injuryX"];
|
|
|
|
if (_injuryIdX == _injuryId && _injuryX == (_injury select 2)) exitwith {
|
2015-04-06 16:22:43 +00:00
|
|
|
_exist = true;
|
|
|
|
_existingInjury = _x;
|
|
|
|
_existingInjury set [3, ((_existingInjury select 3) - _impact) max 0];
|
|
|
|
_bandagedWounds set [_foreachIndex, _existingInjury];
|
|
|
|
};
|
2015-08-22 14:25:10 +00:00
|
|
|
} foreach _bandagedWounds;
|
2015-04-05 17:26:33 +00:00
|
|
|
|
2015-04-06 16:22:43 +00:00
|
|
|
if (_exist) then {
|
2015-06-20 10:38:12 +00:00
|
|
|
_target setvariable [QGVAR(bandagedWounds), _bandagedWounds, true];
|
|
|
|
_target setvariable [QGVAR(openWounds), _openWounds, true];
|
2015-04-06 16:22:43 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
// Otherwise something went wrong, we we don't reopen them..
|
2015-06-20 10:38:12 +00:00
|
|
|
//};
|
|
|
|
}, [_target, _impact, _part, _injuryIndex, +_injury], _delay, 0] call EFUNC(common,waitAndExecute);
|
2015-04-05 17:26:33 +00:00
|
|
|
};
|