]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Make per-weapon reticles an attribute instead of a global string
authorMario <mario@smbclan.net>
Sat, 1 Oct 2016 10:51:01 +0000 (20:51 +1000)
committerMario <mario@smbclan.net>
Sat, 1 Oct 2016 10:51:01 +0000 (20:51 +1000)
qcsrc/client/view.qc
qcsrc/common/weapons/weapon.qh
qcsrc/common/weapons/weapon/rifle.qc
qcsrc/common/weapons/weapon/vaporizer.qc
qcsrc/common/weapons/weapon/vortex.qc

index ac58fd7927f82668c585e1cd747ca2e7ebc5fb42..98bd49dea30c35ee5577c1b929a76d1560255215 100644 (file)
@@ -726,7 +726,6 @@ float camera_mode;
 const float CAMERA_FREE = 1;
 const float CAMERA_CHASE = 2;
 float reticle_type;
-string reticle_image;
 string NextFrameCommand;
 
 vector freeze_org, freeze_ang;
@@ -1948,13 +1947,18 @@ void CSQC_UpdateView(entity this, float w, float h)
 
        if(autocvar_cl_reticle)
        {
+               string reticle_image = wepent.activeweapon.w_reticle;
                bool wep_zoomed = false;
                for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
                {
                        entity wepe = viewmodels[slot];
                        Weapon wep = wepe.activeweapon;
                        if(wep != WEP_Null && wep.wr_zoom)
-                               wep_zoomed += wep.wr_zoom(wep, NULL);
+                       {
+                               bool do_zoom = wep.wr_zoom(wep, NULL);
+                               reticle_image = wep.w_reticle;
+                               wep_zoomed += do_zoom;
+                       }
                }
                // 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
@@ -1967,7 +1971,7 @@ void CSQC_UpdateView(entity this, float w, float h)
                }
                else if(wep_zoomed && autocvar_cl_reticle_weapon)
                {
-                       if(reticle_image != "") { reticle_type = 2; }
+                       if(reticle_image && reticle_image != "") { reticle_type = 2; }
                        else { reticle_type = 0; }
                }
                else if(button_zoom || zoomscript_caught)
index 9d7d11ddba35df57039fd3dab2352d3f784083e1..2e4f0c263c405d33e9ab884a472e48d82006d19c 100644 (file)
@@ -75,6 +75,8 @@ CLASS(Weapon, Object)
     ATTRIB(Weapon, w_crosshair, string, "gfx/crosshair1");
     /** A: crosshair : per-weapon crosshair size (argument two of "crosshair" field) */
     ATTRIB(Weapon, w_crosshair_size, float, 1);
+    /** A: reticle   : per-weapon zoom reticle */
+    ATTRIB(Weapon, w_reticle, string, "");
     /** M: wepimg    : "weaponfoobar" side view image file of weapon. WEAPONTODO: Move out of skin files, move to common files */
     ATTRIB(Weapon, model2, string, "");
     /** M: refname   : reference name name */
index 4794e866a0ce897d1eb0db0aceb538f0aa7fecc0..64242bed6c86eadbc4313238454c2db38f3b529a 100644 (file)
@@ -12,6 +12,7 @@ CLASS(Rifle, Weapon)
 #endif
 /* crosshair */ ATTRIB(Rifle, w_crosshair, string, "gfx/crosshairrifle");
 /* crosshair */ ATTRIB(Rifle, w_crosshair_size, float, 0.6);
+/* reticle   */ ATTRIB(Rifle, w_reticle, string, "gfx/reticle_nex");
 /* wepimg    */ ATTRIB(Rifle, model2, string, "weaponrifle");
 /* refname   */ ATTRIB(Rifle, netname, string, "rifle");
 /* wepname   */ ATTRIB(Rifle, m_name, string, _("Rifle"));
@@ -270,7 +271,6 @@ METHOD(Rifle, wr_zoom, bool(entity thiswep, entity actor))
 {
     if(button_zoom || zoomscript_caught)
     {
-        reticle_image = "gfx/reticle_nex";
         return true;
     }
     else
index 0c0b5b0c3f051ee0a4e9ff4de63aefb50383f1f7..2ce5cb01b110d2cabdc0afd856d8d66e591354db 100644 (file)
@@ -12,6 +12,7 @@ CLASS(Vaporizer, Weapon)
 #endif
 /* crosshair */ ATTRIB(Vaporizer, w_crosshair, string, "gfx/crosshairminstanex");
 /* crosshair */ ATTRIB(Vaporizer, w_crosshair_size, float, 0.6);
+/* reticle   */ ATTRIB(Vaporizer, w_reticle, string, "gfx/reticle_nex");
 /* wepimg    */ ATTRIB(Vaporizer, model2, string, "weaponminstanex");
 /* refname   */ ATTRIB(Vaporizer, netname, string, "vaporizer");
 /* wepname   */ ATTRIB(Vaporizer, m_name, string, _("Vaporizer"));
@@ -505,7 +506,6 @@ METHOD(Vaporizer, wr_zoom, bool(entity thiswep, entity actor))
 {
     if(button_zoom || zoomscript_caught)
     {
-        reticle_image = "gfx/reticle_nex";
         return true;
     }
     else
index 1fbb901d5159bc24a70a26361b437870f1c80363..eca15feca0e4401bd036f1783608410289ba9125 100644 (file)
@@ -12,6 +12,7 @@ CLASS(Vortex, Weapon)
 #endif
 /* crosshair */ ATTRIB(Vortex, w_crosshair, string, "gfx/crosshairnex");
 /* crosshair */ ATTRIB(Vortex, w_crosshair_size, float, 0.65);
+/* reticle   */ ATTRIB(Vortex, w_reticle, string, "gfx/reticle_nex");
 /* wepimg    */ ATTRIB(Vortex, model2, string, "weaponnex");
 /* refname   */ ATTRIB(Vortex, netname, string, "vortex");
 /* wepname   */ ATTRIB(Vortex, m_name, string, _("Vortex"));
@@ -386,7 +387,7 @@ METHOD(Vortex, wr_killmessage, Notification(entity thiswep))
 }
 METHOD(Vortex, wr_zoom, bool(entity thiswep, entity actor))
 {
-    return PHYS_INPUT_BUTTON_ATCK2(actor);
+    return PHYS_INPUT_BUTTON_ATCK2(actor) && !WEP_CVAR(vortex, secondary);
 }
 
 #endif
@@ -411,7 +412,6 @@ METHOD(Vortex, wr_zoom, bool(entity thiswep, entity actor))
 {
     if(button_zoom || zoomscript_caught || (!WEP_CVAR(vortex, secondary) && button_attack2))
     {
-        reticle_image = "gfx/reticle_nex";
         return true;
     }
     else