Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
scripting.qh File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define BOT_EXEC_STATUS_IDLE   0
#define BOT_EXEC_STATUS_PAUSED   1
#define BOT_EXEC_STATUS_WAITING   2
#define CMD_STATUS_ERROR   2
#define CMD_STATUS_EXECUTING   0
#define CMD_STATUS_FINISHED   1

Functions

void bot_cmdhelp (string scmd)
float bot_execute_commands (entity this)
bool bot_ispaused (entity this)
void bot_list_commands ()
void bot_queuecommand (entity bot, string cmdstring)
void bot_resetqueues ()
entity find_bot_by_name (string name)
entity find_bot_by_number (float number)
 float (entity) cmd_resetgoal
 float (entity, vector) cmd_moveto

Variables

float bot_barrier
float bot_barriertime
entity bot_cmd
const int BOT_CMD_AIM = 12
const int BOT_CMD_AIMTARGET = 19
const int BOT_CMD_BARRIER = 20
const int BOT_CMD_CC = 7
const int BOT_CMD_CONSOLE = 21
const int BOT_CMD_CONTINUE = 2
const int BOT_CMD_COUNTER = 24
entity bot_cmd_current
const int BOT_CMD_DEBUG_ASSERT_CANFIRE = 23
const int BOT_CMD_ELSE = 9
float bot_cmd_execution_index
const int BOT_CMD_FI = 10
const int BOT_CMD_IF = 8
const int BOT_CMD_IMPULSE = 16
float bot_cmd_index
const int BOT_CMD_MOVETO = 5
const int BOT_CMD_MOVETOTARGET = 18
const int BOT_CMD_NULL = 0
const int BOT_CMD_PARAMETER_FLOAT = 1
const int BOT_CMD_PARAMETER_NONE = 0
const int BOT_CMD_PARAMETER_STRING = 2
const int BOT_CMD_PARAMETER_VECTOR = 3
float bot_cmd_parm_float
string bot_cmd_parm_string
int bot_cmd_parm_type [BOT_CMD_COUNTER]
vector bot_cmd_parm_vector
const int BOT_CMD_PAUSE = 1
const int BOT_CMD_PRESSKEY = 13
const int BOT_CMD_RELEASEKEY = 14
const int BOT_CMD_RESETAIM = 11
const int BOT_CMD_RESETGOAL = 6
const int BOT_CMD_SELECTWEAPON = 15
const int BOT_CMD_SOUND = 22
string bot_cmd_string [BOT_CMD_COUNTER]
const int BOT_CMD_TURN = 4
int bot_cmd_type
const int BOT_CMD_WAIT = 3
const int BOT_CMD_WAIT_UNTIL = 17
float bot_cmds_initialized

Macro Definition Documentation

◆ BOT_EXEC_STATUS_IDLE

#define BOT_EXEC_STATUS_IDLE   0

Definition at line 3 of file scripting.qh.

◆ BOT_EXEC_STATUS_PAUSED

#define BOT_EXEC_STATUS_PAUSED   1

◆ BOT_EXEC_STATUS_WAITING

#define BOT_EXEC_STATUS_WAITING   2

Definition at line 5 of file scripting.qh.

Referenced by bot_cmd_wait(), and bot_cmd_wait_until().

◆ CMD_STATUS_ERROR

◆ CMD_STATUS_EXECUTING

#define CMD_STATUS_EXECUTING   0

◆ CMD_STATUS_FINISHED

Function Documentation

◆ bot_cmdhelp()

void bot_cmdhelp ( string scmd)

Definition at line 331 of file scripting.qc.

