From 580d180600e2d66f4032c27b825a5e5f2ec19e72 Mon Sep 17 00:00:00 2001 From: MirceaKitsune Date: Tue, 1 Mar 2011 00:40:42 +0200 Subject: [PATCH] Port aiming reticles from Xonotic. --- data/defaultVoretournament.cfg | 4 ++++ data/qcsrc/client/View.qc | 44 ++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/data/defaultVoretournament.cfg b/data/defaultVoretournament.cfg index 6fa6750a..c40476e3 100644 --- a/data/defaultVoretournament.cfg +++ b/data/defaultVoretournament.cfg @@ -128,6 +128,10 @@ seta cl_artwork_lose 2 "number of artwork_lost_ images available in the gfx fold seta cl_artwork_stretch 0 "stretch artwork to fit the screen, even if it brakes image proportions" seta cl_artwork_alpha 1 "artwork alpha" seta cl_artwork_fade 0.3 "artwork fade in speed" + +seta cl_reticle_stretch 0 "whether to stretch reticles so they fit the screen (brakes image proportions)" +seta cl_reticle_item_weapon 1 "draw aiming reticle for weapon zoom, 0 disables and values between 0 and 1 change alpha" +seta cl_reticle_item_normal 1 "draw reticle when zooming without a weapon, 0 disables and values between 0 and 1 change alpha" fov 90 seta cl_velocityzoom 0 "velocity based zooming of fov, negative values zoom out" seta cl_velocityzoomtime 0.3 "time value for averaging speed values" diff --git a/data/qcsrc/client/View.qc b/data/qcsrc/client/View.qc index ecdadde9..9a1b97ab 100644 --- a/data/qcsrc/client/View.qc +++ b/data/qcsrc/client/View.qc @@ -250,6 +250,7 @@ void CSQC_Demo_Camera(); float Sbar_WouldDrawScoreboard (); float view_set; float camera_mode; +float reticle_type; float chase_active_old; float artwork_fade; float pickup_crosshair_time, pickup_crosshair_size; @@ -272,6 +273,7 @@ void CSQC_UpdateView(float w, float h) vector v, vo; float a; + vector reticle_pos, reticle_size; vector artwork_pos, artwork_size; WaypointSprite_Load(); @@ -460,6 +462,48 @@ void CSQC_UpdateView(float w, float h) // next R_RenderScene call drawstring('0 0 0', "", '1 1 0', '1 1 1', 0, 0); + // Draw the aiming reticle for weapons that use it + // reticle_type is changed to the item we are zooming / aiming with, to decide which reticle to use + // It must be a persisted float for fading out to work properly (you let go of the zoom button for + // the view to go back to normal, so reticle_type would become 0 as we fade out) + if(spectatee_status || getstati(STAT_HEALTH) <= 0) + reticle_type = 0; // prevent reticle from showing during the respawn zoom effect or for spectators + else if(activeweapon && (button_zoom || zoomscript_caught)) + reticle_type = 2; // weapon zoom + else if(button_zoom || zoomscript_caught) + reticle_type = 1; // normal zoom + + if(cvar("cl_reticle_stretch")) + { + reticle_size_x = vid_conwidth; + reticle_size_y = vid_conheight; + reticle_pos_x = 0; + reticle_pos_y = 0; + } + else + { + reticle_size_x = max(vid_conwidth, vid_conheight); + reticle_size_y = max(vid_conwidth, vid_conheight); + reticle_pos_x = (vid_conwidth - reticle_size_x) / 2; + reticle_pos_y = (vid_conheight - reticle_size_y) / 2; + } + + f = current_zoomfraction; + if(zoomscript_caught) + f = 1; + if(cvar("cl_reticle_item_normal")) + { + precache_pic("gfx/reticle_normal"); + if(reticle_type == 1 && f) + drawpic(reticle_pos, "gfx/reticle_normal", reticle_size, '1 1 1', f * cvar("cl_reticle_item_normal"), DRAWFLAG_NORMAL); + } + if(cvar("cl_reticle_item_weapon")) + { + precache_pic("gfx/reticle_weapon"); + if(reticle_type == 2 && f) + drawpic(reticle_pos, "gfx/reticle_weapon", reticle_size, '1 1 1', f * cvar("cl_reticle_item_weapon"), DRAWFLAG_NORMAL); + } + // screen effects if(cvar("hud_contents")) { -- 2.39.2