Only call 'handleIncapacitation' when it makes sense

* Minor injuries should not trigger incapacitation
This commit is contained in:
ulteq 2016-12-14 21:02:24 +01:00
parent 964711a38b
commit e817e13cfd
2 changed files with 12 additions and 0 deletions

View File

@ -40,6 +40,7 @@ call compile _extensionOutput;
// todo: Make the pain and bleeding calculations part of the extension again // todo: Make the pain and bleeding calculations part of the extension again
private _painLevel = 0; private _painLevel = 0;
private _critialDamage = false;
private _bodyPartDamage = _unit getVariable [QEGVAR(medical,bodyPartDamage), [0,0,0,0,0,0]]; private _bodyPartDamage = _unit getVariable [QEGVAR(medical,bodyPartDamage), [0,0,0,0,0,0]];
{ {
_x params ["", "_woundClassIDToAdd", "_bodyPartNToAdd", "", "_bleeding"]; _x params ["", "_woundClassIDToAdd", "_bodyPartNToAdd", "", "_bleeding"];
@ -63,6 +64,9 @@ private _bodyPartDamage = _unit getVariable [QEGVAR(medical,bodyPartDamage), [0,
private _pain = ((GVAR(woundsData) select _woundClassIDToAdd) select 3) * _painfullness; private _pain = ((GVAR(woundsData) select _woundClassIDToAdd) select 3) * _painfullness;
_painLevel = _painLevel max _pain; _painLevel = _painLevel max _pain;
if (_bodyPartNToAdd == 0 || {_bodyPartNToAdd == 1 && {_damage > PENETRATION_THRESHOLD}}) then {
_critialDamage = true;
};
#ifdef DEBUG_MODE_FULL #ifdef DEBUG_MODE_FULL
systemChat format["%1, damage: %2, peneration: %3, bleeding: %4, pain: %5", _bodyPart, round(_damage * 100) / 100, _damage > PENETRATION_THRESHOLD, round(_bleeding * 1000) / 1000, round(_pain * 1000) / 1000]; systemChat format["%1, damage: %2, peneration: %3, bleeding: %4, pain: %5", _bodyPart, round(_damage * 100) / 100, _damage > PENETRATION_THRESHOLD, round(_bleeding * 1000) / 1000, round(_pain * 1000) / 1000];
#endif #endif
@ -107,6 +111,8 @@ _unit setVariable [QEGVAR(medical,bodyPartDamage), _bodyPartDamage, true];
// Only update if new wounds have been created // Only update if new wounds have been created
if (count _woundsCreated > 0) then { if (count _woundsCreated > 0) then {
_unit setVariable [QEGVAR(medical,lastUniqueWoundID), _woundID, true]; _unit setVariable [QEGVAR(medical,lastUniqueWoundID), _woundID, true];
};
if (_critialDamage || {_painLevel > PAIN_UNCONSCIOUS}) then {
[_unit] call EFUNC(medical,handleIncapacitation); [_unit] call EFUNC(medical,handleIncapacitation);
}; };

View File

@ -73,6 +73,7 @@ private _openWounds = _unit getVariable [QEGVAR(medical,openWounds), []];
private _woundID = _unit getVariable [QGVAR(lastUniqueWoundID), 1]; private _woundID = _unit getVariable [QGVAR(lastUniqueWoundID), 1];
private _painLevel = 0; private _painLevel = 0;
private _critialDamage = false;
private _bodyPartDamage = _unit getVariable [QEGVAR(medical,bodyPartDamage), [0,0,0,0,0,0]]; private _bodyPartDamage = _unit getVariable [QEGVAR(medical,bodyPartDamage), [0,0,0,0,0,0]];
private _woundsCreated = []; private _woundsCreated = [];
{ {
@ -111,6 +112,9 @@ private _woundsCreated = [];
private _pain = _injuryPain * _painfullness; private _pain = _injuryPain * _painfullness;
_painLevel = _painLevel max _pain; _painLevel = _painLevel max _pain;
if (_bodyPartNToAdd == 0 || {_bodyPartNToAdd == 1 && {_damage > PENETRATION_THRESHOLD}}) then {
_critialDamage = true;
};
#ifdef DEBUG_MODE_FULL #ifdef DEBUG_MODE_FULL
systemChat format["%1, damage: %2, peneration: %3, bleeding: %4, pain: %5", _bodyPart, round(_damage * 100) / 100, _damage > PENETRATION_THRESHOLD, round(_bleeding * 1000) / 1000, round(_pain * 1000) / 1000]; systemChat format["%1, damage: %2, peneration: %3, bleeding: %4, pain: %5", _bodyPart, round(_damage * 100) / 100, _damage > PENETRATION_THRESHOLD, round(_bleeding * 1000) / 1000, round(_pain * 1000) / 1000];
#endif #endif
@ -163,6 +167,8 @@ _unit setVariable [QEGVAR(medical,bodyPartDamage), _bodyPartDamage, true];
// Only update if new wounds have been created // Only update if new wounds have been created
if (count _woundsCreated > 0) then { if (count _woundsCreated > 0) then {
_unit setVariable [QEGVAR(medical,lastUniqueWoundID), _woundID, true]; _unit setVariable [QEGVAR(medical,lastUniqueWoundID), _woundID, true];
};
if (_critialDamage || {_painLevel > PAIN_UNCONSCIOUS}) then {
[_unit] call EFUNC(medical,handleIncapacitation); [_unit] call EFUNC(medical,handleIncapacitation);
}; };