1 #include "role_keyhunt.qh"
6 #include "../navigation.qh"
8 #include "../../mutators/mutators_include.qh"
10 void() havocbot_role_kh_carrier;
11 void() havocbot_role_kh_defense;
12 void() havocbot_role_kh_offense;
13 void() havocbot_role_kh_freelancer;
16 void havocbot_goalrating_kh(float ratingscale_team, float ratingscale_dropped, float ratingscale_enemy)
19 for (head = kh_worldkeylist; head; head = head.kh_worldkeynext)
21 if(head.owner == self)
23 if(!kh_tracking_enabled)
25 // if it's carried by our team we know about it
26 // otherwise we have to see it to know about it
27 if(!head.owner || head.team != self.team)
29 traceline(self.origin + self.view_ofs, head.origin, MOVE_NOMONSTERS, self);
30 if (trace_fraction < 1 && trace_ent != head)
31 continue; // skip what I can't see
35 navigation_routerating(head, ratingscale_dropped * BOT_PICKUP_RATING_HIGH, 100000);
36 else if(head.team == self.team)
37 navigation_routerating(head.owner, ratingscale_team * BOT_PICKUP_RATING_HIGH, 100000);
39 navigation_routerating(head.owner, ratingscale_enemy * BOT_PICKUP_RATING_HIGH, 100000);
42 havocbot_goalrating_items(1, self.origin, 10000);
45 void havocbot_role_kh_carrier()
47 if(self.deadflag != DEAD_NO)
52 LOG_TRACE("changing role to freelancer\n");
53 self.havocbot_role = havocbot_role_kh_freelancer;
54 self.havocbot_role_timeout = 0;
58 if (self.bot_strategytime < time)
60 self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
61 navigation_goalrating_start();
63 if(kh_Key_AllOwnedByWhichTeam() == self.team)
64 havocbot_goalrating_kh(10, 0.1, 0.1); // bring home
66 havocbot_goalrating_kh(4, 4, 1); // play defensively
68 navigation_goalrating_end();
72 void havocbot_role_kh_defense()
74 if(self.deadflag != DEAD_NO)
79 LOG_TRACE("changing role to carrier\n");
80 self.havocbot_role = havocbot_role_kh_carrier;
81 self.havocbot_role_timeout = 0;
85 if (!self.havocbot_role_timeout)
86 self.havocbot_role_timeout = time + random() * 10 + 20;
87 if (time > self.havocbot_role_timeout)
89 LOG_TRACE("changing role to freelancer\n");
90 self.havocbot_role = havocbot_role_kh_freelancer;
91 self.havocbot_role_timeout = 0;
95 if (self.bot_strategytime < time)
98 self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
99 navigation_goalrating_start();
101 key_owner_team = kh_Key_AllOwnedByWhichTeam();
102 if(key_owner_team == self.team)
103 havocbot_goalrating_kh(10, 0.1, 0.1); // defend key carriers
104 else if(key_owner_team == -1)
105 havocbot_goalrating_kh(4, 1, 0.1); // play defensively
107 havocbot_goalrating_kh(0.1, 0.1, 10); // ATTACK ANYWAY
109 navigation_goalrating_end();
113 void havocbot_role_kh_offense()
115 if(self.deadflag != DEAD_NO)
120 LOG_TRACE("changing role to carrier\n");
121 self.havocbot_role = havocbot_role_kh_carrier;
122 self.havocbot_role_timeout = 0;
126 if (!self.havocbot_role_timeout)
127 self.havocbot_role_timeout = time + random() * 10 + 20;
128 if (time > self.havocbot_role_timeout)
130 LOG_TRACE("changing role to freelancer\n");
131 self.havocbot_role = havocbot_role_kh_freelancer;
132 self.havocbot_role_timeout = 0;
136 if (self.bot_strategytime < time)
138 float key_owner_team;
140 self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
141 navigation_goalrating_start();
143 key_owner_team = kh_Key_AllOwnedByWhichTeam();
144 if(key_owner_team == self.team)
145 havocbot_goalrating_kh(10, 0.1, 0.1); // defend anyway
146 else if(key_owner_team == -1)
147 havocbot_goalrating_kh(0.1, 1, 4); // play offensively
149 havocbot_goalrating_kh(0.1, 0.1, 10); // ATTACK! EMERGENCY!
151 navigation_goalrating_end();
155 void havocbot_role_kh_freelancer()
157 if(self.deadflag != DEAD_NO)
162 LOG_TRACE("changing role to carrier\n");
163 self.havocbot_role = havocbot_role_kh_carrier;
164 self.havocbot_role_timeout = 0;
168 if (!self.havocbot_role_timeout)
169 self.havocbot_role_timeout = time + random() * 10 + 10;
170 if (time > self.havocbot_role_timeout)
174 LOG_TRACE("changing role to offense\n");
175 self.havocbot_role = havocbot_role_kh_offense;
179 LOG_TRACE("changing role to defense\n");
180 self.havocbot_role = havocbot_role_kh_defense;
182 self.havocbot_role_timeout = 0;
186 if (self.bot_strategytime < time)
188 float key_owner_team;
190 self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
191 navigation_goalrating_start();
193 key_owner_team = kh_Key_AllOwnedByWhichTeam();
194 if(key_owner_team == self.team)
195 havocbot_goalrating_kh(10, 0.1, 0.1); // defend anyway
196 else if(key_owner_team == -1)
197 havocbot_goalrating_kh(1, 10, 4); // prefer dropped keys
199 havocbot_goalrating_kh(0.1, 0.1, 10); // ATTACK ANYWAY
201 navigation_goalrating_end();
205 void havocbot_chooserole_kh()
209 if(self.deadflag != DEAD_NO)
214 self.havocbot_role = havocbot_role_kh_offense;
216 self.havocbot_role = havocbot_role_kh_defense;
218 self.havocbot_role = havocbot_role_kh_freelancer;