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 if (cvar("bot_nofire"))
263 // don't chase players if we're under water
264 if(self.waterlevel>WATERLEVEL_WETFEET)
267 FOR_EACH_PLAYER(head)
269 // TODO: Merge this logic with the bot_shouldattack function
272 if ((noteam && (!bot_ignore_bots || clienttype(head) == CLIENTTYPE_REAL)) || head.team != self.team)
274 distance = vlen(head.origin - org);
275 if (distance < 100 || distance > sradius)
279 if(head.items & IT_STRENGTH)
282 // rate only visible enemies
284 traceline(self.origin + self.view_ofs, head.origin, MOVE_NOMONSTERS, self);
285 if (trace_fraction < 1 || trace_ent != head)
289 if(head.flags & FL_INWATER || head.flags & FL_PARTIALGROUND)
293 if(head.flags & FL_ONGROUND == 0)
295 traceline(head.origin, head.origin + '0 0 -1500', TRUE, world);
296 t = pointcontents(trace_endpos + '0 0 1');
297 if( t != CONTENT_SOLID )
298 if(t & CONTENT_WATER || t & CONTENT_SLIME || t & CONTENT_LAVA)
300 if(tracebox_hits_trigger_hurt(head.origin, head.mins, head.maxs, trace_endpos))
304 t = (self.health + self.armorvalue ) / (head.health + head.armorvalue );
305 navigation_routerating(head, t * ratingscale, 2000);
311 void() havocbot_role_ctf_middle;
312 void() havocbot_role_ctf_defense;
313 void() havocbot_role_ctf_offense;
314 void() havocbot_role_ctf_interceptor;
316 void havocbot_goalrating_ctf_carrieritems(float ratingscale, vector org, float sradius)
320 head = findchainfloat(bot_pickup, TRUE);
323 // look for health and armor only
324 if (head.solid) // must be possible to pick up (respawning items don't count)
325 if (head.health || head.armorvalue)
326 if (vlen(head.origin - org) < sradius)
329 //if (!head.bot_pickupevalfunc || head.model == "")
331 // get the value of the item
332 t = head.bot_pickupevalfunc(self, head) * 0.0001;
334 navigation_routerating(head, t * ratingscale, 500);
340 entity ctf_worldflaglist;
341 .entity ctf_worldflagnext;
342 void havocbot_goalrating_ctf_ourflag(float ratingscale)
345 head = ctf_worldflaglist;
348 if (self.team == head.team)
350 head = head.ctf_worldflagnext;
353 navigation_routerating(head, ratingscale, 10000);
356 void havocbot_goalrating_ctf_enemyflag(float ratingscale)
359 head = ctf_worldflaglist;
362 if (self.team != head.team)
364 head = head.ctf_worldflagnext;
367 navigation_routerating(head, ratingscale, 10000);
370 void havocbot_goalrating_ctf_enemybase(float ratingscale)
372 // div0: needs a change in the CTF code
375 void havocbot_goalrating_ctf_ourstolenflag(float ratingscale)
378 head = ctf_worldflaglist;
381 if (self.team == head.team)
383 head = head.ctf_worldflagnext;
386 if (head.cnt != FLAG_BASE)
387 navigation_routerating(head, ratingscale, 10000);
390 void havocbot_goalrating_ctf_droppedflags(float ratingscale)
393 head = ctf_worldflaglist;
396 if (head.cnt != FLAG_BASE) // flag is carried or out in the field
397 navigation_routerating(head, ratingscale, 10000);
398 head = head.ctf_worldflagnext;
402 // CTF: (always teamplay)
404 //role rogue: (is this used?)
405 //pick up items and dropped flags (with big rating boost to dropped flags)
406 void havocbot_role_ctf_rogue()
408 if (self.bot_strategytime < time)
410 self.bot_strategytime = time + cvar("bot_ai_strategyinterval");
411 navigation_goalrating_start();
412 havocbot_goalrating_ctf_droppedflags(5000);
413 //havocbot_goalrating_enemyplayers(3000, self.origin, 3000);
414 havocbot_goalrating_items(10000, self.origin, 10000);
415 navigation_goalrating_end();
420 //pick up armor and health
421 //go to our flag spot
422 .float bot_cantfindflag;
423 void havocbot_role_ctf_carrier()
425 if (self.flagcarried == world)
427 dprint("changing role to middle\n");
428 self.havocbot_role = havocbot_role_ctf_middle;
429 self.havocbot_role_timeout = 0;
432 if (self.bot_strategytime < time)
434 self.bot_strategytime = time + cvar("bot_ai_strategyinterval");
435 navigation_goalrating_start();
436 havocbot_goalrating_ctf_ourflag(50000);
437 if (navigation_bestgoal)
438 self.bot_cantfindflag = time + 10;
439 else if (time > self.bot_cantfindflag)
441 // can't navigate to our own flag :(
442 Damage(self, self, self, 100000, DEATH_KILL, self.origin, '0 0 0');
444 havocbot_goalrating_ctf_carrieritems(1000, self.origin, 1000);
445 navigation_goalrating_end();
450 //pick up armor and health
451 //if rockets < 25 || health < 100, change role to middle
452 //if carrying flag, change role to flag carrier
453 //if our flag taken, change role to interceptor
454 //(60-90 second timer) change role to middle
456 void havocbot_role_ctf_offense()
459 if (self.flagcarried)
461 dprint("changing role to carrier\n");
462 self.havocbot_role = havocbot_role_ctf_carrier;
463 self.havocbot_role_timeout = 0;
464 self.bot_cantfindflag = time + 10;
468 f = ctf_worldflaglist;
471 if (self.team == f.team)
473 f = f.ctf_worldflagnext;
475 if (f.cnt != FLAG_BASE && canreach(f))
477 dprint("changing role to interceptor\n");
478 self.havocbot_previous_role = self.havocbot_role;
479 self.havocbot_role = havocbot_role_ctf_interceptor;
480 self.havocbot_role_timeout = 0;
483 if (!self.havocbot_role_timeout)
484 self.havocbot_role_timeout = time + random() * 30 + 60;
485 if (time > self.havocbot_role_timeout)
487 dprint("changing role to middle\n");
488 self.havocbot_role = havocbot_role_ctf_middle;
489 self.havocbot_role_timeout = 0;
492 if (self.bot_strategytime < time)
494 self.bot_strategytime = time + cvar("bot_ai_strategyinterval");
495 navigation_goalrating_start();
496 havocbot_goalrating_ctf_ourstolenflag(50000);
497 havocbot_goalrating_ctf_enemyflag(30000);
498 havocbot_goalrating_ctf_enemybase(20000);
499 havocbot_goalrating_items(10000, self.origin, 10000);
500 navigation_goalrating_end();
504 //role interceptor (temporary role):
506 //if carrying flag, change role to flag carrier
507 //if our flag is back, change role to previous role
509 //go to least recently visited area
510 void havocbot_role_ctf_interceptor()
513 if (self.flagcarried)
515 dprint("changing role to carrier\n");
516 self.havocbot_role = havocbot_role_ctf_carrier;
517 self.havocbot_role_timeout = 0;
518 self.bot_cantfindflag = time + 10;
522 f = ctf_worldflaglist;
525 if (self.team == f.team)
527 f = f.ctf_worldflagnext;
529 if (f.cnt == FLAG_BASE)
531 dprint("changing role back\n");
532 self.havocbot_role = self.havocbot_previous_role;
533 self.havocbot_role_timeout = 0;
537 if (self.bot_strategytime < time)
539 self.bot_strategytime = time + cvar("bot_ai_strategyinterval");
540 navigation_goalrating_start();
541 havocbot_goalrating_ctf_ourstolenflag(50000);
542 havocbot_goalrating_ctf_droppedflags(50000);
543 havocbot_goalrating_items(10000, self.origin, 10000);
544 navigation_goalrating_end();
550 //if carrying flag, change role to flag carrier
551 //if our flag taken, change role to interceptor
552 //if see flag (of either team) follow it (this has many implications)
553 //(10-20 second timer) change role to defense or offense
554 //go to least recently visited area
555 void havocbot_role_ctf_middle()
558 if (self.flagcarried)
560 dprint("changing role to carrier\n");
561 self.havocbot_role = havocbot_role_ctf_carrier;
562 self.havocbot_role_timeout = 0;
563 self.bot_cantfindflag = time + 10;
567 f = ctf_worldflaglist;
570 if (self.team == f.team)
572 f = f.ctf_worldflagnext;
574 if (f.cnt != FLAG_BASE && canreach(f))
576 dprint("changing role to interceptor\n");
577 self.havocbot_previous_role = self.havocbot_role;
578 self.havocbot_role = havocbot_role_ctf_interceptor;
579 self.havocbot_role_timeout = 0;
582 if (!self.havocbot_role_timeout)
583 self.havocbot_role_timeout = time + random() * 10 + 10;
584 if (time > self.havocbot_role_timeout)
588 dprint("changing role to offense\n");
589 self.havocbot_role = havocbot_role_ctf_offense;
593 dprint("changing role to defense\n");
594 self.havocbot_role = havocbot_role_ctf_defense;
596 self.havocbot_role_timeout = 0;
600 if (self.bot_strategytime < time)
602 self.bot_strategytime = time + cvar("bot_ai_strategyinterval");
603 navigation_goalrating_start();
604 havocbot_goalrating_ctf_ourstolenflag(50000);
605 havocbot_goalrating_ctf_droppedflags(30000);
606 //havocbot_goalrating_enemyplayers(1000, self.origin, 1000);
607 havocbot_goalrating_items(10000, self.origin, 10000);
608 navigation_goalrating_end();
613 //if rockets < 25 || health < 100, change role to middle
614 //if carrying flag, change role to flag carrier
615 //if our flag taken, change role to interceptor
616 //(30-50 second timer) change role to middle
617 //move to nearest unclaimed defense spot
618 void havocbot_role_ctf_defense()
621 if (self.flagcarried)
623 dprint("changing role to carrier\n");
624 self.havocbot_role = havocbot_role_ctf_carrier;
625 self.havocbot_role_timeout = 0;
626 self.bot_cantfindflag = time + 10;
630 f = ctf_worldflaglist;
633 if (self.team == f.team)
635 f = f.ctf_worldflagnext;
637 if (f.cnt != FLAG_BASE && canreach(f))
639 dprint("changing role to interceptor\n");
640 self.havocbot_previous_role = self.havocbot_role;
641 self.havocbot_role = havocbot_role_ctf_interceptor;
642 self.havocbot_role_timeout = 0;
645 if (!self.havocbot_role_timeout)
646 self.havocbot_role_timeout = time + random() * 20 + 30;
647 if (time > self.havocbot_role_timeout)
649 dprint("changing role to middle\n");
650 self.havocbot_role = havocbot_role_ctf_middle;
651 self.havocbot_role_timeout = 0;
654 if (self.bot_strategytime < time)
656 self.bot_strategytime = time + cvar("bot_ai_strategyinterval");
657 navigation_goalrating_start();
658 havocbot_goalrating_ctf_ourstolenflag(200000);
659 havocbot_goalrating_ctf_droppedflags(50000);
660 havocbot_goalrating_items(10000, f.origin, 10000);
661 navigation_goalrating_end();
664 // FIXME: place info_ctf_defensepoint entities in CTF maps and use them
665 // change position occasionally
666 if (time > self.bot_strategytime || self.goalentity.classname != "info_ctf_defensepoint")
668 self.bot_strategytime = time + random() * 45 + 15;
669 self.goalentity = world;
670 head = findchain(classname, "info_ctf_defensepoint");
673 if (time > head.count)
675 self.goalentity = head;
680 // if there are no defensepoints defined, switch to middle
681 if (self.goalentity == world)
683 dprint("changing role to middle\n");
684 self.havocbot_role = havocbot_role_ctf_middle;
685 self.havocbot_role_timeout = 0;
689 // keep anyone else from taking this spot
690 if (self.goalentity != world)
691 self.goalentity.count = time + 0.5;
696 // choose a role according to the situation
697 void() havocbot_role_dm;
698 void havocbot_chooserole_ctf()
701 dprint("choose CTF role...\n");
702 if (self.team == COLOR_TEAM3 || self.team == COLOR_TEAM4)
703 self.havocbot_role = havocbot_role_ctf_rogue;
708 self.havocbot_role = havocbot_role_ctf_offense;
710 self.havocbot_role = havocbot_role_ctf_middle;
712 self.havocbot_role = havocbot_role_ctf_defense;
717 //go to best items, or control points you don't own
718 void havocbot_role_dom()
720 if (self.bot_strategytime < time)
722 self.bot_strategytime = time + cvar("bot_ai_strategyinterval");
723 navigation_goalrating_start();
724 havocbot_goalrating_controlpoints(10000, self.origin, 15000);
725 havocbot_goalrating_items(8000, self.origin, 8000);
726 //havocbot_goalrating_enemyplayers(3000, self.origin, 2000);
727 //havocbot_goalrating_waypoints(1, self.origin, 1000);
728 navigation_goalrating_end();
734 void havocbot_role_dm()
736 if (self.bot_strategytime < time)
738 self.bot_strategytime = time + cvar("bot_ai_strategyinterval");
739 navigation_goalrating_start();
740 havocbot_goalrating_items(10000, self.origin, 10000);
741 havocbot_goalrating_enemyplayers(20000, self.origin, 10000);
742 //havocbot_goalrating_waypoints(1, self.origin, 1000);
743 navigation_goalrating_end();
748 //go to next checkpoint, and annoy enemies
749 .float race_checkpoint;
750 void havocbot_role_race()
753 if (self.bot_strategytime < time)
755 self.bot_strategytime = time + cvar("bot_ai_strategyinterval");
756 navigation_goalrating_start();
758 havocbot_goalrating_items(100, self.origin, 10000);
759 havocbot_goalrating_enemyplayers(500, self.origin, 20000);
762 for(e = world; (e = find(e, classname, "trigger_race_checkpoint")) != world; )
764 if(e.cnt == self.race_checkpoint)
766 navigation_routerating(e, 1000000, 5000);
768 else if(self.race_checkpoint == -1)
770 navigation_routerating(e, 1000000, 5000);
774 navigation_goalrating_end();
778 void havocbot_chooserole_dm()
780 self.havocbot_role = havocbot_role_dm;
783 void havocbot_chooserole_race()
785 self.havocbot_role = havocbot_role_race;
788 void havocbot_chooserole_dom()
790 self.havocbot_role = havocbot_role_dom;
798 entity kh_worldkeylist;
799 .entity kh_worldkeynext;
800 void havocbot_goalrating_kh(float ratingscale_team, float ratingscale_dropped, float ratingscale_enemy)
803 for (head = kh_worldkeylist; head; head = head.kh_worldkeynext)
805 if(head.owner == self)
807 if(!kh_tracking_enabled)
809 // if it's carried by our team we know about it
810 // otherwise we have to see it to know about it
811 if(!head.owner || head.team != self.team)
813 traceline(self.origin + self.view_ofs, head.origin, MOVE_NOMONSTERS, self);
814 if (trace_fraction < 1 && trace_ent != head)
815 continue; // skip what I can't see
819 navigation_routerating(head, ratingscale_dropped, 100000);
820 else if(head.team == self.team)
821 navigation_routerating(head, ratingscale_team, 100000);
823 navigation_routerating(head, ratingscale_enemy, 100000);
827 void() havocbot_role_kh_carrier;
828 void() havocbot_role_kh_defense;
829 void() havocbot_role_kh_offense;
830 void() havocbot_role_kh_freelancer;
831 void havocbot_role_kh_carrier()
833 if (!(self.items & IT_KEY1))
835 dprint("changing role to freelancer\n");
836 self.havocbot_role = havocbot_role_kh_freelancer;
837 self.havocbot_role_timeout = 0;
841 if (self.bot_strategytime < time)
843 self.bot_strategytime = time + cvar("bot_ai_strategyinterval");
844 navigation_goalrating_start();
846 if(kh_Key_AllOwnedByWhichTeam() == self.team)
847 havocbot_goalrating_kh(100000, 1, 1); // bring home
849 havocbot_goalrating_kh(40000, 40000, 1000); // play defensively
851 havocbot_goalrating_items(10000, self.origin, 10000);
852 navigation_goalrating_end();
856 void havocbot_role_kh_defense()
858 if (self.items & IT_KEY1)
860 dprint("changing role to carrier\n");
861 self.havocbot_role = havocbot_role_kh_carrier;
862 self.havocbot_role_timeout = 0;
866 if (!self.havocbot_role_timeout)
867 self.havocbot_role_timeout = time + random() * 10 + 20;
868 if (time > self.havocbot_role_timeout)
870 dprint("changing role to freelancer\n");
871 self.havocbot_role = havocbot_role_kh_freelancer;
872 self.havocbot_role_timeout = 0;
876 if (self.bot_strategytime < time)
878 float key_owner_team;
879 self.bot_strategytime = time + cvar("bot_ai_strategyinterval");
880 navigation_goalrating_start();
882 key_owner_team = kh_Key_AllOwnedByWhichTeam();
883 if(key_owner_team == self.team)
884 havocbot_goalrating_kh(100000, 1, 1); // defend key carriers
885 else if(key_owner_team == -1)
886 havocbot_goalrating_kh(40000, 10000, 1); // play defensively
888 havocbot_goalrating_kh(1, 1, 100000); // ATTACK ANYWAY
890 havocbot_goalrating_items(10000, self.origin, 10000);
891 navigation_goalrating_end();
895 void havocbot_role_kh_offense()
897 if (self.items & IT_KEY1)
899 dprint("changing role to carrier\n");
900 self.havocbot_role = havocbot_role_kh_carrier;
901 self.havocbot_role_timeout = 0;
905 if (!self.havocbot_role_timeout)
906 self.havocbot_role_timeout = time + random() * 10 + 20;
907 if (time > self.havocbot_role_timeout)
909 dprint("changing role to freelancer\n");
910 self.havocbot_role = havocbot_role_kh_freelancer;
911 self.havocbot_role_timeout = 0;
915 if (self.bot_strategytime < time)
917 float key_owner_team;
919 self.bot_strategytime = time + cvar("bot_ai_strategyinterval");
920 navigation_goalrating_start();
922 key_owner_team = kh_Key_AllOwnedByWhichTeam();
923 if(key_owner_team == self.team)
924 havocbot_goalrating_kh(100000, 1, 1); // defend anyway
925 else if(key_owner_team == -1)
926 havocbot_goalrating_kh(1, 10000, 40000); // play offensively
928 havocbot_goalrating_kh(1, 1, 100000); // ATTACK! EMERGENCY!
930 havocbot_goalrating_items(10000, self.origin, 10000);
931 navigation_goalrating_end();
935 void havocbot_role_kh_freelancer()
937 if (self.items & IT_KEY1)
939 dprint("changing role to carrier\n");
940 self.havocbot_role = havocbot_role_kh_carrier;
941 self.havocbot_role_timeout = 0;
945 if (!self.havocbot_role_timeout)
946 self.havocbot_role_timeout = time + random() * 10 + 10;
947 if (time > self.havocbot_role_timeout)
951 dprint("changing role to offense\n");
952 self.havocbot_role = havocbot_role_kh_offense;
956 dprint("changing role to defense\n");
957 self.havocbot_role = havocbot_role_kh_defense;
959 self.havocbot_role_timeout = 0;
963 if (self.bot_strategytime < time)
965 float key_owner_team;
967 self.bot_strategytime = time + cvar("bot_ai_strategyinterval");
968 navigation_goalrating_start();
970 key_owner_team = kh_Key_AllOwnedByWhichTeam();
971 if(key_owner_team == self.team)
972 havocbot_goalrating_kh(100000, 1, 1); // defend anyway
973 else if(key_owner_team == -1)
974 havocbot_goalrating_kh(10000, 40000, 10000); // prefer dropped keys
976 havocbot_goalrating_kh(1, 1, 100000); // ATTACK ANYWAY
978 havocbot_goalrating_items(10000, self.origin, 10000);
979 navigation_goalrating_end();
987 void havocbot_chooserole_kh()
992 self.havocbot_role = havocbot_role_kh_offense;
994 self.havocbot_role = havocbot_role_kh_defense;
996 self.havocbot_role = havocbot_role_kh_freelancer;
999 void havocbot_chooserole()
1001 dprint("choose a role...\n");
1002 navigation_routetogoal(world);
1003 self.bot_strategytime = -1;
1005 havocbot_chooserole_ctf();
1006 else if (g_domination)
1007 havocbot_chooserole_dom();
1009 havocbot_chooserole_kh();
1011 havocbot_chooserole_race();
1012 else // assume anything else is deathmatch
1013 havocbot_chooserole_dm();