2018-07-30 09:22:14 +00:00
|
|
|
#include "script_component.hpp"
|
2016-07-15 10:23:47 +00:00
|
|
|
/*
|
|
|
|
* Author: Glowbal
|
2019-06-03 15:31:46 +00:00
|
|
|
* Local callback for bandaging a patient's open wounds.
|
2016-07-15 10:23:47 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
2019-06-03 15:31:46 +00:00
|
|
|
* 0: Patient <OBJECT>
|
|
|
|
* 1: Body Part <STRING>
|
|
|
|
* 2: Treatment <STRING>
|
2016-07-15 10:23:47 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
2019-06-03 15:31:46 +00:00
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [player, "Head", "FieldDressing"] call ace_medical_treatment_fnc_bandageLocal
|
2016-07-15 10:23:47 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
2019-06-03 15:31:46 +00:00
|
|
|
params ["_patient", "_bodyPart", "_bandage"];
|
2019-10-08 15:45:09 +00:00
|
|
|
TRACE_3("bandageLocal",_patient,_bodyPart,_bandage);
|
2016-07-15 10:23:47 +00:00
|
|
|
|
2016-10-05 22:54:57 +00:00
|
|
|
private _partIndex = ALL_BODY_PARTS find toLower _bodyPart;
|
2019-12-12 16:25:21 +00:00
|
|
|
if (_partIndex < 0) exitWith {};
|
2016-07-15 10:23:47 +00:00
|
|
|
|
2019-06-22 18:36:27 +00:00
|
|
|
private _openWounds = GET_OPEN_WOUNDS(_patient);
|
2019-12-12 16:25:21 +00:00
|
|
|
if (_openWounds isEqualTo []) exitWith {};
|
2016-07-15 10:23:47 +00:00
|
|
|
|
|
|
|
// Figure out which injury for this bodypart is the best choice to bandage
|
|
|
|
// TODO also use up the remainder on left over injuries
|
2019-06-03 15:31:46 +00:00
|
|
|
private _targetWound = [_patient, _bandage, _partIndex] call FUNC(findMostEffectiveWound);
|
2018-07-25 08:35:04 +00:00
|
|
|
_targetWound params ["_wound", "_woundIndex", "_effectiveness"];
|
2016-07-15 10:23:47 +00:00
|
|
|
|
2018-07-25 08:35:04 +00:00
|
|
|
// Everything is patched up on this body part already
|
|
|
|
if (_effectiveness == -1) exitWith {};
|
2016-07-15 10:23:47 +00:00
|
|
|
|
|
|
|
// Find the impact this bandage has and reduce the amount this injury is present
|
2019-05-12 04:13:59 +00:00
|
|
|
private _amountOf = _wound select 2;
|
2018-07-25 08:35:04 +00:00
|
|
|
private _impact = _effectiveness min _amountOf;
|
2019-05-12 04:13:59 +00:00
|
|
|
_amountOf = _amountOf - _impact;
|
|
|
|
_wound set [2, _amountOf];
|
2018-07-25 08:35:04 +00:00
|
|
|
_openWounds set [_woundIndex, _wound];
|
2016-07-15 10:23:47 +00:00
|
|
|
|
2019-06-22 18:36:27 +00:00
|
|
|
_patient setVariable [VAR_OPEN_WOUNDS, _openWounds, true];
|
2016-07-15 10:23:47 +00:00
|
|
|
|
2019-06-03 15:31:46 +00:00
|
|
|
[_patient] call EFUNC(medical_status,updateWoundBloodLoss);
|
2019-04-27 19:12:11 +00:00
|
|
|
|
2016-07-15 10:23:47 +00:00
|
|
|
// Handle the reopening of bandaged wounds
|
2018-08-11 10:40:06 +00:00
|
|
|
if (_impact > 0 && {GVAR(advancedBandages) && {GVAR(woundReopening)}}) then {
|
2019-06-03 15:31:46 +00:00
|
|
|
[_patient, _impact, _partIndex, _woundIndex, _wound, _bandage] call FUNC(handleBandageOpening);
|
2016-07-15 10:23:47 +00:00
|
|
|
};
|
|
|
|
|
2019-05-12 04:13:59 +00:00
|
|
|
// Check if we fixed limping from this treatment
|
2019-06-03 15:31:46 +00:00
|
|
|
if ((EGVAR(medical,limping) == 1) && {_partIndex > 3} && {_amountOf <= 0} && {_patient getVariable [QEGVAR(medical,isLimping), false]}) then {
|
|
|
|
[_patient] call EFUNC(medical_engine,updateDamageEffects);
|
2019-05-12 04:13:59 +00:00
|
|
|
};
|
|
|
|
|
2019-10-08 15:45:09 +00:00
|
|
|
if (GVAR(clearTraumaAfterBandage)) then {
|
|
|
|
TRACE_2("clearTraumaAfterBandage - checking open wounds",_partIndex,_openWounds);
|
|
|
|
if ((_openWounds findIf {
|
|
|
|
_x params ["", "_xBodyPartN", "_xAmountOf"];
|
|
|
|
(_partIndex ==_xBodyPartN) && {_xAmountOf > 0}
|
|
|
|
}) == -1) then {
|
|
|
|
|
|
|
|
private _bodyPartDamage = _patient getVariable [QEGVAR(medical,bodyPartDamage), [0,0,0,0,0,0]];
|
|
|
|
_bodyPartDamage set [_partIndex, 0];
|
|
|
|
_patient setVariable [QEGVAR(medical,bodyPartDamage), _bodyPartDamage, true];
|
|
|
|
TRACE_2("fully healed",_partIndex,_bodyPartDamage);
|
|
|
|
|
|
|
|
switch (_partIndex) do {
|
|
|
|
case 0: { [_patient, true, false, false, false] call EFUNC(medical_engine,updateBodyPartVisuals); };
|
|
|
|
case 1: { [_patient, false, true, false, false] call EFUNC(medical_engine,updateBodyPartVisuals); };
|
|
|
|
case 2;
|
|
|
|
case 3: { [_patient, false, false, true, false] call EFUNC(medical_engine,updateBodyPartVisuals); };
|
|
|
|
default { [_patient, false, false, false, true] call EFUNC(medical_engine,updateBodyPartVisuals); };
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2019-12-12 16:25:21 +00:00
|
|
|
if (_amountOf <= 0) then { // Reset treatment condition cache for nearby players if we stopped all bleeding
|
|
|
|
private _nearPlayers = (_patient nearEntities ["CAManBase", 6]) select {_x call EFUNC(common,isPlayer)};
|
|
|
|
TRACE_1("clearConditionCaches: bandage",_nearPlayers);
|
|
|
|
[QEGVAR(interact_menu,clearConditionCaches), [], _nearPlayers] call CBA_fnc_targetEvent;
|
|
|
|
};
|