]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/bot/default/bot.qc
Fix "bot_cmd X pause" command occasionally blocking all other bots
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / bot / default / bot.qc
1 #include "bot.qh"
2
3 #include "cvars.qh"
4
5 #include "aim.qh"
6 #include "navigation.qh"
7 #include "scripting.qh"
8 #include "waypoints.qh"
9
10 #include "havocbot/havocbot.qh"
11 #include "havocbot/scripting.qh"
12
13 #include "../../teamplay.qh"
14
15 #include "../../antilag.qh"
16 #include "../../autocvars.qh"
17 #include "../../campaign.qh"
18 #include "../../client.qh"
19 #include "../../constants.qh"
20 #include "../../defs.qh"
21 #include "../../race.qh"
22 #include <common/t_items.qh>
23
24 #include "../../mutators/_mod.qh"
25
26 #include "../../weapons/accuracy.qh"
27
28 #include <common/physics/player.qh>
29 #include <common/constants.qh>
30 #include <common/net_linked.qh>
31 #include <common/mapinfo.qh>
32 #include <common/teams.qh>
33 #include <common/util.qh>
34
35 #include <server/scores_rules.qh>
36
37 #include <common/weapons/_all.qh>
38
39 #include <lib/csqcmodel/sv_model.qh>
40
41 #include <lib/warpzone/common.qh>
42 #include <lib/warpzone/util_server.qh>
43
44 entity bot_spawn()
45 {
46         entity bot = spawnclient();
47         if (bot)
48         {
49                 currentbots = currentbots + 1;
50                 bot_setnameandstuff(bot);
51                 ClientConnect(bot);
52                 PutClientInServer(bot);
53         }
54         return bot;
55 }
56
57 void bot_think(entity this)
58 {
59         if (this.bot_nextthink > time)
60                 return;
61
62         this.flags &= ~FL_GODMODE;
63         if(autocvar_bot_god)
64                 this.flags |= FL_GODMODE;
65
66         this.bot_nextthink = this.bot_nextthink + autocvar_bot_ai_thinkinterval * pow(0.5, this.bot_aiskill);
67         //if (this.bot_painintensity > 0)
68         //      this.bot_painintensity = this.bot_painintensity - (skill + 1) * 40 * frametime;
69
70         //this.bot_painintensity = this.bot_painintensity + this.bot_oldhealth - this.health;
71         //this.bot_painintensity = bound(0, this.bot_painintensity, 100);
72
73         if (!IS_PLAYER(this) || (autocvar_g_campaign && !campaign_bots_may_start))
74         {
75                 this.bot_nextthink = time + 0.5;
76                 return;
77         }
78
79         if (this.fixangle)
80         {
81                 this.v_angle = this.angles;
82                 this.v_angle_z = 0;
83                 this.fixangle = false;
84         }
85
86         this.dmg_take = 0;
87         this.dmg_save = 0;
88         this.dmg_inflictor = NULL;
89
90         // calculate an aiming latency based on the skill setting
91         // (simulated network latency + naturally delayed reflexes)
92         //this.ping = 0.7 - bound(0, 0.05 * skill, 0.5); // moved the reflexes to bot_aimdir (under the name 'think')
93         // minimum ping 20+10 random
94         this.ping = bound(0,0.07 - bound(0, (skill + this.bot_pingskill) * 0.005,0.05)+random()*0.01,0.65); // Now holds real lag to server, and higer skill players take a less laggy server
95         // skill 10 = ping 0.2 (adrenaline)
96         // skill 0 = ping 0.7 (slightly drunk)
97
98         // clear buttons
99         PHYS_INPUT_BUTTON_ATCK(this) = false;
100         PHYS_INPUT_BUTTON_JUMP(this) = false;
101         PHYS_INPUT_BUTTON_ATCK2(this) = false;
102         PHYS_INPUT_BUTTON_ZOOM(this) = false;
103         PHYS_INPUT_BUTTON_CROUCH(this) = false;
104         PHYS_INPUT_BUTTON_HOOK(this) = false;
105         PHYS_INPUT_BUTTON_INFO(this) = false;
106         PHYS_INPUT_BUTTON_DRAG(this) = false;
107         PHYS_INPUT_BUTTON_CHAT(this) = false;
108         PHYS_INPUT_BUTTON_USE(this) = false;
109
110         if (time < game_starttime)
111         {
112                 // block the bot during the countdown to game start
113                 this.movement = '0 0 0';
114                 this.bot_nextthink = game_starttime;
115                 return;
116         }
117
118         // if dead, just wait until we can respawn
119         if (IS_DEAD(this))
120         {
121                 if (this.deadflag == DEAD_DEAD)
122                 {
123                         PHYS_INPUT_BUTTON_JUMP(this) = true; // press jump to respawn
124                         this.bot_strategytime = 0;
125                 }
126         }
127         else if(this.aistatus & AI_STATUS_STUCK)
128                 navigation_unstuck(this);
129
130         // now call the current bot AI (havocbot for example)
131         this.bot_ai(this);
132 }
133
134 void bot_setnameandstuff(entity this)
135 {
136         string readfile, s;
137         float file, tokens, prio;
138
139         string bot_name, bot_model, bot_skin, bot_shirt, bot_pants;
140         string name, prefix, suffix;
141
142         if(autocvar_g_campaign)
143         {
144                 prefix = "";
145                 suffix = "";
146         }
147         else
148         {
149                 prefix = autocvar_bot_prefix;
150                 suffix = autocvar_bot_suffix;
151         }
152
153         file = fopen(autocvar_bot_config_file, FILE_READ);
154
155         if(file < 0)
156         {
157                 LOG_INFO(strcat("Error: Can not open the bot configuration file '",autocvar_bot_config_file,"'\n"));
158                 readfile = "";
159         }
160         else
161         {
162                 RandomSelection_Init();
163                 while((readfile = fgets(file)))
164                 {
165                         if(substring(readfile, 0, 2) == "//")
166                                 continue;
167                         if(substring(readfile, 0, 1) == "#")
168                                 continue;
169                         tokens = tokenizebyseparator(readfile, "\t");
170                         if(tokens == 0)
171                                 continue;
172                         s = argv(0);
173                         prio = 1;
174                         FOREACH_CLIENT(IS_BOT_CLIENT(it), LAMBDA(
175                                 if(s == it.cleanname)
176                                 {
177                                         prio = 0;
178                                         break;
179                                 }
180                         ));
181                         RandomSelection_AddString(readfile, 1, prio);
182                 }
183                 readfile = RandomSelection_chosen_string;
184                 fclose(file);
185         }
186
187         tokens = tokenizebyseparator(readfile, "\t");
188         if(argv(0) != "") bot_name = argv(0);
189         else bot_name = "Bot";
190
191         if(argv(1) != "") bot_model = argv(1);
192         else bot_model = "";
193
194         if(argv(2) != "") bot_skin = argv(2);
195         else bot_skin = "0";
196
197         if(argv(3) != "" && stof(argv(3)) >= 0) bot_shirt = argv(3);
198         else bot_shirt = ftos(floor(random() * 15));
199
200         if(argv(4) != "" && stof(argv(4)) >= 0) bot_pants = argv(4);
201         else bot_pants = ftos(floor(random() * 15));
202
203         this.bot_forced_team = stof(argv(5));
204
205         prio = 6;
206
207         #define READSKILL(f,w,r) if(argv(prio) != "") this.f = stof(argv(prio)) * (w); else this.f = (!autocvar_g_campaign) * (2 * random() - 1) * (r) * (w); ++prio
208         //print(bot_name, ": ping=", argv(9), "\n");
209
210         READSKILL(havocbot_keyboardskill, 0.5, 0.5); // keyboard skill
211         READSKILL(bot_moveskill, 2, 0); // move skill
212         READSKILL(bot_dodgeskill, 2, 0); // dodge skill
213
214         READSKILL(bot_pingskill, 0.5, 0); // ping skill
215
216         READSKILL(bot_weaponskill, 2, 0); // weapon skill
217         READSKILL(bot_aggresskill, 1, 0); // aggre skill
218         READSKILL(bot_rangepreference, 1, 0); // read skill
219
220         READSKILL(bot_aimskill, 2, 0); // aim skill
221         READSKILL(bot_offsetskill, 2, 0.5); // offset skill
222         READSKILL(bot_mouseskill, 1, 0.5); // mouse skill
223
224         READSKILL(bot_thinkskill, 1, 0.5); // think skill
225         READSKILL(bot_aiskill, 2, 0); // "ai" skill
226
227         this.bot_config_loaded = true;
228
229         // this is really only a default, JoinBestTeam is called later
230         setcolor(this, stof(bot_shirt) * 16 + stof(bot_pants));
231         this.bot_preferredcolors = this.clientcolors;
232
233         // pick the name
234         if (autocvar_bot_usemodelnames)
235                 name = bot_model;
236         else
237                 name = bot_name;
238
239         // number bots with identical names
240         int j = 0;
241         FOREACH_CLIENT(IS_BOT_CLIENT(it), LAMBDA(
242                 if(it.cleanname == name)
243                         ++j;
244         ));
245         if (j)
246                 this.netname = this.netname_freeme = strzone(strcat(prefix, name, "(", ftos(j), ")", suffix));
247         else
248                 this.netname = this.netname_freeme = strzone(strcat(prefix, name, suffix));
249
250         this.cleanname = strzone(name);
251
252         // pick the model and skin
253         if(substring(bot_model, -4, 1) != ".")
254                 bot_model = strcat(bot_model, ".iqm");
255         this.playermodel = this.playermodel_freeme = strzone(strcat("models/player/", bot_model));
256         this.playerskin = this.playerskin_freeme = strzone(bot_skin);
257
258         this.cvar_cl_accuracy_data_share = 1;  // share the bots weapon accuracy data with the NULL
259         this.cvar_cl_accuracy_data_receive = 0;  // don't receive any weapon accuracy data
260 }
261
262 void bot_custom_weapon_priority_setup()
263 {
264         float tokens, i, w;
265
266         bot_custom_weapon = false;
267
268         if(     autocvar_bot_ai_custom_weapon_priority_far == "" ||
269                 autocvar_bot_ai_custom_weapon_priority_mid == "" ||
270                 autocvar_bot_ai_custom_weapon_priority_close == "" ||
271                 autocvar_bot_ai_custom_weapon_priority_distances == ""
272         )
273                 return;
274
275         // Parse distances
276         tokens = tokenizebyseparator(autocvar_bot_ai_custom_weapon_priority_distances," ");
277
278         if (tokens!=2)
279                 return;
280
281         bot_distance_far = stof(argv(0));
282         bot_distance_close = stof(argv(1));
283
284         if(bot_distance_far < bot_distance_close){
285                 bot_distance_far = stof(argv(1));
286                 bot_distance_close = stof(argv(0));
287         }
288
289         // Initialize list of weapons
290         bot_weapons_far[0] = -1;
291         bot_weapons_mid[0] = -1;
292         bot_weapons_close[0] = -1;
293
294         // Parse far distance weapon priorities
295         tokens = tokenizebyseparator(W_NumberWeaponOrder(autocvar_bot_ai_custom_weapon_priority_far)," ");
296
297         int c = 0;
298         for(i=0; i < tokens && c < Weapons_COUNT; ++i){
299                 w = stof(argv(i));
300                 if ( w >= WEP_FIRST && w <= WEP_LAST) {
301                         bot_weapons_far[c] = w;
302                         ++c;
303                 }
304         }
305         if(c < Weapons_COUNT)
306                 bot_weapons_far[c] = -1;
307
308         // Parse mid distance weapon priorities
309         tokens = tokenizebyseparator(W_NumberWeaponOrder(autocvar_bot_ai_custom_weapon_priority_mid)," ");
310
311         c = 0;
312         for(i=0; i < tokens && c < Weapons_COUNT; ++i){
313                 w = stof(argv(i));
314                 if ( w >= WEP_FIRST && w <= WEP_LAST) {
315                         bot_weapons_mid[c] = w;
316                         ++c;
317                 }
318         }
319         if(c < Weapons_COUNT)
320                 bot_weapons_mid[c] = -1;
321
322         // Parse close distance weapon priorities
323         tokens = tokenizebyseparator(W_NumberWeaponOrder(autocvar_bot_ai_custom_weapon_priority_close)," ");
324
325         c = 0;
326         for(i=0; i < tokens && i < Weapons_COUNT; ++i){
327                 w = stof(argv(i));
328                 if ( w >= WEP_FIRST && w <= WEP_LAST) {
329                         bot_weapons_close[c] = w;
330                         ++c;
331                 }
332         }
333         if(c < Weapons_COUNT)
334                 bot_weapons_close[c] = -1;
335
336         bot_custom_weapon = true;
337 }
338
339 void bot_endgame()
340 {
341         bot_relinkplayerlist();
342         entity e = bot_list;
343         while (e)
344         {
345                 setcolor(e, e.bot_preferredcolors);
346                 e = e.nextbot;
347         }
348         // if dynamic waypoints are ever implemented, save them here
349 }
350
351 void bot_relinkplayerlist()
352 {
353         player_count = 0;
354         currentbots = 0;
355         bot_list = NULL;
356
357         entity prevbot = NULL;
358         FOREACH_CLIENT(true,
359         {
360                 ++player_count;
361
362                 if(IS_BOT_CLIENT(it))
363                 {
364                         if(prevbot)
365                                 prevbot.nextbot = it;
366                         else
367                         {
368                                 bot_list = it;
369                                 bot_list.nextbot = NULL;
370                         }
371                         prevbot = it;
372                         ++currentbots;
373                 }
374         });
375         LOG_TRACE("relink: ", ftos(currentbots), " bots seen.");
376         bot_strategytoken = bot_list;
377         bot_strategytoken_taken = true;
378 }
379
380 void bot_clientdisconnect(entity this)
381 {
382         if (!IS_BOT_CLIENT(this))
383                 return;
384         bot_clearqueue(this);
385         if(this.cleanname)
386                 strunzone(this.cleanname);
387         if(this.netname_freeme)
388                 strunzone(this.netname_freeme);
389         if(this.playermodel_freeme)
390                 strunzone(this.playermodel_freeme);
391         if(this.playerskin_freeme)
392                 strunzone(this.playerskin_freeme);
393         this.cleanname = string_null;
394         this.netname_freeme = string_null;
395         this.playermodel_freeme = string_null;
396         this.playerskin_freeme = string_null;
397         if(this.bot_cmd_current)
398                 delete(this.bot_cmd_current);
399         if(bot_waypoint_queue_owner == this)
400                 bot_waypoint_queue_owner = NULL;
401 }
402
403 void bot_clientconnect(entity this)
404 {
405         if (!IS_BOT_CLIENT(this)) return;
406         this.bot_preferredcolors = this.clientcolors;
407         this.bot_nextthink = time - random();
408         this.lag_func = bot_lagfunc;
409         this.isbot = true;
410         this.createdtime = this.bot_nextthink;
411
412         if(!this.bot_config_loaded) // This is needed so team overrider doesn't break between matches
413                 bot_setnameandstuff(this);
414
415         if(this.bot_forced_team==1)
416                 this.team = NUM_TEAM_1;
417         else if(this.bot_forced_team==2)
418                 this.team = NUM_TEAM_2;
419         else if(this.bot_forced_team==3)
420                 this.team = NUM_TEAM_3;
421         else if(this.bot_forced_team==4)
422                 this.team = NUM_TEAM_4;
423         else
424                 JoinBestTeam(this, false, true);
425
426         havocbot_setupbot(this);
427 }
428
429 void bot_removefromlargestteam()
430 {
431         CheckAllowedTeams(NULL);
432         GetTeamCounts(NULL);
433
434         entity best = NULL;
435         float besttime = 0;
436         int bestcount = 0;
437
438         int bcount = 0;
439         FOREACH_CLIENT(it.isbot,
440         {
441                 ++bcount;
442
443                 if(!best)
444                 {
445                         best = it;
446                         besttime = it.createdtime;
447                 }
448
449                 int thiscount = 0;
450
451                 switch(it.team)
452                 {
453                         case NUM_TEAM_1: thiscount = c1; break;
454                         case NUM_TEAM_2: thiscount = c2; break;
455                         case NUM_TEAM_3: thiscount = c3; break;
456                         case NUM_TEAM_4: thiscount = c4; break;
457                 }
458
459                 if(thiscount > bestcount)
460                 {
461                         bestcount = thiscount;
462                         besttime = it.createdtime;
463                         best = it;
464                 }
465                 else if(thiscount == bestcount && besttime < it.createdtime)
466                 {
467                         besttime = it.createdtime;
468                         best = it;
469                 }
470         });
471         if(!bcount)
472                 return; // no bots to remove
473         currentbots = currentbots - 1;
474         dropclient(best);
475 }
476
477 void bot_removenewest()
478 {
479         if(teamplay)
480         {
481                 bot_removefromlargestteam();
482                 return;
483         }
484
485         float besttime = 0;
486         entity best = NULL;
487         int bcount = 0;
488
489         FOREACH_CLIENT(it.isbot,
490         {
491                 ++bcount;
492
493                 if(!best)
494                 {
495                         best = it;
496                         besttime = it.createdtime;
497                 }
498
499                 if(besttime < it.createdtime)
500                 {
501                         besttime = it.createdtime;
502                         best = it;
503                 }
504         });
505
506         if(!bcount)
507                 return; // no bots to remove
508
509         currentbots = currentbots - 1;
510         dropclient(best);
511 }
512
513 void autoskill(float factor)
514 {
515         float bestbot;
516         float bestplayer;
517
518         bestbot = -1;
519         bestplayer = -1;
520         FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
521                 if(IS_REAL_CLIENT(it))
522                         bestplayer = max(bestplayer, it.totalfrags - it.totalfrags_lastcheck);
523                 else
524                         bestbot = max(bestbot, it.totalfrags - it.totalfrags_lastcheck);
525         ));
526
527         LOG_TRACE("autoskill: best player got ", ftos(bestplayer), ", ");
528         LOG_TRACE("best bot got ", ftos(bestbot), "; ");
529         if(bestbot < 0 || bestplayer < 0)
530         {
531                 LOG_TRACE("not doing anything");
532                 // don't return, let it reset all counters below
533         }
534         else if(bestbot <= bestplayer * factor - 2)
535         {
536                 if(autocvar_skill < 17)
537                 {
538                         LOG_TRACE("2 frags difference, increasing skill");
539                         cvar_set("skill", ftos(autocvar_skill + 1));
540                         bprint("^2SKILL UP!^7 Now at level ", ftos(autocvar_skill), "\n");
541                 }
542         }
543         else if(bestbot >= bestplayer * factor + 2)
544         {
545                 if(autocvar_skill > 0)
546                 {
547                         LOG_TRACE("2 frags difference, decreasing skill");
548                         cvar_set("skill", ftos(autocvar_skill - 1));
549                         bprint("^1SKILL DOWN!^7 Now at level ", ftos(autocvar_skill), "\n");
550                 }
551         }
552         else
553         {
554                 LOG_TRACE("not doing anything");
555                 return;
556                 // don't reset counters, wait for them to accumulate
557         }
558
559         FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(it.totalfrags_lastcheck = it.totalfrags));
560 }
561
562 void bot_calculate_stepheightvec()
563 {
564         stepheightvec = autocvar_sv_stepheight * '0 0 1';
565         jumpstepheightvec = stepheightvec +
566                 ((autocvar_sv_jumpvelocity * autocvar_sv_jumpvelocity) / (2 * autocvar_sv_gravity)) * '0 0 0.85';
567                 // 0.75 factor is for safety to make the jumps easy
568 }
569
570 float bot_fixcount()
571 {
572         int activerealplayers = 0;
573         int realplayers = 0;
574         if (MUTATOR_CALLHOOK(Bot_FixCount, activerealplayers, realplayers)) {
575                 activerealplayers = M_ARGV(0, int);
576                 realplayers = M_ARGV(1, int);
577         } else {
578                 FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(
579                         if(IS_PLAYER(it))
580                                 ++activerealplayers;
581                         ++realplayers;
582                 ));
583         }
584
585         int bots;
586         // add/remove bots if needed to make sure there are at least
587         // minplayers+bot_number, or remove all bots if no one is playing
588         // But don't remove bots immediately on level change, as the real players
589         // usually haven't rejoined yet
590         bots_would_leave = false;
591         if (teamplay && autocvar_bot_vs_human && AvailableTeams() == 2)
592                 bots = min(ceil(fabs(autocvar_bot_vs_human) * activerealplayers), maxclients - realplayers);
593         else if ((realplayers || autocvar_bot_join_empty || (currentbots > 0 && time < 5)))
594         {
595                 float realminplayers, minplayers;
596                 realminplayers = autocvar_minplayers;
597                 minplayers = max(0, floor(realminplayers));
598
599                 float realminbots, minbots;
600                 realminbots = autocvar_bot_number;
601                 minbots = max(0, floor(realminbots));
602
603                 bots = min(max(minbots, minplayers - activerealplayers), maxclients - realplayers);
604                 if(bots > minbots)
605                         bots_would_leave = true;
606         }
607         else
608         {
609                 // if there are no players, remove bots
610                 bots = 0;
611         }
612
613         // only add one bot per frame to avoid utter chaos
614         if(time > botframe_nextthink)
615         {
616                 //dprint(ftos(bots), " ? ", ftos(currentbots), "\n");
617                 while (currentbots < bots)
618                 {
619                         if (bot_spawn() == NULL)
620                         {
621                                 bprint("Can not add bot, server full.\n");
622                                 return false;
623                         }
624                 }
625                 while (currentbots > bots)
626                         bot_removenewest();
627         }
628
629         return true;
630 }
631
632 void bot_remove_from_bot_list(entity this)
633 {
634         entity e = bot_list;
635         entity prev_bot = NULL;
636         while (e)
637         {
638                 if(e == this)
639                 {
640                         if(!prev_bot)
641                                 bot_list = this.nextbot;
642                         else
643                                 prev_bot.nextbot = this.nextbot;
644                         if(bot_strategytoken == this)
645                         {
646                                 bot_strategytoken = this.nextbot;
647                                 bot_strategytoken_taken = true;
648                         }
649                         this.nextbot = NULL;
650                         break;
651                 }
652                 prev_bot = e;
653                 e = e.nextbot;
654         }
655 }
656
657 void bot_clear(entity this)
658 {
659         bot_remove_from_bot_list(this);
660         if(bot_waypoint_queue_owner == this)
661                 bot_waypoint_queue_owner = NULL;
662         this.aistatus &= ~AI_STATUS_STUCK; // otherwise bot_waypoint_queue_owner will be set again to this by navigation_unstuck
663 }
664
665 void bot_serverframe()
666 {
667         if (intermission_running)
668                 return;
669
670         if (time < 2)
671                 return;
672
673         bot_calculate_stepheightvec();
674         bot_navigation_movemode = ((autocvar_bot_navigation_ignoreplayers) ? MOVE_NOMONSTERS : MOVE_NORMAL);
675
676         if(time > autoskill_nextthink)
677         {
678                 float a;
679                 a = autocvar_skill_auto;
680                 if(a)
681                         autoskill(a);
682                 autoskill_nextthink = time + 5;
683         }
684
685         if(time > botframe_nextthink)
686         {
687                 if(!bot_fixcount())
688                         botframe_nextthink = time + 10;
689         }
690
691         bot_ignore_bots = autocvar_bot_ignore_bots;
692
693         if(botframe_spawnedwaypoints)
694         {
695                 if(autocvar_waypoint_benchmark)
696                         localcmd("quit\n");
697         }
698
699         if (currentbots > 0 || autocvar_g_waypointeditor || autocvar_g_waypointeditor_auto)
700         if (botframe_spawnedwaypoints)
701         {
702                 if(botframe_cachedwaypointlinks)
703                 {
704                         if(!botframe_loadedforcedlinks)
705                                 waypoint_load_links_hardwired();
706                 }
707                 else
708                 {
709                         // TODO: Make this check cleaner
710                         IL_EACH(g_waypoints, time - it.nextthink > 10,
711                         {
712                                 waypoint_save_links();
713                                 break;
714                         });
715                 }
716         }
717         else
718         {
719                 botframe_spawnedwaypoints = true;
720                 waypoint_loadall();
721                 if(!waypoint_load_links())
722                         waypoint_schedulerelinkall();
723         }
724
725         if (bot_list)
726         {
727                 // cycle the goal token from one bot to the next each frame
728                 // (this prevents them from all doing spawnfunc_waypoint searches on the same
729                 //  frame, which causes choppy framerates)
730                 if (bot_strategytoken_taken)
731                 {
732                         bot_strategytoken_taken = false;
733                         if (bot_strategytoken)
734                                 bot_strategytoken = bot_strategytoken.nextbot;
735                         if (!bot_strategytoken)
736                                 bot_strategytoken = bot_list;
737                 }
738
739                 if (botframe_nextdangertime < time)
740                 {
741                         float interval;
742                         interval = autocvar_bot_ai_dangerdetectioninterval;
743                         if (botframe_nextdangertime < time - interval * 1.5)
744                                 botframe_nextdangertime = time;
745                         botframe_nextdangertime = botframe_nextdangertime + interval;
746                         botframe_updatedangerousobjects(autocvar_bot_ai_dangerdetectionupdates);
747                 }
748         }
749
750         if (autocvar_g_waypointeditor)
751                 botframe_showwaypointlinks();
752
753         if (autocvar_g_waypointeditor_auto)
754                 botframe_autowaypoints();
755
756         if(time > bot_cvar_nextthink)
757         {
758                 if(currentbots>0)
759                         bot_custom_weapon_priority_setup();
760                 bot_cvar_nextthink = time + 5;
761         }
762 }