1 void() havocbot_role_ft_freeing;
2 void() havocbot_role_ft_offense;
4 void havocbot_goalrating_kh(float ratingscale_team, float ratingscale_dropped, float ratingscale_enemy)
7 for (head = kh_worldkeylist; head; head = head.kh_worldkeynext)
11 if(!kh_tracking_enabled)
13 // if it's carried by our team we know about it
14 // otherwise we have to see it to know about it
15 if(!head.owner || head.team != self.team)
17 traceline(self.origin + self.view_ofs, head.origin, MOVE_NOMONSTERS, self);
18 if (trace_fraction < 1 && trace_ent != head)
19 continue; // skip what I can't see
23 navigation_routerating(head, ratingscale_dropped * BOT_PICKUP_RATING_HIGH, 100000);
24 else if(head.team == self.team)
25 navigation_routerating(head.owner, ratingscale_team * BOT_PICKUP_RATING_HIGH, 100000);
27 navigation_routerating(head.owner, ratingscale_enemy * BOT_PICKUP_RATING_HIGH, 100000);
30 havocbot_goalrating_items(1, self.origin, 10000);
33 void havocbot_role_kh_carrier()
35 if(self.deadflag != DEAD_NO)
40 dprint("changing role to freelancer\n");
41 self.havocbot_role = havocbot_role_kh_freelancer;
42 self.havocbot_role_timeout = 0;
46 if (self.bot_strategytime < time)
48 self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
49 navigation_goalrating_start();
51 if(kh_Key_AllOwnedByWhichTeam() == self.team)
52 havocbot_goalrating_kh(10, 0.1, 0.1); // bring home
54 havocbot_goalrating_kh(4, 4, 1); // play defensively
56 navigation_goalrating_end();
60 void havocbot_role_kh_defense()
62 if(self.deadflag != DEAD_NO)
67 dprint("changing role to carrier\n");
68 self.havocbot_role = havocbot_role_kh_carrier;
69 self.havocbot_role_timeout = 0;
73 if (!self.havocbot_role_timeout)
74 self.havocbot_role_timeout = time + random() * 10 + 20;
75 if (time > self.havocbot_role_timeout)
77 dprint("changing role to freelancer\n");
78 self.havocbot_role = havocbot_role_kh_freelancer;
79 self.havocbot_role_timeout = 0;
83 if (self.bot_strategytime < time)
86 self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
87 navigation_goalrating_start();
89 key_owner_team = kh_Key_AllOwnedByWhichTeam();
90 if(key_owner_team == self.team)
91 havocbot_goalrating_kh(10, 0.1, 0.1); // defend key carriers
92 else if(key_owner_team == -1)
93 havocbot_goalrating_kh(4, 1, 0.1); // play defensively
95 havocbot_goalrating_kh(0.1, 0.1, 10); // ATTACK ANYWAY
97 navigation_goalrating_end();
101 void havocbot_role_kh_offense()
103 if(self.deadflag != DEAD_NO)
108 dprint("changing role to carrier\n");
109 self.havocbot_role = havocbot_role_kh_carrier;
110 self.havocbot_role_timeout = 0;
114 if (!self.havocbot_role_timeout)
115 self.havocbot_role_timeout = time + random() * 10 + 20;
116 if (time > self.havocbot_role_timeout)
118 dprint("changing role to freelancer\n");
119 self.havocbot_role = havocbot_role_kh_freelancer;
120 self.havocbot_role_timeout = 0;
124 if (self.bot_strategytime < time)
126 float key_owner_team;
128 self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
129 navigation_goalrating_start();
131 key_owner_team = kh_Key_AllOwnedByWhichTeam();
132 if(key_owner_team == self.team)
133 havocbot_goalrating_kh(10, 0.1, 0.1); // defend anyway
134 else if(key_owner_team == -1)
135 havocbot_goalrating_kh(0.1, 1, 4); // play offensively
137 havocbot_goalrating_kh(0.1, 0.1, 10); // ATTACK! EMERGENCY!
139 navigation_goalrating_end();
143 void havocbot_role_kh_freelancer()
145 if(self.deadflag != DEAD_NO)
150 dprint("changing role to carrier\n");
151 self.havocbot_role = havocbot_role_kh_carrier;
152 self.havocbot_role_timeout = 0;
156 if (!self.havocbot_role_timeout)
157 self.havocbot_role_timeout = time + random() * 10 + 10;
158 if (time > self.havocbot_role_timeout)
162 dprint("changing role to offense\n");
163 self.havocbot_role = havocbot_role_kh_offense;
167 dprint("changing role to defense\n");
168 self.havocbot_role = havocbot_role_kh_defense;
170 self.havocbot_role_timeout = 0;
174 if (self.bot_strategytime < time)
176 float key_owner_team;
178 self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
179 navigation_goalrating_start();
181 key_owner_team = kh_Key_AllOwnedByWhichTeam();
182 if(key_owner_team == self.team)
183 havocbot_goalrating_kh(10, 0.1, 0.1); // defend anyway
184 else if(key_owner_team == -1)
185 havocbot_goalrating_kh(1, 10, 4); // prefer dropped keys
187 havocbot_goalrating_kh(0.1, 0.1, 10); // ATTACK ANYWAY
189 navigation_goalrating_end();
193 void havocbot_chooserole_ft()
195 if(self.deadflag != DEAD_NO)
198 self.havocbot_role = havocbot_role_ft_offensive;