ACE3/addons/medical/functions/fnc_handleDamage.sqf

84 lines
2.5 KiB
Plaintext
Raw Normal View History

2015-02-03 19:09:25 +00:00
/*
* Author: KoffeinFlummi, Glowbal
2015-02-03 19:09:25 +00:00
* Main HandleDamage EH function.
*
2015-02-03 19:09:25 +00:00
* Arguments:
* 0: Unit That Was Hit <OBJECT>
* 1: Name Of Hit Selection <STRING>
* 2: Amount Of Damage <NUMBER>
* 3: Shooter <OBJECT>
* 4: Projectile <OBJECT/STRING>
*
* Return Value:
* Damage To Be Inflicted <NUMBER>
*
* Public: No
*/
#include "script_component.hpp"
private ["_unit", "_selection", "_damage", "_shooter", "_projectile", "_damageReturn", "_typeOfDamage"];
2015-02-06 12:47:17 +00:00
_unit = _this select 0;
_selection = _this select 1;
_damage = _this select 2;
_shooter = _this select 3;
_projectile = _this select 4;
2015-02-06 12:47:17 +00:00
if !(local _unit) exitWith {nil};
if (typeName _projectile == "OBJECT") then {
_projectile = typeOf _projectile;
_this set [4, _projectile];
};
2015-02-06 12:47:17 +00:00
// If the damage is being weird, we just tell it to fuck off.
if !(_selection in (GVAR(SELECTIONS) + [""])) exitWith {0};
2015-02-06 12:47:17 +00:00
_damageReturn = _damage;
if (GVAR(level) < 2) then {
_damageReturn = _this call FUNC(handleDamage_basic);
2015-02-03 19:09:25 +00:00
};
2015-03-06 21:54:44 +00:00
if (GVAR(level) >= 2) then {
if !([_unit] call FUNC(hasMedicalEnabled)) exitwith {
// Because of the config changes, we cannot properly disable the medical system for a unit.
// lets use basic for the time being..
2015-04-04 14:27:44 +00:00
_damageReturn = _this call FUNC(handleDamage_basic);
};
_newDamage = _this call FUNC(handleDamage_caching);
2015-02-28 18:28:05 +00:00
if (_damageReturn > 0.9) then {
_typeOfDamage = [_projectile] call FUNC(getTypeOfDamage);
_typeIndex = (GVAR(allAvailableDamageTypes) find _typeOfDamage);
_minLethalDamage = 0.01;
if (_typeIndex >= 0) then {
_minLethalDamage = GVAR(minLethalDamages) select _typeIndex;
};
2015-04-04 14:27:44 +00:00
if ((_minLethalDamage <= _newDamage) && {[_unit, [_selection] call FUNC(selectionNameToNumber), _newDamage] call FUNC(determineIfFatal)} && {_selection in ["", "head", "body"]}) then {
if ([_unit] call FUNC(setDead)) then {
_damageReturn = 1;
2015-04-03 19:49:46 +00:00
} else {
_damageReturn = 0.89;
};
} else {
_damageReturn = 0.89;
};
2015-02-28 18:28:05 +00:00
};
};
[_unit] call FUNC(addToInjuredCollection);
2015-04-04 14:27:44 +00:00
if ((_unit getVariable [QGVAR(preventInstaDeath), GVAR(preventInstaDeath)]) && {_damageReturn >= 0.9} && {_selection in ["", "head", "body"]}) exitWith {
2015-02-10 12:33:40 +00:00
if (vehicle _unit != _unit and {damage _vehicle >= 1}) then {
// @todo
// [_unit] call FUNC(unload);
};
2015-04-04 14:27:44 +00:00
[_unit] call FUNC(setDead);
2015-02-10 12:33:40 +00:00
0.89
};
2015-02-03 19:09:25 +00:00
_damageReturn