]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/bot/scripting.qc
s/world/NULL/
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / bot / scripting.qc
index 16bb6b314bc4f53eb803bcb12b785fabaabf744e..3734ad8501c815c463719cf3bc6bebd409b3dfa8 100644 (file)
@@ -125,7 +125,7 @@ entity bot_getplace(entity this, string placename)
                        cvar_set(placename, strcat(substring(s2, p+1, -1), " ", s));
                        //print("places: ", placename, " := ", cvar_string(placename), "\n");
                }
-               e = find(world, targetname, s);
+               e = find(NULL, targetname, s);
                if(!e)
                        LOG_INFO("invalid place ", s, "\n");
                if(i < MAX_BOT_PLACES)
@@ -138,7 +138,7 @@ entity bot_getplace(entity this, string placename)
        }
        else
        {
-               e = find(world, targetname, placename);
+               e = find(NULL, targetname, placename);
                if(!e)
                        LOG_INFO("invalid place ", placename, "\n");
                return e;
@@ -240,7 +240,7 @@ entity find_bot_by_name(string name)
                bot = bot.chain;
        }
 
-       return world;
+       return NULL;
 }
 
 // Returns a bot by number on list
@@ -250,7 +250,7 @@ entity find_bot_by_number(float number)
        float c = 0;
 
        if(!number)
-               return world;
+               return NULL;
 
        bot = findchainflags(flags, FL_CLIENT);
        while (bot)
@@ -263,7 +263,7 @@ entity find_bot_by_number(float number)
                bot = bot.chain;
        }
 
-       return world;
+       return NULL;
 }
 
 float bot_decodecommand(string cmdstring)
@@ -479,7 +479,7 @@ void bot_list_commands()
 void SV_ParseClientCommand(string s);
 float bot_cmd_cc(entity this)
 {
-       WITH(entity, self, this, SV_ParseClientCommand(bot_cmd.bot_cmd_parm_string));
+       WITHSELF(this, SV_ParseClientCommand(bot_cmd.bot_cmd_parm_string));
        return CMD_STATUS_FINISHED;
 }
 
@@ -612,7 +612,7 @@ float bot_cmd_eval(entity this, string expr)
                case "speed":
                        return vlen(this.velocity);
                case "flagcarrier":
-                       return ((this.flagcarried!=world));
+                       return ((this.flagcarried!=NULL));
        }
 
        LOG_INFO(strcat("ERROR: Unable to convert the expression '",expr,"' into a numeric value\n"));
@@ -824,50 +824,50 @@ const int BOT_CMD_KEY_HOOK                = BIT(8);
 const int BOT_CMD_KEY_CROUCH   = BIT(9);
 const int BOT_CMD_KEY_CHAT             = BIT(10);
 
