From 0e3242edfff584cbf0a38a0826f3fb13982b7f37 Mon Sep 17 00:00:00 2001 From: Mircea Kitsune Date: Fri, 21 Jan 2011 02:08:29 +0200 Subject: [PATCH] Improve functionality --- qcsrc/server/cl_weaponsystem.qc | 33 ++------------------------------- qcsrc/server/w_shotgun.qc | 12 ++++++------ qcsrc/server/w_sniperrifle.qc | 14 +++++++------- 3 files changed, 15 insertions(+), 44 deletions(-) diff --git a/qcsrc/server/cl_weaponsystem.qc b/qcsrc/server/cl_weaponsystem.qc index 8c510bba7..6576ab2a0 100644 --- a/qcsrc/server/cl_weaponsystem.qc +++ b/qcsrc/server/cl_weaponsystem.qc @@ -1617,35 +1617,6 @@ void W_SetupProjectileVelocity(entity missile, float pSpeed, float spread) // ---------------------------------------------------------------- float ammo_amount; -void W_SniperRifle_Ammo(string ammo_string, float ammo_reduce) -{ - // sets ammo_amount to our current ammo level, and can optionally reduce ammo - switch(ammo_string) - { - case "shells": - ammo_amount = self.ammo_shells; - self.ammo_shells -= ammo_reduce; - return; - case "nails": - ammo_amount = self.ammo_nails; - self.ammo_nails -= ammo_reduce; - return; - case "cells": - ammo_amount = self.ammo_cells; - self.ammo_cells -= ammo_reduce; - return; - case "rockets": - ammo_amount = self.ammo_rockets; - self.ammo_rockets -= ammo_reduce; - return; - case "fuel": - ammo_amount = self.ammo_fuel; - self.ammo_fuel -= ammo_reduce; - return; - default: - return; - } -} float W_SniperRifle_CheckMaxBullets(float checkammo) { @@ -1671,13 +1642,13 @@ void W_SniperRifle_ReloadedAndReady() w_ready(); } -float W_SniperRifle_Reload(string ammo_type) +float W_SniperRifle_Reload(float ammo_value) { float t; W_SniperRifle_CheckMaxBullets(TRUE); - W_SniperRifle_Ammo(ammo_type, 0); // set ammo_amount to the ammo type specified + ammo_amount = ammo_value; // save ammo to a global float if(ammo_amount < min(autocvar_g_balance_sniperrifle_primary_ammo, autocvar_g_balance_sniperrifle_secondary_ammo)) // when we get here, bulletcounter must be 0 or -1 { print("cannot reload... not enough bullets\n"); diff --git a/qcsrc/server/w_shotgun.qc b/qcsrc/server/w_shotgun.qc index 470acac34..e5519551e 100644 --- a/qcsrc/server/w_shotgun.qc +++ b/qcsrc/server/w_shotgun.qc @@ -3,12 +3,11 @@ REGISTER_WEAPON(SHOTGUN, w_shotgun, IT_SHELLS, 2, WEP_FLAG_NORMAL | WEP_TYPE_HIT #else #ifdef SVQC -void W_Shotgun_CheckReloadAndReady() +void W_Shotgun_DoReload() { w_ready(); - if(self.sniperrifle_bulletcounter <= 0) - if(W_SniperRifle_Reload("shells")) - return; + if(W_SniperRifle_Reload(self.ammo_shells)) + return; } void W_Shotgun_Attack (void) @@ -23,7 +22,8 @@ void W_Shotgun_Attack (void) float bulletconstant; local entity flash; - W_Shotgun_CheckReloadAndReady(); + if(self.sniperrifle_bulletcounter <= 0) + W_Shotgun_DoReload(); if(self.sniperrifle_bulletcounter < 0) return; // reloading, so we are done @@ -153,7 +153,7 @@ float w_shotgun(float req) if(self.weaponentity.state == WS_READY) { self.wish_reload = 0; - W_SniperRifle_Reload("shells"); + W_SniperRifle_Reload(self.ammo_shells); } } } diff --git a/qcsrc/server/w_sniperrifle.qc b/qcsrc/server/w_sniperrifle.qc index 655c1204a..94f61e968 100644 --- a/qcsrc/server/w_sniperrifle.qc +++ b/qcsrc/server/w_sniperrifle.qc @@ -8,12 +8,11 @@ REGISTER_WEAPON(SNIPERRIFLE, w_sniperrifle, IT_NAILS, 7, WEP_FLAG_NORMAL | WEP_T .float sniperrifle_accumulator; -void W_SniperRifle_CheckReloadAndReady() +void W_SniperRifle_DoReload() { w_ready(); - if(self.sniperrifle_bulletcounter <= 0) - if(W_SniperRifle_Reload("nails")) - return; + if(W_SniperRifle_Reload(self.ammo_nails)) + return; } void W_SniperRifle_FireBullet(float pSpread, float pDamage, float pHeadshotAddedDamage, float pForce, float pSpeed, float pLifetime, float pAmmo, float deathtype, float pBulletConstant) @@ -74,7 +73,8 @@ void spawnfunc_weapon_campingrifle (void) void W_SniperRifle_BulletHail_Continue() { float r, sw, af; - W_SniperRifle_CheckReloadAndReady(); + if(self.sniperrifle_bulletcounter <= 0) + W_SniperRifle_DoReload(); if(self.sniperrifle_bulletcounter < 0) return; // reloading, so we are done sw = self.switchweapon; // make it not detect weapon changes as reason to abort firing @@ -114,7 +114,7 @@ void W_SniperRifle_BulletHail(float mode, void(void) AttackFunc, float fr, float else { // just one shot - weapon_thinkf(fr, animtime, W_SniperRifle_CheckReloadAndReady); + weapon_thinkf(fr, animtime, w_ready); } } @@ -188,7 +188,7 @@ float w_sniperrifle(float req) if(self.weaponentity.state == WS_READY) { self.wish_reload = 0; - W_SniperRifle_Reload("nails"); + W_SniperRifle_Reload(self.ammo_nails); } } } -- 2.39.2