]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/bot/default/scripting.qc
Merge remote-tracking branch 'origin/terencehill/bot_waypoints'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / bot / default / scripting.qc
index b98317e366ba7ce7547a468d2a7c7c59d7e3c99b..555f6fc58a54c8e898f4472e7ee81577ea99b579 100644 (file)
@@ -132,7 +132,7 @@ entity bot_getplace(entity this, string placename)
                }
                e = find(NULL, targetname, s);
                if(!e)
-                       LOG_INFO("invalid place ", s, "\n");
+                       LOG_INFO("invalid place ", s);
                if(i < MAX_BOT_PLACES)
                {
                        this.(bot_placenames[i]) = strzone(placename);
@@ -145,7 +145,7 @@ entity bot_getplace(entity this, string placename)
        {
                e = find(NULL, targetname, placename);
                if(!e)
-                       LOG_INFO("invalid place ", placename, "\n");
+                       LOG_INFO("invalid place ", placename);
                return e;
        }
 }
@@ -294,7 +294,7 @@ float bot_decodecommand(string cmdstring)
 
                if(cmd_parm_type!=BOT_CMD_PARAMETER_NONE&&parm=="")
                {
-                       LOG_INFO("ERROR: A parameter is required for this command\n");
+                       LOG_INFO("ERROR: A parameter is required for this command");
                        return 0;
                }
 
@@ -308,14 +308,12 @@ float bot_decodecommand(string cmdstring)
                                bot_cmd.bot_cmd_parm_float = stof(parm);
                                break;
                        case BOT_CMD_PARAMETER_STRING:
-                               if(bot_cmd.bot_cmd_parm_string)
-                                       strunzone(bot_cmd.bot_cmd_parm_string);
-                               bot_cmd.bot_cmd_parm_string = strzone(parm);
+                               strcpy(bot_cmd.bot_cmd_parm_string, 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);
+                                       LOG_INFOF("ERROR: expected vector type \'x y z\', got %s", parm);
                                        return 0;
                                }
                                bot_cmd.bot_cmd_parm_vector = stov(parm);
@@ -325,7 +323,7 @@ float bot_decodecommand(string cmdstring)
                }
                return 1;
        }
-       LOG_INFO("ERROR: No such command '", cmdstring, "'\n");
+       LOG_INFO("ERROR: No such command '", cmdstring, "'");
        return 0;
 }
 
@@ -427,7 +425,7 @@ void bot_cmdhelp(string scmd)
                                LOG_INFO(prelude, "Points the aim to given target");
                                break;
                        case BOT_CMD_PRESSKEY:
-                               LOG_INFO(prelude, "Press one of the following keys: forward, backward, left, right, jump, crouch, attack1, attack2, use\n");
+                               LOG_INFO(prelude, "Press one of the following keys: forward, backward, left, right, jump, crouch, attack1, attack2, use");
                                LOG_INFO("Multiple keys can be pressed at time (with many presskey calls) and it will remain pressed until the command \"releasekey\" is called");
                                LOG_INFO("Note: The script will not return the control to the bot ai until all keys are released");
                                break;
@@ -622,10 +620,11 @@ float bot_cmd_eval(entity this, string expr)
                return cvar(substring(expr, 5, strlen(expr)));
 
        // Search for fields
+       // TODO: expand with support for more fields (key carrier, ball carrier, armor etc)
        switch(expr)
        {
                case "health":
-                       return this.health;
+                       return GetResourceAmount(this, RESOURCE_HEALTH);
                case "speed":
                        return vlen(this.velocity);
                case "flagcarrier":
@@ -1082,15 +1081,15 @@ float bot_cmd_debug_assert_canfire(entity this)
                if(f)
                {
                        this.colormod = '0 8 8';
-                       LOG_INFO("Bot ", this.netname, " using ", this.(weaponentity).weaponname, " wants to fire, inhibited by weaponentity state\n");
+                       LOG_INFO("Bot ", this.netname, " using ", this.(weaponentity).weaponname, " wants to fire, inhibited by weaponentity state");
                }
        }
-       else if(ATTACK_FINISHED(this, slot) > time)
+       else if(ATTACK_FINISHED(this, weaponentity) > time)
        {
                if(f)
                {
                        this.colormod = '8 0 8';
-                       LOG_INFO("Bot ", this.netname, " using ", this.(weaponentity).weaponname, " wants to fire, inhibited by ATTACK_FINISHED (", ftos(ATTACK_FINISHED(this, slot) - time), " seconds left)\n");
+                       LOG_INFO("Bot ", this.netname, " using ", this.(weaponentity).weaponname, " wants to fire, inhibited by ATTACK_FINISHED (", ftos(ATTACK_FINISHED(this, weaponentity) - time), " seconds left)");
                }
        }
        else if(this.(weaponentity).tuba_note)
@@ -1098,7 +1097,7 @@ float bot_cmd_debug_assert_canfire(entity this)
                if(f)
                {
                        this.colormod = '8 0 0';
-                       LOG_INFO("Bot ", this.netname, " using ", this.(weaponentity).weaponname, " wants to fire, bot still has an active tuba note\n");
+                       LOG_INFO("Bot ", this.netname, " using ", this.(weaponentity).weaponname, " wants to fire, bot still has an active tuba note");
                }
        }
        else
@@ -1106,7 +1105,7 @@ float bot_cmd_debug_assert_canfire(entity this)
                if(!f)
                {
                        this.colormod = '8 8 0';
-                       LOG_INFO("Bot ", this.netname, " using ", this.(weaponentity).weaponname, " thinks it has fired, but apparently did not; ATTACK_FINISHED says ", ftos(ATTACK_FINISHED(this, slot) - time), " seconds left\n");
+                       LOG_INFO("Bot ", this.netname, " using ", this.(weaponentity).weaponname, " thinks it has fired, but apparently did not; ATTACK_FINISHED says ", ftos(ATTACK_FINISHED(this, weaponentity) - time), " seconds left");
                }
        }
 
@@ -1170,8 +1169,7 @@ void bot_resetqueues()
                it.bot_barrier = 0;
                for(int i = 0; i < it.bot_places_count; ++i)
                {
-                       strunzone(it.(bot_placenames[i]));
-                       it.(bot_placenames[i]) = string_null;
+                       strfree(it.(bot_placenames[i]));
                }
                it.bot_places_count = 0;
        });
@@ -1203,7 +1201,7 @@ float bot_execute_commands_once(entity this)
                if(bot_cmd.bot_cmd_type!=BOT_CMD_NULL)
                {
                        bot_command_executed(this, true);
-                       LOG_INFO("WARNING: Commands are ignored while the bot is paused. Use the command 'continue' instead.\n");
+                       LOG_INFO("WARNING: Commands are ignored while the bot is paused. Use the command 'continue' instead.");
                }
                return 1;
        }