2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2016-07-30 12:00:42 +00:00
|
|
|
/*
|
|
|
|
* Author: commy2
|
|
|
|
* Set structural damage of an object without modifying the individual hit points.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Unit <OBJECT>
|
|
|
|
* 1: New damage value <NUMBER>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [player, 0.5] call ace_medical_engine_fnc_setStructuralDamage
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
|
|
|
params [["_unit", objNull, [objNull]], ["_damage", 0, [0]]];
|
|
|
|
|
2020-04-05 03:01:51 +00:00
|
|
|
if (!local _unit) exitWith { ERROR_2("setStructuralDamage: Unit not local or null [%1:%2]",_unit,typeOf _unit); };
|
2016-07-30 12:00:42 +00:00
|
|
|
|
|
|
|
private _hitPointDamages = getAllHitPointsDamage _unit param [2, []];
|
|
|
|
|
2019-05-03 15:09:16 +00:00
|
|
|
private _damageDisabled = !isDamageAllowed _unit;
|
|
|
|
if (_damageDisabled) then {
|
2019-05-03 15:03:17 +00:00
|
|
|
_unit allowDamage true;
|
|
|
|
};
|
|
|
|
|
2016-07-30 12:00:42 +00:00
|
|
|
_unit setDamage _damage;
|
|
|
|
|
|
|
|
{
|
|
|
|
_unit setHitIndex [_forEachIndex, _x];
|
|
|
|
} forEach _hitPointDamages;
|
2019-05-03 15:03:17 +00:00
|
|
|
|
2019-05-03 15:09:16 +00:00
|
|
|
if (_damageDisabled) then {
|
2019-05-03 15:03:17 +00:00
|
|
|
_unit allowDamage false;
|
|
|
|
};
|