]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/weapons/weaponsystem.qc
Merge remote-tracking branch 'origin/master' into samual/weapons
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / weapons / weaponsystem.qc
index 70588b29d81413edbb8ee9df1d429332773ef9d9..ddf1424439d14e77008ff60580819bd73ecec595 100644 (file)
@@ -18,29 +18,15 @@ float W_WeaponRateFactor()
 }
 
 // VorteX: static frame globals
-float WFRAME_DONTCHANGE = -1;
-float WFRAME_FIRE1 = 0;
-float WFRAME_FIRE2 = 1;
-float WFRAME_IDLE = 2;
-float WFRAME_RELOAD = 3;
+const float WFRAME_DONTCHANGE = -1;
+const float WFRAME_FIRE1 = 0;
+const float WFRAME_FIRE2 = 1;
+const float WFRAME_IDLE = 2;
+const float WFRAME_RELOAD = 3;
 .float wframe;
 
 void(float fr, float t, void() func) weapon_thinkf;
 
-.float prevstrengthsound;
-.float prevstrengthsoundattempt;
-void W_PlayStrengthSound(entity player) // void W_PlayStrengthSound
-{
-       if((player.items & IT_STRENGTH)
-               && ((time > player.prevstrengthsound + autocvar_sv_strengthsound_antispam_time) // prevent insane sound spam
-               || (time > player.prevstrengthsoundattempt + autocvar_sv_strengthsound_antispam_refire_threshold)))
-               {
-                       sound(player, CH_TRIGGER, "weapons/strength_fire.wav", VOL_BASE, ATTN_NORM);
-                       player.prevstrengthsound = time;
-               }
-               player.prevstrengthsoundattempt = time;
-}
-
 float CL_Weaponentity_CustomizeEntityForClient()
 {
        self.viewmodelforclient = self.owner;
@@ -306,10 +292,10 @@ void CL_Weaponentity_Think()
 
        tb = (self.effects & (EF_TELEPORT_BIT | EF_RESTARTANIM_BIT));
        self.effects = self.owner.effects & EFMASK_CHEAP;
-       self.effects &~= EF_LOWPRECISION;
-       self.effects &~= EF_FULLBRIGHT; // can mask team color, so get rid of it
-       self.effects &~= EF_TELEPORT_BIT;
-       self.effects &~= EF_RESTARTANIM_BIT;
+       self.effects &= ~EF_LOWPRECISION;
+       self.effects &= ~EF_FULLBRIGHT; // can mask team color, so get rid of it
+       self.effects &= ~EF_TELEPORT_BIT;
+       self.effects &= ~EF_RESTARTANIM_BIT;
        self.effects |= tb;
 
        if(self.owner.alpha == default_player_alpha)
@@ -330,7 +316,7 @@ void CL_Weaponentity_Think()
        }
 
        self.angles = '0 0 0';
