Added support for bandaging a specific injury class on a selection

This commit is contained in:
Glowbal 2015-03-09 20:03:17 +01:00
parent fc1a52d48b
commit f6fbef980a
2 changed files with 14 additions and 2 deletions

View File

@ -23,11 +23,12 @@ _target = _this select 1;
_selectionName = _this select 2;
_className = _this select 3;
_items = _this select 4;
_specificSpot = if (count _this > 5) then {_this select 5} else {-1};
if (count _items == 0) exitwith {};
if ([_caller, _target, _items] call FUNC(useItems)) then {
[[_target, _className], QUOTE(DFUNC(treatmentBandageLocal)), _target] call EFUNC(common,execRemoteFnc); /* TODO Replace by event system */
[[_target, _className, _selectionName, _specificSpot], QUOTE(DFUNC(treatmentBandageLocal)), _target] call EFUNC(common,execRemoteFnc); /* TODO Replace by event system */
{
if (_x != "") then {
[_target, _x] call FUNC(addToTriageCard);

View File

@ -15,9 +15,11 @@
#include "script_component.hpp"
private ["_target", "_bandage", "_part", "_openWounds", "_config", "_effectiveness","_mostEffectiveInjury", "_mostEffectiveSpot", "_woundEffectivenss", "_mostEffectiveInjury", "_impact"];
private ["_target", "_bandage", "_part", "_selectionName", "_openWounds", "_config", "_effectiveness","_mostEffectiveInjury", "_mostEffectiveSpot", "_woundEffectivenss", "_mostEffectiveInjury", "_impact", "_exit"];
_target = _this select 0;
_bandage = _this select 1;
_selectionName = _this select 2;
_specificClass = if (count _this > 3) then {_this select 3} else { -1 };
// Ensure it is a valid bodypart
_part = [_selectionName] call FUNC(selectionNameToNumber);
@ -39,6 +41,7 @@ if (isClass (_config >> _bandage)) then {
_mostEffectiveSpot = 0;
_effectivenessFound = 0;
_mostEffectiveInjury = _openWounds select 0;
_exit = false;
{
// Only parse injuries that are for the selected bodypart.
if (_x select 2 == _part) then {
@ -56,6 +59,13 @@ _mostEffectiveInjury = _openWounds select 0;
};
};
if (_specificClass == _classID) exitwith {
_effectivenessFound = _woundEffectivenss;
_mostEffectiveSpot = _foreachIndex;
_mostEffectiveInjury = _x;
_exit = true;
};
// 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;
@ -63,6 +73,7 @@ _mostEffectiveInjury = _openWounds select 0;
_mostEffectiveInjury = _x;
};
};
if (_exit) exitwith {};
}foreach _openWounds;
if (_effectivenessFound == 0) exitwith {}; // Seems everything is patched up on this body part already..