]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cl_weaponsystem.qc
Merge remote-tracking branch 'origin/master' into fruitiex/animations
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_weaponsystem.qc
index 4233e7d92d755b7651a60362f27080c192e888c7..21a9bc9428a71d6ec6d9bab9acc51a3db464a105 100644 (file)
@@ -34,10 +34,6 @@ float W_WeaponRateFactor()
 
 void W_SwitchWeapon_Force(entity e, float w)
 {
-       // don't switch to another weapon if we're not allowed to
-       if(e.weapon_forbidchange)
-               return;
-
        e.cnt = e.switchweapon;
        e.switchweapon = w;
        e.selectweapon = w;
@@ -142,7 +138,7 @@ void W_SetupShot_Dir_ProjectileSize_Range(entity ent, vector s_forward, vector m
        local float oldsolid;
        vector vecs, dv;
        oldsolid = ent.dphitcontentsmask;
-       if(ent.weapon == WEP_SNIPERRIFLE)
+       if(ent.weapon == WEP_RIFLE)
                ent.dphitcontentsmask = DPCONTENTS_BODY | DPCONTENTS_CORPSE;
        else
                ent.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_CORPSE;
@@ -255,7 +251,7 @@ void W_SetupShot_Dir_ProjectileSize_Range(entity ent, vector s_forward, vector m
                (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);
+               sound(ent, CH_TRIGGER, "weapons/strength_fire.wav", VOL_BASE, ATTN_NORM);
                ent.prevstrengthsound = time;
        }
        ent.prevstrengthsoundattempt = time;
@@ -297,7 +293,6 @@ vector weapon_adjust = '10 0 -15';
 .vector weapon_morph4origin;
 .vector weapon_morph4angles;
 .float  weapon_morph4time;
-.string weaponname;
 #define QCWEAPONANIMATION_ORIGIN(e) ((weapon_offset_x + e.view_ofs_x) * v_forward - (weapon_offset_y + e.view_ofs_y) * v_right + (weapon_offset_z + e.view_ofs_z) * v_up + weapon_adjust)
 
 /*
@@ -587,9 +582,9 @@ void CL_Weaponentity_Think()
                        self.weaponentity.model = "";
                return;
        }
-       if (self.cnt != self.owner.weapon || self.dmg != self.owner.modelindex || self.deadflag != self.owner.deadflag)
+       if (self.weaponname != self.owner.weaponname || self.dmg != self.owner.modelindex || self.deadflag != self.owner.deadflag)
        {
-               self.cnt = self.owner.weapon;
+               self.weaponname = self.owner.weaponname;
                self.dmg = self.owner.modelindex;
                self.deadflag = self.owner.deadflag;
 
@@ -793,9 +788,9 @@ void CL_ExteriorWeaponentity_Think()
                self.model = "";
                return;
        }
-       if (self.cnt != self.owner.weapon || self.dmg != self.owner.modelindex || self.deadflag != self.owner.deadflag)
+       if (self.weaponname != self.owner.weaponname || self.dmg != self.owner.modelindex || self.deadflag != self.owner.deadflag)
        {
-               self.cnt = self.owner.weapon;
+               self.weaponname = self.owner.weaponname;
                self.dmg = self.owner.modelindex;
                self.deadflag = self.owner.deadflag;
                if (self.owner.weaponname != "")
@@ -828,33 +823,36 @@ void CL_ExteriorWeaponentity_Think()
        else
                self.alpha = 1;
 
-       ang_x = bound(sv_pitch_min, self.owner.v_angle_x, sv_pitch_max);
-       ang_y = 0;
-       ang_z = 0;
-
-       if(sv_pitch_fixyaw) // workaround for stupid player models that don't aim forward
-       {
-               ang_y = self.owner.v_angle_y;
-               makevectors(ang);
-               var vector v = v_forward;
-               var float t = self.tag_entity.frame1time;
-               var float f = self.tag_entity.frame;
-               self.tag_entity.frame1time = time;
-               self.tag_entity.frame = self.tag_entity.anim_idle_x;
-               gettaginfo(self.tag_entity, self.tag_index);
-               self.tag_entity.frame1time = t;
-               self.tag_entity.frame = f;
-               // untransform v according to this coordinate space
-               vector w;
-               w_x = v_forward * v;
-               w_y = -v_right * v;
-               w_z = v_up * v;
-               self.angles = vectoangles(w);
-       }
-       else
+       if (!intermission_running)
        {
-               ang_x = -/* don't ask */ang_x;
-               self.angles = ang;
+               ang_x = bound(sv_pitch_min, self.owner.v_angle_x, sv_pitch_max);
+               ang_y = 0;
+               ang_z = 0;
+
+               if(sv_pitch_fixyaw) // workaround for stupid player models that don't aim forward
+               {
+                       ang_y = self.owner.v_angle_y;
+                       makevectors(ang);
+                       var vector v = v_forward;
+                       var float t = self.tag_entity.frame1time;
+                       var float f = self.tag_entity.frame;
+                       self.tag_entity.frame1time = time;
+                       self.tag_entity.frame = self.tag_entity.anim_idle_x;
+                       gettaginfo(self.tag_entity, self.tag_index);
+                       self.tag_entity.frame1time = t;
+                       self.tag_entity.frame = f;
+                       // untransform v according to this coordinate space
+                       vector w;
+                       w_x = v_forward * v;
+                       w_y = -v_right * v;
+                       w_z = v_up * v;
+                       self.angles = vectoangles(w);
+               }
+               else
+               {
+                       ang_x = -/* don't ask */ang_x;
+                       self.angles = ang;
+               }
        }
 
        self.glowmod = self.owner.weaponentity_glowmod;
@@ -983,7 +981,8 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain)
                                                world, e.origin,
                                                self, 0,
                                                world, enemy,
