2015-02-08 09:01:32 +00:00
|
|
|
/*
|
|
|
|
* Author: Glowbal
|
|
|
|
* Advanced HandleDamage EH function.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Unit That Was Hit <OBJECT>
|
|
|
|
* 1: Name Of Hit Selection <STRING>
|
|
|
|
* 2: Amount Of Damage <NUMBER>
|
|
|
|
* 3: Shooter <OBJECT>
|
|
|
|
* 4: Projectile <STRING>
|
2016-06-10 02:26:50 +00:00
|
|
|
* 5: Hit part index of the hit point <NUMBER>
|
|
|
|
* 6: Shooter? <OBJECT>
|
|
|
|
* 7: Current damage to be returned <NUMBER>
|
2015-02-08 09:01:32 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
2015-08-22 14:25:10 +00:00
|
|
|
* None
|
2015-02-08 09:01:32 +00:00
|
|
|
*
|
2017-06-08 13:31:51 +00:00
|
|
|
* Example:
|
|
|
|
* [bob, "leg", 2, kevin, "bullet", 2, kevin, 2] call ACE_medical_fnc_handleDamage_advanced
|
|
|
|
*
|
2015-02-08 09:01:32 +00:00
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
2015-02-13 21:58:48 +00:00
|
|
|
#include "script_component.hpp"
|
2015-02-08 09:01:32 +00:00
|
|
|
|
2016-09-03 20:00:45 +00:00
|
|
|
params ["_unit", "_selectionName", "_amountOfDamage", "_sourceOfDamage", "_typeOfProjectile", "_hitPointNumber", "", "_newDamage"];
|
|
|
|
|
|
|
|
// For burning damage we will get a ton of very small hits of damage; they are too small to create any wounds
|
|
|
|
// Save them up in a variable and run when it is over a noticable amount
|
2015-02-13 21:55:13 +00:00
|
|
|
|
2016-09-03 20:00:45 +00:00
|
|
|
if ((_typeOfProjectile == "") && {_newDamage < 0.15} && {
|
|
|
|
_newDamage = _newDamage + (_unit getVariable [QGVAR(trivialDamage), 0]);
|
2017-06-08 13:31:51 +00:00
|
|
|
if (_newDamage > 0.15) then {
|
2016-09-03 20:00:45 +00:00
|
|
|
// if the new sum is large enough, reset variable and continue with it added in
|
|
|
|
_unit setVariable [QGVAR(trivialDamage), 0];
|
2017-06-08 13:31:51 +00:00
|
|
|
false
|
2016-09-03 20:00:45 +00:00
|
|
|
} else {
|
|
|
|
// otherwise just save the new sum into the variable and exit
|
|
|
|
_unit setVariable [QGVAR(trivialDamage), _newDamage];
|
|
|
|
true // exit
|
|
|
|
};
|
|
|
|
}) exitWith {};
|
2016-06-10 02:26:50 +00:00
|
|
|
|
2016-06-13 00:34:56 +00:00
|
|
|
private _part = [_selectionName] call FUNC(selectionNameToNumber);
|
2015-11-30 16:14:05 +00:00
|
|
|
if (_part < 0) exitWith {};
|
2015-02-21 22:14:21 +00:00
|
|
|
|
2016-06-13 00:34:56 +00:00
|
|
|
private _hitPoints = ["HitHead", "HitBody", "HitLeftArm", "HitRightArm", "HitLeftLeg", "HitRightLeg"];
|
2015-02-28 18:22:46 +00:00
|
|
|
// Sorting out the damage
|
2016-06-13 00:34:56 +00:00
|
|
|
private _damageBodyParts = _unit getVariable [QGVAR(bodyPartStatus), [0,0,0,0,0,0]];
|
2015-04-17 21:15:41 +00:00
|
|
|
|
2015-02-28 18:22:46 +00:00
|
|
|
_damageBodyParts set [_part, (_damageBodyParts select _part) + _newDamage];
|
2015-11-30 16:27:09 +00:00
|
|
|
_unit setVariable [QGVAR(bodyPartStatus), _damageBodyParts, true];
|
2015-04-11 20:31:17 +00:00
|
|
|
|
2016-06-13 00:34:56 +00:00
|
|
|
private _typeOfDamage = [_typeOfProjectile] call FUNC(getTypeOfDamage);
|
2015-08-26 08:04:51 +00:00
|
|
|
|
2015-08-29 10:59:11 +00:00
|
|
|
[_unit, _selectionName, _newDamage, _typeOfProjectile, _typeOfDamage] call FUNC(handleDamage_assignWounds);
|
2015-02-03 20:48:08 +00:00
|
|
|
|
2015-03-21 09:55:40 +00:00
|
|
|
// TODO Disabled until implemented fully
|
|
|
|
//if (GVAR(enableAirway)) then {
|
|
|
|
// [_unit,_selectionName,_newDamage,_sourceOfDamage, _typeOfDamage] call FUNC(handleDamage_airway);
|
|
|
|
//};
|
|
|
|
//if (GVAR(enableFractures)) then {
|
|
|
|
// [_unit,_selectionName,_newDamage,_sourceOfDamage, _typeOfDamage] call FUNC(handleDamage_fractures);
|
|
|
|
//};
|
|
|
|
//if (GVAR(enableInternalBleeding)) then {
|
|
|
|
// [_unit,_selectionName,_newDamage,_sourceOfDamage, _typeOfDamage] call FUNC(handleDamage_internalInjuries);
|
|
|
|
//};
|
2015-02-21 22:14:21 +00:00
|
|
|
|
2015-11-30 16:27:09 +00:00
|
|
|
if (alive _unit && {!(_unit getVariable ["ACE_isUnconscious", false])}) then {
|
2015-03-05 17:42:32 +00:00
|
|
|
// If it reaches this, we can assume that the hit did not kill this unit, as this function is called 3 frames after the damage has been passed.
|
|
|
|
if ([_unit, _part, if (_part > 1) then {_newDamage * 1.3} else {_newDamage * 2}] call FUNC(determineIfFatal)) then {
|
2015-03-07 12:57:36 +00:00
|
|
|
[_unit] call FUNC(setUnconscious);
|
2015-03-05 17:42:32 +00:00
|
|
|
};
|
2015-02-21 22:14:21 +00:00
|
|
|
};
|