2003-02-18 23:11:05 +00:00
|
|
|
/***********************************************
|
|
|
|
* *
|
|
|
|
* FrikBot Fight Code *
|
|
|
|
* "Because I ain't no Ghandi code" *
|
|
|
|
* *
|
|
|
|
***********************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
This program is in the Public Domain. My crack legal
|
|
|
|
team would like to add:
|
|
|
|
|
|
|
|
RYAN "FRIKAC" SMITH IS PROVIDING THIS SOFTWARE "AS IS"
|
|
|
|
AND MAKES NO WARRANTY, EXPRESS OR IMPLIED, AS TO THE
|
|
|
|
ACCURACY, CAPABILITY, EFFICIENCY, MERCHANTABILITY, OR
|
|
|
|
FUNCTIONING OF THIS SOFTWARE AND/OR DOCUMENTATION. IN
|
|
|
|
NO EVENT WILL RYAN "FRIKAC" SMITH BE LIABLE FOR ANY
|
|
|
|
GENERAL, CONSEQUENTIAL, INDIRECT, INCIDENTAL,
|
|
|
|
EXEMPLARY, OR SPECIAL DAMAGES, EVEN IF RYAN "FRIKAC"
|
|
|
|
SMITH HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
|
|
|
DAMAGES, IRRESPECTIVE OF THE CAUSE OF SUCH DAMAGES.
|
|
|
|
|
|
|
|
You accept this software on the condition that you
|
|
|
|
indemnify and hold harmless Ryan "FrikaC" Smith from
|
|
|
|
any and all liability or damages to third parties,
|
|
|
|
including attorney fees, court costs, and other
|
|
|
|
related costs and expenses, arising out of your use
|
|
|
|
of this software irrespective of the cause of said
|
|
|
|
liability.
|
|
|
|
|
|
|
|
The export from the United States or the subsequent
|
|
|
|
reexport of this software is subject to compliance
|
|
|
|
with United States export control and munitions
|
|
|
|
control restrictions. You agree that in the event you
|
|
|
|
seek to export this software, you assume full
|
|
|
|
responsibility for obtaining all necessary export
|
|
|
|
licenses and approvals and for assuring compliance
|
|
|
|
with applicable reexport restrictions.
|
|
|
|
|
|
|
|
Any reproduction of this software must contain
|
|
|
|
this notice in its entirety.
|
|
|
|
*/
|
|
|
|
|
2003-02-24 16:05:25 +00:00
|
|
|
#include "libfrikbot.h"
|
|
|
|
|
2003-08-18 06:30:05 +00:00
|
|
|
integer bot_fight_linker;
|
|
|
|
|
2003-07-23 22:44:15 +00:00
|
|
|
/*
|
|
|
|
weapon_range
|
|
|
|
|
|
|
|
_x "sweet spot range" - try to maintain this range if possible
|
|
|
|
_y minimum range bot can be to be effective (rl/gl) (move away)
|
|
|
|
_z maximum range bot can be to be effective (lg/axe) (move in)
|
|
|
|
*/
|
|
|
|
vector (float wep)
|
|
|
|
weapon_range =
|
|
|
|
{
|
|
|
|
switch (wep) {
|
2003-07-31 18:36:19 +00:00
|
|
|
case IT_AXE:
|
2003-07-23 22:44:15 +00:00
|
|
|
return '48 0 64';
|
2003-07-31 18:36:19 +00:00
|
|
|
case IT_SHOTGUN:
|
2003-07-23 22:44:15 +00:00
|
|
|
return '128 0 99999';
|
2003-07-31 18:36:19 +00:00
|
|
|
case IT_SUPER_SHOTGUN:
|
2003-07-23 22:44:15 +00:00
|
|
|
return '128 0 99999';
|
2003-07-31 18:36:19 +00:00
|
|
|
case IT_NAILGUN:
|
2003-07-23 22:44:15 +00:00
|
|
|
return '180 0 3000';
|
2003-07-31 18:36:19 +00:00
|
|
|
case IT_SUPER_NAILGUN:
|
2003-07-23 22:44:15 +00:00
|
|
|
return '180 0 3000';
|
2003-07-31 18:36:19 +00:00
|
|
|
case IT_GRENADE_LAUNCHER:
|
2003-07-23 22:44:15 +00:00
|
|
|
return '180 48 3000';
|
2003-07-31 18:36:19 +00:00
|
|
|
case IT_ROCKET_LAUNCHER:
|
2003-07-23 22:44:15 +00:00
|
|
|
return '180 48 3000';
|
2003-07-31 18:36:19 +00:00
|
|
|
case IT_LIGHTNING:
|
2003-07-23 22:44:15 +00:00
|
|
|
return '350 0 512';
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
};
|
2003-02-18 23:11:05 +00:00
|
|
|
|
2003-07-23 22:44:15 +00:00
|
|
|
@implementation Bot (Fight)
|
2003-08-18 16:48:53 +00:00
|
|
|
-(float)sizePlayer:(entity)e
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
2003-03-08 03:20:32 +00:00
|
|
|
local float sz;
|
2003-02-18 23:11:05 +00:00
|
|
|
|
|
|
|
sz = e.health + e.armorvalue * e.armortype;
|
2003-03-08 03:20:32 +00:00
|
|
|
switch (e.weapon) {
|
2003-07-31 18:36:19 +00:00
|
|
|
case IT_AXE:
|
2003-03-08 03:20:32 +00:00
|
|
|
sz -= 50;
|
|
|
|
break;
|
2003-07-31 18:36:19 +00:00
|
|
|
case IT_LIGHTNING:
|
2003-03-08 03:20:32 +00:00
|
|
|
sz += 60;
|
|
|
|
break;
|
2003-07-31 18:36:19 +00:00
|
|
|
case IT_ROCKET_LAUNCHER:
|
2003-03-08 03:20:32 +00:00
|
|
|
sz += 60;
|
|
|
|
break;
|
2003-07-31 18:36:19 +00:00
|
|
|
case IT_GRENADE_LAUNCHER:
|
2003-03-08 03:20:32 +00:00
|
|
|
sz += 50;
|
|
|
|
break;
|
2003-07-31 18:36:19 +00:00
|
|
|
case IT_SUPER_NAILGUN:
|
2003-03-08 03:20:32 +00:00
|
|
|
sz += 50;
|
|
|
|
break;
|
2003-07-31 18:36:19 +00:00
|
|
|
case IT_NAILGUN:
|
2003-03-08 03:20:32 +00:00
|
|
|
sz += 40;
|
|
|
|
break;
|
2003-07-31 18:36:19 +00:00
|
|
|
case IT_SUPER_SHOTGUN:
|
2003-03-08 03:20:32 +00:00
|
|
|
sz += 40;
|
|
|
|
break;
|
2003-07-31 18:36:19 +00:00
|
|
|
case IT_SHOTGUN:
|
2003-03-08 03:20:32 +00:00
|
|
|
sz += 10;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2003-07-31 18:36:19 +00:00
|
|
|
if (e.items & IT_QUAD)
|
2003-03-08 03:20:32 +00:00
|
|
|
sz += 200;
|
2003-07-31 18:36:19 +00:00
|
|
|
if (e.items & IT_INVULNERABILITY)
|
2003-03-08 03:20:32 +00:00
|
|
|
sz += 300;
|
2003-07-31 18:36:19 +00:00
|
|
|
if (e.items & IT_INVISIBILITY)
|
2003-03-08 03:20:32 +00:00
|
|
|
sz += 250;
|
2003-02-18 23:11:05 +00:00
|
|
|
return sz;
|
2003-07-23 22:44:15 +00:00
|
|
|
}
|
2003-02-18 23:11:05 +00:00
|
|
|
|
2003-08-18 16:48:53 +00:00
|
|
|
-(void)dodgeStuff
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
2003-03-08 03:20:32 +00:00
|
|
|
local entity foe;
|
|
|
|
local float foedist, avdist, foesz, flen, tsz;
|
|
|
|
local vector v;
|
2003-02-18 23:11:05 +00:00
|
|
|
|
|
|
|
if (waypoint_mode > WM_LOADED)
|
|
|
|
return;
|
|
|
|
|
2003-07-30 16:53:57 +00:00
|
|
|
avoid = NIL;
|
2003-02-18 23:11:05 +00:00
|
|
|
|
2003-07-23 22:44:15 +00:00
|
|
|
if (ent.enemy) {
|
|
|
|
v = ent.origin - realorigin (ent.enemy);
|
2003-03-08 03:20:32 +00:00
|
|
|
foedist = vlen (v);
|
2003-08-18 16:48:53 +00:00
|
|
|
foesz = [self sizePlayer:ent.enemy];
|
2003-03-04 18:26:17 +00:00
|
|
|
} else {
|
2003-02-18 23:11:05 +00:00
|
|
|
foedist = 3000;
|
|
|
|
foesz = 9999999;
|
|
|
|
}
|
|
|
|
avdist = 256;
|
|
|
|
|
2003-03-08 03:20:32 +00:00
|
|
|
foe = find (NIL, classname, "grenade");
|
|
|
|
while (foe) {
|
2003-07-23 22:44:15 +00:00
|
|
|
flen = vlen (foe.origin - ent.origin);
|
2003-03-04 18:26:17 +00:00
|
|
|
if (flen < avdist) {
|
2003-02-18 23:11:05 +00:00
|
|
|
avdist = flen;
|
2003-07-30 16:53:57 +00:00
|
|
|
avoid = foe;
|
2003-02-18 23:11:05 +00:00
|
|
|
}
|
2003-03-08 03:20:32 +00:00
|
|
|
foe = find (foe, classname, "grenade");
|
2003-02-18 23:11:05 +00:00
|
|
|
}
|
2003-07-30 16:53:57 +00:00
|
|
|
if (!avoid) {
|
2003-03-08 03:20:32 +00:00
|
|
|
foe = find (NIL, classname, "missile");
|
|
|
|
while (foe) {
|
2003-07-23 22:44:15 +00:00
|
|
|
if (foe.owner != ent) {
|
|
|
|
flen = vlen (foe.origin - ent.origin);
|
2003-03-04 18:26:17 +00:00
|
|
|
if (flen < avdist) {
|
2003-02-18 23:11:05 +00:00
|
|
|
avdist = flen;
|
2003-07-30 16:53:57 +00:00
|
|
|
avoid = foe;
|
2003-02-18 23:11:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
foe = find(foe, classname, "missile");
|
|
|
|
}
|
2003-07-30 16:53:57 +00:00
|
|
|
if (!avoid) {
|
2003-02-24 16:05:25 +00:00
|
|
|
foe = find(NIL, classname, "spike");
|
2003-03-08 03:20:32 +00:00
|
|
|
while (foe) {
|
2003-07-23 22:44:15 +00:00
|
|
|
if (foe.owner != ent) {
|
|
|
|
flen = vlen(foe.origin - ent.origin);
|
2003-03-04 18:26:17 +00:00
|
|
|
if (flen < avdist) {
|
2003-02-18 23:11:05 +00:00
|
|
|
avdist = flen;
|
2003-07-30 16:53:57 +00:00
|
|
|
avoid = foe;
|
2003-02-18 23:11:05 +00:00
|
|
|
}
|
|
|
|
}
|
2003-03-08 03:20:32 +00:00
|
|
|
foe = find (foe, classname, "spike");
|
2003-02-18 23:11:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-03-04 18:26:17 +00:00
|
|
|
if (coop) {
|
2003-07-23 22:44:15 +00:00
|
|
|
if (!ent.enemy) {
|
|
|
|
foe = findradius (ent.origin, foedist);
|
2003-03-08 03:20:32 +00:00
|
|
|
while (foe) {
|
|
|
|
if (foe.flags & FL_MONSTER) {
|
|
|
|
if (foe.health > 0) {
|
2003-07-23 22:44:15 +00:00
|
|
|
flen = vlen (foe.origin - ent.origin);
|
2003-03-04 18:26:17 +00:00
|
|
|
if (flen < foedist) {
|
2003-08-18 16:48:53 +00:00
|
|
|
tsz = [self sizePlayer:foe];
|
2003-03-04 18:26:17 +00:00
|
|
|
if (tsz < foesz) {
|
2003-07-24 18:23:13 +00:00
|
|
|
if ([self canSee:foe]) {
|
2003-07-23 22:44:15 +00:00
|
|
|
ent.enemy = foe;
|
2003-02-18 23:11:05 +00:00
|
|
|
foedist = flen;
|
|
|
|
foesz = tsz;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
foe = foe.chain;
|
|
|
|
}
|
|
|
|
}
|
2003-03-04 18:26:17 +00:00
|
|
|
} else {
|
2003-03-04 07:29:42 +00:00
|
|
|
local integer i = 0;
|
2003-07-24 21:54:24 +00:00
|
|
|
local Bot foe;
|
2003-03-04 07:29:42 +00:00
|
|
|
for (i = 0; i < 32; i++) {
|
|
|
|
if (!(foe = players[i]))
|
|
|
|
continue;
|
2003-07-24 21:54:24 +00:00
|
|
|
if(foe != self) {
|
|
|
|
if (foe.ent.modelindex != 0) {
|
|
|
|
if (foe.ent.health > 0) {
|
|
|
|
if (!(teamplay && ent.team == foe.ent.team)) {
|
|
|
|
flen = vlen (foe.ent.origin - ent.origin);
|
2003-03-04 18:26:17 +00:00
|
|
|
if (flen < foedist) {
|
2003-08-18 16:48:53 +00:00
|
|
|
tsz = [self sizePlayer:foe];
|
2003-03-04 18:26:17 +00:00
|
|
|
if (tsz < foesz) {
|
2003-07-24 18:23:13 +00:00
|
|
|
/*XXX
|
2003-07-30 16:53:57 +00:00
|
|
|
if (fov(foe) || foe.b_sound > time || b_skill == 3) {
|
2003-07-24 18:23:13 +00:00
|
|
|
if ([self canSee:foe]) {
|
2003-07-23 22:44:15 +00:00
|
|
|
ent.enemy = foe;
|
|
|
|
foedist = vlen (foe.origin - ent.origin);
|
2003-02-18 23:11:05 +00:00
|
|
|
}
|
|
|
|
}
|
2003-07-24 18:23:13 +00:00
|
|
|
*/
|
2003-02-18 23:11:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-07-23 22:44:15 +00:00
|
|
|
}
|
2003-02-18 23:11:05 +00:00
|
|
|
|
2003-03-08 03:20:32 +00:00
|
|
|
/*
|
2003-08-18 16:48:53 +00:00
|
|
|
weaponSwitch
|
2003-02-18 23:11:05 +00:00
|
|
|
|
|
|
|
Pick a weapon based on range / ammo
|
|
|
|
*/
|
2003-08-18 16:48:53 +00:00
|
|
|
-(void)weaponSwitch:(float)brange
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
2003-03-08 03:20:32 +00:00
|
|
|
local float it, flag = 0, pulse = 0;
|
|
|
|
local vector v;
|
2003-02-18 23:11:05 +00:00
|
|
|
|
2003-07-23 22:44:15 +00:00
|
|
|
it = ent.items & 127;
|
2003-02-18 23:11:05 +00:00
|
|
|
|
2003-03-08 03:20:32 +00:00
|
|
|
while (it) {
|
2003-07-23 22:44:15 +00:00
|
|
|
if ((ent.ammo_rockets >= 1) && (it & 32)) {
|
2003-02-18 23:11:05 +00:00
|
|
|
flag = 32;
|
|
|
|
pulse = 7;
|
2003-07-23 22:44:15 +00:00
|
|
|
} else if (ent.waterlevel <= 1 && ent.ammo_cells >= 1 && (it & 64)) {
|
2003-02-18 23:11:05 +00:00
|
|
|
flag = 64;
|
|
|
|
pulse = 8;
|
2003-07-23 22:44:15 +00:00
|
|
|
} else if (ent.ammo_nails >= 2 && (it & 8)) {
|
2003-02-18 23:11:05 +00:00
|
|
|
flag = 8;
|
|
|
|
pulse = 5;
|
2003-07-23 22:44:15 +00:00
|
|
|
} else if ((ent.ammo_rockets >= 1) && (it & 16)) {
|
2003-02-18 23:11:05 +00:00
|
|
|
flag = 16;
|
|
|
|
pulse = 6;
|
2003-07-23 22:44:15 +00:00
|
|
|
} else if (ent.ammo_shells >= 2 && (it & 2)) {
|
2003-02-18 23:11:05 +00:00
|
|
|
flag = 2;
|
|
|
|
pulse = 3;
|
2003-07-23 22:44:15 +00:00
|
|
|
} else if (ent.ammo_nails >= 1 && (it & 4)) {
|
2003-02-18 23:11:05 +00:00
|
|
|
flag = 4;
|
|
|
|
pulse = 4;
|
2003-07-23 22:44:15 +00:00
|
|
|
} else if (ent.ammo_shells >= 1 && (it & 1)) {
|
2003-02-18 23:11:05 +00:00
|
|
|
flag = 1;
|
|
|
|
pulse = 2;
|
2003-03-04 18:26:17 +00:00
|
|
|
} else {
|
2003-02-18 23:11:05 +00:00
|
|
|
if (pulse)
|
2003-07-23 22:44:15 +00:00
|
|
|
ent.impulse = pulse;
|
2003-02-18 23:11:05 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-03-04 18:26:17 +00:00
|
|
|
if (brange == -1) {
|
2003-02-18 23:11:05 +00:00
|
|
|
if (pulse)
|
2003-07-23 22:44:15 +00:00
|
|
|
ent.impulse = pulse;
|
2003-02-18 23:11:05 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-03-08 03:20:32 +00:00
|
|
|
v = weapon_range (flag);
|
2003-02-18 23:11:05 +00:00
|
|
|
if (brange < v_y || brange > v_z)
|
|
|
|
it = it - flag;
|
2003-03-04 18:26:17 +00:00
|
|
|
else {
|
2003-02-18 23:11:05 +00:00
|
|
|
if (pulse)
|
2003-07-23 22:44:15 +00:00
|
|
|
ent.impulse = pulse;
|
2003-02-18 23:11:05 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2003-07-23 22:44:15 +00:00
|
|
|
}
|
2003-02-18 23:11:05 +00:00
|
|
|
|
2003-07-23 22:44:15 +00:00
|
|
|
-(void)shoot
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
|
|
|
// quick little function to stop making him shoot the wrong way ! Argh
|
|
|
|
local float g;
|
2003-03-08 03:20:32 +00:00
|
|
|
|
2003-08-21 20:39:04 +00:00
|
|
|
g = angcomp (ent.v_angle_x, b_angle.x);
|
2003-03-08 03:20:32 +00:00
|
|
|
if (fabs (g) > 30)
|
2003-02-18 23:11:05 +00:00
|
|
|
return; // argh, too far away
|
2003-08-21 20:39:04 +00:00
|
|
|
g = angcomp (ent.v_angle_y, b_angle.y);
|
2003-03-08 03:20:32 +00:00
|
|
|
if (fabs (g) > 30)
|
2003-02-18 23:11:05 +00:00
|
|
|
return; // not again!
|
2003-08-21 03:53:15 +00:00
|
|
|
buttons |= 1;
|
2003-07-23 22:44:15 +00:00
|
|
|
}
|
2003-02-18 23:11:05 +00:00
|
|
|
|
|
|
|
/*
|
2003-08-18 16:48:53 +00:00
|
|
|
fightStyle
|
2003-02-18 23:11:05 +00:00
|
|
|
|
|
|
|
This is the core of the bot's thinking when
|
|
|
|
attacking an enemy.
|
|
|
|
*/
|
2003-08-18 16:48:53 +00:00
|
|
|
-(void)fightStyle
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
2003-03-08 03:20:32 +00:00
|
|
|
local float foedist, mysz, foesz;
|
|
|
|
local vector v, v1 = '0 0 0', v2 = '0 0 0', org;
|
2003-02-18 23:11:05 +00:00
|
|
|
|
2003-07-23 22:44:15 +00:00
|
|
|
if (ent.enemy.health <= 0) {
|
|
|
|
ent.enemy = NIL;
|
2003-02-18 23:11:05 +00:00
|
|
|
return;
|
2003-07-23 22:44:15 +00:00
|
|
|
} else if (!ent.enemy.takedamage) {
|
|
|
|
ent.enemy = NIL;
|
2003-02-18 23:11:05 +00:00
|
|
|
return;
|
2003-07-24 18:23:13 +00:00
|
|
|
} else if (![self canSee:ent.enemy]) {
|
2003-07-23 22:44:15 +00:00
|
|
|
ent.enemy = NIL;
|
2003-02-18 23:11:05 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-07-23 22:44:15 +00:00
|
|
|
org = realorigin (ent.enemy);
|
2003-08-21 20:39:04 +00:00
|
|
|
makevectors (ent.v_angle);
|
2003-02-18 23:11:05 +00:00
|
|
|
|
|
|
|
// decide if I should shoot
|
2003-07-23 22:44:15 +00:00
|
|
|
foedist = vlen (org - ent.origin);
|
|
|
|
v = weapon_range (ent.weapon);
|
2003-03-04 18:26:17 +00:00
|
|
|
if (foedist > v_y && foedist < v_z) {
|
2003-07-23 22:44:15 +00:00
|
|
|
traceline (ent.origin + ent.view_ofs, ent.origin + ent.view_ofs + v_forward * v_z, FALSE, ent);
|
|
|
|
if (vlen(trace_endpos - (ent.origin + ent.view_ofs)) >= v_y) {
|
2003-02-18 23:11:05 +00:00
|
|
|
// try to avoid shooting teammates
|
|
|
|
if (trace_ent.classname == "player")
|
2003-07-23 22:44:15 +00:00
|
|
|
if ((trace_ent.team == ent.team && teamplay) || (coop))
|
2003-02-18 23:11:05 +00:00
|
|
|
return;
|
2003-07-23 22:44:15 +00:00
|
|
|
[self shoot];
|
2003-02-18 23:11:05 +00:00
|
|
|
}
|
2003-03-04 18:26:17 +00:00
|
|
|
} else
|
2003-08-18 16:48:53 +00:00
|
|
|
[self weaponSwitch:foedist];
|
2003-02-18 23:11:05 +00:00
|
|
|
|
2003-07-30 16:53:57 +00:00
|
|
|
if (!(b_aiflags & (AI_PRECISION | AI_BLIND | AI_OBSTRUCTED))) {
|
2003-08-18 16:48:53 +00:00
|
|
|
foesz = [self sizePlayer:ent.enemy];
|
|
|
|
mysz = [self sizePlayer:self] + 5;
|
2003-02-18 23:11:05 +00:00
|
|
|
|
2003-03-04 18:26:17 +00:00
|
|
|
if (foesz > mysz) {
|
|
|
|
if (teamplay) {
|
2003-03-08 03:20:32 +00:00
|
|
|
if (random () < 0.02) {
|
2003-08-18 16:48:53 +00:00
|
|
|
[self startTopic:5];
|
2003-07-30 16:53:57 +00:00
|
|
|
b_chattime = 1;
|
2003-02-18 23:11:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
2003-03-04 18:26:17 +00:00
|
|
|
} else if (mysz < 140)
|
2003-02-18 23:11:05 +00:00
|
|
|
return;
|
2003-07-30 16:53:57 +00:00
|
|
|
else if (avoid) {
|
|
|
|
if (avoid.velocity)
|
|
|
|
v = avoid.velocity;
|
2003-02-18 23:11:05 +00:00
|
|
|
else
|
2003-07-30 16:53:57 +00:00
|
|
|
v = normalize (avoid.origin - ent.origin);
|
2003-02-18 23:11:05 +00:00
|
|
|
v1_x = v_y;
|
|
|
|
v1_y = v_y * -1;
|
|
|
|
v2_x = v_y;
|
|
|
|
v2_y = v_y * -1;
|
2003-07-30 16:53:57 +00:00
|
|
|
foedist = vlen (avoid.origin - (ent.origin + v1));
|
|
|
|
if (foedist < vlen (avoid.origin - (ent.origin + v2)))
|
2003-07-23 22:44:15 +00:00
|
|
|
[self walkmove:v2];
|
2003-02-18 23:11:05 +00:00
|
|
|
else
|
2003-07-23 22:44:15 +00:00
|
|
|
[self walkmove:v1];
|
|
|
|
} else if (!(ent.enemy.flags & FL_MONSTER)) {
|
2003-02-18 23:11:05 +00:00
|
|
|
if (foedist + 32 < v_x)
|
2003-07-23 22:44:15 +00:00
|
|
|
[self walkmove:ent.origin - org];
|
2003-02-18 23:11:05 +00:00
|
|
|
else if (foedist - 32 > v_x)
|
2003-07-23 22:44:15 +00:00
|
|
|
[self walkmove:org - ent.origin];
|
2003-07-30 16:53:57 +00:00
|
|
|
else if (wallhug)
|
2003-07-23 22:44:15 +00:00
|
|
|
[self walkmove:v_right];
|
2003-02-18 23:11:05 +00:00
|
|
|
else
|
2003-07-23 22:44:15 +00:00
|
|
|
[self walkmove:v_right * -1];
|
2003-02-18 23:11:05 +00:00
|
|
|
}
|
2003-03-04 18:26:17 +00:00
|
|
|
} else {
|
2003-08-18 16:48:53 +00:00
|
|
|
foesz = [self sizePlayer:ent.enemy];
|
|
|
|
mysz = [self sizePlayer:self] + 5;
|
2003-02-18 23:11:05 +00:00
|
|
|
|
|
|
|
if (foesz > mysz)
|
|
|
|
return;
|
|
|
|
else if (mysz < 140)
|
|
|
|
return;
|
2003-07-31 16:57:01 +00:00
|
|
|
keys &= ~KEY_MOVE;
|
2003-02-18 23:11:05 +00:00
|
|
|
}
|
2003-07-23 22:44:15 +00:00
|
|
|
}
|
|
|
|
@end
|