Skip to content

Commit 612c80c

Browse files
authored
Merge pull request #5 from johnb432/dev
1.0.6.0
2 parents f8b258b + b03dcee commit 612c80c

8 files changed

Lines changed: 111 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Changelog for Armor Modifier - ACE 25.6.2025
2+
3+
1.0.6.0
4+
- Added compatibility with upcoming ACE 3.20.0
5+
16
# Changelog for Armor Modifier - ACE 9.2.2025
27

38
1.0.5.0

addons/main/XEH_PREP.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
PREP(getHitpointArmor);
2+
PREP(getItemArmor);
13
PREP(handleDamage);

addons/main/XEH_preInit.sqf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@ ADDON = false;
77
// CBA Settings
88
#include "initSettings.inc.sqf"
99

10+
GVAR(armorCache) = createHashMap;
11+
1012
ADDON = true;
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#include "..\script_component.hpp"
2+
/*
3+
* Author: Pterolatypus, LinkIsGrim
4+
* (This file is a copy from ACE3 3.19 with minor simplifications)
5+
* Checks a unit's equipment to calculate the total armor on a hitpoint.
6+
*
7+
* Arguments:
8+
* 0: Unit <OBJECT>
9+
* 1: Hitpoint <STRING>
10+
*
11+
* Return Value:
12+
* Total armor and scaled armor for the given hitpoint <ARRAY of NUMBERs>
13+
*
14+
* Example:
15+
* [player, "HitChest"] call armor_modifier_ace_main_fnc_getHitpointArmor
16+
*
17+
* Public: No
18+
*/
19+
20+
params ["_unit", "_hitpoint"];
21+
22+
private _uniform = uniform _unit;
23+
// If unit is naked, use its underwear class instead
24+
if (_uniform isEqualTo "") then {
25+
_uniform = getText (configOf _unit >> "nakedUniform");
26+
};
27+
28+
private _gear = [
29+
_uniform,
30+
vest _unit,
31+
headgear _unit
32+
];
33+
34+
private _rags = _gear joinString "$";
35+
private _var = format [QGVAR(armorCache$%1), _hitpoint];
36+
_unit getVariable [_var, ["", 0, 0]] params ["_prevRags", "_armor"];
37+
38+
if (_rags != _prevRags) then {
39+
_armor = 0;
40+
41+
{
42+
_armor = _armor + ([_x, _hitpoint] call FUNC(getItemArmor));
43+
} forEach _gear;
44+
45+
// Armor should be at least 1 to prevent dividing by 0
46+
_armor = _armor max 1;
47+
48+
_unit setVariable [_var, [_rags, _armor]];
49+
};
50+
51+
_armor // return
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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]

addons/main/functions/fnc_handleDamage.sqf

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,8 @@ if (_context != 2 && {_context == 4 || _newDamage == 0}) exitWith {
6363
// Get scaled armor value of hitpoint and calculate damage before armor
6464
// We scale using passThrough to handle explosive-resistant armor properly (#9063)
6565
// We need realDamage to determine which limb was hit correctly
66-
[_unit, _hitpoint] call ace_medical_engine_fnc_getHitpointArmor params ["_armor", "_armorScaled"];
66+
private _armor = [_unit, _hitpoint] call FUNC(getHitpointArmor);
6767
private _realDamage = _newDamage * _armor;
68-
if (!_structuralDamage) then {
69-
private _armorCoef = _armor/_armorScaled;
70-
private _damageCoef = linearConversion [0, 1, ace_medical_engine_damagePassThroughEffect, 1, _armorCoef];
71-
_newDamage = _newDamage * _damageCoef;
72-
};
7368
TRACE_6("Received hit",_hitpoint,_ammo,_newDamage,_realDamage,_directHit,_context);
7469

7570
// Drowning doesn't fire the EH for each hitpoint so the "ace_hdbracket" code never runs

addons/main/script_macros.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,6 @@
2222
#define PRIORITY_RIGHT_LEG (1 + random 1)
2323
#define PRIORITY_STRUCTURAL 1
2424

25+
#define TYPE_UNIFORM 801
26+
2527
#define GET_NUMBER(config,default) (if (isNumber (config)) then {getNumber (config)} else {default})

addons/main/script_version.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#define MAJOR 1
22
#define MINOR 0
3-
#define PATCHLVL 5
3+
#define PATCHLVL 6
44
#define BUILD 0

0 commit comments

Comments
 (0)