From 7481fb2100b9a8b38d29c19744e464bbdd8e3d74 Mon Sep 17 00:00:00 2001 From: LinkIsGrim Date: Sun, 7 Jan 2024 18:09:45 -0300 Subject: [PATCH] whatever this is --- addons/casings/CfgAmmo.hpp | 3 + addons/casings/XEH_postInit.sqf | 18 ++++-- addons/casings/config.cpp | 2 + addons/casings/functions/fnc_createCasing.sqf | 62 ++++++++++++------- addons/casings/script_component.hpp | 2 +- 5 files changed, 59 insertions(+), 28 deletions(-) create mode 100644 addons/casings/CfgAmmo.hpp diff --git a/addons/casings/CfgAmmo.hpp b/addons/casings/CfgAmmo.hpp new file mode 100644 index 0000000000..d1dae4fdb2 --- /dev/null +++ b/addons/casings/CfgAmmo.hpp @@ -0,0 +1,3 @@ +class CfgAmmo { + +}; diff --git a/addons/casings/XEH_postInit.sqf b/addons/casings/XEH_postInit.sqf index e91ab96c0d..60f0108b71 100644 --- a/addons/casings/XEH_postInit.sqf +++ b/addons/casings/XEH_postInit.sqf @@ -1,7 +1,17 @@ #include "script_component.hpp" -if (!hasInterface || !GVAR(enabled)) exitWith {}; +if (!hasInterface) exitWith {}; -GVAR(cachedCasings) = createHashMap; -GVAR(casings) = []; -["CAManBase", "FiredMan", {call FUNC(createCasing)}] call CBA_fnc_addClassEventHandler; +["CBA_settingsInitialized", { + if (!GVAR(enabled)) exitWith {}; + + GVAR(cachedCasings) = createHashMap; + GVAR(caselessWeapons) = createHashMap; + GVAR(casings) = []; + + { + + } forEach ((toString {getText (_x >> "cartridgePos")})) + + ["CAManBase", "FiredMan", LINKFUNC(createCasing)] call CBA_fnc_addClassEventHandler; +}] call CBA_fnc_addEventHandler; diff --git a/addons/casings/config.cpp b/addons/casings/config.cpp index 815048a082..cf1afe7f42 100644 --- a/addons/casings/config.cpp +++ b/addons/casings/config.cpp @@ -14,4 +14,6 @@ class CfgPatches { }; }; +#include "CfgAmmo.hpp" +#include "CfgWeapons.hpp" #include "CfgEventHandlers.hpp" diff --git a/addons/casings/functions/fnc_createCasing.sqf b/addons/casings/functions/fnc_createCasing.sqf index 22347d36a7..5852d22332 100644 --- a/addons/casings/functions/fnc_createCasing.sqf +++ b/addons/casings/functions/fnc_createCasing.sqf @@ -4,8 +4,14 @@ * Produces a casing matching the fired weapons caliber on the ground around the unit * * Arguments: - * 0: unit - Object the event handler is assigned to - * 1: ammo - Ammo used + * 0: Unit that pulled the trigger + * 1: Weapon + * 2: Muzzle + * 3: Weapon Mode (unused) + * 4: Ammo + * 5: Magazine + * 6: Projectile (unused) + * 7: Vehicle * * Return Value: * None @@ -16,33 +22,43 @@ * Public: No */ -params ["_unit", "", "", "", "_ammo"]; +params ["_unit", "_weapon", "_muzzle", "", "_ammo", "", "", "_vehicle"]; -if (!isNull objectParent _unit) exitWith {}; +if (!isNull _vehicle) exitWith {}; + +private _isCaseless = GVAR(caselessWeapons) getOrDefault [[_weapon, _muzzle], false, true]; +if (_isCaseless) exitWith {}; private _modelPath = GVAR(cachedCasings) get _ammo; if (isNil "_modelPath") then { - private _cartridge = getText (configFile >> "CfgAmmo" >> _ammo >> "cartridge"); - //Default cartridge is a 5.56mm model - _modelPath = switch (_cartridge) do { - case "FxCartridge_9mm": { "A3\Weapons_f\ammo\cartridge_small.p3d" }; - case "FxCartridge_65": { "A3\weapons_f\ammo\cartridge_65.p3d" }; - case "FxCartridge_762": { "A3\weapons_f\ammo\cartridge_762.p3d" }; - case "FxCartridge_762x39": { "A3\weapons_f_enoch\ammo\cartridge_762x39.p3d" }; - case "FxCartridge_93x64_Ball": { "A3\Weapons_F_Mark\Ammo\cartridge_93x64.p3d" }; - case "FxCartridge_338_Ball": { "A3\Weapons_F_Mark\Ammo\cartridge_338_LM.p3d" }; - case "FxCartridge_338_NM": { "A3\Weapons_F_Mark\Ammo\cartridge_338_NM.p3d" }; - case "FxCartridge_127": { "A3\weapons_f\ammo\cartridge_127.p3d" }; - case "FxCartridge_127x54": { "A3\Weapons_F_Mark\Ammo\cartridge_127x54.p3d" }; - case "FxCartridge_slug": { "A3\weapons_f\ammo\cartridge_slug.p3d" }; - case "FxCartridge_12Gauge_HE_lxWS": { "lxWS\weapons_1_f_lxws\Ammo\cartridge_he_lxws.p3d" }; - case "FxCartridge_12Gauge_Slug_lxWS": { "lxWS\weapons_1_f_lxws\Ammo\cartridge_slug_lxws.p3d" }; - case "FxCartridge_12Gauge_Smoke_lxWS": { "lxWS\weapons_1_f_lxws\Ammo\cartridge_smoke_lxws.p3d" }; - case "FxCartridge_12Gauge_Pellet_lxWS": { "lxWS\weapons_1_f_lxws\Ammo\cartridge_pellet_lxws.p3d" }; - case "": { "" }; - default { "A3\Weapons_f\ammo\cartridge.p3d" }; + private _ammoCfg = configFile >> "CfgAmmo" >> _ammo; + + if (isClass (_ammoCfg >> QGVAR(modelPath))) then { + _modelPath = getText (_ammoCfg >> QGVAR(modelPath)); + } else { + private _cartridge = getText (_ammoCfg >> "cartridge"); + //Default cartridge is a 5.56mm model + _modelPath = switch (_cartridge) do { + case "FxCartridge_9mm": { "A3\Weapons_f\ammo\cartridge_small.p3d" }; + case "FxCartridge_65": { "A3\weapons_f\ammo\cartridge_65.p3d" }; + case "FxCartridge_762": { "A3\weapons_f\ammo\cartridge_762.p3d" }; + case "FxCartridge_762x39": { "A3\weapons_f_enoch\ammo\cartridge_762x39.p3d" }; + case "FxCartridge_93x64_Ball": { "A3\Weapons_F_Mark\Ammo\cartridge_93x64.p3d" }; + case "FxCartridge_338_Ball": { "A3\Weapons_F_Mark\Ammo\cartridge_338_LM.p3d" }; + case "FxCartridge_338_NM": { "A3\Weapons_F_Mark\Ammo\cartridge_338_NM.p3d" }; + case "FxCartridge_127": { "A3\weapons_f\ammo\cartridge_127.p3d" }; + case "FxCartridge_127x54": { "A3\Weapons_F_Mark\Ammo\cartridge_127x54.p3d" }; + case "FxCartridge_slug": { "A3\weapons_f\ammo\cartridge_slug.p3d" }; + case "FxCartridge_12Gauge_HE_lxWS": { "lxWS\weapons_1_f_lxws\Ammo\cartridge_he_lxws.p3d" }; + case "FxCartridge_12Gauge_Slug_lxWS": { "lxWS\weapons_1_f_lxws\Ammo\cartridge_slug_lxws.p3d" }; + case "FxCartridge_12Gauge_Smoke_lxWS": { "lxWS\weapons_1_f_lxws\Ammo\cartridge_smoke_lxws.p3d" }; + case "FxCartridge_12Gauge_Pellet_lxWS": { "lxWS\weapons_1_f_lxws\Ammo\cartridge_pellet_lxws.p3d" }; + case "": { "" }; + default { "A3\Weapons_f\ammo\cartridge.p3d" }; + }; }; + GVAR(cachedCasings) set [_ammo, _modelPath]; }; diff --git a/addons/casings/script_component.hpp b/addons/casings/script_component.hpp index c734aca4e3..432a1de3b2 100644 --- a/addons/casings/script_component.hpp +++ b/addons/casings/script_component.hpp @@ -3,7 +3,7 @@ #include "\z\ace\addons\main\script_mod.hpp" // #define DEBUG_MODE_FULL -// #define DISABLE_COMPILE_CACHE +#define DISABLE_COMPILE_CACHE // #define ENABLE_PERFORMANCE_COUNTERS #ifdef DEBUG_ENABLED_CASINGS