-                                               0
+                                               0,
+                                               RADARICON_NONE, '0 0 0'
                                        );
                                }
                        }
@@ -1003,7 +1002,10 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain)
 void w_clear()
 {
        if (self.weapon != -1)
+       {
                self.weapon = 0;
+               self.switchingweapon = 0;
+       }
        if (self.weaponentity)
        {
                self.weaponentity.state = WS_CLEAR;
@@ -1029,6 +1031,7 @@ void weapon_setup(float windex)
 
        // the two weapon entities will notice this has changed and update their models
        self.weapon = windex;
+       self.switchingweapon = windex; // to make sure
        self.weaponname = e.mdl;
        self.bulletcounter = 0;
 };
@@ -1059,7 +1062,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, CHAN_AUTO, "weapons/dryfire.wav", VOL_BASE, ATTN_NORM);
+                       sound (self, CH_WEAPON_A, "weapons/dryfire.wav", VOL_BASE, ATTN_NORM);
                        self.prevdryfire = time;
                }
 
@@ -1257,21 +1260,26 @@ void weapon_thinkf(float fr, float t, void() func)
        self.weapon_think = func;
        //dprint("next ", ftos(self.weapon_nextthink), "\n");
 
-    // The shoot animation looks TERRIBLE without animation blending! Yay for moonwalking while shooting!
-    /*
+       // The shoot animation looks TERRIBLE without animation blending! Yay for moonwalking while shooting!
+       //anim = self.anim_shoot;
        if (restartanim)
        if (t)
        if (!self.crouch) // shoot anim stands up, this looks bad
        {
-               local vector anim;
+               vector anim;
                if(self.weapon == WEP_SHOTGUN && self.BUTTON_ATCK2)
+               {
                        anim = self.anim_melee;
-               else
+                       anim_z = anim_y / (t + sys_frametime);
+                       setanim(self, anim, FALSE, TRUE, TRUE);
+               }
+               else if (self.animstate_startframe == self.anim_idle_x) // only allow shoot anim to override idle animation until we have animation blending
+               {
                        anim = self.anim_shoot;
-               anim_z = anim_y / (t + sys_frametime);
-               setanim(self, anim, FALSE, TRUE, TRUE);
+                       anim_z = anim_y / (t + sys_frametime);
+                       setanim(self, anim, FALSE, TRUE, TRUE);
+               }
        }
-    */
 };
 
 void weapon_boblayer1(float spd, vector org)
@@ -1730,7 +1738,7 @@ void W_Reload(float sent_ammo_min, float sent_ammo_amount, float sent_time, stri
 
        // now begin the reloading process
 
-       sound (self, CHAN_WEAPON2, self.reload_sound, VOL_BASE, ATTN_NORM);
+       sound (self, CH_WEAPON_B, self.reload_sound, VOL_BASE, ATTN_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,