diff --git a/42/icon.png b/42/icon.png new file mode 100644 index 0000000..d85ddb8 Binary files /dev/null and b/42/icon.png differ diff --git a/42/mod.info b/42/mod.info index 23b05d4..c345fda 100644 --- a/42/mod.info +++ b/42/mod.info @@ -3,6 +3,7 @@ id=hrsys_opinionated_firearms author=Riggs0 modversion=1.0.0 versionMin=42.12.13 -require=\GaelGunStore_ALPHA - -description=Opinionated Firearms spawn distribution controller for GaelGunStore (B42). +require=\guns93,\2788256295/ammomaker,\HBVCEFb42 +description=Opinionated Firearms casing and other changes to Guns of 93, Ammomaker and Hot Brass +icon=icon.png +poster=preview.png diff --git a/42/preview.png b/42/preview.png new file mode 100644 index 0000000..b780e1c Binary files /dev/null and b/42/preview.png differ diff --git a/art/icon.png b/art/icon.png new file mode 100644 index 0000000..d85ddb8 Binary files /dev/null and b/art/icon.png differ diff --git a/art/icon.psd b/art/icon.psd new file mode 100644 index 0000000..c6292b5 Binary files /dev/null and b/art/icon.psd differ diff --git a/art/preview.png b/art/preview.png new file mode 100644 index 0000000..b780e1c Binary files /dev/null and b/art/preview.png differ diff --git a/art/preview.psd b/art/preview.psd new file mode 100644 index 0000000..a69ead1 Binary files /dev/null and b/art/preview.psd differ diff --git a/art/workshop-preview.png b/art/workshop-preview.png new file mode 100644 index 0000000..0d53816 Binary files /dev/null and b/art/workshop-preview.png differ diff --git a/common/media/lua/server/OpinionatedFirearms_HotBrassAmmoMakerPatch.lua b/common/media/lua/server/OpinionatedFirearms_HotBrassAmmoMakerPatch.lua new file mode 100644 index 0000000..291bf49 --- /dev/null +++ b/common/media/lua/server/OpinionatedFirearms_HotBrassAmmoMakerPatch.lua @@ -0,0 +1,134 @@ +local OFHotBrassPatch = { + patched = false, +} + +local function isPatchToggleEnabled() + local vars = SandboxVars and SandboxVars.OpinionatedFirearms + if vars and vars.HBVCEFAmmoMakerPatch ~= nil then + return vars.HBVCEFAmmoMakerPatch == true + end + + return true +end + +local function isSessionEligible() + return isPatchToggleEnabled() +end + +local function getAmmoMakerFiredCasing(ammoType) + if type(ammoType) ~= "string" or ammoType == "" then + return nil + end + + local function partDataToFiredType(partData) + if type(partData) ~= "table" then + return nil + end + + local firedType = partData.partFired or partData.partOld + if type(firedType) ~= "string" or firedType == "" then + return nil + end + + return firedType + end + + if type(ammoMakerAmmoParts) ~= "table" then + 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 + 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 + end + end + + return nil +end + +local function applyPatch() + if OFHotBrassPatch.patched then + return true + end + + if not isSessionEligible() then + return false + end + + if type(SpentCasingPhysics) ~= "table" then + return false + end + + if type(SpentCasingPhysics.getItemToEject) ~= "function" then + return false + end + + if type(SpentCasingPhysics.doSpawnCasing) ~= "function" then + return false + end + + local originalGetItemToEject = SpentCasingPhysics.getItemToEject + local originalDoSpawnCasing = SpentCasingPhysics.doSpawnCasing + + SpentCasingPhysics.getItemToEject = function(ammoType) + local mappedType = getAmmoMakerFiredCasing(ammoType) + if mappedType then + return mappedType + end + + return originalGetItemToEject(ammoType) + end + + SpentCasingPhysics.doSpawnCasing = function(player, weapon, params, racking, optionalItem) + if not optionalItem and weapon and weapon.getAmmoType then + local ammoType = weapon:getAmmoType() + if ammoType then + local mappedType = getAmmoMakerFiredCasing(tostring(ammoType)) + if mappedType then + optionalItem = mappedType + if racking then + -- Force rack ejects to stay as empties for this patch. + racking = false + end + end + end + end + + return originalDoSpawnCasing(player, weapon, params, racking, optionalItem) + end + + OFHotBrassPatch.patched = true + return true +end + +local function tryPatchOnTick() + if OFHotBrassPatch.patched then + Events.OnTick.Remove(tryPatchOnTick) + return + end + + applyPatch() +end + +Events.OnTick.Add(tryPatchOnTick) diff --git a/common/media/lua/shared/OpinionatedFirearms_AmmoMakerCasingCommandGate.lua b/common/media/lua/shared/OpinionatedFirearms_AmmoMakerCasingCommandGate.lua new file mode 100644 index 0000000..5094315 --- /dev/null +++ b/common/media/lua/shared/OpinionatedFirearms_AmmoMakerCasingCommandGate.lua @@ -0,0 +1,70 @@ +local BLOCKED_AMMOMAKER_COMMANDS = { + returnCasingsOnAttack = true, + incrementSpendtRoundCount = true, + returnCasingsOnReload = true, +} + +local function isPatchToggleEnabled() + local vars = SandboxVars and SandboxVars.OpinionatedFirearms + if vars and vars.HBVCEFAmmoMakerPatch ~= nil then + return vars.HBVCEFAmmoMakerPatch == true + end + + return true +end + +local function shouldBlockAmmoMakerCasingCommands() + return isPatchToggleEnabled() +end + +local function getModuleAndCommand(...) + local argc = select("#", ...) + if argc < 2 then + return nil, nil + end + + local firstArg = select(1, ...) + if type(firstArg) == "string" then + return firstArg, select(2, ...) + end + + if argc >= 3 then + return select(2, ...), select(3, ...) + end + + return nil, nil +end + +local function installCommandGate() + if _G.OpinionatedFirearms_AmmoMakerCommandGateInstalled then + return true + end + + if type(sendClientCommand) ~= "function" then + return false + end + + _G.OpinionatedFirearms_AmmoMakerCommandGateInstalled = true + _G.OpinionatedFirearms_OriginalSendClientCommand = sendClientCommand + + sendClientCommand = function(...) + local module, command = getModuleAndCommand(...) + if module == "ammomaker" and BLOCKED_AMMOMAKER_COMMANDS[command] and shouldBlockAmmoMakerCasingCommands() then + return + end + + return _G.OpinionatedFirearms_OriginalSendClientCommand(...) + end + + return true +end + +local function ensureGateOnTick() + if installCommandGate() then + Events.OnTick.Remove(ensureGateOnTick) + end +end + +if not installCommandGate() then + Events.OnTick.Add(ensureGateOnTick) +end diff --git a/common/media/lua/shared/Translate/EN/Sandbox_EN.txt b/common/media/lua/shared/Translate/EN/Sandbox_EN.txt new file mode 100644 index 0000000..d01d0a7 --- /dev/null +++ b/common/media/lua/shared/Translate/EN/Sandbox_EN.txt @@ -0,0 +1,3 @@ +Sandbox_OpinionatedFirearms = "Opinionated Firearms", +Sandbox_HBVCEFAmmoMakerPatch = "Hot Brass -> Ammo Maker Casings", +Sandbox_HBVCEFAmmoMakerPatch_tooltip = "When enabled, Hot Brass ejects Ammo Maker fired casings with Guns93 and will not eject Guns93 casing.", diff --git a/common/media/sandbox-options.txt b/common/media/sandbox-options.txt new file mode 100644 index 0000000..6e8448f --- /dev/null +++ b/common/media/sandbox-options.txt @@ -0,0 +1,7 @@ +VERSION = 1, +option OpinionatedFirearms.HBVCEFAmmoMakerPatch { + type = boolean, + default = true, + page = OpinionatedFirearms, + translation = HBVCEFAmmoMakerPatch, +} diff --git a/icon.png b/icon.png new file mode 100644 index 0000000..d85ddb8 Binary files /dev/null and b/icon.png differ diff --git a/mod.info b/mod.info index 23b05d4..c345fda 100644 --- a/mod.info +++ b/mod.info @@ -3,6 +3,7 @@ id=hrsys_opinionated_firearms author=Riggs0 modversion=1.0.0 versionMin=42.12.13 -require=\GaelGunStore_ALPHA - -description=Opinionated Firearms spawn distribution controller for GaelGunStore (B42). +require=\guns93,\2788256295/ammomaker,\HBVCEFb42 +description=Opinionated Firearms casing and other changes to Guns of 93, Ammomaker and Hot Brass +icon=icon.png +poster=preview.png diff --git a/preview.png b/preview.png new file mode 100644 index 0000000..b780e1c Binary files /dev/null and b/preview.png differ