Skip to content

Conversation

@thecraftianman
Copy link
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

@Astralcircle
Copy link
Contributor

Astralcircle commented Jun 27, 2025

But if don't nitpick, it looks OK

@thegrb93
Copy link
Contributor

thegrb93 commented Jul 2, 2025

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
Member

@thecraftianman thoughts on using what @thegrb93 proposed?

@thecraftianman
Copy link
Contributor Author

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

Copy link
Member

@wrefgtzweve wrefgtzweve left a 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

Copy link
Contributor

@Astralcircle Astralcircle left a 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)

@thegrb93
Copy link
Contributor

thegrb93 commented Jul 17, 2025

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

@Astralcircle
Copy link
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