Fix TTT ammo and mergeslots issue

This commit is contained in:
TheOnly8Z 2021-05-26 22:20:52 +08:00
parent 5066be174e
commit a2ac5f2d24
5 changed files with 17 additions and 9 deletions

View File

@ -10,7 +10,7 @@ ArcCW.TTT_AttInfo = ArcCW.TTT_AttInfo or {}
local TTTPanel = {
{ type = "h", text = "#arccw.ttt_serverhelp" },
{ type = "b", text = "#arccw.cvar.ttt_replace", var = "arccw_ttt_replace", sv = true },
{ type = "b", text = "#arccw.cvar.ammo_replace", var = "arccw_ammo_replace", sv = true },
{ type = "b", text = "#arccw.cvar.ammo_replace", var = "arccw_ttt_ammo", sv = true },
{ type = "b", text = "#arccw.cvar.ttt_atts", var = "arccw_ttt_atts", sv = true },
{ type = "o", text = "#arccw.cvar.ttt_customizemode", var = "arccw_ttt_customizemode", sv = true,
choices = {[0] = "#arccw.cvar.ttt_customizemode.0", [1] = "#arccw.cvar.ttt_customizemode.1", [2] = "#arccw.cvar.ttt_customizemode.2", [3] = "#arccw.cvar.ttt_customizemode.3"}},

View File

@ -38,6 +38,7 @@ ArcCW.TTTReplaceTable = {
if engine.ActiveGamemode() != "terrortown" then return end
CreateConVar("arccw_ttt_replace", 1, FCVAR_ARCHIVE + FCVAR_REPLICATED, "Use custom code to forcefully replace TTT weapons with ArcCW ones.", 0, 1)
CreateConVar("arccw_ttt_ammo", 1, FCVAR_ARCHIVE + FCVAR_REPLICATED, "Replace TTT ammo with ArcCW ones, takes precedence over the default convar.", 0, 1)
CreateConVar("arccw_ttt_atts", 1, FCVAR_ARCHIVE + FCVAR_REPLICATED, "Automatically set up ArcCW weapons with an attachment loadout.", 0, 1)
CreateConVar("arccw_ttt_customizemode", 1, FCVAR_ARCHIVE + FCVAR_REPLICATED, "If set to 1, disallow customization on ArcCW weapons. If set to 2, players can customize during setup and postgame. If set to 3, only T and Ds can customize.", 0, 3)
CreateConVar("arccw_ttt_bodyattinfo", 1, FCVAR_ARCHIVE + FCVAR_REPLICATED, "Whether a corpse contains info on the attachments of the murder weapon. 1 means detective only and 2 means everyone.", 0, 2)
@ -52,10 +53,12 @@ hook.Add("InitPostEntity", "ArcCW_TTT", function()
continue
end
if weap.ArcCW and !weap.Spawnable then
--[[]
if weap.AutoSpawnable then
--print(weap.ClassName)
--print("\t- Not spawnable but AutoSpawnable so alright")
end
]]
--print(weap.ClassName)
--print("\t- Not spawnable, ignored")
continue
@ -113,6 +116,11 @@ hook.Add("InitPostEntity", "ArcCW_TTT", function()
end
local pistol_ammo = (scripted_ents.GetStored("arccw_ammo_pistol") or {}).t
if pistol_ammo then
pistol_ammo.AmmoCount = 30
end
-- Language string(s)
if CLIENT then
LANG.AddToLanguage("English", "search_dmg_buckshot", "This person was blasted to pieces by buckshot.")

View File

@ -62,9 +62,10 @@ end
hook.Add("Initialize", "ArcCW_AddGrenadeAmmo", ArcCW.AddGrenadeAmmo)
if SERVER then
hook.Add( "OnEntityCreated", "ArcCW_AmmoReplacement", function(ent)
if GetConVar("arccw_ammo_replace"):GetBool() and ArcCW.AmmoEntToArcCW[ent:GetClass()] then
if ((engine.ActiveGamemode() == "terrortown" and GetConVar("arccw_ttt_ammo"):GetBool()) or
(engine.ActiveGamemode() != "terrortown" and GetConVar("arccw_ammo_replace"):GetBool()))
and ArcCW.AmmoEntToArcCW[ent:GetClass()] then
timer.Simple(0, function()
if !IsValid(ent) then return end
local ammoent = ents.Create(ArcCW.AmmoEntToArcCW[ent:GetClass()])
@ -79,14 +80,15 @@ if SERVER then
timer.Simple(2, function()
if IsValid(ammoent) then ammoent:SetOwner(nil) end
end)
ammoent.AmmoCount = ent.AmmoAmount
end
-- Dropped ammo may have less rounds than usual
ammoent.AmmoCount = ent.AmmoAmount or ammoent.AmmoCount
--[[]
if ent:GetClass() == "item_ammo_pistol_ttt" and ent.AmmoCount == 20 then
-- Extremely ugly hack: TTT pistol ammo only gives 20 rounds but we want it to be 30
-- Because most SMGs use pistol ammo (unlike vanilla TTT) and it runs out quickly
ammoent.AmmoCount = 30
end
]]
ammoent:SetNWInt("truecount", ammoent.AmmoCount)
end
end)

View File

@ -10,9 +10,6 @@ ENT.Model = "models/items/arccw/pistol_ammo.mdl"
ENT.AmmoType = "pistol"
ENT.AmmoCount = 40
if engine.ActiveGamemode() == "terrortown" then
ENT.AmmoCount = 30
end
ENT.DetonationDamage = 10
ENT.DetonationRadius = 256

View File

@ -98,10 +98,11 @@ function SWEP:NPC_SetupAttachments()
n = n + 1
end
self.ActiveElementCache = nil -- Reset cache so we have the proper attachments to check with
for i, slot in pairs(self.Attachments) do
if !slot.Installed then continue end
local atttbl = ArcCW.AttachmentTable[slot.Installed]
if !ArcCW:SlotAcceptsAtt(slot.Slot, self, slot.Installed) then slot.Installed = nil end
if !ArcCW:SlotAcceptsAtt(slot.Slot, self, slot.Installed) then slot.Installed = nil continue end
if !self:CheckFlags(slot.ExcludeFlags, slot.RequireFlags) then slot.Installed = nil continue end
if !self:CheckFlags(atttbl.ExcludeFlags, atttbl.RequireFlags) then slot.Installed = nil continue end
end