BTSV_API btEntity BT_FireLaser(btEntity self, vec3 org, vec3 dir, float dmg) { BTGE_Trace tr; btEntity cur; btEntity tmp; tmp=btNewEntityTriggerInit(NULL, NULL); // tmp->solidtype=BT_SOLID_BBOX; // tmp->solidtype=BT_SOLID_TRIGGER; // tmp->movetype=BT_MOVE_FLYMISSILE; tmp->owner=self; tmp->effects=BT_EFF_BEAM_LASER|BT_EFF_GLOW_RED|BT_EFF_ALPHA_50; tmp->origin=org; tmp->velocity=v3scale(dir, 1000); btSetThink(tmp, btDeleteEntity, 0.25); // BT_BulletMuzzleFlash(self, org, dir, BT_MOD_BULLET); btTraceline(&tr, self->morg, self->mend, BT_TRACE_MONSTERS|BT_TRACE_BSPSOLID, self); cur=tr.ent; while(cur) { BT_Damage(cur, self, dmg, BT_MOD_BULLET); cur=cur->chain; } return(tmp); }
int check_conflict(const vec3d *src,const vec3d *dest,const vec3d *point,double dis) { vec3d dir; double dirLength; vec3d pDir; double d; vec3d dir2; v3sub(dest,src,&dir); dirLength = v3length(&dir); if (dirLength!=0.0) v3scale(&dir,1.0/dirLength,&dir); v3sub(point,src,&pDir); d = v3dot(&pDir,&dir); if (d<0.0) return 0; if (d>dirLength) return 0; setVec3dToVec3d(&dir,&dir2); v3simpleRotateY(&dir2,90); d = fabs(v3dot(&pDir,&dir2)); if (d<dis) return 1; else return 0; }
void rebuildTmat(transformData* xform) { vector3d v; if (xform) { if (xform->type == ROTxform) { vector3d axis; matrix4 m1, m2, m3, m4; double twistangle = 0.0; v = xform->a2; v3translationMat(&v, &m1); twistangle = xform->currVal - xform->phase; v3makeVec(&(xform->a2), &(xform->a1), &axis); v3rotationMat(&axis, twistangle, &m2); v3negate(&v); v3translationMat(&v, &m4); v3matMul(&m2, &m1, &m3); v3matMul(&m4, &m3, &(xform->tmat)); } else if (xform->type == TRANSxform) { v3sub(&(xform->a2), &(xform->a1), &v); if (v3squaredLength(&v) > 0.000001) { v3scale(&v, xform->currVal - xform->phase); v3translationMat(&v, &(xform->tmat)); } else { v3identityMat(&(xform->tmat)); } } } }
/** Calculate the physical center-point of an entity, * which is not necessarily at its origin. */ BTSV_API vec3 btCalcCenter(btEntity self) { vec3 org, mid; mid=v3scale(v3add(self->mins, self->maxs), 0.5); org=v3add(self->origin, mid); return(org); }
BTEIFGL_API void BGBDT_Part_ParticleEmitPara( BGBDT_ParticleEmission *para) { BGBDT_Particle *tmp; vec3 tvel, trvel; int i; for(i=0; i<para->cnt; i++) { trvel=vec3( bgbdt_part_randsf(), bgbdt_part_randsf(), bgbdt_part_randsf()); trvel=v3norm(trvel); trvel=v3scale(trvel, 1.0+bgbdt_part_randsf()*0.25); tvel=v3add(para->bvel, v3mul(para->rvel, trvel)); tmp=BGBDT_Part_SpawnParticle(para->org, tvel, para->atxy); tmp->zacc=para->zacc; tmp->clr=para->clr; tmp->clrvel=para->clrvel; tmp->rad=para->rad; tmp->ttl=para->ttl; BGBDT_Part_UpdateParticleClr(tmp, bgbdt_part_randsf()*0.2); } }
void state_check() { char *msg, *tmp; setVec3dToVec3d(&loc, &oldLoc); msg = my_send("getLoc"); setStrToVec3d(msg,&loc); msg = my_send("getRev"); setStrToVec3d(msg,&rot); setXYZToVec3d(0,0,1,&front); v3rotate(&front,&rot); //v3simpleRotateY(&front,rot.y); setXYZToVec3d(1,0,0,&left); v3rotate(&left,&rot); //v3simpleRotateY(&left,rot.y); v3sub(&loc,&oldLoc,&vel); v3scale(&vel,1.0/dt,&vel); msg = my_send("searchBurdens"); makeBurdenSet(msg); msg = my_send("searchObstacles"); tmp = strtok(msg," "); tmp = strtok(NULL," "); tmp = strtok(NULL," "); obstacle1.x = atof(tmp); tmp = strtok(NULL," "); obstacle1.y = atof(tmp); tmp = strtok(NULL," "); obstacle1.z = atof(tmp); tmp = strtok(NULL," "); tmp = strtok(NULL," "); obstacle2.x = atof(tmp); tmp = strtok(NULL," "); obstacle2.y = atof(tmp); tmp = strtok(NULL," "); obstacle2.z = atof(tmp); }
BTEIFGL_API void BGBDT_Part_ParticleExplosionBasic( vec3d org, vec3 bvel, vec3 rvel, int cnt, int atxy, u32 clr) { BGBDT_Particle *tmp; vec3 tvel, trvel; int i; for(i=0; i<cnt; i++) { // trvel=vec3( // bgbdt_part_scurve(bgbdt_part_randsf()), // bgbdt_part_scurve(bgbdt_part_randsf()), // bgbdt_part_scurve(bgbdt_part_randsf())); // trvel=vec3( // bgbdt_part_scurve(bgbdt_part_randf())*2-1, // bgbdt_part_scurve(bgbdt_part_randf())*2-1, // bgbdt_part_scurve(bgbdt_part_randf())*2-1); trvel=vec3( bgbdt_part_randsf(), bgbdt_part_randsf(), bgbdt_part_randsf()); trvel=v3norm(trvel); trvel=v3scale(trvel, 1.0+bgbdt_part_randsf()*0.25); tvel=v3add(bvel, v3mul(rvel, trvel)); tmp=BGBDT_Part_SpawnParticle(org, tvel, atxy); tmp->clr=clr; tmp->ttl=500; } }
BTSV_API btEntity BT_FireGrenade(btEntity self, vec3 org, vec3 dir, float dmg, float speed, float radius) { btEntity tmp; tmp=btNewEntityTriggerInit(NULL, NULL); // tmp->solidtype=BT_SOLID_BBOX; tmp->solidtype=BT_SOLID_TRIGGER; tmp->movetype=BT_MOVE_BOUNCE; tmp->owner=self; tmp->mins=vec3(-8,-8,-8); tmp->maxs=vec3( 8, 8, 8); btSetModel(tmp, "models/objects/rocket/rocket0.ac"); tmp->origin=org; tmp->angles=v3sub(btVecToAngles(dir), vec3(0,0,180)); tmp->velocity=v3scale(dir, speed); tmp->damage=dmg; tmp->height=radius; tmp->effects=BT_EFF_SMOKETRAIL|BT_EFF_NOSHADOW| BT_EFF_GLOW_RED|BT_EFF_GLOW_HIGH| BT_EFF_GLOW_BRIGHT1|BT_EFF_GLOW_BRIGHT0; tmp->vt->touch=BT_GrenadeTouch; btSetThink(tmp, BT_GrenadeThink, 10); return(tmp); }
BTSV_API vec3 btBoxStepMove(vec3 org, vec3 mins, vec3 maxs, vec3 ivel, float dt, btEntity self) { vec3 org1; #if 1 if(self) { self->flags&=~(BT_FL_SIMPLEMOVE|BT_FL_OFFGROUND|BT_FL_JUMPMOVE); self->impulseVelocity=ivel; if(self->flags&BT_FL_CLIENT) { // self->flags&=~(BT_FL_ONGROUND); } } if(self && (self->flags&BT_FL_NOCLIP)) { org1=v3add(org, v3scale(ivel, dt)); return(org1); } #endif org1=btBoxStepMoveI(org, mins, maxs, ivel, dt, self); return(org1); }
V6 ldeflect(V6 s, V6 e, int flag) { double cprime; double g1; double g2; V3 ehat; V3 p; V3 qhat; V3 x; /* the deflection vector */ V3 x1; /* scratch */ V3 x2; /* scratch */ p = v6GetPos(s); { V6 v6; v6 = v6sum(e, s); qhat = v3unit(v6GetPos(v6)); } ehat = v3unit(v6GetPos(e)); cprime = 86400.0 * (IAU_C / IAU_AU); g1 = (2.0 * IAU_K * IAU_K) / (cprime * cprime * v6mod(e)); g2 = 1 + v3dot(qhat, ehat); /* limit the value of g2 as Patrick Wallace does: ** clip it at 1.0e-5 radians (~922 arcseconds) */ if (g2 < 1.0e-5) { g2 = 1.0e-5; } x1 = v3scale(ehat, v3dot(p, qhat)); x2 = v3scale(qhat, v3dot(p, ehat)); x = v3scale(v3diff(x1, x2), g1/g2); if (flag > 0) { p = v3sum(p, x); } else if (flag < 0) { p = v3diff(p, x); } v6SetPos(s, p); return(s); }
/** Calculate the bounding radius for an entity from its center. */ BTSV_API float btCalcRadius(btEntity self) { vec3 org; float rad; // org=btCalcCenter(self); org=v3scale(v3add(self->mins, self->maxs), 0.5); rad=v3len(v3sub(self->maxs, org)); return(rad); }
V6 cat2v6r1(double r, double d, double rd, double dd, double px, double rv, double C) { V6 v6; /* the state vector */ double m; /* vector modulus */ /* get the vector the ES way, and scale it manually */ v6 = cat2v6u2(r, d, rd, dd, px, rv, C); if (px > 0.001) { m = 1 / as2r(px); v6GetPos(v6) = v3scale(v6GetPos(v6), m); v6GetVel(v6) = v3scale(v6GetVel(v6), m*as2r(1)/C); } else { m = 1e10; v6GetPos(v6) = v3scale(v6GetPos(v6), m); v6GetVel(v6) = v3scale(v6GetVel(v6), m*as2r(1)/C); } return(v6); }
BTSV_API btEntity BT_FirePlasma(btEntity self, vec3 org, vec3 dir, float dmg, float speed, float radius, int clr) { btEntity tmp; tmp=btNewEntityTriggerInit(NULL, NULL); // tmp->solidtype=BT_SOLID_BBOX; tmp->solidtype=BT_SOLID_TRIGGER; tmp->movetype=BT_MOVE_FLYMISSILE; tmp->owner=self; tmp->mins=vec3(-4,-4,-4); tmp->maxs=vec3( 4, 4, 4); tmp->origin=org; tmp->angles=v3sub(btVecToAngles(dir), vec3(0,0,180)); tmp->velocity=v3scale(dir, speed); tmp->damage=dmg; tmp->height=radius; tmp->effects=BT_EFF_NOSHADOW| BT_EFF_GLOW_BRIGHT1|BT_EFF_GLOW_BRIGHT0; switch(clr) { case 0: case 1: btSetModel(tmp, "s_plasma"); tmp->effects|=BT_EFF_GLOW_GREEN|BT_EFF_GLOW_BLUE; break; case 2: btSetModel(tmp, "s_plasma2"); tmp->effects|=BT_EFF_GLOW_RED|BT_EFF_GLOW_BLUE; break; case 3: btSetModel(tmp, "s_plasma3"); tmp->effects|=BT_EFF_GLOW_GREEN|BT_EFF_GLOW_RED; break; case 4: btSetModel(tmp, "s_plasma4"); tmp->effects|=BT_EFF_GLOW_GREEN| BT_EFF_GLOW_RED|BT_EFF_GLOW_BLUE; break; default: btSetModel(tmp, "s_plasma"); tmp->effects|=BT_EFF_GLOW_GREEN|BT_EFF_GLOW_BLUE; break; } tmp->vt->touch=BT_PlasmaTouch; btSetThink(tmp, BT_RocketThink, 25); return(tmp); }
V3 v3unit(V3 v) { double m; m = v3mod(v); if (m != 0.0) { v = v3scale(v, 1/m); } return(v); }
V6 fk524(V6 v) { v = m6v6(M, v); /* restore e-terms */ #ifdef ETERMS { double m; /* modulus of position vector */ V3 s0; V3 s1, s1dot; V3 r0, r0dot; V3 r1, r1dot; /* cache the modulus */ m = v6mod(v); /* convert the state vector back to a unit vector */ v6GetPos(v) = v3scale(v6GetPos(v), 1/m); v6GetVel(v) = v3scale(v6GetVel(v), CB/(m*as2r(1))); /* now proceed with the standard treatment */ r1 = v6GetPos(v); r1dot = v6GetVel(v); s1 = v3unit(r1); s0 = s1; r0 = v3sum(s1, v3diff(A, v3scale(s0, v3dot(s0, A)))); #ifdef ETERMS_ITERATE s0 = v3unit(r0); r0 = v3sum(s1, v3diff(A, v3scale(s0, v3dot(s0, A)))); #endif v6SetPos(v, r0); #ifdef ETERMS_VEL s1dot = v3scale(r1dot, 1/v3mod(r1)); r0dot = v3sum(s1dot, v3diff(Adot, v3scale(s0, v3dot(s0, Adot)))); v6SetVel(v, r0dot); #endif /* convert the unit vector back into a state vector */ v6GetPos(v) = v3scale(v6GetPos(v), m); v6GetVel(v) = v3scale(v6GetVel(v), (m*as2r(1))/CB); } #endif return(v); }
BTSV_API btEntity BT_FireBlockPlacerColor(btEntity self, vec3 org, vec3 dir, float dmg, float speed, float radius, int clr, int voxty) { btEntity tmp; tmp=btNewEntityTriggerInit(NULL, NULL); // tmp->solidtype=BT_SOLID_BBOX; tmp->solidtype=BT_SOLID_TRIGGER; tmp->movetype=BT_MOVE_FLYMISSILE; tmp->owner=self; tmp->mins=vec3(-2,-2,-2); tmp->maxs=vec3( 2, 2, 2); tmp->flags|=BT_FL_FLY; btSetModel(tmp, "models/objects/laser/laser0.ac"); tmp->origin=org; tmp->angles=v3sub(btVecToAngles(dir), vec3(0,0,180)); tmp->velocity=v3scale(dir, speed); tmp->damage=dmg; tmp->height=radius; tmp->state=voxty; tmp->effects=BT_EFF_NOSHADOW| BT_EFF_SPARKSTRAIL| // BT_EFF_GLOW_RED|BT_EFF_GLOW_GREEN| // BT_EFF_GLOW_HIGH| BT_EFF_GLOW_BRIGHT1|BT_EFF_GLOW_BRIGHT0; switch(clr) { case 0: tmp->effects|=BT_EFF_GLOW_RED|BT_EFF_GLOW_GREEN; break; case 1: tmp->effects|=BT_EFF_GLOW_RED; break; case 2: tmp->effects|=BT_EFF_GLOW_GREEN; break; case 3: tmp->effects|=BT_EFF_GLOW_RED|BT_EFF_GLOW_GREEN; break; case 4: tmp->effects|=BT_EFF_GLOW_BLUE; break; case 5: tmp->effects|=BT_EFF_GLOW_RED|BT_EFF_GLOW_BLUE; break; case 6: tmp->effects|=BT_EFF_GLOW_GREEN|BT_EFF_GLOW_BLUE; break; case 7: tmp->effects|=BT_EFF_GLOW_WHITE; break; } tmp->vt->touch=BT_BlockPlacerTouch; // btSetThink(tmp, BT_RocketThink, 25); btSetThink(tmp, BT_PlacerThink, 5); return(tmp); }
vec3 BTGE_EntBSP_CalcEntityListOrigin(btWorld wrl, btEntity lst) { btEntity cur; vec3 org; int i, n; cur=lst; org=vec3(0,0,0); n=0; while(cur) { org=v3add(org, btCalcCenter(cur)); n++; cur=cur->chain; } if(!n)n=1; org=v3scale(org, 1.0/n); return(org); }
BTSV_API btEntity BT_BulletMuzzleFlash(btEntity self, vec3 org, vec3 dir, int mod) { btEntity tmp; tmp=btNewEntityTriggerInit(NULL, NULL); // tmp->solidtype=BT_SOLID_BBOX; // tmp->solidtype=BT_SOLID_TRIGGER; // tmp->movetype=BT_MOVE_FLYMISSILE; tmp->owner=self; tmp->origin=org; tmp->angles=v3sub(btVecToAngles(dir), vec3(0,0,180)); tmp->velocity=v3scale(dir, 1000); tmp->effects=BT_EFF_NOSHADOW| BT_EFF_GLOW_RED|BT_EFF_GLOW_GREEN|BT_EFF_GLOW_HIGH| BT_EFF_GLOW_BRIGHT1|BT_EFF_GLOW_BRIGHT0; btSetThink(tmp, btDeleteEntity, 0.1); }
V6 fk425(V6 v) { /* ensure cartesian vectors */ v = v6s2c(v); #ifdef ETERMS { double m; /* modulus of position vector */ V3 u0, u0dot; V3 u1, u1dot; /* cache the modulus */ m = v6mod(v); /* convert the state vector back to a unit vector */ v6GetPos(v) = v3scale(v6GetPos(v), 1/m); v6GetVel(v) = v3scale(v6GetVel(v), CB/(m*as2r(1))); /* now proceed with the standard treatment */ u0 = v6GetPos(v); u1 = v3diff(u0, v3diff(A, v3scale(u0, v3dot(u0, A)))); v6SetPos(v, u1); #ifdef ETERMS_VEL u0dot = v6GetVel(v); u1dot = v3diff(u0dot, v3diff(Adot, v3scale(u0, v3dot(u0, Adot)))); v6SetVel(v, u1dot); #endif /* convert the unit vector back into a state vector */ v6GetPos(v) = v3scale(v6GetPos(v), m); v6GetVel(v) = v3scale(v6GetVel(v), (m*as2r(1))/CB); } #endif v = m6v6(M, v); return(v); }
BTSV_API int btWalkmove(btEntity self, float yaw, float dist) { vec3 org, dir, org1; int i; if(dist>0) { // printf("btWalkmove: %d %f, %d %d\n", (int)yaw, dist, // (int)self->idealYaw, (int)btCurrentYaw(self)); } #if 1 if(self->flags&BT_FL_SCRIPTED) { //predict and update flags as usual // dir=BT_TargetDirection(self, self->goalEntity); // dir=v3scale(dir, dist/btge_framedt); dir=v3scale(btYawVector(yaw), dist/btge_framedt); org=btBoxStepMove(self->origin, self->mins, self->maxs, dir, btge_framedt, self); if(self->flags&BT_FL_SIMPLEMOVE) { self->origin=org; return(1); } //but force the movement org=v3add(self->origin, v3scale(dir, btge_framedt)); self->origin=org; return(1); } #endif #if 1 // btge_tempSelf=self; dir=v3scale(btYawVector(yaw), dist/btge_framedt); org=btBoxStepMove(self->origin, self->mins, self->maxs, dir, btge_framedt, self); self->origin=org; // btge_tempSelf=NULL; if(self->flags&BT_FL_SIMPLEMOVE) return(1); return(0); #endif #if 0 //calculate desired spot dir=v3scale(btYawVector(yaw), dist); org=v3add(self->origin, dir); if(self->flags&BT_FL_FLY) { if(btCheckFlySpot(org, self->mins, self->maxs, self)) { self->origin=org; return(1); } return(0); } if(self->flags&BT_FL_SWIM) { if(btCheckSwimSpot(org, self->mins, self->maxs, self)) { self->origin=org; return(1); } return(0); } if(btCheckOnGround(org, self->mins, self->maxs, self)) { //ok, no problem self->origin=org; return(1); } if(btCheckGroundDist(org, self->mins, self->maxs, 12, self)) { //ok, but no longer on-ground (gone off a step or similar) BT_WalkmovePointAdjGround(self, org); // self->flags&=~BT_FL_ONGROUND; // self->origin=org; return(1); } org1=v3add(org, vec3(0,0,8)); if(btCheckGroundDist(org1, self->mins, self->maxs, 12, self)) { //ok, but went up a step or similar BT_WalkmovePointAdjGround(self, org1); return(1); } //can't go there return(0); #endif }
void v3normal(float *v) { v3scale(v, 1.0f/v3length(v)); }
BTSV_API void BT_BlockPlacerTouch(btEntity self, btEntity other) { BTGE_VoxelData *vox; btEntity nodmg; vec3 org; int x, y, z; int i; if(other) { if(other==self->owner)return; if(other->solidtype==BT_SOLID_NOT)return; if(other->solidtype==BT_SOLID_TRIGGER)return; i=btEntityBoxContents(other, self->absmin, self->absmax); if(!(i&BT_CONTENTS_CHECKSOLID))return; if(i&BT_CONTENTS_SKY)return; } nodmg=NULL; if(self->owner && (self->owner->flags&BT_FL_MONSTER)) { //monsters shouldn't blow themselves up with their own missiles nodmg=self->owner; } self->vt->touch=NULL; if(!nodmg)nodmg=other; if(self->state>=0) { // org=v3sub(self->origin, v3scale(self->velocity, 0.01)); org=self->origin; }else { org=v3add(self->origin, v3scale(self->velocity, 0.025)); } // x=v3x(org)/32; // y=v3y(org)/32; // z=v3z(org)/32; x=floor(v3x(org)/32); y=floor(v3y(org)/32); z=floor(v3z(org)/32); vox=BTGE_Voxel_GetWorldVoxel(btCurrentWorld(), x, y, z); if((self->state>0) && (!vox || !vox->type)) { //place block vox=BTGE_Voxel_GetWorldVoxelDirty(btCurrentWorld(), x, y, z); vox->type=self->state; btSound(self, BT_CHAN_VOICE, "sound/weapons/blkset0", 1.0, BT_ATTN_NORM); BT_EntitySmallSparksExplode(self); return; } if((self->state<0) && vox && (vox->type>0)) { //destroy block vox=BTGE_Voxel_GetWorldVoxelDirty(btCurrentWorld(), x, y, z); vox->type=0; btSound(self, BT_CHAN_VOICE, "sound/weapons/blkbrk0", 1.0, BT_ATTN_NORM); BT_EntitySmallSparksExplode(self); return; } if(self->state<0) { BT_RadiusDamage(self, self->owner, self->damage, nodmg, self->height, BT_MOD_BLASTER); btSound(self, BT_CHAN_VOICE, "sound/weapons/blkbrk0", 1.0, BT_ATTN_NORM); BT_EntitySmallSparksExplode(self); return; } // BT_Damage(other, self->owner, self->damage, BT_MOD_BLASTER); // BT_RadiusDamage(self, self->owner, self->damage, nodmg, // self->height, BT_MOD_BLASTER); // BT_EntitySparksExplode(self); }
BTSV_API vec3 btBoxStepMoveFall( vec3 org, vec3 mins, vec3 maxs, float dt, btEntity self) { vec3 org1, org2, vel; float f; int i, j; f=256*dt; vel=vec3(0, 0, -f); if(self) { // self->flags&=~BT_FL_INWATER; self->flags&=~(BT_FL_ONGROUND|BT_FL_INWATER); //flying entities don't fall if(self->flags&BT_FL_FLY) return(org); vel=v3scale(self->velocity, dt); } // f=64*dt; // f=256*dt; // org1=v3sub(org, vec3(0, 0, f)); org1=v3add(org, vel); i=btPointBoxContents(org1, mins, maxs, self); if(i&BT_CONTENTS_PLAYERSOLID) { if(self) { if(self->flags&BT_FL_CLIENT) { // printf("client impact\n"); // BT_ClientImpact(self, self->velocity); BT_ClientImpact(self, v3add(self->velocity, self->impulseVelocity)); } self->flags|=BT_FL_ONGROUND; self->velocity=vec3(0,0,0); j=btPointContents(org, self); if(j&BT_CONTENTS_FLUID) { self->flags|=BT_FL_INWATER; } } return(org); } if(self && (self->flags&BT_FL_CLIENT)) { org2=v3sub(org, vec3(0, 0, 2)); i=btPointBoxContents(org2, mins, maxs, self); if(i&BT_CONTENTS_PLAYERSOLID) { self->flags|=BT_FL_ONGROUND; } } j=btPointContents(org, self); if(j&BT_CONTENTS_FLUID) { if(self) { self->flags|=BT_FL_INWATER; //swim entities don't sink if(self->flags&BT_FL_SWIM) return(org); f=1.0-dt; if(f<0)f=0; self->velocity=v3scale(self->velocity, f); // self->velocity=vec3(0,0,0); } //reduced falling speed // f=16*dt; // org1=v3sub(org, vec3(0, 0, f)); if(!self) org1=v3addscale(org, vel, 0.25); } return(org1); }
vec3 btBoxStepMoveI(vec3 org, vec3 mins, vec3 maxs, vec3 ivel, float dt, btEntity self) { vec3 norg, org1, org2, org3; float f; int i, j; if(dt>0.5) { return(org); } if(dt>(1.0/24)) { f=dt*0.5; org1=btBoxStepMoveI(org, mins, maxs, ivel, f, self); if(self && (self->flags&BT_FL_JUMPMOVE)) return(btBoxStepMoveFall(org1, mins, maxs, f, self)); org2=btBoxStepMoveI(org1, mins, maxs, ivel, f, self); return(org2); } #if 0 if(self) { self->flags&=~(BT_FL_SIMPLEMOVE|BT_FL_OFFGROUND|BT_FL_JUMPMOVE); self->impulseVelocity=ivel; if(self->flags&BT_FL_CLIENT) { // self->flags&=~(BT_FL_ONGROUND); } } if(self && (self->flags&BT_FL_NOCLIP)) { org1=v3add(org, v3scale(ivel, dt)); return(org1); } #endif //can't move if dead if(self && (self->health<0)) { org1=btBoxStepMoveFall(org, mins, maxs, dt, self); return(org1); } org1=v3add(org, v3scale(ivel, dt)); // f=64*dt; // org2=v3sub(org1, vec3(0, 0, f)); i=btPointBoxContents(org1, mins, maxs, self); // j=btPointBoxContents(org2, mins, maxs); // if(!i) if(!(i&BT_CONTENTS_PLAYERSOLID)) { if(self)self->flags|=BT_FL_SIMPLEMOVE; org2=btBoxStepMoveFall(org1, mins, maxs, dt, self); #if 0 if(self && (self->flags&BT_FL_MONSTER) && !(self->flags&(BT_FL_ONGROUND|BT_FL_FLY|BT_FL_SWIM))) { //ok, not onground, assume walked off a ledge self->flags&=~BT_FL_SIMPLEMOVE; org2=btBoxStepMoveFall(org, mins, maxs, dt, self); } #endif #if 1 if(self && (self->flags&BT_FL_MONSTER) && !(self->flags&(BT_FL_FLY|BT_FL_SWIM))) { // j=btCheckGroundDist(org1, mins, maxs, 16, self); // j=btCheckGroundDist(org1, mins, maxs, 24, self); // j=btCheckGroundDistPts(org1, mins, maxs, 24, self); j=btCheckGroundDistPts(org1, mins, maxs, 36, self); if(!j) { printf("btBoxStepMove: %d Ledge Detect Handle\n", self->entnum); self->flags&=~BT_FL_SIMPLEMOVE; org2=btBoxStepMoveFall(org, mins, maxs, dt, self); } } #endif return(org2); } if((fabs(v3x(ivel))>fabs(v3z(ivel))) && (fabs(v3y(ivel))>fabs(v3z(ivel)))) { //assume sliding along ground org1=vec3(v3x(org1), v3y(org1), v3z(org)); i=btPointBoxContents(org1, mins, maxs, self); // if(!i)return(org1); if(!(i&BT_CONTENTS_PLAYERSOLID)) { if(self)self->flags|=BT_FL_SIMPLEMOVE; return(btBoxStepMoveFall(org1, mins, maxs, dt, self)); // return(org1); } } for(j=0; j<4; j++) { org2=vec3(v3x(org1), v3y(org1), v3z(org1)+(j+1)*4); i=btPointBoxContents(org2, mins, maxs, self); // if(!i)return(org2); if(!(i&BT_CONTENTS_PLAYERSOLID)) { if(self)self->flags|=BT_FL_SIMPLEMOVE; return(btBoxStepMoveFall(org2, mins, maxs, dt, self)); // return(org2); } } if(self && (self->flags&BT_FL_MONSTER)) { org2=vec3(v3x(org1), v3y(org1), v3z(org1)+34); i=btPointBoxContents(org2, mins, maxs, self); // if(!i)return(org2); if(!(i&BT_CONTENTS_PLAYERSOLID)) { printf("btBoxStepMove: %d Jump Move, flags=%08X\n", self->entnum, self->flags); self->flags|=BT_FL_JUMPMOVE; return(btBoxStepMoveFall(org, mins, maxs, dt, self)); } } #if 0 if(self && (self->flags&BT_FL_MONSTER) && !(self->flags&(BT_FL_FLY|BT_FL_SWIM))) { // printf("btBoxStepMove: %d Compound Move\n", // self->entnum); return(btBoxStepMoveFall(org, mins, maxs, dt, self)); } #endif org2=btBoxStepMoveSlide(org, mins, maxs, ivel, dt, org1, self); i=btPointBoxContents(org2, mins, maxs, self); // if(!i)return(org2); if(!(i&BT_CONTENTS_PLAYERSOLID)) { if(self)self->flags|=BT_FL_SIMPLEMOVE; return(btBoxStepMoveFall(org2, mins, maxs, dt, self)); } for(j=0; j<4; j++) { org2=vec3(v3x(org1), v3y(org1), v3z(org1)+(j+1)*4); // i=btPointBoxContents(org2, mins, maxs); // if(!i)return(org2); org2=btBoxStepMoveSlide(org, mins, maxs, ivel, dt, org2, self); i=btPointBoxContents(org2, mins, maxs, self); if(!(i&BT_CONTENTS_PLAYERSOLID)) { if(self)self->flags|=BT_FL_SIMPLEMOVE; return(btBoxStepMoveFall(org2, mins, maxs, dt, self)); } } return(btBoxStepMoveFall(org, mins, maxs, dt, self)); // return(org); }