- floatified AActor::bouncefactor and wallbouncefactor.

This commit is contained in:
Christoph Oelckers 2016-03-24 20:43:35 +01:00
parent 53ea00b9cc
commit c66ff5939d
5 changed files with 20 additions and 26 deletions

View File

@ -1240,8 +1240,8 @@ public:
// but instead tries to come closer for a melee attack. // but instead tries to come closer for a melee attack.
// This is not the same as meleerange // This is not the same as meleerange
fixed_t maxtargetrange; // any target farther away cannot be attacked fixed_t maxtargetrange; // any target farther away cannot be attacked
fixed_t bouncefactor; // Strife's grenades use 50%, Hexen's Flechettes 70. double bouncefactor; // Strife's grenades use 50%, Hexen's Flechettes 70.
fixed_t wallbouncefactor; // The bounce factor for walls can be different. double wallbouncefactor; // The bounce factor for walls can be different.
int bouncecount; // Strife's grenades only bounce twice before exploding int bouncecount; // Strife's grenades only bounce twice before exploding
double Gravity; // [GRB] Gravity factor double Gravity; // [GRB] Gravity factor
fixed_t Friction; fixed_t Friction;
@ -1482,10 +1482,6 @@ public:
{ {
return FIXED2DBL(pushfactor); return FIXED2DBL(pushfactor);
} }
double _bouncefactor() const
{
return FIXED2DBL(bouncefactor);
}
void SetZ(double newz, bool moving = true) void SetZ(double newz, bool moving = true)
{ {
__pos.z = FLOAT2FIXED(newz); __pos.z = FLOAT2FIXED(newz);

View File

@ -1141,14 +1141,12 @@ static int PatchThing (int thingy)
} }
// MBF bounce factors depend on flag combos: // MBF bounce factors depend on flag combos:
enum const double MBF_BOUNCE_NOGRAVITY = 1; // With NOGRAVITY: full momentum
{ const double MBF_BOUNCE_FLOATDROPOFF = 0.85; // With FLOAT and DROPOFF: 85%
MBF_BOUNCE_NOGRAVITY = FRACUNIT, // With NOGRAVITY: full momentum const double MBF_BOUNCE_FLOAT = 0.7; // With FLOAT alone: 70%
MBF_BOUNCE_FLOATDROPOFF = (FRACUNIT * 85) / 100,// With FLOAT and DROPOFF: 85% const double MBF_BOUNCE_DEFAULT = 0.45; // Without the above flags: 45%
MBF_BOUNCE_FLOAT = (FRACUNIT * 70) / 100,// With FLOAT alone: 70% const double MBF_BOUNCE_WALL = 0.5; // Bouncing off walls: 50%
MBF_BOUNCE_DEFAULT = (FRACUNIT * 45) / 100,// Without the above flags: 45%
MBF_BOUNCE_WALL = (FRACUNIT * 50) / 100,// Bouncing off walls: 50%
};
info->bouncefactor = ((value[0] & MF_NOGRAVITY) ? MBF_BOUNCE_NOGRAVITY info->bouncefactor = ((value[0] & MF_NOGRAVITY) ? MBF_BOUNCE_NOGRAVITY
: (value[0] & MF_FLOAT) ? (value[0] & MF_DROPOFF) ? MBF_BOUNCE_FLOATDROPOFF : (value[0] & MF_FLOAT) ? (value[0] & MF_DROPOFF) ? MBF_BOUNCE_FLOATDROPOFF
: MBF_BOUNCE_FLOAT : MBF_BOUNCE_DEFAULT); : MBF_BOUNCE_FLOAT : MBF_BOUNCE_DEFAULT);

View File

