Reformat move.c and player.h

This commit is contained in:
Yamagi Burmeister 2011-10-15 09:14:06 +00:00
parent 55c85f474e
commit ad679e33b2
2 changed files with 601 additions and 497 deletions

View file

@ -1,163 +1,204 @@
/* /*
Copyright (C) 1997-2001 Id Software, Inc. * Copyright (C) 1997-2001 Id Software, Inc.
*
This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or modify
modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
as published by the Free Software Foundation; either version 2 * the Free Software Foundation; either version 2 of the License, or (at
of the License, or (at your option) any later version. * your option) any later version.
*
This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful, but
but WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
See the GNU General Public License for more details. * See the GNU General Public License for more details.
*
You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/ *
// m_move.c -- monster movement * =======================================================================
*
* Monster movement support functions. While unused by the CTF code
* these functions must be here since they're referenced at several
* points inside the game.so.
*
* =======================================================================
*/
#include "../header/local.h" #include "../header/local.h"
#define STEPSIZE 18 #define STEPSIZE 18
/* /*
============= * Returns false if any part of the bottom of
M_CheckBottom * the entity is off an edge that is not a staircase.
*/
Returns false if any part of the bottom of the entity is off an edge that
is not a staircase.
=============
*/
int c_yes, c_no; int c_yes, c_no;
qboolean M_CheckBottom (edict_t *ent) qboolean
M_CheckBottom(edict_t *ent)
{ {
vec3_t mins, maxs, start, stop; vec3_t mins, maxs, start, stop;
trace_t trace; trace_t trace;
int x, y; int x, y;
float mid, bottom; float mid, bottom;
VectorAdd (ent->s.origin, ent->mins, mins);
VectorAdd (ent->s.origin, ent->maxs, maxs);
// if all of the points under the corners are solid world, don't bother VectorAdd(ent->s.origin, ent->mins, mins);
// with the tougher checks VectorAdd(ent->s.origin, ent->maxs, maxs);
// the corners must be within 16 of the midpoint
/* 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 */
start[2] = mins[2] - 1; start[2] = mins[2] - 1;
for (x=0 ; x<=1 ; x++)
for (y=0 ; y<=1 ; y++) for (x = 0; x <= 1; x++)
{
for (y = 0; y <= 1; y++)
{ {
start[0] = x ? maxs[0] : mins[0]; start[0] = x ? maxs[0] : mins[0];
start[1] = y ? maxs[1] : mins[1]; start[1] = y ? maxs[1] : mins[1];
if (gi.pointcontents (start) != CONTENTS_SOLID)
if (gi.pointcontents(start) != CONTENTS_SOLID)
{
goto realcheck; goto realcheck;
}
} }
}
c_yes++; c_yes++;
return true; // we got out easy return true; /* we got out easy */
realcheck: realcheck:
c_no++; c_no++;
//
// check it for real... /* check it for real... */
//
start[2] = mins[2]; start[2] = mins[2];
// the midpoint must be within 16 of the bottom /* the midpoint must be within 16 of the bottom */
start[0] = stop[0] = (mins[0] + maxs[0])*0.5; start[0] = stop[0] = (mins[0] + maxs[0]) * 0.5;
start[1] = stop[1] = (mins[1] + maxs[1])*0.5; start[1] = stop[1] = (mins[1] + maxs[1]) * 0.5;
stop[2] = start[2] - 2*STEPSIZE; stop[2] = start[2] - 2 * STEPSIZE;
trace = gi.trace (start, vec3_origin, vec3_origin, stop, ent, MASK_MONSTERSOLID); trace = gi.trace(start, vec3_origin, vec3_origin,
stop, ent, MASK_MONSTERSOLID);
if (trace.fraction == 1.0) if (trace.fraction == 1.0)
{
return false; return false;
}
mid = bottom = trace.endpos[2]; mid = bottom = trace.endpos[2];
// the corners must be within 16 of the midpoint /* the corners must be within 16 of the midpoint */
for (x=0 ; x<=1 ; x++) for (x = 0; x <= 1; x++)
for (y=0 ; y<=1 ; y++) {
for (y = 0; y <= 1; y++)
{ {
start[0] = stop[0] = x ? maxs[0] : mins[0]; start[0] = stop[0] = x ? maxs[0] : mins[0];
start[1] = stop[1] = y ? maxs[1] : mins[1]; start[1] = stop[1] = y ? maxs[1] : mins[1];
trace = gi.trace (start, vec3_origin, vec3_origin, stop, ent, MASK_MONSTERSOLID); trace = gi.trace(start, vec3_origin, vec3_origin,
stop, ent, MASK_MONSTERSOLID);
if (trace.fraction != 1.0 && trace.endpos[2] > bottom)
if ((trace.fraction != 1.0) && (trace.endpos[2] > bottom))
{
bottom = trace.endpos[2]; bottom = trace.endpos[2];
if (trace.fraction == 1.0 || mid - trace.endpos[2] > STEPSIZE) }
if ((trace.fraction == 1.0) || (mid - trace.endpos[2] > STEPSIZE))
{
return false; return false;
}
} }
}
c_yes++; c_yes++;
return true; return true;
} }
/* /*
============= * Called by monster program code.
SV_movestep * The move will be adjusted for
* slopes and stairs, but if the move
Called by monster program code. * isn't possible, no move is done,
The move will be adjusted for slopes and stairs, but if the move isn't * false is returned, and
possible, no move is done, false is returned, and * pr_global_struct->trace_normal
pr_global_struct->trace_normal is set to the normal of the blocking wall * is set to the normal of the
============= * blocking wall
*/ */
//FIXME since we need to test end position contents here, can we avoid doing qboolean
//it again later in catagorize position? SV_movestep(edict_t *ent, vec3_t move, qboolean relink)
qboolean SV_movestep (edict_t *ent, vec3_t move, qboolean relink)
{ {
float dz; float dz;
vec3_t oldorg, neworg, end; vec3_t oldorg, neworg, end;
trace_t trace; trace_t trace;
int i; int i;
float stepsize; float stepsize;
vec3_t test; vec3_t test;
int contents; int contents;
// try the move /* try the move */
VectorCopy (ent->s.origin, oldorg); VectorCopy(ent->s.origin, oldorg);
VectorAdd (ent->s.origin, move, neworg); VectorAdd(ent->s.origin, move, neworg);
// flying monsters don't step up /* flying monsters don't step up */
if ( ent->flags & (FL_SWIM | FL_FLY) ) if (ent->flags & (FL_SWIM | FL_FLY))
{ {
// try one move with vertical motion, then one without /* try one move with vertical motion, then one without */
for (i=0 ; i<2 ; i++) for (i = 0; i < 2; i++)
{ {
VectorAdd (ent->s.origin, move, neworg); VectorAdd(ent->s.origin, move, neworg);
if (i == 0 && ent->enemy)
if ((i == 0) && ent->enemy)
{ {
if (!ent->goalentity) if (!ent->goalentity)
{
ent->goalentity = ent->enemy; ent->goalentity = ent->enemy;
}
dz = ent->s.origin[2] - ent->goalentity->s.origin[2]; dz = ent->s.origin[2] - ent->goalentity->s.origin[2];
if (ent->goalentity->client) if (ent->goalentity->client)
{ {
if (dz > 40) if (dz > 40)
{
neworg[2] -= 8; neworg[2] -= 8;
}
if (!((ent->flags & FL_SWIM) && (ent->waterlevel < 2))) if (!((ent->flags & FL_SWIM) && (ent->waterlevel < 2)))
{
if (dz < 30) if (dz < 30)
{
neworg[2] += 8; neworg[2] += 8;
}
}
} }
else else
{ {
if (dz > 8) if (dz > 8)
{
neworg[2] -= 8; neworg[2] -= 8;
}
else if (dz > 0) else if (dz > 0)
{
neworg[2] -= dz; neworg[2] -= dz;
}
else if (dz < -8) else if (dz < -8)
{
neworg[2] += 8; neworg[2] += 8;
}
else else
{
neworg[2] += dz; neworg[2] += dz;
}
} }
} }
trace = gi.trace (ent->s.origin, ent->mins, ent->maxs, neworg, ent, MASK_MONSTERSOLID);
trace = gi.trace(ent->s.origin, ent->mins, ent->maxs,
// fly monsters don't enter water voluntarily neworg, ent, MASK_MONSTERSOLID);
/* fly monsters don't enter water voluntarily */
if (ent->flags & FL_FLY) if (ent->flags & FL_FLY)
{ {
if (!ent->waterlevel) if (!ent->waterlevel)
@ -166,12 +207,15 @@ qboolean SV_movestep (edict_t *ent, vec3_t move, qboolean relink)
test[1] = trace.endpos[1]; test[1] = trace.endpos[1];
test[2] = trace.endpos[2] + ent->mins[2] + 1; test[2] = trace.endpos[2] + ent->mins[2] + 1;
contents = gi.pointcontents(test); contents = gi.pointcontents(test);
if (contents & MASK_WATER) if (contents & MASK_WATER)
{
return false; return false;
}
} }
} }
// swim monsters don't exit water voluntarily /* swim monsters don't exit water voluntarily */
if (ent->flags & FL_SWIM) if (ent->flags & FL_SWIM)
{ {
if (ent->waterlevel < 2) if (ent->waterlevel < 2)
@ -180,376 +224,434 @@ qboolean SV_movestep (edict_t *ent, vec3_t move, qboolean relink)
test[1] = trace.endpos[1]; test[1] = trace.endpos[1];
test[2] = trace.endpos[2] + ent->mins[2] + 1; test[2] = trace.endpos[2] + ent->mins[2] + 1;
contents = gi.pointcontents(test); contents = gi.pointcontents(test);
if (!(contents & MASK_WATER)) if (!(contents & MASK_WATER))
{
return false; return false;
}
} }
} }
if (trace.fraction == 1) if (trace.fraction == 1)
{ {
VectorCopy (trace.endpos, ent->s.origin); VectorCopy(trace.endpos, ent->s.origin);
if (relink) if (relink)
{ {
gi.linkentity (ent); gi.linkentity(ent);
G_TouchTriggers (ent); G_TouchTriggers(ent);
} }
return true; return true;
} }
if (!ent->enemy) if (!ent->enemy)
{
break; break;
}
} }
return false; return false;
} }
// push down from a step height above the wished position /* push down from a step height above the wished position */
if (!(ent->monsterinfo.aiflags & AI_NOSTEP)) if (!(ent->monsterinfo.aiflags & AI_NOSTEP))
{
stepsize = STEPSIZE; stepsize = STEPSIZE;
}
else else
{
stepsize = 1; stepsize = 1;
}
neworg[2] += stepsize; neworg[2] += stepsize;
VectorCopy (neworg, end); VectorCopy(neworg, end);
end[2] -= stepsize*2; end[2] -= stepsize * 2;
trace = gi.trace (neworg, ent->mins, ent->maxs, end, ent, MASK_MONSTERSOLID); trace = gi.trace(neworg, ent->mins, ent->maxs, end, ent, MASK_MONSTERSOLID);
if (trace.allsolid) if (trace.allsolid)
{
return false; return false;
}
if (trace.startsolid) if (trace.startsolid)
{ {
neworg[2] -= stepsize; neworg[2] -= stepsize;
trace = gi.trace (neworg, ent->mins, ent->maxs, end, ent, MASK_MONSTERSOLID); trace = gi.trace(neworg, ent->mins, ent->maxs, end,
ent, MASK_MONSTERSOLID);
if (trace.allsolid || trace.startsolid) if (trace.allsolid || trace.startsolid)
{
return false; return false;
}
} }
/* don't go in to water */
// don't go in to water
if (ent->waterlevel == 0) if (ent->waterlevel == 0)
{ {
test[0] = trace.endpos[0]; test[0] = trace.endpos[0];
test[1] = trace.endpos[1]; test[1] = trace.endpos[1];
test[2] = trace.endpos[2] + ent->mins[2] + 1; test[2] = trace.endpos[2] + ent->mins[2] + 1;
contents = gi.pointcontents(test); contents = gi.pointcontents(test);
if (contents & MASK_WATER) if (contents & MASK_WATER)
{
return false; return false;
}
} }
if (trace.fraction == 1) if (trace.fraction == 1)
{ {
// if monster had the ground pulled out, go ahead and fall /* if monster had the ground pulled out, go ahead and fall */
if ( ent->flags & FL_PARTIALGROUND ) if (ent->flags & FL_PARTIALGROUND)
{ {
VectorAdd (ent->s.origin, move, ent->s.origin); VectorAdd(ent->s.origin, move, ent->s.origin);
if (relink) if (relink)
{ {
gi.linkentity (ent); gi.linkentity(ent);
G_TouchTriggers (ent); G_TouchTriggers(ent);
} }
ent->groundentity = NULL; ent->groundentity = NULL;
return true; return true;
} }
return false; // walked off an edge return false; /* walked off an edge */
} }
// check point traces down for dangling corners /* check point traces down for dangling corners */
VectorCopy (trace.endpos, ent->s.origin); VectorCopy(trace.endpos, ent->s.origin);
if (!M_CheckBottom (ent)) if (!M_CheckBottom(ent))
{ {
if ( ent->flags & FL_PARTIALGROUND ) if (ent->flags & FL_PARTIALGROUND)
{ // entity had floor mostly pulled out from underneath it {
// and is trying to correct /* entity had floor mostly pulled out
from underneath it and is trying to
correct */
if (relink) if (relink)
{ {
gi.linkentity (ent); gi.linkentity(ent);
G_TouchTriggers (ent); G_TouchTriggers(ent);
} }
return true; return true;
} }
VectorCopy (oldorg, ent->s.origin);
VectorCopy(oldorg, ent->s.origin);
return false; return false;
} }
if ( ent->flags & FL_PARTIALGROUND ) if (ent->flags & FL_PARTIALGROUND)
{ {
ent->flags &= ~FL_PARTIALGROUND; ent->flags &= ~FL_PARTIALGROUND;
} }
ent->groundentity = trace.ent; ent->groundentity = trace.ent;
ent->groundentity_linkcount = trace.ent->linkcount; ent->groundentity_linkcount = trace.ent->linkcount;
// the move is ok /* the move is ok */
if (relink) if (relink)
{ {
gi.linkentity (ent); gi.linkentity(ent);
G_TouchTriggers (ent); G_TouchTriggers(ent);
} }
return true; return true;
} }
/* ============================================================================ */
//============================================================================ void
M_ChangeYaw(edict_t *ent)
/*
===============
M_ChangeYaw
===============
*/
void M_ChangeYaw (edict_t *ent)
{ {
float ideal; float ideal;
float current; float current;
float move; float move;
float speed; float speed;
current = anglemod(ent->s.angles[YAW]); current = anglemod(ent->s.angles[YAW]);
ideal = ent->ideal_yaw; ideal = ent->ideal_yaw;
if (current == ideal) if (current == ideal)
{
return; return;
}
move = ideal - current; move = ideal - current;
speed = ent->yaw_speed; speed = ent->yaw_speed;
if (ideal > current) if (ideal > current)
{ {
if (move >= 180) if (move >= 180)
{
move = move - 360; move = move - 360;
}
} }
else else
{ {
if (move <= -180) if (move <= -180)
{
move = move + 360; move = move + 360;
}
} }
if (move > 0) if (move > 0)
{ {
if (move > speed) if (move > speed)
{
move = speed; move = speed;
}
} }
else else
{ {
if (move < -speed) if (move < -speed)
{
move = -speed; move = -speed;
}
} }
ent->s.angles[YAW] = anglemod (current + move); ent->s.angles[YAW] = anglemod(current + move);
} }
/* /*
====================== * Turns to the movement direction, and
SV_StepDirection * walks the current distance if facing it.
*/
Turns to the movement direction, and walks the current distance if qboolean
facing it. SV_StepDirection(edict_t *ent, float yaw, float dist)
======================
*/
qboolean SV_StepDirection (edict_t *ent, float yaw, float dist)
{ {
vec3_t move, oldorigin; vec3_t move, oldorigin;
float delta; float delta;
ent->ideal_yaw = yaw; ent->ideal_yaw = yaw;
M_ChangeYaw (ent); M_ChangeYaw(ent);
yaw = yaw*M_PI*2 / 360; yaw = yaw * M_PI * 2 / 360;
move[0] = cos(yaw)*dist; move[0] = cos(yaw) * dist;
move[1] = sin(yaw)*dist; move[1] = sin(yaw) * dist;
move[2] = 0; move[2] = 0;
VectorCopy (ent->s.origin, oldorigin); VectorCopy(ent->s.origin, oldorigin);
if (SV_movestep (ent, move, false))
if (SV_movestep(ent, move, false))
{ {
delta = ent->s.angles[YAW] - ent->ideal_yaw; delta = ent->s.angles[YAW] - ent->ideal_yaw;
if (delta > 45 && delta < 315)
{ // not turned far enough, so don't take the step if ((delta > 45) && (delta < 315))
VectorCopy (oldorigin, ent->s.origin); {
/* not turned far enough, so don't take the step */
VectorCopy(oldorigin, ent->s.origin);
} }
gi.linkentity (ent);
G_TouchTriggers (ent); gi.linkentity(ent);
G_TouchTriggers(ent);
return true; return true;
} }
gi.linkentity (ent);
G_TouchTriggers (ent); gi.linkentity(ent);
G_TouchTriggers(ent);
return false; return false;
} }
/* void
====================== SV_FixCheckBottom(edict_t *ent)
SV_FixCheckBottom
======================
*/
void SV_FixCheckBottom (edict_t *ent)
{ {
ent->flags |= FL_PARTIALGROUND; ent->flags |= FL_PARTIALGROUND;
} }
#define DI_NODIR -1
void
/* SV_NewChaseDir(edict_t *actor, edict_t *enemy, float dist)
================
SV_NewChaseDir
================
*/
#define DI_NODIR -1
void SV_NewChaseDir (edict_t *actor, edict_t *enemy, float dist)
{ {
float deltax,deltay; float deltax, deltay;
float d[3]; float d[3];
float tdir, olddir, turnaround; float tdir, olddir, turnaround;
//FIXME: how did we get here with no enemy
if (!enemy) if (!enemy)
{
return; return;
}
olddir = anglemod( (int)(actor->ideal_yaw/45)*45 ); olddir = anglemod((int)(actor->ideal_yaw / 45) * 45);
turnaround = anglemod(olddir - 180); turnaround = anglemod(olddir - 180);
deltax = enemy->s.origin[0] - actor->s.origin[0]; deltax = enemy->s.origin[0] - actor->s.origin[0];
deltay = enemy->s.origin[1] - actor->s.origin[1]; deltay = enemy->s.origin[1] - actor->s.origin[1];
if (deltax>10)
d[1]= 0;
else if (deltax<-10)
d[1]= 180;
else
d[1]= DI_NODIR;
if (deltay<-10)
d[2]= 270;
else if (deltay>10)
d[2]= 90;
else
d[2]= DI_NODIR;
// try direct route if (deltax > 10)
if (d[1] != DI_NODIR && d[2] != DI_NODIR) {
d[1] = 0;
}
else if (deltax < -10)
{
d[1] = 180;
}
else
{
d[1] = DI_NODIR;
}
if (deltay < -10)
{
d[2] = 270;
}
else if (deltay > 10)
{
d[2] = 90;
}
else
{
d[2] = DI_NODIR;
}
/* try direct route */
if ((d[1] != DI_NODIR) && (d[2] != DI_NODIR))
{ {
if (d[1] == 0) if (d[1] == 0)
{
tdir = d[2] == 90 ? 45 : 315; tdir = d[2] == 90 ? 45 : 315;
}
else else
{
tdir = d[2] == 90 ? 135 : 215; tdir = d[2] == 90 ? 135 : 215;
}
if (tdir != turnaround && SV_StepDirection(actor, tdir, dist))
if ((tdir != turnaround) && SV_StepDirection(actor, tdir, dist))
{
return; return;
}
} }
// try other directions /* try other directions */
if ( ((rand()&3) & 1) || abs(deltay)>abs(deltax)) if (((rand() & 3) & 1) || (abs(deltay) > abs(deltax)))
{ {
tdir=d[1]; tdir = d[1];
d[1]=d[2]; d[1] = d[2];
d[2]=tdir; d[2] = tdir;
} }
if (d[1]!=DI_NODIR && d[1]!=turnaround if ((d[1] != DI_NODIR) && (d[1] != turnaround) &&
&& SV_StepDirection(actor, d[1], dist)) SV_StepDirection(actor, d[1], dist))
return; {
return;
}
if (d[2]!=DI_NODIR && d[2]!=turnaround if ((d[2] != DI_NODIR) && (d[2] != turnaround) &&
&& SV_StepDirection(actor, d[2], dist)) SV_StepDirection(actor, d[2], dist))
return; {
return;
}
/* there is no direct path to the player, so pick another direction */ /* there is no direct path to the player, so pick another direction */
if ((olddir != DI_NODIR) && SV_StepDirection(actor, olddir, dist))
if (olddir!=DI_NODIR && SV_StepDirection(actor, olddir, dist))
return;
if (rand()&1) /*randomly determine direction of search*/
{ {
for (tdir=0 ; tdir<=315 ; tdir += 45) return;
if (tdir!=turnaround && SV_StepDirection(actor, tdir, dist) ) }
return;
if (rand() & 1) /*randomly determine direction of search*/
{
for (tdir = 0; tdir <= 315; tdir += 45)
{
if ((tdir != turnaround) && SV_StepDirection(actor, tdir, dist))
{
return;
}
}
} }
else else
{ {
for (tdir=315 ; tdir >=0 ; tdir -= 45) for (tdir = 315; tdir >= 0; tdir -= 45)
if (tdir!=turnaround && SV_StepDirection(actor, tdir, dist) ) {
return; if ((tdir != turnaround) && SV_StepDirection(actor, tdir, dist))
{
return;
}
}
} }
if (turnaround != DI_NODIR && SV_StepDirection(actor, turnaround, dist) ) if ((turnaround != DI_NODIR) && SV_StepDirection(actor, turnaround, dist))
return; {
return;
}
actor->ideal_yaw = olddir; // can't move actor->ideal_yaw = olddir; /* can't move */
// if a bridge was pulled out from underneath a monster, it may not have /* if a bridge was pulled out from underneath a
// a valid standing position at all monster, it may not have a valid standing
position at all */
if (!M_CheckBottom (actor)) if (!M_CheckBottom(actor))
SV_FixCheckBottom (actor); {
SV_FixCheckBottom(actor);
}
} }
/* qboolean
====================== SV_CloseEnough(edict_t *ent, edict_t *goal, float dist)
SV_CloseEnough
======================
*/
qboolean SV_CloseEnough (edict_t *ent, edict_t *goal, float dist)
{ {
int i; int i;
for (i=0 ; i<3 ; i++) for (i = 0; i < 3; i++)
{ {
if (goal->absmin[i] > ent->absmax[i] + dist) if (goal->absmin[i] > ent->absmax[i] + dist)
{
return false; return false;
}
if (goal->absmax[i] < ent->absmin[i] - dist) if (goal->absmax[i] < ent->absmin[i] - dist)
{
return false; return false;
}
} }
return true; return true;
} }
void
/* M_MoveToGoal(edict_t *ent, float dist)
======================
M_MoveToGoal
======================
*/
void M_MoveToGoal (edict_t *ent, float dist)
{ {
edict_t *goal; edict_t *goal;
goal = ent->goalentity; goal = ent->goalentity;
if (!ent->groundentity && !(ent->flags & (FL_FLY|FL_SWIM))) if (!ent->groundentity && !(ent->flags & (FL_FLY | FL_SWIM)))
{
return; return;
}
// if the next step hits the enemy, return immediately /* if the next step hits the enemy, return immediately */
if (ent->enemy && SV_CloseEnough (ent, ent->enemy, dist) ) if (ent->enemy && SV_CloseEnough(ent, ent->enemy, dist))
{
return; return;
}
// bump around... /* bump around... */
if ( (rand()&3)==1 || !SV_StepDirection (ent, ent->ideal_yaw, dist)) if (((rand() & 3) == 1) || !SV_StepDirection(ent, ent->ideal_yaw, dist))
{ {
if (ent->inuse) if (ent->inuse)
SV_NewChaseDir (ent, goal, dist); {
SV_NewChaseDir(ent, goal, dist);
}
} }
} }
qboolean
/* M_walkmove(edict_t *ent, float yaw, float dist)
===============
M_walkmove
===============
*/
qboolean M_walkmove (edict_t *ent, float yaw, float dist)
{ {
vec3_t move; vec3_t move;
if (!ent->groundentity && !(ent->flags & (FL_FLY|FL_SWIM)))
return false;
yaw = yaw*M_PI*2 / 360; if (!ent->groundentity && !(ent->flags & (FL_FLY | FL_SWIM)))
{
move[0] = cos(yaw)*dist; return false;
move[1] = sin(yaw)*dist; }
yaw = yaw * M_PI * 2 / 360;
move[0] = cos(yaw) * dist;
move[1] = sin(yaw) * dist;
move[2] = 0; move[2] = 0;
return SV_movestep(ent, move, true); return SV_movestep(ent, move, true);

View file

@ -1,225 +1,227 @@
/* /*
Copyright (C) 1997-2001 Id Software, Inc. * Copyright (C) 1997-2001 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 the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* =======================================================================
*
* Player (the arm and the weapons) animation.
*
* =======================================================================
*/
This program is free software; you can redistribute it and/or #define FRAME_stand01 0
modify it under the terms of the GNU General Public License #define FRAME_stand02 1
as published by the Free Software Foundation; either version 2 #define FRAME_stand03 2
of the License, or (at your option) any later version. #define FRAME_stand04 3
#define FRAME_stand05 4
This program is distributed in the hope that it will be useful, #define FRAME_stand06 5
but WITHOUT ANY WARRANTY; without even the implied warranty of #define FRAME_stand07 6
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. #define FRAME_stand08 7
#define FRAME_stand09 8
See the GNU General Public License for more details. #define FRAME_stand10 9
#define FRAME_stand11 10
You should have received a copy of the GNU General Public License #define FRAME_stand12 11
along with this program; if not, write to the Free Software #define FRAME_stand13 12
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define FRAME_stand14 13
#define FRAME_stand15 14
*/ #define FRAME_stand16 15
// G:\quake2\baseq2\models/player_x/frames #define FRAME_stand17 16
#define FRAME_stand18 17
// This file generated by qdata - Do NOT Modify #define FRAME_stand19 18
#define FRAME_stand20 19
#define FRAME_stand01 0 #define FRAME_stand21 20
#define FRAME_stand02 1 #define FRAME_stand22 21
#define FRAME_stand03 2 #define FRAME_stand23 22
#define FRAME_stand04 3 #define FRAME_stand24 23
#define FRAME_stand05 4 #define FRAME_stand25 24
#define FRAME_stand06 5 #define FRAME_stand26 25
#define FRAME_stand07 6 #define FRAME_stand27 26
#define FRAME_stand08 7 #define FRAME_stand28 27
#define FRAME_stand09 8 #define FRAME_stand29 28
#define FRAME_stand10 9 #define FRAME_stand30 29
#define FRAME_stand11 10 #define FRAME_stand31 30
#define FRAME_stand12 11 #define FRAME_stand32 31
#define FRAME_stand13 12 #define FRAME_stand33 32
#define FRAME_stand14 13 #define FRAME_stand34 33
#define FRAME_stand15 14 #define FRAME_stand35 34
#define FRAME_stand16 15 #define FRAME_stand36 35
#define FRAME_stand17 16 #define FRAME_stand37 36
#define FRAME_stand18 17 #define FRAME_stand38 37
#define FRAME_stand19 18 #define FRAME_stand39 38
#define FRAME_stand20 19 #define FRAME_stand40 39
#define FRAME_stand21 20 #define FRAME_run1 40
#define FRAME_stand22 21 #define FRAME_run2 41
#define FRAME_stand23 22 #define FRAME_run3 42
#define FRAME_stand24 23 #define FRAME_run4 43
#define FRAME_stand25 24 #define FRAME_run5 44
#define FRAME_stand26 25 #define FRAME_run6 45
#define FRAME_stand27 26 #define FRAME_attack1 46
#define FRAME_stand28 27 #define FRAME_attack2 47
#define FRAME_stand29 28 #define FRAME_attack3 48
#define FRAME_stand30 29 #define FRAME_attack4 49
#define FRAME_stand31 30 #define FRAME_attack5 50
#define FRAME_stand32 31 #define FRAME_attack6 51
#define FRAME_stand33 32 #define FRAME_attack7 52
#define FRAME_stand34 33 #define FRAME_attack8 53
#define FRAME_stand35 34 #define FRAME_pain101 54
#define FRAME_stand36 35 #define FRAME_pain102 55
#define FRAME_stand37 36 #define FRAME_pain103 56
#define FRAME_stand38 37 #define FRAME_pain104 57
#define FRAME_stand39 38 #define FRAME_pain201 58
#define FRAME_stand40 39 #define FRAME_pain202 59
#define FRAME_run1 40 #define FRAME_pain203 60
#define FRAME_run2 41 #define FRAME_pain204 61
#define FRAME_run3 42 #define FRAME_pain301 62
#define FRAME_run4 43 #define FRAME_pain302 63
#define FRAME_run5 44 #define FRAME_pain303 64
#define FRAME_run6 45 #define FRAME_pain304 65
#define FRAME_attack1 46 #define FRAME_jump1 66
#define FRAME_attack2 47 #define FRAME_jump2 67
#define FRAME_attack3 48 #define FRAME_jump3 68
#define FRAME_attack4 49 #define FRAME_jump4 69
#define FRAME_attack5 50 #define FRAME_jump5 70
#define FRAME_attack6 51 #define FRAME_jump6 71
#define FRAME_attack7 52 #define FRAME_flip01 72
#define FRAME_attack8 53 #define FRAME_flip02 73
#define FRAME_pain101 54 #define FRAME_flip03 74
#define FRAME_pain102 55 #define FRAME_flip04 75
#define FRAME_pain103 56 #define FRAME_flip05 76
#define FRAME_pain104 57 #define FRAME_flip06 77
#define FRAME_pain201 58 #define FRAME_flip07 78
#define FRAME_pain202 59 #define FRAME_flip08 79
#define FRAME_pain203 60 #define FRAME_flip09 80
#define FRAME_pain204 61 #define FRAME_flip10 81
#define FRAME_pain301 62 #define FRAME_flip11 82
#define FRAME_pain302 63 #define FRAME_flip12 83
#define FRAME_pain303 64 #define FRAME_salute01 84
#define FRAME_pain304 65 #define FRAME_salute02 85
#define FRAME_jump1 66 #define FRAME_salute03 86
#define FRAME_jump2 67 #define FRAME_salute04 87
#define FRAME_jump3 68 #define FRAME_salute05 88
#define FRAME_jump4 69 #define FRAME_salute06 89
#define FRAME_jump5 70 #define FRAME_salute07 90
#define FRAME_jump6 71 #define FRAME_salute08 91
#define FRAME_flip01 72 #define FRAME_salute09 92
#define FRAME_flip02 73 #define FRAME_salute10 93
#define FRAME_flip03 74 #define FRAME_salute11 94
#define FRAME_flip04 75 #define FRAME_taunt01 95
#define FRAME_flip05 76 #define FRAME_taunt02 96
#define FRAME_flip06 77 #define FRAME_taunt03 97
#define FRAME_flip07 78 #define FRAME_taunt04 98
#define FRAME_flip08 79 #define FRAME_taunt05 99
#define FRAME_flip09 80 #define FRAME_taunt06 100
#define FRAME_flip10 81 #define FRAME_taunt07 101
#define FRAME_flip11 82 #define FRAME_taunt08 102
#define FRAME_flip12 83 #define FRAME_taunt09 103
#define FRAME_salute01 84 #define FRAME_taunt10 104
#define FRAME_salute02 85 #define FRAME_taunt11 105
#define FRAME_salute03 86 #define FRAME_taunt12 106
#define FRAME_salute04 87 #define FRAME_taunt13 107
#define FRAME_salute05 88 #define FRAME_taunt14 108
#define FRAME_salute06 89 #define FRAME_taunt15 109
#define FRAME_salute07 90 #define FRAME_taunt16 110
#define FRAME_salute08 91 #define FRAME_taunt17 111
#define FRAME_salute09 92 #define FRAME_wave01 112
#define FRAME_salute10 93 #define FRAME_wave02 113
#define FRAME_salute11 94 #define FRAME_wave03 114
#define FRAME_taunt01 95 #define FRAME_wave04 115
#define FRAME_taunt02 96 #define FRAME_wave05 116
#define FRAME_taunt03 97 #define FRAME_wave06 117
#define FRAME_taunt04 98 #define FRAME_wave07 118
#define FRAME_taunt05 99 #define FRAME_wave08 119
#define FRAME_taunt06 100 #define FRAME_wave09 120
#define FRAME_taunt07 101 #define FRAME_wave10 121
#define FRAME_taunt08 102 #define FRAME_wave11 122
#define FRAME_taunt09 103 #define FRAME_point01 123
#define FRAME_taunt10 104 #define FRAME_point02 124
#define FRAME_taunt11 105 #define FRAME_point03 125
#define FRAME_taunt12 106 #define FRAME_point04 126
#define FRAME_taunt13 107 #define FRAME_point05 127
#define FRAME_taunt14 108 #define FRAME_point06 128
#define FRAME_taunt15 109 #define FRAME_point07 129
#define FRAME_taunt16 110 #define FRAME_point08 130
#define FRAME_taunt17 111 #define FRAME_point09 131
#define FRAME_wave01 112 #define FRAME_point10 132
#define FRAME_wave02 113 #define FRAME_point11 133
#define FRAME_wave03 114 #define FRAME_point12 134
#define FRAME_wave04 115 #define FRAME_crstnd01 135
#define FRAME_wave05 116 #define FRAME_crstnd02 136
#define FRAME_wave06 117 #define FRAME_crstnd03 137
#define FRAME_wave07 118 #define FRAME_crstnd04 138
#define FRAME_wave08 119 #define FRAME_crstnd05 139
#define FRAME_wave09 120 #define FRAME_crstnd06 140
#define FRAME_wave10 121 #define FRAME_crstnd07 141
#define FRAME_wave11 122 #define FRAME_crstnd08 142
#define FRAME_point01 123 #define FRAME_crstnd09 143
#define FRAME_point02 124 #define FRAME_crstnd10 144
#define FRAME_point03 125 #define FRAME_crstnd11 145
#define FRAME_point04 126 #define FRAME_crstnd12 146
#define FRAME_point05 127 #define FRAME_crstnd13 147
#define FRAME_point06 128 #define FRAME_crstnd14 148
#define FRAME_point07 129 #define FRAME_crstnd15 149
#define FRAME_point08 130 #define FRAME_crstnd16 150
#define FRAME_point09 131 #define FRAME_crstnd17 151
#define FRAME_point10 132 #define FRAME_crstnd18 152
#define FRAME_point11 133 #define FRAME_crstnd19 153
#define FRAME_point12 134 #define FRAME_crwalk1 154
#define FRAME_crstnd01 135 #define FRAME_crwalk2 155
#define FRAME_crstnd02 136 #define FRAME_crwalk3 156
#define FRAME_crstnd03 137 #define FRAME_crwalk4 157
#define FRAME_crstnd04 138 #define FRAME_crwalk5 158
#define FRAME_crstnd05 139 #define FRAME_crwalk6 159
#define FRAME_crstnd06 140 #define FRAME_crattak1 160
#define FRAME_crstnd07 141 #define FRAME_crattak2 161
#define FRAME_crstnd08 142 #define FRAME_crattak3 162
#define FRAME_crstnd09 143 #define FRAME_crattak4 163
#define FRAME_crstnd10 144 #define FRAME_crattak5 164
#define FRAME_crstnd11 145 #define FRAME_crattak6 165
#define FRAME_crstnd12 146 #define FRAME_crattak7 166
#define FRAME_crstnd13 147 #define FRAME_crattak8 167
#define FRAME_crstnd14 148 #define FRAME_crattak9 168
#define FRAME_crstnd15 149 #define FRAME_crpain1 169
#define FRAME_crstnd16 150 #define FRAME_crpain2 170
#define FRAME_crstnd17 151 #define FRAME_crpain3 171
#define FRAME_crstnd18 152 #define FRAME_crpain4 172
#define FRAME_crstnd19 153 #define FRAME_crdeath1 173
#define FRAME_crwalk1 154 #define FRAME_crdeath2 174
#define FRAME_crwalk2 155 #define FRAME_crdeath3 175
#define FRAME_crwalk3 156 #define FRAME_crdeath4 176
#define FRAME_crwalk4 157 #define FRAME_crdeath5 177
#define FRAME_crwalk5 158 #define FRAME_death101 178
#define FRAME_crwalk6 159 #define FRAME_death102 179
#define FRAME_crattak1 160 #define FRAME_death103 180
#define FRAME_crattak2 161 #define FRAME_death104 181
#define FRAME_crattak3 162 #define FRAME_death105 182
#define FRAME_crattak4 163 #define FRAME_death106 183
#define FRAME_crattak5 164 #define FRAME_death201 184
#define FRAME_crattak6 165 #define FRAME_death202 185
#define FRAME_crattak7 166 #define FRAME_death203 186
#define FRAME_crattak8 167 #define FRAME_death204 187
#define FRAME_crattak9 168 #define FRAME_death205 188
#define FRAME_crpain1 169 #define FRAME_death206 189
#define FRAME_crpain2 170 #define FRAME_death301 190
#define FRAME_crpain3 171 #define FRAME_death302 191
#define FRAME_crpain4 172 #define FRAME_death303 192
#define FRAME_crdeath1 173 #define FRAME_death304 193
#define FRAME_crdeath2 174 #define FRAME_death305 194
#define FRAME_crdeath3 175 #define FRAME_death306 195
#define FRAME_crdeath4 176 #define FRAME_death307 196
#define FRAME_crdeath5 177 #define FRAME_death308 197
#define FRAME_death101 178
#define FRAME_death102 179
#define FRAME_death103 180
#define FRAME_death104 181
#define FRAME_death105 182
#define FRAME_death106 183
#define FRAME_death201 184
#define FRAME_death202 185
#define FRAME_death203 186
#define FRAME_death204 187
#define FRAME_death205 188
#define FRAME_death206 189
#define FRAME_death301 190
#define FRAME_death302 191
#define FRAME_death303 192
#define FRAME_death304 193
#define FRAME_death305 194
#define FRAME_death306 195
#define FRAME_death307 196
#define FRAME_death308 197
#define MODEL_SCALE 1.000000
#define MODEL_SCALE 1.000000