2016-07-15 10:23:47 +00:00
|
|
|
/*
|
|
|
|
* Author: Glowbal
|
|
|
|
* Handles the bandage of a patient.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: The patient <OBJECT>
|
2016-10-07 02:21:01 +00:00
|
|
|
* 1: Treatment class name <STRING>
|
2016-10-05 22:54:57 +00:00
|
|
|
* 2: Body part <STRING>
|
2016-07-15 10:23:47 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* Succesful treatment started <BOOL>
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2018-07-25 08:35:04 +00:00
|
|
|
params ["_target", "_bandage", "_bodyPart"];
|
2016-07-15 10:23:47 +00:00
|
|
|
|
2016-10-05 22:54:57 +00:00
|
|
|
private _partIndex = ALL_BODY_PARTS find toLower _bodyPart;
|
2016-12-10 14:39:03 +00:00
|
|
|
if (_partIndex < 0) exitWith { false };
|
2016-07-15 10:23:47 +00:00
|
|
|
|
|
|
|
private _openWounds = _target getVariable [QEGVAR(medical,openWounds), []];
|
2016-12-10 14:39:03 +00:00
|
|
|
if (_openWounds isEqualTo []) exitWith { false };
|
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
|
2018-07-25 08:35:04 +00:00
|
|
|
private _targetWound = [_target, _bandage, _partIndex] call FUNC(findMostEffectiveWound);
|
|
|
|
_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
|
2018-07-25 08:35:04 +00:00
|
|
|
private _amountOf = _wound select 3;
|
|
|
|
private _impact = _effectiveness min _amountOf;
|
|
|
|
_wound set [3, _amountOf - _impact];
|
|
|
|
_openWounds set [_woundIndex, _wound];
|
2016-07-15 10:23:47 +00:00
|
|
|
|
|
|
|
_target setVariable [QEGVAR(medical,openWounds), _openWounds, true];
|
|
|
|
|
|
|
|
// Handle the reopening of bandaged wounds
|
2016-12-15 13:51:24 +00:00
|
|
|
if (_impact > 0 && {EGVAR(medical,advancedBandages) && {EGVAR(medical,woundReopening)}}) then {
|
2018-07-25 08:35:04 +00:00
|
|
|
[_target, _impact, _partIndex, _woundIndex, _wound, _bandage] call FUNC(handleBandageOpening);
|
2016-07-15 10:23:47 +00:00
|
|
|
};
|
|
|
|
|
2016-10-05 22:54:57 +00:00
|
|
|
true
|