- Added bounce states. Set the BOUNCE_UseBounceState flag to use them (+USEBOUNCESTATE via

DECORATE). Then you can use:
  * Bounce
  * Bounce.Floor
  * Bounce.Ceiling
  * Bounce.Wall
  * Bounce.Actor
  * Bounce.Actor.Creature
  Partial matches work just like Pain states, so if an actor bounces off a floor and you don't
  have a Bounce.Floor state, but you do have a Bounce state, it will use the Bounce state.
  Conversely, if you only have a Bounce.Floor state but no Bounce state, then the actor will
  only enter the Bounce.Floor state when it bounces on a floor; bouncing off anything else will
  not cause it to change state.

SVN r4250 (trunk)
This commit is contained in:
Randy Heit 2013-05-04 22:52:37 +00:00
parent 8830d3a07a
commit 40f7abb8e9
5 changed files with 54 additions and 0 deletions

View file

@ -414,6 +414,7 @@ enum EBounceFlags
// for them that are not present in ZDoom, so it is necessary to identify it properly.
BOUNCE_MBF = 1<<12, // This in itself is not a valid mode, but replaces MBF's MF_BOUNCE flag.
BOUNCE_AutoOffFloorOnly = 1<<13, // like BOUNCE_AutoOff, but only on floors
BOUNCE_UseBounceState = 1<<14, // Use Bounce[.*] states
BOUNCE_TypeMask = BOUNCE_Walls | BOUNCE_Floors | BOUNCE_Ceilings | BOUNCE_Actors | BOUNCE_AutoOff | BOUNCE_HereticType | BOUNCE_MBF,
@ -1006,6 +1007,11 @@ public:
return GetClass()->ActorInfo->FindState(2, names, exact);
}
FState *FindState(int numnames, FName *names, bool exact = false) const
{
return GetClass()->ActorInfo->FindState(numnames, names, exact);
}
bool HasSpecialDeathStates () const;
};

View file

@ -181,6 +181,13 @@ xx(Idle)
xx(GenericFreezeDeath)
xx(GenericCrush)
// Bounce state names
xx(Bounce)
xx(Wall)
xx(Floor)
xx(Ceiling)
xx(Creature)
// Compatible death names for the decorate parser.
xx(XDeath)
xx(Burn)

View file

@ -2869,6 +2869,14 @@ bool FSlide::BounceWall (AActor *mo)
}
mo->velx = FixedMul(movelen, finecosine[deltaangle]);
mo->vely = FixedMul(movelen, finesine[deltaangle]);
if (mo->BounceFlags & BOUNCE_UseBounceState)
{
FState *bouncestate = mo->FindState(NAME_Bounce, NAME_Wall);
if (bouncestate != NULL)
{
mo->SetState(bouncestate);
}
}
return true;
}
@ -2906,6 +2914,22 @@ bool P_BounceActor (AActor *mo, AActor *BlockingMobj, bool ontop)
mo->velx = FixedMul (speed, finecosine[angle]);
mo->vely = FixedMul (speed, finesine[angle]);
mo->PlayBounceSound(true);
if (mo->BounceFlags & BOUNCE_UseBounceState)
{
FName names[] = { NAME_Bounce, NAME_Actor, NAME_Creature };
FState *bouncestate;
int count = 2;
if ((BlockingMobj->flags & MF_SHOOTABLE) && !(BlockingMobj->flags & MF_NOBLOOD))
{
count = 3;
}
bouncestate = mo->FindState(count, names);
if (bouncestate != NULL)
{
mo->SetState(bouncestate);
}
}
}
else
{

View file

@ -1383,6 +1383,22 @@ bool AActor::FloorBounceMissile (secplane_t &plane)
}
PlayBounceSound(true);
// Set bounce state
if (BounceFlags & BOUNCE_UseBounceState)
{
FName names[2];
FState *bouncestate;
names[0] = NAME_Bounce;
names[1] = plane.c < 0 ? NAME_Ceiling : NAME_Floor;
bouncestate = FindState(2, names);
if (bouncestate != NULL)
{
SetState(bouncestate);
}
}
if (BounceFlags & BOUNCE_MBF) // Bring it to rest below a certain speed
{
if (abs(velz) < (fixed_t)(Mass * GetGravity() / 64))

View file

@ -255,6 +255,7 @@ static FFlagDef ActorFlags[]=
DEFINE_FLAG2(BOUNCE_ExplodeOnWater, EXPLODEONWATER, AActor, BounceFlags),
DEFINE_FLAG2(BOUNCE_MBF, MBFBOUNCER, AActor, BounceFlags),
DEFINE_FLAG2(BOUNCE_AutoOffFloorOnly, BOUNCEAUTOOFFFLOORONLY, AActor, BounceFlags),
DEFINE_FLAG2(BOUNCE_UseBounceState, USEBOUNCESTATE, AActor, BounceFlags),
// Deprecated flags. Handling must be performed in HandleDeprecatedFlags
DEFINE_DEPRECATED_FLAG(FIREDAMAGE),