2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2020-02-28 16:54:53 +00:00
|
|
|
/*
|
2023-09-23 17:07:06 +00:00
|
|
|
* Author: Pterolatypus, LinkIsGrim
|
2020-02-28 16:54:53 +00:00
|
|
|
* Checks a unit's equipment to calculate the total armor on a hitpoint.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Unit <OBJECT>
|
|
|
|
* 1: Hitpoint <STRING>
|
|
|
|
*
|
|
|
|
* Return Value:
|
2023-09-23 17:07:06 +00:00
|
|
|
* Total armor and scaled armor for the given hitpoint <ARRAY of NUMBER>
|
2020-02-28 16:54:53 +00:00
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [player, "HitChest"] call ace_medical_engine_fnc_getHitpointArmor
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
|
|
|
params ["_unit", "_hitpoint"];
|
|
|
|
|
|
|
|
private _uniform = uniform _unit;
|
|
|
|
// If unit is naked, use its underwear class instead
|
|
|
|
if (_uniform isEqualTo "") then {
|
2021-02-18 18:58:08 +00:00
|
|
|
_uniform = getText (configOf _unit >> "nakedUniform");
|
2020-02-28 16:54:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
private _gear = [
|
|
|
|
_uniform,
|
|
|
|
vest _unit,
|
|
|
|
headgear _unit
|
|
|
|
];
|
|
|
|
|
|
|
|
private _rags = _gear joinString "$";
|
|
|
|
private _var = format [QGVAR(armorCache$%1), _hitpoint];
|
2023-09-23 17:07:06 +00:00
|
|
|
_unit getVariable [_var, ["", 0, 0]] params ["_prevRags", "_armor", "_armorScaled"];
|
2020-02-28 16:54:53 +00:00
|
|
|
|
|
|
|
if (_rags != _prevRags) then {
|
|
|
|
_armor = 0;
|
2023-09-23 17:07:06 +00:00
|
|
|
_armorScaled = 0;
|
2020-02-28 16:54:53 +00:00
|
|
|
|
|
|
|
{
|
2023-09-23 17:07:06 +00:00
|
|
|
([_x, _hitpoint] call FUNC(getItemArmor)) params ["_itemArmor", "_itemArmorScaled"];
|
|
|
|
_armor = _armor + _itemArmor;
|
|
|
|
_armorScaled = _armorScaled + _itemArmorScaled;
|
2020-02-28 16:54:53 +00:00
|
|
|
} forEach _gear;
|
|
|
|
|
2023-09-23 17:07:06 +00:00
|
|
|
_unit setVariable [_var, [_rags, _armor, _armorScaled]];
|
2020-02-28 16:54:53 +00:00
|
|
|
};
|
|
|
|
|
2023-09-23 17:07:06 +00:00
|
|
|
[_armor, _armorScaled] // return
|