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-09-04 14:46:35 +00:00
|
|
|
TRACE_1("ACE_DEBUG: HandleDamage_BASIC Called",_target);
|
2015-02-06 12:47:17 +00:00
|
|
|
|
2015-11-30 16:53:57 +00:00
|
|
|
_damageBodyParts = _target getVariable [QGVAR(bodyPartStatus), [0,0,0,0,0,0]];
|
2015-08-29 10:01:00 +00:00
|
|
|
_cache_params = _target getVariable [QGVAR(cachedHandleDamageParams), []];
|
|
|
|
_cache_damages = _target getVariable QGVAR(cachedDamages);
|
2015-04-22 21:50:37 +00:00
|
|
|
|
2015-09-04 14:46:35 +00:00
|
|
|
TRACE_4("ACE_DEBUG: HandleDamage BASIC",_unit, _damageBodyParts,_cache_params,_cache_damages);
|
|
|
|
|
2015-08-29 10:01:00 +00:00
|
|
|
{
|
|
|
|
_x params ["_unit","_selectionName","_amountOfDamage","_sourceOfDamage","_typeOfProjectile","_typeOfDamage"];
|
2015-11-21 17:11:13 +00:00
|
|
|
TRACE_6("_x",_unit,_selectionName,_amountOfDamage,_sourceOfDamage,_typeOfProjectile,_typeOfDamage);
|
2015-08-29 10:01:00 +00:00
|
|
|
if !(isNull _sourceOfDamage && {_typeOfProjectile == ""} && {vehicle _unit == _unit} && {(_selectionName == "head" || isBurning _unit)}) then {
|
|
|
|
_part = [_selectionName] call FUNC(selectionNameToNumber);
|
|
|
|
if (_part < 0) exitwith {};
|
2015-08-11 18:58:00 +00:00
|
|
|
|
2015-08-29 10:01:00 +00:00
|
|
|
private ["_newDamage", "_pain"];
|
|
|
|
_newDamage = (_cache_damages select _foreachIndex);
|
|
|
|
_damageBodyParts set [_part, (_damageBodyParts select _part) + _newDamage];
|
2015-11-30 16:53:57 +00:00
|
|
|
_unit setVariable [QGVAR(bodyPartStatus), _damageBodyParts];
|
2015-02-06 12:47:17 +00:00
|
|
|
|
2015-11-30 16:53:57 +00:00
|
|
|
if (alive _unit && {!(_unit getVariable ["ACE_isUnconscious", false])}) then {
|
2015-08-29 10:01:00 +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-09-14 13:19:18 +00:00
|
|
|
[_unit, true, 0.5+random(10)] call FUNC(setUnconscious);
|
2015-05-19 05:23:44 +00:00
|
|
|
};
|
2015-02-06 12:47:17 +00:00
|
|
|
};
|
2015-08-29 10:01:00 +00:00
|
|
|
_pain = _unit getVariable [QGVAR(pain), 0];
|
2015-09-05 11:27:02 +00:00
|
|
|
_pain = _pain + (_newDamage / 4) * (1 - (_unit getVariable [QGVAR(morphine), 0]));
|
2015-08-29 10:01:00 +00:00
|
|
|
_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
|
2015-11-30 16:53:57 +00:00
|
|
|
_target setVariable [QGVAR(bodyPartStatus), _damageBodyParts, true];
|
|
|
|
TRACE_2("ACE_DEBUG: HandleDamage BASIC Broadcast value here",_unit, _target getVariable QGVAR(bodyPartStatus));
|
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
|
|
|
{
|
2015-11-21 17:11:13 +00:00
|
|
|
private _hitPointName = [_target, _x, true] call FUNC(translateSelections);
|
|
|
|
_target setHitPointDamage [_hitPointName, (_damageBodyParts select _foreachIndex) min 0.95];
|
|
|
|
}foreach GVAR(SELECTIONS);
|