[nexuiz-commits] r6996 - trunk/data/qcsrc/server
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Fri Jun 12 04:17:49 EDT 2009
Author: div0
Date: 2009-06-12 04:17:49 -0400 (Fri, 12 Jun 2009)
New Revision: 6996
Modified:
trunk/data/qcsrc/server/bots_scripting.qc
trunk/data/qcsrc/server/gamecommand.qc
Log:
fix bot barriers, add a "load" command to bot_cmd
Modified: trunk/data/qcsrc/server/bots_scripting.qc
===================================================================
--- trunk/data/qcsrc/server/bots_scripting.qc 2009-06-12 08:05:49 UTC (rev 6995)
+++ trunk/data/qcsrc/server/bots_scripting.qc 2009-06-12 08:17:49 UTC (rev 6996)
@@ -9,6 +9,7 @@
error("readcommand but no queue allocated");
buf_del(bot.bot_cmdqueuebuf);
bot.bot_cmdqueuebuf_allocated = FALSE;
+ print("bot ", bot.netname, " queue cleared\n");
}
void bot_queuecommand(entity bot, string cmdstring)
@@ -85,11 +86,12 @@
#define BOT_CMD_MOVETOTARGET 18
#define BOT_CMD_AIMTARGET 19
#define BOT_CMD_BARRIER 20
-#define BOT_CMD_WHILE 21 // TODO: Not implemented yet
-#define BOT_CMD_WEND 22 // TODO: Not implemented yet
-#define BOT_CMD_CHASE 23 // TODO: Not implemented yet
+#define BOT_CMD_CONSOLE 21
+#define BOT_CMD_WHILE 22 // TODO: Not implemented yet
+#define BOT_CMD_WEND 23 // TODO: Not implemented yet
+#define BOT_CMD_CHASE 24 // TODO: Not implemented yet
-#define BOT_CMD_COUNTER 21 // Update this value if you add/remove a command
+#define BOT_CMD_COUNTER 22 // Update this value if you add/remove a command
// NOTE: Following commands should be implemented on the bot ai
// If a new command should be handled by the target ai(s) please declare it here
@@ -189,6 +191,9 @@
bot_cmd_string[BOT_CMD_BARRIER] = "barrier";
bot_cmd_parm_type[BOT_CMD_BARRIER] = BOT_CMD_PARAMETER_NONE;
+ bot_cmd_string[BOT_CMD_CONSOLE] = "console";
+ bot_cmd_parm_type[BOT_CMD_CONSOLE] = BOT_CMD_PARAMETER_STRING;
+
bot_cmds_initialized = TRUE;
}
@@ -273,6 +278,8 @@
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);
break;
case BOT_CMD_PARAMETER_VECTOR:
@@ -494,13 +501,15 @@
if(self.bot_barrier == 0) // initialization
{
self.bot_barrier = 1;
+
+ self.colormod = '4 4 0';
}
if(self.bot_barrier == 1) // find other bots
{
FOR_EACH_CLIENT(cl) if(cl.isbot)
{
- if(cl.bot_barrier == 0)
+ if(cl.bot_barrier != 1)
return CMD_STATUS_EXECUTING; // not all are at the barrier yet
}
@@ -516,6 +525,7 @@
// if we get here, the barrier is finished
// so end it...
self.bot_barrier = 0;
+ self.colormod = '0 0 0';
return CMD_STATUS_FINISHED;
}
@@ -1165,6 +1175,10 @@
case BOT_CMD_BARRIER:
status = bot_cmd_barrier();
break;
+ case BOT_CMD_CONSOLE:
+ localcmd(strcat(bot_cmd.bot_cmd_parm_string, "\n"));
+ status = CMD_STATUS_FINISHED;
+ break;
default:
print(strcat("ERROR: Invalid command on queue with id '",ftos(bot_cmd.bot_cmd_type),"'\n"));
return FALSE;
Modified: trunk/data/qcsrc/server/gamecommand.qc
===================================================================
--- trunk/data/qcsrc/server/gamecommand.qc 2009-06-12 08:05:49 UTC (rev 6995)
+++ trunk/data/qcsrc/server/gamecommand.qc 2009-06-12 08:17:49 UTC (rev 6996)
@@ -580,6 +580,7 @@
entity client, e;
vector v;
float entno, i;
+ string s;
argc = tokenize_console(command);
if(argv(0) == "help" || argc == 0)
@@ -645,7 +646,6 @@
if(argv(0) == "gametype") if(argc == 2)
{
float t, tsave;
- string s;
s = argv(1);
t = MapInfo_Type_FromString(s);
tsave = MapInfo_CurrentGametype();
@@ -924,6 +924,8 @@
if(argv(0) == "bot_cmd")
{
+ local entity bot;
+
if(argv(1) == "help")
{
if(argc==2)
@@ -943,6 +945,36 @@
return;
}
+ if(argv(1) == "load" && argc == 3)
+ {
+ float fh;
+ fh = fopen(argv(2), FILE_READ);
+ if(fh < 0)
+ {
+ print("cannot open the file\n");
+ return;
+ }
+
+ i = 0;
+ while((s = fgets(fh)))
+ {
+ argc = tokenize_console(s);
+ // let's start at token 2 so we can skip sv_cmd bot_cmd
+ bot = find_bot_by_name(argv(2));
+ if(bot == world)
+ bot = find_bot_by_number(stof(argv(2)));
+ if(bot)
+ bot_queuecommand(bot, strcat(argv(3), " ", argv(4)));
+ ++i;
+ }
+
+ print(ftos(i), " commands read\n");
+
+ fclose(fh);
+
+ return;
+ }
+
if(argc < 3)
{
print("Usage: sv_cmd bot_cmd <bot name or number> <command> [argument]\n");
@@ -952,7 +984,6 @@
return;
}
- local entity bot;
bot = find_bot_by_name(argv(1));
if(bot==world)
bot = find_bot_by_number(stof(argv(1)));
More information about the nexuiz-commits
mailing list