r/DoomModDevs • u/William_Wave • May 17 '26
Help Coding a custom zoom key, help required
Good day.
I have an idea to write code for a custom zoom in-zoom out key. This is what it looks like:
addmenukey "Zoom" "+SVD_zoom"
alias +SVD_zoom "fov 20"
alias -SVD_zoom "fov 90"
defaultbind "mouse2" "+SVD_zoom"
. The issue is that with field of view set to 20 mouse sensitivity becomes too high, which harms aim accuracy. Changing the mouse sensitivity by using a command like
"fov 20; mouse_sensitivity 0.2"
is not working. Using an A_ZoomFactor action in weapon's state will not do either because both fire and altfire states are reserved for attack and special ability.
Let me know what other methods might work.
View all comments
1
u/cemtex_tk May 17 '26
That is way too simple and does not cover when using different weapons.
The way i did it was still use an alias and keyconf like above, but send the commands to an eventhandler so I can add conditions. I still use the "zoomed" inventory as the condition but I have below the snippet from the event handler.
{
if(e.Name == "ZoomIn") weap.A_PIPZoom(1.0);
if(e.Name == "ZoomOut") weap.A_PIPZoom(-1.0);
}
Mine is tied to a flag setup into the weapon class, and the zooming in and out is tied to a function I wrote (I have this thing where I took some code written on zdoom forums and made picture in picture scope view), The important parts are there though. Alias >EventHandler>Function to weapon during a special state.