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