1 #include "role_keyhunt.qh"
2 #include "../../_all.qh"
7 #include "../navigation.qh"
9 #include "../../mutators/mutators_include.qh"
11 void() havocbot_role_kh_carrier;
12 void() havocbot_role_kh_defense;
13 void() havocbot_role_kh_offense;
14 void() havocbot_role_kh_freelancer;
17 void havocbot_goalrating_kh(float ratingscale_team, float ratingscale_dropped, float ratingscale_enemy)
20 for (head = kh_worldkeylist; head; head = head.kh_worldkeynext)
22 if(head.owner == self)
24 if(!kh_tracking_enabled)
26 // if it's carried by our team we know about it
27 // otherwise we have to see it to know about it
28 if(!head.owner || head.team != self.team)
30 traceline(self.origin + self.view_ofs, head.origin, MOVE_NOMONSTERS, self);
31 if (trace_fraction < 1 && trace_ent != head)
32 continue; // skip what I can't see
36 navigation_routerating(head, ratingscale_dropped * BOT_PICKUP_RATING_HIGH, 100000);
37 else if(head.team == self.team)
38 navigation_routerating(head.owner, ratingscale_team * BOT_PICKUP_RATING_HIGH, 100000);
40 navigation_routerating(head.owner, ratingscale_enemy * BOT_PICKUP_RATING_HIGH, 100000);
43 havocbot_goalrating_items(1, self.origin, 10000);
46 void havocbot_role_kh_carrier()
48 if(self.deadflag != DEAD_NO)
53 LOG_TRACE("changing role to freelancer\n");
54 self.havocbot_role = havocbot_role_kh_freelancer;
55 self.havocbot_role_timeout = 0;
59 if (self.bot_strategytime < time)
61 self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
62 navigation_goalrating_start();
64 if(kh_Key_AllOwnedByWhichTeam() == self.team)
65 havocbot_goalrating_kh(10, 0.1, 0.1); // bring home
67 havocbot_goalrating_kh(4, 4, 1); // play defensively
69 navigation_goalrating_end();
73 void havocbot_role_kh_defense()
75 if(self.deadflag != DEAD_NO)
80 LOG_TRACE("changing role to carrier\n");
81 self.havocbot_role = havocbot_role_kh_carrier;
82 self.havocbot_role_timeout = 0;
86 if (!self.havocbot_role_timeout)
87 self.havocbot_role_timeout = time + random() * 10 + 20;
88 if (time > self.havocbot_role_timeout)
90 LOG_TRACE("changing role to freelancer\n");
91 self.havocbot_role = havocbot_role_kh_freelancer;
92 self.havocbot_role_timeout = 0;
96 if (self.bot_strategytime < time)
99 self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
100 navigation_goalrating_start();
102 key_owner_team = kh_Key_AllOwnedByWhichTeam();
103 if(key_owner_team == self.team)
104 havocbot_goalrating_kh(10, 0.1, 0.1); // defend key carriers
105 else if(key_owner_team == -1)
106 havocbot_goalrating_kh(4, 1, 0.1); // play defensively
108 havocbot_goalrating_kh(0.1, 0.1, 10); // ATTACK ANYWAY
110 navigation_goalrating_end();
114 void havocbot_role_kh_offense()
116 if(self.deadflag != DEAD_NO)
121 LOG_TRACE("changing role to carrier\n");
122 self.havocbot_role = havocbot_role_kh_carrier;
123 self.havocbot_role_timeout = 0;
127 if (!self.havocbot_role_timeout)
128 self.havocbot_role_timeout = time + random() * 10 + 20;
129 if (time > self.havocbot_role_timeout)
131 LOG_TRACE("changing role to freelancer\n");
132 self.havocbot_role = havocbot_role_kh_freelancer;
133 self.havocbot_role_timeout = 0;
137 if (self.bot_strategytime < time)
139 float key_owner_team;
141 self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
142 navigation_goalrating_start();
144 key_owner_team = kh_Key_AllOwnedByWhichTeam();
145 if(key_owner_team == self.team)
146 havocbot_goalrating_kh(10, 0.1, 0.1); // defend anyway
147 else if(key_owner_team == -1)
148 havocbot_goalrating_kh(0.1, 1, 4); // play offensively
150 havocbot_goalrating_kh(0.1, 0.1, 10); // ATTACK! EMERGENCY!
152 navigation_goalrating_end();
156 void havocbot_role_kh_freelancer()
158 if(self.deadflag != DEAD_NO)
163 LOG_TRACE("changing role to carrier\n");
164 self.havocbot_role = havocbot_role_kh_carrier;
165 self.havocbot_role_timeout = 0;
169 if (!self.havocbot_role_timeout)
170 self.havocbot_role_timeout = time + random() * 10 + 10;
171 if (time > self.havocbot_role_timeout)
175 LOG_TRACE("changing role to offense\n");
176 self.havocbot_role = havocbot_role_kh_offense;
180 LOG_TRACE("changing role to defense\n");
181 self.havocbot_role = havocbot_role_kh_defense;
183 self.havocbot_role_timeout = 0;
187 if (self.bot_strategytime < time)
189 float key_owner_team;
191 self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
192 navigation_goalrating_start();
194 key_owner_team = kh_Key_AllOwnedByWhichTeam();
195 if(key_owner_team == self.team)
196 havocbot_goalrating_kh(10, 0.1, 0.1); // defend anyway
197 else if(key_owner_team == -1)
198 havocbot_goalrating_kh(1, 10, 4); // prefer dropped keys
200 havocbot_goalrating_kh(0.1, 0.1, 10); // ATTACK ANYWAY
202 navigation_goalrating_end();
206 void havocbot_chooserole_kh()
210 if(self.deadflag != DEAD_NO)
215 self.havocbot_role = havocbot_role_kh_offense;
217 self.havocbot_role = havocbot_role_kh_defense;
219 self.havocbot_role = havocbot_role_kh_freelancer;