1 void() havocbot_role_kh_carrier;
2 void() havocbot_role_kh_defense;
3 void() havocbot_role_kh_offense;
4 void() havocbot_role_kh_freelancer;
6 entity kh_worldkeylist;
7 .entity kh_worldkeynext;
9 void havocbot_goalrating_kh(float ratingscale_team, float ratingscale_dropped, float ratingscale_enemy)
12 for (head = kh_worldkeylist; head; head = head.kh_worldkeynext)
14 if(head.owner == self)
16 if(!kh_tracking_enabled)
18 // if it's carried by our team we know about it
19 // otherwise we have to see it to know about it
20 if(!head.owner || head.team != self.team)
22 traceline(self.origin + self.view_ofs, head.origin, MOVE_NOMONSTERS, self);
23 if (trace_fraction < 1 && trace_ent != head)
24 continue; // skip what I can't see
28 navigation_routerating(head, ratingscale_dropped * BOT_PICKUP_RATING_HIGH, 100000);
29 else if(head.team == self.team)
30 navigation_routerating(head.owner, ratingscale_team * BOT_PICKUP_RATING_HIGH, 100000);
32 navigation_routerating(head.owner, ratingscale_enemy * BOT_PICKUP_RATING_HIGH, 100000);
35 havocbot_goalrating_items(1, self.origin, 10000);
38 void havocbot_role_kh_carrier()
40 if(self.deadflag != DEAD_NO)
45 dprint("changing role to freelancer\n");
46 self.havocbot_role = havocbot_role_kh_freelancer;
47 self.havocbot_role_timeout = 0;
51 if (self.bot_strategytime < time)
53 self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
54 navigation_goalrating_start();
56 if(kh_Key_AllOwnedByWhichTeam() == self.team)
57 havocbot_goalrating_kh(10, 0.1, 0.1); // bring home
59 havocbot_goalrating_kh(4, 4, 1); // play defensively
61 navigation_goalrating_end();
65 void havocbot_role_kh_defense()
67 if(self.deadflag != DEAD_NO)
72 dprint("changing role to carrier\n");
73 self.havocbot_role = havocbot_role_kh_carrier;
74 self.havocbot_role_timeout = 0;
78 if (!self.havocbot_role_timeout)
79 self.havocbot_role_timeout = time + random() * 10 + 20;
80 if (time > self.havocbot_role_timeout)
82 dprint("changing role to freelancer\n");
83 self.havocbot_role = havocbot_role_kh_freelancer;
84 self.havocbot_role_timeout = 0;
88 if (self.bot_strategytime < time)
91 self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
92 navigation_goalrating_start();
94 key_owner_team = kh_Key_AllOwnedByWhichTeam();
95 if(key_owner_team == self.team)
96 havocbot_goalrating_kh(10, 0.1, 0.1); // defend key carriers
97 else if(key_owner_team == -1)
98 havocbot_goalrating_kh(4, 1, 0.1); // play defensively
100 havocbot_goalrating_kh(0.1, 0.1, 10); // ATTACK ANYWAY
102 navigation_goalrating_end();
106 void havocbot_role_kh_offense()
108 if(self.deadflag != DEAD_NO)
113 dprint("changing role to carrier\n");
114 self.havocbot_role = havocbot_role_kh_carrier;
115 self.havocbot_role_timeout = 0;
119 if (!self.havocbot_role_timeout)
120 self.havocbot_role_timeout = time + random() * 10 + 20;
121 if (time > self.havocbot_role_timeout)
123 dprint("changing role to freelancer\n");
124 self.havocbot_role = havocbot_role_kh_freelancer;
125 self.havocbot_role_timeout = 0;
129 if (self.bot_strategytime < time)
131 float key_owner_team;
133 self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
134 navigation_goalrating_start();
136 key_owner_team = kh_Key_AllOwnedByWhichTeam();
137 if(key_owner_team == self.team)
138 havocbot_goalrating_kh(10, 0.1, 0.1); // defend anyway
139 else if(key_owner_team == -1)
140 havocbot_goalrating_kh(0.1, 1, 4); // play offensively
142 havocbot_goalrating_kh(0.1, 0.1, 10); // ATTACK! EMERGENCY!
144 navigation_goalrating_end();
148 void havocbot_role_kh_freelancer()
150 if(self.deadflag != DEAD_NO)
155 dprint("changing role to carrier\n");
156 self.havocbot_role = havocbot_role_kh_carrier;
157 self.havocbot_role_timeout = 0;
161 if (!self.havocbot_role_timeout)
162 self.havocbot_role_timeout = time + random() * 10 + 10;
163 if (time > self.havocbot_role_timeout)
167 dprint("changing role to offense\n");
168 self.havocbot_role = havocbot_role_kh_offense;
172 dprint("changing role to defense\n");
173 self.havocbot_role = havocbot_role_kh_defense;
175 self.havocbot_role_timeout = 0;
179 if (self.bot_strategytime < time)
181 float key_owner_team;
183 self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
184 navigation_goalrating_start();
186 key_owner_team = kh_Key_AllOwnedByWhichTeam();
187 if(key_owner_team == self.team)
188 havocbot_goalrating_kh(10, 0.1, 0.1); // defend anyway
189 else if(key_owner_team == -1)
190 havocbot_goalrating_kh(1, 10, 4); // prefer dropped keys
192 havocbot_goalrating_kh(0.1, 0.1, 10); // ATTACK ANYWAY
194 navigation_goalrating_end();
198 void havocbot_chooserole_kh()
202 if(self.deadflag != DEAD_NO)
207 self.havocbot_role = havocbot_role_kh_offense;
209 self.havocbot_role = havocbot_role_kh_defense;
211 self.havocbot_role = havocbot_role_kh_freelancer;