]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/impulse.qc
Merge branch 'terencehill/auto-balanced_bots' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / impulse.qc
index 5010d283711ff0e795ed3f146bb097b56cfbcd10..2320eb830ef50db38913df89c96a724ce801080d 100644 (file)
@@ -1,11 +1,10 @@
 #include "impulse.qh"
 #include "round_handler.qh"
 
-#include "bot/api.qh"
-
 #include "weapons/throwing.qh"
 #include "command/common.qh"
 #include "cheats.qh"
+#include "clientkill.qh"
 #include "weapons/selection.qh"
 #include "weapons/tracing.qh"
 #include "weapons/weaponsystem.qh"
 
 // weapon switching impulses
 
-#define X(slot) \
-       IMPULSE(weapon_group_##slot) \
+#define X(i) \
+       IMPULSE(weapon_group_##i) \
        { \
                if (IS_DEAD(this)) \
                { \
-                       this.impulse = IMP_weapon_group_##slot.impulse; \
+                       this.impulse = IMP_weapon_group_##i.impulse; \
                        return; \
                } \
-               for(int wepslot = 0; wepslot < MAX_WEAPONSLOTS; ++wepslot) \
+               for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) \
                { \
-                       .entity weaponentity = weaponentities[wepslot]; \
-                       W_NextWeaponOnImpulse(this, slot, weaponentity); \
-                       if(wepslot == 0 && autocvar_g_weaponswitch_debug != 1) \
+                       .entity weaponentity = weaponentities[slot]; \
+                       W_NextWeaponOnImpulse(this, i, weaponentity); \
+                       if(autocvar_g_weaponswitch_debug != 1) \
                                break; \
                } \
        }
@@ -82,23 +81,23 @@ X(0)
 
 // custom order weapon cycling
 
-#define X(slot, dir) \
-       IMPULSE(weapon_priority_##slot##_##dir) \
+#define X(i, dir) \
+       IMPULSE(weapon_priority_##i##_##dir) \
        { \
                if (this.vehicle) return; \
                if (IS_DEAD(this)) \
                { \
-                       this.impulse = IMP_weapon_priority_##slot##_##dir.impulse; \
+                       this.impulse = IMP_weapon_priority_##i##_##dir.impulse; \
                        return; \
                } \
                noref int prev = -1; \
                noref int best =  0; \
                noref int next = +1; \
-               for(int wepslot = 0; wepslot < MAX_WEAPONSLOTS; ++wepslot) \
+               for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) \
                { \
-                       .entity weaponentity = weaponentities[wepslot]; \
-                       W_CycleWeapon(this, CS(this).cvar_cl_weaponpriorities[slot], dir, weaponentity); \
-                       if(wepslot == 0 && autocvar_g_weaponswitch_debug != 1) \
+                       .entity weaponentity = weaponentities[slot]; \
+                       W_CycleWeapon(this, CS(this).cvar_cl_weaponpriorities[i], dir, weaponentity); \
+                       if(autocvar_g_weaponswitch_debug != 1) \
                                break; \
                } \
        }
@@ -150,8 +149,8 @@ X(9, next)
                for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) \
                { \
                        .entity weaponentity = weaponentities[slot]; \
-                       W_SwitchWeapon(this, Weapons_from(WEP_FIRST + i), weaponentity); \
-                       if(slot == 0 && autocvar_g_weaponswitch_debug != 1) \
+                       W_SwitchWeapon_TryOthers(this, Weapons_from(WEP_FIRST + i), weaponentity); \
+                       if(autocvar_g_weaponswitch_debug != 1) \
                                break; \
                } \
        }
@@ -194,7 +193,7 @@ IMPULSE(weapon_next_byid)
                .entity weaponentity = weaponentities[slot];
                W_NextWeapon(this, 0, weaponentity);
 
-               if(slot == 0 && autocvar_g_weaponswitch_debug != 1)
+               if(autocvar_g_weaponswitch_debug != 1)
                        break;
        }
 }
@@ -212,7 +211,7 @@ IMPULSE(weapon_prev_byid)
                .entity weaponentity = weaponentities[slot];
                W_PreviousWeapon(this, 0, weaponentity);
 
-               if(slot == 0 && autocvar_g_weaponswitch_debug != 1)
+               if(autocvar_g_weaponswitch_debug != 1)
                        break;
        }
 }
