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>
|
|
|
|
* 5: Current damage to be returned <NUMBER>
|
|
|
|
* 6: Type of Damage <STRING>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* Damage To Be Inflicted <NUMBER>
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
2015-02-13 21:58:48 +00:00
|
|
|
#include "script_component.hpp"
|
2015-02-08 09:01:32 +00:00
|
|
|
|
2015-02-28 18:22:46 +00:00
|
|
|
private ["_unit","_selectionName","_amountOfDamage","_sourceOfDamage","_typeOfProjectile","_typeOfDamage", "_part", "_damageBodyParts", "_newDamage", "_hitPoints"];
|
2015-02-03 20:48:08 +00:00
|
|
|
_unit = _this select 0;
|
|
|
|
_selectionName = _this select 1;
|
|
|
|
_amountOfDamage = _this select 2;
|
|
|
|
_sourceOfDamage = _this select 3;
|
|
|
|
_typeOfProjectile = _this select 4;
|
|
|
|
_returnDamage = _this select 5;
|
2015-02-13 21:55:13 +00:00
|
|
|
|
2015-02-28 18:22:46 +00:00
|
|
|
_typeOfDamage = [_typeOfProjectile] call FUNC(getTypeOfDamage);
|
|
|
|
_part = [_selectionName] call FUNC(selectionNameToNumber);
|
2015-02-21 22:14:21 +00:00
|
|
|
|
2015-02-28 18:22:46 +00:00
|
|
|
_hitPoints = ["HitHead", "HitBody", "HitLeftArm", "HitRightArm", "HitLeftLeg", "HitRightLeg"];
|
|
|
|
// Sorting out the damage
|
|
|
|
_damageBodyParts = _unit getvariable [QGVAR(bodyPartStatus), [0,0,0,0,0,0]];
|
|
|
|
_newDamage = _amountOfDamage - (_unit getHitPointDamage (_hitPoints select _part));
|
|
|
|
_damageBodyParts set [_part, (_damageBodyParts select _part) + _newDamage];
|
|
|
|
_unit setvariable [QGVAR(bodyPartStatus), _damageBodyParts, true];
|
|
|
|
[_unit] call FUNC(handleDamage_advancedSetDamage);
|
2015-02-21 22:14:21 +00:00
|
|
|
|
2015-02-28 18:22:46 +00:00
|
|
|
[_unit, _selectionName, _newDamage, _typeOfProjectile, _typeOfDamage] call FUNC(handleDamage_wounds);
|
2015-02-03 20:48:08 +00:00
|
|
|
|
|
|
|
if (GVAR(enableAirway)) then {
|
2015-02-28 18:22:46 +00:00
|
|
|
[_unit,_selectionName,_newDamage,_sourceOfDamage, _typeOfDamage] call FUNC(handleDamage_airway);
|
2015-02-03 20:48:08 +00:00
|
|
|
};
|
|
|
|
if (GVAR(enableFractures)) then {
|
2015-02-28 18:22:46 +00:00
|
|
|
[_unit,_selectionName,_newDamage,_sourceOfDamage, _typeOfDamage] call FUNC(handleDamage_fractures);
|
2015-02-03 20:48:08 +00:00
|
|
|
};
|
|
|
|
if (GVAR(enableInternalBleeding)) then {
|
2015-02-28 18:22:46 +00:00
|
|
|
[_unit,_selectionName,_newDamage,_sourceOfDamage, _typeOfDamage] call FUNC(handleDamage_internalInjuries);
|
2015-02-03 20:48:08 +00:00
|
|
|
};
|
2015-02-21 22:14:21 +00:00
|
|
|
|
|
|
|
if (alive _unit && {!(_unit getvariable ["ACE_isUnconscious", false])}) then {
|
2015-02-28 18:22:46 +00:00
|
|
|
[_unit, _newDamage] call FUNC(reactionToDamage);
|
2015-02-21 22:14:21 +00:00
|
|
|
};
|
|
|
|
|
2015-02-13 21:55:13 +00:00
|
|
|
_returnDamage;
|