Casing - Move model lookup to cartridge config (#9893)

Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>
Co-authored-by: Jouni Järvinen <rautamiekka@users.noreply.github.com>
Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>
This commit is contained in:
PabstMirror 2024-04-06 20:12:06 -05:00 committed by GitHub
parent 5ca3465b8a
commit 431c4d616e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 29 additions and 25 deletions

View File

@ -0,0 +1,6 @@
class CfgVehicles {
class FxCartridge;
class FxCartridge_65_caseless: FxCartridge {
GVAR(model) = ""; // note: the vanilla 6.5 caseless don't actually use this, just being safe
};
};

View File

@ -15,3 +15,4 @@ class CfgPatches {
};
#include "CfgEventHandlers.hpp"
#include "CfgVehicles.hpp"

View File

@ -20,33 +20,30 @@ params ["_unit", "", "", "", "_ammo"];
if (!isNull objectParent _unit) exitWith {};
private _modelPath = GVAR(cachedCasings) get _ammo;
if (isNil "_modelPath") then {
private _modelPath = GVAR(cachedCasings) getOrDefaultCall [_ammo, {
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 "CUP_FxCartridge_545": { "CUP\Weapons\CUP_Weapons_Ammunition\magazines\cartridge545.p3d" };
case "CUP_FxCartridge_939": { "CUP\Weapons\CUP_Weapons_Ammunition\magazines\cartridge939.p3d" };
case "": { "" };
default { "A3\Weapons_f\ammo\cartridge.p3d" };
if (_cartridge == "") then { // return (note: can't use exitWith)
""
} else {
private _cartridgeConfig = configFile >> "CfgVehicles" >> _cartridge;
// if explicitly defined, use ACE's config
if (isText (_cartridgeConfig >> QGVAR(model))) exitWith {
getText (_cartridgeConfig >> QGVAR(model))
};
GVAR(cachedCasings) set [_ammo, _modelPath];
};
// use casing's default model
private _model = getText (_cartridgeConfig >> "model");
if ("a3\weapons_f\empty" in toLowerANSI _model) exitWith { "" };
// Add file extension if missing (fileExists needs file extension)
if ((_model select [count _model - 4]) != ".p3d") then {
_model = _model + ".p3d";
};
["", _model] select (fileExists _model)
};
}, true];
if (_modelPath isEqualTo "") exitWith {};

View File

@ -15,6 +15,6 @@ class CfgPatches {
};
};
#include "CfgEventHandlers.hpp"
#include "CfgMagazines.hpp"
#include "CfgWeapons.hpp"
#include "CfgEventHandlers.hpp"