whatever this is

This commit is contained in:
LinkIsGrim 2024-01-07 18:09:45 -03:00
parent 474ecdd93b
commit 7481fb2100
5 changed files with 59 additions and 28 deletions

View File

@ -0,0 +1,3 @@
class CfgAmmo {
};

View File

@ -1,7 +1,17 @@
#include "script_component.hpp"
if (!hasInterface || !GVAR(enabled)) exitWith {};
if (!hasInterface) exitWith {};
["CBA_settingsInitialized", {
if (!GVAR(enabled)) exitWith {};
GVAR(cachedCasings) = createHashMap;
GVAR(caselessWeapons) = createHashMap;
GVAR(casings) = [];
["CAManBase", "FiredMan", {call FUNC(createCasing)}] call CBA_fnc_addClassEventHandler;
{
} forEach ((toString {getText (_x >> "cartridgePos")}))
["CAManBase", "FiredMan", LINKFUNC(createCasing)] call CBA_fnc_addClassEventHandler;
}] call CBA_fnc_addEventHandler;

View File

@ -14,4 +14,6 @@ class CfgPatches {
};
};
#include "CfgAmmo.hpp"
#include "CfgWeapons.hpp"
#include "CfgEventHandlers.hpp"

View File

@ -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 <OBJECT>
* 1: ammo - Ammo used <STRING>
* 0: Unit that pulled the trigger <OBJECT>
* 1: Weapon <STRING>
* 2: Muzzle <STRING>
* 3: Weapon Mode (unused) <STRING>
* 4: Ammo <STRING>
* 5: Magazine <STRING>
* 6: Projectile (unused) <OBJECT>
* 7: Vehicle <OBJECT>
*
* Return Value:
* None
@ -16,14 +22,22 @@
* 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");
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" };
@ -43,6 +57,8 @@ if (isNil "_modelPath") then {
case "": { "" };
default { "A3\Weapons_f\ammo\cartridge.p3d" };
};
};
GVAR(cachedCasings) set [_ammo, _modelPath];
};

View File

@ -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