From 87618c806dea37d820be6b60c3747c0acc2ad669 Mon Sep 17 00:00:00 2001 From: LinkIsGrim <69561145+LinkIsGrim@users.noreply.github.com> Date: Tue, 17 Dec 2024 01:12:20 -0300 Subject: [PATCH] Arsenal - Improve armor stat for medical, fix gforce stat --- addons/gforces/ACE_Arsenal_Stats.hpp | 2 +- addons/medical/XEH_PREP.hpp | 2 + addons/medical/arsenal/ACE_Arsenal_Stats.hpp | 17 +++++++++ addons/medical/arsenal/config.cpp | 18 +++++++++ addons/medical/arsenal/script_component.hpp | 3 ++ .../functions/fnc_statBarStatement_armor.sqf | 30 +++++++++++++++ .../functions/fnc_statTextStatement_armor.sqf | 37 +++++++++++++++++++ 7 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 addons/medical/arsenal/ACE_Arsenal_Stats.hpp create mode 100644 addons/medical/arsenal/config.cpp create mode 100644 addons/medical/arsenal/script_component.hpp create mode 100644 addons/medical/functions/fnc_statBarStatement_armor.sqf create mode 100644 addons/medical/functions/fnc_statTextStatement_armor.sqf diff --git a/addons/gforces/ACE_Arsenal_Stats.hpp b/addons/gforces/ACE_Arsenal_Stats.hpp index bebcf74489d..1a85d6a107f 100644 --- a/addons/gforces/ACE_Arsenal_Stats.hpp +++ b/addons/gforces/ACE_Arsenal_Stats.hpp @@ -7,7 +7,7 @@ class EGVAR(arsenal,stats) { displayName = CSTRING(statGReduction); showBar = 1; barStatement = QUOTE([ARR_3((_this select 0) select 0,_this select 1,[ARR_3([ARR_2(1,0)],[ARR_2(0.01,1)],false)])] call EFUNC(arsenal,statBarStatement_default)); - condition = QUOTE(getNumber (_this select 1 >> (_this select 0) select 0) > 0); + condition = QUOTE(getNumber (_this select 1 >> (_this select 0) select 0) < 1); tabs[] = {{3}, {}}; }; }; diff --git a/addons/medical/XEH_PREP.hpp b/addons/medical/XEH_PREP.hpp index 63d22caefe1..f527c5e3320 100644 --- a/addons/medical/XEH_PREP.hpp +++ b/addons/medical/XEH_PREP.hpp @@ -11,3 +11,5 @@ PREP(isInjured); PREP(isInStableCondition); PREP(serializeState); PREP(setUnconscious); +PREP(statBarStatement_armor); +PREP(statTextStatement_armor); diff --git a/addons/medical/arsenal/ACE_Arsenal_Stats.hpp b/addons/medical/arsenal/ACE_Arsenal_Stats.hpp new file mode 100644 index 00000000000..740756e3e16 --- /dev/null +++ b/addons/medical/arsenal/ACE_Arsenal_Stats.hpp @@ -0,0 +1,17 @@ +class EGVAR(arsenal,stats) { + class statBase; + class ACE_ballisticProtection: statBase { + condition = QUOTE(!(missionNamespace getVariable [ARR_2(QQEGVAR(medical,enabled),false)])); // Hide if medical is enabled + }; + class ACE_explosiveResistance: statBase { + condition = QUOTE(!(missionNamespace getVariable [ARR_2(QQEGVAR(medical,enabled),false)])); // Hide if medical is enabled + }; + class GVAR(armor): ACE_ballisticProtection { + displayName = "$STR_UI_ABAR"; + condition = QUOTE(missionNamespace getVariable [ARR_2(QQEGVAR(medical,enabled),false)]); // Show if medical is enabled + showBar = 1; + barStatement = QUOTE((_this select 1) call FUNC(statBarStatement_armor)); + showText = 1; + textStatement = QUOTE((_this select 1) call FUNC(statTextStatement_armor)); + }; +}; diff --git a/addons/medical/arsenal/config.cpp b/addons/medical/arsenal/config.cpp new file mode 100644 index 00000000000..c2f2ad0388d --- /dev/null +++ b/addons/medical/arsenal/config.cpp @@ -0,0 +1,18 @@ +#include "script_component.hpp" + +class CfgPatches { + class SUBADDON { + addonRootClass = QUOTE(COMPONENT); + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = { + "ace_medical_engine", + "ace_arsenal" + }; + skipWhenMissingDependencies = 1; + VERSION_CONFIG; + }; +}; + +#include "ACE_Arsenal_Stats.hpp" diff --git a/addons/medical/arsenal/script_component.hpp b/addons/medical/arsenal/script_component.hpp new file mode 100644 index 00000000000..9de14c499cf --- /dev/null +++ b/addons/medical/arsenal/script_component.hpp @@ -0,0 +1,3 @@ +#define SUBCOMPONENT arsenal +#define SUBCOMPONENT_BEAUTIFIED Arsenal +#include "..\script_component.hpp" diff --git a/addons/medical/functions/fnc_statBarStatement_armor.sqf b/addons/medical/functions/fnc_statBarStatement_armor.sqf new file mode 100644 index 00000000000..5e773e14c33 --- /dev/null +++ b/addons/medical/functions/fnc_statBarStatement_armor.sqf @@ -0,0 +1,30 @@ +#include "..\script_component.hpp" +/* + * Author: LinkIsGrim + * Bar statement for armor. + * + * Arguments: + * 0: Item config path + * + * Return Value: + * Bar statement + * + * Public: No +*/ + +params ["_config"]; + +private _itemType = getNumber (_config >> "ItemInfo" >> "type"); + +private _hitpoint = ["HitChest", "HitHead"] select (_itemType == TYPE_HEADGEAR); +private _levelStep = [4, 2] select (_itemType == TYPE_HEADGEAR); + +([configName _config, _hitpoint] call EFUNC(medical_engine,getItemArmor)) params ["_armor", "_armorScaled"]; + +if (_armor > (_armorScaled * 2)) then { // Probably explosive-resistant armor + _armor = _armorScaled; +}; + +private _armorLevel = (_armor - _levelStep) / _levelStep; + +0.01 max (_armorLevel / 5) min 1 diff --git a/addons/medical/functions/fnc_statTextStatement_armor.sqf b/addons/medical/functions/fnc_statTextStatement_armor.sqf new file mode 100644 index 00000000000..253ead912e4 --- /dev/null +++ b/addons/medical/functions/fnc_statTextStatement_armor.sqf @@ -0,0 +1,37 @@ +#include "..\script_component.hpp" +/* + * Author: LinkIsGrim + * Text statement for armor. + * + * Arguments: + * 0: Item config path + * + * Return Value: + * Stat Text + * + * Public: No +*/ + +params ["_config"]; + +private _itemType = getNumber (_config >> "ItemInfo" >> "type"); + +private _hitpoint = ["HitChest", "HitHead"] select (_itemType == TYPE_HEADGEAR); +private _levelStep = [4, 2] select (_itemType == TYPE_HEADGEAR); + +([configName _config, _hitpoint] call EFUNC(medical_engine,getItemArmor)) params ["_armor", "_armorScaled"]; + +if (_armor > (_armorScaled * 2)) then { // Probably explosive-resistant armor + _armor = _armorScaled; +}; + +private _armorLevel = 0 max (round ((_armor - _levelStep) / _levelStep)) min 5; + +localize ([ + "STR_A3_SP_NOARMOR", + "STR_A3_SP_AL_I", + "STR_A3_SP_AL_II", + "STR_A3_SP_AL_III", + "STR_A3_SP_AL_IV", + "STR_A3_SP_AL_V" +] select _armorLevel)