X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fweapons%2Fselection.qc;h=5dd3073e9f0fe57b800b0ba19376e3a159942e81;hb=3cbcea63497633f206816900e4f7e32b833751f0;hp=b4c13851bf47514c57a0212e5d2df0e0a4bcc627;hpb=c2afbf519433fb56c9b8b807ca3ab12c62575ec8;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/weapons/selection.qc b/qcsrc/server/weapons/selection.qc index b4c13851b..5dd3073e9 100644 --- a/qcsrc/server/weapons/selection.qc +++ b/qcsrc/server/weapons/selection.qc @@ -1,16 +1,18 @@ #include "selection.qh" -#include "weaponsystem.qh" -#include -#include #include +#include +#include +#include #include +#include +#include #include -#include #include -#include -#include #include +#include +#include +#include // switch between weapons void Send_WeaponComplain(entity e, float wpn, float type) @@ -70,7 +72,7 @@ bool client_hasweapon(entity this, Weapon wpn, .entity weaponentity, float andam { if (andammo) { - if(this.items & IT_UNLIMITED_WEAPON_AMMO) + if(this.items & IT_UNLIMITED_AMMO) { f = 1; } @@ -151,7 +153,7 @@ float W_GetCycleWeapon(entity this, string weaponorder, float dir, float imp, fl while(rest != "") { weaponwant = stof(car(rest)); rest = cdr(rest); - wep = Weapons_from(weaponwant); + wep = REGISTRY_GET(Weapons, weaponwant); wepset = wep.m_wepset; if(imp >= 0) if(wep.impulse != imp) @@ -207,7 +209,7 @@ float W_GetCycleWeapon(entity this, string weaponorder, float dir, float imp, fl while(rest != "") { weaponwant = stof(car(rest)); rest = cdr(rest); - wep = Weapons_from(weaponwant); + wep = REGISTRY_GET(Weapons, weaponwant); wepset = wep.m_wepset; if(imp >= 0) if(wep.impulse != imp) @@ -266,7 +268,6 @@ void W_SwitchToOtherWeapon(entity this, .entity weaponentity) W_SwitchWeapon_Force(this, ww, weaponentity); } -AUTOCVAR_SAVE(cl_weapon_switch_reload, bool, true, "When trying to switch to the currently held weapon, reload it"); bool W_SwitchWeapon(entity this, Weapon w, .entity weaponentity) { if(this.(weaponentity).m_switchweapon != w) @@ -282,7 +283,7 @@ bool W_SwitchWeapon(entity this, Weapon w, .entity weaponentity) return false; } } - else if(!forbidWeaponUse(this) && autocvar_cl_weapon_switch_reload) + else if(!weaponLocked(this) && CS(this).cvar_cl_weapon_switch_reload) { entity actor = this; w.wr_reload(w, actor, weaponentity); @@ -291,10 +292,9 @@ bool W_SwitchWeapon(entity this, Weapon w, .entity weaponentity) return true; // player already has the weapon out or needs to reload } -AUTOCVAR_SAVE(cl_weapon_switch_fallback_to_impulse, bool, true, "When trying to switch to a weapon that is not available, switch to an alternative from the same impulse"); void W_SwitchWeapon_TryOthers(entity this, Weapon w, .entity weaponentity) { - if(!W_SwitchWeapon(this, w, weaponentity) && autocvar_cl_weapon_switch_fallback_to_impulse) + if(!W_SwitchWeapon(this, w, weaponentity) && CS(this).cvar_cl_weapon_switch_fallback_to_impulse) W_NextWeaponOnImpulse(this, w.impulse, weaponentity); } @@ -303,7 +303,7 @@ void W_CycleWeapon(entity this, string weaponorder, float dir, .entity weaponent float w; w = W_GetCycleWeapon(this, weaponorder, dir, -1, 1, true, weaponentity); if(w > 0) - W_SwitchWeapon(this, Weapons_from(w), weaponentity); + W_SwitchWeapon(this, REGISTRY_GET(Weapons, w), weaponentity); } void W_NextWeaponOnImpulse(entity this, float imp, .entity weaponentity) @@ -311,7 +311,7 @@ void W_NextWeaponOnImpulse(entity this, float imp, .entity weaponentity) float w; w = W_GetCycleWeapon(this, CS(this).cvar_cl_weaponpriority, +1, imp, 1, (CS(this).cvar_cl_weaponimpulsemode == 0), weaponentity); if(w > 0) - W_SwitchWeapon(this, Weapons_from(w), weaponentity); + W_SwitchWeapon(this, REGISTRY_GET(Weapons, w), weaponentity); } // next weapon @@ -339,7 +339,7 @@ void W_PreviousWeapon(entity this, float list, .entity weaponentity) // previously used if exists and has ammo, (second) best otherwise void W_LastWeapon(entity this, .entity weaponentity) { - Weapon wep = Weapons_from(this.(weaponentity).cnt); + Weapon wep = REGISTRY_GET(Weapons, this.(weaponentity).cnt); if (client_hasweapon(this, wep, weaponentity, true, false)) W_SwitchWeapon(this, wep, weaponentity); else