Hi there Guest,  
Sign in here: Login through Steam



  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 
Crosshair Customizer?

#11
I'm gonna look into it again.

But the last time I checked the crosshair isn't a universal thing in the code that I can replace. It's defined for each weapon separately for the most part I think. I may find something different this time around though. n o p r o m i s e s
Find
Reply

#12
(02-24-2017, 11:28 PM)anangrybeaver Wrote:  I'm gonna look into it again.

But the last time I checked the crosshair isn't a universal thing in the code that I can replace. It's defined for each weapon separately for the most part I think. I may find something different this time around though. n o  p r o m i s e s

Nope, here's the base code in weapon_tttbase(SWEPs can override it using the DrawHUD() function, so guns that draw a custom crosshair would be fine)

PHP Code:
  local sights_opacity CreateConVar("ttt_ironsights_crosshair_opacity""0.8"FCVAR_ARCHIVE)
 
  local crosshair_brightness CreateConVar("ttt_crosshair_brightness""1.0"FCVAR_ARCHIVE)
 
  local crosshair_size CreateConVar("ttt_crosshair_size""1.0"FCVAR_ARCHIVE)
 
  local disable_crosshair CreateConVar("ttt_disable_crosshair""0"FCVAR_ARCHIVE)

 
  function SWEP:DrawHUD()
 
     if self.HUDHelp then
         self
:DrawHelp()
 
     end

      local client 
LocalPlayer()
 
     if disable_crosshair:GetBool() or (not IsValid(client)) then return end

      local sights 
= (not self.NoSights) and self:GetIronsights()

 
     local x math.floor(ScrW() / 2.0)
 
     local y math.floor(ScrH() / 2.0)
 
     local scale math.max(0.2 10 self:GetPrimaryCone())

 
     local LastShootTime self:LastShootTime()
 
     scale scale * (math.Clamp( (CurTime() - LastShootTime) * 50.01.0 ))

 
     local alpha sights and sights_opacity:GetFloat() or 1
      local bright 
crosshair_brightness:GetFloat() or 1

      
-- somehow it seems this can be called before my player metatable
      
-- additions have loaded
      if client
.IsTraitor and client:IsTraitor() then
         surface
.SetDrawColor(255 bright,
 
                             50 bright,
 
                             50 bright,
 
                             255 alpha)
 
     else
         surface
.SetDrawColor(0,
 
                             255 bright,
 
                             0,
 
                             255 alpha)
 
     end

      local gap 
math.floor(20 scale * (sights and 0.8 or 1))
 
     local length math.floor(gap + (25 crosshair_size:GetFloat()) * scale)
 
     surface.DrawLinelengthygap)
 
     surface.DrawLinelengthygap)
 
     surface.DrawLinexlengthxgap )
 
     surface.DrawLinexlengthxgap )
 
  end 

Funny enough, I was actually gonna ask Brass if I could make my own crosshair customizer, but haven't bothered yet.
Find
Reply

#13
There's a few older SWEP's that re-implement the default crosshair design without calling self.BaseClass.DrawHUD(self), which is a dumb way of doing it. Like I said before about this to some people, that would need to be fixed in order for this to be fully supported, and yeah, there are also a lot of weapons that have a custom crosshair already.
Find
Reply



Forum Jump:


Users browsing this thread:
2 Guest(s)