332{
333 int i, ntype;
334 string stype;
335
338
339 for(i=1;i<BOT_CMD_COUNTER;++i)
340 {
341 if(bot_cmd_string[i]!=scmd)
342 continue;
343
344 ntype = bot_cmd_parm_type[i];
345
346 switch(ntype)
347 {
349 stype = "float";
350 break;
352 stype = "string";
353 break;
355 stype = "vector";
356 break;
357 default:
358 stype = "none";
359 break;
360 }
361
362 string desc = "";
363 switch(i)
364 {
365 case BOT_CMD_PAUSE:
366 desc = "Stops the bot completely. Any command other than 'continue' will be ignored.";
367 break;
368 case BOT_CMD_CONTINUE:
369 desc = "Disable paused status";
370 break;
371 case BOT_CMD_WAIT:
372 desc = "Pause command parsing and bot ai for N seconds. Pressed key will remain pressed";
373 break;
375 desc = "Pause command parsing and bot ai until time is N from the last barrier. Pressed key will remain pressed";
376 break;
377 case BOT_CMD_BARRIER:
378 desc = "Waits till all bots that have a command queue reach this command. Pressed key will remain pressed";
379 break;
380 case BOT_CMD_TURN:
381 desc = "Look to the right or left N degrees. For turning to the left use positive numbers.";
382 break;
383 case BOT_CMD_MOVETO:
384 desc = "Walk to an specific coordinate on the map. Usage: moveto \'x y z\'";
385 break;
387 desc = "Walk to the specific target on the map";
388 break;
390 desc = "Resets the goal stack";
391 break;
392 case BOT_CMD_CC:
393 desc = "Execute client command. Examples: cc say something; cc god; cc name newnickname; cc kill;";
394 break;
395 case BOT_CMD_IF:
396 desc = "Perform simple conditional execution.\n"
397 "Syntax: \n"
398 " sv_cmd .. if \"condition\"\n"
399 " sv_cmd .. <instruction if true>\n"
400 " sv_cmd .. <instruction if true>\n"
401 " sv_cmd .. else\n"
402 " sv_cmd .. <instruction if false>\n"
403 " sv_cmd .. <instruction if false>\n"
404 " sv_cmd .. fi\n"
405 "Conditions: a=b, a>b, a<b, a\t\t(spaces not allowed)\n"
406 " Values in conditions can be numbers, cvars in the form cvar.cvar_string or special fields\n"
407 "Fields: health, speed, flagcarrier\n"
408 "Examples: if health>50; if health>cvar.g_balance_laser_primary_damage; if flagcarrier;";
409 break;
410 case BOT_CMD_RESETAIM:
411 desc = "Points the aim to the coordinates x,y 0,0";
412 break;
413 case BOT_CMD_AIM:
414 desc = "Move the aim x/y (horizontal/vertical) degrees relatives to the bot\n"
415 "There is a 3rd optional parameter telling in how many seconds the aim has to reach the new position\n"
416 "Examples: aim \"90 0\" // Turn 90 degrees inmediately (positive numbers move to the left/up)\n"
417 " aim \"0 90 2\" // Will gradually look to the sky in the next two seconds";
418 break;
420 desc = "Points the aim to given target";
421 break;
422 case BOT_CMD_PRESSKEY:
423 desc = "Press one of the following keys: forward, backward, left, right, jump, crouch, attack1, attack2, use"
424 "Multiple keys can be pressed at time (with many presskey calls) and it will remain pressed until the command \"releasekey\" is called"
425 "Note: The script will not return the control to the bot ai until all keys are released";
426 break;
428 desc = "Release previoulsy used keys. Use the parameter \"all\" to release all keys";
429 break;
430 case BOT_CMD_SOUND:
431 desc = "play sound file at bot location";
432 break;
434 desc = "verify the state of the weapon entity";
435 break;
436 default:
437 desc = "This command has no description yet.";
438 break;
439 }
440 LOG_HELP("Command: ", bot_cmd_string[i], "\nParameter: <", stype, ">", "\nDescription: ", desc);
441 }
442}
#define LOG_HELP(...)
Definition log.qh:85
void bot_commands_init()
Definition scripting.qc:157
const int BOT_CMD_AIMTARGET
Definition scripting.qh:32
const int BOT_CMD_AIM
Definition scripting.qh:25
const int BOT_CMD_PARAMETER_FLOAT
Definition scripting.qh:50
const int BOT_CMD_CC
Definition scripting.qh:20
const int BOT_CMD_PRESSKEY
Definition scripting.qh:26
const int BOT_CMD_WAIT_UNTIL
Definition scripting.qh:30
const int BOT_CMD_IF
Definition scripting.qh:21
const int BOT_CMD_DEBUG_ASSERT_CANFIRE
Definition scripting.qh:36
string bot_cmd_string[BOT_CMD_COUNTER]
Definition scripting.qh:56
const int BOT_CMD_SOUND
Definition scripting.qh:35
const int BOT_CMD_RELEASEKEY
Definition scripting.qh:27
const int BOT_CMD_MOVETOTARGET
Definition scripting.qh:31
const int BOT_CMD_PAUSE
Definition scripting.qh:14
const int BOT_CMD_CONTINUE
Definition scripting.qh:15
const int BOT_CMD_MOVETO
Definition scripting.qh:18
const int BOT_CMD_PARAMETER_VECTOR
Definition scripting.qh:52
const int BOT_CMD_COUNTER
Definition scripting.qh:41
const int BOT_CMD_PARAMETER_STRING
Definition scripting.qh:51
const int BOT_CMD_BARRIER
Definition scripting.qh:33
const int BOT_CMD_WAIT
Definition scripting.qh:16
const int BOT_CMD_TURN
Definition scripting.qh:17
int bot_cmd_parm_type[BOT_CMD_COUNTER]
Definition scripting.qh:55
const int BOT_CMD_RESETGOAL
Definition scripting.qh:19
const int BOT_CMD_RESETAIM
Definition scripting.qh:24
float bot_cmds_initialized
Definition scripting.qh:54

