ACE3/addons/medical_engine/functions/fnc_getItemArmor.sqf
pterolatypus 73a7dbdc1e
Medical - Rework wound handling (#8278)
- Add stackable wound handler system for easy 3rd party extensibility and overriding of default wound handler.
- Change mapping from wound type -> damage types, to damage type -> wound types. Improves the semantics and makes configuration easier to reason about.
- Allow damage types to influence wound properties (bleed, size, etc.) with configurable variance parameters.
- Allow configuration of wound type variance per damage type. Enabling more logically driven variance for sensible but still varied end results.
- Improve handling of non-selection-specific damage events. The wound handler now receives all incoming damages and may apply damage to multiple selections (previously only ever one) if the damage type is not configured to be selection specific (with new config property `selectionSpecific`).
- Add debug script for testing explosion damage events at varied ranges.
- Add custom fire wound handler.
2022-02-17 20:03:12 +00:00

53 lines
1.7 KiB
Plaintext

#include "script_component.hpp"
/*
* Author: Pterolatypus
* Returns the armor value the given item provides to a particular hitpoint, either from a cache or by reading the item config.
*
* Arguments:
* 0: Item Class <STRING>
* 1: Hitpoint <STRING>
*
* Return Value:
* Item armor for the given hitpoint <NUMBER>
*
* Example:
* ["V_PlateCarrier_rgr", "HitChest"] call ace_medical_engine_fnc_getItemArmor
*
* Public: No
*/
params ["_item", "_hitpoint"];
private _key = format ["%1$%2", _item, _hitpoint];
private _armor = GVAR(armorCache) get _key;
if (isNil "_armor") then {
TRACE_2("Cache miss",_item,_hitpoint);
if ("" in [_item, _hitpoint]) exitWith {
_armor = 0;
GVAR(armorCache) set [_key, _armor];
};
private _itemInfo = configFile >> "CfgWeapons" >> _item >> "ItemInfo";
if (getNumber (_itemInfo >> "type") == TYPE_UNIFORM) then {
private _unitCfg = configFile >> "CfgVehicles" >> getText (_itemInfo >> "uniformClass");
if (_hitpoint == "#structural") then {
// TODO: I'm not sure if this should be multiplied by the base armor value or not
_armor = getNumber (_unitCfg >> "armorStructural");
} else {
private _entry = _unitCfg >> "HitPoints" >> _hitpoint;
_armor = getNumber (_unitCfg >> "armor") * (1 max getNumber (_entry >> "armor"));
};
} else {
private _condition = format ["getText (_x >> 'hitpointName') == '%1'", _hitpoint];
private _entry = configProperties [_itemInfo >> "HitpointsProtectionInfo", _condition] param [0, configNull];
_armor = getNumber (_entry >> "armor");
};
GVAR(armorCache) set [_key, _armor];
};
_armor // return