|
| 1 | +#include "..\script_component.hpp" |
| 2 | +/* |
| 3 | + * Author: Pterolatypus, LinkIsGrim |
| 4 | + * Returns the regular and scaled armor values the given item provides to a particular hitpoint, either from a cache or by reading the item config. |
| 5 | + * |
| 6 | + * Arguments: |
| 7 | + * 0: Item Class <STRING> |
| 8 | + * 1: Hitpoint <STRING> |
| 9 | + * |
| 10 | + * Return Value: |
| 11 | + * Regular and scaled item armor for the given hitpoint <ARRAY of NUMBERs> |
| 12 | + * |
| 13 | + * Example: |
| 14 | + * ["V_PlateCarrier_rgr", "HitChest"] call armor_modifier_ace_main_fnc_getItemArmor |
| 15 | + * |
| 16 | + * Public: No |
| 17 | + */ |
| 18 | + |
| 19 | +params ["_item", "_hitpoint"]; |
| 20 | + |
| 21 | +GVAR(armorCache) getOrDefaultCall [_this joinString "$", { |
| 22 | + TRACE_2("Cache miss",_item,_hitpoint); |
| 23 | + private _armor = 0; |
| 24 | + |
| 25 | + if !("" in [_item, _hitpoint]) then { |
| 26 | + private _itemInfo = configFile >> "CfgWeapons" >> _item >> "ItemInfo"; |
| 27 | + private _itemType = getNumber (_itemInfo >> "type"); |
| 28 | + |
| 29 | + if (_itemType == TYPE_UNIFORM) then { |
| 30 | + private _unitCfg = configFile >> "CfgVehicles" >> getText (_itemInfo >> "uniformClass"); |
| 31 | + _armor = if (_hitpoint == "#structural") then { |
| 32 | + // TODO: I'm not sure if this should be multiplied by the base armor value or not |
| 33 | + getNumber (_unitCfg >> "armorStructural") |
| 34 | + } else { |
| 35 | + getNumber (_unitCfg >> "armor") * (1 max getNumber (_unitCfg >> "HitPoints" >> _hitpoint >> "armor")) |
| 36 | + }; |
| 37 | + } else { |
| 38 | + private _condition = format ["getText (_x >> 'hitpointName') == '%1'", _hitpoint]; |
| 39 | + private _entry = configProperties [_itemInfo >> "HitpointsProtectionInfo", _condition] param [0, configNull]; |
| 40 | + if (!isNull _entry) then { |
| 41 | + _armor = getNumber (_entry >> "armor"); |
| 42 | + }; |
| 43 | + }; |
| 44 | + }; |
| 45 | + |
| 46 | + _armor // return |
| 47 | +}, true] |
0 commit comments