]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'martin-t/weapon_switch' into 'master'
authorMario <zacjardine@y7mail.com>
Sun, 21 Oct 2018 16:47:21 +0000 (16:47 +0000)
committerMario <zacjardine@y7mail.com>
Sun, 21 Oct 2018 16:47:21 +0000 (16:47 +0000)
Option to not reload by weapswitch and not fallback to other weaps from the impulse

See merge request xonotic/xonotic-data.pk3dir!616

qcsrc/client/main.qc
qcsrc/server/client.qh
qcsrc/server/defs.qh
qcsrc/server/miscfunctions.qc
qcsrc/server/weapons/selection.qc
xonotic-client.cfg

index 51324e1c5e09aa320895b35d1725ba572d21382d..e32c0e8f57568bf4f63380368cab0570a2754874 100644 (file)
@@ -140,6 +140,9 @@ void CSQC_Init()
 
        registercvar("cl_spawn_near_teammate", "1");
 
+       registercvar("cl_weapon_switch_reload", "1");
+       registercvar("cl_weapon_switch_fallback_to_impulse", "1");
+
        if(autocvar_cl_lockview)
                cvar_set("cl_lockview", "0");
 
index f8a7e2ab5fa4063b29ebe4c96c7f32ddfca42127..6cf13da2a43746c4bdc49481e991a3fe39b18ec8 100644 (file)
@@ -146,6 +146,8 @@ CLASS(Client, Object)
     ATTRIBARRAY(Client, cvar_cl_weaponpriorities, string, 10);
     ATTRIB(Client, cvar_cl_weaponpriority, string, this.cvar_cl_weaponpriority);
     ATTRIB(Client, cvar_cl_cts_noautoswitch, bool, this.cvar_cl_cts_noautoswitch);
+    ATTRIB(Client, cvar_cl_weapon_switch_reload, bool, this.cvar_cl_weapon_switch_reload);
+    ATTRIB(Client, cvar_cl_weapon_switch_fallback_to_impulse, bool, this.cvar_cl_weapon_switch_fallback_to_impulse);
 
     METHOD(Client, m_unwind, bool(Client this));
 
index e667906f1dddb3351a48b6d9c5543fdadcf39f4d..5b5d8a66b78a017e5f077e975592e94b0b65227d 100644 (file)
@@ -169,6 +169,8 @@ float default_weapon_alpha;
 .float cvar_cl_movement_track_canjump;
 .float cvar_cl_newusekeysupported;
 .float cvar_cl_cts_noautoswitch;
+.bool cvar_cl_weapon_switch_reload;
+.bool cvar_cl_weapon_switch_fallback_to_impulse;
 
 .string cvar_g_xonoticversion;
 .string cvar_cl_weaponpriority;
index 47c0cb2fe4615af49105c651d2bc3192c9452b5f..035891e5b19c0205bac6ef228d91ecbb3f974c5d 100644 (file)
@@ -418,6 +418,10 @@ REPLICATE(cvar_g_xonoticversion, string, "g_xonoticversion");
 
 REPLICATE(cvar_cl_cts_noautoswitch, bool, "cl_cts_noautoswitch");
 
+REPLICATE(cvar_cl_weapon_switch_reload, bool, "cl_weapon_switch_reload");
+
+REPLICATE(cvar_cl_weapon_switch_fallback_to_impulse, bool, "cl_weapon_switch_fallback_to_impulse");
+
 /**
  * @param f -1: cleanup, 0: request, 1: receive
  */
index 5912261dbf68cf6bca6a47ce8e86db480c2cd2b9..ea5bd22551cec73cc63b9578665b9be0dd8bf25f 100644 (file)
@@ -281,7 +281,7 @@ bool W_SwitchWeapon(entity this, Weapon w, .entity weaponentity)
                        return false;
                }
        }
-       else if(!forbidWeaponUse(this))
+       else if(!forbidWeaponUse(this) && CS(this).cvar_cl_weapon_switch_reload)
        {
                entity actor = this;
                w.wr_reload(w, actor, weaponentity);
@@ -292,7 +292,7 @@ bool W_SwitchWeapon(entity this, Weapon w, .entity weaponentity)
 
 void W_SwitchWeapon_TryOthers(entity this, Weapon w, .entity weaponentity)
 {
-       if(!W_SwitchWeapon(this, w, weaponentity))
+       if(!W_SwitchWeapon(this, w, weaponentity) && CS(this).cvar_cl_weapon_switch_fallback_to_impulse)
                W_NextWeaponOnImpulse(this, w.impulse, weaponentity);
 }
 
index 3f9baf571bb2f56366bbeb2c511110ec486a1042..280e9b1e3ea7ddb76d135d6c7382d8fccd3651f2 100644 (file)
@@ -60,6 +60,9 @@ seta cl_unpress_zoom_on_death 1 "automatically unpress zoom when you die (and do
 seta cl_unpress_zoom_on_weapon_switch 1 "automatically unpress zoom when you switch a weapon"
 seta cl_unpress_attack_on_weapon_switch 0 "automatically unpress fire and fire1 attack buttons when you switch a weapon"
 
+seta cl_weapon_switch_reload 1 "When trying to switch to the currently held weapon, reload it"
+seta cl_weapon_switch_fallback_to_impulse 1 "When trying to switch to a weapon that is not available, switch to an alternative from the same impulse"
+
 seta cl_spawn_event_particles 1 "pointparticles effect whenever a player spawns"
 seta cl_spawn_event_sound 1 "sound effect whenever a player spawns"
 //seta cl_spawn_point_model 0 "place a model at all spawn points" // still needs a model