2015-02-21 20:10:57 +00:00
|
|
|
/*
|
|
|
|
* Author: Glowbal
|
|
|
|
* Handles the bandage of a patient.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: The patient <OBJECT>
|
|
|
|
* 1: Treatment classname <STRING>
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* Succesful treatment started <BOOL>
|
|
|
|
*
|
2015-04-05 17:26:33 +00:00
|
|
|
* Public: No
|
2015-02-21 20:10:57 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-08-22 17:47:23 +00:00
|
|
|
private ["_openWounds", "_config", "_effectiveness","_mostEffectiveInjury", "_mostEffectiveSpot", "_woundEffectivenss", "_mostEffectiveInjury", "_impact", "_exit", "_classID", "_effectivenessFound", "_className", "_hitPoints", "_hitSelections", "_point", "_woundTreatmentConfig"];
|
|
|
|
params ["_target", "_bandage", "_selectionName", ["_specificClass", -1]];
|
2015-02-21 20:10:57 +00:00
|
|
|
|
|
|
|
// Ensure it is a valid bodypart
|
|
|
|
_part = [_selectionName] call FUNC(selectionNameToNumber);
|
2015-08-22 17:47:23 +00:00
|
|
|
if (_part < 0) exitwith {false};
|
2015-02-21 20:10:57 +00:00
|
|
|
|
|
|
|
// Get the open wounds for this unit
|
|
|
|
_openWounds = _target getvariable [QGVAR(openWounds), []];
|
2015-08-22 17:47:23 +00:00
|
|
|
if (count _openWounds == 0) exitwith {false}; // nothing to do here!
|
2015-02-21 20:10:57 +00:00
|
|
|
|
|
|
|
// Get the default effectiveness for the used bandage
|
|
|
|
_config = (ConfigFile >> "ACE_Medical_Advanced" >> "Treatment" >> "Bandaging");
|
|
|
|
_effectiveness = getNumber (_config >> "effectiveness");
|
|
|
|
if (isClass (_config >> _bandage)) then {
|
|
|
|
_config = (_config >> _bandage);
|
|
|
|
if (isNumber (_config >> "effectiveness")) then { _effectiveness = getNumber (_config >> "effectiveness");};
|
|
|
|
};
|
|
|
|
|
|
|
|
// Figure out which injury for this bodypart is the best choice to bandage
|
|
|
|
_mostEffectiveSpot = 0;
|
2015-03-09 21:23:37 +00:00
|
|
|
_effectivenessFound = -1;
|
2015-02-21 20:10:57 +00:00
|
|
|
_mostEffectiveInjury = _openWounds select 0;
|
2015-03-09 19:03:17 +00:00
|
|
|
_exit = false;
|
2015-02-21 20:10:57 +00:00
|
|
|
{
|
2015-08-26 08:04:51 +00:00
|
|
|
_x params ["", "_classID", "_partX"];
|
2015-09-05 10:59:09 +00:00
|
|
|
TRACE_2("OPENWOUND: ", _target, _x);
|
2015-02-21 20:10:57 +00:00
|
|
|
// Only parse injuries that are for the selected bodypart.
|
2015-08-22 17:47:23 +00:00
|
|
|
if (_partX == _part) then {
|
2015-02-21 20:10:57 +00:00
|
|
|
_woundEffectivenss = _effectiveness;
|
|
|
|
|
2015-03-03 22:26:54 +00:00
|
|
|
// Select the classname from the wound classname storage
|
|
|
|
_className = GVAR(woundClassNames) select _classID;
|
|
|
|
// Check if this wound type has attributes specified for the used bandage
|
|
|
|
if (isClass (_config >> _className)) then {
|
2015-02-21 20:10:57 +00:00
|
|
|
// Collect the effectiveness from the used bandage for this wound type
|
2015-03-03 22:26:54 +00:00
|
|
|
_woundTreatmentConfig = (_config >> _className);
|
2015-02-21 20:10:57 +00:00
|
|
|
if (isNumber (_woundTreatmentConfig >> "effectiveness")) then {
|
|
|
|
_woundEffectivenss = getNumber (_woundTreatmentConfig >> "effectiveness");
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2015-09-05 10:59:09 +00:00
|
|
|
TRACE_2("Wound classes: ", _specificClass, _classID);
|
2015-03-09 19:03:17 +00:00
|
|
|
if (_specificClass == _classID) exitwith {
|
|
|
|
_effectivenessFound = _woundEffectivenss;
|
|
|
|
_mostEffectiveSpot = _foreachIndex;
|
|
|
|
_mostEffectiveInjury = _x;
|
|
|
|
_exit = true;
|
|
|
|
};
|
|
|
|
|
2015-02-21 20:10:57 +00:00
|
|
|
// Check if this is the currently most effective found.
|
|
|
|
if (_woundEffectivenss * ((_x select 4) * (_x select 3)) > _effectivenessFound * ((_mostEffectiveInjury select 4) * (_mostEffectiveInjury select 3))) then {
|
|
|
|
_effectivenessFound = _woundEffectivenss;
|
|
|
|
_mostEffectiveSpot = _foreachIndex;
|
|
|
|
_mostEffectiveInjury = _x;
|
|
|
|
};
|
|
|
|
};
|
2015-03-09 19:03:17 +00:00
|
|
|
if (_exit) exitwith {};
|
2015-08-22 17:47:23 +00:00
|
|
|
} foreach _openWounds;
|
2015-02-21 20:10:57 +00:00
|
|
|
|
2015-03-09 21:23:37 +00:00
|
|
|
if (_effectivenessFound == -1) exitwith {}; // Seems everything is patched up on this body part already..
|
|
|
|
|
2015-02-21 20:10:57 +00:00
|
|
|
|
2015-02-28 10:41:27 +00:00
|
|
|
// TODO refactor this part
|
2015-02-21 20:10:57 +00:00
|
|
|
// Find the impact this bandage has and reduce the amount this injury is present
|
|
|
|
_impact = if ((_mostEffectiveInjury select 3) >= _effectivenessFound) then {_effectivenessFound} else { (_mostEffectiveInjury select 3) };
|
2015-04-05 17:26:33 +00:00
|
|
|
_mostEffectiveInjury set [ 3, ((_mostEffectiveInjury select 3) - _impact) max 0];
|
2015-02-28 19:48:34 +00:00
|
|
|
_openWounds set [_mostEffectiveSpot, _mostEffectiveInjury];
|
2015-02-28 10:41:27 +00:00
|
|
|
|
2015-04-01 18:03:44 +00:00
|
|
|
_target setvariable [QGVAR(openWounds), _openWounds, !USE_WOUND_EVENT_SYNC];
|
2015-02-21 20:10:57 +00:00
|
|
|
|
2015-04-01 18:03:44 +00:00
|
|
|
if (USE_WOUND_EVENT_SYNC) then {
|
2015-04-05 17:26:33 +00:00
|
|
|
["medical_propagateWound", [_target, _mostEffectiveInjury]] call EFUNC(common,globalEvent);
|
2015-04-01 18:03:44 +00:00
|
|
|
};
|
2015-02-21 20:10:57 +00:00
|
|
|
// Handle the reopening of bandaged wounds
|
2015-04-05 17:26:33 +00:00
|
|
|
if (_impact > 0 && {GVAR(enableAdvancedWounds)}) then {
|
2015-04-20 20:00:11 +00:00
|
|
|
[_target, _impact, _part, _mostEffectiveSpot, _mostEffectiveInjury, _bandage] call FUNC(handleBandageOpening);
|
2015-02-21 20:10:57 +00:00
|
|
|
};
|
|
|
|
|
2015-09-29 00:08:07 +00:00
|
|
|
// If all wounds to a body part have been bandaged, reset damage to that body part to zero
|
|
|
|
// so that the body part functions normally and blood is removed from the uniform.
|
|
|
|
// Arma combines left and right arms into a single body part (HitHands), same with left and right legs (HitLegs).
|
|
|
|
// Arms are actually hands.
|
2015-09-29 10:36:36 +00:00
|
|
|
if (GVAR(healHitPointAfterAdvBandage)) then {
|
2015-09-29 00:08:07 +00:00
|
|
|
private["_currentWounds", "_headWounds", "_bodyWounds", "_legsWounds", "_armWounds"];
|
|
|
|
|
|
|
|
// Get the list of the wounds the target is currently suffering from.
|
2015-09-30 10:17:54 +00:00
|
|
|
_currentWounds = _target getVariable [QGVAR(openWounds), []];
|
2015-09-29 00:08:07 +00:00
|
|
|
|
|
|
|
// Tally of unbandaged wounds to each body part.
|
|
|
|
_headWounds = 0;
|
|
|
|
_bodyWounds = 0;
|
|
|
|
_legsWounds = 0;
|
|
|
|
_armWounds = 0;
|
|
|
|
|
|
|
|
// Loop through all current wounds and add up the number of unbandaged wounds on each body part.
|
|
|
|
{
|
2015-09-29 10:19:49 +00:00
|
|
|
_x params ["", "", "_bodyPart", "_numOpenWounds", "_bloodLoss"];
|
|
|
|
|
2015-10-01 00:27:40 +00:00
|
|
|
// Use switch/case for early termination if wounded limb is found before all six are checked.
|
|
|
|
// Multiplying wounds by blood loss will either increment the wound count by
|
|
|
|
// some number (only care if greater than zero) or it will return zero indicating
|
|
|
|
// the body part is still undamaged.
|
|
|
|
switch (_bodyPart) do {
|
|
|
|
// Head
|
|
|
|
case 0: {
|
|
|
|
_headWounds = _headWounds + (_numOpenWounds * _bloodLoss);
|
|
|
|
};
|
2015-09-29 10:36:36 +00:00
|
|
|
|
2015-10-01 00:27:40 +00:00
|
|
|
// Body
|
|
|
|
case 1: {
|
|
|
|
_bodyWounds = _bodyWounds + (_numOpenWounds * _bloodLoss);
|
|
|
|
};
|
2015-09-29 10:36:36 +00:00
|
|
|
|
2015-10-01 00:27:40 +00:00
|
|
|
// Left Arm
|
|
|
|
case 2: {
|
|
|
|
_armWounds = _armWounds + (_numOpenWounds * _bloodLoss);
|
|
|
|
};
|
2015-09-29 10:36:36 +00:00
|
|
|
|
2015-10-01 00:27:40 +00:00
|
|
|
// Right Arm
|
|
|
|
case 3: {
|
|
|
|
_armWounds = _armWounds + (_numOpenWounds * _bloodLoss);
|
|
|
|
};
|
2015-09-29 10:36:36 +00:00
|
|
|
|
2015-10-01 00:27:40 +00:00
|
|
|
// Left Leg
|
|
|
|
case 4: {
|
|
|
|
_legsWounds = _legsWounds + (_numOpenWounds * _bloodLoss);
|
|
|
|
};
|
2015-09-29 10:36:36 +00:00
|
|
|
|
2015-10-01 00:27:40 +00:00
|
|
|
// Right Leg
|
|
|
|
case 5: {
|
|
|
|
_legsWounds = _legsWounds + (_numOpenWounds * _bloodLoss);
|
|
|
|
};
|
2015-09-29 10:36:36 +00:00
|
|
|
};
|
2015-09-30 10:17:54 +00:00
|
|
|
} forEach _currentWounds;
|
2015-09-29 00:08:07 +00:00
|
|
|
|
|
|
|
// Any body part that has no wounds is healed to full health
|
2015-09-29 10:36:36 +00:00
|
|
|
if (_headWounds == 0) then {
|
|
|
|
_target setHitPointDamage ["hitHead", 0.0];
|
|
|
|
};
|
|
|
|
|
|
|
|
if (_bodyWounds == 0) then {
|
|
|
|
_target setHitPointDamage ["hitBody", 0.0];
|
|
|
|
};
|
|
|
|
|
|
|
|
if (_armWounds == 0) then {
|
|
|
|
_target setHitPointDamage ["hitHands", 0.0];
|
|
|
|
};
|
|
|
|
|
|
|
|
if (_legsWounds == 0) then {
|
|
|
|
_target setHitPointDamage ["hitLegs", 0.0];
|
|
|
|
};
|
2015-02-21 20:10:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
true;
|