clamp damage roll by maxroll

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@2572 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
Lee Salzman
2008-09-13 23:00:54 +00:00
parent f990c79be3
commit dad839d9f1
2 changed files with 9 additions and 2 deletions
+2
View File
@@ -389,8 +389,10 @@ struct playerent : dynent, playerstate
void damageroll(float damage)
{
extern void clamproll(physent *pl);
float damroll = 2.0f*damage;
roll += roll>0 ? damroll : (roll<0 ? -damroll : (rnd(2) ? damroll : -damroll)); // give player a kick
clamproll(this);
}
void hitpush(int damage, const vec &dir, playerent *actor, int gun)
+7 -2
View File
@@ -243,6 +243,12 @@ VAR(recoilbackfade, 0, 100, 1000);
// moveres indicated the physics precision (which is lower for monsters and multiplayer prediction)
// local is false for multiplayer prediction
void clamproll(physent *pl)
{
if(pl->roll > maxroll) pl->roll = maxroll;
else if(pl->roll < -maxroll) pl->roll = -maxroll;
}
void moveplayer(physent *pl, int moveres, bool local, int curtime)
{
bool water = false;
@@ -457,8 +463,7 @@ void moveplayer(physent *pl, int moveres, bool local, int curtime)
else
{
pl->roll += pl->strafe*curtime/-30.0f;
if(pl->roll>maxroll) pl->roll = (float)maxroll;
if(pl->roll<-maxroll) pl->roll = (float)-maxroll;
clamproll(pl);
}
// smooth pitch