]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/bot/bot.qc
Header police
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / bot / bot.qc
index 671014b806d4790a6406fa4a2d7f69a771354eb2..72ebfcb2e70d65cecc4aeba4373151514effec6b 100644 (file)
 #include "../constants.qh"
 #include "../defs.qh"
 #include "../race.qh"
-#include "../t_items.qh"
+#include <common/t_items.qh>
 
 #include "../mutators/all.qh"
 
 #include "../weapons/accuracy.qh"
 
-#include "../../common/constants.qh"
-#include "../../common/mapinfo.qh"
-#include "../../common/teams.qh"
-#include "../../common/util.qh"
+#include <common/constants.qh>
+#include <common/mapinfo.qh>
+#include <common/teams.qh>
+#include <common/util.qh>
 
-#include "../../common/weapons/all.qh"
+#include <common/weapons/all.qh>
 
-#include "../../lib/csqcmodel/sv_model.qh"
+#include <lib/csqcmodel/sv_model.qh>
 
-#include "../../lib/warpzone/common.qh"
-#include "../../lib/warpzone/util_server.qh"
+#include <lib/warpzone/common.qh>
+#include <lib/warpzone/util_server.qh>
 
 entity bot_spawn()
 {SELFPARAM();
@@ -92,17 +92,16 @@ void bot_think()
        // skill 0 = ping 0.7 (slightly drunk)
 
        // clear buttons
-       self.BUTTON_ATCK = 0;
-       self.button1 = 0;
-       self.BUTTON_JUMP = 0;
-       self.BUTTON_ATCK2 = 0;
-       self.BUTTON_ZOOM = 0;
-       self.BUTTON_CROUCH = 0;
-       self.BUTTON_HOOK = 0;
-       self.BUTTON_INFO = 0;
-       self.button8 = 0;
-       self.BUTTON_CHAT = 0;
-       self.BUTTON_USE = 0;
+       PHYS_INPUT_BUTTON_ATCK(self) = false;
+       PHYS_INPUT_BUTTON_JUMP(self) = false;
+       PHYS_INPUT_BUTTON_ATCK2(self) = false;
+       PHYS_INPUT_BUTTON_ZOOM(self) = false;
+       PHYS_INPUT_BUTTON_CROUCH(self) = false;
+       PHYS_INPUT_BUTTON_HOOK(self) = false;
+       PHYS_INPUT_BUTTON_INFO(self) = false;
+       PHYS_INPUT_BUTTON_DRAG(self) = false;
+       PHYS_INPUT_BUTTON_CHAT(self) = false;
+       PHYS_INPUT_BUTTON_USE(self) = false;
 
        if (time < game_starttime)
        {
@@ -113,11 +112,11 @@ void bot_think()
        }
 
        // if dead, just wait until we can respawn
-       if (self.deadflag)
+       if (IS_DEAD(self))
        {
                if (self.deadflag == DEAD_DEAD)
                {
-                       self.BUTTON_JUMP = 1; // press jump to respawn
+                       PHYS_INPUT_BUTTON_JUMP(self) = true; // press jump to respawn
                        self.bot_strategytime = 0;
                }
        }
@@ -132,7 +131,6 @@ void bot_setnameandstuff()
 {SELFPARAM();
        string readfile, s;
        float file, tokens, prio;
-       entity p;
 
        string bot_name, bot_model, bot_skin, bot_shirt, bot_pants;
        string name, prefix, suffix;
@@ -169,15 +167,13 @@ void bot_setnameandstuff()
                                continue;
                        s = argv(0);
                        prio = 1;
-                       FOR_EACH_CLIENT(p)
-                       {
-                               if(IS_BOT_CLIENT(p))
-                               if(s == p.cleanname)
+                       FOREACH_CLIENT(IS_BOT_CLIENT(it), LAMBDA(
+                               if(s == it.cleanname)
                                {
                                        prio = 0;
                                        break;
                                }
-                       }
+                       ));
                        RandomSelection_Add(world, 0, readfile, 1, prio);
                }
                readfile = RandomSelection_chosen_string;
@@ -237,16 +233,13 @@ void bot_setnameandstuff()
                name = bot_name;
 
        // number bots with identical names
-       float i;
-       i = 0;
-       FOR_EACH_CLIENT(p)
-       {
-               if(IS_BOT_CLIENT(p))
-                       if(p.cleanname == name)
-                               ++i;
-       }
-       if (i)
-               self.netname = self.netname_freeme = strzone(strcat(prefix, name, "(", ftos(i), ")", suffix));
+       int j = 0;
+       FOREACH_CLIENT(IS_BOT_CLIENT(it), LAMBDA(
+               if(it.cleanname == name)
+                       ++j;
+       ));
+       if (j)
+               self.netname = self.netname_freeme = strzone(strcat(prefix, name, "(", ftos(j), ")", suffix));
        else
                self.netname = self.netname_freeme = strzone(strcat(prefix, name, suffix));
 
@@ -507,17 +500,15 @@ void autoskill(float factor)
 {
        float bestbot;
        float bestplayer;
-       entity head;
 
        bestbot = -1;
        bestplayer = -1;
-       FOR_EACH_PLAYER(head)
-       {
-               if(IS_REAL_CLIENT(head))
-                       bestplayer = max(bestplayer, head.totalfrags - head.totalfrags_lastcheck);
+       FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
+               if(IS_REAL_CLIENT(it))
+                       bestplayer = max(bestplayer, it.totalfrags - it.totalfrags_lastcheck);
                else
-                       bestbot = max(bestbot, head.totalfrags - head.totalfrags_lastcheck);
-       }
+                       bestbot = max(bestbot, it.totalfrags - it.totalfrags_lastcheck);
+       ));
 
        LOG_TRACE("autoskill: best player got ", ftos(bestplayer), ", ");
        LOG_TRACE("best bot got ", ftos(bestbot), "; ");
@@ -551,8 +542,7 @@ void autoskill(float factor)
                // don't reset counters, wait for them to accumulate
        }
 
-       FOR_EACH_PLAYER(head)
-               head.totalfrags_lastcheck = head.totalfrags;
+       FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(it.totalfrags_lastcheck = it.totalfrags));
 }
 
 void bot_calculate_stepheightvec()
@@ -571,13 +561,11 @@ float bot_fixcount()
                activerealplayers = bot_activerealplayers;
                realplayers = bot_realplayers;
        } else {
-               entity head;
-               FOR_EACH_REALCLIENT(head)
-               {
-                       if(IS_PLAYER(head))
+               FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(
+                       if(IS_PLAYER(it))
                                ++activerealplayers;
                        ++realplayers;
-               }
+               ));
        }
 
        int bots;