TTT improvements

- Role based crosshair color
- Nerve Gas kill icon (gas grenade)
- Fixed bug with non-networked ragdoll causing error w/ body attachment info
- Fixed customize hud not disappearing when weapon is dropped
- Fixed random spawns w/ mag reducers not updating ammo
- Fixed ammo taking nerve gas dmg
This commit is contained in:
TheOnly8Z 2020-07-05 04:56:50 -04:00
parent ee396eb5d0
commit a875e462cf
6 changed files with 46 additions and 48 deletions

View File

@ -1,15 +1,19 @@
if engine.ActiveGamemode() != "terrortown" then return end
CreateClientConVar("arccw_ttt_inforoundstart", "1", true, false, "Whether to show ArcCW config every round.")
CreateClientConVar("arccw_ttt_rolecrosshair", "1", true, false, "Whether to color your crosshair according to your role.")
ArcCW.TTT_AttInfo = {}
net.Receive("arccw_ttt_bodyattinfo", function()
local rag = net.ReadEntity()
rag.ArcCW_AttInfo = {}
rag = rag:EntIndex()
ArcCW.TTT_AttInfo[rag] = {}
local atts = net.ReadUInt(8)
for i = 1, atts do
local id = net.ReadUInt(ArcCW.GetBitNecessity())
if id != 0 then
rag.ArcCW_AttInfo[i] = ArcCW.AttachmentIDTable[id]
ArcCW.TTT_AttInfo[rag][i] = ArcCW.AttachmentIDTable[id]
end
end
end)
@ -18,14 +22,15 @@ hook.Add("TTTBodySearchPopulate", "ArcCW_PopulateHUD", function(processed, raw)
-- Attachment Info
local mode = GetConVar("arccw_ttt_bodyattinfo"):GetInt()
if Entity(raw.eidx).ArcCW_AttInfo and (mode == 2 or (mode == 1 and raw.detective_search)) then
local attTbl = ArcCW.TTT_AttInfo[raw.eidx]
if attTbl and (mode == 2 or (mode == 1 and raw.detective_search)) then
local finalTbl = {
img = "arccw/ttticons/arccw_dropattinfo.png",
p = 10.5, -- Right after the murder weapon
text = (mode == 1 and "With your detective skills, you" or "You") .. " deduce the murder weapon had these attachments: "
text = (mode == 1 and "With your detective skills, you deduce" or "You think") .. " the murder weapon had these attachments: "
}
local comma = false
for i, v in pairs(Entity(raw.eidx).ArcCW_AttInfo) do
for i, v in pairs(attTbl) do
if v and ArcCW.AttachmentTable[v] then
finalTbl.text = finalTbl.text .. (comma and ", " or "") .. ArcCW.AttachmentTable[v].PrintName
comma = true
@ -35,10 +40,13 @@ hook.Add("TTTBodySearchPopulate", "ArcCW_PopulateHUD", function(processed, raw)
processed.arccw_atts = finalTbl
end
-- Buckshot kill info
-- kill info
if bit.band(raw.dmg, DMG_BUCKSHOT) == DMG_BUCKSHOT then
processed.dmg.text = LANG.GetTranslation("search_dmg_buckshot")
processed.dmg.img = "arccw/ttticons/kill_buckshot.png"
elseif bit.band(raw.dmg, DMG_NERVEGAS) == DMG_NERVEGAS then
processed.dmg.text = LANG.GetTranslation("search_dmg_nervegas")
processed.dmg.img = "arccw/ttticons/kill_nervegas.png"
end
end)
@ -160,6 +168,7 @@ hook.Add("TTTPrepareRound", "ArcCW_TTT_Info", function()
chat.AddText(Color(255,255,255), "To turn off ArcCW config info, type 'arccw_ttt_inforoundstart 0' in console.")
end
end
ArcCW.TTT_AttInfo = {}
end)
hook.Add("TTTSettingsTabs", "ArcCW_TTT", function(dtabs)
@ -175,9 +184,10 @@ hook.Add("TTTSettingsTabs", "ArcCW_TTT", function(dtabs)
local dgui = vgui.Create("DForm", panellist)
dgui:SetName("Client Settings")
dgui:CheckBox("Enable round startup info", "arccw_ttt_inforoundstart")
dgui:CheckBox("Enable Crosshair", "arccw_crosshair")
dgui:CheckBox("Enable role-based crosshair color", "arccw_ttt_rolecrosshair")
dgui:CheckBox("Enable 2D3D on ammo and weapons", "arccw_2d3d")
dgui:CheckBox("Enable Cheap Scopes (saves perf.)", "arccw_cheapscopes")
dgui:CheckBox("Enable Crosshair", "arccw_crosshair")
dgui:CheckBox("Toggle ADS", "arccw_toggleads")
dgui:CheckBox("E+RMB for UBGL", "arccw_altubglkey")

View File

@ -126,6 +126,7 @@ hook.Add("InitPostEntity", "ArcCW_TTT", function()
-- Language string(s)
if CLIENT then
LANG.AddToLanguage("English", "search_dmg_buckshot", "This person was blasted to pieces by buckshot.")
LANG.AddToLanguage("English", "search_dmg_nervegas", "Their face looks pale. It must have been some sort of nerve gas.")
LANG.AddToLanguage("English", "ammo_smg1_grenade", "Rifle Grenades")
end
end)
@ -133,7 +134,7 @@ end)
hook.Add("DoPlayerDeath", "ArcCW_DetectiveSeeAtts", function(ply, attacker, dmginfo)
local wep = util.WeaponFromDamage(dmginfo)
timer.Simple(0, function()
if GetConVar("arccw_ttt_bodyattinfo"):GetInt() > 0 and ply.server_ragdoll and IsValid(wep) and wep:IsWeapon() and wep.ArcCW then
if GetConVar("arccw_ttt_bodyattinfo"):GetInt() > 0 and ply.server_ragdoll and IsValid(wep) and wep:IsWeapon() and wep.ArcCW and wep.Attachments then
net.Start("arccw_ttt_bodyattinfo")
net.WriteEntity(ply.server_ragdoll)
net.WriteUInt(table.Count(wep.Attachments), 8)

View File

@ -31,6 +31,8 @@ ENT.ResistanceMult = {
[DMG_CLUB] = 0.25,
[DMG_SLASH] = 0.25,
[DMG_CRUSH] = 0.25,
[DMG_NERVEGAS] = 0,
[DMG_POISON] = 0
}
function ENT:Initialize()

View File

@ -24,6 +24,17 @@ function SWEP:DoDrawCrosshair(x, y)
local prong_right = true
local prong_down = true
local clr = Color(255, 255, 255)
if GetConVar("arccw_ttt_rolecrosshair") and GetConVar("arccw_ttt_rolecrosshair"):GetBool() then
if LocalPlayer():IsActiveTraitor() then
clr = Color(255, 50, 50)
elseif LocalPlayer():IsActiveDetective() then
clr = Color(50, 50, 255)
elseif GetRoundState() != ROUND_PREP then
clr = Color(50, 255, 50)
end
end
local gap = ScreenScale(24) * math.Clamp(self:GetDispersion() / 1000, 0.1, 100)
gap = gap + ScreenScale(8) * math.Clamp(self.RecoilAmount, 0, 1)
@ -69,7 +80,7 @@ function SWEP:DoDrawCrosshair(x, y)
surface.SetDrawColor(0, 0, 0, 150 * delta)
surface.DrawRect(x - p_w2 / 2, y - p_w2 / 2, p_w2, p_w2)
surface.SetDrawColor(255, 255, 255, 255 * delta)
surface.SetDrawColor(clr.r, clr.g, clr.b, 255 * delta)
surface.DrawRect(x - p_w / 2, y - p_w / 2, p_w, p_w)
end
@ -115,7 +126,7 @@ function SWEP:DoDrawCrosshair(x, y)
surface.DrawRect(x - p_w2 / 2, y + gap - 1, p_w2, prong2)
end
surface.SetDrawColor(255, 255, 255, 255 * delta)
surface.SetDrawColor(clr.r, clr.g, clr.b, 255 * delta)
if prong_left then
surface.DrawRect(x - gap - prong, y - p_w / 2, prong, p_w)

View File

@ -37,6 +37,10 @@ function SWEP:PreDrop()
end
end
end
if CLIENT then
self:CloseCustomizeHUD()
end
end
function SWEP:DampenDrop()
@ -88,10 +92,8 @@ end
function SWEP:TTT_PostAttachments()
self.IsSilent = self:GetBuff_Override("Suppressor")
if !self.IsSilent then
if self.ShootVol * self:GetBuff_Mult("Mult_ShootVol") <= 90 then
self.IsSilent = true
end
if !self.IsSilent and self.ShootVol * self:GetBuff_Mult("Mult_ShootVol") <= 90 then
self.IsSilent = true
end
end
@ -108,41 +110,13 @@ function SWEP:TTT_Init()
if self.ForgetDefaultBehavior then return end
--[[]
if self.Kind != WEAPON_EQUIP1 and self.Kind != WEAPON_EQUIP2 then
if !self.CanBuy then
if self.Slot == 0 then
-- melee weapons
self.Slot = 6
self.Kind = WEAPON_EQUIP1
elseif self.Slot == 1 then
-- sidearms
self.Kind = WEAPON_PISTOL
elseif self.Slot == 2 then
-- primaries
self.Kind = WEAPON_HEAVY
else
-- idk
self.Slot = 2
self.Kind = WEAPON_HEAVY
end
self.Primary.ClipMax = ArcCW.TTTAmmo_To_ClipMax[self.Primary.Ammo] or self.RegularClipSize * 2 or self.Primary.ClipSize * 2
if self.Throwing then
self.Slot = 3
self.Kind = WEAPON_NADE
end
end
end
if ArcCW.Ammo_To_TTTAmmo[self.Primary.Ammo] then
self.Primary.Ammo = ArcCW.Ammo_To_TTTAmmo[self.Primary.Ammo]
end
self.AmmoEnt = ArcCW.TTTAmmo_To_Ent[self.Primary.Ammo] or ""
]]
self.Primary.ClipMax = ArcCW.TTTAmmo_To_ClipMax[self.Primary.Ammo] or self.RegularClipSize or self.Primary.ClipSize
self:SetClip1(self:GetCapacity())
self.Primary.DefaultClip = self:GetCapacity()
-- This will overwrite mag reducers, so give it a bit of time
timer.Simple(0.1, function()
self:SetClip1(self:GetCapacity())
self.Primary.DefaultClip = self:GetCapacity()
end)
if self.Throwing then
self.Primary.Ammo = "none"

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB