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;
54 else if (e.weapon == 64)
56 else if (e.weapon == 16)
58 else if (e.weapon == 8)
60 else if (e.weapon == 4)
62 else if (e.weapon == 2)
64 else if (e.weapon == 1)
66 else if (e.weapon == 4096)
68 if (e.items & 4194304) // Quad
70 if (e.items & 1048576) // Invul
72 if (e.items & 524288) // Invis
77 void() bot_dodge_stuff =
80 local float foedist, avdist, /*scandist, */foesz, flen, tsz;
83 if (waypoint_mode > WM_LOADED)
91 v = self.origin - realorigin(self.enemy);
93 foesz = bot_size_player(self.enemy);
102 foe = find(world, classname, "grenade");
105 flen = vlen(foe.origin - self.origin);
111 foe = find(foe, classname, "grenade");
115 foe = find(world, classname, "missile");
118 if (foe.owner != self)
120 flen = vlen(foe.origin - self.origin);
127 foe = find(foe, classname, "missile");
131 foe = find(world, classname, "spike");
134 if (foe.owner != self)
136 flen = vlen(foe.origin - self.origin);
143 foe = find(foe, classname, "spike");
151 foe = findradius(self.origin, foedist);
154 if(foe.flags & FL_MONSTER)
158 flen = vlen(foe.origin - self.origin);
161 tsz = bot_size_player(foe);
185 if (foe.modelindex != 0)
189 if (!(teamplay && self.team == foe.team))
191 flen = vlen(foe.origin - self.origin);
194 tsz = bot_size_player(foe);
197 if (fov(foe) || foe.b_sound > time || self.b_skill == 3)
202 foedist = vlen(foe.origin - self.origin);
220 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
224 _x "sweet spot range" - try to maintain this range if possible
225 _y minimum range bot can be to be effective (rl/gl) (move away)
226 _z maximum range bot can be to be effective (lg/axe) (move in)
227 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
230 vector(float wep) weapon_range =
232 if (wep == 4096) // IT_AXE
234 else if (wep == 1) // IT_SHOTGUN
235 return '128 0 99999';
236 else if (wep == 2) // IT_SUPER_SHOTGUN
237 return '128 0 99999';
238 else if (wep == 4) // IT_NAILGUN
240 else if (wep == 8) // IT_SUPER_NAILGUN
242 else if (wep == 16) // IT_GRENADE_LAUNCHER
243 return '180 48 3000';
244 else if (wep == 32) // IT_ROCKET_LAUNCHER
245 return '180 48 3000';
246 else if (wep == 64) // IT_LIGHTNING
250 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
254 Pick a weapon based on range / ammo
256 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
259 void(float brange) bot_weapon_switch =
261 local float it, flag, pulse;
264 it = self.items & 127;
268 if ((self.ammo_rockets >= 1) && (it & 32))
273 else if (self.waterlevel <= 1 && self.ammo_cells >= 1 && (it & 64))
278 else if(self.ammo_nails >= 2 && (it & 8))
283 else if ((self.ammo_rockets >= 1) && (it & 16))
288 else if(self.ammo_shells >= 2 && (it & 2))
293 else if(self.ammo_nails >= 1 && (it & 4))
298 else if(self.ammo_shells >= 1 && (it & 1))
306 self.impulse = pulse;
313 self.impulse = pulse;
317 v = weapon_range(flag);
318 if (brange < v_y || brange > v_z)
323 self.impulse = pulse;
331 // quick little function to stop making him shoot the wrong way ! Argh
333 g = angcomp(self.v_angle_x, self.b_angle_x);
335 return; // argh, too far away
336 g = angcomp(self.v_angle_y, self.b_angle_y);
338 return; // not again!
343 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
347 This is the core of the bot's thinking when
350 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
353 void() bot_fight_style =
355 local vector v, v1, v2, org;
356 local float foedist, mysz, foesz;
359 if (self.enemy.health <= 0)
364 else if (!self.enemy.takedamage)
369 else if (!fisible(self.enemy))
375 org = realorigin(self.enemy);
376 makevectors(self.v_angle);
378 // decide if I should shoot
380 foedist = vlen(org - self.origin);
381 v = weapon_range(self.weapon);
382 if (foedist > v_y && foedist < v_z)
384 traceline(self.origin + self.view_ofs, self.origin + self.view_ofs + v_forward * v_z, FALSE, self);
385 if (vlen(trace_endpos - (self.origin + self.view_ofs)) >= v_y)
387 // try to avoid shooting teammates
388 if (trace_ent.classname == "player")
389 if ((trace_ent.team == self.team && teamplay) || (coop))
395 bot_weapon_switch(foedist);
397 if (!(self.b_aiflags & (AI_PRECISION | AI_BLIND | AI_OBSTRUCTED)))
399 foesz = bot_size_player(self.enemy);
400 mysz = bot_size_player(self) + 5;
419 if (self.avoid.velocity)
420 v = self.avoid.velocity;
422 v = normalize(self.avoid.origin - self.origin);
427 foedist = vlen(self.avoid.origin - (self.origin + v1));
428 if (foedist < vlen(self.avoid.origin - (self.origin + v2)))
433 else if (!self.enemy.flags & FL_MONSTER)
435 if (foedist + 32 < v_x)
436 frik_walkmove(self.origin - org);
437 else if (foedist - 32 > v_x)
438 frik_walkmove(org - self.origin);
439 else if (self.wallhug)
440 frik_walkmove(v_right);
442 frik_walkmove(v_right * -1);
447 foesz = bot_size_player(self.enemy);
448 mysz = bot_size_player(self) + 5;
454 self.keys = self.keys & 960;