Skip to content
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
0534a4c
Added ROLE events
BDJslime-UnaverageJoe Apr 12, 2024
01920fb
Added role change support
BDJslime-UnaverageJoe Apr 12, 2024
fa0c2f4
misc
BDJslime-UnaverageJoe Apr 12, 2024
9bf26de
Cache log line color
BDJslime-UnaverageJoe Apr 12, 2024
bf35935
misc changes
BDJslime-UnaverageJoe Apr 12, 2024
26e61ec
Update roles for death recent logs
BDJslime-UnaverageJoe Apr 13, 2024
9168279
Added round check
BDJslime-UnaverageJoe Apr 13, 2024
acdce5a
Handle instant respawns
BDJslime-UnaverageJoe Apr 18, 2024
cbebd64
Delayed respawn check
BDJslime-UnaverageJoe Apr 18, 2024
dac675c
move message to client
BDJslime-UnaverageJoe Apr 18, 2024
c24d003
Merge pull request #1 from BDJslime-UnaverageJoe/RoleRespawn
BDJslime-UnaverageJoe Apr 18, 2024
1d818e2
Merge branch 'BadgerCode:master' into RoleEventCR
BDJslime-UnaverageJoe Jan 22, 2025
4e27efc
Revert "Role respawn"
BDJslime-UnaverageJoe Jan 22, 2025
563e2ed
Merge pull request #2 from BDJslime-UnaverageJoe/revert-1-RoleRespawn
BDJslime-UnaverageJoe Jan 22, 2025
de0e801
Config additions
BDJslime-UnaverageJoe Jan 23, 2025
d6a944e
Prompt to respond to reports + console command to respond
BDJslime-UnaverageJoe Jan 23, 2025
fa274a0
Merge pull request #3 from BDJslime-UnaverageJoe/answerPrompt
BDJslime-UnaverageJoe Jan 23, 2025
b3dd409
Change spawn check to generic hook
BDJslime-UnaverageJoe Jan 23, 2025
f7fc67d
Prevent autorespond when reported while dead
BDJslime-UnaverageJoe Jan 24, 2025
5f20956
cleanup
BDJslime-UnaverageJoe Jul 27, 2025
384a933
Save mid responces and prevent closing when respawning outside of act…
BDJslime-UnaverageJoe Jul 28, 2025
8d4a9c2
fix closing prompts
BDJslime-UnaverageJoe Jul 28, 2025
5b3a3db
Replace prompt with simple chat message
BDJslime-UnaverageJoe Apr 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions lua/damagelogs/client/listview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,15 @@ function Damagelog:AddLogsLine(listview, tbl, roles, nofilters, old)
end
end

local color = infos:GetColor(tbl.infos, roles)

function item:PaintOver(w, h)
if not self:IsSelected() and infos:Highlight(item, tbl.infos, text) then
surface.SetDrawColor(color_what)
surface.DrawRect(0, 0, w, h)
else
for _, v in pairs(item.Columns) do
v:SetTextColor(infos:GetColor(tbl.infos, roles))
v:SetTextColor(color)
end
end
end
Expand All @@ -170,13 +172,18 @@ function Damagelog:SetListViewTable(listview, tbl, nofilters, old)

if #tbl.logs > 0 then
local added = false

local roles = tbl.roles
for _, v in ipairs(tbl.logs) do
local line_added = self:AddLogsLine(listview, v, tbl.roles, nofilters, old)
local line_added = self:AddLogsLine(listview, v, roles, nofilters, old)

if not added and line_added then
added = true
end

if (CR_VERSION or TTT2) and Damagelog:CheckRoleUpdates(v) then
local infos = v["infos"]
roles[infos[2]]["role"] = infos[4]
end
end

if not added then
Expand All @@ -187,6 +194,13 @@ function Damagelog:SetListViewTable(listview, tbl, nofilters, old)
end
end

function Damagelog:CheckRoleUpdates(tbl)
if self.events[tbl.id]["Type"] == "ROLE" and tbl.infos[1] == 1 then
return true
end
return false
end

function Damagelog:SetRolesListView(listview, tbl)
listview:Clear()

Expand Down
6 changes: 6 additions & 0 deletions lua/damagelogs/client/rdm_manager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,12 @@ net.Receive("DL_Death", function()
end
end)

