X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fweapons%2Fweaponsystem.qc;h=7c8ce3511f3d28a7dab2bb8df555834e03ca58f7;hb=02b39f4dc42e4a0449e1191ed9d104ec280b91a6;hp=593919ec0548fa6842581a52fd3fc4513590c414;hpb=fbb52b893f7be6bf4073f1853761c4f2fc11a343;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/weapons/weaponsystem.qc b/qcsrc/server/weapons/weaponsystem.qc index 593919ec0..7c8ce3511 100644 --- a/qcsrc/server/weapons/weaponsystem.qc +++ b/qcsrc/server/weapons/weaponsystem.qc @@ -322,14 +322,12 @@ void CL_Weaponentity_Think() { entity newwep = get_weaponinfo(self.owner.switchweapon); f = f * g_weaponratefactor / max(f, newwep.switchdelay_raise); - //print(sprintf("CL_Weaponentity_Think(): cvar: %s, value: %f, nextthink: %f\n", sprintf("g_balance_%s_switchdelay_raise", newwep.netname), cvar(sprintf("g_balance_%s_switchdelay_raise", newwep.netname)), (self.owner.weapon_nextthink - time))); self.angles_x = -90 * f * f; } else if (self.state == WS_DROP && !intermission_running) { entity oldwep = get_weaponinfo(self.owner.weapon); f = 1 - f * g_weaponratefactor / max(f, oldwep.switchdelay_drop); - //print(sprintf("CL_Weaponentity_Think(): cvar: %s, value: %f, nextthink: %f\n", sprintf("g_balance_%s_switchdelay_drop", oldwep.netname), cvar(sprintf("g_balance_%s_switchdelay_drop", oldwep.netname)), (self.owner.weapon_nextthink - time))); self.angles_x = -90 * f * f; } else if (self.state == WS_CLEAR) @@ -679,14 +677,11 @@ void W_WeaponFrame() self.switchingweapon = self.switchweapon; entity newwep = get_weaponinfo(self.switchweapon); - //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 self.weapon = self.switchweapon; self.weaponname = newwep.mdl; - self.bulletcounter = 0; // WEAPONTODO - //self.current_ammo = newwep.current_ammo; + self.bulletcounter = 0; + //self.ammo_field = newwep.ammo_field; WEP_ACTION(self.switchweapon, WR_SETUP); self.weaponentity.state = WS_RAISE; @@ -699,10 +694,7 @@ void W_WeaponFrame() else self.clip_load = self.clip_size = 0; - // VorteX: add player model weapon select frame here - // setcustomframe(PlayerWeaponRaise); weapon_thinkf(WFRAME_IDLE, newwep.switchdelay_raise, w_ready); - //print(sprintf("W_WeaponFrame(): cvar: %s, value: %f\n", sprintf("g_balance_%s_switchdelay_raise", newwep.netname), cvar(sprintf("g_balance_%s_switchdelay_raise", newwep.netname)))); } else if (self.weaponentity.state == WS_DROP) { @@ -713,21 +705,19 @@ void W_WeaponFrame() { // start switching! self.switchingweapon = self.switchweapon; - entity oldwep = get_weaponinfo(self.weapon); - -#ifndef INDEPENDENT_ATTACK_FINISHED + + // set up weapon switch think in the future, and start drop anim + #ifndef INDEPENDENT_ATTACK_FINISHED if(ATTACK_FINISHED(self) <= time + self.weapon_frametime * 0.5) { -#endif - sound (self, CH_WEAPON_SINGLE, "weapons/weapon_switch.wav", VOL_BASE, ATTN_NORM); - self.weaponentity.state = WS_DROP; - // set up weapon switch think in the future, and start drop anim - weapon_thinkf(WFRAME_DONTCHANGE, oldwep.switchdelay_drop, w_clear); - //print(sprintf("W_WeaponFrame(): cvar: %s, value: %f\n", sprintf("g_balance_%s_switchdelay_drop", oldwep.netname), cvar(sprintf("g_balance_%s_switchdelay_drop", oldwep.netname)))); -#ifndef INDEPENDENT_ATTACK_FINISHED + #endif + sound(self, CH_WEAPON_SINGLE, "weapons/weapon_switch.wav", VOL_BASE, ATTN_NORM); + self.weaponentity.state = WS_DROP; + weapon_thinkf(WFRAME_DONTCHANGE, oldwep.switchdelay_drop, w_clear); + #ifndef INDEPENDENT_ATTACK_FINISHED } -#endif + #endif } } @@ -822,8 +812,22 @@ void W_DecreaseAmmo(float ammo_use) self.clip_load -= ammo_use; self.(weapon_load[self.weapon]) = self.clip_load; } - else - self.(wep.current_ammo) -= ammo_use; + else if(wep.ammo_field != ammo_none) + { + self.(wep.ammo_field) -= ammo_use; + if(self.(wep.ammo_field) < 0) + { + backtrace(sprintf( + "W_DecreaseAmmo(%.2f): '%s' subtracted too much %s from '%s', resulting with '%.2f' left... " + "Please notify Samual immediately with a copy of this backtrace!\n", + ammo_use, + wep.netname, + GetAmmoPicture(wep.ammo_field), + self.netname, + self.(wep.ammo_field) + )); + } + } } // weapon reloading code @@ -839,14 +843,14 @@ void W_ReloadedAndReady() self.clip_load = self.old_clip_load; // restore the ammo counter, in case we still had ammo in the weapon before reloading // if the gun uses no ammo, max out weapon load, else decrease ammo as we increase weapon load - if(!self.reload_ammo_min || self.items & IT_UNLIMITED_WEAPON_AMMO) + if(!self.reload_ammo_min || self.items & IT_UNLIMITED_WEAPON_AMMO || self.ammo_field == ammo_none) self.clip_load = self.reload_ammo_amount; else { - while(self.clip_load < self.reload_ammo_amount && self.(self.current_ammo)) // make sure we don't add more ammo than we have + while(self.clip_load < self.reload_ammo_amount && self.(self.ammo_field)) // make sure we don't add more ammo than we have { self.clip_load += 1; - self.(self.current_ammo) -= 1; + self.(self.ammo_field) -= 1; } } self.(weapon_load[self.weapon]) = self.clip_load; @@ -887,13 +891,14 @@ void W_Reload(float sent_ammo_min, string sent_sound) return; // no ammo, so nothing to load - if(!self.(self.current_ammo) && self.reload_ammo_min) + if(self.ammo_field != ammo_none) + if(!self.(self.ammo_field) && self.reload_ammo_min) if (!(self.items & IT_UNLIMITED_WEAPON_AMMO)) { if(IS_REAL_CLIENT(self) && self.reload_complain < time) { play2(self, "weapons/unavailable.wav"); - sprint(self, strcat("You don't have enough ammo to reload the ^2", W_Name(self.weapon), "\n")); + sprint(self, strcat("You don't have enough ammo to reload the ^2", WEP_NAME(self.weapon), "\n")); self.reload_complain = time + 1; } // switch away if the amount of ammo is not enough to keep using this weapon