ACE3/addons/medical/functions/fnc_handleDamage_basic.sqf

57 lines
2.4 KiB
Plaintext
Raw Normal View History

2015-02-06 12:47:17 +00:00
/*
2015-08-29 10:01:00 +00:00
* Author: KoffeinFlummi, Glowbal
* Handle damage basic medical
2015-02-06 12:47:17 +00:00
*
* Arguments:
*
* Return Value:
2015-08-29 10:01:00 +00:00
* <nil>
2015-02-06 12:47:17 +00:00
*
* Public: No
*/
#include "script_component.hpp"
2015-08-29 10:01:00 +00:00
private ["_damageBodyParts", "_cache_params", "_cache_damages"];
params ["_target"];
2015-02-06 12:47:17 +00:00
2015-08-29 10:01:00 +00:00
_damageBodyParts = _target getvariable [QGVAR(bodyPartStatus), [0,0,0,0,0,0]];
_cache_params = _target getVariable [QGVAR(cachedHandleDamageParams), []];
_cache_damages = _target getVariable QGVAR(cachedDamages);
2015-04-22 21:50:37 +00:00
2015-08-29 10:01:00 +00:00
{
_x params ["_unit","_selectionName","_amountOfDamage","_sourceOfDamage","_typeOfProjectile","_typeOfDamage"];
if !(isNull _sourceOfDamage && {_typeOfProjectile == ""} && {vehicle _unit == _unit} && {(_selectionName == "head" || isBurning _unit)}) then {
_part = [_selectionName] call FUNC(selectionNameToNumber);
if (_part < 0) exitwith {};
2015-08-29 10:01:00 +00:00
private ["_newDamage", "_pain"];
_newDamage = (_cache_damages select _foreachIndex);
_damageBodyParts set [_part, (_damageBodyParts select _part) + _newDamage];
_unit setvariable [QGVAR(bodyPartStatus), _damageBodyParts];
2015-02-06 12:47:17 +00:00
2015-08-29 10:01:00 +00:00
if (alive _unit && {!(_unit getvariable ["ACE_isUnconscious", false])}) then {
// 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 {
[_unit] call FUNC(setUnconscious);
};
2015-02-06 12:47:17 +00:00
};
2015-08-29 10:01:00 +00:00
_pain = _unit getVariable [QGVAR(pain), 0];
_pain = _pain + _newDamage * (1 - (_unit getVariable [QGVAR(morphine), 0]));
_unit setVariable [QGVAR(pain), _pain min 1, true];
2015-02-06 12:47:17 +00:00
};
2015-08-29 10:01:00 +00:00
}foreach _cache_params;
2015-02-06 12:47:17 +00:00
2015-08-29 10:01:00 +00:00
// We broadcast the value across the net here, in order to avoid broadcasting it multiple times earlier in the above code block
_target setvariable [QGVAR(bodyPartStatus), _damageBodyParts, true];
2015-02-06 12:47:17 +00:00
2015-08-29 10:01:00 +00:00
EXPLODE_6_PVT(_damageBodyParts,_headDamage,_torsoDamage,_handsDamageR,_handsDamageL,_legsDamageR,_legsDamageL);
_target setHitPointDamage ["hitHead", _headDamage min 0.95];
_target setHitPointDamage ["hitBody", _torsoDamage min 0.95];
_target setHitPointDamage ["hitHands", (_handsDamageR + _handsDamageL) min 0.95];
_target setHitPointDamage ["hitLegs", (_legsDamageR + _legsDamageL) min 0.95];
2015-02-06 12:47:17 +00:00
2015-08-29 10:01:00 +00:00
{
_target setHitPointDamage [_x, (_damageBodyParts select _foreachIndex) min 0.95];
}foreach GVAR(HITPOINTS);