-
Notifications
You must be signed in to change notification settings - Fork 345
Improve SWEP visuals/audio #3377
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
Improve SWEP visuals/audio #3377
Conversation
|
But if don't nitpick, it looks OK |
|
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 |
|
@thecraftianman thoughts on using what @thegrb93 proposed? |
|
Looks good to me, I'll add it in. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much more polished than before this pr, nice
Astralcircle
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)|
Please merge and make new improvements in a new PR. This has been waiting long enough. |
|
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 just makes some pretty minor tweaks to the appearances of the two SWEPs to make them a bit more interesting to use.