Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc. changes and fixes #13

Merged
merged 4 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
30 changes: 18 additions & 12 deletions lua/rolemodifications/enhancedmedium/enhancedmedium.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ local player = player
local table = table
local timer = timer

local GetAllPlayers = player.GetAll
local PlayerIterator = player.Iterator

-------------
-- CONVARS --
Expand Down Expand Up @@ -38,7 +38,7 @@ local cured = Sound("items/smallmedkit1.wav")

local deadMediums = {}
hook.Add("TTTPrepareRound", "EnhancedMedium_TTTPrepareRound", function()
for _, v in pairs(GetAllPlayers()) do
for _, v in PlayerIterator() do
v:SetNWBool("MediumHaunted", false)
v:SetNWBool("MediumHaunting", false)
v:SetNWString("MediumHauntingTarget", nil)
Expand Down Expand Up @@ -110,7 +110,7 @@ hook.Add("PlayerDeath", "EnhancedMedium_PlayerDeath", function(victim, infl, att
end

if medium_announce_death:GetBool() then
for _, v in pairs(GetAllPlayers()) do
for _, v in PlayerIterator() do
if v ~= attacker and v:IsDetectiveLike() and v:Alive() and not v:IsSpec() and v:SteamID64() ~= loverSID then
v:QueueMessage(MSG_PRINTCENTER, "The " .. ROLE_STRINGS[ROLE_MEDIUM] .. " has been killed.")
end
Expand Down Expand Up @@ -295,7 +295,7 @@ hook.Add("DoPlayerDeath", "EnhancedMedium_DoPlayerDeath", function(ply, attacker

local respawnCount = table.Count(respawning)
if respawnCount > 0 and medium_announce_death:GetBool() then
for _, v in pairs(GetAllPlayers()) do
for _, v in PlayerIterator() do
if v:IsDetectiveLike() and v:Alive() and not v:IsSpec() then
if not respawning[v:SteamID64()] then
v:QueueMessage(MSG_PRINTCENTER, "The " .. ROLE_STRINGS[ROLE_MEDIUM] .. " has been respawned.")
Expand Down Expand Up @@ -327,12 +327,18 @@ hook.Add("PlayerFootstep", "EnhancedMedium_PlayerFootstep", function(ply, pos, f

-- This player killed a Medium. Tell everyone where their foot steps should go
net.Start("TTT_PlayerFootstep")
net.WriteEntity(ply)
net.WriteVector(pos)
net.WriteAngle(ply:GetAimVector():Angle())
net.WriteBit(foot)
net.WriteTable(Color(138, 4, 4))
net.WriteUInt(killer_footstep_time, 8)
-- TODO: Remove after 2.1.10 is pushed to release
if CRVersion("2.1.10") then
net.WritePlayer(ply)
else
net.WriteEntity(ply)
end
net.WriteVector(pos)
net.WriteAngle(ply:GetAimVector():Angle())
net.WriteBit(foot)
net.WriteTable(Color(138, 4, 4))
net.WriteUInt(killer_footstep_time, 8)
net.WriteFloat(1) -- Scale
net.Broadcast()
end)

Expand Down Expand Up @@ -374,7 +380,7 @@ hook.Add("PreRegisterSWEP", "EnhancedMedium_PreRegisterSWEP", function(SWEP, cla
ply:EmitSound(cured)

if ply:GetNWBool("PhantomHaunted", false) then
for _, v in pairs(player.GetAll()) do
for _, v in PlayerIterator() do
if v:GetNWString("PhantomHauntingTarget", "") == ply:SteamID64() then
ply:SetNWBool("PhantomHaunted", false)
v:SetNWBool("PhantomHaunting", false)
Expand All @@ -397,7 +403,7 @@ hook.Add("PreRegisterSWEP", "EnhancedMedium_PreRegisterSWEP", function(SWEP, cla
end

if ply:GetNWBool("MediumHaunted", false) then
for _, v in pairs(player.GetAll()) do
for _, v in PlayerIterator() do
if v:GetNWString("MediumHauntingTarget", "") == ply:SteamID64() then
ply:SetNWBool("MediumHaunted", false)
v:SetNWBool("MediumHaunting", false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ local paladin_explosion_protect_self = GetConVar("ttt_paladin_explosion_protect_
-- Damage aura
net.Receive("EnhancedPaladin_ShowDamageAura", function()
local client = LocalPlayer()
local paladin = net.ReadEntity()
local paladin = net.ReadPlayer()
local paladinPos = paladin:GetPos()
local pos = paladinPos + Vector(0, 0, 30)
if client:GetPos():Distance(pos) > 3000 then return end
Expand Down
7 changes: 3 additions & 4 deletions lua/rolemodifications/enhancedpaladin/enhancedpaladin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ AddCSLuaFile()

local hook = hook
local IsValid = IsValid
local pairs = pairs
local player = player
local util = util

local GetAllPlayers = player.GetAll
local PlayerIterator = player.Iterator

util.AddNetworkString("EnhancedPaladin_ShowDamageAura")

Expand All @@ -26,7 +25,7 @@ hook.Add("EntityTakeDamage", "EnhancedPaladin_EntityTakeDamage", function(ent, d
if not ent:IsPaladin() or paladin_explosion_protect_self:GetBool() then
local paladin = nil
local radius = GetConVar("ttt_paladin_aura_radius"):GetInt() * UNITS_PER_METER
for _, v in pairs(GetAllPlayers()) do
for _, v in PlayerIterator() do
if v:IsActivePaladin() and v:GetPos():Distance(ent:GetPos()) <= radius then
paladin = v
break
Expand All @@ -37,7 +36,7 @@ hook.Add("EntityTakeDamage", "EnhancedPaladin_EntityTakeDamage", function(ent, d
dmginfo:SetDamage(0)

net.Start("EnhancedPaladin_ShowDamageAura")
net.WriteEntity(paladin)
net.WritePlayer(paladin)
net.Broadcast()
end
end
Expand Down
5 changes: 2 additions & 3 deletions lua/rolemodifications/enhancedtracker/enhancedtracker.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
AddCSLuaFile()

local hook = hook
local pairs = pairs
local player = player
local timer = timer

local GetAllPlayers = player.GetAll
local PlayerIterator = player.Iterator

-------------
-- CONVARS --
Expand Down Expand Up @@ -34,7 +33,7 @@ end)

-- Cleanup
hook.Add("TTTEndRound", "EnhancedTracker_TTTEndRound", function()
for _, v in pairs(GetAllPlayers()) do
for _, v in PlayerIterator() do
v:SetNWBool("blindedbytracker", false)
end
timer.Remove("EnhancedTrackerBlindTimer")
Expand Down
Loading