Improve SWEP visuals/audio#3377
Merged
Astralcircle merged 6 commits intowiremod:masterfrom Jul 17, 2025
Merged
Conversation
Contributor
|
But if don't nitpick, it looks OK |
Astralcircle
approved these changes
Jun 27, 2025
thegrb93
reviewed
Jun 27, 2025
thegrb93
reviewed
Jun 27, 2025
Contributor
|
Here's better laser pointer: include("shared.lua")
SWEP.PrintName = "Laser Pointer"
SWEP.Slot = 0
SWEP.SlotPos = 4
SWEP.DrawAmmo = false
SWEP.DrawCrosshair = true
local color_red = Color(255, 0, 0)
local laser = Material("cable/redlaser")
-- Scale screen coords by linear proportion of viewmodel and world fov
local function WorldToViewModel(point)
local view = render.GetViewSetup()
local factor = math.tan(math.rad(view.fovviewmodel_unscaled)*0.5) / math.tan(math.rad(view.fov_unscaled)*0.5)
point = WorldToLocal(point, Angle(), view.origin, view.angles)
point:Mul(Vector(1, factor, factor))
point = LocalToWorld(point, Angle(), view.origin, view.angles)
return point
end
function SWEP:PostDrawViewModel(vm, wep, ply)
if self:GetLaserEnabled() then
local att = vm:GetAttachment(vm:LookupAttachment("muzzle"))
if not att then return end
local startpos = WorldToViewModel(att.Pos)
local endpos = ply:GetEyeTrace().HitPos
render.SetMaterial(laser)
render.DrawBeam(startpos, endpos, 2, 0, 12.5, color_red)
end
end
function SWEP:DrawWorldModel()
self:DrawModel()
if self:GetLaserEnabled() then
local att = self:GetAttachment(self:LookupAttachment("muzzle"))
if not att then return end
local owner = self:GetOwner()
local startpos = att.Pos
local endpos
if IsValid(owner) then
endpos = owner:GetEyeTrace().HitPos
else
local tr = util.TraceLine({ start = startpos, endpos = startpos + att.Ang:Forward() * 16384, filter = self })
endpos = tr.HitPos
end
-- Draw the laser beam.
render.SetMaterial(laser)
render.DrawBeam(startpos, endpos, 2, 0, 12.5, color_red)
end
end |
Member
|
@thecraftianman thoughts on using what @thegrb93 proposed? |
Contributor
Author
|
Looks good to me, I'll add it in. |
thegrb93
suggested changes
Jul 8, 2025
thegrb93
approved these changes
Jul 9, 2025
wrefgtzweve
approved these changes
Jul 9, 2025
thegrb93
suggested changes
Jul 13, 2025
Astralcircle
approved these changes
Jul 14, 2025
Contributor
Astralcircle
left a comment
There was a problem hiding this comment.
Probably should use WEAPON:ShouldDrawViewModel because ply:DrawViewModel has a weird apper effect, c_hands apper first, then the weapon.
Also hook wire_remotecontroller_antinoclip is unpredicated
hook.Add("PlayerNoClip", "wire_remotecontroller_antinoclip", function(ply, cmd)
if ply.using_wire_remote_control then return false end
end)
Contributor
|
Please merge and make new improvements in a new PR. This has been waiting long enough. |
Contributor
|
I think you're right, this PR is already quite functional, the rest of the not so important stuff can be finished later in another PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This just makes some pretty minor tweaks to the appearances of the two SWEPs to make them a bit more interesting to use.