net.Receive("DL_Delayed", function()
if #Damagelog.ReportsQueue > 0 then
LocalPlayer():PrintMessage(HUD_PRINTTALK, string_format(TTTLogTranslate(GetDMGLogLang, "reportDelayed"), #Damagelog.ReportsQueue))
end
end)

net.Receive("DL_SendForgive", function()
local previous = net.ReadUInt(1) == 1
local canceled = net.ReadUInt(1) == 1
Expand Down
19 changes: 16 additions & 3 deletions lua/damagelogs/server/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ Damagelog.OldTables = Damagelog.OldTables or {}
Damagelog.ShootTables = Damagelog.ShootTables or {}
Damagelog.Roles = Damagelog.Roles or {}
Damagelog.SceneRounds = Damagelog.SceneRounds or {}
local RecentRoles = {}

net.Receive("DL_SendLang", function(_, ply)
ply.DMGLogLang = net.ReadString()
Expand All @@ -101,13 +102,16 @@ function Player:SetDamagelogID(id)
end

function Player:AddToDamagelogRoles(joinedAfterRoundStart)
local id = table.insert(Damagelog.Roles[#Damagelog.Roles], {
local info = {
role = (joinedAfterRoundStart and DAMAGELOG_ROLE_JOINAFTERROUNDSTART)
or (self:IsSpec() and DAMAGELOG_ROLE_SPECTATOR)
or self:GetRole(),
steamid64 = self:SteamID64(),
nick = self:Nick()
})
}

local id = table.insert(Damagelog.Roles[#Damagelog.Roles], info)
if joinedAfterRoundStart then table.insert(RecentRoles[#Damagelog.Roles], id, info) end

self:SetDamagelogID(id)
end
Expand Down Expand Up @@ -152,6 +156,7 @@ function Damagelog:TTTBeginRound()
end

self.CurrentRound = rounds + 1
RecentRoles = self.Roles[rounds + 1]
end

table.Empty(self.DamageTable)
Expand Down Expand Up @@ -360,8 +365,16 @@ hook.Add("PlayerDeath", "Damagelog_PlayerDeathLastLogs", function(ply)

ply.DeathDmgLog = {
logs = table.Reverse(found_dmg),
roles = Damagelog.Roles[#Damagelog.Roles]
roles = RecentRoles
}
end)

function Damagelog:UpdateRecentRole(ply, role)
if GetRoundState() ~= ROUND_ACTIVE then return end
local round = self.CurrentRound

timer.Simple(10, function()
if round ~= self.CurrentRound then return end
RecentRoles[ply:GetDamagelogID()]["role"] = role
end)
end
34 changes: 34 additions & 0 deletions lua/damagelogs/server/rdm_manager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -679,11 +679,45 @@ hook_Add("PlayerInitialSpawn", "PlayerInitialSpawn_RDM_Manager", function(ply)
end)
end)

local function CheckRevive(ply)
if CR_VERSION and ply:IsRespawning() then
Comment thread
BadgerCode marked this conversation as resolved.
Outdated
return true
elseif TTT2 and ply:IsReviving() then
return true
end
return false
end

hook_Add("PlayerDeath", "RDM_Manager", function(ply)

if GetRoundState() == ROUND_ACTIVE and (TTT2 or CR_VERSION) then
--Instant Respawn Cases
timer.Simple(1, function()
if ply:Alive() then return end
end)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't do anything?

-- Delayed Respawn Check
if CheckRevive(ply) then
net.Start("DL_Delayed")
net.Send(ply)

timer.Create("RDM_RespawnDelay_" .. ply:SteamID64(), 5, 1, function()

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would 5 seconds be long enough for the respawn mechanics?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately role respawns vary and are often controlled by cvars so a flat 5 second timer may not work.
I'm not completely clear on what this is doing so I can't offer advice, really.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe instead, we should look at closing the report window if a player is respawned (and the round is active).
This way, no matter how long it takes for them to be respawned, the report window won't get in the way.

If they've already started typing out a response, we should probably keep track of it.

@BDJslime-UnaverageJoe BDJslime-UnaverageJoe Jun 13, 2024

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I'm commonly seeing, there are 3 kinds of role respawns,
Instant: Has an effect on death and usually doesn't state the respawning state during that small timeframe(Swapper)
Delayed: Respawns on a timer which usually doesn't last more than 5 +1 seconds (Zombie)
Conditional: Only respawns when a condition is fulfilled, which can range from happening instantly or never (Parasite)

The checks cover the first 2, while conditional has only 5-second grace before having to respond to reports.

net.Start("DL_Death")
net.Send(ply)
end)
return
end
end

net.Start("DL_Death")
net.Send(ply)
end)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could simplify this function to always wait 5 seconds before requesting that the dead player replies to their reports.


hook_Add("PlayerSpawn", "RDM_RespawnCancel", function(ply)
if timer.Exists("RDM_RespawnDelay_" .. ply:SteamID64()) then
timer.Remove("RDM_RespawnDelay_" .. ply:SteamID64())
end
end)

hook_Add("TTTEndRound", "RDM_Manager", function()
net.Start("DL_Death")
net.Broadcast()
Expand Down
84 changes: 84 additions & 0 deletions lua/damagelogs/shared/events/roles.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
if SERVER then
--Global Variables Unavailable? find how to hook later
--if CR_VERSION then
Damagelog:EventHook("TTTPlayerRoleChanged")
Damagelog:EventHook("TTTPlayerRoleChangedByItem")
Damagelog:EventHook("TTTPlayerSpawnForRound")

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will these cause problems for the regular TTT or TTT2 gamemodes?

--elseif TTT2 then
--TODO
--else
--UNUSED
--end
else
Damagelog:AddFilter("filter_show_roles", DAMAGELOG_FILTER_BOOL, true)
Damagelog:AddColor("color_roles", Color(128, 64, 0))
end
local event = {}
event.Type = "ROLE"

function event:TTTPlayerRoleChanged(ply, oldRole, newRole)
if oldRole == nil or oldRole == ROLE_NONE or oldRole == newRole or newRole == ROLE_NONE then return end
self.CallEvent({
[1] = 1,
[2] = ply:GetDamagelogID(),
[3] = oldRole,
[4] = newRole
})
Damagelog:UpdateRecentRole(ply, newRole)
end

function event:TTTPlayerRoleChangedByItem(ply, tgt, item)
if not IsValid(item) then return end
self.CallEvent({
[1] = 2,
[2] = ply:GetDamagelogID(),
[3] = tgt:GetDamagelogID(),
[4] = IsEntity(item) and item:GetClass() or item
})
end

function event:TTTPlayerSpawnForRound(ply, deadOnly)
self.CallEvent({
[1] = 3,
[2] = ply:GetDamagelogID(),
})
end


function event:ToString(v, roles)
local ply = Damagelog:InfoFromID(roles, v[2])

if v[1] == 1 then
return string.format(TTTLogTranslate(GetDMGLogLang, "role_change"), ply.nick, Damagelog:StrRole(v[3]), Damagelog:StrRole(v[4]))
elseif v[1] == 2 then
local tgt = Damagelog:InfoFromID(roles, v[3])
return string.format(TTTLogTranslate(GetDMGLogLang, "role_item"), ply.nick, Damagelog:StrRole(ply.role), Damagelog:GetWeaponName(v[4]), tgt.nick, Damagelog:StrRole(tgt.role))
elseif v[1] == 3 then
return string.format(TTTLogTranslate(GetDMGLogLang, "revive"), ply.nick, Damagelog:StrRole(ply.role))
end
end

function event:IsAllowed(tbl)
return Damagelog.filter_settings["filter_show_roles"]
end

function event:Highlight(line, tbl, text)
return table.HasValue(Damagelog.Highlighted, tbl[1])
end

function event:GetColor(tbl)
return Damagelog:GetColor("color_roles")
end

function event:RightClick(line, tbl, roles, text)
line:ShowTooLong(true)
local ply = Damagelog:InfoFromID(roles, tbl[2])
if tbl[1] == 2 then
local tgt = Damagelog:InfoFromID(roles, tbl[3])
line:ShowCopy(true, {ply.nick, util.SteamIDFrom64(ply.steamid64)}, {tgt.nick, util.SteamIDFrom64(tgt.steamid64)})
return
end
line:ShowCopy(true, {ply.nick, util.SteamIDFrom64(ply.steamid64)})
end

Damagelog:AddEvent(event)
8 changes: 7 additions & 1 deletion lua/damagelogs/shared/lang/english.lua
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ DamagelogLang.english = {
filter_show_equipment_usage = "Show equipment usage (if supported)",
filter_show_c4 = "Show C4",
filter_show_drownings = "Show drownings",
filter_show_roles = "Show role changes",
-- Colors
color_found_bodies = "Found bodies",
colors_aslays = "Auto Slays",
Expand Down Expand Up @@ -408,5 +409,10 @@ DamagelogLang.english = {
rdmmanager_action_ban = "Ban",
rdmmanager_action_ban_title = "Banning",
rdmmanager_action_ban_submit = "Ban",
dmglogs_btn_highlight = "Highlight"
dmglogs_btn_highlight = "Highlight",

role_change = "%s [%s] has changed into [%s]",
role_item = "%s [%s] used %s on %s [%s]",
revive = "%s [%s] has been revived",
reportDelayed = "You have %s pending reports against you, you are required to respond if you are unable to be revived shortly."
}