Debian Codegraph @

code/game/ai_cmd.c

raw ◀ ▶
1 Debian patch touch this file
1 /*
2 ===========================================================================
3 Copyright (C) 1999-2005 Id Software, Inc.
4
5 This file is part of Quake III Arena source code.
6
7 Quake III Arena source code is free software; you can redistribute it
8 and/or modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2 of the License,
10 or (at your option) any later version.
11
12 Quake III Arena source code is distributed in the hope that it will be
13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Quake III Arena source code; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 ===========================================================================
21 */
22 //
23
24 /*****************************************************************************
25 * name: ai_cmd.c
26 *
27 * desc: Quake3 bot AI
28 *
29 * $Archive: /MissionPack/code/game/ai_cmd.c $
30 *
31 *****************************************************************************/
32
33 #include "g_local.h"
34 #include "../botlib/botlib.h"
35 #include "../botlib/be_aas.h"
36 #include "../botlib/be_ea.h"
37 #include "../botlib/be_ai_char.h"
38 #include "../botlib/be_ai_chat.h"
39 #include "../botlib/be_ai_gen.h"
40 #include "../botlib/be_ai_goal.h"
41 #include "../botlib/be_ai_move.h"
42 #include "../botlib/be_ai_weap.h"
43 //
44 #include "ai_main.h"
45 #include "ai_dmq3.h"
46 #include "ai_chat.h"
47 #include "ai_cmd.h"
48 #include "ai_dmnet.h"
49 #include "ai_team.h"
50 //
51 #include "chars.h" //characteristics
52 #include "inv.h" //indexes into the inventory
53 #include "syn.h" //synonyms
54 #include "match.h" //string matching types and vars
55
56 // for the voice chats
57 #include "../../ui/menudef.h"
58
59 int notleader[MAX_CLIENTS];
60
61 #ifdef DEBUG
62 /*
63 ==================
64 BotPrintTeamGoal
65 ==================
66 */
67 void BotPrintTeamGoal(bot_state_t *bs) {
68 char netname[MAX_NETNAME];
69 float t;
70
71 ClientName(bs->client, netname, sizeof(netname));
72 t = bs->teamgoal_time - FloatTime();
73 switch(bs->ltgtype) {
74 case LTG_TEAMHELP:
75 {
76 BotAI_Print(PRT_MESSAGE, "%s: I'm gonna help a team mate for %1.0f secs\n", netname, t);
77 break;
78 }
79 case LTG_TEAMACCOMPANY:
80 {
81 BotAI_Print(PRT_MESSAGE, "%s: I'm gonna accompany a team mate for %1.0f secs\n", netname, t);
82 break;
83 }
84 case LTG_GETFLAG:
85 {
86 BotAI_Print(PRT_MESSAGE, "%s: I'm gonna get the flag for %1.0f secs\n", netname, t);
87 break;
88 }
89 case LTG_RUSHBASE:
90 {
91 BotAI_Print(PRT_MESSAGE, "%s: I'm gonna rush to the base for %1.0f secs\n", netname, t);
92 break;
93 }
94 case LTG_RETURNFLAG:
95 {
96 BotAI_Print(PRT_MESSAGE, "%s: I'm gonna try to return the flag for %1.0f secs\n", netname, t);
97 break;
98 }
99 case LTG_ATTACKENEMYBASE:
100 {
101 BotAI_Print(PRT_MESSAGE, "%s: I'm gonna attack the enemy base for %1.0f secs\n", netname, t);
102 break;
103 }
104 case LTG_HARVEST:
105 {
106 BotAI_Print(PRT_MESSAGE, "%s: I'm gonna harvest for %1.0f secs\n", netname, t);
107 break;
108 }
109 case LTG_DEFENDKEYAREA:
110 {
111 BotAI_Print(PRT_MESSAGE, "%s: I'm gonna defend a key area for %1.0f secs\n", netname, t);
112 break;
113 }
114 case LTG_GETITEM:
115 {
116 BotAI_Print(PRT_MESSAGE, "%s: I'm gonna get an item for %1.0f secs\n", netname, t);
117 break;
118 }
119 case LTG_KILL:
120 {
121 BotAI_Print(PRT_MESSAGE, "%s: I'm gonna kill someone for %1.0f secs\n", netname, t);
122 break;
123 }
124 case LTG_CAMP:
125 case LTG_CAMPORDER:
126 {
127 BotAI_Print(PRT_MESSAGE, "%s: I'm gonna camp for %1.0f secs\n", netname, t);
128 break;
129 }
130 case LTG_PATROL:
131 {
132 BotAI_Print(PRT_MESSAGE, "%s: I'm gonna patrol for %1.0f secs\n", netname, t);
133 break;
134 }
135 case LTG_POINTA:
136 {
137 BotAI_Print(PRT_MESSAGE, "%s: I'm gonna take care of point A for %1.0f secs\n", netname, t);
138 break;
139 }
140 case LTG_POINTB:
141 {
142 BotAI_Print(PRT_MESSAGE, "%s: I'm gonna take care of point B for %1.0f secs\n", netname, t);
143 break;
144 }
145 default:
146 {
147 if (bs->ctfroam_time > FloatTime()) {
148 t = bs->ctfroam_time - FloatTime();
149 BotAI_Print(PRT_MESSAGE, "%s: I'm gonna roam for %1.0f secs\n", netname, t);
150 }
151 else {
152 BotAI_Print(PRT_MESSAGE, "%s: I've got a regular goal\n", netname);
153 }
154 }
155 }
156 }
157 #endif //DEBUG
158
159 /*
160 ==================
161 BotGetItemTeamGoal
162
163 FIXME: add stuff like "upper rocket launcher"
164 "the rl near the railgun", "lower grenade launcher" etc.
165 ==================
166 */
167 int BotGetItemTeamGoal(char *goalname, bot_goal_t *goal) {
168 int i;
169
170 if (!strlen(goalname)) return qfalse;
171 i = -1;
172 do {
173 i = trap_BotGetLevelItemGoal(i, goalname, goal);
174 if (i > 0) {
175 //do NOT defend dropped items
176 if (goal->flags & GFL_DROPPED)
177 continue;
178 return qtrue;
179 }
180 } while(i > 0);
181 return qfalse;
182 }
183
184 /*
185 ==================
186 BotGetMessageTeamGoal
187 ==================
188 */
189 int BotGetMessageTeamGoal(bot_state_t *bs, char *goalname, bot_goal_t *goal) {
190 bot_waypoint_t *cp;
191
192 if (BotGetItemTeamGoal(goalname, goal)) return qtrue;
193
194 cp = BotFindWayPoint(bs->checkpoints, goalname);
195 if (cp) {
196 memcpy(goal, &cp->goal, sizeof(bot_goal_t));
197 return qtrue;
198 }
199 return qfalse;
200 }
201
202 /*
203 ==================
204 BotGetTime
205 ==================
206 */
207 float BotGetTime(bot_match_t *match) {
208 bot_match_t timematch;
209 char timestring[MAX_MESSAGE_SIZE];
210 float t;
211
212 //if the matched string has a time
213 if (match->subtype & ST_TIME) {
214 //get the time string
215 trap_BotMatchVariable(match, TIME, timestring, MAX_MESSAGE_SIZE);
216 //match it to find out if the time is in seconds or minutes
217 if (trap_BotFindMatch(timestring, &timematch, MTCONTEXT_TIME)) {
218 if (timematch.type == MSG_FOREVER) {
219 t = 99999999.0f;
220 }
221 else if (timematch.type == MSG_FORAWHILE) {
222 t = 10 * 60; // 10 minutes
223 }
224 else if (timematch.type == MSG_FORALONGTIME) {
225 t = 30 * 60; // 30 minutes
226 }
227 else {
228 trap_BotMatchVariable(&timematch, TIME, timestring, MAX_MESSAGE_SIZE);
229 if (timematch.type == MSG_MINUTES) t = atof(timestring) * 60;
230 else if (timematch.type == MSG_SECONDS) t = atof(timestring);
231 else t = 0;
232 }
233 //if there's a valid time
234 if (t > 0) return FloatTime() + t;
235 }
236 }
237 return 0;
238 }
239
240 /*
241 ==================
242 FindClientByName
243 ==================
244 */
245 int FindClientByName(char *name) {
246 int i;
247 char buf[MAX_INFO_STRING];
248 static int maxclients;
249
250 if (!maxclients)
251 maxclients = trap_Cvar_VariableIntegerValue("sv_maxclients");
252 for (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {
253 ClientName(i, buf, sizeof(buf));
254 if (!Q_stricmp(buf, name)) return i;
255 }
256 for (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {
257 ClientName(i, buf, sizeof(buf));
258 if (stristr(buf, name)) return i;
259 }
260 return -1;
261 }
262
263 /*
264 ==================
265 FindEnemyByName
266 ==================
267 */
268 int FindEnemyByName(bot_state_t *bs, char *name) {
269 int i;
270 char buf[MAX_INFO_STRING];
271 static int maxclients;
272
273 if (!maxclients)
274 maxclients = trap_Cvar_VariableIntegerValue("sv_maxclients");
275 for (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {
276 if (BotSameTeam(bs, i)) continue;
277 ClientName(i, buf, sizeof(buf));
278 if (!Q_stricmp(buf, name)) return i;
279 }
280 for (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {
281 if (BotSameTeam(bs, i)) continue;
282 ClientName(i, buf, sizeof(buf));
283 if (stristr(buf, name)) return i;
284 }
285 return -1;
286 }
287
288 /*
289 ==================
290 NumPlayersOnSameTeam
291 ==================
292 */
293 int NumPlayersOnSameTeam(bot_state_t *bs) {
294 int i, num;
295 char buf[MAX_INFO_STRING];
296 static int maxclients;
297
298 if (!maxclients)
299 maxclients = trap_Cvar_VariableIntegerValue("sv_maxclients");
300
301 num = 0;
302 for (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {
303 trap_GetConfigstring(CS_PLAYERS+i, buf, MAX_INFO_STRING);
304 if (strlen(buf)) {
305 if (BotSameTeam(bs, i+1)) num++;
306 }
307 }
308 return num;
309 }
310
311 /*
312 ==================
313 TeamPlayIsOn
314 ==================
315 */
316 int BotGetPatrolWaypoints(bot_state_t *bs, bot_match_t *match) {
317 char keyarea[MAX_MESSAGE_SIZE];
318 int patrolflags;
319 bot_waypoint_t *wp, *newwp, *newpatrolpoints;
320 bot_match_t keyareamatch;
321 bot_goal_t goal;
322
323 newpatrolpoints = NULL;
324 patrolflags = 0;
325 //
326 trap_BotMatchVariable(match, KEYAREA, keyarea, MAX_MESSAGE_SIZE);
327 //
328 while(1) {
329 if (!trap_BotFindMatch(keyarea, &keyareamatch, MTCONTEXT_PATROLKEYAREA)) {
330 trap_EA_SayTeam(bs->client, "what do you say?");
331 BotFreeWaypoints(newpatrolpoints);
332 bs->patrolpoints = NULL;
333 return qfalse;
334 }
335 trap_BotMatchVariable(&keyareamatch, KEYAREA, keyarea, MAX_MESSAGE_SIZE);
336 if (!BotGetMessageTeamGoal(bs, keyarea, &goal)) {
337 //BotAI_BotInitialChat(bs, "cannotfind", keyarea, NULL);
338 //trap_BotEnterChat(bs->cs, 0, CHAT_TEAM);
339 BotFreeWaypoints(newpatrolpoints);
340 bs->patrolpoints = NULL;
341 return qfalse;
342 }
343 //create a new waypoint
344 newwp = BotCreateWayPoint(keyarea, goal.origin, goal.areanum);
345 if (!newwp)
346 break;
347 //add the waypoint to the patrol points
348 newwp->next = NULL;
349 for (wp = newpatrolpoints; wp && wp->next; wp = wp->next);
350 if (!wp) {
351 newpatrolpoints = newwp;
352 newwp->prev = NULL;
353 }
354 else {
355 wp->next = newwp;
356 newwp->prev = wp;
357 }
358 //
359 if (keyareamatch.subtype & ST_BACK) {
360 patrolflags = PATROL_LOOP;
361 break;
362 }
363 else if (keyareamatch.subtype & ST_REVERSE) {
364 patrolflags = PATROL_REVERSE;
365 break;
366 }
367 else if (keyareamatch.subtype & ST_MORE) {
368 trap_BotMatchVariable(&keyareamatch, MORE, keyarea, MAX_MESSAGE_SIZE);
369 }
370 else {
371 break;
372 }
373 }
374 //
375 if (!newpatrolpoints || !newpatrolpoints->next) {
376 trap_EA_SayTeam(bs->client, "I need more key points to patrol\n");
377 BotFreeWaypoints(newpatrolpoints);
378 newpatrolpoints = NULL;
379 return qfalse;
380 }
381 //
382 BotFreeWaypoints(bs->patrolpoints);
383 bs->patrolpoints = newpatrolpoints;
384 //
385 bs->curpatrolpoint = bs->patrolpoints;
386 bs->patrolflags = patrolflags;
387 //
388 return qtrue;
389 }
390
391 /*
392 ==================
393 BotAddressedToBot
394 ==================
395 */
396 int BotAddressedToBot(bot_state_t *bs, bot_match_t *match) {
397 char addressedto[MAX_MESSAGE_SIZE];
398 char netname[MAX_MESSAGE_SIZE];
399 char name[MAX_MESSAGE_SIZE];
400 char botname[128];
401 int client;
402 bot_match_t addresseematch;
403
404 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
405 client = ClientOnSameTeamFromName(bs, netname);
406 if (client < 0) return qfalse;
407 //if the message is addressed to someone
408 if (match->subtype & ST_ADDRESSED) {
409 trap_BotMatchVariable(match, ADDRESSEE, addressedto, sizeof(addressedto));
410 //the name of this bot
411 ClientName(bs->client, botname, 128);
412 //
413 while(trap_BotFindMatch(addressedto, &addresseematch, MTCONTEXT_ADDRESSEE)) {
414 if (addresseematch.type == MSG_EVERYONE) {
415 return qtrue;
416 }
417 else if (addresseematch.type == MSG_MULTIPLENAMES) {
418 trap_BotMatchVariable(&addresseematch, TEAMMATE, name, sizeof(name));
419 if (strlen(name)) {
420 if (stristr(botname, name)) return qtrue;
421 if (stristr(bs->subteam, name)) return qtrue;
422 }
423 trap_BotMatchVariable(&addresseematch, MORE, addressedto, MAX_MESSAGE_SIZE);
424 }
425 else {
426 trap_BotMatchVariable(&addresseematch, TEAMMATE, name, MAX_MESSAGE_SIZE);
427 if (strlen(name)) {
428 if (stristr(botname, name)) return qtrue;
429 if (stristr(bs->subteam, name)) return qtrue;
430 }
431 break;
432 }
433 }
434 //Com_sprintf(buf, sizeof(buf), "not addressed to me but %s", addressedto);
435 //trap_EA_Say(bs->client, buf);
436 return qfalse;
437 }
438 else {
439 bot_match_t tellmatch;
440
441 tellmatch.type = 0;
442 //if this message wasn't directed solely to this bot
443 if (!trap_BotFindMatch(match->string, &tellmatch, MTCONTEXT_REPLYCHAT) ||
444 tellmatch.type != MSG_CHATTELL) {
445 //make sure not everyone reacts to this message
446 if (random() > (float ) 1.0 / (NumPlayersOnSameTeam(bs)-1)) return qfalse;
447 }
448 }
449 return qtrue;
450 }
451
452 /*
453 ==================
454 BotGPSToPosition
455 ==================
456 */
457 int BotGPSToPosition(char *buf, vec3_t position) {
458 int i, j = 0;
459 int num, sign;
460
461 for (i = 0; i < 3; i++) {
462 num = 0;
463 while(buf[j] == ' ') j++;
464 if (buf[j] == '-') {
465 j++;
466 sign = -1;
467 }
468 else {
469 sign = 1;
470 }
471 while (buf[j]) {
472 if (buf[j] >= '0' && buf[j] <= '9') {
473 num = num * 10 + buf[j] - '0';
474 j++;
475 }
476 else {
477 j++;
478 break;
479 }
480 }
481 BotAI_Print(PRT_MESSAGE, "%d\n", sign * num);
482 position[i] = (float) sign * num;
483 }
484 return qtrue;
485 }
486
487 /*
488 ==================
489 BotMatch_HelpAccompany
490 ==================
491 */
492 void BotMatch_HelpAccompany(bot_state_t *bs, bot_match_t *match) {
493 int client, other, areanum;
494 char teammate[MAX_MESSAGE_SIZE];
495 char netname[MAX_MESSAGE_SIZE];
496 char itemname[MAX_MESSAGE_SIZE];
497 bot_match_t teammatematch;
498 aas_entityinfo_t entinfo;
499
500 if (!TeamPlayIsOn()) return;
501 //if not addressed to this bot
502 if (!BotAddressedToBot(bs, match)) return;
503 //get the team mate name
504 trap_BotMatchVariable(match, TEAMMATE, teammate, sizeof(teammate));
505 //get the client to help
506 if (trap_BotFindMatch(teammate, &teammatematch, MTCONTEXT_TEAMMATE) &&
507 //if someone asks for him or herself
508 teammatematch.type == MSG_ME) {
509 //get the netname
510 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
511 client = ClientFromName(netname);
512 other = qfalse;
513 }
514 else {
515 //asked for someone else
516 client = FindClientByName(teammate);
517 //if this is the bot self
518 if (client == bs->client) {
519 other = qfalse;
520 }
521 else if (!BotSameTeam(bs, client)) {
522 //FIXME: say "I don't help the enemy"
523 return;
524 }
525 else {
526 other = qtrue;
527 }
528 }
529 //if the bot doesn't know who to help (FindClientByName returned -1)
530 if (client < 0) {
531 if (other) BotAI_BotInitialChat(bs, "whois", teammate, NULL);
532 else BotAI_BotInitialChat(bs, "whois", netname, NULL);
533 client = ClientFromName(netname);
534 trap_BotEnterChat(bs->cs, client, CHAT_TELL);
535 return;
536 }
537 //don't help or accompany yourself
538 if (client == bs->client) {
539 return;
540 }
541 //
542 bs->teamgoal.entitynum = -1;
543 BotEntityInfo(client, &entinfo);
544 //if info is valid (in PVS)
545 if (entinfo.valid) {
546 areanum = BotPointAreaNum(entinfo.origin);
547 if (areanum) {// && trap_AAS_AreaReachability(areanum)) {
548 bs->teamgoal.entitynum = client;
549 bs->teamgoal.areanum = areanum;
550 VectorCopy(entinfo.origin, bs->teamgoal.origin);
551 VectorSet(bs->teamgoal.mins, -8, -8, -8);
552 VectorSet(bs->teamgoal.maxs, 8, 8, 8);
553 }
554 }
555 //if no teamgoal yet
556 if (bs->teamgoal.entitynum < 0) {
557 //if near an item
558 if (match->subtype & ST_NEARITEM) {
559 //get the match variable
560 trap_BotMatchVariable(match, ITEM, itemname, sizeof(itemname));
561 //
562 if (!BotGetMessageTeamGoal(bs, itemname, &bs->teamgoal)) {
563 //BotAI_BotInitialChat(bs, "cannotfind", itemname, NULL);
564 //trap_BotEnterChat(bs->cs, bs->client, CHAT_TEAM);
565 return;
566 }
567 }
568 }
569 //
570 if (bs->teamgoal.entitynum < 0) {
571 if (other) BotAI_BotInitialChat(bs, "whereis", teammate, NULL);
572 else BotAI_BotInitialChat(bs, "whereareyou", netname, NULL);
573 client = ClientFromName(netname);
574 trap_BotEnterChat(bs->cs, client, CHAT_TEAM);
575 return;
576 }
577 //the team mate
578 bs->teammate = client;
579 //
580 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
581 //
582 client = ClientFromName(netname);
583 //the team mate who ordered
584 bs->decisionmaker = client;
585 bs->ordered = qtrue;
586 bs->order_time = FloatTime();
587 //last time the team mate was assumed visible
588 bs->teammatevisible_time = FloatTime();
589 //set the time to send a message to the team mates
590 bs->teammessage_time = FloatTime() + 2 * random();
591 //get the team goal time
592 bs->teamgoal_time = BotGetTime(match);
593 //set the ltg type
594 if (match->type == MSG_HELP) {
595 bs->ltgtype = LTG_TEAMHELP;
596 if (!bs->teamgoal_time) bs->teamgoal_time = FloatTime() + TEAM_HELP_TIME;
597 }
598 else {
599 bs->ltgtype = LTG_TEAMACCOMPANY;
600 if (!bs->teamgoal_time) bs->teamgoal_time = FloatTime() + TEAM_ACCOMPANY_TIME;
601 bs->formation_dist = 3.5 * 32; //3.5 meter
602 bs->arrive_time = 0;
603 //
604 BotSetTeamStatus(bs);
605 // remember last ordered task
606 BotRememberLastOrderedTask(bs);
607 }
608 #ifdef DEBUG
609 BotPrintTeamGoal(bs);
610 #endif //DEBUG
611 }
612
613 /*
614 ==================
615 BotMatch_DefendKeyArea
616 ==================
617 */
618 void BotMatch_DefendKeyArea(bot_state_t *bs, bot_match_t *match) {
619 char itemname[MAX_MESSAGE_SIZE];
620 char netname[MAX_MESSAGE_SIZE];
621 int client;
622
623 if (!TeamPlayIsOn()) return;
624 //if not addressed to this bot
625 if (!BotAddressedToBot(bs, match)) return;
626 //get the match variable
627 trap_BotMatchVariable(match, KEYAREA, itemname, sizeof(itemname));
628 //
629 if (!BotGetMessageTeamGoal(bs, itemname, &bs->teamgoal)) {
630 //BotAI_BotInitialChat(bs, "cannotfind", itemname, NULL);
631 //trap_BotEnterChat(bs->cs, bs->client, CHAT_TEAM);
632 return;
633 }
634 //
635 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
636 //
637 client = ClientFromName(netname);
638 //the team mate who ordered
639 bs->decisionmaker = client;
640 bs->ordered = qtrue;
641 bs->order_time = FloatTime();
642 //set the time to send a message to the team mates
643 bs->teammessage_time = FloatTime() + 2 * random();
644 //set the ltg type
645 bs->ltgtype = LTG_DEFENDKEYAREA;
646 //get the team goal time
647 bs->teamgoal_time = BotGetTime(match);
648 //set the team goal time
649 if (!bs->teamgoal_time) bs->teamgoal_time = FloatTime() + TEAM_DEFENDKEYAREA_TIME;
650 //away from defending
651 bs->defendaway_time = 0;
652 //
653 BotSetTeamStatus(bs);
654 // remember last ordered task
655 BotRememberLastOrderedTask(bs);
656 #ifdef DEBUG
657 BotPrintTeamGoal(bs);
658 #endif //DEBUG
659 }
660
661 /*
662 ==================
663 BotMatch_TakeA
664 For Double Domination
665 ==================
666 */
667 void BotMatch_TakeA(bot_state_t *bs, bot_match_t *match) {
668 // char itemname[MAX_MESSAGE_SIZE];
669 char netname[MAX_MESSAGE_SIZE];
670 int client;
671
672 if (!TeamPlayIsOn()) return;
673 //if not addressed to this bot
674 if (!BotAddressedToBot(bs, match)) return;
675 //get the match variable
676 /*trap_BotMatchVariable(match, KEYAREA, itemname, sizeof(itemname));
677 //
678 if (!BotGetMessageTeamGoal(bs, itemname, &bs->teamgoal)) {
679 //BotAI_BotInitialChat(bs, "cannotfind", itemname, NULL);
680 //trap_BotEnterChat(bs->cs, bs->client, CHAT_TEAM);
681 return;
682 }*/
683 //
684 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
685 //
686 client = ClientFromName(netname);
687 //the team mate who ordered
688 bs->decisionmaker = client;
689 bs->ordered = qtrue;
690 bs->order_time = FloatTime();
691 //set the time to send a message to the team mates
692 bs->teammessage_time = FloatTime() + 2 * random();
693 //set the ltg type
694 bs->ltgtype = LTG_POINTA;
695 //get the team goal time
696 bs->teamgoal_time = BotGetTime(match);
697 //set the team goal time
698 if (!bs->teamgoal_time) bs->teamgoal_time = FloatTime() + DD_POINTA;
699 //away from defending
700 bs->defendaway_time = 0;
701 //
702 BotSetTeamStatus(bs);
703 // remember last ordered task
704 BotRememberLastOrderedTask(bs);
705 #ifdef DEBUG
706 BotPrintTeamGoal(bs);
707 #endif //DEBUG
708 }
709
710 /*
711 ==================
712 BotMatch_TakeB
713 For Double Domination
714 ==================
715 */
716 void BotMatch_TakeB(bot_state_t *bs, bot_match_t *match) {
717 // char itemname[MAX_MESSAGE_SIZE];
718 char netname[MAX_MESSAGE_SIZE];
719 int client;
720
721 if (!TeamPlayIsOn()) return;
722 //if not addressed to this bot
723 if (!BotAddressedToBot(bs, match)) return;
724 //get the match variable
725 /*trap_BotMatchVariable(match, KEYAREA, itemname, sizeof(itemname));
726 //
727 if (!BotGetMessageTeamGoal(bs, itemname, &bs->teamgoal)) {
728 //BotAI_BotInitialChat(bs, "cannotfind", itemname, NULL);
729 //trap_BotEnterChat(bs->cs, bs->client, CHAT_TEAM);
730 //return;
731 }*/
732 //
733 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
734 //
735 client = ClientFromName(netname);
736 //the team mate who ordered
737 bs->decisionmaker = client;
738 bs->ordered = qtrue;
739 bs->order_time = FloatTime();
740 //set the time to send a message to the team mates
741 bs->teammessage_time = FloatTime() + 2 * random();
742 //set the ltg type
743 bs->ltgtype = LTG_POINTB;
744 //get the team goal time
745 bs->teamgoal_time = BotGetTime(match);
746 //set the team goal time
747 if (!bs->teamgoal_time) bs->teamgoal_time = FloatTime() + DD_POINTA;
748 //away from defending
749 bs->defendaway_time = 0;
750 //
751 BotSetTeamStatus(bs);
752 // remember last ordered task
753 BotRememberLastOrderedTask(bs);
754 #ifdef DEBUG
755 BotPrintTeamGoal(bs);
756 #endif //DEBUG
757 }
758
759 /*
760 ==================
761 BotMatch_GetItem
762 ==================
763 */
764 void BotMatch_GetItem(bot_state_t *bs, bot_match_t *match) {
765 char itemname[MAX_MESSAGE_SIZE];
766 char netname[MAX_MESSAGE_SIZE];
767 int client;
768
769 if (!TeamPlayIsOn()) return;
770 //if not addressed to this bot
771 if (!BotAddressedToBot(bs, match)) return;
772 //get the match variable
773 trap_BotMatchVariable(match, ITEM, itemname, sizeof(itemname));
774 //
775 if (!BotGetMessageTeamGoal(bs, itemname, &bs->teamgoal)) {
776 //BotAI_BotInitialChat(bs, "cannotfind", itemname, NULL);
777 //trap_BotEnterChat(bs->cs, bs->client, CHAT_TEAM);
778 return;
779 }
780 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
781 client = ClientOnSameTeamFromName(bs, netname);
782 //
783 bs->decisionmaker = client;
784 bs->ordered = qtrue;
785 bs->order_time = FloatTime();
786 //set the time to send a message to the team mates
787 bs->teammessage_time = FloatTime() + 2 * random();
788 //set the ltg type
789 bs->ltgtype = LTG_GETITEM;
790 //set the team goal time
791 bs->teamgoal_time = FloatTime() + TEAM_GETITEM_TIME;
792 //
793 BotSetTeamStatus(bs);
794 #ifdef DEBUG
795 BotPrintTeamGoal(bs);
796 #endif //DEBUG
797 }
798
799 /*
800 ==================
801 BotMatch_Camp
802 ==================
803 */
804 void BotMatch_Camp(bot_state_t *bs, bot_match_t *match) {
805 int client, areanum;
806 char netname[MAX_MESSAGE_SIZE];
807 char itemname[MAX_MESSAGE_SIZE];
808 aas_entityinfo_t entinfo;
809
810 if (!TeamPlayIsOn()) return;
811 //if not addressed to this bot
812 if (!BotAddressedToBot(bs, match)) return;
813 //
814 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
815 //asked for someone else
816 client = FindClientByName(netname);
817 //if there's no valid client with this name
818 if (client < 0) {
819 BotAI_BotInitialChat(bs, "whois", netname, NULL);
820 trap_BotEnterChat(bs->cs, bs->client, CHAT_TEAM);
821 return;
822 }
823 //get the match variable
824 trap_BotMatchVariable(match, KEYAREA, itemname, sizeof(itemname));
825 //in CTF it could be the base
826 if (match->subtype & ST_THERE) {
827 //camp at the spot the bot is currently standing
828 bs->teamgoal.entitynum = bs->entitynum;
829 bs->teamgoal.areanum = bs->areanum;
830 VectorCopy(bs->origin, bs->teamgoal.origin);
831 VectorSet(bs->teamgoal.mins, -8, -8, -8);
832 VectorSet(bs->teamgoal.maxs, 8, 8, 8);
833 }
834 else if (match->subtype & ST_HERE) {
835 //if this is the bot self
836 if (client == bs->client) return;
837 //
838 bs->teamgoal.entitynum = -1;
839 BotEntityInfo(client, &entinfo);
840 //if info is valid (in PVS)
841 if (entinfo.valid) {
842 areanum = BotPointAreaNum(entinfo.origin);
843 if (areanum) {// && trap_AAS_AreaReachability(areanum)) {
844 //NOTE: just assume the bot knows where the person is
845 //if (BotEntityVisible(bs->entitynum, bs->eye, bs->viewangles, 360, client)) {
846 bs->teamgoal.entitynum = client;
847 bs->teamgoal.areanum = areanum;
848 VectorCopy(entinfo.origin, bs->teamgoal.origin);
849 VectorSet(bs->teamgoal.mins, -8, -8, -8);
850 VectorSet(bs->teamgoal.maxs, 8, 8, 8);
851 //}
852 }
853 }
854 //if the other is not visible
855 if (bs->teamgoal.entitynum < 0) {
856 BotAI_BotInitialChat(bs, "whereareyou", netname, NULL);
857 client = ClientFromName(netname);
858 trap_BotEnterChat(bs->cs, client, CHAT_TELL);
859 return;
860 }
861 }
862 else if (!BotGetMessageTeamGoal(bs, itemname, &bs->teamgoal)) {
863 //BotAI_BotInitialChat(bs, "cannotfind", itemname, NULL);
864 //client = ClientFromName(netname);
865 //trap_BotEnterChat(bs->cs, client, CHAT_TELL);
866 return;
867 }
868 //
869 bs->decisionmaker = client;
870 bs->ordered = qtrue;
871 bs->order_time = FloatTime();
872 //set the time to send a message to the team mates
873 bs->teammessage_time = FloatTime() + 2 * random();
874 //set the ltg type
875 bs->ltgtype = LTG_CAMPORDER;
876 //get the team goal time
877 bs->teamgoal_time = BotGetTime(match);
878 //set the team goal time
879 if (!bs->teamgoal_time) bs->teamgoal_time = FloatTime() + TEAM_CAMP_TIME;
880 //not arrived yet
881 bs->arrive_time = 0;
882 //
883 BotSetTeamStatus(bs);
884 // remember last ordered task
885 BotRememberLastOrderedTask(bs);
886 #ifdef DEBUG
887 BotPrintTeamGoal(bs);
888 #endif //DEBUG
889 }
890
891 /*
892 ==================
893 BotMatch_Patrol
894 ==================
895 */
896 void BotMatch_Patrol(bot_state_t *bs, bot_match_t *match) {
897 char netname[MAX_MESSAGE_SIZE];
898 int client;
899
900 if (!TeamPlayIsOn()) return;
901 //if not addressed to this bot
902 if (!BotAddressedToBot(bs, match)) return;
903 //get the patrol waypoints
904 if (!BotGetPatrolWaypoints(bs, match)) return;
905 //
906 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
907 //
908 client = FindClientByName(netname);
909 //
910 bs->decisionmaker = client;
911 bs->ordered = qtrue;
912 bs->order_time = FloatTime();
913 //set the time to send a message to the team mates
914 bs->teammessage_time = FloatTime() + 2 * random();
915 //set the ltg type
916 bs->ltgtype = LTG_PATROL;
917 //get the team goal time
918 bs->teamgoal_time = BotGetTime(match);
919 //set the team goal time if not set already
920 if (!bs->teamgoal_time) bs->teamgoal_time = FloatTime() + TEAM_PATROL_TIME;
921 //
922 BotSetTeamStatus(bs);
923 // remember last ordered task
924 BotRememberLastOrderedTask(bs);
925 #ifdef DEBUG
926 BotPrintTeamGoal(bs);
927 #endif //DEBUG
928 }
929
930 /*
931 ==================
932 BotMatch_GetFlag
933 ==================
934 */
935 void BotMatch_GetFlag(bot_state_t *bs, bot_match_t *match) {
936 char netname[MAX_MESSAGE_SIZE];
937 int client;
938
939 if (gametype == GT_CTF || gametype == GT_CTF_ELIMINATION) {
940 if (!ctf_redflag.areanum || !ctf_blueflag.areanum)
941 return;
942 }
943 else if (gametype == GT_1FCTF) {
944 if (!ctf_neutralflag.areanum || !ctf_redflag.areanum || !ctf_blueflag.areanum)
945 return;
946 }
947 else {
948 return;
949 }
950 //if not addressed to this bot
951 if (!BotAddressedToBot(bs, match)) return;
952 //
953 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
954 //
955 client = FindClientByName(netname);
956 //
957 bs->decisionmaker = client;
958 bs->ordered = qtrue;
959 bs->order_time = FloatTime();
960 //set the time to send a message to the team mates
961 bs->teammessage_time = FloatTime() + 2 * random();
962 //set the ltg type
963 bs->ltgtype = LTG_GETFLAG;
964 //set the team goal time
965 bs->teamgoal_time = FloatTime() + CTF_GETFLAG_TIME;
966 // get an alternate route in ctf
967 if (gametype == GT_CTF || gametype == GT_CTF_ELIMINATION) {
968 //get an alternative route goal towards the enemy base
969 BotGetAlternateRouteGoal(bs, BotOppositeTeam(bs));
970 }
971 //
972 BotSetTeamStatus(bs);
973 // remember last ordered task
974 BotRememberLastOrderedTask(bs);
975 #ifdef DEBUG
976 BotPrintTeamGoal(bs);
977 #endif //DEBUG
978 }
979
980 /*
981 ==================
982 BotMatch_AttackEnemyBase
983 ==================
984 */
985 void BotMatch_AttackEnemyBase(bot_state_t *bs, bot_match_t *match) {
986 char netname[MAX_MESSAGE_SIZE];
987 int client;
988
989 if (gametype == GT_CTF|| gametype == GT_CTF_ELIMINATION) {
990 BotMatch_GetFlag(bs, match);
991 }
992 else if (gametype == GT_1FCTF || gametype == GT_OBELISK || gametype == GT_HARVESTER) {
993 if (!redobelisk.areanum || !blueobelisk.areanum)
994 return;
995 }
996 else {
997 return;
998 }
999 //if not addressed to this bot
1000 if (!BotAddressedToBot(bs, match)) return;
1001 //
1002 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
1003 //
1004 client = FindClientByName(netname);
1005 //
1006 bs->decisionmaker = client;
1007 bs->ordered = qtrue;
1008 bs->order_time = FloatTime();
1009 //set the time to send a message to the team mates
1010 bs->teammessage_time = FloatTime() + 2 * random();
1011 //set the ltg type
1012 bs->ltgtype = LTG_ATTACKENEMYBASE;
1013 //set the team goal time
1014 bs->teamgoal_time = FloatTime() + TEAM_ATTACKENEMYBASE_TIME;
1015 bs->attackaway_time = 0;
1016 //
1017 BotSetTeamStatus(bs);
1018 // remember last ordered task
1019 BotRememberLastOrderedTask(bs);
1020 #ifdef DEBUG
1021 BotPrintTeamGoal(bs);
1022 #endif //DEBUG
1023 }
1024
1025 /*
1026 ==================
1027 BotMatch_Harvest
1028 ==================
1029 */
1030 void BotMatch_Harvest(bot_state_t *bs, bot_match_t *match) {
1031 char netname[MAX_MESSAGE_SIZE];
1032 int client;
1033
1034 if (gametype == GT_HARVESTER) {
1035 if (!neutralobelisk.areanum || !redobelisk.areanum || !blueobelisk.areanum)
1036 return;
1037 }
1038 else {
1039 return;
1040 }
1041 //if not addressed to this bot
1042 if (!BotAddressedToBot(bs, match)) return;
1043 //
1044 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
1045 //
1046 client = FindClientByName(netname);
1047 //
1048 bs->decisionmaker = client;
1049 bs->ordered = qtrue;
1050 bs->order_time = FloatTime();
1051 //set the time to send a message to the team mates
1052 bs->teammessage_time = FloatTime() + 2 * random();
1053 //set the ltg type
1054 bs->ltgtype = LTG_HARVEST;
1055 //set the team goal time
1056 bs->teamgoal_time = FloatTime() + TEAM_HARVEST_TIME;
1057 bs->harvestaway_time = 0;
1058 //
1059 BotSetTeamStatus(bs);
1060 // remember last ordered task
1061 BotRememberLastOrderedTask(bs);
1062 #ifdef DEBUG
1063 BotPrintTeamGoal(bs);
1064 #endif //DEBUG
1065 }
1066
1067 /*
1068 ==================
1069 BotMatch_RushBase
1070 ==================
1071 */
1072 void BotMatch_RushBase(bot_state_t *bs, bot_match_t *match) {
1073 char netname[MAX_MESSAGE_SIZE];
1074 int client;
1075
1076 if (gametype == GT_CTF|| gametype == GT_CTF_ELIMINATION) {
1077 if (!ctf_redflag.areanum || !ctf_blueflag.areanum)
1078 return;
1079 }
1080 else if (gametype == GT_1FCTF || gametype == GT_HARVESTER) {
1081 if (!redobelisk.areanum || !blueobelisk.areanum)
1082 return;
1083 }
1084 else {
1085 return;
1086 }
1087 //if not addressed to this bot
1088 if (!BotAddressedToBot(bs, match)) return;
1089 //
1090 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
1091 //
1092 client = FindClientByName(netname);
1093 //
1094 bs->decisionmaker = client;
1095 bs->ordered = qtrue;
1096 bs->order_time = FloatTime();
1097 //set the time to send a message to the team mates
1098 bs->teammessage_time = FloatTime() + 2 * random();
1099 //set the ltg type
1100 bs->ltgtype = LTG_RUSHBASE;
1101 //set the team goal time
1102 bs->teamgoal_time = FloatTime() + CTF_RUSHBASE_TIME;
1103 bs->rushbaseaway_time = 0;
1104 //
1105 BotSetTeamStatus(bs);
1106 #ifdef DEBUG
1107 BotPrintTeamGoal(bs);
1108 #endif //DEBUG
1109 }
1110
1111 /*
1112 ==================
1113 BotMatch_TaskPreference
1114 ==================
1115 */
1116 void BotMatch_TaskPreference(bot_state_t *bs, bot_match_t *match) {
1117 char netname[MAX_NETNAME];
1118 char teammatename[MAX_MESSAGE_SIZE];
1119 int teammate, preference;
1120
1121 ClientName(bs->client, netname, sizeof(netname));
1122 if (Q_stricmp(netname, bs->teamleader) != 0) return;
1123
1124 trap_BotMatchVariable(match, NETNAME, teammatename, sizeof(teammatename));
1125 teammate = ClientFromName(teammatename);
1126 if (teammate < 0) return;
1127
1128 preference = BotGetTeamMateTaskPreference(bs, teammate);
1129 switch(match->subtype)
1130 {
1131 case ST_DEFENDER:
1132 {
1133 preference &= ~TEAMTP_ATTACKER;
1134 preference |= TEAMTP_DEFENDER;
1135 break;
1136 }
1137 case ST_ATTACKER:
1138 {
1139 preference &= ~TEAMTP_DEFENDER;
1140 preference |= TEAMTP_ATTACKER;
1141 break;
1142 }
1143 case ST_ROAMER:
1144 {
1145 preference &= ~(TEAMTP_ATTACKER|TEAMTP_DEFENDER);
1146 break;
1147 }
1148 }
1149 BotSetTeamMateTaskPreference(bs, teammate, preference);
1150 //
1151 EasyClientName(teammate, teammatename, sizeof(teammatename));
1152 BotAI_BotInitialChat(bs, "keepinmind", teammatename, NULL);
1153 trap_BotEnterChat(bs->cs, teammate, CHAT_TELL);
1154 BotVoiceChatOnly(bs, teammate, VOICECHAT_YES);
1155 trap_EA_Action(bs->client, ACTION_AFFIRMATIVE);
1156 }
1157
1158 /*
1159 ==================
1160 BotMatch_ReturnFlag
1161 ==================
1162 */
1163 void BotMatch_ReturnFlag(bot_state_t *bs, bot_match_t *match) {
1164 char netname[MAX_MESSAGE_SIZE];
1165 int client;
1166
1167 //if not in CTF mode
1168 if (gametype != GT_CTF && gametype != GT_CTF_ELIMINATION && gametype != GT_1FCTF)
1169 return;
1170 //if not addressed to this bot
1171 if (!BotAddressedToBot(bs, match))
1172 return;
1173 //
1174 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
1175 //
1176 client = FindClientByName(netname);
1177 //
1178 bs->decisionmaker = client;
1179 bs->ordered = qtrue;
1180 bs->order_time = FloatTime();
1181 //set the time to send a message to the team mates
1182 bs->teammessage_time = FloatTime() + 2 * random();
1183 //set the ltg type
1184 bs->ltgtype = LTG_RETURNFLAG;
1185 //set the team goal time
1186 bs->teamgoal_time = FloatTime() + CTF_RETURNFLAG_TIME;
1187 bs->rushbaseaway_time = 0;
1188 //
1189 BotSetTeamStatus(bs);
1190 #ifdef DEBUG
1191 BotPrintTeamGoal(bs);
1192 #endif //DEBUG
1193 }
1194
1195 /*
1196 ==================
1197 BotMatch_JoinSubteam
1198 ==================
1199 */
1200 void BotMatch_JoinSubteam(bot_state_t *bs, bot_match_t *match) {
1201 char teammate[MAX_MESSAGE_SIZE];
1202 char netname[MAX_MESSAGE_SIZE];
1203 int client;
1204
1205 if (!TeamPlayIsOn()) return;
1206 //if not addressed to this bot
1207 if (!BotAddressedToBot(bs, match)) return;
1208 //get the sub team name
1209 trap_BotMatchVariable(match, TEAMNAME, teammate, sizeof(teammate));
1210 //set the sub team name
•1211 Q_strncpyz(bs->subteam, teammate, 32);
1212 //
1213 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
1214 BotAI_BotInitialChat(bs, "joinedteam", teammate, NULL);
1215 client = ClientFromName(netname);
1216 trap_BotEnterChat(bs->cs, client, CHAT_TELL);
1217 }
1218
1219 /*
1220 ==================
1221 BotMatch_LeaveSubteam
1222 ==================
1223 */
1224 void BotMatch_LeaveSubteam(bot_state_t *bs, bot_match_t *match) {
1225 char netname[MAX_MESSAGE_SIZE];
1226 int client;
1227
1228 if (!TeamPlayIsOn()) return;
1229 //if not addressed to this bot
1230 if (!BotAddressedToBot(bs, match)) return;
1231 //
1232 if (strlen(bs->subteam))
1233 {
1234 BotAI_BotInitialChat(bs, "leftteam", bs->subteam, NULL);
1235 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
1236 client = ClientFromName(netname);
1237 trap_BotEnterChat(bs->cs, client, CHAT_TELL);
1238 } //end if
1239 strcpy(bs->subteam, "");
1240 }
1241
1242 /*
1243 ==================
1244 BotMatch_LeaveSubteam
1245 ==================
1246 */
1247 void BotMatch_WhichTeam(bot_state_t *bs, bot_match_t *match) {
1248 if (!TeamPlayIsOn()) return;
1249 //if not addressed to this bot
1250 if (!BotAddressedToBot(bs, match)) return;
1251
1252 //
1253 if (strlen(bs->subteam)) {
1254 BotAI_BotInitialChat(bs, "inteam", bs->subteam, NULL);
1255 }
1256 else {
1257 BotAI_BotInitialChat(bs, "noteam", NULL);
1258 }
1259 trap_BotEnterChat(bs->cs, bs->client, CHAT_TEAM);
1260 }
1261
1262 /*
1263 ==================
1264 BotMatch_CheckPoint
1265 ==================
1266 */
1267 void BotMatch_CheckPoint(bot_state_t *bs, bot_match_t *match) {
1268 int areanum, client;
1269 char buf[MAX_MESSAGE_SIZE];
1270 char netname[MAX_MESSAGE_SIZE];
1271 vec3_t position;
1272 bot_waypoint_t *cp;
1273
1274 if (!TeamPlayIsOn()) return;
1275 //
1276 trap_BotMatchVariable(match, POSITION, buf, MAX_MESSAGE_SIZE);
1277 VectorClear(position);
1278 //
1279 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
1280 client = ClientFromName(netname);
1281 //BotGPSToPosition(buf, position);
1282 sscanf(buf, "%f %f %f", &position[0], &position[1], &position[2]);
1283 position[2] += 0.5;
1284 areanum = BotPointAreaNum(position);
1285 if (!areanum) {
1286 if (BotAddressedToBot(bs, match)) {
1287 BotAI_BotInitialChat(bs, "checkpoint_invalid", NULL);
1288 trap_BotEnterChat(bs->cs, client, CHAT_TELL);
1289 }
1290 return;
1291 }
1292 //
1293 trap_BotMatchVariable(match, NAME, buf, MAX_MESSAGE_SIZE);
1294 //check if there already exists a checkpoint with this name
1295 cp = BotFindWayPoint(bs->checkpoints, buf);
1296 if (cp) {
1297 if (cp->next) cp->next->prev = cp->prev;
1298 if (cp->prev) cp->prev->next = cp->next;
1299 else bs->checkpoints = cp->next;
1300 cp->inuse = qfalse;
1301 }
1302 //create a new check point
1303 cp = BotCreateWayPoint(buf, position, areanum);
1304 //add the check point to the bot's known chech points
1305 cp->next = bs->checkpoints;
1306 if (bs->checkpoints) bs->checkpoints->prev = cp;
1307 bs->checkpoints = cp;
1308 //
1309 if (BotAddressedToBot(bs, match)) {
1310 Com_sprintf(buf, sizeof(buf), "%1.0f %1.0f %1.0f", cp->goal.origin[0],
1311 cp->goal.origin[1],
1312 cp->goal.origin[2]);
1313
1314 BotAI_BotInitialChat(bs, "checkpoint_confirm", cp->name, buf, NULL);
1315 trap_BotEnterChat(bs->cs, client, CHAT_TELL);
1316 }
1317 }
1318
1319 /*
1320 ==================
1321 BotMatch_FormationSpace
1322 ==================
1323 */
1324 void BotMatch_FormationSpace(bot_state_t *bs, bot_match_t *match) {
1325 char buf[MAX_MESSAGE_SIZE];
1326 float space;
1327
1328 if (!TeamPlayIsOn()) return;
1329 //if not addressed to this bot
1330 if (!BotAddressedToBot(bs, match)) return;
1331 //
1332 trap_BotMatchVariable(match, NUMBER, buf, MAX_MESSAGE_SIZE);
1333 //if it's the distance in feet
1334 if (match->subtype & ST_FEET) space = 0.3048 * 32 * atof(buf);
1335 //else it's in meters
1336 else space = 32 * atof(buf);
1337 //check if the formation intervening space is valid
1338 if (space < 48 || space > 500) space = 100;
1339 bs->formation_dist = space;
1340 }
1341
1342 /*
1343 ==================
1344 BotMatch_Dismiss
1345 ==================
1346 */
1347 void BotMatch_Dismiss(bot_state_t *bs, bot_match_t *match) {
1348 char netname[MAX_MESSAGE_SIZE];
1349 int client;
1350
1351 if (!TeamPlayIsOn()) return;
1352 //if not addressed to this bot
1353 if (!BotAddressedToBot(bs, match)) return;
1354 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
1355 client = ClientFromName(netname);
1356 //
1357 bs->decisionmaker = client;
1358 //
1359 bs->ltgtype = 0;
1360 bs->lead_time = 0;
1361 bs->lastgoal_ltgtype = 0;
1362 //
1363 BotAI_BotInitialChat(bs, "dismissed", NULL);
1364 trap_BotEnterChat(bs->cs, client, CHAT_TELL);
1365 }
1366
1367 /*
1368 ==================
1369 BotMatch_Suicide
1370 ==================
1371 */
1372 void BotMatch_Suicide(bot_state_t *bs, bot_match_t *match) {
1373 char netname[MAX_MESSAGE_SIZE];
1374 int client;
1375
1376 if (!TeamPlayIsOn()) return;
1377 //if not addressed to this bot
1378 if (!BotAddressedToBot(bs, match)) return;
1379 //
1380 trap_EA_Command(bs->client, "kill");
1381 //
1382 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
1383 client = ClientFromName(netname);
1384 //
1385 BotVoiceChat(bs, client, VOICECHAT_TAUNT);
1386 trap_EA_Action(bs->client, ACTION_AFFIRMATIVE);
1387 }
1388
1389 /*
1390 ==================
1391 BotMatch_StartTeamLeaderShip
1392 ==================
1393 */
1394 void BotMatch_StartTeamLeaderShip(bot_state_t *bs, bot_match_t *match) {
1395 int client;
1396 char teammate[MAX_MESSAGE_SIZE];
1397
1398 if (!TeamPlayIsOn()) return;
1399 //if chats for him or herself
1400 if (match->subtype & ST_I) {
1401 //get the team mate that will be the team leader
1402 trap_BotMatchVariable(match, NETNAME, teammate, sizeof(teammate));
•1403 Q_strncpyz(bs->teamleader, teammate, sizeof(bs->teamleader));
1404 }
1405 //chats for someone else
1406 else {
1407 //get the team mate that will be the team leader
1408 trap_BotMatchVariable(match, TEAMMATE, teammate, sizeof(teammate));
1409 client = FindClientByName(teammate);
1410 if (client >= 0) ClientName(client, bs->teamleader, sizeof(bs->teamleader));
1411 }
1412 }
1413
1414 /*
1415 ==================
1416 BotMatch_StopTeamLeaderShip
1417 ==================
1418 */
1419 void BotMatch_StopTeamLeaderShip(bot_state_t *bs, bot_match_t *match) {
1420 int client;
1421 char teammate[MAX_MESSAGE_SIZE];
1422 char netname[MAX_MESSAGE_SIZE];
1423
1424 if (!TeamPlayIsOn()) return;
1425 //get the team mate that stops being the team leader
1426 trap_BotMatchVariable(match, TEAMMATE, teammate, sizeof(teammate));
1427 //if chats for him or herself
1428 if (match->subtype & ST_I) {
1429 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
1430 client = FindClientByName(netname);
1431 }
1432 //chats for someone else
1433 else {
1434 client = FindClientByName(teammate);
1435 } //end else
1436 if (client >= 0) {
1437 if (!Q_stricmp(bs->teamleader, ClientName(client, netname, sizeof(netname)))) {
1438 bs->teamleader[0] = '\0';
1439 notleader[client] = qtrue;
1440 }
1441 }
1442 }
1443
1444 /*
1445 ==================
1446 BotMatch_WhoIsTeamLeader
1447 ==================
1448 */
1449 void BotMatch_WhoIsTeamLeader(bot_state_t *bs, bot_match_t *match) {
1450 char netname[MAX_MESSAGE_SIZE];
1451
1452 if (!TeamPlayIsOn()) return;
1453
1454 ClientName(bs->client, netname, sizeof(netname));
1455 //if this bot IS the team leader
1456 if (!Q_stricmp(netname, bs->teamleader)) {
1457 trap_EA_SayTeam(bs->client, "I'm the team leader\n");
1458 }
1459 }
1460
1461 /*
1462 ==================
1463 BotMatch_WhatAreYouDoing
1464 ==================
1465 */
1466 void BotMatch_WhatAreYouDoing(bot_state_t *bs, bot_match_t *match) {
1467 char netname[MAX_MESSAGE_SIZE];
1468 char goalname[MAX_MESSAGE_SIZE];
1469 int client;
1470
1471 //if not addressed to this bot
1472 if (!BotAddressedToBot(bs, match)) return;
1473 //
1474 switch(bs->ltgtype) {
1475 case LTG_TEAMHELP:
1476 {
1477 EasyClientName(bs->teammate, netname, sizeof(netname));
1478 BotAI_BotInitialChat(bs, "helping", netname, NULL);
1479 break;
1480 }
1481 case LTG_TEAMACCOMPANY:
1482 {
1483 EasyClientName(bs->teammate, netname, sizeof(netname));
1484 BotAI_BotInitialChat(bs, "accompanying", netname, NULL);
1485 break;
1486 }
1487 case LTG_DEFENDKEYAREA:
1488 {
1489 trap_BotGoalName(bs->teamgoal.number, goalname, sizeof(goalname));
1490 BotAI_BotInitialChat(bs, "defending", goalname, NULL);
1491 break;
1492 }
1493 case LTG_GETITEM:
1494 {
1495 trap_BotGoalName(bs->teamgoal.number, goalname, sizeof(goalname));
1496 BotAI_BotInitialChat(bs, "gettingitem", goalname, NULL);
1497 break;
1498 }
1499 case LTG_KILL:
1500 {
1501 ClientName(bs->teamgoal.entitynum, netname, sizeof(netname));
1502 BotAI_BotInitialChat(bs, "killing", netname, NULL);
1503 break;
1504 }
1505 case LTG_CAMP:
1506 case LTG_CAMPORDER:
1507 {
1508 BotAI_BotInitialChat(bs, "camping", NULL);
1509 break;
1510 }
1511 case LTG_PATROL:
1512 {
1513 BotAI_BotInitialChat(bs, "patrolling", NULL);
1514 break;
1515 }
1516 case LTG_GETFLAG:
1517 {
1518 BotAI_BotInitialChat(bs, "capturingflag", NULL);
1519 break;
1520 }
1521 case LTG_RUSHBASE:
1522 {
1523 BotAI_BotInitialChat(bs, "rushingbase", NULL);
1524 break;
1525 }
1526 case LTG_RETURNFLAG:
1527 {
1528 BotAI_BotInitialChat(bs, "returningflag", NULL);
1529 break;
1530 }
1531 case LTG_ATTACKENEMYBASE:
1532 {
1533 BotAI_BotInitialChat(bs, "attackingenemybase", NULL);
1534 break;
1535 }
1536 case LTG_HARVEST:
1537 {
1538 BotAI_BotInitialChat(bs, "harvesting", NULL);
1539 break;
1540 }
1541 //#endif
1542 case LTG_POINTA:
1543 {
1544 BotAI_BotInitialChat(bs, "dd_pointa", NULL);
1545 break;
1546 }
1547 case LTG_POINTB:
1548 {
1549 BotAI_BotInitialChat(bs, "dd_pointb", NULL);
1550 break;
1551 }
1552 default:
1553 {
1554 BotAI_BotInitialChat(bs, "roaming", NULL);
1555 break;
1556 }
1557 }
1558 //chat what the bot is doing
1559 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
1560 client = ClientFromName(netname);
1561 trap_BotEnterChat(bs->cs, client, CHAT_TELL);
1562 }
1563
1564 /*
1565 ==================
1566 BotMatch_WhatIsMyCommand
1567 ==================
1568 */
1569 void BotMatch_WhatIsMyCommand(bot_state_t *bs, bot_match_t *match) {
1570 char netname[MAX_NETNAME];
1571
1572 ClientName(bs->client, netname, sizeof(netname));
1573 if (Q_stricmp(netname, bs->teamleader) != 0) return;
1574 bs->forceorders = qtrue;
1575 }
1576
1577 /*
1578 ==================
1579 BotNearestVisibleItem
1580 ==================
1581 */
1582 float BotNearestVisibleItem(bot_state_t *bs, char *itemname, bot_goal_t *goal) {
1583 int i;
1584 char name[64];
1585 bot_goal_t tmpgoal;
1586 float dist, bestdist;
1587 vec3_t dir;
1588 bsp_trace_t trace;
1589
1590 bestdist = 999999;
1591 i = -1;
1592 do {
1593 i = trap_BotGetLevelItemGoal(i, itemname, &tmpgoal);
1594 trap_BotGoalName(tmpgoal.number, name, sizeof(name));
1595 if (Q_stricmp(itemname, name) != 0)
1596 continue;
1597 VectorSubtract(tmpgoal.origin, bs->origin, dir);
1598 dist = VectorLength(dir);
1599 if (dist < bestdist) {
1600 //trace from start to end
1601 BotAI_Trace(&trace, bs->eye, NULL, NULL, tmpgoal.origin, bs->client, CONTENTS_SOLID|CONTENTS_PLAYERCLIP);
1602 if (trace.fraction >= 1.0) {
1603 bestdist = dist;
1604 memcpy(goal, &tmpgoal, sizeof(bot_goal_t));
1605 }
1606 }
1607 } while(i > 0);
1608 return bestdist;
1609 }
1610
1611 /*
1612 ==================
1613 BotMatch_WhereAreYou
1614 ==================
1615 */
1616 void BotMatch_WhereAreYou(bot_state_t *bs, bot_match_t *match) {
1617 float dist, bestdist;
1618 int i, bestitem, redtt, bluett, client;
1619 bot_goal_t goal;
1620 char netname[MAX_MESSAGE_SIZE];
1621 char *nearbyitems[] = {
1622 "Shotgun",
1623 "Grenade Launcher",
1624 "Rocket Launcher",
1625 "Plasmagun",
1626 "Railgun",
1627 "Lightning Gun",
1628 "BFG10K",
1629 "Quad Damage",
1630 "Regeneration",
1631 "Battle Suit",
1632 "Speed",
1633 "Invisibility",
1634 "Flight",
1635 "Armor",
1636 "Heavy Armor",
1637 "Red Flag",
1638 "Blue Flag",
1639 "Nailgun",
1640 "Prox Launcher",
1641 "Chaingun",
1642 "Scout",
1643 "Guard",
1644 "Doubler",
1645 "Ammo Regen",
1646 "Neutral Flag",
1647 "Red Obelisk",
1648 "Blue Obelisk",
1649 "Neutral Obelisk",
1650 NULL
1651 };
1652 //
1653 if (!TeamPlayIsOn())
1654 return;
1655
1656 //if not addressed to this bot
1657 if (!BotAddressedToBot(bs, match))
1658 return;
1659
1660 bestitem = -1;
1661 bestdist = 999999;
1662 for (i = 0; nearbyitems[i]; i++) {
1663 dist = BotNearestVisibleItem(bs, nearbyitems[i], &goal);
1664 if (dist < bestdist) {
1665 bestdist = dist;
1666 bestitem = i;
1667 }
1668 }
1669 if (bestitem != -1) {
1670 if (gametype == GT_CTF || gametype == GT_CTF_ELIMINATION
1671 || gametype == GT_1FCTF
1672 ) {
1673 redtt = trap_AAS_AreaTravelTimeToGoalArea(bs->areanum, bs->origin, ctf_redflag.areanum, TFL_DEFAULT);
1674 bluett = trap_AAS_AreaTravelTimeToGoalArea(bs->areanum, bs->origin, ctf_blueflag.areanum, TFL_DEFAULT);
1675 if (redtt < (redtt + bluett) * 0.4) {
1676 BotAI_BotInitialChat(bs, "teamlocation", nearbyitems[bestitem], "red", NULL);
1677 }
1678 else if (bluett < (redtt + bluett) * 0.4) {
1679 BotAI_BotInitialChat(bs, "teamlocation", nearbyitems[bestitem], "blue", NULL);
1680 }
1681 else {
1682 BotAI_BotInitialChat(bs, "location", nearbyitems[bestitem], NULL);
1683 }
1684 }
1685 else if (gametype == GT_OBELISK || gametype == GT_HARVESTER) {
1686 redtt = trap_AAS_AreaTravelTimeToGoalArea(bs->areanum, bs->origin, redobelisk.areanum, TFL_DEFAULT);
1687 bluett = trap_AAS_AreaTravelTimeToGoalArea(bs->areanum, bs->origin, blueobelisk.areanum, TFL_DEFAULT);
1688 if (redtt < (redtt + bluett) * 0.4) {
1689 BotAI_BotInitialChat(bs, "teamlocation", nearbyitems[bestitem], "red", NULL);
1690 }
1691 else if (bluett < (redtt + bluett) * 0.4) {
1692 BotAI_BotInitialChat(bs, "teamlocation", nearbyitems[bestitem], "blue", NULL);
1693 }
1694 else {
1695 BotAI_BotInitialChat(bs, "location", nearbyitems[bestitem], NULL);
1696 }
1697 }
1698 else {
1699 BotAI_BotInitialChat(bs, "location", nearbyitems[bestitem], NULL);
1700 }
1701 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
1702 client = ClientFromName(netname);
1703 trap_BotEnterChat(bs->cs, client, CHAT_TELL);
1704 }
1705 }
1706
1707 /*
1708 ==================
1709 BotMatch_LeadTheWay
1710 ==================
1711 */
1712 void BotMatch_LeadTheWay(bot_state_t *bs, bot_match_t *match) {
1713 aas_entityinfo_t entinfo;
1714 char netname[MAX_MESSAGE_SIZE], teammate[MAX_MESSAGE_SIZE];
1715 int client, areanum, other;
1716
1717 if (!TeamPlayIsOn()) return;
1718 //if not addressed to this bot
1719 if (!BotAddressedToBot(bs, match)) return;
1720 //if someone asks for someone else
1721 if (match->subtype & ST_SOMEONE) {
1722 //get the team mate name
1723 trap_BotMatchVariable(match, TEAMMATE, teammate, sizeof(teammate));
1724 client = FindClientByName(teammate);
1725 //if this is the bot self
1726 if (client == bs->client) {
1727 other = qfalse;
1728 }
1729 else if (!BotSameTeam(bs, client)) {
1730 //FIXME: say "I don't help the enemy"
1731 return;
1732 }
1733 else {
1734 other = qtrue;
1735 }
1736 }
1737 else {
1738 //get the netname
1739 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
1740 client = ClientFromName(netname);
1741 other = qfalse;
1742 }
1743 //if the bot doesn't know who to help (FindClientByName returned -1)
1744 if (client < 0) {
1745 BotAI_BotInitialChat(bs, "whois", netname, NULL);
1746 trap_BotEnterChat(bs->cs, bs->client, CHAT_TEAM);
1747 return;
1748 }
1749 //
1750 bs->lead_teamgoal.entitynum = -1;
1751 BotEntityInfo(client, &entinfo);
1752 //if info is valid (in PVS)
1753 if (entinfo.valid) {
1754 areanum = BotPointAreaNum(entinfo.origin);
1755 if (areanum) { // && trap_AAS_AreaReachability(areanum)) {
1756 bs->lead_teamgoal.entitynum = client;
1757 bs->lead_teamgoal.areanum = areanum;
1758 VectorCopy(entinfo.origin, bs->lead_teamgoal.origin);
1759 VectorSet(bs->lead_teamgoal.mins, -8, -8, -8);
1760 VectorSet(bs->lead_teamgoal.maxs, 8, 8, 8);
1761 }
1762 }
1763
1764 if (bs->teamgoal.entitynum < 0) {
1765 if (other) BotAI_BotInitialChat(bs, "whereis", teammate, NULL);
1766 else BotAI_BotInitialChat(bs, "whereareyou", netname, NULL);
1767 trap_BotEnterChat(bs->cs, bs->client, CHAT_TEAM);
1768 return;
1769 }
1770 bs->lead_teammate = client;
1771 bs->lead_time = FloatTime() + TEAM_LEAD_TIME;
1772 bs->leadvisible_time = 0;
1773 bs->leadmessage_time = -(FloatTime() + 2 * random());
1774 }
1775
1776 /*
1777 ==================
1778 BotMatch_Kill
1779 ==================
1780 */
1781 void BotMatch_Kill(bot_state_t *bs, bot_match_t *match) {
1782 char enemy[MAX_MESSAGE_SIZE];
1783 char netname[MAX_MESSAGE_SIZE];
1784 int client;
1785
1786 if (!TeamPlayIsOn()) return;
1787 //if not addressed to this bot
1788 if (!BotAddressedToBot(bs, match)) return;
1789
1790 trap_BotMatchVariable(match, ENEMY, enemy, sizeof(enemy));
1791 //
1792 client = FindEnemyByName(bs, enemy);
1793 if (client < 0) {
1794 BotAI_BotInitialChat(bs, "whois", enemy, NULL);
1795 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
1796 client = ClientFromName(netname);
1797 trap_BotEnterChat(bs->cs, client, CHAT_TELL);
1798 return;
1799 }
1800 bs->teamgoal.entitynum = client;
1801 //set the time to send a message to the team mates
1802 bs->teammessage_time = FloatTime() + 2 * random();
1803 //set the ltg type
1804 bs->ltgtype = LTG_KILL;
1805 //set the team goal time
1806 bs->teamgoal_time = FloatTime() + TEAM_KILL_SOMEONE;
1807 //
1808 BotSetTeamStatus(bs);
1809 #ifdef DEBUG
1810 BotPrintTeamGoal(bs);
1811 #endif //DEBUG
1812 }
1813
1814 /*
1815 ==================
1816 BotMatch_CTF
1817 ==================
1818 */
1819 void BotMatch_CTF(bot_state_t *bs, bot_match_t *match) {
1820
1821 char flag[128], netname[MAX_NETNAME];
1822
1823 if (gametype == GT_CTF || gametype == GT_CTF_ELIMINATION) {
1824 trap_BotMatchVariable(match, FLAG, flag, sizeof(flag));
1825 if (match->subtype & ST_GOTFLAG) {
1826 if (!Q_stricmp(flag, "red")) {
1827 bs->redflagstatus = 1;
1828 if (BotTeam(bs) == TEAM_BLUE) {
1829 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
1830 bs->flagcarrier = ClientFromName(netname);
1831 }
1832 }
1833 else {
1834 bs->blueflagstatus = 1;
1835 if (BotTeam(bs) == TEAM_RED) {
1836 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
1837 bs->flagcarrier = ClientFromName(netname);
1838 }
1839 }
1840 bs->flagstatuschanged = 1;
1841 bs->lastflagcapture_time = FloatTime();
1842 }
1843 else if (match->subtype & ST_CAPTUREDFLAG) {
1844 bs->redflagstatus = 0;
1845 bs->blueflagstatus = 0;
1846 bs->flagcarrier = 0;
1847 bs->flagstatuschanged = 1;
1848 }
1849 else if (match->subtype & ST_RETURNEDFLAG) {
1850 if (!Q_stricmp(flag, "red")) bs->redflagstatus = 0;
1851 else bs->blueflagstatus = 0;
1852 bs->flagstatuschanged = 1;
1853 }
1854 }
1855 else if (gametype == GT_1FCTF) {
1856 if (match->subtype & ST_1FCTFGOTFLAG) {
1857 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
1858 bs->flagcarrier = ClientFromName(netname);
1859 }
1860 }
1861 }
1862
1863 void BotMatch_EnterGame(bot_state_t *bs, bot_match_t *match) {
1864 int client;
1865 char netname[MAX_NETNAME];
1866
1867 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
1868 client = FindClientByName(netname);
1869 if (client >= 0) {
1870 notleader[client] = qfalse;
1871 }
1872 //NOTE: eliza chats will catch this
1873 //Com_sprintf(buf, sizeof(buf), "heya %s", netname);
1874 //EA_Say(bs->client, buf);
1875 }
1876
1877 void BotMatch_NewLeader(bot_state_t *bs, bot_match_t *match) {
1878 int client;
1879 char netname[MAX_NETNAME];
1880
1881 trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
1882 client = FindClientByName(netname);
1883 if (!BotSameTeam(bs, client))
1884 return;
1885 Q_strncpyz(bs->teamleader, netname, sizeof(bs->teamleader));
1886 }
1887
1888 /*
1889 ==================
1890 BotMatchMessage
1891 ==================
1892 */
1893 int BotMatchMessage(bot_state_t *bs, char *message) {
1894 bot_match_t match;
1895
1896 match.type = 0;
1897 //if it is an unknown message
1898 if (!trap_BotFindMatch(message, &match, MTCONTEXT_MISC
1899 |MTCONTEXT_INITIALTEAMCHAT
1900 |MTCONTEXT_CTF
1901 |MTCONTEXT_DD)) {
1902 return qfalse;
1903 }
1904 //react to the found message
1905 switch(match.type)
1906 {
1907 case MSG_HELP: //someone calling for help
1908 case MSG_ACCOMPANY: //someone calling for company
1909 {
1910 BotMatch_HelpAccompany(bs, &match);
1911 break;
1912 }
1913 case MSG_DEFENDKEYAREA: //teamplay defend a key area
1914 {
1915 BotMatch_DefendKeyArea(bs, &match);
1916 break;
1917 }
1918 case MSG_CAMP: //camp somewhere
1919 {
1920 BotMatch_Camp(bs, &match);
1921 break;
1922 }
1923 case MSG_PATROL: //patrol between several key areas
1924 {
1925 BotMatch_Patrol(bs, &match);
1926 break;
1927 }
1928 //CTF & 1FCTF
1929 case MSG_GETFLAG: //ctf get the enemy flag
1930 {
1931 BotMatch_GetFlag(bs, &match);
1932 break;
1933 }
1934 //CTF & 1FCTF & Obelisk & Harvester
1935 case MSG_ATTACKENEMYBASE:
1936 {
1937 BotMatch_AttackEnemyBase(bs, &match);
1938 break;
1939 }
1940 //Harvester
1941 case MSG_HARVEST:
1942 {
1943 BotMatch_Harvest(bs, &match);
1944 break;
1945 }
1946 //CTF & 1FCTF & Harvester
1947 case MSG_RUSHBASE: //ctf rush to the base
1948 {
1949 BotMatch_RushBase(bs, &match);
1950 break;
1951 }
1952 //CTF & 1FCTF
1953 case MSG_RETURNFLAG:
1954 {
1955 BotMatch_ReturnFlag(bs, &match);
1956 break;
1957 }
1958 //CTF & 1FCTF & Obelisk & Harvester
1959 case MSG_TASKPREFERENCE:
1960 {
1961 BotMatch_TaskPreference(bs, &match);
1962 break;
1963 }
1964 //CTF & 1FCTF
1965 case MSG_CTF:
1966 {
1967 BotMatch_CTF(bs, &match);
1968 break;
1969 }
1970 case MSG_GETITEM:
1971 {
1972 BotMatch_GetItem(bs, &match);
1973 break;
1974 }
1975 case MSG_JOINSUBTEAM: //join a sub team
1976 {
1977 BotMatch_JoinSubteam(bs, &match);
1978 break;
1979 }
1980 case MSG_LEAVESUBTEAM: //leave a sub team
1981 {
1982 BotMatch_LeaveSubteam(bs, &match);
1983 break;
1984 }
1985 case MSG_WHICHTEAM:
1986 {
1987 BotMatch_WhichTeam(bs, &match);
1988 break;
1989 }
1990 case MSG_CHECKPOINT: //remember a check point
1991 {
1992 BotMatch_CheckPoint(bs, &match);
1993 break;
1994 }
1995 case MSG_CREATENEWFORMATION: //start the creation of a new formation
1996 {
1997 trap_EA_SayTeam(bs->client, "the part of my brain to create formations has been damaged");
1998 break;
1999 }
2000 case MSG_FORMATIONPOSITION: //tell someone his/her position in the formation
2001 {
2002 trap_EA_SayTeam(bs->client, "the part of my brain to create formations has been damaged");
2003 break;
2004 }
2005 case MSG_FORMATIONSPACE: //set the formation space
2006 {
2007 BotMatch_FormationSpace(bs, &match);
2008 break;
2009 }
2010 case MSG_DOFORMATION: //form a certain formation
2011 {
2012 break;
2013 }
2014 case MSG_DISMISS: //dismiss someone
2015 {
2016 BotMatch_Dismiss(bs, &match);
2017 break;
2018 }
2019 case MSG_STARTTEAMLEADERSHIP: //someone will become the team leader
2020 {
2021 BotMatch_StartTeamLeaderShip(bs, &match);
2022 break;
2023 }
2024 case MSG_STOPTEAMLEADERSHIP: //someone will stop being the team leader
2025 {
2026 BotMatch_StopTeamLeaderShip(bs, &match);
2027 break;
2028 }
2029 case MSG_WHOISTEAMLAEDER:
2030 {
2031 BotMatch_WhoIsTeamLeader(bs, &match);
2032 break;
2033 }
2034 case MSG_WHATAREYOUDOING: //ask a bot what he/she is doing
2035 {
2036 BotMatch_WhatAreYouDoing(bs, &match);
2037 break;
2038 }
2039 case MSG_WHATISMYCOMMAND:
2040 {
2041 BotMatch_WhatIsMyCommand(bs, &match);
2042 break;
2043 }
2044 case MSG_WHEREAREYOU:
2045 {
2046 BotMatch_WhereAreYou(bs, &match);
2047 break;
2048 }
2049 case MSG_LEADTHEWAY:
2050 {
2051 BotMatch_LeadTheWay(bs, &match);
2052 break;
2053 }
2054 case MSG_KILL:
2055 {
2056 BotMatch_Kill(bs, &match);
2057 break;
2058 }
2059 case MSG_ENTERGAME: //someone entered the game
2060 {
2061 BotMatch_EnterGame(bs, &match);
2062 break;
2063 }
2064 case MSG_NEWLEADER:
2065 {
2066 BotMatch_NewLeader(bs, &match);
2067 break;
2068 }
2069 case MSG_WAIT:
2070 {
2071 break;
2072 }
2073 case MSG_SUICIDE:
2074 {
2075 BotMatch_Suicide(bs, &match);
2076 break;
2077 }
2078 case MSG_TAKEA:
2079 {
2080 BotMatch_TakeA(bs, &match);
2081 break;
2082 }
2083 case MSG_TAKEB:
2084 {
2085 BotMatch_TakeB(bs, &match);
2086 break;
2087 }
2088 default:
2089 {
2090 BotAI_Print(PRT_MESSAGE, "unknown match type\n");
2091 break;
2092 }
2093 }
2094 return qtrue;
2095 }