@ -3296,7 +3296,7 @@ bool FSlide::BounceWall(AActor *mo)
deltaangle >>= ANGLETOFINESHIFT; deltaangle >>= ANGLETOFINESHIFT;
movelen = fixed_t(g_sqrt(double(mo->_f_velx())*mo->_f_velx() + double(mo->_f_vely())*mo->_f_vely())); movelen = fixed_t(g_sqrt(double(mo->_f_velx())*mo->_f_velx() + double(mo->_f_vely())*mo->_f_vely()));
movelen = FixedMul(movelen, mo->wallbouncefactor); movelen = fixed_t(movelen * mo->wallbouncefactor);
FBoundingBox box(mo->_f_X(), mo->_f_Y(), mo->_f_radius()); FBoundingBox box(mo->_f_X(), mo->_f_Y(), mo->_f_radius());
if (box.BoxOnLineSide(line) == -1) if (box.BoxOnLineSide(line) == -1)
@ -3356,7 +3356,7 @@ bool P_BounceActor(AActor *mo, AActor *BlockingMobj, bool ontop)
if (!ontop) if (!ontop)
{ {
DAngle angle = BlockingMobj->AngleTo(mo) + ((pr_bounce() % 16) - 8); DAngle angle = BlockingMobj->AngleTo(mo) + ((pr_bounce() % 16) - 8);
double speed = mo->VelXYToSpeed() * FIXED2DBL(mo->wallbouncefactor); // [GZ] was 0.75, using wallbouncefactor seems more consistent double speed = mo->VelXYToSpeed() * mo->wallbouncefactor; // [GZ] was 0.75, using wallbouncefactor seems more consistent
mo->Angles.Yaw = ANGLE2DBL(angle); mo->Angles.Yaw = ANGLE2DBL(angle);
mo->VelFromAngle(speed); mo->VelFromAngle(speed);
mo->PlayBounceSound(true); mo->PlayBounceSound(true);
@ -3393,13 +3393,13 @@ bool P_BounceActor(AActor *mo, AActor *BlockingMobj, bool ontop)
} }
else else
{ {
mo->Vel.Z *= mo->_bouncefactor(); mo->Vel.Z *= mo->bouncefactor;
} }
} }
else // Don't run through this for MBF-style bounces else // Don't run through this for MBF-style bounces
{ {
// The reflected velocity keeps only about 70% of its original speed // The reflected velocity keeps only about 70% of its original speed
mo->Vel.Z = (mo->Vel.Z - 2. / dot) * mo->_bouncefactor(); mo->Vel.Z = (mo->Vel.Z - 2. / dot) * mo->bouncefactor;
} }
mo->PlayBounceSound(true); mo->PlayBounceSound(true);

View File

@ -1583,12 +1583,12 @@ bool AActor::FloorBounceMissile (secplane_t &plane)
flags &= ~MF_INBOUNCE; flags &= ~MF_INBOUNCE;
return false; return false;
} }
else Vel.Z *= _bouncefactor(); else Vel.Z *= bouncefactor;
} }
else // Don't run through this for MBF-style bounces else // Don't run through this for MBF-style bounces
{ {
// The reflected velocity keeps only about 70% of its original speed // The reflected velocity keeps only about 70% of its original speed
Vel = (Vel - plane.Normal() * dot) * _bouncefactor(); Vel = (Vel - plane.Normal() * dot) * bouncefactor;
AngleFromVel(); AngleFromVel();
} }
@ -6672,8 +6672,8 @@ void PrintMiscActorInfo(AActor *query)
for (flagi = 0; flagi <= 31; flagi++) for (flagi = 0; flagi <= 31; flagi++)
if (query->flags7 & ActorFlags7::FromInt(1<<flagi)) Printf(" %s", FLAG_NAME(1<<flagi, flags7)); if (query->flags7 & ActorFlags7::FromInt(1<<flagi)) Printf(" %s", FLAG_NAME(1<<flagi, flags7));
Printf("\nBounce flags: %x\nBounce factors: f:%f, w:%f", Printf("\nBounce flags: %x\nBounce factors: f:%f, w:%f",
query->BounceFlags.GetValue(), FIXED2DBL(query->bouncefactor), query->BounceFlags.GetValue(), query->bouncefactor,
FIXED2DBL(query->wallbouncefactor)); query->wallbouncefactor);
/*for (flagi = 0; flagi < 31; flagi++) /*for (flagi = 0; flagi < 31; flagi++)
if (query->BounceFlags & 1<<flagi) Printf(" %s", flagnamesb[flagi]);*/ if (query->BounceFlags & 1<<flagi) Printf(" %s", flagnamesb[flagi]);*/
Printf("\nRender style = %i:%s, alpha %f\nRender flags: %x", Printf("\nRender style = %i:%s, alpha %f\nRender flags: %x",

View File

@ -1132,8 +1132,8 @@ DEFINE_PROPERTY(bouncetype, S, Actor)
//========================================================================== //==========================================================================
DEFINE_PROPERTY(bouncefactor, F, Actor) DEFINE_PROPERTY(bouncefactor, F, Actor)
{ {
PROP_FIXED_PARM(id, 0); PROP_DOUBLE_PARM(id, 0);
defaults->bouncefactor = clamp<fixed_t>(id, 0, FRACUNIT); defaults->bouncefactor = clamp<double>(id, 0, 1);
} }
//========================================================================== //==========================================================================
@ -1141,8 +1141,8 @@ DEFINE_PROPERTY(bouncefactor, F, Actor)
//========================================================================== //==========================================================================
DEFINE_PROPERTY(wallbouncefactor, F, Actor) DEFINE_PROPERTY(wallbouncefactor, F, Actor)
{ {
PROP_FIXED_PARM(id, 0); PROP_DOUBLE_PARM(id, 0);
defaults->wallbouncefactor = clamp<fixed_t>(id, 0, FRACUNIT); defaults->wallbouncefactor = clamp<double>(id, 0, 1);
} }
//========================================================================== //==========================================================================