mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-03-13 22:42:07 +00:00
Added flags for angle handling on bounce
Allows for keeping the current angle on bounce or modifying the pitch.
This commit is contained in:
parent
3d2f9e06ed
commit
e0394ef16a
4 changed files with 20 additions and 5 deletions
|
@ -548,6 +548,8 @@ enum ActorBounceFlag
|
|||
BOUNCE_BounceOnUnrips = 1<<16, // projectile bounces on actors with DONTRIP
|
||||
BOUNCE_NotOnSky = 1<<17, // Don't bounce on sky floors / ceilings / walls
|
||||
BOUNCE_DEH = 1<<18, // Flag was set through Dehacked.
|
||||
BOUNCE_KeepAngle = 1<<19, // Don't change yaw when bouncing off a surface.
|
||||
BOUNCE_ModifyPitch = 1<<20, // Change pitch when bouncing off a surface.
|
||||
|
||||
BOUNCE_TypeMask = BOUNCE_Walls | BOUNCE_Floors | BOUNCE_Ceilings | BOUNCE_Actors | BOUNCE_AutoOff | BOUNCE_HereticType | BOUNCE_MBF,
|
||||
|
||||
|
|
|
@ -3653,7 +3653,8 @@ bool FSlide::BounceWall(AActor *mo)
|
|||
}
|
||||
moveangle = mo->Vel.Angle();
|
||||
deltaangle = (lineangle * 2) - moveangle;
|
||||
mo->Angles.Yaw = deltaangle;
|
||||
if (!(mo->BounceFlags & BOUNCE_KeepAngle))
|
||||
mo->Angles.Yaw = deltaangle;
|
||||
|
||||
movelen = mo->Vel.XY().Length() * GetWallBounceFactor(mo);
|
||||
|
||||
|
@ -3751,8 +3752,10 @@ bool P_BounceActor(AActor *mo, AActor *BlockingMobj, bool ontop)
|
|||
DAngle angle = BlockingMobj->AngleTo(mo) + DAngle::fromDeg((pr_bounce() % 16) - 8);
|
||||
double speed = mo->VelXYToSpeed() * GetWallBounceFactor(mo); // [GZ] was 0.75, using wallbouncefactor seems more consistent
|
||||
if (fabs(speed) < EQUAL_EPSILON) speed = 0;
|
||||
mo->Angles.Yaw = angle;
|
||||
mo->VelFromAngle(speed);
|
||||
if (!(mo->BounceFlags & BOUNCE_KeepAngle))
|
||||
mo->Angles.Yaw = angle;
|
||||
mo->Vel.X = speed * angle.Cos();
|
||||
mo->Vel.Y = speed * angle.Sin();
|
||||
mo->PlayBounceSound(true, 1.0);
|
||||
}
|
||||
else
|
||||
|
@ -3781,6 +3784,9 @@ bool P_BounceActor(AActor *mo, AActor *BlockingMobj, bool ontop)
|
|||
mo->Vel *= mo->bouncefactor;
|
||||
}
|
||||
|
||||
if (mo->BounceFlags & BOUNCE_ModifyPitch)
|
||||
mo->Angles.Pitch = -VecToAngle(mo->Vel.XY().Length(), mo->Vel.Z);
|
||||
|
||||
mo->PlayBounceSound(true, 1.0);
|
||||
if (mo->BounceFlags & BOUNCE_MBF) // Bring it to rest below a certain speed
|
||||
{
|
||||
|
|
|
@ -1824,7 +1824,8 @@ bool AActor::FloorBounceMissile (secplane_t &plane, bool is3DFloor)
|
|||
if (BounceFlags & (BOUNCE_HereticType | BOUNCE_MBF))
|
||||
{
|
||||
Vel -= norm * dot;
|
||||
AngleFromVel();
|
||||
if (!(BounceFlags & BOUNCE_KeepAngle))
|
||||
AngleFromVel();
|
||||
if (!(BounceFlags & BOUNCE_MBF)) // Heretic projectiles die, MBF projectiles don't.
|
||||
{
|
||||
flags |= MF_INBOUNCE;
|
||||
|
@ -1838,9 +1839,13 @@ bool AActor::FloorBounceMissile (secplane_t &plane, bool is3DFloor)
|
|||
{
|
||||
// The reflected velocity keeps only about 70% of its original speed
|
||||
Vel = (Vel - norm * dot) * bouncefactor;
|
||||
AngleFromVel();
|
||||
if (!(BounceFlags & BOUNCE_KeepAngle))
|
||||
AngleFromVel();
|
||||
}
|
||||
|
||||
if (BounceFlags & BOUNCE_ModifyPitch)
|
||||
Angles.Pitch = -VecToAngle(Vel.XY().Length(), Vel.Z);
|
||||
|
||||
PlayBounceSound(true, 1.0);
|
||||
|
||||
// Set bounce state
|
||||
|
|
|
@ -407,6 +407,8 @@ static FFlagDef ActorFlagDefs[]=
|
|||
DEFINE_FLAG2(BOUNCE_NotOnShootables, DONTBOUNCEONSHOOTABLES, AActor, BounceFlags),
|
||||
DEFINE_FLAG2(BOUNCE_BounceOnUnrips, BOUNCEONUNRIPPABLES, AActor, BounceFlags),
|
||||
DEFINE_FLAG2(BOUNCE_NotOnSky, DONTBOUNCEONSKY, AActor, BounceFlags),
|
||||
DEFINE_FLAG2(BOUNCE_KeepAngle, KEEPBOUNCEANGLE, AActor, BounceFlags),
|
||||
DEFINE_FLAG2(BOUNCE_ModifyPitch, BOUNCEMODIFIESPITCH, AActor, BounceFlags),
|
||||
|
||||
DEFINE_FLAG2(OF_Transient, NOSAVEGAME, AActor, ObjectFlags),
|
||||
|
||||
|
|
Loading…
Reference in a new issue