From: Mircea Kitsune Date: Tue, 12 Apr 2011 23:17:13 +0000 (+0300) Subject: Actually, create a weapon independent function that forbids the player to change... X-Git-Tag: xonotic-v0.5.0~263^2~10^2~13 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=f884797b17fa38d33fb8efc0615aff6481e455c1;p=xonotic%2Fxonotic-data.pk3dir.git Actually, create a weapon independent function that forbids the player to change their weapon (drop or switch to another) while active. Can once again be used for other weapons and reasons. --- diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index 93dfc1c5f..a59ef51e6 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -1064,6 +1064,7 @@ void PutClientInServer (void) if(e.spawnflags & WEP_FLAG_RELOADABLE) // prevent accessing undefined cvars self.weapon_load[j] = cvar(strcat("g_balance_", e.netname, "_reload_ammo")); } + self.weapon_forbidchange = FALSE; oldself = self; self = spot; diff --git a/qcsrc/server/cl_weapons.qc b/qcsrc/server/cl_weapons.qc index 6deb23c42..4df6655b7 100644 --- a/qcsrc/server/cl_weapons.qc +++ b/qcsrc/server/cl_weapons.qc @@ -284,6 +284,8 @@ void W_ThrowWeapon(vector velo, vector delta, float doreduce) w = self.weapon; if (w == 0) return; // just in case + if(self.weapon_forbidchange) + return; if(MUTATOR_CALLHOOK(ForbidThrowCurrentWeapon)) return; if(!autocvar_g_weapon_throwable) @@ -295,10 +297,6 @@ void W_ThrowWeapon(vector velo, vector delta, float doreduce) if(!W_IsWeaponThrowable(w)) return; - // don't allow throwing the hager if we're loading rockets into it - if(self.weapon == WEP_HAGAR && self.hagar_load) - return; - wb = W_WeaponBit(w); if(self.weapons & wb != wb) return; diff --git a/qcsrc/server/cl_weaponsystem.qc b/qcsrc/server/cl_weaponsystem.qc index 0c9409bc7..ee4b70352 100644 --- a/qcsrc/server/cl_weaponsystem.qc +++ b/qcsrc/server/cl_weaponsystem.qc @@ -34,9 +34,8 @@ float W_WeaponRateFactor() void W_SwitchWeapon_Force(entity e, float w) { - // don't allow switching to another weapon if we're loading rockets into the hagar - if(e.weapon == WEP_HAGAR && e.hagar_load) - if(e.weapons & WEPBIT_HAGAR) // only if we still have the hagar, prevents a bug with dropping + // don't switch to another weapon if we're not allowed to + if(e.weapon_forbidchange) return; e.cnt = e.switchweapon; diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index 34d773504..79579f0e1 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -209,6 +209,7 @@ void w_ready(); // VorteX: standalone think for weapons, so normal think on weaponentity can be reserved by weaponflashes (which needs update even player dies) .float weapon_nextthink; .void() weapon_think; +.float weapon_forbidchange; //float PLAYER_WEAPONSELECTION_DELAY = ); float PLAYER_WEAPONSELECTION_SPEED = 18; diff --git a/qcsrc/server/w_hagar.qc b/qcsrc/server/w_hagar.qc index 3ab783636..43216cd4c 100644 --- a/qcsrc/server/w_hagar.qc +++ b/qcsrc/server/w_hagar.qc @@ -231,8 +231,14 @@ void W_Hagar_Attack2_Load (void) } if(self.hagar_load) - if(!self.BUTTON_ATCK2 || ((loaded || !weapon_action(self.weapon, WR_CHECKAMMO2)) && self.hagar_loadstep < time && !autocvar_g_balance_hagar_secondary_load_hold)) - W_Hagar_Attack2_Load_Release(); + { + self.weapon_forbidchange = TRUE; + + if(!self.BUTTON_ATCK2 || ((loaded || !weapon_action(self.weapon, WR_CHECKAMMO2)) && self.hagar_loadstep < time && !autocvar_g_balance_hagar_secondary_load_hold)) + W_Hagar_Attack2_Load_Release(); + } + else + self.weapon_forbidchange = FALSE; // we aren't checking ammo during an attack, so we must do it here if not(weapon_action(self.weapon, WR_CHECKAMMO2))