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);
|
2023-06-24 05:11:56 +00:00
|
|
|
_bodyPart = toLower _bodyPart;
|
2016-07-15 10:23:47 +00:00
|
|
|
|
2019-06-22 18:36:27 +00:00
|
|
|
private _openWounds = GET_OPEN_WOUNDS(_patient);
|
2023-06-24 05:11:56 +00:00
|
|
|
private _woundsOnPart = _openWounds getOrDefault [_bodyPart, []];
|
|
|
|
if (_woundsOnPart 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
|
2023-06-24 05:11:56 +00:00
|
|
|
private _targetWound = [_patient, _bandage, _bodyPart] 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
|
2023-06-24 05:11:56 +00:00
|
|
|
private _amountOf = _wound select 1;
|
2018-07-25 08:35:04 +00:00
|
|
|
private _impact = _effectiveness min _amountOf;
|
2019-05-12 04:13:59 +00:00
|
|
|
_amountOf = _amountOf - _impact;
|
2023-06-24 05:11:56 +00:00
|
|
|
_wound set [1, _amountOf];
|
|
|
|
_woundsOnPart 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
|
2020-01-04 20:43:51 +00:00
|
|
|
if (_impact > 0 && {GVAR(advancedBandages) == 2}) then {
|
2023-06-24 05:11:56 +00:00
|
|
|
[_patient, _impact, _bodyPart, _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
|
2023-06-24 05:11:56 +00:00
|
|
|
if (
|
|
|
|
EGVAR(medical,limping) == 1
|
|
|
|
&& {_bodyPart isEqualTo "leftleg" || _bodyPart isEqualTo "rightleg"}
|
|
|
|
&& {_amountOf <= 0}
|
|
|
|
&& {_patient getVariable [QEGVAR(medical,isLimping), false]}
|
|
|
|
) then {
|
2019-06-03 15:31:46 +00:00
|
|
|
[_patient] call EFUNC(medical_engine,updateDamageEffects);
|
2019-05-12 04:13:59 +00:00
|
|
|
};
|
|
|
|
|
2021-10-12 08:08:10 +00:00
|
|
|
if (GVAR(clearTrauma) == 2) then {
|
2023-06-24 05:11:56 +00:00
|
|
|
TRACE_2("clearTrauma - clearing trauma after bandage",_bodyPart,_openWounds);
|
|
|
|
private _partIndex = ALL_BODY_PARTS find _bodyPart;
|
|
|
|
private _treatedDamageOf = (_wound select 3) * _impact;
|
2021-10-12 08:08:10 +00:00
|
|
|
private _bodyPartDamage = _patient getVariable [QEGVAR(medical,bodyPartDamage), [0,0,0,0,0,0]];
|
|
|
|
private _newDam = (_bodyPartDamage select _partIndex) - _treatedDamageOf;
|
2023-06-24 05:11:56 +00:00
|
|
|
|
|
|
|
// Prevent obscenely small damage from lack of floating precision
|
|
|
|
if (_newDam < 0.05) then {
|
2019-10-08 15:45:09 +00:00
|
|
|
_bodyPartDamage set [_partIndex, 0];
|
2021-10-12 08:08:10 +00:00
|
|
|
} else {
|
|
|
|
_bodyPartDamage set [_partIndex, _newDam];
|
|
|
|
};
|
|
|
|
_patient setVariable [QEGVAR(medical,bodyPartDamage), _bodyPartDamage, true];
|
|
|
|
TRACE_2("clearTrauma - healed damage",_partIndex,_treatedDamageOf);
|
2019-10-08 15:45:09 +00:00
|
|
|
|
2023-06-24 05:11:56 +00:00
|
|
|
switch (_bodyPart) do {
|
|
|
|
case "head": { [_patient, true, false, false, false] call EFUNC(medical_engine,updateBodyPartVisuals); };
|
|
|
|
case "body": { [_patient, false, true, false, false] call EFUNC(medical_engine,updateBodyPartVisuals); };
|
|
|
|
case "leftarm";
|
|
|
|
case "rightarm": { [_patient, false, false, true, false] call EFUNC(medical_engine,updateBodyPartVisuals); };
|
2021-10-12 08:08:10 +00:00
|
|
|
default { [_patient, false, false, false, true] call EFUNC(medical_engine,updateBodyPartVisuals); };
|
2019-10-08 15:45:09 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-06-24 05:11:56 +00:00
|
|
|
// Reset treatment condition cache for nearby players if we stopped all bleeding
|
|
|
|
if (_amountOf <= 0) then {
|
2019-12-12 16:25:21 +00:00
|
|
|
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;
|
|
|
|
};
|