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