[nexuiz-commits] r6697 - trunk/data/qcsrc/server
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Sat May 9 23:33:45 EDT 2009
Author: mand1nga
Date: 2009-05-09 23:33:44 -0400 (Sat, 09 May 2009)
New Revision: 6697
Modified:
trunk/data/qcsrc/server/bots_scripting.qc
trunk/data/qcsrc/server/havocbot.qc
Log:
Added moveto and resetgoal bot commands
Modified: trunk/data/qcsrc/server/bots_scripting.qc
===================================================================
--- trunk/data/qcsrc/server/bots_scripting.qc 2009-05-10 03:30:28 UTC (rev 6696)
+++ trunk/data/qcsrc/server/bots_scripting.qc 2009-05-10 03:33:44 UTC (rev 6697)
@@ -291,9 +291,11 @@
case BOT_CMD_TURN:
print("Look to the right or left N degrees. For turning to the left use positive numbers.");
break;
- case BOT_CMD_MOVETO:
+ case BOT_CMD_MOVETO:
+ print("Walk to an specific coordinate on the map. Usage: moveto \"x y z\"");
break;
- case BOT_CMD_RESETGOAL:
+ case BOT_CMD_RESETGOAL:
+ print("Resets the goal stack");
break;
case BOT_CMD_CC:
print("Execute client command. Examples: cc \"say something\"; cc god; cc \"name newnickname\"; cc kill;");
@@ -792,8 +794,18 @@
self.bot_exec_status = self.bot_exec_status | BOT_EXEC_STATUS_PAUSED;
return CMD_STATUS_FINISHED;
+}
+
+float bot_cmd_moveto()
+{
+ return self.cmd_moveto(bot_cmd.bot_cmd_parm_vector);
}
-
+
+float bot_cmd_resetgoal()
+{
+ return self.cmd_resetgoal();
+}
+
void bot_command_executed(float rm)
{
entity cmd;
@@ -895,12 +907,10 @@
status = bot_cmd_turn();
break;
case BOT_CMD_MOVETO:
- // status = bot.bot_cmd_moveto();
- status = CMD_STATUS_FINISHED;
+ status = bot_cmd_moveto();
break;
case BOT_CMD_RESETGOAL:
- // status = bot.cmd_resetgoal();
- status = CMD_STATUS_FINISHED;
+ status = bot_cmd_resetgoal();
break;
case BOT_CMD_CC:
status = bot_cmd_cc();
Modified: trunk/data/qcsrc/server/havocbot.qc
===================================================================
--- trunk/data/qcsrc/server/havocbot.qc 2009-05-10 03:30:28 UTC (rev 6696)
+++ trunk/data/qcsrc/server/havocbot.qc 2009-05-10 03:33:44 UTC (rev 6697)
@@ -208,6 +208,7 @@
if(self.aistatus & AI_STATUS_ROAMING)
if(self.goalcurrent.classname=="waypoint")
+ if not(self.goalcurrent.wpflags & WAYPOINTFLAG_PERSONAL)
if(fabs(self.goalcurrent.origin_z - self.origin_z) < self.maxs_z - self.mins_z)
if(self.goalstack01!=world)
{
@@ -1117,9 +1118,75 @@
havocbot_movetogoal();
};
+float havocbot_moveto(vector pos)
+{
+ if(self.aistatus & AI_STATUS_WAYPOINT_PERSONAL_GOING)
+ {
+ if(self.goalcurrent==world)
+ return CMD_STATUS_ERROR;
+
+ if (!bot_strategytoken_taken)
+ if(self.bot_strategytime<time)
+ {
+ // Refresh path to goal if necessary
+ local entity g;
+ g = self.goalentity;
+ navigation_clearroute();
+ navigation_routetogoal(g,self.origin);
+ bot_strategytoken_taken = TRUE;
+ self.bot_strategytime = time + 10;
+ }
+
+ #ifdef DEBUG_BOT_GOALSTACK
+ debuggoalstack();
+ #endif
+
+ // Heading
+ local vector dir = self.goalcurrent.origin - (self.origin + self.view_ofs);
+ dir_z = 0;
+ bot_aimdir(dir, -1);
+
+ // Go!
+ havocbot_movetogoal();
+ return CMD_STATUS_EXECUTING;
+ }
+
+ if(self.aistatus & AI_STATUS_WAYPOINT_PERSONAL_REACHED)
+ {
+ self.aistatus &~= AI_STATUS_WAYPOINT_PERSONAL_REACHED;
+ return CMD_STATUS_FINISHED;
+ }
+
+ // Spawn personal waypoint
+ entity wp;
+ wp = waypoint_spawnpersonal(pos);
+ if(wp==world)
+ return CMD_STATUS_ERROR;
+
+ // Put it as next goal
+ navigation_clearroute();
+ navigation_findnearestwaypoint(wp, TRUE);
+ navigation_routetogoal(wp,self.origin);
+ bot_strategytoken_taken = TRUE;
+ self.bot_strategytime = time + 10;
+
+ self.aistatus |= AI_STATUS_WAYPOINT_PERSONAL_GOING;
+
+ return CMD_STATUS_EXECUTING;
+}
+
+float havocbot_resetgoal()
+{
+ navigation_clearroute();
+ return CMD_STATUS_FINISHED;
+}
+
void havocbot_setupbot()
{
self.bot_ai = havocbot_ai;
+ self.cmd_moveto = havocbot_moveto;
+ self.cmd_resetgoal = havocbot_resetgoal;
+
// will be updated by think code
//Generate some random skill levels
self.havocbot_keyboardskill=random()-0.5;
More information about the nexuiz-commits
mailing list