From e02ad4c156fd2b080a6ec68645af5900ecbfecb9 Mon Sep 17 00:00:00 2001 From: Samual Lenks Date: Thu, 7 Feb 2013 00:19:54 -0500 Subject: [PATCH] Code far better handling of zoom upon spawn --- qcsrc/client/Main.qc | 2 +- qcsrc/client/View.qc | 20 ++++++++++++++++---- qcsrc/client/autocvars.qh | 2 ++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/qcsrc/client/Main.qc b/qcsrc/client/Main.qc index 3e5deb104..57cf97c99 100644 --- a/qcsrc/client/Main.qc +++ b/qcsrc/client/Main.qc @@ -1100,7 +1100,7 @@ void Net_ReadRace() void Net_ReadSpawn() { zoomin_effect = 1; - current_viewzoom = 0.6; + current_viewzoom = (1 / bound(1, autocvar_cl_spawnzoom_factor, 16)); } void Net_TeamNagger() diff --git a/qcsrc/client/View.qc b/qcsrc/client/View.qc index e07a44b48..117de38c4 100644 --- a/qcsrc/client/View.qc +++ b/qcsrc/client/View.qc @@ -104,9 +104,13 @@ vector GetCurrentFov(float fov) zoomfactor = 2.5; zoomspeed = autocvar_cl_zoomspeed; if(zoomspeed >= 0) - if(zoomspeed < 0.5 || zoomspeed > 16) + if(zoomspeed < 0.5 || zoomspeed > 16) zoomspeed = 3.5; + + float spawnzoomfactor = bound(1, autocvar_cl_spawnzoom_factor, 16); + float spawnzoomspeed = autocvar_cl_spawnzoom_speed; + zoomdir = button_zoom; if(hud == HUD_NORMAL) if((activeweapon == WEP_NEX && nex_scope) || (activeweapon == WEP_RIFLE && rifle_scope)) // do NOT use switchweapon here @@ -123,13 +127,21 @@ vector GetCurrentFov(float fov) // fteqcc failed twice here already, don't optimize this } - if(zoomdir) - zoomin_effect = 0; + if(zoomdir) { zoomin_effect = 0; } - if(zoomin_effect || camera_active) + if(camera_active) { current_viewzoom = min(1, current_viewzoom + drawframetime); } + else if(zoomin_effect) + { + /*if(autocvar_cl_spawnzoom_type == 1) { current_viewzoom = (current_viewzoom + drawframetime * spawnzoomspeed * (1 - 1 / spawnzoomfactor)); } + else { */ + + current_viewzoom += (spawnzoomspeed * (spawnzoomfactor - current_viewzoom) * drawframetime); + current_viewzoom = bound(1 / spawnzoomfactor, current_viewzoom, 1); + if(current_viewzoom == 1) { zoomin_effect = 0; } + } else { if(zoomspeed < 0) // instant zoom diff --git a/qcsrc/client/autocvars.qh b/qcsrc/client/autocvars.qh index 72d7ec557..779815ad4 100644 --- a/qcsrc/client/autocvars.qh +++ b/qcsrc/client/autocvars.qh @@ -63,6 +63,8 @@ var float autocvar_cl_reticle = 1; float autocvar_cl_reticle_item_nex; float autocvar_cl_reticle_item_normal; float autocvar_cl_reticle_stretch; +var float autocvar_cl_spawnzoom_speed = 2; +var float autocvar_cl_spawnzoom_factor = 2; float autocvar_cl_stripcolorcodes; var float autocvar_cl_vehicle_spiderbot_cross_alpha = 0.6; var float autocvar_cl_vehicle_spiderbot_cross_size = 1; -- 2.39.2