◆ bot_execute_commands()

float bot_execute_commands ( entity this)

Definition at line 1350 of file scripting.qc.

1351{
1352 int f;
1353 do
1354 {
1355 f = bot_execute_commands_once(this);
1356 }
1357 while(f < 0);
1358 return f;
1359}
float bot_execute_commands_once(entity this)

References bot_execute_commands_once(), and entity().

Referenced by havocbot_ai().

◆ bot_ispaused()

bool bot_ispaused ( entity this)

Definition at line 1003 of file scripting.qc.

1004{
1006}
int bot_exec_status
Definition scripting.qc:480
#define BOT_EXEC_STATUS_PAUSED
Definition scripting.qh:4

References bot_exec_status, BOT_EXEC_STATUS_PAUSED, and entity().

Referenced by bot_relinkplayerlist(), and havocbot_ai().

◆ bot_list_commands()

void bot_list_commands ( )

Definition at line 444 of file scripting.qc.

445{
446 int i;
447 string ptype;
448
451
452 LOG_HELP("Bot commands:");
453
454 for(i=1;i<BOT_CMD_COUNTER;++i)
455 {
456 switch(bot_cmd_parm_type[i])
457 {
459 ptype = "float";
460 break;
462 ptype = "string";
463 break;
465 ptype = "vector";
466 break;
467 default:
468 ptype = "none";
469 break;
470 }
471 if (ptype != "none")
472 LOG_HELP(" ^2", bot_cmd_string[i]," ^7<", ptype, ">");
473 else
474 LOG_HELP(" ^2", bot_cmd_string[i]);
475 }
476 LOG_HELP("For help about a specific command, type bot_cmd help <command>");
477}

◆ bot_queuecommand()

void bot_queuecommand ( entity bot,
string cmdstring )

Definition at line 30 of file scripting.qc.

31{
32 if(!bot.bot_cmdqueuebuf_allocated)
33 {
34 bot.bot_cmdqueuebuf = buf_create();
35 bot.bot_cmdqueuebuf_allocated = true;
36 bot.bot_cmdqueuebuf_start = 0;
37 bot.bot_cmdqueuebuf_end = 0;
38 }
39
40 bufstr_set(bot.bot_cmdqueuebuf, bot.bot_cmdqueuebuf_end, cmdstring);
41
42 // if the command was a "sound" command, precache the sound NOW
43 // this prevents lagging!
44 {
45 float sp;
46 string parm;
47 string cmdstr;
48
49 sp = strstrofs(cmdstring, " ", 0);
50 if(sp >= 0)
51 {
52 parm = substring(cmdstring, sp + 1, -1);
53 cmdstr = substring(cmdstring, 0, sp);
54 if(cmdstr == "sound")
55 {
56 // find the LAST word
57 for (;;)
58 {
59 sp = strstrofs(parm, " ", 0);
60 if(sp < 0)
61 break;
62 parm = substring(parm, sp + 1, -1);
63 }
64 precache_sound(parm);
65 }
66 }
67 }
68
69 bot.bot_cmdqueuebuf_end += 1;
70}
#define strstrofs
#define buf_create
string substring(string s, float start, float length)
string precache_sound(string sample)

◆ bot_resetqueues()

void bot_resetqueues ( )

Definition at line 1165 of file scripting.qc.

1166{
1167 FOREACH_CLIENT(it.isbot, {
1168 it.bot_cmd_execution_index = 0;
1169 bot_clearqueue(it);
1170 // also, cancel all barriers
1171 it.bot_barrier = 0;
1172 for(int i = 0; i < it.bot_places_count; ++i)
1173 {
1174 strfree(it.(bot_placenames[i]));
1175 }
1176 it.bot_places_count = 0;
1177 });
1178
1180}
float time
float bot_barriertime
Definition scripting.qh:68
#define FOREACH_CLIENT(cond, body)
Definition utils.qh:50

◆ find_bot_by_name()

entity find_bot_by_name ( string name)

Definition at line 235 of file scripting.qc.

