ctf flag pickup

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@1844 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
driAn
2008-05-03 19:27:17 +00:00
parent b0e7e553cd
commit 722d70907b
4 changed files with 24 additions and 11 deletions
+3 -2
View File
@@ -3,6 +3,8 @@
#include "pch.h"
#include "cube.h"
const int physent::crouchtime = 200;
vector<entity> ents;
const char *entnames[] =
@@ -16,7 +18,6 @@ const char *entnames[] =
const char *entmdlnames[] =
{
//FIXME : fix the "pickups" infront
"pickups/pistolclips", "pickups/ammobox", "pickups/nades", "pickups/health", "pickups/kevlar", "pickups/akimbo",
};
@@ -161,7 +162,7 @@ void checkitems(playerent *d)
if(e.type==CTF_FLAG)
{
vec v(e.x, e.y, e.z);
if(d->o.dist(v)<5.0f) trypickup(i, d);
if(objcollide(d, v, 2.5f, 4.0f)) trypickup(i, d);
}
else
{
+3 -2
View File
@@ -100,6 +100,7 @@ struct physent
int lastcrouch;
char move, strafe;
uchar state, type;
static const int crouchtime;
physent() : o(0, 0, 0), yaw(270), pitch(0), roll(0), pitchvel(0),
crouching(false), lastcrouch(0), state(CS_ALIVE)
@@ -118,9 +119,9 @@ struct physent
virtual float dyneyeheight()
{
extern int lastmillis, crouchtime;
extern int lastmillis;
const float croucheyeheight = eyeheight*3.0f/4.0f;
const float t = (lastmillis-lastcrouch)/(float)crouchtime;
const float t = (lastmillis-lastcrouch)/(float)physent::crouchtime;
if(lastcrouch && t < 1.0f && t >= 0.0f) // crouch move in progress
{
+17 -7
View File
@@ -108,16 +108,26 @@ void mmcollide(physent *d, float &hi, float &lo) // collide with a map
const float r = mmi.rad+d->radius;
if(fabs(e.x-d->o.x)<r && fabs(e.y-d->o.y)<r)
{
float mmz = (float)(S(e.x, e.y)->floor+mmi.zoff+e.attr3);
float dz = d->o.z+(-eyeheight+d->aboveeye)/2.0f;
const float mmz = (float)(S(e.x, e.y)->floor+mmi.zoff+e.attr3);
const float dz = d->o.z+(-eyeheight+d->aboveeye)/2.0f;
if(dz<mmz) { if(mmz<hi) hi = mmz; }
else if(mmz+mmi.h>lo) lo = mmz+mmi.h;
}
}
}
// TESTME
VARP(crouchtime, 1, 200, 20000);
bool objcollide(physent *d, vec &objpos, float objrad, float objheight) // collide with custom/typeless objects
{
const float r = d->radius+objrad;
if(fabs(objpos.x-d->o.x)<r && fabs(objpos.y-d->o.y)<r)
{
const float maxdist = max(d->eyeheight+d->aboveeye, objheight);
const float dz = d->o.z+(-d->eyeheight+d->aboveeye)/2.0f;
const float objz = objpos.z+objheight/2.0f;
return dz-objz <= maxdist || dz-objz >= -maxdist;
}
return false;
}
// all collision happens here
// spawn is a dirty side effect used in spawning
@@ -217,7 +227,7 @@ bool collide(physent *d, bool spawn, float drop, float rise)
d->vel.z = 0; // cancel out jumping velocity
}
d->onfloor = d->o.z-eyeheight-lo < (lastmillis-d->lastcrouch<=crouchtime ? 0.1f : 0.01f);
d->onfloor = d->o.z-eyeheight-lo < (lastmillis-d->lastcrouch<=physent::crouchtime ? 0.1f : 0.01f);
}
return true;
}
@@ -515,8 +525,8 @@ void updatecrouch(playerent *p, bool on)
if(p->crouching == on) return;
p->crouching = on;
const int progress = lastmillis-p->lastcrouch;
if(progress > crouchtime) p->lastcrouch = lastmillis; // new crouch
else p->lastcrouch = lastmillis-(crouchtime-progress); // only change direction, fix progress time
if(progress > physent::crouchtime) p->lastcrouch = lastmillis; // new crouch
else p->lastcrouch = lastmillis-(physent::crouchtime-progress); // only change direction, fix progress time
}
void crouch(bool on)
+1
View File
@@ -430,6 +430,7 @@ extern void mousemove(int dx, int dy);
extern void fixcamerarange(physent *cam = camera1);
extern float floor(short x, short y);
extern void updatecrouch(playerent *p, bool on);
extern bool objcollide(physent *d, vec &objpos, float objrad, float objheight);
// sound
extern void playsound(int n, physent *p = NULL, entity *ent = NULL, const vec *v = NULL, int priority = SP_NORMAL);