mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
da60a1b39d
* scale armor damage using passthrough * add - to comment Co-authored-by: Jouni Järvinen <rautamiekka@users.noreply.github.com> * improve condition Co-authored-by: Jouni Järvinen <rautamiekka@users.noreply.github.com> * remove extra brackets Co-authored-by: Jouni Järvinen <rautamiekka@users.noreply.github.com> * remove extra brackets * fix damage sorting * whitespace * comment * fix function header * fix infinite armor when no item equipped * cleanup * more cleanup * name * don't scale structural damage * add setting * fix key name * add cap to passThrough * fix script error in setting --------- Co-authored-by: GhostIsSpooky <69561145+Salluci@users.noreply.github.com> Co-authored-by: Jouni Järvinen <rautamiekka@users.noreply.github.com>
51 lines
1.2 KiB
Plaintext
51 lines
1.2 KiB
Plaintext
#include "..\script_component.hpp"
|
|
/*
|
|
* Author: Pterolatypus, LinkIsGrim
|
|
* Checks a unit's equipment to calculate the total armor on a hitpoint.
|
|
*
|
|
* Arguments:
|
|
* 0: Unit <OBJECT>
|
|
* 1: Hitpoint <STRING>
|
|
*
|
|
* Return Value:
|
|
* Total armor and scaled armor for the given hitpoint <ARRAY of NUMBER>
|
|
*
|
|
* 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 {
|
|
_uniform = getText (configOf _unit >> "nakedUniform");
|
|
};
|
|
|
|
private _gear = [
|
|
_uniform,
|
|
vest _unit,
|
|
headgear _unit
|
|
];
|
|
|
|
private _rags = _gear joinString "$";
|
|
private _var = format [QGVAR(armorCache$%1), _hitpoint];
|
|
_unit getVariable [_var, ["", 0, 0]] params ["_prevRags", "_armor", "_armorScaled"];
|
|
|
|
if (_rags != _prevRags) then {
|
|
_armor = 0;
|
|
_armorScaled = 0;
|
|
|
|
{
|
|
([_x, _hitpoint] call FUNC(getItemArmor)) params ["_itemArmor", "_itemArmorScaled"];
|
|
_armor = _armor + _itemArmor;
|
|
_armorScaled = _armorScaled + _itemArmorScaled;
|
|
} forEach _gear;
|
|
|
|
_unit setVariable [_var, [_rags, _armor, _armorScaled]];
|
|
};
|
|
|
|
[_armor, _armorScaled] // return
|