-float bot_presskeys()
-{SELFPARAM();
-       self.movement = '0 0 0';
-       PHYS_INPUT_BUTTON_JUMP(self) = false;
-       PHYS_INPUT_BUTTON_CROUCH(self) = false;
-       PHYS_INPUT_BUTTON_ATCK(self) = false;
-       PHYS_INPUT_BUTTON_ATCK2(self) = false;
-       PHYS_INPUT_BUTTON_USE(self) = false;
-       PHYS_INPUT_BUTTON_HOOK(self) = false;
-       PHYS_INPUT_BUTTON_CHAT(self) = false;
-
-       if(self.bot_cmd_keys == BOT_CMD_KEY_NONE)
+bool bot_presskeys(entity this)
+{
+       this.movement = '0 0 0';
+       PHYS_INPUT_BUTTON_JUMP(this) = false;
+       PHYS_INPUT_BUTTON_CROUCH(this) = false;
+       PHYS_INPUT_BUTTON_ATCK(this) = false;
+       PHYS_INPUT_BUTTON_ATCK2(this) = false;
+       PHYS_INPUT_BUTTON_USE(this) = false;
+       PHYS_INPUT_BUTTON_HOOK(this) = false;
+       PHYS_INPUT_BUTTON_CHAT(this) = false;
+
+       if(this.bot_cmd_keys == BOT_CMD_KEY_NONE)
                return false;
 
-       if(self.bot_cmd_keys & BOT_CMD_KEY_FORWARD)
-               self.movement_x = autocvar_sv_maxspeed;
-       else if(self.bot_cmd_keys & BOT_CMD_KEY_BACKWARD)
-               self.movement_x = -autocvar_sv_maxspeed;
+       if(this.bot_cmd_keys & BOT_CMD_KEY_FORWARD)
+               this.movement_x = autocvar_sv_maxspeed;
+       else if(this.bot_cmd_keys & BOT_CMD_KEY_BACKWARD)
+               this.movement_x = -autocvar_sv_maxspeed;
 
-       if(self.bot_cmd_keys & BOT_CMD_KEY_RIGHT)
-               self.movement_y = autocvar_sv_maxspeed;
-       else if(self.bot_cmd_keys & BOT_CMD_KEY_LEFT)
-               self.movement_y = -autocvar_sv_maxspeed;
+       if(this.bot_cmd_keys & BOT_CMD_KEY_RIGHT)
+               this.movement_y = autocvar_sv_maxspeed;
+       else if(this.bot_cmd_keys & BOT_CMD_KEY_LEFT)
+               this.movement_y = -autocvar_sv_maxspeed;
 
-       if(self.bot_cmd_keys & BOT_CMD_KEY_JUMP)
-               PHYS_INPUT_BUTTON_JUMP(self) = true;
+       if(this.bot_cmd_keys & BOT_CMD_KEY_JUMP)
+               PHYS_INPUT_BUTTON_JUMP(this) = true;
 
-       if(self.bot_cmd_keys & BOT_CMD_KEY_CROUCH)
-               PHYS_INPUT_BUTTON_CROUCH(self) = true;
+       if(this.bot_cmd_keys & BOT_CMD_KEY_CROUCH)
+               PHYS_INPUT_BUTTON_CROUCH(this) = true;
 
-       if(self.bot_cmd_keys & BOT_CMD_KEY_ATTACK1)
-               PHYS_INPUT_BUTTON_ATCK(self) = true;
+       if(this.bot_cmd_keys & BOT_CMD_KEY_ATTACK1)
+               PHYS_INPUT_BUTTON_ATCK(this) = true;
 
-       if(self.bot_cmd_keys & BOT_CMD_KEY_ATTACK2)
-               PHYS_INPUT_BUTTON_ATCK2(self) = true;
+       if(this.bot_cmd_keys & BOT_CMD_KEY_ATTACK2)
+               PHYS_INPUT_BUTTON_ATCK2(this) = true;
 
-       if(self.bot_cmd_keys & BOT_CMD_KEY_USE)
-               PHYS_INPUT_BUTTON_USE(self) = true;
+       if(this.bot_cmd_keys & BOT_CMD_KEY_USE)
+               PHYS_INPUT_BUTTON_USE(this) = true;
 
-       if(self.bot_cmd_keys & BOT_CMD_KEY_HOOK)
-               PHYS_INPUT_BUTTON_HOOK(self) = true;
+       if(this.bot_cmd_keys & BOT_CMD_KEY_HOOK)
+               PHYS_INPUT_BUTTON_HOOK(this) = true;
 
-       if(self.bot_cmd_keys & BOT_CMD_KEY_CHAT)
-               PHYS_INPUT_BUTTON_CHAT(self) = true;
+       if(this.bot_cmd_keys & BOT_CMD_KEY_CHAT)
+               PHYS_INPUT_BUTTON_CHAT(this) = true;
 
        return true;
 }
@@ -1111,7 +1111,7 @@ void bot_command_executed(entity this, bool rm)
 
 void bot_setcurrentcommand(entity this)
 {
-       bot_cmd = world;
+       bot_cmd = NULL;
 
        if(!this.bot_cmd_current)
        {
@@ -1134,13 +1134,13 @@ void bot_setcurrentcommand(entity this)
                        else
                        {
                                // Invalid command, remove from queue
-                               bot_cmd = world;
+                               bot_cmd = NULL;
                                bot_dequeuecommand(this, this.bot_cmd_execution_index);
                                this.bot_cmd_execution_index++;
                        }
                }
                else
-                       bot_cmd = world;
+                       bot_cmd = NULL;
        }
 }
 
@@ -1175,7 +1175,7 @@ float bot_execute_commands_once(entity this)
        // old logic kept pressing previously pressed keys, but that has problems
        // (namely, it means you cannot make a bot "normal" ever again)
        // to keep a bot walking for a while, use the "wait" bot command
-       if(bot_cmd == world)
+       if(bot_cmd == NULL)
                return false;
 
        // Ignore all commands except continue when the bot is paused
@@ -1191,7 +1191,7 @@ float bot_execute_commands_once(entity this)
        }
 
        // Keep pressing keys raised by the "presskey" command
-       ispressingkey = boolean(bot_presskeys());
+       ispressingkey = boolean(bot_presskeys(this));
 
        // Handle conditions
        if (!(bot_cmd.bot_cmd_type==BOT_CMD_FI||bot_cmd.bot_cmd_type==BOT_CMD_ELSE))