236{
237 FOREACH_CLIENT(IS_BOT_CLIENT(it) && it.netname == name,
238 {
239 return it;
240 });
241
242 return NULL;
243}
string name
Definition menu.qh:30
#define NULL
Definition post.qh:14
#define IS_BOT_CLIENT(v)
want: (IS_CLIENT(v) && !IS_REAL_CLIENT(v))
Definition utils.qh:15

◆ find_bot_by_number()

entity find_bot_by_number ( float number)

Definition at line 246 of file scripting.qc.

247{
248 entity bot;
249 float c = 0;
250
251 if(!number)
252 return NULL;
253
254 bot = findchainflags(flags, FL_CLIENT); // TODO: doesn't findchainflags loop backwards through entities?
255 while (bot)
256 {
257 if(IS_BOT_CLIENT(bot))
258 {
259 if(++c==number)
260 return bot;
261 }
262 bot = bot.chain;
263 }
264
265 return NULL;
266}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
const int FL_CLIENT
Definition constants.qh:72
float flags
entity findchainflags(.float field, float match)
int int number
Definition impulse.qc:89

◆ float() [1/2]

float ( entity )

References entity().

◆ float() [2/2]

float ( entity ,
vector  )

References entity(), and vector.

Variable Documentation

◆ bot_barrier

float bot_barrier

Definition at line 69 of file scripting.qh.

Referenced by bot_cmd_barrier().

◆ bot_barriertime

float bot_barriertime

Definition at line 68 of file scripting.qh.

Referenced by bot_cmd_barrier(), and bot_cmd_wait_until().

◆ bot_cmd

◆ BOT_CMD_AIM

const int BOT_CMD_AIM = 12

Definition at line 25 of file scripting.qh.

Referenced by bot_cmdhelp(), bot_commands_init(), and bot_execute_commands_once().

◆ BOT_CMD_AIMTARGET

const int BOT_CMD_AIMTARGET = 19

Definition at line 32 of file scripting.qh.

Referenced by bot_cmdhelp(), bot_commands_init(), and bot_execute_commands_once().

◆ BOT_CMD_BARRIER

const int BOT_CMD_BARRIER = 20

Definition at line 33 of file scripting.qh.

Referenced by bot_cmdhelp(), bot_commands_init(), and bot_execute_commands_once().

◆ BOT_CMD_CC

const int BOT_CMD_CC = 7

Definition at line 20 of file scripting.qh.

Referenced by bot_cmdhelp(), bot_commands_init(), and bot_execute_commands_once().

◆ BOT_CMD_CONSOLE

const int BOT_CMD_CONSOLE = 21

Definition at line 34 of file scripting.qh.

Referenced by bot_commands_init(), and bot_execute_commands_once().

◆ BOT_CMD_CONTINUE

const int BOT_CMD_CONTINUE = 2

Definition at line 15 of file scripting.qh.

Referenced by bot_cmdhelp(), bot_commands_init(), and bot_execute_commands_once().

◆ BOT_CMD_COUNTER

const int BOT_CMD_COUNTER = 24

Definition at line 41 of file scripting.qh.

Referenced by bot_cmdhelp(), bot_decodecommand(), and bot_list_commands().

◆ bot_cmd_current

entity bot_cmd_current

Definition at line 60 of file scripting.qh.

Referenced by bot_clientdisconnect(), and bot_setcurrentcommand().

◆ BOT_CMD_DEBUG_ASSERT_CANFIRE

const int BOT_CMD_DEBUG_ASSERT_CANFIRE = 23

Definition at line 36 of file scripting.qh.

Referenced by bot_cmdhelp(), bot_commands_init(), and bot_execute_commands_once().

◆ BOT_CMD_ELSE

const int BOT_CMD_ELSE = 9

Definition at line 22 of file scripting.qh.

Referenced by bot_commands_init(), and bot_execute_commands_once().

◆ bot_cmd_execution_index

float bot_cmd_execution_index

Definition at line 71 of file scripting.qh.

Referenced by bot_command_executed(), and bot_setcurrentcommand().

◆ BOT_CMD_FI

const int BOT_CMD_FI = 10

Definition at line 23 of file scripting.qh.

Referenced by bot_commands_init(), and bot_execute_commands_once().

◆ BOT_CMD_IF

const int BOT_CMD_IF = 8

Definition at line 21 of file scripting.qh.

Referenced by bot_cmdhelp(), bot_commands_init(), and bot_execute_commands_once().

◆ BOT_CMD_IMPULSE

const int BOT_CMD_IMPULSE = 16

Definition at line 29 of file scripting.qh.

