2015-08-22 14:25:10 +00:00
|
|
|
/*
|
|
|
|
* Author: Glowbal
|
|
|
|
* Determine If Fatal
|
2015-02-28 18:22:46 +00:00
|
|
|
*
|
2015-08-22 14:25:10 +00:00
|
|
|
* Arguments:
|
|
|
|
* 0: Unit <OBJECT>
|
|
|
|
* 1: Part <NUMBER>
|
|
|
|
* 2: with Damage <NUMBER> (default: 0)
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
2017-06-08 13:31:51 +00:00
|
|
|
* Example:
|
|
|
|
* [bob, 2, 5] call ACE_medical_fnc_determineIfFatal
|
|
|
|
*
|
2015-08-22 14:25:10 +00:00
|
|
|
* Public: No
|
2015-02-28 18:22:46 +00:00
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-09-14 19:13:58 +00:00
|
|
|
#define INCREASE_CHANCE_HEAD 0.05
|
|
|
|
#define INCREASE_CHANCE_TORSO 0.03
|
|
|
|
#define INCREASE_CHANGE_LIMB 0.01
|
|
|
|
|
|
|
|
#define CHANGE_FATAL_HEAD 0.7
|
|
|
|
#define CHANGE_FATAL_TORSO 0.6
|
|
|
|
#define CHANGE_FATAL_LIMB 0.1
|
|
|
|
|
2015-08-22 14:25:10 +00:00
|
|
|
params ["_unit", "_part", ["_withDamage", 0]];
|
2015-02-28 18:22:46 +00:00
|
|
|
|
2015-11-30 16:14:05 +00:00
|
|
|
if (!alive _unit) exitWith {true};
|
|
|
|
if ((vehicle _unit != _unit) && {!alive (vehicle _unit)}) exitWith { true };
|
2016-02-16 04:23:04 +00:00
|
|
|
if (_part < 0 || _part > 5) exitWith {false};
|
2015-02-28 18:22:46 +00:00
|
|
|
|
|
|
|
// Find the correct Damage threshold for unit.
|
2016-06-13 00:34:56 +00:00
|
|
|
private _damageThreshold = [1,1,1];
|
2017-06-02 16:21:57 +00:00
|
|
|
if ([_unit, GVAR(remoteControlledAI)] call EFUNC(common,isPlayer)) then {
|
2015-11-30 16:27:09 +00:00
|
|
|
_damageThreshold =_unit getVariable[QGVAR(unitDamageThreshold), [GVAR(playerDamageThreshold), GVAR(playerDamageThreshold), GVAR(playerDamageThreshold) * 1.7]];
|
2015-02-28 18:22:46 +00:00
|
|
|
} else {
|
2015-11-30 16:27:09 +00:00
|
|
|
_damageThreshold =_unit getVariable[QGVAR(unitDamageThreshold), [GVAR(AIDamageThreshold), GVAR(AIDamageThreshold), GVAR(AIDamageThreshold) * 1.7]];
|
2015-02-28 18:22:46 +00:00
|
|
|
};
|
2015-09-14 19:13:58 +00:00
|
|
|
_damageThreshold params ["_thresholdHead", "_thresholdTorso", "_thresholdLimbs"];
|
2015-02-28 18:22:46 +00:00
|
|
|
|
2016-06-13 00:34:56 +00:00
|
|
|
private _damageBodyPart = ((_unit getVariable [QGVAR(bodyPartStatus),[0, 0, 0, 0, 0, 0]]) select _part) + _withDamage;
|
2015-02-28 18:22:46 +00:00
|
|
|
|
|
|
|
// Check if damage to body part is higher as damage head
|
2015-11-30 16:14:05 +00:00
|
|
|
if (_part == 0) exitWith {
|
2016-06-13 00:34:56 +00:00
|
|
|
private _chanceFatal = CHANGE_FATAL_HEAD + ((INCREASE_CHANCE_HEAD * (_damageBodyPart - _thresholdHead)) * 10);
|
2015-09-14 19:13:58 +00:00
|
|
|
(_damageBodyPart >= _thresholdHead && {(_chanceFatal >= random(1))});
|
2015-02-28 18:22:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Check if damage to body part is higher as damage torso
|
2015-11-30 16:14:05 +00:00
|
|
|
if (_part == 1) exitWith {
|
2016-06-13 00:34:56 +00:00
|
|
|
private _chanceFatal = CHANGE_FATAL_TORSO + ((INCREASE_CHANCE_TORSO * (_damageBodyPart - _thresholdTorso)) * 10);
|
2015-09-14 19:13:58 +00:00
|
|
|
(_damageBodyPart >= _thresholdTorso && {(_chanceFatal >= random(1))});
|
2015-02-28 18:22:46 +00:00
|
|
|
};
|
|
|
|
// Check if damage to body part is higher as damage limbs
|
2015-09-14 19:13:58 +00:00
|
|
|
// We use a slightly lower decrease for limbs, as we want any injuries done to those to be less likely to be fatal compared to head shots or torso.
|
2016-06-13 00:34:56 +00:00
|
|
|
private _chanceFatal = CHANGE_FATAL_LIMB + ((INCREASE_CHANGE_LIMB * (_damageBodyPart - _thresholdLimbs)) * 10);
|
2015-09-14 19:13:58 +00:00
|
|
|
(_damageBodyPart >= _thresholdLimbs && {(_chanceFatal >= random(1))});
|