]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/bot/default/bot.qc
Merge branch 'master' into terencehill/gameover_stuff
[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/mapinfo.qh>
31 #include <common/teams.qh>
32 #include <common/util.qh>
33
34 #include <server/scores_rules.qh>
35
36 #include <common/weapons/_all.qh>
37
38 #include <lib/csqcmodel/sv_model.qh>
39
40 #include <lib/warpzone/common.qh>
41 #include <lib/warpzone/util_server.qh>
42
43 entity bot_spawn()
44 {
45         entity bot = spawnclient();
46         if (bot)
47         {
48                 currentbots = currentbots + 1;
49                 bot_setnameandstuff(bot);
50                 ClientConnect(bot);
51                 PutClientInServer(bot);
52         }
53         return bot;
54 }
55
56 void bot_think(entity this)
57 {
58         if (this.bot_nextthink > time)
59                 return;
60
61         this.flags &= ~FL_GODMODE;
62         if(autocvar_bot_god)
63                 this.flags |= FL_GODMODE;
64
65         this.bot_nextthink = this.bot_nextthink + autocvar_bot_ai_thinkinterval * pow(0.5, this.bot_aiskill);
66         //if (this.bot_painintensity > 0)
67         //      this.bot_painintensity = this.bot_painintensity - (skill + 1) * 40 * frametime;
68
69         //this.bot_painintensity = this.bot_painintensity + this.bot_oldhealth - this.health;
70         //this.bot_painintensity = bound(0, this.bot_painintensity, 100);
71
72         if (!IS_PLAYER(this) || (autocvar_g_campaign && !campaign_bots_may_start))
73         {
74                 this.bot_nextthink = time + 0.5;
75                 return;
76         }
77
78         if (this.fixangle)
79         {
80                 this.v_angle = this.angles;
81                 this.v_angle_z = 0;
82                 this.fixangle = false;
83         }
84
85         this.dmg_take = 0;
86         this.dmg_save = 0;
87         this.dmg_inflictor = NULL;
88
89         // calculate an aiming latency based on the skill setting
90         // (simulated network latency + naturally delayed reflexes)
91         //this.ping = 0.7 - bound(0, 0.05 * skill, 0.5); // moved the reflexes to bot_aimdir (under the name 'think')
92         // minimum ping 20+10 random
93         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
94         // skill 10 = ping 0.2 (adrenaline)
95         // skill 0 = ping 0.7 (slightly drunk)
96
97         // clear buttons
98         PHYS_INPUT_BUTTON_ATCK(this) = false;
99         PHYS_INPUT_BUTTON_JUMP(this) = false;
100         PHYS_INPUT_BUTTON_ATCK2(this) = false;
101         PHYS_INPUT_BUTTON_ZOOM(this) = false;
102         PHYS_INPUT_BUTTON_CROUCH(this) = false;
103         PHYS_INPUT_BUTTON_HOOK(this) = false;
104         PHYS_INPUT_BUTTON_INFO(this) = false;
105         PHYS_INPUT_BUTTON_DRAG(this) = false;
106         PHYS_INPUT_BUTTON_CHAT(this) = false;
107         PHYS_INPUT_BUTTON_USE(this) = false;
108
109         if (time < game_starttime)
110         {
111                 // block the bot during the countdown to game start
112                 this.movement = '0 0 0';
113                 this.bot_nextthink = game_starttime;
114                 return;
115         }
116
117         // if dead, just wait until we can respawn
118         if (IS_DEAD(this))
119         {
120                 if (this.deadflag == DEAD_DEAD)
121                 {
122                         PHYS_INPUT_BUTTON_JUMP(this) = true; // press jump to respawn
123                         this.bot_strategytime = 0;
124                 }
125         }
126         else if(this.aistatus & AI_STATUS_STUCK)
127                 navigation_unstuck(this);
128
129         // now call the current bot AI (havocbot for example)
130         this.bot_ai(this);
131 }
132
133 void bot_setnameandstuff(entity this)
134 {
135         string readfile, s;
136         float file, tokens, prio;
137
138         string bot_name, bot_model, bot_skin, bot_shirt, bot_pants;
139         string name, prefix, suffix;
140
141         if(autocvar_g_campaign)
142         {
143                 prefix = "";
144                 suffix = "";
145         }
146         else
147         {
148                 prefix = autocvar_bot_prefix;
149                 suffix = autocvar_bot_suffix;
150         }
151
152         file = fopen(autocvar_bot_config_file, FILE_READ);
153
154         if(file < 0)
155         {
156                 LOG_INFO(strcat("Error: Can not open the bot configuration file '",autocvar_bot_config_file,"'\n"));
157                 readfile = "";
158         }
159         else
160         {
161                 RandomSelection_Init();
162                 while((readfile = fgets(file)))
163                 {
164                         if(substring(readfile, 0, 2) == "//")
165                                 continue;
166                         if(substring(readfile, 0, 1) == "#")
167                                 continue;
168                         tokens = tokenizebyseparator(readfile, "\t");
169                         if(tokens == 0)
170                                 continue;
171                         s = argv(0);
172                         prio = 1;
173                         FOREACH_CLIENT(IS_BOT_CLIENT(it), LAMBDA(
174                                 if(s == it.cleanname)
175                                 {
176                                         prio = 0;
177                                         break;
178                                 }
179                         ));
180                         RandomSelection_Add(NULL, 0, readfile, 1, prio);
181                 }
182                 readfile = RandomSelection_chosen_string;
183                 fclose(file);
184         }
185
186         tokens = tokenizebyseparator(readfile, "\t");
187         if(argv(0) != "") bot_name = argv(0);
188         else bot_name = "Bot";
189
190         if(argv(1) != "") bot_model = argv(1);
191         else bot_model = "";
192
193         if(argv(2) != "") bot_skin = argv(2);
194         else bot_skin = "0";
195
196         if(argv(3) != "" && stof(argv(3)) >= 0) bot_shirt = argv(3);
197         else bot_shirt = ftos(floor(random() * 15));
198
199         if(argv(4) != "" && stof(argv(4)) >= 0) bot_pants = argv(4);
200         else bot_pants = ftos(floor(random() * 15));
201
202         this.bot_forced_team = stof(argv(5));
203
204         prio = 6;
205
206         #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
207         //print(bot_name, ": ping=", argv(9), "\n");
208
209         READSKILL(havocbot_keyboardskill, 0.5, 0.5); // keyboard skill
210         READSKILL(bot_moveskill, 2, 0); // move skill
211         READSKILL(bot_dodgeskill, 2, 0); // dodge skill
212
213         READSKILL(bot_pingskill, 0.5, 0); // ping skill
214
215         READSKILL(bot_weaponskill, 2, 0); // weapon skill
216         READSKILL(bot_aggresskill, 1, 0); // aggre skill
217         READSKILL(bot_rangepreference, 1, 0); // read skill
218
219         READSKILL(bot_aimskill, 2, 0); // aim skill
220         READSKILL(bot_offsetskill, 2, 0.5); // offset skill
221         READSKILL(bot_mouseskill, 1, 0.5); // mouse skill
222
223         READSKILL(bot_thinkskill, 1, 0.5); // think skill
224         READSKILL(bot_aiskill, 2, 0); // "ai" skill
225
226         this.bot_config_loaded = true;
227
228         // this is really only a default, JoinBestTeam is called later
229         setcolor(this, stof(bot_shirt) * 16 + stof(bot_pants));
230         this.bot_preferredcolors = this.clientcolors;
231
232         // pick the name
233         if (autocvar_bot_usemodelnames)
234                 name = bot_model;
235         else
236                 name = bot_name;
237
238         // number bots with identical names
239         int j = 0;
240         FOREACH_CLIENT(IS_BOT_CLIENT(it), LAMBDA(
241                 if(it.cleanname == name)
242                         ++j;
243         ));
244         if (j)
245                 this.netname = this.netname_freeme = strzone(strcat(prefix, name, "(", ftos(j), ")", suffix));
246         else
247                 this.netname = this.netname_freeme = strzone(strcat(prefix, name, suffix));
248
249         this.cleanname = strzone(name);
250
251         // pick the model and skin
252         if(substring(bot_model, -4, 1) != ".")
253                 bot_model = strcat(bot_model, ".iqm");
254         this.playermodel = this.playermodel_freeme = strzone(strcat("models/player/", bot_model));
255         this.playerskin = this.playerskin_freeme = strzone(bot_skin);
256
257         this.cvar_cl_accuracy_data_share = 1;  // share the bots weapon accuracy data with the NULL
258         this.cvar_cl_accuracy_data_receive = 0;  // don't receive any weapon accuracy data
259 }
260
261 void bot_custom_weapon_priority_setup()
262 {
263         float tokens, i, w;
264
265         bot_custom_weapon = false;
266
267         if(     autocvar_bot_ai_custom_weapon_priority_far == "" ||
268                 autocvar_bot_ai_custom_weapon_priority_mid == "" ||
269                 autocvar_bot_ai_custom_weapon_priority_close == "" ||
270                 autocvar_bot_ai_custom_weapon_priority_distances == ""
271         )
272                 return;
273
274         // Parse distances
275         tokens = tokenizebyseparator(autocvar_bot_ai_custom_weapon_priority_distances," ");
276
277         if (tokens!=2)
278                 return;
279
280         bot_distance_far = stof(argv(0));
281         bot_distance_close = stof(argv(1));
282
283         if(bot_distance_far < bot_distance_close){
284                 bot_distance_far = stof(argv(1));
285                 bot_distance_close = stof(argv(0));
286         }
287
288         // Initialize list of weapons
289         bot_weapons_far[0] = -1;
290         bot_weapons_mid[0] = -1;
291         bot_weapons_close[0] = -1;
292
293         // Parse far distance weapon priorities
294         tokens = tokenizebyseparator(W_NumberWeaponOrder(autocvar_bot_ai_custom_weapon_priority_far)," ");
295
296         int c = 0;
297         for(i=0; i < tokens && c < Weapons_COUNT; ++i){
298                 w = stof(argv(i));
299                 if ( w >= WEP_FIRST && w <= WEP_LAST) {
300                         bot_weapons_far[c] = w;
301                         ++c;
302                 }
303         }
304         if(c < Weapons_COUNT)
305                 bot_weapons_far[c] = -1;
306
307         // Parse mid distance weapon priorities
308         tokens = tokenizebyseparator(W_NumberWeaponOrder(autocvar_bot_ai_custom_weapon_priority_mid)," ");
309
310         c = 0;
311         for(i=0; i < tokens && c < Weapons_COUNT; ++i){
312                 w = stof(argv(i));
313                 if ( w >= WEP_FIRST && w <= WEP_LAST) {
314                         bot_weapons_mid[c] = w;
315                         ++c;
316                 }
317         }
318         if(c < Weapons_COUNT)
319                 bot_weapons_mid[c] = -1;
320
321         // Parse close distance weapon priorities
322         tokens = tokenizebyseparator(W_NumberWeaponOrder(autocvar_bot_ai_custom_weapon_priority_close)," ");
323
324         c = 0;
325         for(i=0; i < tokens && i < Weapons_COUNT; ++i){
326                 w = stof(argv(i));
327                 if ( w >= WEP_FIRST && w <= WEP_LAST) {
328                         bot_weapons_close[c] = w;
329                         ++c;
330                 }
331         }
332         if(c < Weapons_COUNT)
333                 bot_weapons_close[c] = -1;
334
335         bot_custom_weapon = true;
336 }
337
338 void bot_endgame()
339 {
340         entity e;
341         //dprint("bot_endgame\n");
342         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_serverframe()
633 {
634         if (gameover)
635                 return;
636
637         if (time < 2)
638                 return;
639
640         bot_calculate_stepheightvec();
641         bot_navigation_movemode = ((autocvar_bot_navigation_ignoreplayers) ? MOVE_NOMONSTERS : MOVE_NORMAL);
642
643         if(time > autoskill_nextthink)
644         {
645                 float a;
646                 a = autocvar_skill_auto;
647                 if(a)
648                         autoskill(a);
649                 autoskill_nextthink = time + 5;
650         }
651
652         if(time > botframe_nextthink)
653         {
654                 if(!bot_fixcount())
655                         botframe_nextthink = time + 10;
656         }
657
658         bot_ignore_bots = autocvar_bot_ignore_bots;
659
660         if(botframe_spawnedwaypoints)
661         {
662                 if(autocvar_waypoint_benchmark)
663                         localcmd("quit\n");
664         }
665
666         if (currentbots > 0 || autocvar_g_waypointeditor || autocvar_g_waypointeditor_auto)
667         if (botframe_spawnedwaypoints)
668         {
669                 if(botframe_cachedwaypointlinks)
670                 {
671                         if(!botframe_loadedforcedlinks)
672                                 waypoint_load_links_hardwired();
673                 }
674                 else
675                 {
676                         // TODO: Make this check cleaner
677                         IL_EACH(g_waypoints, time - it.nextthink > 10,
678                         {
679                                 waypoint_save_links();
680                                 break;
681                         });
682                 }
683         }
684         else
685         {
686                 botframe_spawnedwaypoints = true;
687                 waypoint_loadall();
688                 if(!waypoint_load_links())
689                         waypoint_schedulerelinkall();
690         }
691
692         if (bot_list)
693         {
694                 // cycle the goal token from one bot to the next each frame
695                 // (this prevents them from all doing spawnfunc_waypoint searches on the same
696                 //  frame, which causes choppy framerates)
697                 if (bot_strategytoken_taken)
698                 {
699                         bot_strategytoken_taken = false;
700                         if (bot_strategytoken)
701                                 bot_strategytoken = bot_strategytoken.nextbot;
702                         if (!bot_strategytoken)
703                                 bot_strategytoken = bot_list;
704                 }
705
706                 if (botframe_nextdangertime < time)
707                 {
708                         float interval;
709                         interval = autocvar_bot_ai_dangerdetectioninterval;
710                         if (botframe_nextdangertime < time - interval * 1.5)
711                                 botframe_nextdangertime = time;
712                         botframe_nextdangertime = botframe_nextdangertime + interval;
713                         botframe_updatedangerousobjects(autocvar_bot_ai_dangerdetectionupdates);
714                 }
715         }
716
717         if (autocvar_g_waypointeditor)
718                 botframe_showwaypointlinks();
719
720         if (autocvar_g_waypointeditor_auto)
721                 botframe_autowaypoints();
722
723         if(time > bot_cvar_nextthink)
724         {
725                 if(currentbots>0)
726                         bot_custom_weapon_priority_setup();
727                 bot_cvar_nextthink = time + 5;
728         }
729 }