Referenced by bot_commands_init(), and bot_execute_commands_once().

◆ bot_cmd_index

float bot_cmd_index

Definition at line 62 of file scripting.qh.

◆ BOT_CMD_MOVETO

const int BOT_CMD_MOVETO = 5

Definition at line 18 of file scripting.qh.

Referenced by bot_cmdhelp(), bot_commands_init(), and bot_execute_commands_once().

◆ BOT_CMD_MOVETOTARGET

const int BOT_CMD_MOVETOTARGET = 18

Definition at line 31 of file scripting.qh.

Referenced by bot_cmdhelp(), bot_commands_init(), and bot_execute_commands_once().

◆ BOT_CMD_NULL

const int BOT_CMD_NULL = 0

Definition at line 13 of file scripting.qh.

Referenced by bot_commands_init(), and bot_execute_commands_once().

◆ BOT_CMD_PARAMETER_FLOAT

const int BOT_CMD_PARAMETER_FLOAT = 1

◆ BOT_CMD_PARAMETER_NONE

const int BOT_CMD_PARAMETER_NONE = 0

Definition at line 49 of file scripting.qh.

Referenced by bot_commands_init(), and bot_decodecommand().

◆ BOT_CMD_PARAMETER_STRING

const int BOT_CMD_PARAMETER_STRING = 2

◆ BOT_CMD_PARAMETER_VECTOR

const int BOT_CMD_PARAMETER_VECTOR = 3

◆ bot_cmd_parm_float

float bot_cmd_parm_float

Definition at line 64 of file scripting.qh.

◆ bot_cmd_parm_string

string bot_cmd_parm_string

Definition at line 65 of file scripting.qh.

◆ bot_cmd_parm_type

◆ bot_cmd_parm_vector

vector bot_cmd_parm_vector

Definition at line 66 of file scripting.qh.

◆ BOT_CMD_PAUSE

const int BOT_CMD_PAUSE = 1

Definition at line 14 of file scripting.qh.

Referenced by bot_cmdhelp(), bot_commands_init(), and bot_execute_commands_once().

◆ BOT_CMD_PRESSKEY

const int BOT_CMD_PRESSKEY = 13

Definition at line 26 of file scripting.qh.

Referenced by bot_cmdhelp(), bot_commands_init(), and bot_execute_commands_once().

◆ BOT_CMD_RELEASEKEY

const int BOT_CMD_RELEASEKEY = 14

Definition at line 27 of file scripting.qh.

Referenced by bot_cmdhelp(), bot_commands_init(), and bot_execute_commands_once().

◆ BOT_CMD_RESETAIM

const int BOT_CMD_RESETAIM = 11

Definition at line 24 of file scripting.qh.

Referenced by bot_cmdhelp(), bot_commands_init(), and bot_execute_commands_once().

◆ BOT_CMD_RESETGOAL

const int BOT_CMD_RESETGOAL = 6

Definition at line 19 of file scripting.qh.

Referenced by bot_cmdhelp(), bot_commands_init(), and bot_execute_commands_once().

◆ BOT_CMD_SELECTWEAPON

const int BOT_CMD_SELECTWEAPON = 15

Definition at line 28 of file scripting.qh.

Referenced by bot_commands_init(), and bot_execute_commands_once().

◆ BOT_CMD_SOUND

const int BOT_CMD_SOUND = 22

Definition at line 35 of file scripting.qh.

Referenced by bot_cmdhelp(), bot_commands_init(), and bot_execute_commands_once().

◆ bot_cmd_string

◆ BOT_CMD_TURN

const int BOT_CMD_TURN = 4

Definition at line 17 of file scripting.qh.

Referenced by bot_cmdhelp(), bot_commands_init(), and bot_execute_commands_once().

◆ bot_cmd_type

int bot_cmd_type

Definition at line 63 of file scripting.qh.

◆ BOT_CMD_WAIT

const int BOT_CMD_WAIT = 3

Definition at line 16 of file scripting.qh.

Referenced by bot_cmdhelp(), bot_commands_init(), and bot_execute_commands_once().

◆ BOT_CMD_WAIT_UNTIL

const int BOT_CMD_WAIT_UNTIL = 17

Definition at line 30 of file scripting.qh.

Referenced by bot_cmdhelp(), bot_commands_init(), and bot_execute_commands_once().

◆ bot_cmds_initialized

float bot_cmds_initialized

Definition at line 54 of file scripting.qh.

Referenced by bot_cmdhelp(), bot_commands_init(), bot_decodecommand(), and bot_list_commands().