2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2018-07-25 08:35:04 +00:00
|
|
|
/*
|
2023-06-24 05:11:56 +00:00
|
|
|
* Author: kymckay
|
2018-07-25 08:35:04 +00:00
|
|
|
* Calculates the time to bandage a wound based on it's size, the patient and the medic.
|
|
|
|
*
|
|
|
|
* Arguments:
|
2019-06-03 15:31:46 +00:00
|
|
|
* 0: Medic <OBJECT>
|
|
|
|
* 1: Patient <OBJECT>
|
|
|
|
* 2: Body Part <STRING>
|
|
|
|
* 3: Treatment <STRING>
|
2018-07-25 08:35:04 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
2019-06-03 15:31:46 +00:00
|
|
|
* Treatment Time <NUMBER>
|
|
|
|
*
|
|
|
|
* Example:
|
2023-09-10 06:06:15 +00:00
|
|
|
* [player, cursorTarget, "head", "FieldDressing"] call ace_medical_treatment_fnc_getBandageTime
|
2018-07-25 08:35:04 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
2023-06-24 05:11:56 +00:00
|
|
|
params ["_medic", "_patient", "_bodyPart", "_bandage"];
|
2018-07-25 08:35:04 +00:00
|
|
|
|
2024-03-07 21:08:13 +00:00
|
|
|
private _partIndex = ALL_BODY_PARTS find toLowerANSI _bodyPart;
|
2019-06-16 16:04:51 +00:00
|
|
|
if (_partIndex < 0) exitWith { ERROR_1("invalid partIndex - %1",_this); 0 };
|
2018-07-25 08:35:04 +00:00
|
|
|
|
2023-09-10 06:06:15 +00:00
|
|
|
private _targetWounds = [_patient, _bandage, _bodyPart] call FUNC(findMostEffectiveWounds);
|
|
|
|
TRACE_1("findMostEffectiveWounds",_targetWounds);
|
2018-07-25 08:35:04 +00:00
|
|
|
|
2023-09-10 06:06:15 +00:00
|
|
|
private _woundCount = count _targetWounds;
|
2018-07-25 08:35:04 +00:00
|
|
|
|
2023-09-10 06:06:15 +00:00
|
|
|
// Everything is patched up on this body part already
|
|
|
|
if (_woundCount == 0) exitWith {0};
|
2018-07-25 08:35:04 +00:00
|
|
|
|
|
|
|
// Base bandage time is based on wound size and remaining percentage
|
2023-09-10 06:06:15 +00:00
|
|
|
private _bandageTimesArray = [BANDAGE_TIME_S, BANDAGE_TIME_M, BANDAGE_TIME_L];
|
|
|
|
private _bandageTime = 0;
|
2019-06-16 16:04:51 +00:00
|
|
|
|
2023-09-10 06:06:15 +00:00
|
|
|
{
|
|
|
|
private _wound = _x;
|
|
|
|
_wound params ["_classID", "", "_amountOf"];
|
|
|
|
_y params ["_effectiveness", "", "_impact"];
|
|
|
|
private _category = (_classID % 10);
|
|
|
|
|
|
|
|
// Base bandage time is based on wound size and remaining percentage
|
|
|
|
private _woundTime = _bandageTimesArray select _category;
|
|
|
|
|
|
|
|
// Scale bandage time based on amount left and effectiveness (less time if only a little wound left)
|
|
|
|
// Basic bandage treatment will have a very high effectiveness and can be ignored
|
|
|
|
if (GVAR(advancedBandages != 0)) then {
|
|
|
|
_woundTime = _woundTime * linearConversion [0, _effectiveness, _impact, 0.666, 1, true];
|
|
|
|
};
|
|
|
|
|
|
|
|
_bandageTime = _bandageTime + _woundTime;
|
|
|
|
} forEach _targetWounds;
|
2018-07-25 08:35:04 +00:00
|
|
|
|
|
|
|
// Medics are more practised at applying bandages
|
|
|
|
if ([_medic] call FUNC(isMedic)) then {
|
|
|
|
_bandageTime = _bandageTime + BANDAGE_TIME_MOD_MEDIC;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Bandaging yourself requires more work
|
|
|
|
if (_medic == _patient) then {
|
|
|
|
_bandageTime = _bandageTime + BANDAGE_TIME_MOD_SELF;
|
|
|
|
};
|
|
|
|
|
2023-09-10 06:06:15 +00:00
|
|
|
// Bandaging multiple injuries doesn't require opening a new bandage each time
|
|
|
|
if (_woundCount > 1) then {
|
|
|
|
_bandageTime = _bandageTime - (2 * _woundCount);
|
|
|
|
};
|
|
|
|
|
2019-06-16 16:04:51 +00:00
|
|
|
TRACE_1("",_bandageTime);
|
2018-07-25 08:35:04 +00:00
|
|
|
// Nobody can bandage instantly
|
2019-06-16 16:04:51 +00:00
|
|
|
_bandageTime max 2.25
|