Weapon Zoom Sourcemod plugin for HL2 Death Match and possibly others (untested) by [foo] bar.
This plugin adds enhanced zoom to weapons by changing the FOV of the player when a player uses secondary attack (ATTACK2) on a configured weapon, or through bound console commands. By default the plugin adds zoom to weapon_357, but can be added to other weapons that don't have an attack2 mode.
I have some changes in the works, but I'd love to hear feedback on how I can improve this plugin. It's coming up to my first year of Sourcemod coding and learning how to do things more effectively is important to me. Constructive criticism is appreciated.
To reduce zoom, a player can hold down their "walk" (alt) key while pressing ATTACK2.
Zoom is automatically turned off if toggle_zoom or suit zoom is turned on (for quick release).
The plugin also registers three console commands: weaponzoom_in, weaponzoom_out, and weaponzoom_unzoom. This is particularly useful for binding mwheelup and mwheeldown to zoom in and out, and an extra mouse button unzoom completely.
Example:
Code:
bind mwheelup weaponzoom_in
bind mwheeldown weaponzoom_out
bind mouse5 weaponzoom_unzoom
The plugin also supports an "ICU" sound, played to a player who's being zoomed in on. This is fun for causing a bit of panic on players, especially in large sniper maps.
Installation
- Upload plugins/sm_weaponzoom.smx into addons/sourcemod/plugins
- Upload translations/sm_weaponzoom.phrases.txt into addons/sourcemod/translations
- Upload html/sm_weaponzoom.html to a web server and set sm_weaponzoom_helpurl to that web address (see below)
- Load plugin using sm plugins load sm_weaponzoom
- If required, tweak cfg/sourcemod/plugin.sm_weaponzoom.cfg ; Reload using "sm plugins reload sm_weaponzoom" from srcds console.
Configuration
On first load the plugin will generate cfg/sourcemod/plugin.sm_weaponzoom.cfg with default settings.
Here's a brief list of cvar's and what they do:
Code:
sm_weaponzoom_weapons List of weapons to work on. ie: "weapon_357 weapon_pistol" etc.
sm_weaponzoom_helpurl Web address for in-game help. Set to nothing ("") to disable.
sm_weaponzoom_cmdallzoom 1: allow weaponzoom_in and weaponzoom_out on all weapons. (default)
0: limited to weapons specified by sm_weapon_commands
sm_weaponzoom_icusound Sound to play to a player being zoomed in on (useful for teasing
players on large maps)
sm_weaponzoom_icusound_mintime Minimum number of seconds between targetted player hearing a
sound from a stalking player
Out of box the zoom settings should be suitable for most servers. If you want tweak them, adjust the following cvar's to suite:
Code:
sm_weaponzoom_zoommax Maximum zoom levels (1-9)
sm_weaponzoom_zoomstart Starting "zoom" (FOV). High = less zoom, low = high zoom.
Range is 1-89. 35 or 40 is a good starting point.
sm_weaponzoom_zoomincrement Increment to take away from the FOV to increase zoom
Note: Perhaps counter-intuitively, the FOV is negated by sm_weapon_zoomincrement for each zoom increment performed by the player. If the FOV hits 0, the plugin unzooms the player (otherwise wierdness occurs).
In-game commands
Player settings can be accessed either through the chat command: !settings (if you have this enabled) or !weaponzoom.
Players can:
- Turn it off completely
- Set their own maximum zoom (up to the maximum set by sm_weaponzoom_maxzoom)
- Disable attack2 (alt-fire) zooming (ie: if they only want to use the console commands through bindings instead)
- Turn off hearing ICU
- View in-game help
- In-game help
An html helpfile is included for you to display in-game help via !weaponzoom. (Download the zip for the html help file, it is not included in this post).
Upload it to your fast download site, web server, or whatever, and set sm_weaponzoom_helpurl to the correct web address.
By default the web address is set to a web server under the author's control but you are encouraged to host it yourself lest the in-game help is updated to a newer but incompatible version, or suddenly just stops working down the road.
Future changes TODO list
At the moment there's a couple of changes I plan on implementing in a future release:
- Losing the increment level and zoom level calculations in favour of an explicit list of zoom levels (fov) set by the sysop
- Changing the player configuring for "max zoom" to allowing a player to set which zoom levels they want.
Credits
Many thanks to Outlaw for prompting me to code this, and to Nyarlathotep, jono, Boogyman and anyone I forgot to mention for testing and suggesting feature improvements.
Donations
If you enjoy this plugin please take a moment to donate! I happily accept donations!
- Purchases of games on my wishlist
- Paypal (contact me directly if you want to do this)
Thanks, I hope you enjoy this plugin. And have fun sniping!
[foo] bar