mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
c949a07c83
* HandleDamage uses armour values to determine which hitpoint was damaged * Tidied up comments * Newlines * Tabs? In MY code?! * Added uniform caching and option to force disable caching * Review suggestions * Review suggestions/code style * Spelling and select * Removed unnecessary validity check * Apply suggestions from code review Co-Authored-By: commy2 <commy-2@gmx.de> * Tweaks and optimisations, removed _noCache Also fixed cache nil vs empty * Different approach with fewer loops Lookup is now done per-hitpoint and default values cached fnc_getItemArmor made a helper function as it's now only a few lines * Tabs & newlines * Moved uniform logic inside helper function * Optimisations * Tweaks & optimisations, improved formatting * Ignore explosionShielding * Moved getArmor back to separate func, add per-unit caching * Formatting * Review suggestions Co-authored-by: commy2 <commy-2@gmx.de>
48 lines
1.0 KiB
Plaintext
48 lines
1.0 KiB
Plaintext
#include "script_component.hpp"
|
|
/*
|
|
* Author: Pterolatypus
|
|
* Checks a unit's equipment to calculate the total armor on a hitpoint.
|
|
*
|
|
* Arguments:
|
|
* 0: Unit <OBJECT>
|
|
* 1: Hitpoint <STRING>
|
|
*
|
|
* Return Value:
|
|
* Total armor for the given hitpoint <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 (configFile >> "CfgVehicles" >> typeOf _unit >> "nakedUniform");
|
|
};
|
|
|
|
private _gear = [
|
|
_uniform,
|
|
vest _unit,
|
|
headgear _unit
|
|
];
|
|
|
|
private _rags = _gear joinString "$";
|
|
private _var = format [QGVAR(armorCache$%1), _hitpoint];
|
|
_unit getVariable [_var, [""]] params ["_prevRags", "_armor"];
|
|
|
|
if (_rags != _prevRags) then {
|
|
_armor = 0;
|
|
|
|
{
|
|
_armor = _armor + ([_x, _hitpoint] call FUNC(getItemArmor));
|
|
} forEach _gear;
|
|
|
|
_unit setVariable [_var, [_rags, _armor]];
|
|
};
|
|
|
|
_armor // return
|