]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/bot/default/scripting.qc
Merged master.
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / bot / default / scripting.qc
index 4b3fc6266e175c98beaf0c3e0fc6af179b86d7e5..9dca0af07637ce9f44d1fbd194115a0a88581cf3 100644 (file)
@@ -311,6 +311,11 @@ float bot_decodecommand(string cmdstring)
                                bot_cmd.bot_cmd_parm_string = strzone(parm);
                                break;
                        case BOT_CMD_PARAMETER_VECTOR:
+                               if(substring(parm, 0, 1) != "\'")
+                               {
+                                       LOG_INFOF("ERROR: expected vector type \'x y z\', got %s\n", parm);
+                                       return 0;
+                               }
                                bot_cmd.bot_cmd_parm_vector = stov(parm);
                                break;
                        default:
@@ -377,7 +382,7 @@ void bot_cmdhelp(string scmd)
                                LOG_INFO("Look to the right or left N degrees. For turning to the left use positive numbers.");
                                break;
                        case BOT_CMD_MOVETO:
-                               LOG_INFO("Walk to an specific coordinate on the map. Usage: moveto \"x y z\"");
+                               LOG_INFO("Walk to an specific coordinate on the map. Usage: moveto \'x y z\'");
                                break;
                        case BOT_CMD_MOVETOTARGET:
                                LOG_INFO("Walk to the specific target on the map");
@@ -480,12 +485,13 @@ float bot_cmd_cc(entity this)
 
 float bot_cmd_impulse(entity this)
 {
-       this.impulse = bot_cmd.bot_cmd_parm_float;
+       CS(this).impulse = bot_cmd.bot_cmd_parm_float;
        return CMD_STATUS_FINISHED;
 }
 
 float bot_cmd_continue(entity this)
 {
+       bot_relinkplayerlist();
        this.bot_exec_status &= ~BOT_EXEC_STATUS_PAUSED;
        return CMD_STATUS_FINISHED;
 }
@@ -830,7 +836,7 @@ const int BOT_CMD_KEY_CHAT          = BIT(10);
 
 bool bot_presskeys(entity this)
 {
-       this.movement = '0 0 0';
+       CS(this).movement = '0 0 0';
        PHYS_INPUT_BUTTON_JUMP(this) = false;
        PHYS_INPUT_BUTTON_CROUCH(this) = false;
        PHYS_INPUT_BUTTON_ATCK(this) = false;
@@ -843,14 +849,14 @@ bool bot_presskeys(entity this)
                return false;
 
        if(this.bot_cmd_keys & BOT_CMD_KEY_FORWARD)
-               this.movement_x = autocvar_sv_maxspeed;
+               CS(this).movement_x = autocvar_sv_maxspeed;
        else if(this.bot_cmd_keys & BOT_CMD_KEY_BACKWARD)
-               this.movement_x = -autocvar_sv_maxspeed;
+               CS(this).movement_x = -autocvar_sv_maxspeed;
 
        if(this.bot_cmd_keys & BOT_CMD_KEY_RIGHT)
-               this.movement_y = autocvar_sv_maxspeed;
+               CS(this).movement_y = autocvar_sv_maxspeed;
        else if(this.bot_cmd_keys & BOT_CMD_KEY_LEFT)
-               this.movement_y = -autocvar_sv_maxspeed;
+               CS(this).movement_y = -autocvar_sv_maxspeed;
 
        if(this.bot_cmd_keys & BOT_CMD_KEY_JUMP)
                PHYS_INPUT_BUTTON_JUMP(this) = true;
@@ -883,7 +889,7 @@ float bot_cmd_keypress_handler(entity this, string key, float enabled)
        {
                case "all":
                        if(enabled)
-                               this.bot_cmd_keys = power2of(20) - 1; // >:)
+                               this.bot_cmd_keys = (2 ** 20) - 1; // >:)
                        else
                                this.bot_cmd_keys = BOT_CMD_KEY_NONE;
                case "forward":
@@ -1002,9 +1008,10 @@ float bot_cmd_pause(entity this)
        PHYS_INPUT_BUTTON_ATCK2(this) = false;
        PHYS_INPUT_BUTTON_CROUCH(this) = false;
 
-       this.movement = '0 0 0';
+       CS(this).movement = '0 0 0';
        this.bot_cmd_keys = BOT_CMD_KEY_NONE;
 
+       bot_clear(this);
        this.bot_exec_status |= BOT_EXEC_STATUS_PAUSED;
        return CMD_STATUS_FINISHED;
 }
@@ -1120,7 +1127,6 @@ void bot_setcurrentcommand(entity this)
        if(!this.bot_cmd_current)
        {
                this.bot_cmd_current = new_pure(bot_cmd);
-               this.bot_cmd_current.is_bot_cmd = true;
        }
 
        bot_cmd = this.bot_cmd_current;
@@ -1175,16 +1181,17 @@ float bot_execute_commands_once(entity this)
        // Find command
        bot_setcurrentcommand(this);
 
-       // if we have no bot command, better return
-       // 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 == NULL)
-               return false;
-
        // Ignore all commands except continue when the bot is paused
-       if(this.bot_exec_status & BOT_EXEC_STATUS_PAUSED)
-       if(bot_cmd.bot_cmd_type!=BOT_CMD_CONTINUE)
+       if(!(this.bot_exec_status & BOT_EXEC_STATUS_PAUSED))
+       {
+               // if we have no bot command, better return
+               // 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)
+                       return 0;
+       }
+       else if(bot_cmd.bot_cmd_type != BOT_CMD_CONTINUE)
        {
                if(bot_cmd.bot_cmd_type!=BOT_CMD_NULL)
                {