From: MrBougo Date: Sun, 18 Sep 2011 12:09:51 +0000 (+0200) Subject: make weaplast and laser secondary use the best other weapon if previous is unusable X-Git-Tag: xonotic-v0.6.0~40^2~111^2~1 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=c28d67f351bd2df30ec7b43e88a1031d482b50b9;p=xonotic%2Fxonotic-data.pk3dir.git make weaplast and laser secondary use the best other weapon if previous is unusable this also makes weaplast use the second best weapon on spawn --- diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index ef05663e5..dde6a26ab 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -1109,7 +1109,7 @@ void PutClientInServer (void) MUTATOR_CALLHOOK(PlayerSpawn); self.switchweapon = w_getbestweapon(self); - self.cnt = self.switchweapon; + self.cnt = -1; // W_LastWeapon will not complain self.weapon = 0; self.switchingweapon = 0; diff --git a/qcsrc/server/cl_impulse.qc b/qcsrc/server/cl_impulse.qc index 939b6d258..9e211e5f5 100644 --- a/qcsrc/server/cl_impulse.qc +++ b/qcsrc/server/cl_impulse.qc @@ -70,7 +70,7 @@ void ImpulseCommands (void) W_NextWeapon (0); break; case 11: - W_SwitchWeapon (self.cnt); // previously used + W_LastWeapon(); break; case 12: W_PreviousWeapon (0); diff --git a/qcsrc/server/cl_weapons.qc b/qcsrc/server/cl_weapons.qc index fe6789618..f0981f5e2 100644 --- a/qcsrc/server/cl_weapons.qc +++ b/qcsrc/server/cl_weapons.qc @@ -137,6 +137,15 @@ void W_PreviousWeapon(float list) W_CycleWeapon(self.cvar_cl_weaponpriority, +1); } +// previously used if exists and has ammo, (second) best otherwise +void W_LastWeapon() +{ + if(client_hasweapon(self, self.cnt, TRUE, FALSE)) + W_SwitchWeapon(self.cnt); + else + W_SwitchToOtherWeapon(self); +} + float w_getbestweapon(entity e) { return W_GetCycleWeapon(e, e.cvar_cl_weaponpriority, 0, -1, FALSE, TRUE); diff --git a/qcsrc/server/w_laser.qc b/qcsrc/server/w_laser.qc index 5e034acb9..fa52a6e0d 100644 --- a/qcsrc/server/w_laser.qc +++ b/qcsrc/server/w_laser.qc @@ -3,6 +3,7 @@ REGISTER_WEAPON(LASER, w_laser, 0, 1, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WE #else #ifdef SVQC void(float imp) W_SwitchWeapon; +void() W_LastWeapon; void W_Laser_Touch (void) { @@ -259,7 +260,7 @@ float w_laser(float req) else { if(self.switchweapon == WEP_LASER) // don't do this if already switching - W_SwitchWeapon (self.cnt); + W_LastWeapon(); } } }