@@ -230,7 +229,7 @@ IMPULSE(weapon_next_bygroup)
                .entity weaponentity = weaponentities[slot];
                W_NextWeapon(this, 1, weaponentity);
 
-               if(slot == 0 && autocvar_g_weaponswitch_debug != 1)
+               if(autocvar_g_weaponswitch_debug != 1)
                        break;
        }
 }
@@ -248,7 +247,7 @@ IMPULSE(weapon_prev_bygroup)
                .entity weaponentity = weaponentities[slot];
                W_PreviousWeapon(this, 1, weaponentity);
 
-               if(slot == 0 && autocvar_g_weaponswitch_debug != 1)
+               if(autocvar_g_weaponswitch_debug != 1)
                        break;
        }
 }
@@ -266,7 +265,7 @@ IMPULSE(weapon_next_bypriority)
                .entity weaponentity = weaponentities[slot];
                W_NextWeapon(this, 2, weaponentity);
 
-               if(slot == 0 && autocvar_g_weaponswitch_debug != 1)
+               if(autocvar_g_weaponswitch_debug != 1)
                        break;
        }
 }
@@ -284,7 +283,7 @@ IMPULSE(weapon_prev_bypriority)
                .entity weaponentity = weaponentities[slot];
                W_PreviousWeapon(this, 2, weaponentity);
 
-               if(slot == 0 && autocvar_g_weaponswitch_debug != 1)
+               if(autocvar_g_weaponswitch_debug != 1)
                        break;
        }
 }
@@ -298,7 +297,7 @@ IMPULSE(weapon_last)
                .entity weaponentity = weaponentities[slot];
                W_LastWeapon(this, weaponentity);
 
-               if(slot == 0 && autocvar_g_weaponswitch_debug != 1)
+               if(autocvar_g_weaponswitch_debug != 1)
                        break;
        }
 }
@@ -312,7 +311,7 @@ IMPULSE(weapon_best)
                .entity weaponentity = weaponentities[slot];
                W_SwitchWeapon(this, w_getbestweapon(this, weaponentity), weaponentity);
 
-               if(slot == 0 && autocvar_g_weaponswitch_debug != 1)
+               if(autocvar_g_weaponswitch_debug != 1)
                        break;
        }
 }
@@ -326,7 +325,7 @@ IMPULSE(weapon_drop)
                .entity weaponentity = weaponentities[slot];
                W_ThrowWeapon(this, weaponentity, W_CalculateProjectileVelocity(this, this.velocity, v_forward * 750, false), '0 0 0', true);
 
-               if(slot == 0 && autocvar_g_weaponswitch_debug != 1)
+               if(autocvar_g_weaponswitch_debug != 1)
                        break;
        }
 }
@@ -335,7 +334,7 @@ IMPULSE(weapon_reload)
 {
        if (this.vehicle) return;
        if (IS_DEAD(this)) return;
-       if (forbidWeaponUse(this)) return;
+       if (weaponLocked(this)) return;
        entity actor = this;
        for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
        {
@@ -344,7 +343,7 @@ IMPULSE(weapon_reload)
                w.wr_reload(w, actor, weaponentity);
 
                // allow reloading all active slots?
-               //if(slot == 0 && autocvar_g_weaponswitch_debug != 1)
+               //if(autocvar_g_weaponswitch_debug != 1)
                        //break;
        }
 }
@@ -571,33 +570,3 @@ IMPULSE(waypoint_clear)
        }
        sprint(this, "all waypoints cleared\n");
 }
-
-IMPULSE(navwaypoint_spawn)
-{
-       if (!autocvar_g_waypointeditor) return;
-       waypoint_spawn_fromeditor(this);
-}
-
-IMPULSE(navwaypoint_remove)
-{
-       if (!autocvar_g_waypointeditor) return;
-       waypoint_remove_fromeditor(this);
-}
-
-IMPULSE(navwaypoint_relink)
-{
-       if (!autocvar_g_waypointeditor) return;
-       waypoint_schedulerelinkall();
-}
-
-IMPULSE(navwaypoint_save)
-{
-       if (!autocvar_g_waypointeditor) return;
-       waypoint_saveall();
-}
-
-IMPULSE(navwaypoint_unreachable)
-{
-       if (!autocvar_g_waypointeditor) return;
-       waypoint_unreachable(this);
-}