2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
sv_move.c
|
|
|
|
|
2002-02-20 20:53:41 +00:00
|
|
|
monster movement
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
Copyright (C) 1996-1997 Id Software, Inc.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "world.h"
|
|
|
|
|
2020-06-21 14:15:17 +00:00
|
|
|
#include "nq/include/server.h"
|
|
|
|
#include "nq/include/sv_progs.h"
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
#define STEPSIZE 18
|
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
int c_yes, c_no;
|
|
|
|
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
/*
|
2001-07-15 01:48:03 +00:00
|
|
|
SV_CheckBottom
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-07-15 01:48:03 +00:00
|
|
|
Returns false if any part of the bottom of the entity is off an edge that
|
|
|
|
is not a staircase.
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
qboolean
|
|
|
|
SV_CheckBottom (edict_t *ent)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
float mid, bottom;
|
2002-02-20 20:53:41 +00:00
|
|
|
int x, y;
|
|
|
|
trace_t trace;
|
|
|
|
vec3_t mins, maxs, start, stop;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-08-08 20:28:53 +00:00
|
|
|
VectorAdd (SVvector (ent, origin), SVvector (ent, mins), mins);
|
|
|
|
VectorAdd (SVvector (ent, origin), SVvector (ent, maxs), maxs);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// if all of the points under the corners are solid world, don't bother
|
|
|
|
// with the tougher checks
|
|
|
|
|
|
|
|
// the corners must be within 16 of the midpoint
|
2001-02-19 21:15:25 +00:00
|
|
|
start[2] = mins[2] - 1;
|
2001-02-26 06:48:02 +00:00
|
|
|
for (x = 0; x <= 1; x++)
|
|
|
|
for (y = 0; y <= 1; y++) {
|
2001-02-19 21:15:25 +00:00
|
|
|
start[0] = x ? maxs[0] : mins[0];
|
|
|
|
start[1] = y ? maxs[1] : mins[1];
|
|
|
|
if (SV_PointContents (start) != CONTENTS_SOLID)
|
|
|
|
goto realcheck;
|
|
|
|
}
|
|
|
|
|
|
|
|
c_yes++;
|
2001-02-26 06:48:02 +00:00
|
|
|
return true; // we got out easy
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
realcheck:
|
2001-02-19 21:15:25 +00:00
|
|
|
c_no++;
|
2001-08-27 07:13:32 +00:00
|
|
|
|
|
|
|
// check it for real...
|
2001-02-19 21:15:25 +00:00
|
|
|
start[2] = mins[2];
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// the midpoint must be within 16 of the bottom
|
2001-02-26 06:48:02 +00:00
|
|
|
start[0] = stop[0] = (mins[0] + maxs[0]) * 0.5;
|
|
|
|
start[1] = stop[1] = (mins[1] + maxs[1]) * 0.5;
|
|
|
|
stop[2] = start[2] - 2 * STEPSIZE;
|
2001-02-19 21:15:25 +00:00
|
|
|
trace = SV_Move (start, vec3_origin, vec3_origin, stop, true, ent);
|
|
|
|
|
|
|
|
if (trace.fraction == 1.0)
|
|
|
|
return false;
|
|
|
|
mid = bottom = trace.endpos[2];
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2012-05-21 23:23:22 +00:00
|
|
|
// the corners must be within 16 of the midpoint
|
2001-02-26 06:48:02 +00:00
|
|
|
for (x = 0; x <= 1; x++)
|
|
|
|
for (y = 0; y <= 1; y++) {
|
2001-02-19 21:15:25 +00:00
|
|
|
start[0] = stop[0] = x ? maxs[0] : mins[0];
|
|
|
|
start[1] = stop[1] = y ? maxs[1] : mins[1];
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
trace = SV_Move (start, vec3_origin, vec3_origin, stop, true, ent);
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
if (trace.fraction != 1.0 && trace.endpos[2] > bottom)
|
|
|
|
bottom = trace.endpos[2];
|
|
|
|
if (trace.fraction == 1.0 || mid - trace.endpos[2] > STEPSIZE)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
c_yes++;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-07-15 01:48:03 +00:00
|
|
|
SV_movestep
|
|
|
|
|
|
|
|
Called by monster program code.
|
|
|
|
The move will be adjusted for slopes and stairs, but if the move isn't
|
|
|
|
possible, no move is done, false is returned, and
|
|
|
|
pr_global_struct->trace_normal is set to the normal of the blocking wall
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
qboolean
|
2002-01-03 05:29:38 +00:00
|
|
|
SV_movestep (edict_t *ent, const vec3_t move, qboolean relink)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2002-02-20 20:53:41 +00:00
|
|
|
edict_t *enemy;
|
2001-02-26 06:48:02 +00:00
|
|
|
float dz;
|
2002-02-20 20:53:41 +00:00
|
|
|
int i;
|
2001-02-26 06:48:02 +00:00
|
|
|
trace_t trace;
|
2002-02-20 20:53:41 +00:00
|
|
|
vec3_t oldorg, neworg, end;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2012-05-21 23:23:22 +00:00
|
|
|
// try the move
|
2001-08-08 20:28:53 +00:00
|
|
|
VectorCopy (SVvector (ent, origin), oldorg);
|
|
|
|
VectorAdd (SVvector (ent, origin), move, neworg);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// flying monsters don't step up
|
2001-08-08 20:28:53 +00:00
|
|
|
if ((int) SVfloat (ent, flags) & (FL_SWIM | FL_FLY)) {
|
2001-02-26 06:48:02 +00:00
|
|
|
// try one move with vertical motion, then one without
|
|
|
|
for (i = 0; i < 2; i++) {
|
2001-08-08 20:28:53 +00:00
|
|
|
VectorAdd (SVvector (ent, origin), move, neworg);
|
|
|
|
enemy = PROG_TO_EDICT (&sv_pr_state, SVentity (ent, enemy));
|
2001-02-26 06:48:02 +00:00
|
|
|
if (i == 0 && enemy != sv.edicts) {
|
2001-08-27 07:13:32 +00:00
|
|
|
dz = SVvector (ent, origin)[2] - SVvector (enemy, origin)[2];
|
2001-02-19 21:15:25 +00:00
|
|
|
if (dz > 40)
|
|
|
|
neworg[2] -= 8;
|
|
|
|
if (dz < 30)
|
|
|
|
neworg[2] += 8;
|
|
|
|
}
|
2001-08-27 07:13:32 +00:00
|
|
|
trace = SV_Move (SVvector (ent, origin), SVvector (ent, mins),
|
|
|
|
SVvector (ent, maxs), neworg, false, ent);
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
if (trace.fraction == 1) {
|
2001-08-08 20:28:53 +00:00
|
|
|
if (((int) SVfloat (ent, flags) & FL_SWIM)
|
2001-02-26 06:48:02 +00:00
|
|
|
&& SV_PointContents (trace.endpos) == CONTENTS_EMPTY)
|
|
|
|
return false; // swim monster left water
|
|
|
|
|
2001-08-08 20:28:53 +00:00
|
|
|
VectorCopy (trace.endpos, SVvector (ent, origin));
|
2001-02-19 21:15:25 +00:00
|
|
|
if (relink)
|
|
|
|
SV_LinkEdict (ent, true);
|
|
|
|
return true;
|
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
if (enemy == sv.edicts)
|
|
|
|
break;
|
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
return false;
|
|
|
|
}
|
2001-08-27 07:13:32 +00:00
|
|
|
|
|
|
|
// push down from a step height above the wished position
|
2001-02-19 21:15:25 +00:00
|
|
|
neworg[2] += STEPSIZE;
|
|
|
|
VectorCopy (neworg, end);
|
2001-02-26 06:48:02 +00:00
|
|
|
end[2] -= STEPSIZE * 2;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
trace = SV_Move (neworg, SVvector (ent, mins), SVvector (ent, maxs), end,
|
|
|
|
false, ent);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (trace.allsolid)
|
|
|
|
return false;
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
if (trace.startsolid) {
|
2001-02-19 21:15:25 +00:00
|
|
|
neworg[2] -= STEPSIZE;
|
2001-08-27 07:13:32 +00:00
|
|
|
trace = SV_Move (neworg, SVvector (ent, mins), SVvector (ent, maxs),
|
|
|
|
end, false, ent);
|
2001-02-19 21:15:25 +00:00
|
|
|
if (trace.allsolid || trace.startsolid)
|
|
|
|
return false;
|
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
if (trace.fraction == 1) {
|
|
|
|
// if monster had the ground pulled out, go ahead and fall
|
2001-08-08 20:28:53 +00:00
|
|
|
if ((int) SVfloat (ent, flags) & FL_PARTIALGROUND) {
|
|
|
|
VectorAdd (SVvector (ent, origin), move, SVvector (ent, origin));
|
2001-02-19 21:15:25 +00:00
|
|
|
if (relink)
|
|
|
|
SV_LinkEdict (ent, true);
|
2001-08-08 20:28:53 +00:00
|
|
|
SVfloat (ent, flags) = (int) SVfloat (ent, flags) & ~FL_ONGROUND;
|
2001-02-19 21:15:25 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
return false; // walked off an edge
|
|
|
|
}
|
2001-08-27 07:13:32 +00:00
|
|
|
// check point traces down for dangling corners
|
2001-08-08 20:28:53 +00:00
|
|
|
VectorCopy (trace.endpos, SVvector (ent, origin));
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
if (!SV_CheckBottom (ent)) {
|
2001-08-27 07:13:32 +00:00
|
|
|
if ((int) SVfloat (ent, flags) & FL_PARTIALGROUND) {
|
|
|
|
// entity had floor mostly pulled out from underneath it and is
|
|
|
|
// trying to correct
|
2001-02-19 21:15:25 +00:00
|
|
|
if (relink)
|
|
|
|
SV_LinkEdict (ent, true);
|
|
|
|
return true;
|
|
|
|
}
|
2001-08-08 20:28:53 +00:00
|
|
|
VectorCopy (oldorg, SVvector (ent, origin));
|
2001-02-19 21:15:25 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2001-08-08 20:28:53 +00:00
|
|
|
if ((int) SVfloat (ent, flags) & FL_PARTIALGROUND) {
|
|
|
|
SVfloat (ent, flags) = (int) SVfloat (ent, flags) & ~FL_PARTIALGROUND;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2001-08-08 20:28:53 +00:00
|
|
|
SVentity (ent, groundentity) = EDICT_TO_PROG (&sv_pr_state, trace.ent);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// the move is ok
|
2001-02-19 21:15:25 +00:00
|
|
|
if (relink)
|
|
|
|
SV_LinkEdict (ent, true);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2002-02-20 20:53:41 +00:00
|
|
|
SV_StepDirection
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2002-02-20 20:53:41 +00:00
|
|
|
Turns to the movement direction, and walks the current distance if
|
|
|
|
facing it.
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static qboolean
|
2001-02-26 06:48:02 +00:00
|
|
|
SV_StepDirection (edict_t *ent, float yaw, float dist)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
float delta;
|
2001-08-27 07:13:32 +00:00
|
|
|
vec3_t move, oldorigin;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-08-08 20:28:53 +00:00
|
|
|
SVfloat (ent, ideal_yaw) = yaw;
|
2022-02-14 03:28:38 +00:00
|
|
|
PF_changeyaw (&sv_pr_state, 0);
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
yaw = yaw * M_PI * 2 / 360;
|
|
|
|
move[0] = cos (yaw) * dist;
|
|
|
|
move[1] = sin (yaw) * dist;
|
2001-02-19 21:15:25 +00:00
|
|
|
move[2] = 0;
|
|
|
|
|
2001-08-08 20:28:53 +00:00
|
|
|
VectorCopy (SVvector (ent, origin), oldorigin);
|
2001-02-26 06:48:02 +00:00
|
|
|
if (SV_movestep (ent, move, false)) {
|
2001-08-08 20:28:53 +00:00
|
|
|
delta = SVvector (ent, angles)[YAW] - SVfloat (ent, ideal_yaw);
|
2001-02-26 06:48:02 +00:00
|
|
|
if (delta > 45 && delta < 315) { // not turned far enough, so
|
2001-07-15 01:48:03 +00:00
|
|
|
// don't take the step
|
2001-08-08 20:28:53 +00:00
|
|
|
VectorCopy (oldorigin, SVvector (ent, origin));
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
SV_LinkEdict (ent, true);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
SV_LinkEdict (ent, true);
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-26 06:48:02 +00:00
|
|
|
SV_FixCheckBottom (edict_t *ent)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-08-08 20:28:53 +00:00
|
|
|
SVfloat (ent, flags) = (int) SVfloat (ent, flags) | FL_PARTIALGROUND;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define DI_NODIR -1
|
2001-08-27 07:13:32 +00:00
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-26 06:48:02 +00:00
|
|
|
SV_NewChaseDir (edict_t *actor, edict_t *enemy, float dist)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-08-27 07:13:32 +00:00
|
|
|
float deltax, deltay, olddir, tdir, turnaround;
|
2001-02-26 06:48:02 +00:00
|
|
|
float d[3];
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-08 20:28:53 +00:00
|
|
|
olddir = anglemod ((int) (SVfloat (actor, ideal_yaw) / 45) * 45);
|
2001-02-26 06:48:02 +00:00
|
|
|
turnaround = anglemod (olddir - 180);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-08 20:28:53 +00:00
|
|
|
deltax = SVvector (enemy, origin)[0] - SVvector (actor, origin)[0];
|
|
|
|
deltay = SVvector (enemy, origin)[1] - SVvector (actor, origin)[1];
|
2001-02-26 06:48:02 +00:00
|
|
|
if (deltax > 10)
|
|
|
|
d[1] = 0;
|
|
|
|
else if (deltax < -10)
|
|
|
|
d[1] = 180;
|
2001-02-19 21:15:25 +00:00
|
|
|
else
|
2001-02-26 06:48:02 +00:00
|
|
|
d[1] = DI_NODIR;
|
|
|
|
if (deltay < -10)
|
|
|
|
d[2] = 270;
|
|
|
|
else if (deltay > 10)
|
|
|
|
d[2] = 90;
|
2001-02-19 21:15:25 +00:00
|
|
|
else
|
2001-02-26 06:48:02 +00:00
|
|
|
d[2] = DI_NODIR;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// try direct route
|
2001-02-26 06:48:02 +00:00
|
|
|
if (d[1] != DI_NODIR && d[2] != DI_NODIR) {
|
2001-02-19 21:15:25 +00:00
|
|
|
if (d[1] == 0)
|
|
|
|
tdir = d[2] == 90 ? 45 : 315;
|
|
|
|
else
|
|
|
|
tdir = d[2] == 90 ? 135 : 215;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
if (tdir != turnaround && SV_StepDirection (actor, tdir, dist))
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-08-27 07:13:32 +00:00
|
|
|
// try other directions
|
2001-02-26 06:48:02 +00:00
|
|
|
if (((rand () & 3) & 1) || abs (deltay) > abs (deltax)) {
|
|
|
|
tdir = d[1];
|
|
|
|
d[1] = d[2];
|
|
|
|
d[2] = tdir;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
if (d[1] != DI_NODIR && d[1] != turnaround
|
|
|
|
&& SV_StepDirection (actor, d[1], dist)) return;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
if (d[2] != DI_NODIR && d[2] != turnaround
|
|
|
|
&& SV_StepDirection (actor, d[2], dist)) return;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
/* there is no direct path to the player, so pick another direction */
|
2001-02-26 06:48:02 +00:00
|
|
|
if (olddir != DI_NODIR && SV_StepDirection (actor, olddir, dist))
|
|
|
|
return;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2002-02-20 20:53:41 +00:00
|
|
|
if (rand () & 1) { // randomly determine direction of search
|
2001-02-26 06:48:02 +00:00
|
|
|
for (tdir = 0; tdir <= 315; tdir += 45)
|
|
|
|
if (tdir != turnaround && SV_StepDirection (actor, tdir, dist))
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
for (tdir = 315; tdir >= 0; tdir -= 45)
|
|
|
|
if (tdir != turnaround && SV_StepDirection (actor, tdir, dist))
|
|
|
|
return;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
if (turnaround != DI_NODIR && SV_StepDirection (actor, turnaround, dist))
|
|
|
|
return;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-08 20:28:53 +00:00
|
|
|
SVfloat (actor, ideal_yaw) = olddir; // can't move
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// if a bridge was pulled out from underneath a monster, it may not have
|
|
|
|
// a valid standing position at all
|
2001-02-19 21:15:25 +00:00
|
|
|
if (!SV_CheckBottom (actor))
|
|
|
|
SV_FixCheckBottom (actor);
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static qboolean
|
2001-02-26 06:48:02 +00:00
|
|
|
SV_CloseEnough (edict_t *ent, edict_t *goal, float dist)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 3; i++) {
|
2001-08-08 20:28:53 +00:00
|
|
|
if (SVvector (goal, absmin)[i] > SVvector (ent, absmax)[i] + dist)
|
2001-02-19 21:15:25 +00:00
|
|
|
return false;
|
2001-08-08 20:28:53 +00:00
|
|
|
if (SVvector (goal, absmax)[i] < SVvector (ent, absmin)[i] - dist)
|
2001-02-19 21:15:25 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2022-02-14 03:28:38 +00:00
|
|
|
SV_MoveToGoal (progs_t *pr, void *data)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-08-27 07:13:32 +00:00
|
|
|
edict_t *ent, *goal;
|
2002-02-20 20:53:41 +00:00
|
|
|
float dist;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-03-03 08:31:58 +00:00
|
|
|
ent = PROG_TO_EDICT (pr, *pr->globals.self);
|
2001-08-08 20:28:53 +00:00
|
|
|
goal = PROG_TO_EDICT (pr, SVentity (ent, goalentity));
|
2002-07-24 21:42:33 +00:00
|
|
|
dist = P_FLOAT (pr, 0);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-08 20:28:53 +00:00
|
|
|
if (!((int) SVfloat (ent, flags) & (FL_ONGROUND | FL_FLY | FL_SWIM))) {
|
2002-07-24 21:42:33 +00:00
|
|
|
R_FLOAT (pr) = 0;
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-08-27 07:13:32 +00:00
|
|
|
// if the next step hits the enemy, return immediately
|
2001-08-08 20:28:53 +00:00
|
|
|
if (PROG_TO_EDICT (pr, SVentity (ent, enemy)) != sv.edicts
|
2001-02-26 06:48:02 +00:00
|
|
|
&& SV_CloseEnough (ent, goal, dist))
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// bump around...
|
2002-02-20 20:53:41 +00:00
|
|
|
if ((rand () & 3) == 1
|
|
|
|
|| !SV_StepDirection (ent, SVfloat (ent, ideal_yaw), dist)) {
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_NewChaseDir (ent, goal, dist);
|
|
|
|
}
|
|
|
|
}
|