Skip to content

Improve SWEP visuals/audio#3377

Merged
Astralcircle merged 6 commits into
wiremod:masterfrom
thecraftianman:swep-improvements
Jul 17, 2025
Merged

Improve SWEP visuals/audio#3377
Astralcircle merged 6 commits into
wiremod:masterfrom
thecraftianman:swep-improvements

Conversation

@thecraftianman

Copy link
Copy Markdown
Contributor

This just makes some pretty minor tweaks to the appearances of the two SWEPs to make them a bit more interesting to use.

  • Both the Laser Pointer and the Remote Control now use c_hands
  • The Laser Pointer's viewmodel laser now properly starts at the muzzle
  • Added a spawnmenu icon to the Remote Control (it just reuses the HL2 pistol icon)
  • The Laser Pointer now uses a short sparking sound when turning it on/off
  • Gave both weapons feedback sounds for successful/unsuccessful links
  • Fixed a couple of typos

Comment thread lua/weapons/laserpointer/shared.lua Outdated
Comment thread lua/weapons/remotecontroller.lua
Comment thread lua/weapons/laserpointer/init.lua Outdated
@Astralcircle

Astralcircle commented Jun 27, 2025

Copy link
Copy Markdown
Contributor

But if don't nitpick, it looks OK

Comment thread lua/weapons/remotecontroller.lua Outdated
Comment thread lua/weapons/laserpointer/cl_init.lua Outdated
@thegrb93

thegrb93 commented Jul 2, 2025

Copy link
Copy Markdown
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

@wrefgtzweve

Copy link
Copy Markdown
Member

@thecraftianman thoughts on using what @thegrb93 proposed?

@thecraftianman

Copy link
Copy Markdown
Contributor Author

Looks good to me, I'll add it in.

Comment thread lua/weapons/laserpointer/cl_init.lua

@wrefgtzweve wrefgtzweve left a comment

Copy link
Copy Markdown
Member

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

Comment thread lua/weapons/remotecontroller.lua Outdated
Comment thread lua/weapons/laserpointer/shared.lua

@Astralcircle Astralcircle left a comment

Copy link
Copy Markdown
Contributor

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)

@thegrb93

thegrb93 commented Jul 17, 2025

Copy link
Copy Markdown
Contributor

Please merge and make new improvements in a new PR. This has been waiting long enough.

@Astralcircle

Copy link
Copy Markdown
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

@Astralcircle Astralcircle merged commit 0cd9a90 into wiremod:master Jul 17, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants