smooth recoil, crouching
git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@1424 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
+2
-1
@@ -90,6 +90,7 @@ struct physent
|
||||
{
|
||||
vec o, vel; // origin, velocity
|
||||
float yaw, pitch, roll; // used as vec in one place
|
||||
float pitchvel;
|
||||
float maxspeed; // cubes per second, 24 for player
|
||||
int timeinair; // used for fake gravity
|
||||
float radius, eyeheight, aboveeye; // bounding box size
|
||||
@@ -99,7 +100,7 @@ struct physent
|
||||
char move, strafe;
|
||||
uchar state, type;
|
||||
|
||||
physent() : o(0, 0, 0), yaw(270), pitch(0), roll(0), maxspeed(16),
|
||||
physent() : o(0, 0, 0), yaw(270), pitch(0), roll(0), pitchvel(0), maxspeed(16),
|
||||
radius(1.1f), eyeheight(4.5f), aboveeye(0.7f),
|
||||
state(CS_ALIVE), type(ENT_PLAYER)
|
||||
{
|
||||
|
||||
@@ -67,6 +67,7 @@ struct weaponmove
|
||||
if(percent_done > 100.0f) percent_done = 100.0f;
|
||||
// f(x) = -sin(x-1.5)^3
|
||||
kick = -sinf(pow((1.5f/100.0f*percent_done)-1.5f,3));
|
||||
if(player1->crouching) kick *= 0.35f;
|
||||
}
|
||||
|
||||
if(player1->lastaction && player1->lastattackgun==player1->gunselect)
|
||||
@@ -102,6 +103,8 @@ struct weaponmove
|
||||
sway.x *= swayspeed;
|
||||
sway.y *= swayspeed;
|
||||
sway.z *= swayupspeed;
|
||||
|
||||
if(player1->crouching) sway.mul(0.35f);
|
||||
}
|
||||
|
||||
pos.x -= base.x*k_back+sway.x;
|
||||
|
||||
@@ -291,6 +291,11 @@ void moveplayer(physent *pl, int moveres, bool local, int curtime)
|
||||
d = pl->vel;
|
||||
d.mul(speed);
|
||||
|
||||
// smooth pitch
|
||||
pl->pitch += pl->pitchvel*speed;
|
||||
pl->pitchvel *= fpsfric-3;
|
||||
pl->pitchvel /= fpsfric;
|
||||
|
||||
if(floating) // just apply velocity
|
||||
{
|
||||
pl->o.add(d);
|
||||
|
||||
+8
-10
@@ -662,18 +662,16 @@ void raydamage(vec &from, vec &to, playerent *d)
|
||||
}
|
||||
}
|
||||
|
||||
VAR(testrecoil, 0, 100, 200);
|
||||
|
||||
void spreadandrecoil(vec &from, vec &to, playerent *d)
|
||||
{
|
||||
//nothing special for a knife
|
||||
if(d->gunselect==GUN_KNIFE || d->gunselect==GUN_GRENADE) return;
|
||||
if(d->gunselect==GUN_KNIFE || d->gunselect==GUN_GRENADE) return; //nothing special for a knife
|
||||
|
||||
//spread
|
||||
vec unitv;
|
||||
float dist = to.dist(from, unitv);
|
||||
float f = dist/1000;
|
||||
int spd = guns[d->gunselect].spread;
|
||||
|
||||
//recoil
|
||||
float rcl = guns[d->gunselect].recoil*-0.01f;
|
||||
|
||||
if(d->gunselect==GUN_ASSAULT)
|
||||
@@ -683,7 +681,7 @@ void spreadandrecoil(vec &from, vec &to, playerent *d)
|
||||
rcl += (rnd(8)*-0.01f);
|
||||
}
|
||||
|
||||
if((d->gunselect==GUN_SNIPER) /*&& (d->vel.x<.25f && d->vel.y<.25f)*/ && scoped)
|
||||
if((d->gunselect==GUN_SNIPER) && scoped)
|
||||
{
|
||||
spd = 1;
|
||||
rcl = rcl / 3;
|
||||
@@ -697,10 +695,10 @@ void spreadandrecoil(vec &from, vec &to, playerent *d)
|
||||
#undef RNDD
|
||||
}
|
||||
|
||||
//increase pitch for recoil
|
||||
d->vel.add(vec(unitv).mul(rcl/dist));
|
||||
|
||||
if(d->pitch<80.0f) d->pitch += guns[d->gunselect].recoil*0.05f;
|
||||
//increase pitch for recoil
|
||||
d->vel.add(vec(unitv).mul(rcl/dist).mul(d->crouching ? 0.5 : 1.0f));
|
||||
if(d->pitch < 80.0f) d->pitchvel += guns[d->gunselect].recoil*0.15f*(float)testrecoil/100.0f;
|
||||
//if(d->pitch<80.0f) d->pitch += guns[d->gunselect].recoil*0.05f;
|
||||
}
|
||||
|
||||
bool hasammo(playerent *d) // bot mod
|
||||
|
||||
Reference in New Issue
Block a user