1 /***********************************************
4 * "Because I ain't no Ghandi code" *
6 ***********************************************/
10 This program is in the Public Domain. My crack legal
11 team would like to add:
13 RYAN "FRIKAC" SMITH IS PROVIDING THIS SOFTWARE "AS IS"
14 AND MAKES NO WARRANTY, EXPRESS OR IMPLIED, AS TO THE
15 ACCURACY, CAPABILITY, EFFICIENCY, MERCHANTABILITY, OR
16 FUNCTIONING OF THIS SOFTWARE AND/OR DOCUMENTATION. IN
17 NO EVENT WILL RYAN "FRIKAC" SMITH BE LIABLE FOR ANY
18 GENERAL, CONSEQUENTIAL, INDIRECT, INCIDENTAL,
19 EXEMPLARY, OR SPECIAL DAMAGES, EVEN IF RYAN "FRIKAC"
20 SMITH HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
21 DAMAGES, IRRESPECTIVE OF THE CAUSE OF SUCH DAMAGES.
23 You accept this software on the condition that you
24 indemnify and hold harmless Ryan "FrikaC" Smith from
25 any and all liability or damages to third parties,
26 including attorney fees, court costs, and other
27 related costs and expenses, arising out of your use
28 of this software irrespective of the cause of said
31 The export from the United States or the subsequent
32 reexport of this software is subject to compliance
33 with United States export control and munitions
34 control restrictions. You agree that in the event you
35 seek to export this software, you assume full
36 responsibility for obtaining all necessary export
37 licenses and approvals and for assuring compliance
38 with applicable reexport restrictions.
40 Any reproduction of this software must contain
41 this notice in its entirety.
47 float(entity e) bot_size_player =
51 sz = e.health + e.armorvalue * e.armortype;
52 if (e.weapon == WEP_ROCKET_LAUNCHER)
54 else if (e.weapon == WEP_HAGAR)
56 else if (e.weapon == WEP_NEX)
58 else if (e.weapon == WEP_CRYLINK)
60 else if (e.weapon == WEP_ELECTRO)
62 else if (e.weapon == WEP_GRENADE_LAUNCHER)
64 else if (e.weapon == WEP_UZI)
66 else if (e.weapon == WEP_SHOTGUN)
68 else if (e.weapon == WEP_LASER)
70 if (e.items & 4194304) // Quad
72 if (e.items & 1048576) // Invul
74 if (e.items & 524288) // Invis
79 void() bot_dodge_stuff =
82 local float foedist, avdist, foesz, flen, tsz;
85 if (waypoint_mode > WM_LOADED)
93 v = self.origin - realorigin(self.enemy);
95 foesz = bot_size_player(self.enemy);
104 foe = find(world, classname, "grenade");
107 flen = vlen(foe.origin - self.origin);
113 foe = find(foe, classname, "grenade");
117 foe = find(world, classname, "missile");
120 if (foe.owner != self)
122 flen = vlen(foe.origin - self.origin);
129 foe = find(foe, classname, "missile");
133 foe = find(world, classname, "spike");
136 if (foe.owner != self)
138 flen = vlen(foe.origin - self.origin);
145 foe = find(foe, classname, "spike");
153 foe = findradius(self.origin, foedist);
156 if(foe.flags & FL_MONSTER)
160 flen = vlen(foe.origin - self.origin);
163 tsz = bot_size_player(foe);
187 if (foe.modelindex != 0)
191 if (!(teamplay && self.team == foe.team))
193 flen = vlen(foe.origin - self.origin);
196 tsz = bot_size_player(foe);
199 if (fov(foe) || foe.b_sound > time || self.b_skill == 3)
204 foedist = vlen(foe.origin - self.origin);
222 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
226 _x "sweet spot range" - try to maintain this range if possible
227 _y minimum range bot can be to be effective (rl/gl) (move away)
228 _z maximum range bot can be to be effective (lg/axe) (move in)
229 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
232 vector(float wep) weapon_range =
234 if (wep == IT_LASER) // IT_AXE
236 else if (wep == IT_SHOTGUN) // IT_SHOTGUN
237 return '128 0 99999';
238 else if (wep == IT_CRYLINK) // IT_SUPER_SHOTGUN
239 return '128 0 99999';
240 else if (wep == IT_UZI) // IT_NAILGUN
242 else if (wep == IT_HAGAR) // IT_SUPER_NAILGUN
243 return '180 48 3000';
244 else if (wep == IT_GRENADE_LAUNCHER) // IT_GRENADE_LAUNCHER
245 return '180 48 3000';
246 else if (wep == IT_ELECTRO) // IT_ROCKET_LAUNCHER
247 return '180 48 3000';
248 else if (wep == IT_ROCKET_LAUNCHER) // IT_ROCKET_LAUNCHER
249 return '180 48 3000';
250 else if (wep == IT_NEX) // IT_LIGHTNING
251 return '350 0 99999';
256 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
260 Pick a weapon based on range / ammo
262 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
265 void(float brange) bot_weapon_switch =
267 local float it, flag, pulse;
270 it = self.items & 127;
275 if ((self.ammo_rockets >= 3) && (it & IT_ROCKET_LAUNCHER)){flag = IT_ROCKET_LAUNCHER;pulse = 9;}
276 else if ((self.ammo_rockets >= 1) && (it & IT_HAGAR)){flag = IT_HAGAR;pulse = 8;}
277 else if ((self.ammo_cells >= 5) && (it & IT_NEX)){flag = IT_NEX;pulse = 7;}
278 else if ((self.ammo_cells >= 1) && (it & IT_CRYLINK)){flag = IT_CRYLINK;pulse = 6;}
279 else if ((self.ammo_cells >= 2) && (it & IT_ELECTRO)){flag = IT_ELECTRO;pulse = 5;}
280 else if ((self.ammo_rockets >= 3) && (it & IT_GRENADE_LAUNCHER)){flag = IT_GRENADE_LAUNCHER;pulse = 4;}
281 else if ((self.ammo_nails >= 1) && (it & IT_UZI)){flag = IT_UZI;pulse = 3;}
282 else if ((self.ammo_shells >= 1) && (it & IT_SHOTGUN)){flag = IT_SHOTGUN;pulse = 2;}
286 self.impulse = pulse;
293 self.impulse = pulse;
297 v = weapon_range(flag);
298 if (brange < v_y || brange > v_z)
303 self.impulse = pulse;
311 // quick little function to stop making him shoot the wrong way ! Argh
313 g = angcomp(self.v_angle_x, self.b_angle_x);
315 return; // argh, too far away
316 g = angcomp(self.v_angle_y, self.b_angle_y);
318 return; // not again!
323 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
327 This is the core of the bot's thinking when
330 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
333 void() bot_fight_style =
335 local vector v, v1, v2, org;
336 local float foedist, mysz, foesz;
339 if (self.enemy.health <= 0)
344 else if (!self.enemy.takedamage)
349 else if (!fisible(self.enemy))
355 org = realorigin(self.enemy);
356 makevectors(self.v_angle);
358 // decide if I should shoot
360 foedist = vlen(org - self.origin);
361 v = weapon_range(self.weapon);
362 if (foedist > v_y && foedist < v_z)
364 traceline(self.origin + self.view_ofs, self.origin + self.view_ofs + v_forward * v_z, FALSE, self);
365 if (vlen(trace_endpos - (self.origin + self.view_ofs)) >= v_y)
367 // try to avoid shooting teammates
368 if (trace_ent.classname == "player")
369 if ((trace_ent.team == self.team && teamplay) || (coop))
375 bot_weapon_switch(foedist);
377 if (!(self.b_aiflags & (AI_PRECISION | AI_BLIND | AI_OBSTRUCTED)))
379 foesz = bot_size_player(self.enemy);
380 mysz = bot_size_player(self) + 5;
399 if (self.avoid.velocity)
400 v = self.avoid.velocity;
402 v = normalize(self.avoid.origin - self.origin);
407 foedist = vlen(self.avoid.origin - (self.origin + v1));
408 if (foedist < vlen(self.avoid.origin - (self.origin + v2)))
413 else if (!self.enemy.flags & FL_MONSTER)
415 if (foedist + 32 < v_x)
416 frik_walkmove(self.origin - org);
417 else if (foedist - 32 > v_x)
418 frik_walkmove(org - self.origin);
419 else if (self.wallhug)
420 frik_walkmove(v_right);
422 frik_walkmove(v_right * -1);
427 foesz = bot_size_player(self.enemy);
428 mysz = bot_size_player(self) + 5;
434 self.keys = self.keys & 960;