diff --git a/CHANGELOG.md b/CHANGELOG.md index 80fadad213..725ed14632 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ All notable changes to TTT2 will be documented here. Inspired by [keep a changel - Updated old TTT HUD to show name of spectated player (by @somefnfplayerlol) - Changes to the enabled map prefixes will not be announced to players anymore (by @Histalek) - By default only `ttt` and `ttt2` map prefixes are enabled (by @Histalek) +- Updated `ttt_identify_body_woconfirm` to be replicated across the server and client (by @Wryyyong) ## [v0.14.0b](https://github.com/TTT-2/TTT2/tree/v0.14.0b) (2024-09-20) diff --git a/gamemodes/terrortown/gamemode/server/sv_corpse.lua b/gamemodes/terrortown/gamemode/server/sv_corpse.lua index a22405e825..03833c1c5e 100644 --- a/gamemodes/terrortown/gamemode/server/sv_corpse.lua +++ b/gamemodes/terrortown/gamemode/server/sv_corpse.lua @@ -30,19 +30,6 @@ local IsValid = IsValid local ConVarExists = ConVarExists local hook = hook ---- --- @realm server -local cvBodyfound = CreateConVar( - "ttt_announce_body_found", - "1", - { FCVAR_NOTIFY, FCVAR_ARCHIVE }, - "If detective mode, announce when someone's body is found" -) - ---- --- @realm server -local cvRagCollide = CreateConVar("ttt_ragdoll_collide", "0", { FCVAR_NOTIFY, FCVAR_ARCHIVE }) - local soundsSearch = { Sound("player/footsteps/snow1.wav"), Sound("player/footsteps/snow2.wav"), @@ -60,8 +47,41 @@ ttt_include("sh_corpse") util.AddNetworkString("TTT2SendConfirmMsg") +--- +-- @realm server +CORPSE.cv.announce_body_found = CreateConVar( + "ttt_announce_body_found", + "1", + { FCVAR_NOTIFY, FCVAR_ARCHIVE }, + "If detective mode, announce when someone's body is found" +) + +--- +-- @realm server +CORPSE.cv.confirm_team = CreateConVar( + "ttt2_confirm_team", + "0", + { FCVAR_NOTIFY, FCVAR_ARCHIVE }, + "Show team of confirmed player" +) + +--- +-- @realm server +CORPSE.cv.confirm_killlist = CreateConVar( + "ttt2_confirm_killlist", + "1", + { FCVAR_NOTIFY, FCVAR_ARCHIVE }, + "Confirm players in kill list" +) + +--- +-- @realm server +CORPSE.cv.ragdoll_collide = + CreateConVar("ttt_ragdoll_collide", "0", { FCVAR_NOTIFY, FCVAR_ARCHIVE }) + -- networked data abstraction layer local dti = CORPSE.dti +local config = CORPSE.cv --- -- Sets a CORPSE found state @@ -160,13 +180,13 @@ function CORPSE.IdentifyBody(ply, rag, searchUID) end -- Announce body - if cvBodyfound:GetBool() and notConfirmed then + if config.announce_body_found:GetBool() and notConfirmed then local subrole = rag.was_role local team = rag.was_team local rd = roles.GetByIndex(subrole) local roletext = "body_found_" .. rd.abbr local clr = rag.role_color - local bool = GetGlobalBool("ttt2_confirm_team") + local bool = config.confirm_team:GetBool() net.Start("TTT2SendConfirmMsg") @@ -200,7 +220,7 @@ function CORPSE.IdentifyBody(ply, rag, searchUID) net.Broadcast() end - if GetConVar("ttt2_confirm_killlist"):GetBool() then + if config.confirm_killlist:GetBool() then -- Handle kill list local ragKills = rag.kills @@ -278,7 +298,7 @@ function CORPSE.ShowSearch(ply, rag, isCovert, isLongRange) end if - GetConVar("ttt_identify_body_woconfirm"):GetBool() + config.identify_body_woconfirm:GetBool() and gameloop.IsDetectiveMode() and not isCovert then @@ -640,7 +660,7 @@ function CORPSE.GetPlayerTeam(rag) end hook.Add("ShouldCollide", "TTT2RagdollCollide", function(ent1, ent2) - if cvRagCollide:GetBool() then + if config.ragdoll_collide:GetBool() then return end diff --git a/gamemodes/terrortown/gamemode/server/sv_main.lua b/gamemodes/terrortown/gamemode/server/sv_main.lua index 6c5a7fec0a..7085526656 100644 --- a/gamemodes/terrortown/gamemode/server/sv_main.lua +++ b/gamemodes/terrortown/gamemode/server/sv_main.lua @@ -130,33 +130,6 @@ local map_switch_delay = CreateConVar( 0 ) ---- --- @realm server -CreateConVar( - "ttt_identify_body_woconfirm", - "1", - { FCVAR_NOTIFY, FCVAR_ARCHIVE }, - "Toggles whether ragdolls should be confirmed in gameloop.IsDetectiveMode() without clicking on confirm espacially" -) - ---- --- @realm server -local confirm_team = CreateConVar( - "ttt2_confirm_team", - "0", - { FCVAR_NOTIFY, FCVAR_ARCHIVE }, - "Show team of confirmed player" -) - ---- --- @realm server -CreateConVar( - "ttt2_confirm_killlist", - "1", - { FCVAR_NOTIFY, FCVAR_ARCHIVE }, - "Confirm players in kill list" -) - --- -- @realm server CreateConVar( @@ -505,8 +478,6 @@ function GM:SyncGlobals() ) end - SetGlobalBool("ttt2_confirm_team", confirm_team:GetBool()) - --- -- @realm server hook.Run("TTT2SyncGlobals") diff --git a/gamemodes/terrortown/gamemode/shared/sh_corpse.lua b/gamemodes/terrortown/gamemode/shared/sh_corpse.lua index cab183b28a..8604e68577 100644 --- a/gamemodes/terrortown/gamemode/shared/sh_corpse.lua +++ b/gamemodes/terrortown/gamemode/shared/sh_corpse.lua @@ -13,6 +13,17 @@ CORPSE.dti = { INT_CREDITS = 0, } +CORPSE.cv = { + --- + -- @realm shared + identify_body_woconfirm = CreateConVar( + "ttt_identify_body_woconfirm", + "1", + { FCVAR_NOTIFY, FCVAR_ARCHIVE, FCVAR_REPLICATED }, + "Toggles whether ragdolls should be confirmed in gameloop.IsDetectiveMode() without clicking on confirm espacially" + ), +} + local dti = CORPSE.dti --- diff --git a/lua/autorun/gs_crazyphysics.lua b/lua/autorun/gs_crazyphysics.lua index 5cd40f3a2f..9c695ce429 100644 --- a/lua/autorun/gs_crazyphysics.lua +++ b/lua/autorun/gs_crazyphysics.lua @@ -164,8 +164,7 @@ local tEntitiesToCheck = { local bTTT local tIdentifyEntities -local cv_ttt_announce_body_found -local cv_ttt2_confirm_killlist +local corpseConfig hook.Add("Initialize", "TTT2GSCrazyPhysics", function() -- Change check if your terrortown folder is named something different @@ -176,8 +175,7 @@ hook.Add("Initialize", "TTT2GSCrazyPhysics", function() prop_ragdoll = true, } - cv_ttt_announce_body_found = GetConVar("ttt_announce_body_found") - cv_ttt2_confirm_killlist = GetConVar("ttt2_confirm_killlist") + corpseConfig = CORPSE.cv end end) @@ -281,8 +279,8 @@ local function IdentifyCorpse(pCorpse) end end - if cv_ttt_announce_body_found:GetBool() then - if GetGlobalBool("ttt2_confirm_team") then -- TODO adjust the new messages + if corpseConfig.announce_body_found:GetBool() then + if corpseConfig.confirm_team:GetBool() then -- TODO adjust the new messages LANG.Msg("body_found", { finder = "The Server", victim = CORPSE.GetPlayerNick(pCorpse, nil) or pPlayer:GetName(), @@ -298,7 +296,7 @@ local function IdentifyCorpse(pCorpse) end end - if cv_ttt2_confirm_killlist:GetBool() then + if corpseConfig.confirm_killlist:GetBool() then local tKills = pCorpse.kills if tKills then for i = 1, #tKills do diff --git a/lua/ttt2/libraries/bodysearch.lua b/lua/ttt2/libraries/bodysearch.lua index e3fe699226..50e38425a1 100644 --- a/lua/ttt2/libraries/bodysearch.lua +++ b/lua/ttt2/libraries/bodysearch.lua @@ -115,6 +115,15 @@ if SERVER then local mathRound = math.Round local mathFloor = math.floor + local cv_ttt2_confirm_killlist + + hook.Add("Initialize", "TTT2BodySearch", function() + -- Change check if your terrortown folder is named something different + if engine.ActiveGamemode():lower() == "terrortown" and TTT2 and istable(CORPSE) then + cv_ttt2_confirm_killlist = CORPSE.cv.confirm_killlist + end + end) + util.AddNetworkString("ttt2_client_reports_corpse") util.AddNetworkString("ttt2_client_confirm_corpse") util.AddNetworkString("ttt2_credits_were_taken") @@ -356,7 +365,7 @@ if SERVER then -- build list of people this player killed, but only if convar is enabled sceneData.killEntityIDList = {} - if GetConVar("ttt2_confirm_killlist"):GetBool() then + if cv_ttt2_confirm_killlist:GetBool() then local ragKills = rag.kills or {} for i = 1, #ragKills do diff --git a/lua/ttt2/libraries/targetid.lua b/lua/ttt2/libraries/targetid.lua index 6179c2fc31..07101382be 100644 --- a/lua/ttt2/libraries/targetid.lua +++ b/lua/ttt2/libraries/targetid.lua @@ -37,6 +37,15 @@ local materialDestructible = Material("vgui/ttt/tid/tid_destructible") local materialDNATargetID = Material("vgui/ttt/dnascanner/dna_hud") local materialFire = Material("vgui/ttt/tid/tid_onfire") +local cv_ttt_identify_body_woconfirm + +hook.Add("Initialize", "TTT2TargetID", function() + -- Change check if your terrortown folder is named something different + if engine.ActiveGamemode():lower() == "terrortown" and TTT2 and istable(CORPSE) then + cv_ttt_identify_body_woconfirm = CORPSE.cv.identify_body_woconfirm + end +end) + --- -- This function makes sure local variables, which use other libraries that are not yet initialized, are initialized later. -- It gets called after all libraries are included and `cl_targetid.lua` gets included. @@ -562,7 +571,7 @@ function targetid.HUDDrawTargetIDRagdolls(tData) tData:AddDescriptionLine(TryT("corpse_hint_inspect_limited_details")) elseif bodysearch.GetInspectConfirmMode() == 0 - and not GetConVar("ttt_identify_body_woconfirm"):GetBool() + and not cv_ttt_identify_body_woconfirm:GetBool() then tData:SetSubtitle(ParT("corpse_hint_without_confirm", key_params)) else