2 .float havocbot_role_timeout;
3 .void() havocbot_previous_role;
7 float canreach(entity e)
9 return vlen(self.origin - e.origin) < 1500;
12 .float max_armorvalue;
13 float havocbot_pickupevalfunc(entity item)
15 float i, j, rating, base, position, need_shells, need_nails, need_rockets, need_cells;
18 base = item.bot_pickupbasevalue;
20 need_shells = self.weapons & WEPBIT_SHOTGUN;
21 need_nails = self.weapons & WEPBIT_UZI;
22 need_cells = self.weapons & ( WEPBIT_HOOK | WEPBIT_HLAC | WEPBIT_MINSTANEX | WEPBIT_NEX | WEPBIT_ELECTRO | WEPBIT_CRYLINK );
23 need_rockets = self.weapons & ( WEPBIT_ROCKET_LAUNCHER | WEPBIT_GRENADE_LAUNCHER | WEPBIT_HAGAR | WEPBIT_SEEKER );
27 if( self.weapons & item.weapons == item.weapons )
28 rating = 0.5 + bound(0, skill / 20, 0.5);
32 if( bot_custom_weapon )
34 for(i = WEP_FIRST; i < WEP_LAST ; ++i){
35 if( power2of(i-1) & item.weapons != item.weapons )
39 for(j = 0; j < WEP_LAST ; ++j){
41 bot_weapons_far[j] == i ||
42 bot_weapons_mid[j] == i ||
43 bot_weapons_close[j] == i
53 position = WEP_LAST - position;
54 // item.bot_pickupbasevalue is overwritten here
55 base = BOT_PICKUP_RATING_LOW + ( (BOT_PICKUP_RATING_HIGH - BOT_PICKUP_RATING_LOW) * (position / WEP_LAST ));
63 if (self.ammo_shells < g_pickup_shells_max && need_cells )
64 rating = rating + max(0, 1 - self.ammo_shells / g_pickup_shells_max);
67 if (self.ammo_nails < g_pickup_nails_max && need_nails )
68 rating = rating + max(0, 1 - self.ammo_nails / g_pickup_nails_max);
70 if (item.ammo_rockets)
71 if (self.ammo_rockets < g_pickup_rockets_max && need_rockets)
72 rating = rating + max(0, 1 - self.ammo_rockets / g_pickup_rockets_max);
75 if (self.ammo_cells < g_pickup_cells_max && need_cells)
76 rating = rating + max(0, 1 - self.ammo_cells / g_pickup_cells_max);
79 if (self.armorvalue < item.max_armorvalue * 0.5)
80 rating = rating + max(0, 1 - self.armorvalue / (item.max_armorvalue * 0.5));
83 if (self.health < item.max_health * 0.5)
85 rating = rating + max(0, 1 - self.health / (item.max_health * 0.5));
88 // TODO: if the item is not recognized then default to item.bot_pickupevalfunc(self, item);
93 void havocbot_goalrating_items(float ratingscale, vector org, float sradius)
97 local float rating, d, discard, distance, friend_distance, enemy_distance;
98 ratingscale = ratingscale * 0.0001; // items are rated around 10000 already
99 head = findchainfloat(bot_pickup, TRUE);
103 distance = vlen(head.origin - org);
104 friend_distance = 10000; enemy_distance = 10000;
107 if(!head.solid || distance > sradius || (head == self.ignoregoal && time < self.ignoregoaltime) )
113 // Check if the item can be picked up safely
114 if(head.classname == "droppedweapon")
116 traceline(head.origin, head.origin + '0 0 -1500', TRUE, world);
118 d = pointcontents(trace_endpos + '0 0 1');
119 if(d & CONTENT_WATER || d & CONTENT_SLIME || d & CONTENT_LAVA)
124 if(tracebox_hits_trigger_hurt(head.origin, head.mins, head.maxs, trace_endpos))
132 // Ignore items under water
133 traceline(head.origin + head.maxs, head.origin + head.maxs, MOVE_NORMAL, head);
134 if(trace_dpstartcontents & DPCONTENTS_LIQUIDSMASK)
145 FOR_EACH_PLAYER(player)
148 if ( self == player || player.deadflag )
151 d = vlen(player.origin - head.origin); // distance between player and item
153 if ( player.team == self.team )
155 if ( clienttype(player) != CLIENTTYPE_REAL || discard )
158 if( d > friend_distance)
165 if( head.health && player.health > self.health )
168 if( head.armorvalue && player.armorvalue > self.armorvalue)
172 if( (player.weapons & head.weapons) != head.weapons)
175 if (head.ammo_shells && player.ammo_shells > self.ammo_shells)
178 if (head.ammo_nails && player.ammo_nails > self.ammo_nails)
181 if (head.ammo_rockets && player.ammo_rockets > self.ammo_rockets)
184 if (head.ammo_cells && player.ammo_cells > self.ammo_cells )
191 // If enemy only track distances
192 // TODO: track only if visible ?
193 if( d < enemy_distance )
198 // Rate the item only if no one needs it, or if an enemy is closer to it
199 if ( (enemy_distance < friend_distance && distance < enemy_distance) ||
200 (friend_distance > cvar("bot_ai_friends_aware_pickup_radius") ) || !discard )
202 // rating = head.bot_pickupevalfunc(self, head);
203 rating = havocbot_pickupevalfunc(head);
208 // rating = head.bot_pickupevalfunc(self, head);
209 rating = havocbot_pickupevalfunc(head);
213 navigation_routerating(head, rating * ratingscale, 2000);
218 void havocbot_goalrating_controlpoints(float ratingscale, vector org, float sradius)
221 head = findchain(classname, "dom_controlpoint");
224 if (vlen(head.origin - org) < sradius)
226 if(head.cnt > -1) // this is just being fought for
227 navigation_routerating(head, ratingscale, 5000);
228 else if(head.goalentity.cnt == 0) // unclaimed point
229 navigation_routerating(head, ratingscale * 0.5, 5000);
230 else if(head.goalentity.team != self.team) // other team's point
231 navigation_routerating(head, ratingscale * 0.2, 5000);
238 // LordHavoc: this function was already unused, but for waypoints to be a
239 // useful goal the bots would have to seek out the least-recently-visited
240 // ones, not the closest
241 void havocbot_goalrating_waypoints(float ratingscale, vector org, float sradius)
244 head = findchain(classname, "waypoint");
247 if (vlen(head.origin - org) < sradius && vlen(head.origin - org) > 100)
248 navigation_routerating(head, ratingscale, 2000);
254 void havocbot_goalrating_enemyplayers(float ratingscale, vector org, float sradius)
257 local float t, noteam, distance;
258 noteam = ((self.team == 0) || !teams_matter); // fteqcc sucks
260 // don't chase players if we're under water
261 if(self.waterlevel>1)
264 FOR_EACH_PLAYER(head)
266 // TODO: Merge this logic with the bot_shouldattack function
269 if ((noteam && (!bot_ignore_bots || clienttype(head) == CLIENTTYPE_REAL)) || head.team != self.team)
271 distance = vlen(head.origin - org);
272 if (distance < 100 || distance > sradius)
276 if(head.items & IT_STRENGTH)
279 // rate only visible enemies
281 traceline(self.origin + self.view_ofs, head.origin, MOVE_NOMONSTERS, self);
282 if (trace_fraction < 1 || trace_ent != head)
286 if(head.flags & FL_INWATER || head.flags & FL_PARTIALGROUND)
290 if(head.flags & FL_ONGROUND == 0)
292 traceline(head.origin, head.origin + '0 0 -1500', TRUE, world);
293 t = pointcontents(trace_endpos + '0 0 1');
294 if( t != CONTENT_SOLID )
295 if(t & CONTENT_WATER || t & CONTENT_SLIME || t & CONTENT_LAVA)
297 if(tracebox_hits_trigger_hurt(head.origin, head.mins, head.maxs, trace_endpos))
301 t = (self.health + self.armorvalue ) / (head.health + head.armorvalue );
302 navigation_routerating(head, t * ratingscale, 2000);
308 void() havocbot_role_ctf_middle;
309 void() havocbot_role_ctf_defense;
310 void() havocbot_role_ctf_offense;
311 void() havocbot_role_ctf_interceptor;
313 void havocbot_goalrating_ctf_carrieritems(float ratingscale, vector org, float sradius)
317 head = findchainfloat(bot_pickup, TRUE);
320 // look for health and armor only
321 if (head.solid) // must be possible to pick up (respawning items don't count)
322 if (head.health || head.armorvalue)
323 if (vlen(head.origin - org) < sradius)
326 //if (!head.bot_pickupevalfunc || head.model == "")
328 // get the value of the item
329 t = head.bot_pickupevalfunc(self, head) * 0.0001;
331 navigation_routerating(head, t * ratingscale, 500);
337 entity ctf_worldflaglist;
338 .entity ctf_worldflagnext;
339 void havocbot_goalrating_ctf_ourflag(float ratingscale)
342 head = ctf_worldflaglist;
345 if (self.team == head.team)
347 head = head.ctf_worldflagnext;
350 navigation_routerating(head, ratingscale, 10000);
353 void havocbot_goalrating_ctf_enemyflag(float ratingscale)
356 head = ctf_worldflaglist;
359 if (self.team != head.team)
361 head = head.ctf_worldflagnext;
364 navigation_routerating(head, ratingscale, 10000);
367 void havocbot_goalrating_ctf_enemybase(float ratingscale)
369 // div0: needs a change in the CTF code
372 void havocbot_goalrating_ctf_ourstolenflag(float ratingscale)
375 head = ctf_worldflaglist;
378 if (self.team == head.team)
380 head = head.ctf_worldflagnext;
383 if (head.cnt != FLAG_BASE)
384 navigation_routerating(head, ratingscale, 10000);
387 void havocbot_goalrating_ctf_droppedflags(float ratingscale)
390 head = ctf_worldflaglist;
393 if (head.cnt != FLAG_BASE) // flag is carried or out in the field
394 navigation_routerating(head, ratingscale, 10000);
395 head = head.ctf_worldflagnext;
399 // CTF: (always teamplay)
401 //role rogue: (is this used?)
402 //pick up items and dropped flags (with big rating boost to dropped flags)
403 void havocbot_role_ctf_rogue()
405 if (self.bot_strategytime < time)
407 self.bot_strategytime = time + cvar("bot_ai_strategyinterval");
408 navigation_goalrating_start();
409 havocbot_goalrating_ctf_droppedflags(5000);
410 //havocbot_goalrating_enemyplayers(3000, self.origin, 3000);
411 havocbot_goalrating_items(10000, self.origin, 10000);
412 navigation_goalrating_end();
417 //pick up armor and health
418 //go to our flag spot
419 .float bot_cantfindflag;
420 void havocbot_role_ctf_carrier()
422 if (self.flagcarried == world)
424 dprint("changing role to middle\n");
425 self.havocbot_role = havocbot_role_ctf_middle;
426 self.havocbot_role_timeout = 0;
429 if (self.bot_strategytime < time)
431 self.bot_strategytime = time + cvar("bot_ai_strategyinterval");
432 navigation_goalrating_start();
433 havocbot_goalrating_ctf_ourflag(50000);
434 if (navigation_bestgoal)
435 self.bot_cantfindflag = time + 10;
436 else if (time > self.bot_cantfindflag)
438 // can't navigate to our own flag :(
439 Damage(self, self, self, 100000, DEATH_KILL, self.origin, '0 0 0');
441 havocbot_goalrating_ctf_carrieritems(1000, self.origin, 1000);
442 navigation_goalrating_end();
447 //pick up armor and health
448 //if rockets < 25 || health < 100, change role to middle
449 //if carrying flag, change role to flag carrier
450 //if our flag taken, change role to interceptor
451 //(60-90 second timer) change role to middle
453 void havocbot_role_ctf_offense()
456 if (self.flagcarried)
458 dprint("changing role to carrier\n");
459 self.havocbot_role = havocbot_role_ctf_carrier;
460 self.havocbot_role_timeout = 0;
461 self.bot_cantfindflag = time + 10;
465 f = ctf_worldflaglist;
468 if (self.team == f.team)
470 f = f.ctf_worldflagnext;
472 if (f.cnt != FLAG_BASE && canreach(f))
474 dprint("changing role to interceptor\n");
475 self.havocbot_previous_role = self.havocbot_role;
476 self.havocbot_role = havocbot_role_ctf_interceptor;
477 self.havocbot_role_timeout = 0;
480 if (!self.havocbot_role_timeout)
481 self.havocbot_role_timeout = time + random() * 30 + 60;
482 if (time > self.havocbot_role_timeout)
484 dprint("changing role to middle\n");
485 self.havocbot_role = havocbot_role_ctf_middle;
486 self.havocbot_role_timeout = 0;
489 if (self.bot_strategytime < time)
491 self.bot_strategytime = time + cvar("bot_ai_strategyinterval");
492 navigation_goalrating_start();
493 havocbot_goalrating_ctf_ourstolenflag(50000);
494 havocbot_goalrating_ctf_enemyflag(30000);
495 havocbot_goalrating_ctf_enemybase(20000);
496 havocbot_goalrating_items(10000, self.origin, 10000);
497 navigation_goalrating_end();
501 //role interceptor (temporary role):
503 //if carrying flag, change role to flag carrier
504 //if our flag is back, change role to previous role
506 //go to least recently visited area
507 void havocbot_role_ctf_interceptor()
510 if (self.flagcarried)
512 dprint("changing role to carrier\n");
513 self.havocbot_role = havocbot_role_ctf_carrier;
514 self.havocbot_role_timeout = 0;
515 self.bot_cantfindflag = time + 10;
519 f = ctf_worldflaglist;
522 if (self.team == f.team)
524 f = f.ctf_worldflagnext;
526 if (f.cnt == FLAG_BASE)
528 dprint("changing role back\n");
529 self.havocbot_role = self.havocbot_previous_role;
530 self.havocbot_role_timeout = 0;
534 if (self.bot_strategytime < time)
536 self.bot_strategytime = time + cvar("bot_ai_strategyinterval");
537 navigation_goalrating_start();
538 havocbot_goalrating_ctf_ourstolenflag(50000);
539 havocbot_goalrating_ctf_droppedflags(50000);
540 havocbot_goalrating_items(10000, self.origin, 10000);
541 navigation_goalrating_end();
547 //if carrying flag, change role to flag carrier
548 //if our flag taken, change role to interceptor
549 //if see flag (of either team) follow it (this has many implications)
550 //(10-20 second timer) change role to defense or offense
551 //go to least recently visited area
552 void havocbot_role_ctf_middle()
555 if (self.flagcarried)
557 dprint("changing role to carrier\n");
558 self.havocbot_role = havocbot_role_ctf_carrier;
559 self.havocbot_role_timeout = 0;
560 self.bot_cantfindflag = time + 10;
564 f = ctf_worldflaglist;
567 if (self.team == f.team)
569 f = f.ctf_worldflagnext;
571 if (f.cnt != FLAG_BASE && canreach(f))
573 dprint("changing role to interceptor\n");
574 self.havocbot_previous_role = self.havocbot_role;
575 self.havocbot_role = havocbot_role_ctf_interceptor;
576 self.havocbot_role_timeout = 0;
579 if (!self.havocbot_role_timeout)
580 self.havocbot_role_timeout = time + random() * 10 + 10;
581 if (time > self.havocbot_role_timeout)
585 dprint("changing role to offense\n");
586 self.havocbot_role = havocbot_role_ctf_offense;
590 dprint("changing role to defense\n");
591 self.havocbot_role = havocbot_role_ctf_defense;
593 self.havocbot_role_timeout = 0;
597 if (self.bot_strategytime < time)
599 self.bot_strategytime = time + cvar("bot_ai_strategyinterval");
600 navigation_goalrating_start();
601 havocbot_goalrating_ctf_ourstolenflag(50000);
602 havocbot_goalrating_ctf_droppedflags(30000);
603 //havocbot_goalrating_enemyplayers(1000, self.origin, 1000);
604 havocbot_goalrating_items(10000, self.origin, 10000);
605 navigation_goalrating_end();
610 //if rockets < 25 || health < 100, change role to middle
611 //if carrying flag, change role to flag carrier
612 //if our flag taken, change role to interceptor
613 //(30-50 second timer) change role to middle
614 //move to nearest unclaimed defense spot
615 void havocbot_role_ctf_defense()
618 if (self.flagcarried)
620 dprint("changing role to carrier\n");
621 self.havocbot_role = havocbot_role_ctf_carrier;
622 self.havocbot_role_timeout = 0;
623 self.bot_cantfindflag = time + 10;
627 f = ctf_worldflaglist;
630 if (self.team == f.team)
632 f = f.ctf_worldflagnext;
634 if (f.cnt != FLAG_BASE && canreach(f))
636 dprint("changing role to interceptor\n");
637 self.havocbot_previous_role = self.havocbot_role;
638 self.havocbot_role = havocbot_role_ctf_interceptor;
639 self.havocbot_role_timeout = 0;
642 if (!self.havocbot_role_timeout)
643 self.havocbot_role_timeout = time + random() * 20 + 30;
644 if (time > self.havocbot_role_timeout)
646 dprint("changing role to middle\n");
647 self.havocbot_role = havocbot_role_ctf_middle;
648 self.havocbot_role_timeout = 0;
651 if (self.bot_strategytime < time)
653 self.bot_strategytime = time + cvar("bot_ai_strategyinterval");
654 navigation_goalrating_start();
655 havocbot_goalrating_ctf_ourstolenflag(200000);
656 havocbot_goalrating_ctf_droppedflags(50000);
657 havocbot_goalrating_items(10000, f.origin, 10000);
658 navigation_goalrating_end();
661 // FIXME: place info_ctf_defensepoint entities in CTF maps and use them
662 // change position occasionally
663 if (time > self.bot_strategytime || self.goalentity.classname != "info_ctf_defensepoint")
665 self.bot_strategytime = time + random() * 45 + 15;
666 self.goalentity = world;
667 head = findchain(classname, "info_ctf_defensepoint");
670 if (time > head.count)
672 self.goalentity = head;
677 // if there are no defensepoints defined, switch to middle
678 if (self.goalentity == world)
680 dprint("changing role to middle\n");
681 self.havocbot_role = havocbot_role_ctf_middle;
682 self.havocbot_role_timeout = 0;
686 // keep anyone else from taking this spot
687 if (self.goalentity != world)
688 self.goalentity.count = time + 0.5;
693 // choose a role according to the situation
694 void() havocbot_role_dm;
695 void havocbot_chooserole_ctf()
698 dprint("choose CTF role...\n");
699 if (self.team == COLOR_TEAM3 || self.team == COLOR_TEAM4)
700 self.havocbot_role = havocbot_role_ctf_rogue;
705 self.havocbot_role = havocbot_role_ctf_offense;
707 self.havocbot_role = havocbot_role_ctf_middle;
709 self.havocbot_role = havocbot_role_ctf_defense;
714 //go to best items, or control points you don't own
715 void havocbot_role_dom()
717 if (self.bot_strategytime < time)
719 self.bot_strategytime = time + cvar("bot_ai_strategyinterval");
720 navigation_goalrating_start();
721 havocbot_goalrating_controlpoints(10000, self.origin, 15000);
722 havocbot_goalrating_items(8000, self.origin, 8000);
723 //havocbot_goalrating_enemyplayers(3000, self.origin, 2000);
724 //havocbot_goalrating_waypoints(1, self.origin, 1000);
725 navigation_goalrating_end();
731 void havocbot_role_dm()
733 if (self.bot_strategytime < time)
735 self.bot_strategytime = time + cvar("bot_ai_strategyinterval");
736 navigation_goalrating_start();
737 havocbot_goalrating_items(10000, self.origin, 10000);
738 havocbot_goalrating_enemyplayers(20000, self.origin, 10000);
739 //havocbot_goalrating_waypoints(1, self.origin, 1000);
740 navigation_goalrating_end();
745 //go to next checkpoint, and annoy enemies
746 .float race_checkpoint;
747 void havocbot_role_race()
750 if (self.bot_strategytime < time)
752 self.bot_strategytime = time + cvar("bot_ai_strategyinterval");
753 navigation_goalrating_start();
755 havocbot_goalrating_items(100, self.origin, 10000);
756 havocbot_goalrating_enemyplayers(500, self.origin, 20000);
759 for(e = world; (e = find(e, classname, "trigger_race_checkpoint")) != world; )
761 if(e.cnt == self.race_checkpoint)
763 navigation_routerating(e, 1000000, 5000);
765 else if(self.race_checkpoint == -1)
767 navigation_routerating(e, 1000000, 5000);
771 navigation_goalrating_end();
775 void havocbot_chooserole_dm()
777 self.havocbot_role = havocbot_role_dm;
780 void havocbot_chooserole_race()
782 self.havocbot_role = havocbot_role_race;
785 void havocbot_chooserole_dom()
787 self.havocbot_role = havocbot_role_dom;
795 entity kh_worldkeylist;
796 .entity kh_worldkeynext;
797 void havocbot_goalrating_kh(float ratingscale_team, float ratingscale_dropped, float ratingscale_enemy)
800 for (head = kh_worldkeylist; head; head = head.kh_worldkeynext)
802 if(head.owner == self)
804 if(!kh_tracking_enabled)
806 // if it's carried by our team we know about it
807 // otherwise we have to see it to know about it
808 if(!head.owner || head.team != self.team)
810 traceline(self.origin + self.view_ofs, head.origin, MOVE_NOMONSTERS, self);
811 if (trace_fraction < 1 && trace_ent != head)
812 continue; // skip what I can't see
816 navigation_routerating(head, ratingscale_dropped, 100000);
817 else if(head.team == self.team)
818 navigation_routerating(head, ratingscale_team, 100000);
820 navigation_routerating(head, ratingscale_enemy, 100000);
824 void() havocbot_role_kh_carrier;
825 void() havocbot_role_kh_defense;
826 void() havocbot_role_kh_offense;
827 void() havocbot_role_kh_freelancer;
828 void havocbot_role_kh_carrier()
830 if (!(self.items & IT_KEY1))
832 dprint("changing role to freelancer\n");
833 self.havocbot_role = havocbot_role_kh_freelancer;
834 self.havocbot_role_timeout = 0;
838 if (self.bot_strategytime < time)
840 self.bot_strategytime = time + cvar("bot_ai_strategyinterval");
841 navigation_goalrating_start();
843 if(kh_Key_AllOwnedByWhichTeam() == self.team)
844 havocbot_goalrating_kh(100000, 1, 1); // bring home
846 havocbot_goalrating_kh(40000, 40000, 1000); // play defensively
848 havocbot_goalrating_items(10000, self.origin, 10000);
849 navigation_goalrating_end();
853 void havocbot_role_kh_defense()
855 if (self.items & IT_KEY1)
857 dprint("changing role to carrier\n");
858 self.havocbot_role = havocbot_role_kh_carrier;
859 self.havocbot_role_timeout = 0;
863 if (!self.havocbot_role_timeout)
864 self.havocbot_role_timeout = time + random() * 10 + 20;
865 if (time > self.havocbot_role_timeout)
867 dprint("changing role to freelancer\n");
868 self.havocbot_role = havocbot_role_kh_freelancer;
869 self.havocbot_role_timeout = 0;
873 if (self.bot_strategytime < time)
875 float key_owner_team;
876 self.bot_strategytime = time + cvar("bot_ai_strategyinterval");
877 navigation_goalrating_start();
879 key_owner_team = kh_Key_AllOwnedByWhichTeam();
880 if(key_owner_team == self.team)
881 havocbot_goalrating_kh(100000, 1, 1); // defend key carriers
882 else if(key_owner_team == -1)
883 havocbot_goalrating_kh(40000, 10000, 1); // play defensively
885 havocbot_goalrating_kh(1, 1, 100000); // ATTACK ANYWAY
887 havocbot_goalrating_items(10000, self.origin, 10000);
888 navigation_goalrating_end();
892 void havocbot_role_kh_offense()
894 if (self.items & IT_KEY1)
896 dprint("changing role to carrier\n");
897 self.havocbot_role = havocbot_role_kh_carrier;
898 self.havocbot_role_timeout = 0;
902 if (!self.havocbot_role_timeout)
903 self.havocbot_role_timeout = time + random() * 10 + 20;
904 if (time > self.havocbot_role_timeout)
906 dprint("changing role to freelancer\n");
907 self.havocbot_role = havocbot_role_kh_freelancer;
908 self.havocbot_role_timeout = 0;
912 if (self.bot_strategytime < time)
914 float key_owner_team;
916 self.bot_strategytime = time + cvar("bot_ai_strategyinterval");
917 navigation_goalrating_start();
919 key_owner_team = kh_Key_AllOwnedByWhichTeam();
920 if(key_owner_team == self.team)
921 havocbot_goalrating_kh(100000, 1, 1); // defend anyway
922 else if(key_owner_team == -1)
923 havocbot_goalrating_kh(1, 10000, 40000); // play offensively
925 havocbot_goalrating_kh(1, 1, 100000); // ATTACK! EMERGENCY!
927 havocbot_goalrating_items(10000, self.origin, 10000);
928 navigation_goalrating_end();
932 void havocbot_role_kh_freelancer()
934 if (self.items & IT_KEY1)
936 dprint("changing role to carrier\n");
937 self.havocbot_role = havocbot_role_kh_carrier;
938 self.havocbot_role_timeout = 0;
942 if (!self.havocbot_role_timeout)
943 self.havocbot_role_timeout = time + random() * 10 + 10;
944 if (time > self.havocbot_role_timeout)
948 dprint("changing role to offense\n");
949 self.havocbot_role = havocbot_role_kh_offense;
953 dprint("changing role to defense\n");
954 self.havocbot_role = havocbot_role_kh_defense;
956 self.havocbot_role_timeout = 0;
960 if (self.bot_strategytime < time)
962 float key_owner_team;
964 self.bot_strategytime = time + cvar("bot_ai_strategyinterval");
965 navigation_goalrating_start();
967 key_owner_team = kh_Key_AllOwnedByWhichTeam();
968 if(key_owner_team == self.team)
969 havocbot_goalrating_kh(100000, 1, 1); // defend anyway
970 else if(key_owner_team == -1)
971 havocbot_goalrating_kh(10000, 40000, 10000); // prefer dropped keys
973 havocbot_goalrating_kh(1, 1, 100000); // ATTACK ANYWAY
975 havocbot_goalrating_items(10000, self.origin, 10000);
976 navigation_goalrating_end();
984 void havocbot_chooserole_kh()
989 self.havocbot_role = havocbot_role_kh_offense;
991 self.havocbot_role = havocbot_role_kh_defense;
993 self.havocbot_role = havocbot_role_kh_freelancer;
996 void havocbot_chooserole()
998 dprint("choose a role...\n");
999 navigation_routetogoal(world);
1000 self.bot_strategytime = -1;
1002 havocbot_chooserole_ctf();
1003 else if (g_domination)
1004 havocbot_chooserole_dom();
1006 havocbot_chooserole_kh();
1008 havocbot_chooserole_race();
1009 else // assume anything else is deathmatch
1010 havocbot_chooserole_dm();