]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cl_impulse.qc
Revert "Merge branch 'TimePath/bot_api' into 'master'\r"
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_impulse.qc
index a02cf40acab473d57b6854da0d29f7e72f0bf1dd..a594c83c7c93b72876eb6fc3a24f6a47342945e3 100644 (file)
 #include "weapons/selection.qh"
 #include "weapons/tracing.qh"
 #include "weapons/weaponsystem.qh"
-#include "vehicles/vehicle.qh"
-#include "waypointsprites.qh"
 
-#include "../common/weapons/weapons.qh"
+#include "../common/minigames/sv_minigames.qh"
+
+#include "../common/weapons/all.qh"
 
 /*
  * Impulse map:
@@ -51,7 +51,7 @@
  */
 
 void ImpulseCommands (void)
-{
+{SELFPARAM();
        int imp;
        vector org;
        float i;
@@ -63,6 +63,10 @@ void ImpulseCommands (void)
                return;
        self.impulse = 0;
 
+       if ( self.active_minigame )
+       if ( MinigameImpulse(imp) )
+               return;
+
        // allow only weapon change impulses when not in round time
        if(round_handler_IsActive() && !round_handler_IsRoundStarted())
        if(imp == 17 || (imp >= 20 && imp < 200) || imp > 253)
@@ -71,11 +75,15 @@ void ImpulseCommands (void)
        if (timeout_status == TIMEOUT_ACTIVE) //don't allow any impulses while the game is paused
                return;
 
-    if(self.vehicle)
-        if(self.vehicle.deadflag == DEAD_NO)
-            if(self.vehicle.vehicles_impulse)
-                if(self.vehicle.vehicles_impulse(imp))
-                    return;
+       if(self.vehicle)
+       if(self.vehicle.deadflag == DEAD_NO)
+       {
+               if(self.vehicle.vehicles_impulse)
+               if(self.vehicle.vehicles_impulse(imp))
+                       return;
+               if(vehicle_impulse(imp))
+                       return;
+       }
 
        if(CheatImpulse(imp))
        {
@@ -90,6 +98,7 @@ void ImpulseCommands (void)
        }
        else if(imp >= 10 && imp <= 20)
        {
+               if(!self.vehicle)
                if(self.deadflag == DEAD_NO)
                {
                        switch(imp)
@@ -125,7 +134,10 @@ void ImpulseCommands (void)
                                        W_PreviousWeapon(1);
                                        break;
                                case 20:
-                                       if(!forbidWeaponUse()) { WEP_ACTION(self.weapon, WR_RELOAD); }
+                                       if(!forbidWeaponUse(self)) {
+                                               Weapon w = get_weaponinfo(self.weapon);
+                                               w.wr_reload(w);
+                                       }
                                        break;
                        }
                }
@@ -138,6 +150,7 @@ void ImpulseCommands (void)
        }
        else if(imp >= 200 && imp <= 229)
        {
+               if(!self.vehicle)
                if(self.deadflag == DEAD_NO)
                {
                        // custom order weapon cycling
@@ -148,10 +161,11 @@ void ImpulseCommands (void)
                else
                        self.impulse = imp; // retry in next frame
        }
-       else if(imp >= 230 && imp <= 253)
+       else if(imp >= WEP_IMPULSE_BEGIN && imp <= WEP_IMPULSE_END)
        {
+               if(!self.vehicle)
                if(self.deadflag == DEAD_NO)
-                       W_SwitchWeapon (imp - 230 + WEP_FIRST);
+                       W_SwitchWeapon (imp - WEP_IMPULSE_BEGIN + WEP_FIRST);
                else
                        self.impulse = imp; // retry in next frame
        }
@@ -162,14 +176,14 @@ void ImpulseCommands (void)
                switch(imp)
                {
                        case 30:
-                               wp = WaypointSprite_DeployPersonal("waypoint", self.origin, RADARICON_WAYPOINT, '0 1 1');
+                               wp = WaypointSprite_DeployPersonal(WP_Waypoint, self.origin, RADARICON_WAYPOINT);
                                if(wp)
                                        WaypointSprite_Ping(wp);
                                sprint(self, "personal waypoint spawned at location\n");
                                break;
                        case 31:
                                WarpZone_crosshair_trace(self);
-                               wp = WaypointSprite_DeployPersonal("waypoint", trace_endpos, RADARICON_WAYPOINT, '0 1 1');
+                               wp = WaypointSprite_DeployPersonal(WP_Waypoint, trace_endpos, RADARICON_WAYPOINT);
                                if(wp)
                                        WaypointSprite_Ping(wp);
                                sprint(self, "personal waypoint spawned at crosshair\n");
@@ -177,7 +191,7 @@ void ImpulseCommands (void)
                        case 32:
                                if(vlen(self.death_origin))
                                {
-                                       wp = WaypointSprite_DeployPersonal("waypoint", self.death_origin, RADARICON_WAYPOINT, '0 1 1');
+                                       wp = WaypointSprite_DeployPersonal(WP_Waypoint, self.death_origin, RADARICON_WAYPOINT);
                                        if(wp)
                                                WaypointSprite_Ping(wp);
                                        sprint(self, "personal waypoint spawned at death location\n");
@@ -186,9 +200,9 @@ void ImpulseCommands (void)
                        case 33:
                                if(self.deadflag == DEAD_NO && teamplay)
                                {
-                                       if (!MUTATOR_CALLHOOK(HelpMePing))
+                                       if (!MUTATOR_CALLHOOK(HelpMePing, self))
                                        {
-                                               wp = WaypointSprite_Attach("helpme", true, RADARICON_HELPME, '1 0.5 0');
+                                               wp = WaypointSprite_Attach(WP_Helpme, true, RADARICON_HELPME);
                                                if(!wp)
                                                        WaypointSprite_HelpMePing(self.waypointsprite_attachedforcarrier);
                                                else
@@ -198,14 +212,14 @@ void ImpulseCommands (void)
                                }
                                break;
                        case 34:
-                               wp = WaypointSprite_DeployFixed("here", false, self.origin, RADARICON_HERE, '0 1 0');
+                               wp = WaypointSprite_DeployFixed(WP_Here, false, self.origin, RADARICON_HERE);
                                if(wp)
                                        WaypointSprite_Ping(wp);
                                sprint(self, "HERE spawned at location\n");
                                break;
                        case 35:
                                WarpZone_crosshair_trace(self);
-                               wp = WaypointSprite_DeployFixed("here", false, trace_endpos, RADARICON_HERE, '0 1 0');
+                               wp = WaypointSprite_DeployFixed(WP_Here, false, trace_endpos, RADARICON_HERE);
                                if(wp)
                                        WaypointSprite_Ping(wp);
                                sprint(self, "HERE spawned at crosshair\n");
@@ -213,21 +227,21 @@ void ImpulseCommands (void)
                        case 36:
                                if(vlen(self.death_origin))
                                {
-                                       wp = WaypointSprite_DeployFixed("here", false, self.death_origin, RADARICON_HERE, '0 1 0');
+                                       wp = WaypointSprite_DeployFixed(WP_Here, false, self.death_origin, RADARICON_HERE);
                                        if(wp)
                                                WaypointSprite_Ping(wp);
                                        sprint(self, "HERE spawned at death location\n");
                                }
                                break;
                        case 37:
-                               wp = WaypointSprite_DeployFixed("danger", false, self.origin, RADARICON_DANGER, '1 0.5 0');
+                               wp = WaypointSprite_DeployFixed(WP_Danger, false, self.origin, RADARICON_DANGER);
                                if(wp)
                                        WaypointSprite_Ping(wp);
                                sprint(self, "DANGER spawned at location\n");
                                break;
                        case 38:
                                WarpZone_crosshair_trace(self);
-                               wp = WaypointSprite_DeployFixed("danger", false, trace_endpos, RADARICON_DANGER, '1 0.5 0');
+                               wp = WaypointSprite_DeployFixed(WP_Danger, false, trace_endpos, RADARICON_DANGER);
                                if(wp)
                                        WaypointSprite_Ping(wp);
                                sprint(self, "DANGER spawned at crosshair\n");
@@ -235,7 +249,7 @@ void ImpulseCommands (void)
                        case 39:
                                if(vlen(self.death_origin))
                                {
-                                       wp = WaypointSprite_DeployFixed("danger", false, self.death_origin, RADARICON_DANGER, '1 0.5 0');
+                                       wp = WaypointSprite_DeployFixed(WP_Danger, false, self.death_origin, RADARICON_DANGER);
                                        if(wp)
                                                WaypointSprite_Ping(wp);
                                        sprint(self, "DANGER spawned at death location\n");
@@ -300,7 +314,7 @@ void ImpulseCommands (void)
                                        {
                                                if(e.wpcost >= 10000000)
                                                {
-                                                       print("unreachable: ", etos(e), " ", vtos(e.origin), "\n");
+                                                       LOG_INFO("unreachable: ", etos(e), " ", vtos(e.origin), "\n");
                                                        e.colormod_z = 8;
                                                        e.effects |= EF_NODEPTHTEST | EF_BLUE;
                                                        ++i;
@@ -308,14 +322,14 @@ void ImpulseCommands (void)
                                                }
                                        }
                                        if(i)
-                                               print(ftos(i), " waypoints cannot be reached from here in any way (marked with blue light)\n");
+                                               LOG_INFO(ftos(i), " waypoints cannot be reached from here in any way (marked with blue light)\n");
                                        navigation_markroutes_inverted(e2);
                                        i = 0;
                                        for(e = findchain(classname, "waypoint"); e; e = e.chain)
                                        {
                                                if(e.wpcost >= 10000000)
                                                {
-                                                       print("cannot reach me: ", etos(e), " ", vtos(e.origin), "\n");
+                                                       LOG_INFO("cannot reach me: ", etos(e), " ", vtos(e.origin), "\n");
                                                        e.colormod_x = 8;
                                                        if(!(e.effects & EF_NODEPTHTEST)) // not already reported before
                                                                ++m;
@@ -324,9 +338,9 @@ void ImpulseCommands (void)
                                                }
                                        }
                                        if(i)
-                                               print(ftos(i), " waypoints cannot walk to here in any way (marked with red light)\n");
+                                               LOG_INFO(ftos(i), " waypoints cannot walk to here in any way (marked with red light)\n");
                                        if(m)
-                                               print(ftos(m), " waypoints have been marked total\n");
+                                               LOG_INFO(ftos(m), " waypoints have been marked total\n");
                                        i = 0;
                                        for(e = findchain(classname, "info_player_deathmatch"); e; e = e.chain)
                                        {
@@ -342,9 +356,9 @@ void ImpulseCommands (void)
                                                else
                                                {
                                                        setorigin(e, org);
-                                                       print("spawn without waypoint: ", etos(e), " ", vtos(e.origin), "\n");
+                                                       LOG_INFO("spawn without waypoint: ", etos(e), " ", vtos(e.origin), "\n");
                                                        e.effects |= EF_NODEPTHTEST;
-                                                       setmodel(e, self.model);
+                                                       _setmodel(e, self.model);
                                                        e.frame = self.frame;
                                                        e.skin = self.skin;
                                                        e.colormod = '8 0.5 8';
@@ -353,7 +367,7 @@ void ImpulseCommands (void)
                                                }
                                        }
                                        if(i)
-                                               print(ftos(i), " spawnpoints have no nearest waypoint (marked by player model)\n");
+                                               LOG_INFO(ftos(i), " spawnpoints have no nearest waypoint (marked by player model)\n");
                                        i = 0;
                                        entity start;
                                        start = findchainflags(flags, FL_ITEM);
@@ -369,14 +383,14 @@ void ImpulseCommands (void)
                                                }
                                                else
                                                {
-                                                       print("item without waypoint: ", etos(e), " ", vtos(e.origin), "\n");
+                                                       LOG_INFO("item without waypoint: ", etos(e), " ", vtos(e.origin), "\n");
                                                        e.effects |= EF_NODEPTHTEST | EF_RED;
                                                        e.colormod_x = 8;
                                                        ++i;
                                                }
                                        }
                                        if(i)
-                                               print(ftos(i), " items have no nearest waypoint and cannot be walked away from (marked with red light)\n");
+                                               LOG_INFO(ftos(i), " items have no nearest waypoint and cannot be walked away from (marked with red light)\n");
                                        i = 0;
                                        for(e = start; e; e = e.chain)
                                        {
@@ -386,20 +400,16 @@ void ImpulseCommands (void)
                                                }
                                                else
                                                {
-                                                       print("item without waypoint: ", etos(e), " ", vtos(e.origin), "\n");
+                                                       LOG_INFO("item without waypoint: ", etos(e), " ", vtos(e.origin), "\n");
                                                        e.effects |= EF_NODEPTHTEST | EF_BLUE;
                                                        e.colormod_z = 8;
                                                        ++i;
                                                }
                                        }
                                        if(i)
-                                               print(ftos(i), " items have no nearest waypoint and cannot be walked to (marked with blue light)\n");
+                                               LOG_INFO(ftos(i), " items have no nearest waypoint and cannot be walked to (marked with blue light)\n");
                                        break;
                        }
                }
        }
-#ifdef TETRIS
-       else if(imp == 100)
-               TetrisImpulse();
-#endif
 }