From: Mario Date: Sat, 1 Oct 2016 10:51:01 +0000 (+1000) Subject: Make per-weapon reticles an attribute instead of a global string X-Git-Tag: xonotic-v0.8.2~326^2~77^2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=b1e67b8362394879c1d0c6250930820cc56b5b36;p=xonotic%2Fxonotic-data.pk3dir.git Make per-weapon reticles an attribute instead of a global string --- diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index ac58fd792..98bd49dea 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -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) diff --git a/qcsrc/common/weapons/weapon.qh b/qcsrc/common/weapons/weapon.qh index 9d7d11ddb..2e4f0c263 100644 --- a/qcsrc/common/weapons/weapon.qh +++ b/qcsrc/common/weapons/weapon.qh @@ -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 */ diff --git a/qcsrc/common/weapons/weapon/rifle.qc b/qcsrc/common/weapons/weapon/rifle.qc index 4794e866a..64242bed6 100644 --- a/qcsrc/common/weapons/weapon/rifle.qc +++ b/qcsrc/common/weapons/weapon/rifle.qc @@ -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 diff --git a/qcsrc/common/weapons/weapon/vaporizer.qc b/qcsrc/common/weapons/weapon/vaporizer.qc index 0c0b5b0c3..2ce5cb01b 100644 --- a/qcsrc/common/weapons/weapon/vaporizer.qc +++ b/qcsrc/common/weapons/weapon/vaporizer.qc @@ -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 diff --git a/qcsrc/common/weapons/weapon/vortex.qc b/qcsrc/common/weapons/weapon/vortex.qc index 1fbb901d5..eca15feca 100644 --- a/qcsrc/common/weapons/weapon/vortex.qc +++ b/qcsrc/common/weapons/weapon/vortex.qc @@ -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