new vel fixes, and sending the scope info into the new g int

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@5346 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
Rafael Barreto
2010-07-11 22:09:47 +00:00
parent 3b4b2ba506
commit acfa36e353
3 changed files with 25 additions and 25 deletions
+5 -7
View File
@@ -357,9 +357,7 @@ void c2sinfo(playerent *d) // send update to the server
dz = dzt - d->vel_t.i[2],
// pack rest in 1 int: strafe:2, move:2, onfloor:1, onladder: 1
f = (d->strafe&3) | ((d->move&3)<<2) | (((int)d->onfloor)<<4) | (((int)d->onladder)<<5) | ((d->lifesequence&1)<<6) | (((int)d->crouching)<<7),
vx = (dx*d->vel.i[0] >= 0 && dx? 1 : 0), vy = (dy*d->vel.i[1] >= 0 && dy? 1 : 0), vz = (dz*d->vel.i[2] >= 0 && dz? 1 : 0), vr = (r ? 1 : 0),
g = (vx) | (vy<<1) | (vz<<2) | (vr<<3) | (((int)d->scoping)<<4);
dx *= vx; dy *= vy; dz *= vz;
g = (dx?1:0) | ((dy?1:0)<<1) | ((dz?1:0)<<2) | ((r?1:0)<<3) | (((int)d->scoping)<<4);
d->vel_t.i[0] = dxt;
d->vel_t.i[1] = dyt;
d->vel_t.i[2] = dzt;
@@ -414,10 +412,10 @@ void c2sinfo(playerent *d) // send update to the server
putuint(q, (int)d->yaw);
putint(q, (int)d->pitch);
putuint(q, g);
if (vr) putint(q, (int)(125*d->roll/20));
if (vx) putint(q, dx);
if (vy) putint(q, dy);
if (vz) putint(q, dz);
if (r) putint(q, (int)(125*d->roll/20));
if (dx) putint(q, dx);
if (dy) putint(q, dy);
if (dz) putint(q, dz);
putuint(q, f);
}
sendpackettoserv(0, q.finalize());
+15 -13
View File
@@ -118,7 +118,7 @@ void parsepositions(ucharbuf &p)
int cn, f, g;
vec o, vel;
float yaw, pitch, roll = 0;
bool scoping;
bool scoping = false;
if(type == SV_POSC)
{
bitbuf<ucharbuf> q(p);
@@ -168,11 +168,23 @@ void parsepositions(ucharbuf &p)
if(!d || seqcolor!=(d->lifesequence&1)) continue;
vec oldpos(d->o);
float oldyaw = d->yaw, oldpitch = d->pitch;
loopi(3)
{
float dr = o.v[i] - d->o.v[i] + ( i == 2 ? d->eyeheight : 0);
if ( !dr ) d->vel.v[i] *= 0.7;
else if ( d->vel.v[i] ) d->vel.v[i] = dr * 0.1 + d->vel.v[i] * 0.9;
d->vel.v[i] += vel.v[i];
if ( i==2 && d->onfloor && d->vel.v[i] < 0 ) d->vel.v[i] = 0;
}
d->o = o;
d->o.z += d->eyeheight;
d->yaw = yaw;
d->pitch = pitch;
d->scoping = scoping;
if(d->weaponsel->type == GUN_SNIPER)
{
sniperrifle *sr = (sniperrifle *)d->weaponsel;
sr->scoped = d->scoping = scoping;
}
d->roll = roll;
d->strafe = (f&3)==3 ? -1 : f&3;
f >>= 2;
@@ -182,17 +194,7 @@ void parsepositions(ucharbuf &p)
f >>= 1;
d->onladder = f&1;
f >>= 2;
if ( d->last_pos > totalmillis )
{
loopi(3)
{
float dr = o.v[i] - d->o.v[i] + ( i == 2 ? d->eyeheight : 0);
d->vel.v[i] = dr * 0.05f + d->vel.v[i] * 0.95f + vel.v[i];
if ( i==2 && d->onfloor && d->vel.v[i] < 0 ) d->vel.v[i] = 0;
}
}
else loopi(3) d->vel.v[i] = 0.0f;
d->last_pos = totalmillis + 300;
d->last_pos = totalmillis;
updatecrouch(d, f&1);
updatepos(d);
updatelagtime(d);
+5 -5
View File
@@ -1084,7 +1084,7 @@ void sniperrifle::attackfx(const vec &from, const vec &to, int millis)
bool sniperrifle::reload()
{
bool r = weapon::reload();
if(owner==player1 && r) { scoped = false; addmsg(SV_SCOPE, "ri2", lastmillis, 0); }
if(owner==player1 && r) { scoped = false; player1->scoping = false; /*addmsg(SV_SCOPE, "ri2", lastmillis, 0);*/ }
return r;
}
@@ -1103,9 +1103,9 @@ int sniperrifle::dynspread()
}
float sniperrifle::dynrecoil() { return scoped && lastmillis - scoped_since > SCOPESETTLETIME ? info.recoil / 3 : info.recoil; }
bool sniperrifle::selectable() { return weapon::selectable() && !m_noprimary && this == owner->primweap; }
void sniperrifle::onselecting() { weapon::onselecting(); scoped = false; addmsg(SV_SCOPE, "ri2", lastmillis, 0); }
void sniperrifle::ondeselecting() { scoped = false; addmsg(SV_SCOPE, "ri2", lastmillis, 0); }
void sniperrifle::onownerdies() { scoped = false; addmsg(SV_SCOPE, "ri2", lastmillis, 0); }
void sniperrifle::onselecting() { weapon::onselecting(); scoped = false; player1->scoping = false; /*addmsg(SV_SCOPE, "ri2", lastmillis, 0);*/ }
void sniperrifle::ondeselecting() { scoped = false; player1->scoping = false; /*addmsg(SV_SCOPE, "ri2", lastmillis, 0);*/ }
void sniperrifle::onownerdies() { scoped = false; player1->scoping = false; /*addmsg(SV_SCOPE, "ri2", lastmillis, 0);*/ }
void sniperrifle::renderhudmodel() { if(!scoped) weapon::renderhudmodel(); }
void sniperrifle::renderaimhelp(bool teamwarning)
@@ -1119,7 +1119,7 @@ void sniperrifle::setscope(bool enable)
if(this == owner->weaponsel && !reloading && owner->state == CS_ALIVE)
{
if(scoped == false && enable == true) scoped_since = lastmillis;
if(player1 == owner && enable != scoped) addmsg(SV_SCOPE, "ri2", lastmillis, enable);
if(player1 == owner && enable != scoped) player1->scoping = enable /*addmsg(SV_SCOPE, "ri2", lastmillis, enable)*/;
// 2010 MAY 17 : flowtron:
// if(watching_demo) we might need to ignore some messages
// e.g. I got one where I pressed SCOPE during the auto-reload -