2015-01-18 21:16:35 +00:00
|
|
|
/**
|
|
|
|
* fn_handleDamage.sqf
|
|
|
|
* @Descr: N/A
|
|
|
|
* @Author: Glowbal
|
|
|
|
*
|
|
|
|
* @Arguments: []
|
|
|
|
* @Return:
|
|
|
|
* @PublicAPI: false
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
|
|
|
private ["_unit","_selectionName","_amountOfDamage","_sourceOfDamage", "_typeOfProjectile","_bodyPartn","_newDamage","_typeOfDamage","_caliber", "_hitPointName", "_returnDamage", "_varCheck"];
|
|
|
|
_unit = _this select 0;
|
|
|
|
_selectionName = _this select 1;
|
|
|
|
_amountOfDamage = _this select 2;
|
|
|
|
_sourceOfDamage = _this select 3;
|
|
|
|
_typeOfProjectile = _this select 4;
|
|
|
|
_returnDamage = _amountOfDamage;
|
|
|
|
|
2015-01-22 21:28:04 +00:00
|
|
|
// do not function on non local units
|
|
|
|
if (!local _unit) exitwith {
|
|
|
|
nil;
|
2015-01-20 17:57:33 +00:00
|
|
|
};
|
|
|
|
|
2015-01-18 21:16:35 +00:00
|
|
|
_bodyPartn = [_selectionName] call FUNC(getBodyPartNumber);
|
|
|
|
|
|
|
|
// Check for vehicle crash
|
|
|
|
if (vehicle _unit != _unit && {_bodyPartn < 0} && {isNull _sourceOfDamage} && {_typeOfProjectile == ""} && {_selectionName == ""}) then {
|
|
|
|
if (GVAR(setting_allowVehicleCrashInjuries)) then {
|
|
|
|
_bodyPartn = if (random(1)>=0.5) then { 0 } else { 1 };
|
|
|
|
_typeOfProjectile = "VehicleCrash";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
// If it is not a valid bodyPart number, exit because we cannot do anything with it.
|
|
|
|
if (_bodyPartn < 0) exitwith {0};
|
|
|
|
|
|
|
|
// Most likely taking exessive fire damage. Lets exit.
|
|
|
|
if (isNull _sourceOfDamage && (_selectionName == "head" || isBurning _unit) && _typeOfProjectile == "" && vehicle _unit == _unit) exitwith {
|
|
|
|
0
|
|
|
|
}; // Prefent excessive fire damage
|
|
|
|
|
2015-01-22 22:29:18 +00:00
|
|
|
// Ensure damage is being handled correctly.
|
|
|
|
_newDamage = [_unit, _amountOfDamage, _bodyPartn] call FUNC(getNewDamageBodyPart);
|
|
|
|
[_unit] call FUNC(setDamageBodyPart);
|
|
|
|
|
2015-01-22 21:28:04 +00:00
|
|
|
if ([_unit] call FUNC(hasMedicalEnabled)) then {
|
2015-01-18 21:16:35 +00:00
|
|
|
_returnDamage = 0;
|
|
|
|
if (_amountOfDamage < 0) then {
|
|
|
|
_amountOfDamage = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
// figure out the type of damage so we can use that to determine what injures should be given.
|
|
|
|
_typeOfDamage = [_typeOfProjectile] call FUNC(getTypeOfDamage);
|
|
|
|
|
|
|
|
[_unit, _newDamage, _typeOfDamage, _bodyPartn] call FUNC(onInjury_assignOpenWounds);
|
|
|
|
|
|
|
|
if ((missionNamespace getvariable[QGVAR(setting_AdvancedLevel), 0]) > 0) then {
|
|
|
|
if (GVAR(setting_allowAirwayInjuries)) then {
|
|
|
|
[_unit, _amountOfDamage, _typeOfDamage, _bodyPartn] call FUNC(onInjury_assignAirwayStatus);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
[_unit, _newDamage, _bodyPartn] call FUNC(increasePain);
|
|
|
|
|
|
|
|
if (([_unit, _bodyPartn] call FUNC(determineIfFatal)) || !(alive (vehicle _unit))) then {
|
|
|
|
[_unit] call FUNC(setDead);
|
|
|
|
_returnDamage = 1;
|
|
|
|
} else {
|
|
|
|
[_unit] call FUNC(addToInjuredCollection);
|
|
|
|
if ([_unit, _bodyPartn] call FUNC(determineIfUnconscious)) then {
|
2015-01-25 15:40:47 +00:00
|
|
|
[_unit] call FUNC(setUnconsciousState);
|
2015-01-18 21:16:35 +00:00
|
|
|
} else {
|
|
|
|
[_unit,_newDamage] call FUNC(handleReactionHit);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
if (!(alive (vehicle _unit))) then {
|
|
|
|
_returnDamage = 1;
|
|
|
|
[_unit] call FUNC(setDead);
|
|
|
|
};
|
|
|
|
["Medical_onHandleDamage", _this] call ace_common_fnc_localEvent;
|
|
|
|
} else {
|
2015-01-22 22:29:18 +00:00
|
|
|
if (_returnDamage > 0.957) then {
|
|
|
|
_returnDamage = 0.957;
|
|
|
|
};
|
|
|
|
if (([_unit, _bodyPartn] call FUNC(determineIfFatal)) || !(alive (vehicle _unit))) then {
|
|
|
|
[_unit] call FUNC(setDead);
|
|
|
|
_returnDamage = 1;
|
|
|
|
};
|
2015-01-18 21:16:35 +00:00
|
|
|
};
|
|
|
|
|
2015-01-22 22:29:18 +00:00
|
|
|
_returnDamage;
|