Skip to content

Commit

Permalink
Radar in Meters (#1353)
Browse files Browse the repository at this point in the history
  • Loading branch information
TimGoll authored Feb 4, 2024
1 parent be9917f commit f01d167
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ All notable changes to TTT2 will be documented here. Inspired by [keep a changel
- All `builtin` weapons can now be configured to drop via `Edit Equipment` (by @EntranceJew)
- Removed redundant checks outside of `SWEP:DrawHelp`, protected only `SWEP:DrawHelp`
- Spectator name labels now use a skin font and scaling (by @EntranceJew)
- The built-in radar now displays distances in meters (by @TimGoll)
- Converted `ttt_ragdoll_pinning` and `ttt_ragdoll_pinning_innocents` into per-role permissions.
- Magneto stick now allows right-clicking to instantly drop something, while left-clicking still releases/throws it.
- Magneto stick now shows tooltips respective to its current state.
Expand Down
15 changes: 7 additions & 8 deletions lua/terrortown/entities/items/item_ttt_radar/cl_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ function ITEM:AddToSettingsMenu(parent)
})
end



local function DrawTarget(tgt, size, offset, no_shrink)
local scrpos = tgt.pos:ToScreen() -- sweet
local sz = (util.IsOffScreen(scrpos) and not no_shrink) and (size * 0.5) or size
Expand All @@ -117,7 +115,7 @@ local function DrawTarget(tgt, size, offset, no_shrink)

-- Drawing full size?
if sz == size then
local text = math.ceil(LocalPlayer():GetPos():Distance(tgt.pos))
local text = tostring(math.Round(util.HammerUnitsToMeters(LocalPlayer():EyePos():Distance(tgt.pos)), 0)) .. "m"
local w, h = surface.GetTextSize(text)

-- Show range to target
Expand Down Expand Up @@ -155,7 +153,8 @@ function RADAR:Draw(client)

surface.SetFont("HudSelectionText")

-- C4 warnings
-- bomb warnings
-- note: This is deprecated use markerVision instead
if self.bombs_count ~= 0 and client:IsActive() and not client:GetSubRoleData().unknownTeam then
surface.SetTexture(c4warn)
surface.SetTextColor(client:GetRoleColor())
Expand All @@ -168,7 +167,7 @@ function RADAR:Draw(client)
end
end

-- Corpse calls
-- corpse calls
if not table.IsEmpty(self.called_corpses) then
surface.SetTexture(det_beacon)
surface.SetTextColor(255, 255, 255, 240)
Expand All @@ -179,7 +178,7 @@ function RADAR:Draw(client)
end
end

-- Samples
-- DNA samples
if self.samples_count ~= 0 then
surface.SetTexture(sample_scan)
surface.SetTextColor(200, 50, 50, 255)
Expand All @@ -190,14 +189,14 @@ function RADAR:Draw(client)
end
end

-- Player radar
-- player radar
if not self.enable then return end

surface.SetTexture(indicator)

local radarTime = client.radarTime or 30
local remaining = math.max(0, radarTime - (CurTime() - RADAR.startTime))
local alpha_base = 50 + 180 * (remaining / radarTime)
local alpha_base = 55 + 200 * (remaining / radarTime)
local mpos = Vector(ScrW() * 0.5, ScrH() * 0.5, 0)

local subrole, alpha, scrpos, md
Expand Down

0 comments on commit f01d167

Please sign in to comment.