GameBanana shows no ads to members. Sign up now!
Ads keep us online. Without them, we wouldn't exist. We don't have paywalls or sell mods - we never will. But every month we have large bills and running ads is our only way to cover them. Please consider unblocking us. Thank you from GameBanana <3

Adding Working Scopes to Weapons

A Tutorial for Half-Life 2

Working Scopes: Disturbingly Easy

Working Scope Overlays in HL2

To add a working scope to any weapon in HL2 is relatively simple.

Getting Started


You'll need a scope texture to use. This is GameBanana, so you should be able to find one laying around if you look hard enough.

Open up the weapon of choice, such as weapon_crossbow, and scroll to the texturedata block. In this table, you'll find several entries such as weapon, weapon_s, etc. You can find detailed descriptions of what each of these mean on the Valve Developer Community page. The parts we're looking to change or add are called zoom and zoom_autoaim.

Breaking it Down


zoom is called when the +zoom or toggle_zoom commands are used. zoom_autoaim is a slight variation used when the crosshair is over a target. This could be used to make a different overlay appear when a target is marked.

The Code


The following is an example of how to add a proper scope overlay to the weapon.
zoom
{

// Texture path; relative to root/materials/
file sprites/scope_2

// X & Y-position on the screen
x 0
y 0

// The width & height of the texture; preferably match the VTF size
width 4096
height 2048

}

zoom_autoaim
{

file sprites/scope_2
x 0
y 0
width 4096
height 2048

}

The file line can be used to choose the texture to display. The x & y are used to set the translation, width & height the size.

Conclusion


This can be added to any of the native weapons in HL2, as they all share the same form fields as far as texturedata is concerned for the scope of this tutorial. If you want a working example to shamelessly edit & break apart for experimentation, you might try my release of the scoped Crossbows using this very method.

Sign up to access this!
  • Sedqubus avatar
    Sedqubus Joined 1y ago
    Offline
    1,954 points Ranked 21004th
    11 medals 1 legendary 1 rare
    • 2019 Top Contributor Medal icon
    • 10 submissions featured Medal icon
    • Submission featured Medal icon
    • One month a member Medal icon
    • Submitted 10 Skins Medal icon
    • Received thanks 5 times Medal icon
    access_time 1mo
    i remember having a lot of fun doing this about a year or so ago, lol. nice to have a proper tutorial for those who wanna try it out.
    i hate underscores.
    URL to post:
  • Allen Scott avatar
    Allen Scott username pic Joined 9y ago
    TF2 Manager Moderator
    Unavailable
    Our Pink Sanctum Flag Affiliation: Our Pink Sanctum
    7,565 points Ranked 858th
    37 medals 5 legendary 7 rare
    • Reached 100 subscribers Medal icon
    • Returned 5000 times Medal icon
    • 30 submissions featured Medal icon
    • 2017 Top Contributor Medal icon
    • 2019 Top Contributor Medal icon
    • Reached 50 subscribers Medal icon
    Allen Scott avatar
    Allen Scott
    Our Pink Sanctum Flag
    Affiliation
    Our Pink Sanctum
    access_time 1mo
    This is very useful.
    Texture Artist avatar
    Mantra
    Texture Artist
    URL to post:

Embed

Share banner
Image URL
HTML embed code
BB embed code
Markdown embed code

Credits

Key Authors
Reverend V92 avatar
Reverend V92 username pic Joined 10y ago
HL2 Manager HL2:MMod Manager HL2:EP1 Manager HL2:EP2 Manager HL2:DM Manager SOURCE Manager OC Manager Syn Manager GMod Manager GMod 11 Manager GMod 13 Manager GMod 9 Manager
Offline
22,425 points Ranked 239th
39 medals 2 legendary 7 rare
  • 2019 Top Contributor Medal icon
  • Returned 5000 times Medal icon
  • 2nd Place - A Bananite's Guide to... Contest Medal icon
  • 6 years a member Medal icon
  • Returned 1000 times Medal icon
  • Received thanks 50 times Medal icon
Creator
Special Thanks
SamVision
SamVision Joined 6y ago
Offline
426 points Ranked 47702nd
Original proof of concept

Submitter

Reverend V92 avatar
Reverend V92 username pic Joined 10y ago
HL2 Manager HL2:MMod Manager HL2:EP1 Manager HL2:EP2 Manager HL2:DM Manager SOURCE Manager OC Manager Syn Manager GMod Manager GMod 11 Manager GMod 13 Manager GMod 9 Manager
WAITING
22,425 points Ranked 239th
39 medals 2 legendary 7 rare
  • 2019 Top Contributor Medal icon
  • Returned 5000 times Medal icon
  • 2nd Place - A Bananite's Guide to... Contest Medal icon
  • 6 years a member Medal icon
  • Returned 1000 times Medal icon
  • Received thanks 50 times Medal icon
Reverend V92 avatar
Reverend V92

Creator
Sign up to access this!
Sign up to access this!
Sign up to access this!

Game

Sign up to access this!

Category

Details

Difficulty Level
Beginner

Attributes

Share

  • Share on Reddit
  • Share on Twitter
  • Share on Facebook
  • Today's Pick
    Featured on Apr 23 2020
  • 5
  • 809
  • 2
  • 1mo
  • 1mo

More from Submitter

Teleports
Teleports folder Mapping Beginner
Advanced Displacement
Advanced Displacement folder Mapping Intermediate
Advanced Destruction
Advanced Destruction folder Mapping Intermediate
3D Skybox
3D Skybox folder Mapping Beginner

WiPs by Submitter

More Scripting Tutorials