-       
+
        float f = (self.owner.weapon_nextthink - time);
        if (self.state == WS_RAISE && !intermission_running)
        {
@@ -461,7 +447,7 @@ void w_ready()
 .float prevwarntime;
 float weapon_prepareattack_checkammo(float secondary)
 {
-       if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
+       if (!(self.items & IT_UNLIMITED_WEAPON_AMMO))
        if (!WEP_ACTION(self.weapon, WR_CHECKAMMO1 + secondary))
        {
                // always keep the Mine Layer if we placed mines, so that we can detonate them
@@ -472,7 +458,7 @@ float weapon_prepareattack_checkammo(float secondary)
 
                if(self.weapon == self.switchweapon && time - self.prevdryfire > 1) // only play once BEFORE starting to switch weapons
                {
-                       sound (self, CH_WEAPON_A, "weapons/dryfire.wav", VOL_BASE, ATTN_NORM);
+                       sound (self, CH_WEAPON_A, "weapons/dryfire.wav", VOL_BASE, ATTEN_NORM);
                        self.prevdryfire = time;
                }
 
@@ -496,7 +482,7 @@ float weapon_prepareattack_checkammo(float secondary)
                {
                        W_SwitchToOtherWeapon(self);
                }
-               
+
                return FALSE;
        }
        return TRUE;
@@ -675,7 +661,7 @@ void W_WeaponFrame()
                self.switchingweapon = 0;
                self.weaponentity.state = WS_CLEAR;
                self.weaponname = "";
-               self.items &~= IT_AMMO;
+               self.items &= ~IT_AMMO;
                return;
        }
 
@@ -693,7 +679,7 @@ void W_WeaponFrame()
                        self.switchingweapon = self.switchweapon;
                        entity newwep = get_weaponinfo(self.switchweapon);
 
-                       self.items &~= IT_AMMO;
+                       self.items &= ~IT_AMMO;
                        self.items = self.items | (newwep.items & IT_AMMO);
 
                        // the two weapon entities will notice this has changed and update their models
@@ -704,10 +690,10 @@ void W_WeaponFrame()
                        self.weaponentity.state = WS_RAISE;
 
                        // set our clip load to the load of the weapon we switched to, if it's reloadable
-                       if(newwep.spawnflags & WEP_FLAG_RELOADABLE && cvar(strcat("g_balance_", newwep.netname, "_reload_ammo"))) // prevent accessing undefined cvars
+                       if(newwep.spawnflags & WEP_FLAG_RELOADABLE && newwep.reloading_ammo) // prevent accessing undefined cvars
                        {
                                self.clip_load = self.(weapon_load[self.switchweapon]);
-                               self.clip_size = cvar(strcat("g_balance_", newwep.netname, "_reload_ammo"));
+                               self.clip_size = newwep.reloading_ammo;
                        }
                        else
                                self.clip_load = self.clip_size = 0;
@@ -759,7 +745,7 @@ void W_WeaponFrame()
        while (c < W_TICSPERFRAME)
        {
                c = c + 1;
-               if(w && !WEPSET_CONTAINS_EW(self, w))
+               if(w && !(self.weapons & WepSet_FromWeapon(w)))
                {
                        if(self.weapon == self.switchweapon)
                                W_SwitchWeapon_Force(self, w_getbestweapon(self));
@@ -884,22 +870,19 @@ void W_ReloadedAndReady()
        w_ready();
 }
 
-void W_Reload(float sent_ammo_min, float sent_ammo_amount, float sent_time, string sent_sound)
+void W_Reload(float sent_ammo_min, string sent_sound)
 {
        // set global values to work with
+       entity e;
+       e = get_weaponinfo(self.weapon);
 
        self.reload_ammo_min = sent_ammo_min;
-       self.reload_ammo_amount = sent_ammo_amount;
-       self.reload_time = sent_time;
+       self.reload_ammo_amount = e.reloading_ammo;;
+       self.reload_time = e.reloading_time;
        self.reload_sound = sent_sound;
 
-       // check if we meet the necessary conditions to reload
-
-       entity e;
-       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;
@@ -915,7 +898,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)
                {
@@ -924,7 +907,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(WEP_ACTION(self.weapon, WR_CHECKAMMO1) + WEP_ACTION(self.weapon, WR_CHECKAMMO2))
+               if (!(WEP_ACTION(self.weapon, WR_CHECKAMMO1) + WEP_ACTION(self.weapon, WR_CHECKAMMO2)))
                {
                        self.clip_load = -1; // reload later
                        W_SwitchToOtherWeapon(self);
@@ -943,7 +926,7 @@ void W_Reload(float sent_ammo_min, float sent_ammo_amount, float sent_time, stri
 
        // now begin the reloading process
 
-       sound (self, CH_WEAPON_SINGLE, self.reload_sound, VOL_BASE, ATTN_NORM);
+       sound(self, CH_WEAPON_SINGLE, self.reload_sound, VOL_BASE, ATTEN_NORM);
 
        // do not set ATTACK_FINISHED in reload code any more. This causes annoying delays if eg: You start reloading a weapon,
        // then quickly switch to another weapon and back. Reloading is canceled, but the reload delay is still there,