]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cl_weaponsystem.qc
fix glowmod of weapon entity (no longer assign it to world, make code more consistent)
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_weaponsystem.qc
index 2770d43147a09eb400fc21cc3155f4b2f9bc6863..4f5e7604448fc0e7458a91be39f81fc4808f9f20 100644 (file)
@@ -19,13 +19,13 @@ float W_WeaponRateFactor()
                if(self.runes & RUNE_SPEED)
                {
                        if(self.runes & CURSE_SLOW)
-                               t = t * cvar("g_balance_rune_speed_combo_atkrate");
+                               t = t * autocvar_g_balance_rune_speed_combo_atkrate;
                        else
-                               t = t * cvar("g_balance_rune_speed_atkrate");
+                               t = t * autocvar_g_balance_rune_speed_atkrate;
                }
                else if(self.runes & CURSE_SLOW)
                {
-                       t = t * cvar("g_balance_curse_slow_atkrate");
+                       t = t * autocvar_g_balance_curse_slow_atkrate;
                }
        }
 
@@ -132,7 +132,7 @@ vector w_shotend;
 // make sure you call makevectors first (FIXME?)
 .float prevstrengthsound;
 .float prevstrengthsoundattempt;
-void W_SetupShot_Dir_ProjectileSize_Range(entity ent, vector s_forward, vector mi, vector ma, float antilag, float recoil, string snd, float maxdamage, float range)
+void W_SetupShot_Dir_ProjectileSize_Range(entity ent, vector s_forward, vector mi, vector ma, float antilag, float recoil, string snd, float chan, float maxdamage, float range)
 {
        float nudge = 1; // added to traceline target and subtracted from result
        local float oldsolid;
@@ -191,7 +191,7 @@ void W_SetupShot_Dir_ProjectileSize_Range(entity ent, vector s_forward, vector m
        if (antilag)
        if (!ent.cvar_cl_noantilag)
        {
-               if (cvar("g_antilag") == 1) // switch to "ghost" if not hitting original
+               if (autocvar_g_antilag == 1) // switch to "ghost" if not hitting original
                {
                        traceline(w_shotorg, w_shotorg + w_shotdir * range, MOVE_NORMAL, ent);
                        if (!trace_ent.takedamage)
@@ -207,7 +207,7 @@ void W_SetupShot_Dir_ProjectileSize_Range(entity ent, vector s_forward, vector m
                                }
                        }
                }
-               else if(cvar("g_antilag") == 3) // client side hitscan
+               else if(autocvar_g_antilag == 3) // client side hitscan
                {
                        // this part MUST use prydon cursor
                        if (ent.cursor_trace_ent)                 // client was aiming at someone
@@ -237,16 +237,14 @@ void W_SetupShot_Dir_ProjectileSize_Range(entity ent, vector s_forward, vector m
                ent.punchangle_x = recoil * -1;
 
        if (snd != "")
-       {
-               sound (ent, CHAN_WEAPON, snd, VOL_BASE, ATTN_NORM);
-       }
+               sound (ent, chan, snd, VOL_BASE, ATTN_NORM);
 
        if(ent.items & IT_STRENGTH)
        if(!g_minstagib)
        if(
-               (time > ent.prevstrengthsound + cvar("sv_strengthsound_antispam_time"))
+               (time > ent.prevstrengthsound + autocvar_sv_strengthsound_antispam_time)
                ||
-               (time > ent.prevstrengthsoundattempt + cvar("sv_strengthsound_antispam_refire_threshold"))
+               (time > ent.prevstrengthsoundattempt + autocvar_sv_strengthsound_antispam_refire_threshold)
        ) // prevent insane sound spam
        {
                sound(ent, CHAN_AUTO, "weapons/strength_fire.wav", VOL_BASE, ATTN_NORM);
@@ -258,11 +256,11 @@ void W_SetupShot_Dir_ProjectileSize_Range(entity ent, vector s_forward, vector m
        w_shotend = w_shotend + normalize(w_shotend - w_shotorg) * nudge;
 };
 
-#define W_SetupShot_Dir_ProjectileSize(ent,s_forward,mi,ma,antilag,recoil,snd,maxdamage) W_SetupShot_Dir_ProjectileSize_Range(ent, s_forward, mi, ma, antilag, recoil, snd, maxdamage, MAX_SHOT_DISTANCE)
-#define W_SetupShot_ProjectileSize(ent,mi,ma,antilag,recoil,snd,maxdamage) W_SetupShot_Dir_ProjectileSize(ent, v_forward, mi, ma, antilag, recoil, snd, maxdamage)
-#define W_SetupShot_Dir(ent,s_forward,antilag,recoil,snd,maxdamage) W_SetupShot_Dir_ProjectileSize(ent, s_forward, '0 0 0', '0 0 0', antilag, recoil, snd, maxdamage)
-#define W_SetupShot(ent,antilag,recoil,snd,maxdamage) W_SetupShot_ProjectileSize(ent, '0 0 0', '0 0 0', antilag, recoil, snd, maxdamage)
-#define W_SetupShot_Range(ent,antilag,recoil,snd,maxdamage,range) W_SetupShot_Dir_ProjectileSize_Range(ent, v_forward, '0 0 0', '0 0 0', antilag, recoil, snd, maxdamage, range)
+#define W_SetupShot_Dir_ProjectileSize(ent,s_forward,mi,ma,antilag,recoil,snd,chan,maxdamage) W_SetupShot_Dir_ProjectileSize_Range(ent, s_forward, mi, ma, antilag, recoil, snd, chan, maxdamage, MAX_SHOT_DISTANCE)
+#define W_SetupShot_ProjectileSize(ent,mi,ma,antilag,recoil,snd,chan,maxdamage) W_SetupShot_Dir_ProjectileSize(ent, v_forward, mi, ma, antilag, recoil, snd, chan, maxdamage)
+#define W_SetupShot_Dir(ent,s_forward,antilag,recoil,snd,chan,maxdamage) W_SetupShot_Dir_ProjectileSize(ent, s_forward, '0 0 0', '0 0 0', antilag, recoil, snd, chan, maxdamage)
+#define W_SetupShot(ent,antilag,recoil,snd,chan,maxdamage) W_SetupShot_ProjectileSize(ent, '0 0 0', '0 0 0', antilag, recoil, snd, chan, maxdamage)
+#define W_SetupShot_Range(ent,antilag,recoil,snd,chan,maxdamage,range) W_SetupShot_Dir_ProjectileSize_Range(ent, v_forward, '0 0 0', '0 0 0', antilag, recoil, snd, chan, maxdamage, range)
 
 float CL_Weaponentity_CustomizeEntityForClient()
 {
@@ -605,12 +603,14 @@ void CL_Weaponentity_Think()
        else
                self.alpha = 1;
 
+       self.glowmod = self.owner.weaponentity_glowmod;
        self.colormap = self.owner.colormap;
        if (self.weaponentity)
        {
                self.weaponentity.effects = self.effects;
                self.weaponentity.alpha = self.alpha;
                self.weaponentity.colormap = self.colormap;
+               self.weaponentity.glowmod = self.glowmod;
        }
 
        self.angles = '0 0 0';
@@ -618,7 +618,7 @@ void CL_Weaponentity_Think()
        f = 0;
        if (self.state == WS_RAISE && !intermission_running)
        {
-               f = (self.owner.weapon_nextthink - time) * g_weaponratefactor / cvar("g_balance_weaponswitchdelay");
+               f = (self.owner.weapon_nextthink - time) * g_weaponratefactor / autocvar_g_balance_weaponswitchdelay;
                self.angles_x = -90 * f * f;
                if (qcweaponanimation)
                {
@@ -628,7 +628,7 @@ void CL_Weaponentity_Think()
        }
        else if (self.state == WS_DROP && !intermission_running)
        {
-               f = 1 - (self.owner.weapon_nextthink - time) * g_weaponratefactor / cvar("g_balance_weaponswitchdelay");
+               f = 1 - (self.owner.weapon_nextthink - time) * g_weaponratefactor / autocvar_g_balance_weaponswitchdelay;
                self.angles_x = -90 * f * f;
                if (qcweaponanimation)
                {
@@ -849,6 +849,7 @@ void CL_ExteriorWeaponentity_Think()
                self.angles = ang;
        }
 
+       self.glowmod = self.owner.weaponentity_glowmod;
        self.colormap = self.owner.colormap;
 };
 
@@ -954,7 +955,7 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain)
                        sprint(cl, strcat("You do not have the ^2", W_Name(wpn), "\n") );
                        Send_WeaponComplain (cl, wpn, W_Name(wpn), 1);
 
-                       if(cvar("g_showweaponspawns"))
+                       if(autocvar_g_showweaponspawns)
                        {
                                entity e;
                                string s;
@@ -1013,7 +1014,7 @@ void w_ready()
 void weapon_setup(float windex)
 {
        entity e;
-       qcweaponanimation = cvar("sv_qcweaponanimation");
+       qcweaponanimation = autocvar_sv_qcweaponanimation;
        e = get_weaponinfo(windex);
        self.items &~= IT_AMMO;
        self.items = self.items | e.items;
@@ -1277,7 +1278,7 @@ vector W_CalculateProjectileVelocity(vector pvelocity, vector mvelocity, float f
        mdirection = normalize(mvelocity);
        mspeed = vlen(mvelocity);
 
-       nstyle = cvar("g_projectiles_newton_style");
+       nstyle = autocvar_g_projectiles_newton_style;
        if(nstyle == 0 || forceAbsolute)
        {
                // absolute velocity
@@ -1314,7 +1315,7 @@ vector W_CalculateProjectileVelocity(vector pvelocity, vector mvelocity, float f
                        //dprint("impossible shot, adjusting\n");
                }
 
-               outspeed = bound(mspeed * cvar("g_projectiles_newton_style_2_minfactor"), outspeed, mspeed * cvar("g_projectiles_newton_style_2_maxfactor"));
+               outspeed = bound(mspeed * autocvar_g_projectiles_newton_style_2_minfactor, outspeed, mspeed * autocvar_g_projectiles_newton_style_2_maxfactor);
                outvelocity = mdirection * outspeed;
        }
        else if(nstyle == 3)
@@ -1457,7 +1458,7 @@ vector W_CalculateProjectileSpread(vector forward, float spread)
        spread *= g_weaponspreadfactor;
        if(spread <= 0)
                return forward;
-       sstyle = cvar("g_projectiles_spread_style");
+       sstyle = autocvar_g_projectiles_spread_style;
        
        if(sstyle == 0)
        {
@@ -1582,10 +1583,10 @@ void W_SetupProjectileVelocityEx(entity missile, vector dir, vector upDir, float
        dir = normalize(dir);
 
 #if 0
-       if(cvar("g_projectiles_spread_style") != mspercallsstyle)
+       if(autocvar_g_projectiles_spread_style != mspercallsstyle)
        {
                mspercallsum = mspercallcount = 0;
-               mspercallsstyle = cvar("g_projectiles_spread_style");
+               mspercallsstyle = autocvar_g_projectiles_spread_style;
        }
        mspercallsum -= gettime(GETTIME_HIRES);
 #endif