diff --git a/42/mod.info b/42/mod.info index c345fda..92ca79f 100644 --- a/42/mod.info +++ b/42/mod.info @@ -1,5 +1,5 @@ name=Opinionated Firearms -id=hrsys_opinionated_firearms +id=hrsys_opinionated_firearms_testing author=Riggs0 modversion=1.0.0 versionMin=42.12.13 diff --git a/common/media/lua/client/BetterContainers/Categorize/Categories/mods/guns93_items.lua b/common/media/lua/client/BetterContainers/Categorize/Categories/mods/guns93_items.lua new file mode 100644 index 0000000..674970e --- /dev/null +++ b/common/media/lua/client/BetterContainers/Categorize/Categories/mods/guns93_items.lua @@ -0,0 +1,368 @@ +return { + + WepFire = { + "Base.83Cheetah", + "Base.AKM", + "Base.AKSport", + "Base.Anaconda", + "Base.AR15", + "Base.AR180", + "Base.AssaultRifle", + "Base.AssaultRifle2", + "Base.Auto5", + "Base.Auto5_Alt", + "Base.BenelliM3", + "Base.BenelliM3_Alt", + "Base.Beretta682", + "Base.Beretta682_Alt", + "Base.Beretta92FS", + "Base.BHP", + "Base.Bobcat", + "Base.Brown3006BAR", + "Base.Brown308BAR", + "Base.BrownCitori", + "Base.BrownCitori_Alt", + "Base.Buckmark", + "Base.CalicoPistol", + "Base.CalicoRifle", + "Base.CAR15", + "Base.Colt9mm", + "Base.ColtArmy", + "Base.ColtDet", + "Base.Command1911", + "Base.CZ75B", + "Base.DE357", + "Base.DeltaElite", + "Base.Dissy", + "Base.DoubleBarrelShotgun", + "Base.DoubleBarrelShotgun_Alt", + "Base.DoubleBarrelShotgunSawnoff", + "Base.DoubleBarrelShotgunSawnoff_Alt", + "Base.FAL", + "Base.Glock17", + "Base.Glock17L", + "Base.Glock19", + "Base.Glock20", + "Base.Glock21", + "Base.Glock22", + "Base.Glock23", + "Base.Glock24", + "Base.Gov1911", + "Base.GP100", + "Base.GP100_Alt", + "Base.GP101", + "Base.GP101_Alt", + "Base.Hammerless", + "Base.HBAR", + "Base.HK91", + "Base.HuntingRifle", + "Base.Ithaca37", + "Base.Ithaca37_Alt", + "Base.Ithaca37Riot", + "Base.Ithaca37Riot_Alt", + "Base.J22", + "Base.Javelina", + "Base.L395K", + "Base.L395K_Alt", + "Base.Longslide", + "Base.M1903", + "Base.M1917", + "Base.M1A", + "Base.M1ABush", + "Base.M1Carbine", + "Base.M1Garand", + "Base.M24", + "Base.M249", + "Base.M3GreaseGun", + "Base.M590", + "Base.M590_Alt", + "Base.M60", + "Base.M635", + "Base.M723", + "Base.M727", + "Base.M733", + "Base.M870", + "Base.M870_Alt", + "Base.MAC10", + "Base.Marlin3363030", + "Base.Marlin33644", + "Base.Marlin39A", + "Base.Marlin45", + "Base.Marlin60", + "Base.Marlin9", + "Base.Mauser98K", + "Base.Mini14", + "Base.Mini30", + "Base.Moss500", + "Base.Moss500_Alt", + "Base.Moss590", + "Base.Moss590_Alt", + "Base.MP5", + "Base.Officer1911", + "Base.P226", + "Base.P228", + "Base.P380", + "Base.P7M13", + "Base.P7M8", + "Base.Pistol", + "Base.Pistol2", + "Base.Pistol3", + "Base.PPK", + "Base.Python", + "Base.Python_Alt", + "Base.R223Rem788", + "Base.R223RugM77", + "Base.R3006Rem700", + "Base.R3006RugM77", + "Base.R3030Rem788", + "Base.R308Rem700", + "Base.R308RugM77", + "Base.R44Rem788", + "Base.Raven25", + "Base.Rem1100", + "Base.Rem1100_Alt", + "Base.Rem1187P", + "Base.Rem1187P_Alt", + "Base.Rem223760", + "Base.Rem3006760", + "Base.Rem308760", + "Base.Rem870P", + "Base.Rem870P_Alt", + "Base.Revolver", + "Base.Revolver_Long", + "Base.Revolver_Short", + "Base.Rug1022", + "Base.Rugmark", + "Base.RugP89", + "Base.RugP90", + "Base.SavageFox", + "Base.SavageFox_Alt", + "Base.SecuritySix", + "Base.SecuritySix_Alt", + "Base.Shotgun", + "Base.Shotgun_Alt", + "Base.ShotgunSawnoff", + "Base.ShotgunSawnoff_Alt", + "Base.SKS", + "Base.SOAuto5", + "Base.SOAuto5_Alt", + "Base.SOBeretta682", + "Base.SOBeretta682_Alt", + "Base.SOBrownCitori", + "Base.SOBrownCitori_Alt", + "Base.SOIthaca37", + "Base.SOIthaca37_Alt", + "Base.SOL395K", + "Base.SOL395K_Alt", + "Base.SOM24", + "Base.SOMoss500", + "Base.SOMoss500_Alt", + "Base.SOR223Rem700", + "Base.SOR223Rem788", + "Base.SOR3006Rem700", + "Base.SOR3030Rem788", + "Base.SOR308Rem700", + "Base.SOR308Rem788", + "Base.SOR44Rem788", + "Base.SORem1100", + "Base.SORem1100_Alt", + "Base.SOSavageFox", + "Base.SOSavageFox_Alt", + "Base.SOW223WinM70", + "Base.SOW3006WinM70", + "Base.SOW308WinM70", + "Base.SOWin1200", + "Base.SOWin1200_Alt", + "Base.SOWin1400", + "Base.SOWin1400_Alt", + "Base.SOWin1912", + "Base.SOWin1912_Alt", + "Base.SOWin37", + "Base.SOWin37_Alt", + "Base.SPAS12", + "Base.SPAS12_Alt", + "Base.SW10", + "Base.SW17", + "Base.SW4006", + "Base.SW4506", + "Base.SW586", + "Base.SW586_Alt", + "Base.SW5906", + "Base.SW65", + "Base.SW65_Alt", + "Base.T56", + "Base.TEC9", + "Base.USP40", + "Base.USP9", + "Base.Uzi", + "Base.Valmet", + "Base.VarmintRifle", + "Base.W223WinM70", + "Base.W3006WinM70", + "Base.W308WinM70", + "Base.Win1200", + "Base.Win1200_Alt", + "Base.Win1200Def", + "Base.Win1200Def_Alt", + "Base.Win1400", + "Base.Win1400_Alt", + "Base.Win1912", + "Base.Win1912_Alt", + "Base.Win30067400", + "Base.Win3087400", + "Base.Win37", + "Base.Win37_Alt", + "Base.Win61", + "Base.Win69", + "Base.Win943030", + "Base.Win94357", + "Base.Win94357_Alt", + "Base.Win9445", + }, + + WepAmmoMag = { + "Base.100CalicoMag", + "Base.1022Mag", + "Base.10M14Mag", + "Base.15BHPMag", + "Base.17BHPMag", + "Base.1908Mag", + "Base.1911MagExtend", + "Base.1911MagExtendSS", + "Base.1911MagSS", + "Base.20M16AR180Mag", + "Base.20M16Mag", + "Base.20M9Mag", + "Base.20MP5Mag", + "Base.223Rem760Mag", + "Base.223RemMag", + "Base.25Rug1022Mag", + "Base.25UziColtSMGMag", + "Base.25UziMag", + "Base.3006BARMag", + "Base.3006clip", + "Base.3006Rem760Mag", + "Base.3006WinMag", + "Base.3030RemMag", + "Base.308BARMag", + "Base.308Clip", + "Base.308Rem760Mag", + "Base.308WinMag", + "Base.30M14Mag", + "Base.30M16AR180Mag", + "Base.30M1CarMag", + "Base.30Mini14Mag", + "Base.4006Mag", + "Base.40AKMag", + "Base.40AR180Mag", + "Base.40M16AR180Mag", + "Base.44Clip", + "Base.44RemMag", + "Base.4506Mag", + "Base.45Clip", + "Base.45Moonclip", + "Base.556Clip", + "Base.5906Mag", + "Base.83Mag", + "Base.9mmClip", + "Base.AK5Mag", + "Base.AKBakeMag", + "Base.AKDrumMag", + "Base.AKMag", + "Base.AR180Mag", + "Base.BetaCMag", + "Base.BHPMag", + "Base.BHPMagSS", + "Base.BobcatMag", + "Base.BuckMag", + "Base.CalicoMag", + "Base.ColtSMGMag", + "Base.CZ75BMag", + "Base.DE357Mag", + "Base.DeltaEliteMag", + "Base.DeltaEliteMagBlue", + "Base.DeltaEliteMagExtend", + "Base.DeltaEliteMagExtendBlue", + "Base.EblocClip", + "Base.FALMag", + "Base.G17ExtMag", + "Base.G17Mag", + "Base.G17StickMag", + "Base.G19ExtMag", + "Base.G19Mag", + "Base.G20Mag", + "Base.G21Mag", + "Base.G22Mag", + "Base.G23Mag", + "Base.HK91Mag", + "Base.HKS10A357", + "Base.HKS10A38", + "Base.HKS22K", + "Base.HKS29M44", + "Base.HKS36A357", + "Base.HKS36A38", + "Base.HKS586A357", + "Base.HKS586A38", + "Base.HKSDSA38", + "Base.HKSMK3A357", + "Base.HKSMK3A38", + "Base.HKSPYA357", + "Base.HKSPYA38", + "Base.J22Mag", + "Base.L395KMag", + "Base.L395KMagSlugs", + "Base.M14Clip", + "Base.M1CarMag", + "Base.M249Box", + "Base.M3GreaseMag", + "Base.M60Box", + "Base.MAC10Mag", + "Base.MACGreaseMag", + "Base.MarkMag", + "Base.Mauserclip", + "Base.Mini14Mag", + "Base.Mini30Mag", + "Base.MP5Mag", + "Base.OfficerMag", + "Base.P226Mag", + "Base.P228Mag", + "Base.P380Mag", + "Base.P7M13Mag", + "Base.P7M8Mag", + "Base.P89Mag", + "Base.P90Mag", + "Base.PPKMag", + "Base.R25Mag", + "Base.Size3CompII357", + "Base.Size3CompII38", + "Base.Size3CompIII357", + "Base.Size3CompIII38", + "Base.Size4CompII357", + "Base.Size4CompII38", + "Base.Size4CompIII357", + "Base.Size4CompIII38", + "Base.Size5CompII357", + "Base.Size5CompII38", + "Base.Size5CompIII357", + "Base.Size5CompIII38", + "Base.Size6CompII357", + "Base.Size6CompII38", + "Base.Size6CompIII357", + "Base.Size6CompIII38", + "Base.SKSclip", + "Base.SpeedStrip357", + "Base.SpeedStrip38", + "Base.SpeedStrip44", + "Base.TEC9Mag", + "Base.TherARMag", + "Base.TherMini14Mag", + "Base.USP40Mag", + "Base.USP9Mag", + "Base.UziColtSMGMag", + "Base.UziMag", + "Base.ValmetMag", + "Base.Win69AMag", + }, + +} + diff --git a/common/media/lua/client/OpinionatedFirearms_BetterContainersGuns93ModPackInjector.lua b/common/media/lua/client/OpinionatedFirearms_BetterContainersGuns93ModPackInjector.lua new file mode 100644 index 0000000..4114e89 --- /dev/null +++ b/common/media/lua/client/OpinionatedFirearms_BetterContainersGuns93ModPackInjector.lua @@ -0,0 +1,135 @@ +local OFBCGuns93ModPackInjector = { + installed = false, + tickHookAdded = false, +} + +local APPLY_MODS_MODULE = "BetterContainers/Categorize/Categories/_applyMods" +local GUNS93_PACK_PATH = "mods/guns93_items" + +local BC_MOD_IDS = { + "EURY_CONTAINERS", + "REORDER_CONTAINERS", + "\\EURY_CONTAINERS", + "\\REORDER_CONTAINERS", +} + +local GUNS93_MOD_IDS = { + "guns93", + "\\guns93", +} + +local function getActivatedModsList() + if type(getActivatedMods) ~= "function" then + return nil + end + + local mods = getActivatedMods() + if not mods or type(mods.contains) ~= "function" then + return nil + end + + return mods +end + +local function isBetterContainersActive() + local mods = getActivatedModsList() + if not mods then + return nil + end + + for i = 1, #BC_MOD_IDS do + if mods:contains(BC_MOD_IDS[i]) then + return true + end + end + + return false +end + +local function isGuns93Active() + local mods = getActivatedModsList() + if not mods then + return false + end + + for i = 1, #GUNS93_MOD_IDS do + if mods:contains(GUNS93_MOD_IDS[i]) then + return true + end + end + + return false +end + +local function installApplyModsWrapper() + if OFBCGuns93ModPackInjector.installed then + return true + end + + local bcState = isBetterContainersActive() + if bcState == false then + OFBCGuns93ModPackInjector.installed = true + return true + end + if bcState == nil then + return false + end + + if _G.OF_GUNS93_BC_APPLYMODS_WRAPPED then + OFBCGuns93ModPackInjector.installed = true + return true + end + + local ok, applyMods = pcall(require, APPLY_MODS_MODULE) + if not ok or type(applyMods) ~= "function" then + return false + end + + if type(package) ~= "table" or type(package.loaded) ~= "table" then + return false + end + + local function wrappedApplyMods(loadCategoryFile, dlog) + applyMods(loadCategoryFile, dlog) + + if not isGuns93Active() then + return + end + + if type(loadCategoryFile) == "function" then + loadCategoryFile(GUNS93_PACK_PATH) + if dlog then + dlog("Loaded category pack guns93_items") + end + end + end + + package.loaded[APPLY_MODS_MODULE] = wrappedApplyMods + _G.OF_GUNS93_BC_APPLYMODS_WRAPPED = true + OFBCGuns93ModPackInjector.installed = true + return true +end + +local function tryInstallOnTick() + if installApplyModsWrapper() then + OFBCGuns93ModPackInjector.tickHookAdded = false + Events.OnTick.Remove(tryInstallOnTick) + end +end + +local function ensureTickHook() + if OFBCGuns93ModPackInjector.tickHookAdded then + return + end + + OFBCGuns93ModPackInjector.tickHookAdded = true + Events.OnTick.Add(tryInstallOnTick) +end + +if not installApplyModsWrapper() then + ensureTickHook() +end + +if Events.OnMainMenuEnter and type(Events.OnMainMenuEnter.Add) == "function" then + Events.OnMainMenuEnter.Add(installApplyModsWrapper) +end diff --git a/common/media/lua/server/OpinionatedFirearms_HotBrassAmmoMakerPatch.lua b/common/media/lua/server/OpinionatedFirearms_HotBrassAmmoMakerPatch.lua index 291bf49..4cf66e2 100644 --- a/common/media/lua/server/OpinionatedFirearms_HotBrassAmmoMakerPatch.lua +++ b/common/media/lua/server/OpinionatedFirearms_HotBrassAmmoMakerPatch.lua @@ -20,6 +20,59 @@ local function getAmmoMakerFiredCasing(ammoType) return nil end + local function getAmmoTypeData() + if type(ammoMakerAmmoTypes) ~= "table" then + return nil + end + + local data = ammoMakerAmmoTypes[ammoType] + if type(data) ~= "table" or type(data.ammoTypes) ~= "table" or #data.ammoTypes == 0 then + return nil + end + + return data + end + + local function getActiveAmmoData(typeData) + if type(typeData) ~= "table" or type(typeData.ammoTypes) ~= "table" or type(ammoMakerAmmoData) ~= "table" then + return nil + end + + local activeIndex = 1 + if type(typeData.modIds) == "table" and type(ammoMakerCompatibleMods) == "table" then + for i = 1, #typeData.modIds do + local modId = typeData.modIds[i] + if ammoMakerCompatibleMods[modId] == true then + activeIndex = i + end + end + end + + if activeIndex < 1 or activeIndex > #typeData.ammoTypes then + activeIndex = 1 + end + + local activeAmmoKey = typeData.ammoTypes[activeIndex] + if type(activeAmmoKey) == "string" then + local activeAmmoData = ammoMakerAmmoData[activeAmmoKey] + if type(activeAmmoData) == "table" then + return activeAmmoData + end + end + + for i = 1, #typeData.ammoTypes do + local ammoKey = typeData.ammoTypes[i] + if type(ammoKey) == "string" then + local ammoData = ammoMakerAmmoData[ammoKey] + if type(ammoData) == "table" then + return ammoData + end + end + end + + return nil + end + local function partDataToFiredType(partData) if type(partData) ~= "table" then return nil @@ -37,30 +90,16 @@ local function getAmmoMakerFiredCasing(ammoType) return nil end - if type(ammoMakerGetCasingType) == "function" then - local ok, casingType = pcall(ammoMakerGetCasingType, ammoType) - if ok and type(casingType) == "string" then - local firedType = partDataToFiredType(ammoMakerAmmoParts[casingType]) - if firedType then - return firedType - end - end + local ammoTypeData = getAmmoTypeData() + if not ammoTypeData then + return nil end - -- Fallback path that doesn't depend on Ammo Maker active-mod resolution. - if type(ammoMakerAmmoTypes) == "table" and type(ammoMakerAmmoData) == "table" then - local ammoDef = ammoMakerAmmoTypes[ammoType] - if type(ammoDef) == "table" and type(ammoDef.ammoTypes) == "table" then - for i = 1, #ammoDef.ammoTypes do - local ammoKey = ammoDef.ammoTypes[i] - local ammoData = ammoMakerAmmoData[ammoKey] - if type(ammoData) == "table" and type(ammoData.casingType) == "string" then - local firedType = partDataToFiredType(ammoMakerAmmoParts[ammoData.casingType]) - if firedType then - return firedType - end - end - end + local ammoData = getActiveAmmoData(ammoTypeData) + if type(ammoData) == "table" and type(ammoData.casingType) == "string" then + local firedType = partDataToFiredType(ammoMakerAmmoParts[ammoData.casingType]) + if firedType then + return firedType end end diff --git a/common/media/lua/shared/OpinionatedFirearms_AmmoMakerSpentCasingsDisplayCategoryPatch.lua b/common/media/lua/shared/OpinionatedFirearms_AmmoMakerSpentCasingsDisplayCategoryPatch.lua new file mode 100644 index 0000000..8217c9b --- /dev/null +++ b/common/media/lua/shared/OpinionatedFirearms_AmmoMakerSpentCasingsDisplayCategoryPatch.lua @@ -0,0 +1,127 @@ +local OFAmmoMakerDisplayCategoryPatch = { + patched = false, + tickHookAdded = false, +} + +local SPENT_CASINGS_CATEGORY = "OFSpentCasings" +local AMMO_PART_CATEGORY = "OFAmmoPart" + +local function addAmmoMakerType(typeSet, fullType) + if type(fullType) ~= "string" or fullType == "" then + return + end + + if not string.find(fullType, "^ammomaker%.") then + return + end + + typeSet[fullType] = true +end + +local function setDisplayCategory(scriptManager, fullType, category) + local scriptItem = scriptManager:FindItem(fullType) + if not scriptItem then + return false + end + + if type(scriptItem.DoParam) == "function" then + scriptItem:DoParam("DisplayCategory = " .. category) + return true + end + + if type(scriptItem.setDisplayCategory) == "function" then + scriptItem:setDisplayCategory(category) + return true + end + + return false +end + +local function collectAmmoMakerTypes() + if type(ammoMakerAmmoParts) ~= "table" then + return nil, nil + end + + local spentCasingTypes = {} + local ammoPartTypes = {} + + for _, partData in pairs(ammoMakerAmmoParts) do + if type(partData) == "table" then + local partClass = partData.partClass + if partClass == "Casing" or partClass == "Hull" then + addAmmoMakerType(spentCasingTypes, partData.partOld) + addAmmoMakerType(spentCasingTypes, partData.partFired) + addAmmoMakerType(ammoPartTypes, partData.boxType) + addAmmoMakerType(ammoPartTypes, partData.bagType) + end + end + end + + return spentCasingTypes, ammoPartTypes +end + +local function applyCategory(scriptManager, itemTypes, category) + local patchedAny = false + + for fullType in pairs(itemTypes) do + if setDisplayCategory(scriptManager, fullType, category) then + patchedAny = true + end + end + + return patchedAny +end + +local function applyPatch() + if OFAmmoMakerDisplayCategoryPatch.patched then + return true + end + + local scriptManager = ScriptManager and ScriptManager.instance + if not scriptManager or type(scriptManager.FindItem) ~= "function" then + return false + end + + local spentCasingTypes, ammoPartTypes = collectAmmoMakerTypes() + if not spentCasingTypes or not ammoPartTypes then + return false + end + + local patchedSpentCasings = applyCategory(scriptManager, spentCasingTypes, SPENT_CASINGS_CATEGORY) + local patchedAmmoParts = applyCategory(scriptManager, ammoPartTypes, AMMO_PART_CATEGORY) + if not patchedSpentCasings and not patchedAmmoParts then + return false + end + + OFAmmoMakerDisplayCategoryPatch.patched = true + return true +end + +local function tryPatchOnTick() + if applyPatch() then + OFAmmoMakerDisplayCategoryPatch.tickHookAdded = false + Events.OnTick.Remove(tryPatchOnTick) + end +end + +local function ensureTickHook() + if OFAmmoMakerDisplayCategoryPatch.tickHookAdded then + return + end + + OFAmmoMakerDisplayCategoryPatch.tickHookAdded = true + Events.OnTick.Add(tryPatchOnTick) +end + +if not applyPatch() then + ensureTickHook() +end + +if Events.OnMainMenuEnter and type(Events.OnMainMenuEnter.Add) == "function" then + Events.OnMainMenuEnter.Add(function() + OFAmmoMakerDisplayCategoryPatch.patched = false + if not applyPatch() then + ensureTickHook() + end + end) +end diff --git a/common/media/lua/shared/OpinionatedFirearms_Guns93DisplayCategoryPatch.lua b/common/media/lua/shared/OpinionatedFirearms_Guns93DisplayCategoryPatch.lua new file mode 100644 index 0000000..052ea2e --- /dev/null +++ b/common/media/lua/shared/OpinionatedFirearms_Guns93DisplayCategoryPatch.lua @@ -0,0 +1,510 @@ +local OFGuns93DisplayCategoryPatch = { + patched = false, + tickHookAdded = false, + repatchQueued = false, +} + +local BC_FIREARM_CATEGORY = "WepFire" +local BC_MAGAZINE_CATEGORY = "WepAmmoMag" + +local GUNS93_SENTINEL_FIREARM = "Base.83Cheetah" +local GUNS93_SENTINEL_MAGAZINE = "Base.83Mag" + +local function resolveWeaponCategories() + return BC_FIREARM_CATEGORY, BC_MAGAZINE_CATEGORY +end + +local GUNS93_FIREARMS = { + ["Base.83Cheetah"] = true, + ["Base.AKM"] = true, + ["Base.AKSport"] = true, + ["Base.Anaconda"] = true, + ["Base.AR15"] = true, + ["Base.AR180"] = true, + ["Base.AssaultRifle"] = true, + ["Base.AssaultRifle2"] = true, + ["Base.Auto5"] = true, + ["Base.Auto5_Alt"] = true, + ["Base.BenelliM3"] = true, + ["Base.BenelliM3_Alt"] = true, + ["Base.Beretta682"] = true, + ["Base.Beretta682_Alt"] = true, + ["Base.Beretta92FS"] = true, + ["Base.BHP"] = true, + ["Base.Bobcat"] = true, + ["Base.Brown3006BAR"] = true, + ["Base.Brown308BAR"] = true, + ["Base.BrownCitori"] = true, + ["Base.BrownCitori_Alt"] = true, + ["Base.Buckmark"] = true, + ["Base.CalicoPistol"] = true, + ["Base.CalicoRifle"] = true, + ["Base.CAR15"] = true, + ["Base.Colt9mm"] = true, + ["Base.ColtArmy"] = true, + ["Base.ColtDet"] = true, + ["Base.Command1911"] = true, + ["Base.CZ75B"] = true, + ["Base.DE357"] = true, + ["Base.DeltaElite"] = true, + ["Base.Dissy"] = true, + ["Base.DoubleBarrelShotgun"] = true, + ["Base.DoubleBarrelShotgun_Alt"] = true, + ["Base.DoubleBarrelShotgunSawnoff"] = true, + ["Base.DoubleBarrelShotgunSawnoff_Alt"] = true, + ["Base.FAL"] = true, + ["Base.Glock17"] = true, + ["Base.Glock17L"] = true, + ["Base.Glock19"] = true, + ["Base.Glock20"] = true, + ["Base.Glock21"] = true, + ["Base.Glock22"] = true, + ["Base.Glock23"] = true, + ["Base.Glock24"] = true, + ["Base.Gov1911"] = true, + ["Base.GP100"] = true, + ["Base.GP100_Alt"] = true, + ["Base.GP101"] = true, + ["Base.GP101_Alt"] = true, + ["Base.Hammerless"] = true, + ["Base.HBAR"] = true, + ["Base.HK91"] = true, + ["Base.HuntingRifle"] = true, + ["Base.Ithaca37"] = true, + ["Base.Ithaca37_Alt"] = true, + ["Base.Ithaca37Riot"] = true, + ["Base.Ithaca37Riot_Alt"] = true, + ["Base.J22"] = true, + ["Base.Javelina"] = true, + ["Base.L395K"] = true, + ["Base.L395K_Alt"] = true, + ["Base.Longslide"] = true, + ["Base.M1903"] = true, + ["Base.M1917"] = true, + ["Base.M1A"] = true, + ["Base.M1ABush"] = true, + ["Base.M1Carbine"] = true, + ["Base.M1Garand"] = true, + ["Base.M24"] = true, + ["Base.M249"] = true, + ["Base.M3GreaseGun"] = true, + ["Base.M590"] = true, + ["Base.M590_Alt"] = true, + ["Base.M60"] = true, + ["Base.M635"] = true, + ["Base.M723"] = true, + ["Base.M727"] = true, + ["Base.M733"] = true, + ["Base.M870"] = true, + ["Base.M870_Alt"] = true, + ["Base.MAC10"] = true, + ["Base.Marlin3363030"] = true, + ["Base.Marlin33644"] = true, + ["Base.Marlin39A"] = true, + ["Base.Marlin45"] = true, + ["Base.Marlin60"] = true, + ["Base.Marlin9"] = true, + ["Base.Mauser98K"] = true, + ["Base.Mini14"] = true, + ["Base.Mini30"] = true, + ["Base.Moss500"] = true, + ["Base.Moss500_Alt"] = true, + ["Base.Moss590"] = true, + ["Base.Moss590_Alt"] = true, + ["Base.MP5"] = true, + ["Base.Officer1911"] = true, + ["Base.P226"] = true, + ["Base.P228"] = true, + ["Base.P380"] = true, + ["Base.P7M13"] = true, + ["Base.P7M8"] = true, + ["Base.Pistol"] = true, + ["Base.Pistol2"] = true, + ["Base.Pistol3"] = true, + ["Base.PPK"] = true, + ["Base.Python"] = true, + ["Base.Python_Alt"] = true, + ["Base.R223Rem788"] = true, + ["Base.R223RugM77"] = true, + ["Base.R3006Rem700"] = true, + ["Base.R3006RugM77"] = true, + ["Base.R3030Rem788"] = true, + ["Base.R308Rem700"] = true, + ["Base.R308RugM77"] = true, + ["Base.R44Rem788"] = true, + ["Base.Raven25"] = true, + ["Base.Rem1100"] = true, + ["Base.Rem1100_Alt"] = true, + ["Base.Rem1187P"] = true, + ["Base.Rem1187P_Alt"] = true, + ["Base.Rem223760"] = true, + ["Base.Rem3006760"] = true, + ["Base.Rem308760"] = true, + ["Base.Rem870P"] = true, + ["Base.Rem870P_Alt"] = true, + ["Base.Revolver"] = true, + ["Base.Revolver_Long"] = true, + ["Base.Revolver_Short"] = true, + ["Base.Rug1022"] = true, + ["Base.Rugmark"] = true, + ["Base.RugP89"] = true, + ["Base.RugP90"] = true, + ["Base.SavageFox"] = true, + ["Base.SavageFox_Alt"] = true, + ["Base.SecuritySix"] = true, + ["Base.SecuritySix_Alt"] = true, + ["Base.Shotgun"] = true, + ["Base.Shotgun_Alt"] = true, + ["Base.ShotgunSawnoff"] = true, + ["Base.ShotgunSawnoff_Alt"] = true, + ["Base.SKS"] = true, + ["Base.SOAuto5"] = true, + ["Base.SOAuto5_Alt"] = true, + ["Base.SOBeretta682"] = true, + ["Base.SOBeretta682_Alt"] = true, + ["Base.SOBrownCitori"] = true, + ["Base.SOBrownCitori_Alt"] = true, + ["Base.SOIthaca37"] = true, + ["Base.SOIthaca37_Alt"] = true, + ["Base.SOL395K"] = true, + ["Base.SOL395K_Alt"] = true, + ["Base.SOM24"] = true, + ["Base.SOMoss500"] = true, + ["Base.SOMoss500_Alt"] = true, + ["Base.SOR223Rem700"] = true, + ["Base.SOR223Rem788"] = true, + ["Base.SOR3006Rem700"] = true, + ["Base.SOR3030Rem788"] = true, + ["Base.SOR308Rem700"] = true, + ["Base.SOR308Rem788"] = true, + ["Base.SOR44Rem788"] = true, + ["Base.SORem1100"] = true, + ["Base.SORem1100_Alt"] = true, + ["Base.SOSavageFox"] = true, + ["Base.SOSavageFox_Alt"] = true, + ["Base.SOW223WinM70"] = true, + ["Base.SOW3006WinM70"] = true, + ["Base.SOW308WinM70"] = true, + ["Base.SOWin1200"] = true, + ["Base.SOWin1200_Alt"] = true, + ["Base.SOWin1400"] = true, + ["Base.SOWin1400_Alt"] = true, + ["Base.SOWin1912"] = true, + ["Base.SOWin1912_Alt"] = true, + ["Base.SOWin37"] = true, + ["Base.SOWin37_Alt"] = true, + ["Base.SPAS12"] = true, + ["Base.SPAS12_Alt"] = true, + ["Base.SW10"] = true, + ["Base.SW17"] = true, + ["Base.SW4006"] = true, + ["Base.SW4506"] = true, + ["Base.SW586"] = true, + ["Base.SW586_Alt"] = true, + ["Base.SW5906"] = true, + ["Base.SW65"] = true, + ["Base.SW65_Alt"] = true, + ["Base.T56"] = true, + ["Base.TEC9"] = true, + ["Base.USP40"] = true, + ["Base.USP9"] = true, + ["Base.Uzi"] = true, + ["Base.Valmet"] = true, + ["Base.VarmintRifle"] = true, + ["Base.W223WinM70"] = true, + ["Base.W3006WinM70"] = true, + ["Base.W308WinM70"] = true, + ["Base.Win1200"] = true, + ["Base.Win1200_Alt"] = true, + ["Base.Win1200Def"] = true, + ["Base.Win1200Def_Alt"] = true, + ["Base.Win1400"] = true, + ["Base.Win1400_Alt"] = true, + ["Base.Win1912"] = true, + ["Base.Win1912_Alt"] = true, + ["Base.Win30067400"] = true, + ["Base.Win3087400"] = true, + ["Base.Win37"] = true, + ["Base.Win37_Alt"] = true, + ["Base.Win61"] = true, + ["Base.Win69"] = true, + ["Base.Win943030"] = true, + ["Base.Win94357"] = true, + ["Base.Win94357_Alt"] = true, + ["Base.Win9445"] = true, +} + +local GUNS93_MAGAZINES = { + ["Base.100CalicoMag"] = true, + ["Base.1022Mag"] = true, + ["Base.10M14Mag"] = true, + ["Base.15BHPMag"] = true, + ["Base.17BHPMag"] = true, + ["Base.1908Mag"] = true, + ["Base.1911MagExtend"] = true, + ["Base.1911MagExtendSS"] = true, + ["Base.1911MagSS"] = true, + ["Base.20M16AR180Mag"] = true, + ["Base.20M16Mag"] = true, + ["Base.20M9Mag"] = true, + ["Base.20MP5Mag"] = true, + ["Base.223Rem760Mag"] = true, + ["Base.223RemMag"] = true, + ["Base.25Rug1022Mag"] = true, + ["Base.25UziColtSMGMag"] = true, + ["Base.25UziMag"] = true, + ["Base.3006BARMag"] = true, + ["Base.3006clip"] = true, + ["Base.3006Rem760Mag"] = true, + ["Base.3006WinMag"] = true, + ["Base.3030RemMag"] = true, + ["Base.308BARMag"] = true, + ["Base.308Clip"] = true, + ["Base.308Rem760Mag"] = true, + ["Base.308WinMag"] = true, + ["Base.30M14Mag"] = true, + ["Base.30M16AR180Mag"] = true, + ["Base.30M1CarMag"] = true, + ["Base.30Mini14Mag"] = true, + ["Base.4006Mag"] = true, + ["Base.40AKMag"] = true, + ["Base.40AR180Mag"] = true, + ["Base.40M16AR180Mag"] = true, + ["Base.44Clip"] = true, + ["Base.44RemMag"] = true, + ["Base.4506Mag"] = true, + ["Base.45Clip"] = true, + ["Base.45Moonclip"] = true, + ["Base.556Clip"] = true, + ["Base.5906Mag"] = true, + ["Base.83Mag"] = true, + ["Base.9mmClip"] = true, + ["Base.AK5Mag"] = true, + ["Base.AKBakeMag"] = true, + ["Base.AKDrumMag"] = true, + ["Base.AKMag"] = true, + ["Base.AR180Mag"] = true, + ["Base.BetaCMag"] = true, + ["Base.BHPMag"] = true, + ["Base.BHPMagSS"] = true, + ["Base.BobcatMag"] = true, + ["Base.BuckMag"] = true, + ["Base.CalicoMag"] = true, + ["Base.ColtSMGMag"] = true, + ["Base.CZ75BMag"] = true, + ["Base.DE357Mag"] = true, + ["Base.DeltaEliteMag"] = true, + ["Base.DeltaEliteMagBlue"] = true, + ["Base.DeltaEliteMagExtend"] = true, + ["Base.DeltaEliteMagExtendBlue"] = true, + ["Base.EblocClip"] = true, + ["Base.FALMag"] = true, + ["Base.G17ExtMag"] = true, + ["Base.G17Mag"] = true, + ["Base.G17StickMag"] = true, + ["Base.G19ExtMag"] = true, + ["Base.G19Mag"] = true, + ["Base.G20Mag"] = true, + ["Base.G21Mag"] = true, + ["Base.G22Mag"] = true, + ["Base.G23Mag"] = true, + ["Base.HK91Mag"] = true, + ["Base.HKS10A357"] = true, + ["Base.HKS10A38"] = true, + ["Base.HKS22K"] = true, + ["Base.HKS29M44"] = true, + ["Base.HKS36A357"] = true, + ["Base.HKS36A38"] = true, + ["Base.HKS586A357"] = true, + ["Base.HKS586A38"] = true, + ["Base.HKSDSA38"] = true, + ["Base.HKSMK3A357"] = true, + ["Base.HKSMK3A38"] = true, + ["Base.HKSPYA357"] = true, + ["Base.HKSPYA38"] = true, + ["Base.J22Mag"] = true, + ["Base.L395KMag"] = true, + ["Base.L395KMagSlugs"] = true, + ["Base.M14Clip"] = true, + ["Base.M1CarMag"] = true, + ["Base.M249Box"] = true, + ["Base.M3GreaseMag"] = true, + ["Base.M60Box"] = true, + ["Base.MAC10Mag"] = true, + ["Base.MACGreaseMag"] = true, + ["Base.MarkMag"] = true, + ["Base.Mauserclip"] = true, + ["Base.Mini14Mag"] = true, + ["Base.Mini30Mag"] = true, + ["Base.MP5Mag"] = true, + ["Base.OfficerMag"] = true, + ["Base.P226Mag"] = true, + ["Base.P228Mag"] = true, + ["Base.P380Mag"] = true, + ["Base.P7M13Mag"] = true, + ["Base.P7M8Mag"] = true, + ["Base.P89Mag"] = true, + ["Base.P90Mag"] = true, + ["Base.PPKMag"] = true, + ["Base.R25Mag"] = true, + ["Base.Size3CompII357"] = true, + ["Base.Size3CompII38"] = true, + ["Base.Size3CompIII357"] = true, + ["Base.Size3CompIII38"] = true, + ["Base.Size4CompII357"] = true, + ["Base.Size4CompII38"] = true, + ["Base.Size4CompIII357"] = true, + ["Base.Size4CompIII38"] = true, + ["Base.Size5CompII357"] = true, + ["Base.Size5CompII38"] = true, + ["Base.Size5CompIII357"] = true, + ["Base.Size5CompIII38"] = true, + ["Base.Size6CompII357"] = true, + ["Base.Size6CompII38"] = true, + ["Base.Size6CompIII357"] = true, + ["Base.Size6CompIII38"] = true, + ["Base.SKSclip"] = true, + ["Base.SpeedStrip357"] = true, + ["Base.SpeedStrip38"] = true, + ["Base.SpeedStrip44"] = true, + ["Base.TEC9Mag"] = true, + ["Base.TherARMag"] = true, + ["Base.TherMini14Mag"] = true, + ["Base.USP40Mag"] = true, + ["Base.USP9Mag"] = true, + ["Base.UziColtSMGMag"] = true, + ["Base.UziMag"] = true, + ["Base.ValmetMag"] = true, + ["Base.Win69AMag"] = true, +} + +local function setDisplayCategory(scriptManager, fullType, category) + local scriptItem = scriptManager:FindItem(fullType) + if not scriptItem then + return false + end + + if type(scriptItem.DoParam) == "function" then + scriptItem:DoParam("DisplayCategory = " .. category) + return true + end + + if type(scriptItem.setDisplayCategory) == "function" then + scriptItem:setDisplayCategory(category) + return true + end + + return false +end + +local function areGuns93ItemsReady(scriptManager) + if not scriptManager then + return false + end + + local firearm = scriptManager:FindItem(GUNS93_SENTINEL_FIREARM) + local magazine = scriptManager:FindItem(GUNS93_SENTINEL_MAGAZINE) + return firearm ~= nil and magazine ~= nil +end + +local function applyPatch() + if OFGuns93DisplayCategoryPatch.patched then + return true + end + + local scriptManager = ScriptManager and ScriptManager.instance + if not scriptManager or type(scriptManager.FindItem) ~= "function" then + return false + end + + local firearmCategory, magazineCategory = resolveWeaponCategories() + + if not areGuns93ItemsReady(scriptManager) then + return false + end + + local patchedCount = 0 + for fullType in pairs(GUNS93_FIREARMS) do + if setDisplayCategory(scriptManager, fullType, firearmCategory) then + patchedCount = patchedCount + 1 + end + end + + for fullType in pairs(GUNS93_MAGAZINES) do + if setDisplayCategory(scriptManager, fullType, magazineCategory) then + patchedCount = patchedCount + 1 + end + end + + if patchedCount == 0 then + return false + end + + OFGuns93DisplayCategoryPatch.patched = true + return true +end + +local function tryPatchOnTick() + if applyPatch() then + OFGuns93DisplayCategoryPatch.tickHookAdded = false + Events.OnTick.Remove(tryPatchOnTick) + end +end + +local function ensureTickHook() + if OFGuns93DisplayCategoryPatch.tickHookAdded then + return + end + + OFGuns93DisplayCategoryPatch.tickHookAdded = true + Events.OnTick.Add(tryPatchOnTick) +end + +local function queueRepatchNow() + OFGuns93DisplayCategoryPatch.patched = false + if not applyPatch() then + ensureTickHook() + end +end + +local function runQueuedRepatch() + OFGuns93DisplayCategoryPatch.repatchQueued = false + Events.OnTick.Remove(runQueuedRepatch) + queueRepatchNow() +end + +local function queueRepatch() + if OFGuns93DisplayCategoryPatch.repatchQueued then + return + end + + OFGuns93DisplayCategoryPatch.repatchQueued = true + Events.OnTick.Add(runQueuedRepatch) +end + +local function tryInstallBetterContainersRepatchHook() + local ok, helpers = pcall(require, "BetterContainers/Helpers") + if not ok or type(helpers) ~= "table" then + return + end + + local eventName = helpers.OPTIONS_APPLIED + if type(eventName) ~= "string" then + return + end + + local event = Events[eventName] + if event and type(event.Add) == "function" then + event.Add(queueRepatch) + end +end + +if not applyPatch() then + ensureTickHook() +end + +if Events.OnMainMenuEnter and type(Events.OnMainMenuEnter.Add) == "function" then + Events.OnMainMenuEnter.Add(queueRepatch) +end + +tryInstallBetterContainersRepatchHook() diff --git a/common/media/lua/shared/Translate/EN/IG_UI_EN.txt b/common/media/lua/shared/Translate/EN/IG_UI_EN.txt new file mode 100644 index 0000000..d756abe --- /dev/null +++ b/common/media/lua/shared/Translate/EN/IG_UI_EN.txt @@ -0,0 +1,7 @@ +IGUI_EN = { + IGUI_ItemCat_WepFire = "Weapon - Firearm", + IGUI_ItemCat_WepAmmoMag = "Weapon - Magazine", + IGUI_ItemCat_Casings = "Spent Casings", + IGUI_ItemCat_OFSpentCasings = "Spent Casings", + IGUI_ItemCat_OFAmmoPart = "Ammo Part", +}