]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cl_weaponsystem.qc
Merge branch 'master' into Mario/buffs
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_weaponsystem.qc
index f651a3bfae838446cdca3e7716e4643e79a9cade..dac383633c105f98e3cb9d74ae843c51e072f309 100644 (file)
@@ -14,6 +14,10 @@ float W_WeaponRateFactor()
        float t;
        t = 1.0 / g_weaponratefactor;
 
+       weapon_rate = t;
+       MUTATOR_CALLHOOK(WeaponRateFactor);
+       t = weapon_rate;
+
        return t;
 }
 
@@ -93,12 +97,12 @@ void W_HitPlotAnalysis(entity player, vector screenforward, vector screenright,
                lag = ANTILAG_LATENCY(player);
                if(lag < 0.001)
                        lag = 0;
-               if not(IS_REAL_CLIENT(player))
+               if (!IS_REAL_CLIENT(player))
                        lag = 0; // only antilag for clients
 
                org = player.origin + player.view_ofs;
                traceline_antilag_force(player, org, org + screenforward * MAX_SHOT_DISTANCE, MOVE_NORMAL, player, lag);
-               if(IS_CLIENT(trace_ent))
+               if(IS_CLIENT(trace_ent) || (trace_ent.flags & FL_MONSTER))
                {
                        antilag_takeback(trace_ent, time - lag);
                        hitplot = W_HitPlotNormalizedUntransform(org, trace_ent, screenforward, screenright, screenup, trace_endpos);
@@ -163,7 +167,7 @@ void W_SetupShot_Dir_ProjectileSize_Range(entity ent, vector s_forward, vector m
        // track max damage
        if(accuracy_canbegooddamage(ent))
                accuracy_add(ent, ent.weapon, maxdamage, 0);
-               
+
        W_HitPlotAnalysis(ent, v_forward, v_right, v_up);
 
        if(ent.weaponentity.movedir_x > 0)
@@ -541,20 +545,20 @@ void CL_Weaponentity_Think()
        }
 
        self.angles = '0 0 0';
-       
+
        float f = (self.owner.weapon_nextthink - time);
        if (self.state == WS_RAISE && !intermission_running)
        {
                entity newwep = get_weaponinfo(self.owner.switchweapon);
                f = f * g_weaponratefactor / max(f, cvar(sprintf("g_balance_%s_switchdelay_raise", newwep.netname)));
-               //print(sprintf("CL_Weaponentity_Think(): cvar: %s, value: %f, nextthink: %f\n", sprintf("g_balance_%s_switchdelay_raise", newwep.netname), cvar(sprintf("g_balance_%s_switchdelay_raise", newwep.netname)), (self.owner.weapon_nextthink - time)));
+               //printf("CL_Weaponentity_Think(): cvar: %s, value: %f, nextthink: %f\n", sprintf("g_balance_%s_switchdelay_raise", newwep.netname), cvar(sprintf("g_balance_%s_switchdelay_raise", newwep.netname)), (self.owner.weapon_nextthink - time));
                self.angles_x = -90 * f * f;
        }
        else if (self.state == WS_DROP && !intermission_running)
        {
                entity oldwep = get_weaponinfo(self.owner.weapon);
                f = 1 - f * g_weaponratefactor / max(f, cvar(sprintf("g_balance_%s_switchdelay_drop", oldwep.netname)));
-               //print(sprintf("CL_Weaponentity_Think(): cvar: %s, value: %f, nextthink: %f\n", sprintf("g_balance_%s_switchdelay_drop", oldwep.netname), cvar(sprintf("g_balance_%s_switchdelay_drop", oldwep.netname)), (self.owner.weapon_nextthink - time)));
+               //printf("CL_Weaponentity_Think(): cvar: %s, value: %f, nextthink: %f\n", sprintf("g_balance_%s_switchdelay_drop", oldwep.netname), cvar(sprintf("g_balance_%s_switchdelay_drop", oldwep.netname)), (self.owner.weapon_nextthink - time));
                self.angles_x = -90 * f * f;
        }
        else if (self.state == WS_CLEAR)
@@ -667,7 +671,7 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain)
                complain = 0;
        if(complain)
                self.hasweapon_complain_spam = time + 0.2;
-               
+
        if(wpn == WEP_HOOK && !g_grappling_hook && autocvar_g_nades && !((cl.weapons | weaponsInMap) & WepSet_FromWeapon(wpn)))
                complain = 0;
 
@@ -733,7 +737,7 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain)
                                {
                                        if(e.classname == "droppedweapon")
                                                continue;
-                                       if not(e.flags & FL_ITEM)
+                                       if (!(e.flags & FL_ITEM))
                                                continue;
                                        WaypointSprite_Spawn(
                                                s,
@@ -816,7 +820,7 @@ void W_SwitchToOtherWeapon(entity pl)
 .float prevwarntime;
 float weapon_prepareattack_checkammo(float secondary)
 {
-       if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
+       if (!(self.items & IT_UNLIMITED_WEAPON_AMMO))
        if (!weapon_action(self.weapon, WR_CHECKAMMO1 + secondary))
        {
                // always keep the Mine Layer if we placed mines, so that we can detonate them
@@ -851,7 +855,7 @@ float weapon_prepareattack_checkammo(float secondary)
                {
                        W_SwitchToOtherWeapon(self);
                }
-               
+
                return FALSE;
        }
        return TRUE;
@@ -1129,7 +1133,7 @@ vector W_CalculateProjectileSpread(vector forward, float spread)
        if(spread <= 0)
                return forward;
        sstyle = autocvar_g_projectiles_spread_style;
-       
+
        if(sstyle == 0)
        {
                // this is the baseline for the spread value!
@@ -1342,7 +1346,7 @@ void W_Reload(float sent_ammo_min, float sent_ammo_amount, float sent_time, stri
        e = get_weaponinfo(self.weapon);
 
        // don't reload weapons that don't have the RELOADABLE flag
-       if not(e.spawnflags & WEP_FLAG_RELOADABLE)
+       if (!(e.spawnflags & WEP_FLAG_RELOADABLE))
        {
                dprint("Warning: Attempted to reload a weapon that does not have the WEP_FLAG_RELOADABLE flag. Fix your code!\n");
                return;
@@ -1358,7 +1362,7 @@ void W_Reload(float sent_ammo_min, float sent_ammo_amount, float sent_time, stri
 
        // no ammo, so nothing to load
        if(!self.(self.current_ammo) && self.reload_ammo_min)
-       if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
+       if (!(self.items & IT_UNLIMITED_WEAPON_AMMO))
        {
                if(IS_REAL_CLIENT(self) && self.reload_complain < time)
                {
@@ -1367,7 +1371,7 @@ void W_Reload(float sent_ammo_min, float sent_ammo_amount, float sent_time, stri
                        self.reload_complain = time + 1;
                }
                // switch away if the amount of ammo is not enough to keep using this weapon
-               if not(weapon_action(self.weapon, WR_CHECKAMMO1) + weapon_action(self.weapon, WR_CHECKAMMO2))
+               if (!(weapon_action(self.weapon, WR_CHECKAMMO1) + weapon_action(self.weapon, WR_CHECKAMMO2)))
                {
                        self.clip_load = -1; // reload later
                        W_SwitchToOtherWeapon(self);