crouch cleanups
parent
28ba3a553c
commit
664efacb96
|
@ -1500,10 +1500,10 @@ bool move(physent *d, vec &dir)
|
|||
return !collided;
|
||||
}
|
||||
|
||||
void crouchplayer(physent *pl, int moveres, bool local, float speed, float minheight, float maxheight)
|
||||
void crouchplayer(physent *pl, int moveres, bool local)
|
||||
{
|
||||
if(!curtime) return;
|
||||
speed = (maxheight - minheight) * (curtime / speed);
|
||||
float minheight = pl->maxheight * CROUCHHEIGHT, speed = (pl->maxheight - minheight) * curtime / float(CROUCHTIME);
|
||||
if(pl->crouching < 0)
|
||||
{
|
||||
if(pl->eyeheight > minheight)
|
||||
|
@ -1517,9 +1517,9 @@ void crouchplayer(physent *pl, int moveres, bool local, float speed, float minhe
|
|||
}
|
||||
}
|
||||
}
|
||||
else if(pl->eyeheight < maxheight)
|
||||
else if(pl->eyeheight < pl->maxheight)
|
||||
{
|
||||
float diff = min(maxheight - pl->eyeheight, speed), step = diff/moveres;
|
||||
float diff = min(pl->maxheight - pl->eyeheight, speed), step = diff/moveres;
|
||||
pl->eyeheight += diff;
|
||||
if(pl->physstate > PHYS_FALL)
|
||||
{
|
||||
|
|
|
@ -204,7 +204,7 @@ namespace game
|
|||
}
|
||||
if(d->state==CS_ALIVE || d->state==CS_EDITING)
|
||||
{
|
||||
crouchplayer(d, 10, false, CROUCHTIME, CROUCHMINHEIGHT, CROUCHMAXHEIGHT);
|
||||
crouchplayer(d, 10, false);
|
||||
if(smoothmove && d->smoothmillis>0) predictplayer(d, true);
|
||||
else moveplayer(d, 1, false);
|
||||
}
|
||||
|
@ -240,7 +240,7 @@ namespace game
|
|||
else if(!intermission)
|
||||
{
|
||||
if(player1->ragdoll) cleanragdoll(player1);
|
||||
crouchplayer(player1, 10, true, CROUCHTIME, CROUCHMINHEIGHT, CROUCHMAXHEIGHT);
|
||||
crouchplayer(player1, 10, true);
|
||||
moveplayer(player1, 10, true);
|
||||
swayhudgun(curtime);
|
||||
entities::checkitems(player1);
|
||||
|
|
|
@ -345,10 +345,6 @@ static const struct guninfo { int sound, attackdelay, damage, spread, projspeed,
|
|||
|
||||
#include "ai.h"
|
||||
|
||||
#define CROUCHTIME 150
|
||||
#define CROUCHMAXHEIGHT 14
|
||||
#define CROUCHMINHEIGHT 10
|
||||
|
||||
// inherited by fpsent and server clients
|
||||
struct fpsstate
|
||||
{
|
||||
|
@ -580,7 +576,6 @@ struct fpsent : dynent, fpsstate
|
|||
lastcollect = vec(-1e10f, -1e10f, -1e10f);
|
||||
stopattacksound();
|
||||
lastnode = -1;
|
||||
eyeheight = CROUCHMAXHEIGHT;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -41,6 +41,9 @@ enum { ENT_PLAYER = 0, ENT_CAMERA, ENT_BOUNCE };
|
|||
|
||||
enum { COLLIDE_AABB = 0, COLLIDE_OBB, COLLIDE_ELLIPSE };
|
||||
|
||||
#define CROUCHTIME 150
|
||||
#define CROUCHHEIGHT 0.75f
|
||||
|
||||
struct physent // base entity type, can be affected by physics
|
||||
{
|
||||
vec o, vel, falling; // origin, velocity
|
||||
|
@ -48,7 +51,7 @@ struct physent // base entity type, can be affe
|
|||
float yaw, pitch, roll;
|
||||
float maxspeed; // cubes per second, 100 for player
|
||||
int timeinair;
|
||||
float radius, eyeheight, aboveeye; // bounding box size
|
||||
float radius, eyeheight, maxheight, aboveeye; // bounding box size
|
||||
float xradius, yradius, zmargin;
|
||||
vec floor; // the normal of floor the dynent is on
|
||||
|
||||
|
@ -64,7 +67,7 @@ struct physent // base entity type, can be affe
|
|||
bool blocked; // used by physics to signal ai
|
||||
|
||||
physent() : o(0, 0, 0), deltapos(0, 0, 0), newpos(0, 0, 0), yaw(0), pitch(0), roll(0), maxspeed(100),
|
||||
radius(4.1f), eyeheight(14), aboveeye(1), xradius(4.1f), yradius(4.1f), zmargin(0),
|
||||
radius(4.1f), eyeheight(14), maxheight(14), aboveeye(1), xradius(4.1f), yradius(4.1f), zmargin(0),
|
||||
state(CS_ALIVE), editstate(CS_ALIVE), type(ENT_PLAYER),
|
||||
collidetype(COLLIDE_ELLIPSE),
|
||||
blocked(false)
|
||||
|
@ -80,6 +83,7 @@ struct physent // base entity type, can be affe
|
|||
{
|
||||
inwater = 0;
|
||||
timeinair = 0;
|
||||
eyeheight = maxheight;
|
||||
strafe = move = crouching = 0;
|
||||
physstate = PHYS_FALL;
|
||||
vel = falling = vec(0, 0, 0);
|
||||
|
|
|
@ -336,7 +336,7 @@ extern bool loadents(const char *fname, vector<entity> &ents, uint *crc = NULL);
|
|||
// physics
|
||||
extern void moveplayer(physent *pl, int moveres, bool local);
|
||||
extern bool moveplayer(physent *pl, int moveres, bool local, int curtime);
|
||||
extern void crouchplayer(physent *pl, int moveres, bool local, float speed, float minheight, float maxheight);
|
||||
extern void crouchplayer(physent *pl, int moveres, bool local);
|
||||
extern bool collide(physent *d, const vec &dir = vec(0, 0, 0), float cutoff = 0.0f, bool playercol = true);
|
||||
extern bool bounce(physent *d, float secs, float elasticity, float waterfric, float grav);
|
||||
extern bool bounce(physent *d, float elasticity, float waterfric, float grav);
|
||||
|
|
Loading…
Reference in New Issue