]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Make it so that weapon zoom reticles are in weapon code, not view code
authorSamual Lenks <samual@xonotic.org>
Tue, 31 Dec 2013 16:25:35 +0000 (11:25 -0500)
committerSamual Lenks <samual@xonotic.org>
Tue, 31 Dec 2013 16:25:35 +0000 (11:25 -0500)
24 files changed:
qcsrc/client/Main.qc
qcsrc/client/View.qc
qcsrc/client/autocvars.qh
qcsrc/common/weapons/w_arc.qc
qcsrc/common/weapons/w_blaster.qc
qcsrc/common/weapons/w_crylink.qc
qcsrc/common/weapons/w_devastator.qc
qcsrc/common/weapons/w_electro.qc
qcsrc/common/weapons/w_fireball.qc
qcsrc/common/weapons/w_hagar.qc
qcsrc/common/weapons/w_hlac.qc
qcsrc/common/weapons/w_hook.qc
qcsrc/common/weapons/w_machinegun.qc
qcsrc/common/weapons/w_minelayer.qc
qcsrc/common/weapons/w_mortar.qc
qcsrc/common/weapons/w_porto.qc
qcsrc/common/weapons/w_rifle.qc
qcsrc/common/weapons/w_seeker.qc
qcsrc/common/weapons/w_shockwave.qc
qcsrc/common/weapons/w_shotgun.qc
qcsrc/common/weapons/w_tuba.qc
qcsrc/common/weapons/w_vaporizer.qc
qcsrc/common/weapons/w_vortex.qc
qcsrc/common/weapons/weapons.qh

index c5e214116f56e746b17b33045ad6ae34219faba0..49d0461a195e689cb982ab49582c93f21bdb6758 100644 (file)
@@ -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
index 07c866fb6cc7fd8d2a53b395755fcda6901b8a15..554ddfaad11cba7822d9fc8c2ceb49c99be79734 100644 (file)
@@ -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
index 1e5ad9d92ef848bda57e887f28607bf64865cbbe..bd3870762d867a4bc565521823e689c0b07130d2 100644 (file)
@@ -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;
index 6906c0d9e218b5a76e04f0c73842450baa7c01cb..511f7e784ec59d6579aa4fb6859fc126522edefd 100644 (file)
@@ -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;
 }
index 6a9d2a764ad1e8ffe7256b6688035b2133c6f8ee..7566d10ec96f361684b120a78b4db9826ff1e33c 100644 (file)
@@ -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;
index a7f3a1b063e509c1e73f285d3bf4178e5c881a6a..c91f3ab904f74ea40368593f869a38d44ebd071b 100644 (file)
@@ -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;
 }
index 0f5afb02ceb0f783e24bfe011c302acd7352957d..4f5f8b3aaac89818ff0494cdc1d8bb57197ee5da 100644 (file)
@@ -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;
 }
index 44234b7f6db92e0cc5dcffaa95cc9de4c8dd634d..d13b55674582b048d11e0bd32c66dc31d9312d5b 100644 (file)
@@ -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;
 }
index 0a19c3df0496dae873d962e16aaae2de2c5fce58..ad2e426257628b8b0327275dcdc2066d90d8250f 100644 (file)
@@ -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;
index d745d1473c628a21c478b29d9f46c883fe7971b9..56e62074061f4b41eeeda36af6128bfe63ca3046 100644 (file)
@@ -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;
 }
index 80ad5661dbee138aaa56f69dde445687108c3d26..cad0f53bfc7cb485db0dc3ff553a9908c3917bfc 100644 (file)
@@ -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;
 }
index 361d8ba62d0d263c50cf8d4c5c72fde8822be79b..a4b07319a8c00323d334ebcc4f463af0e37683a3 100644 (file)
@@ -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;
 }
index 0bb2d812685edbd8cbd658672034220547af3fed..5fda5ef174996dc3f2783eb6d76da7a13ed37d9a 100644 (file)
@@ -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;
 }
index 6e70043ae190aa91ca7bc56c33f9ee3a8f5ef345..62f8e9e28f730b6e574a0a77c019f466d563d08a 100644 (file)
@@ -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;
 }
index b9b33520741c612b013fea78f0d403a45a794a86..df300db136842ae2c49f5aa3b7703f2472820ebc 100644 (file)
@@ -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;
 }
index 2963182ea27f845ec25ac0c1e4940b56168b9eff..e0bf83ba456c032d45d86a7c3bb535fa56b4682d 100644 (file)
@@ -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;
 }
index 3f3755747e37fb600d26cdbc2eaddb04d1d62bf0..fca774e05e0fc4d2c11ae99edd8c2c11de156f85 100644 (file)
@@ -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;
index 64662a50c5d05998b05799b907790c831b8fdf42..f7b9ae4aa6d92a7296fe1bf8b342a6796023100b 100644 (file)
@@ -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;
index 0f80b982bb57169b4ca1edcc7d5875a03ea6f035..0b3c2b47552285a00991d9e724158ae3b46453f4 100644 (file)
@@ -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;
 }
index 2d92ffda8c4dee75e27286e1842058e9ac1233a6..bb20240af973d2689074433785887e2a8a178e3b 100644 (file)
@@ -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;
 }
index df5bb97f90b2fe27c6c6b6f0b086676a2dd9f939..7db2bd4e9d697c00770fd22a1b84ca008a405225 100644 (file)
@@ -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;
 }
index cc6a585178d7e8c91af4c8efcea6fe3c48d059d0..63c9bb5cfcfcb9577aaa8b596cd07a91541c87c3 100644 (file)
@@ -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;
 }
index a8d0ea1317315756a82d633dad6b59ffda10847b..6a43b1e465d0885badbb5481d4e93ce16a51b646 100644 (file)
@@ -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;
 }
index 602f8f7330e3e8e27419b75201fd8ab2acc68492..cbd2c34f3c486e07e9bcc9f54d557954465492f6 100644 (file)
@@ -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