Finished
This commit is contained in:
BIN
42/icon.png
Normal file
BIN
42/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.1 KiB |
@@ -3,6 +3,7 @@ id=hrsys_opinionated_firearms
|
|||||||
author=Riggs0
|
author=Riggs0
|
||||||
modversion=1.0.0
|
modversion=1.0.0
|
||||||
versionMin=42.12.13
|
versionMin=42.12.13
|
||||||
require=\GaelGunStore_ALPHA
|
require=\guns93,\2788256295/ammomaker,\HBVCEFb42
|
||||||
|
description=Opinionated Firearms casing and other changes to Guns of 93, Ammomaker and Hot Brass
|
||||||
description=Opinionated Firearms spawn distribution controller for GaelGunStore (B42).
|
icon=icon.png
|
||||||
|
poster=preview.png
|
||||||
|
|||||||
BIN
42/preview.png
Normal file
BIN
42/preview.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 69 KiB |
BIN
art/icon.png
Normal file
BIN
art/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.1 KiB |
BIN
art/icon.psd
Normal file
BIN
art/icon.psd
Normal file
Binary file not shown.
BIN
art/preview.png
Normal file
BIN
art/preview.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 69 KiB |
BIN
art/preview.psd
Normal file
BIN
art/preview.psd
Normal file
Binary file not shown.
BIN
art/workshop-preview.png
Normal file
BIN
art/workshop-preview.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 26 KiB |
@@ -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)
|
||||||
@@ -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
|
||||||
3
common/media/lua/shared/Translate/EN/Sandbox_EN.txt
Normal file
3
common/media/lua/shared/Translate/EN/Sandbox_EN.txt
Normal file
@@ -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.",
|
||||||
7
common/media/sandbox-options.txt
Normal file
7
common/media/sandbox-options.txt
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
VERSION = 1,
|
||||||
|
option OpinionatedFirearms.HBVCEFAmmoMakerPatch {
|
||||||
|
type = boolean,
|
||||||
|
default = true,
|
||||||
|
page = OpinionatedFirearms,
|
||||||
|
translation = HBVCEFAmmoMakerPatch,
|
||||||
|
}
|
||||||
7
mod.info
7
mod.info
@@ -3,6 +3,7 @@ id=hrsys_opinionated_firearms
|
|||||||
author=Riggs0
|
author=Riggs0
|
||||||
modversion=1.0.0
|
modversion=1.0.0
|
||||||
versionMin=42.12.13
|
versionMin=42.12.13
|
||||||
require=\GaelGunStore_ALPHA
|
require=\guns93,\2788256295/ammomaker,\HBVCEFb42
|
||||||
|
description=Opinionated Firearms casing and other changes to Guns of 93, Ammomaker and Hot Brass
|
||||||
description=Opinionated Firearms spawn distribution controller for GaelGunStore (B42).
|
icon=icon.png
|
||||||
|
poster=preview.png
|
||||||
|
|||||||
BIN
preview.png
Normal file
BIN
preview.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 69 KiB |
Reference in New Issue
Block a user