From: Samual Lenks Date: Tue, 31 Dec 2013 16:25:35 +0000 (-0500) Subject: Make it so that weapon zoom reticles are in weapon code, not view code X-Git-Tag: xonotic-v0.8.0~152^2~188 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=40e05369d8f7ebb2da94656bf15847ef4e314e32;p=xonotic%2Fxonotic-data.pk3dir.git Make it so that weapon zoom reticles are in weapon code, not view code --- diff --git a/qcsrc/client/Main.qc b/qcsrc/client/Main.qc index c5e214116..49d0461a1 100644 --- a/qcsrc/client/Main.qc +++ b/qcsrc/client/Main.qc @@ -127,8 +127,8 @@ void CSQC_Init(void) if(autocvar_cl_reticle) { - if(autocvar_cl_reticle_item_normal) { precache_pic("gfx/reticle_normal"); } - if(autocvar_cl_reticle_item_vortex) { precache_pic("gfx/reticle_nex"); } + precache_pic("gfx/reticle_normal"); + // weapon reticles are precached in weapon files } get_mi_min_max_texcoords(1); // try the CLEVER way first diff --git a/qcsrc/client/View.qc b/qcsrc/client/View.qc index 07c866fb6..554ddfaad 100644 --- a/qcsrc/client/View.qc +++ b/qcsrc/client/View.qc @@ -352,6 +352,7 @@ float camera_mode; const float CAMERA_FREE = 1; const float CAMERA_CHASE = 2; float reticle_type; +string reticle_image; string NextFrameCommand; void CSQC_SPIDER_HUD(); void CSQC_RAPTOR_HUD(); @@ -798,50 +799,64 @@ void CSQC_UpdateView(float w, float h) R_EndPolygon(); } - // 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 || is_dead || hud != HUD_NORMAL) - reticle_type = 0; // prevent reticle from showing during the respawn zoom effect or for spectators - else if((activeweapon == WEP_VORTEX || activeweapon == WEP_RIFLE || activeweapon == WEP_VAPORIZER) && (button_zoom || zoomscript_caught)) - reticle_type = 2; // nex zoom - else if(button_zoom || zoomscript_caught) - reticle_type = 1; // normal zoom - else if((activeweapon == WEP_VORTEX) && button_attack2) - reticle_type = 2; // nex zoom - - if(reticle_type && autocvar_cl_reticle) + if(autocvar_cl_reticle) { - if(autocvar_cl_reticle_stretch) + // 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 || is_dead || hud != HUD_NORMAL) { - reticle_size_x = vid_conwidth; - reticle_size_y = vid_conheight; - reticle_pos_x = 0; - reticle_pos_y = 0; + // no zoom reticle while dead + reticle_type = 0; } - else + else if(WEP_ACTION(activeweapon, WR_ZOOMRETICLE) && autocvar_cl_reticle_weapon) { - 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; + if(reticle_image != "") { reticle_type = 2; } + else { reticle_type = 0; } } - - f = current_zoomfraction; - if(zoomscript_caught) - f = 1; - if(autocvar_cl_reticle_item_normal) + else if(button_zoom || zoomscript_caught) { - if(reticle_type == 1 && f) - drawpic(reticle_pos, "gfx/reticle_normal", reticle_size, '1 1 1', f * autocvar_cl_reticle_item_normal, DRAWFLAG_NORMAL); + // normal zoom + reticle_type = 1; } - if(autocvar_cl_reticle_item_vortex) + + if(reticle_type) { - if(reticle_type == 2 && f) - drawpic(reticle_pos, "gfx/reticle_nex", reticle_size, '1 1 1', f * autocvar_cl_reticle_item_vortex, DRAWFLAG_NORMAL); + if(autocvar_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; + } + + if(zoomscript_caught) + f = 1; + else + f = current_zoomfraction; + + if(f) + { + switch(reticle_type) + { + case 1: drawpic(reticle_pos, "gfx/reticle_normal", reticle_size, '1 1 1', f * autocvar_cl_reticle_normal_alpha, DRAWFLAG_NORMAL); break; + case 2: drawpic(reticle_pos, reticle_image, reticle_size, '1 1 1', f * autocvar_cl_reticle_weapon_alpha, DRAWFLAG_NORMAL); break; + } + } } } + else + { + if(reticle_type != 0) { reticle_type = 0; } + } // improved polyblend diff --git a/qcsrc/client/autocvars.qh b/qcsrc/client/autocvars.qh index 1e5ad9d92..bd3870762 100644 --- a/qcsrc/client/autocvars.qh +++ b/qcsrc/client/autocvars.qh @@ -60,8 +60,9 @@ float autocvar_cl_particles_quality; float autocvar_cl_projectiles_sloppy; float autocvar_cl_readpicture_force; var float autocvar_cl_reticle = 1; -float autocvar_cl_reticle_item_vortex; -float autocvar_cl_reticle_item_normal; +var float autocvar_cl_reticle_normal_alpha = 1; +var float autocvar_cl_reticle_weapon = 1; +var float autocvar_cl_reticle_weapon_alpha = 1; float autocvar_cl_reticle_stretch; float autocvar_cl_spawn_event_particles; var float autocvar_cl_spawn_event_sound = 1; diff --git a/qcsrc/common/weapons/w_arc.qc b/qcsrc/common/weapons/w_arc.qc index 6906c0d9e..511f7e784 100644 --- a/qcsrc/common/weapons/w_arc.qc +++ b/qcsrc/common/weapons/w_arc.qc @@ -329,6 +329,11 @@ float W_Arc(float req) precache_sound("weapons/arc_impact_combo.wav"); return TRUE; } + case WR_ZOOMRETICLE: + { + // no weapon specific image for this weapon + return FALSE; + } } return TRUE; } diff --git a/qcsrc/common/weapons/w_blaster.qc b/qcsrc/common/weapons/w_blaster.qc index 6a9d2a764..7566d10ec 100644 --- a/qcsrc/common/weapons/w_blaster.qc +++ b/qcsrc/common/weapons/w_blaster.qc @@ -277,6 +277,11 @@ float W_Blaster(float request) precache_sound("weapons/laserimpact.wav"); return TRUE; } + case WR_ZOOMRETICLE: + { + // no weapon specific image for this weapon + return FALSE; + } } return TRUE; diff --git a/qcsrc/common/weapons/w_crylink.qc b/qcsrc/common/weapons/w_crylink.qc index a7f3a1b06..c91f3ab90 100644 --- a/qcsrc/common/weapons/w_crylink.qc +++ b/qcsrc/common/weapons/w_crylink.qc @@ -714,6 +714,11 @@ float W_Crylink(float req) precache_sound("weapons/crylink_impact.wav"); return TRUE; } + case WR_ZOOMRETICLE: + { + // no weapon specific image for this weapon + return FALSE; + } } return TRUE; } diff --git a/qcsrc/common/weapons/w_devastator.qc b/qcsrc/common/weapons/w_devastator.qc index 0f5afb02c..4f5f8b3aa 100644 --- a/qcsrc/common/weapons/w_devastator.qc +++ b/qcsrc/common/weapons/w_devastator.qc @@ -479,6 +479,11 @@ float W_Devastator(float req) precache_sound("weapons/rocket_impact.wav"); return TRUE; } + case WR_ZOOMRETICLE: + { + // no weapon specific image for this weapon + return FALSE; + } } return TRUE; } diff --git a/qcsrc/common/weapons/w_electro.qc b/qcsrc/common/weapons/w_electro.qc index 44234b7f6..d13b55674 100644 --- a/qcsrc/common/weapons/w_electro.qc +++ b/qcsrc/common/weapons/w_electro.qc @@ -586,6 +586,11 @@ float W_Electro(float req) precache_sound("weapons/electro_impact_combo.wav"); return TRUE; } + case WR_ZOOMRETICLE: + { + // no weapon specific image for this weapon + return FALSE; + } } return TRUE; } diff --git a/qcsrc/common/weapons/w_fireball.qc b/qcsrc/common/weapons/w_fireball.qc index 0a19c3df0..ad2e42625 100644 --- a/qcsrc/common/weapons/w_fireball.qc +++ b/qcsrc/common/weapons/w_fireball.qc @@ -469,6 +469,11 @@ float W_Fireball(float req) precache_sound("weapons/fireball_impact2.wav"); return TRUE; } + case WR_ZOOMRETICLE: + { + // no weapon specific image for this weapon + return FALSE; + } } return TRUE; diff --git a/qcsrc/common/weapons/w_hagar.qc b/qcsrc/common/weapons/w_hagar.qc index d745d1473..56e620740 100644 --- a/qcsrc/common/weapons/w_hagar.qc +++ b/qcsrc/common/weapons/w_hagar.qc @@ -543,6 +543,11 @@ float W_Hagar(float req) precache_sound("weapons/hagexp3.wav"); return TRUE; } + case WR_ZOOMRETICLE: + { + // no weapon specific image for this weapon + return FALSE; + } } return TRUE; } diff --git a/qcsrc/common/weapons/w_hlac.qc b/qcsrc/common/weapons/w_hlac.qc index 80ad5661d..cad0f53bf 100644 --- a/qcsrc/common/weapons/w_hlac.qc +++ b/qcsrc/common/weapons/w_hlac.qc @@ -297,6 +297,11 @@ float W_HLAC(float req) precache_sound("weapons/laserimpact.wav"); return TRUE; } + case WR_ZOOMRETICLE: + { + // no weapon specific image for this weapon + return FALSE; + } } return TRUE; } diff --git a/qcsrc/common/weapons/w_hook.qc b/qcsrc/common/weapons/w_hook.qc index 361d8ba62..a4b07319a 100644 --- a/qcsrc/common/weapons/w_hook.qc +++ b/qcsrc/common/weapons/w_hook.qc @@ -351,6 +351,11 @@ float W_Hook(float req) precache_sound("weapons/hookbomb_impact.wav"); return TRUE; } + case WR_ZOOMRETICLE: + { + // no weapon specific image for this weapon + return FALSE; + } } return TRUE; } diff --git a/qcsrc/common/weapons/w_machinegun.qc b/qcsrc/common/weapons/w_machinegun.qc index 0bb2d8126..5fda5ef17 100644 --- a/qcsrc/common/weapons/w_machinegun.qc +++ b/qcsrc/common/weapons/w_machinegun.qc @@ -391,6 +391,11 @@ float W_MachineGun(float req) precache_sound("weapons/ric3.wav"); return TRUE; } + case WR_ZOOMRETICLE: + { + // no weapon specific image for this weapon + return FALSE; + } } return TRUE; } diff --git a/qcsrc/common/weapons/w_minelayer.qc b/qcsrc/common/weapons/w_minelayer.qc index 6e70043ae..62f8e9e28 100644 --- a/qcsrc/common/weapons/w_minelayer.qc +++ b/qcsrc/common/weapons/w_minelayer.qc @@ -604,6 +604,11 @@ float W_MineLayer(float req) precache_sound("weapons/mine_exp.wav"); return TRUE; } + case WR_ZOOMRETICLE: + { + // no weapon specific image for this weapon + return FALSE; + } } return TRUE; } diff --git a/qcsrc/common/weapons/w_mortar.qc b/qcsrc/common/weapons/w_mortar.qc index b9b335207..df300db13 100644 --- a/qcsrc/common/weapons/w_mortar.qc +++ b/qcsrc/common/weapons/w_mortar.qc @@ -474,6 +474,11 @@ float W_Mortar(float req) precache_sound("weapons/grenade_impact.wav"); return TRUE; } + case WR_ZOOMRETICLE: + { + // no weapon specific image for this weapon + return FALSE; + } } return TRUE; } diff --git a/qcsrc/common/weapons/w_porto.qc b/qcsrc/common/weapons/w_porto.qc index 2963182ea..e0bf83ba4 100644 --- a/qcsrc/common/weapons/w_porto.qc +++ b/qcsrc/common/weapons/w_porto.qc @@ -406,6 +406,11 @@ float W_Porto(float req) // nothing to do return TRUE; } + case WR_ZOOMRETICLE: + { + // no weapon specific image for this weapon + return FALSE; + } } return TRUE; } diff --git a/qcsrc/common/weapons/w_rifle.qc b/qcsrc/common/weapons/w_rifle.qc index 3f3755747..fca774e05 100644 --- a/qcsrc/common/weapons/w_rifle.qc +++ b/qcsrc/common/weapons/w_rifle.qc @@ -286,8 +286,25 @@ float W_Rifle(float req) precache_sound("weapons/ric1.wav"); precache_sound("weapons/ric2.wav"); precache_sound("weapons/ric3.wav"); + if(autocvar_cl_reticle && autocvar_cl_reticle_weapon) + { + precache_pic("gfx/reticle_nex"); + } return TRUE; } + case WR_ZOOMRETICLE: + { + if(button_zoom || zoomscript_caught) + { + reticle_image = "gfx/reticle_nex"; + return TRUE; + } + else + { + // no weapon specific image for this weapon + return FALSE; + } + } } return TRUE; diff --git a/qcsrc/common/weapons/w_seeker.qc b/qcsrc/common/weapons/w_seeker.qc index 64662a50c..f7b9ae4aa 100644 --- a/qcsrc/common/weapons/w_seeker.qc +++ b/qcsrc/common/weapons/w_seeker.qc @@ -776,6 +776,11 @@ float W_Seeker(float req) precache_sound("weapons/tag_impact.wav"); return TRUE; } + case WR_ZOOMRETICLE: + { + // no weapon specific image for this weapon + return FALSE; + } } return TRUE; diff --git a/qcsrc/common/weapons/w_shockwave.qc b/qcsrc/common/weapons/w_shockwave.qc index 0f80b982b..0b3c2b475 100644 --- a/qcsrc/common/weapons/w_shockwave.qc +++ b/qcsrc/common/weapons/w_shockwave.qc @@ -727,6 +727,11 @@ float W_Shockwave(float req) //precache_sound("weapons/ric3.wav"); return FALSE; } + case WR_ZOOMRETICLE: + { + // no weapon specific image for this weapon + return FALSE; + } } return TRUE; } diff --git a/qcsrc/common/weapons/w_shotgun.qc b/qcsrc/common/weapons/w_shotgun.qc index 2d92ffda8..bb20240af 100644 --- a/qcsrc/common/weapons/w_shotgun.qc +++ b/qcsrc/common/weapons/w_shotgun.qc @@ -315,6 +315,11 @@ float W_Shotgun(float req) precache_sound("weapons/ric3.wav"); return TRUE; } + case WR_ZOOMRETICLE: + { + // no weapon specific image for this weapon + return FALSE; + } } return TRUE; } diff --git a/qcsrc/common/weapons/w_tuba.qc b/qcsrc/common/weapons/w_tuba.qc index df5bb97f9..7db2bd4e9 100644 --- a/qcsrc/common/weapons/w_tuba.qc +++ b/qcsrc/common/weapons/w_tuba.qc @@ -487,6 +487,16 @@ float W_Tuba(float req) float W_Tuba(float req) { // nothing to do here; particles of tuba are handled differently + // WEAPONTODO + + switch(req) + { + case WR_ZOOMRETICLE: + { + // no weapon specific image for this weapon + return FALSE; + } + } return TRUE; } diff --git a/qcsrc/common/weapons/w_vaporizer.qc b/qcsrc/common/weapons/w_vaporizer.qc index cc6a58517..63c9bb5cf 100644 --- a/qcsrc/common/weapons/w_vaporizer.qc +++ b/qcsrc/common/weapons/w_vaporizer.qc @@ -265,8 +265,25 @@ float W_Vaporizer(float req) case WR_INIT: { precache_sound("weapons/neximpact.wav"); + if(autocvar_cl_reticle && autocvar_cl_reticle_weapon) + { + precache_pic("gfx/reticle_nex"); + } return TRUE; } + case WR_ZOOMRETICLE: + { + if(button_zoom || zoomscript_caught) + { + reticle_image = "gfx/reticle_nex"; + return TRUE; + } + else + { + // no weapon specific image for this weapon + return FALSE; + } + } } return TRUE; } diff --git a/qcsrc/common/weapons/w_vortex.qc b/qcsrc/common/weapons/w_vortex.qc index a8d0ea131..6a43b1e46 100644 --- a/qcsrc/common/weapons/w_vortex.qc +++ b/qcsrc/common/weapons/w_vortex.qc @@ -293,6 +293,7 @@ float W_Vortex(float req) } #endif #ifdef CSQC +var float autocvar_g_balance_vortex_secondary = 0; // WEAPONTODO float W_Vortex(float req) { switch(req) @@ -310,8 +311,25 @@ float W_Vortex(float req) case WR_INIT: { precache_sound("weapons/neximpact.wav"); + if(autocvar_cl_reticle && autocvar_cl_reticle_weapon) + { + precache_pic("gfx/reticle_nex"); + } return TRUE; } + case WR_ZOOMRETICLE: + { + if(button_zoom || zoomscript_caught || (!WEP_CVAR(vortex, secondary) && button_attack2)) + { + reticle_image = "gfx/reticle_nex"; + return TRUE; + } + else + { + // no weapon specific image for this weapon + return FALSE; + } + } } return TRUE; } diff --git a/qcsrc/common/weapons/weapons.qh b/qcsrc/common/weapons/weapons.qh index 602f8f733..cbd2c34f3 100644 --- a/qcsrc/common/weapons/weapons.qh +++ b/qcsrc/common/weapons/weapons.qh @@ -34,7 +34,8 @@ const float MAX_SHOT_DISTANCE = 32768; #define WR_SWITCHABLE 12 // (CLIENT) impact effect #define WR_PLAYERDEATH 13 // (SERVER) does not need to do anything #define WR_GONETHINK 14 // (SERVER) logic to run every frame, also if no longer having the weapon as long as the switch away has not been performed -#define WR_CONFIG 15 // (ALL) +#define WR_CONFIG 15 // (ALL) +#define WR_ZOOMRETICLE 16 // (CLIENT) weapon specific zoom reticle // WEAPONTODO const float IT_UNLIMITED_WEAPON_AMMO = 1; @@ -127,7 +128,7 @@ string W_Name(float weaponid); .WepSet weapons; // WEPSET_... .string netname; // short name .string message; // human readable name -.float items; // IT_... +.float items; // IT_... // WEAPONTODO: I thought I removed items from weapons... ? .float(float) weapon_func; // w_... .vector wpcolor; // waypointsprite color .string mdl; // modelname without g_, v_, w_ @@ -136,6 +137,7 @@ string W_Name(float weaponid); .float impulse; // weapon impulse .float bot_pickupbasevalue; // bot weapon priority .string model2; // wpn- sprite name +.string message2; // zoom reticle image ..float current_ammo; // main ammo field // other useful macros