mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-02-01 21:41:12 +00:00
Merged https://github.com/ZDoom/gzdoom/pull/1960 (Bounce virtual)
This commit is contained in:
parent
bf803ce2e9
commit
93bc2a3caf
4 changed files with 54 additions and 0 deletions
|
@ -842,6 +842,11 @@ public:
|
|||
// (virtual on the script side only)
|
||||
int SpecialMissileHit (AActor *victim);
|
||||
|
||||
// Called when bouncing to allow for custom behavior.
|
||||
// Returns -1 for normal behavior, 0 to stop, and 1 to keep going.
|
||||
// (virtual on the script side only)
|
||||
int SpecialBounceHit(AActor* bounceMobj, line_t* bounceLine, secplane_t* bouncePlane);
|
||||
|
||||
// Returns true if it's okay to switch target to "other" after being attacked by it.
|
||||
bool CallOkayToSwitchTarget(AActor *other);
|
||||
bool OkayToSwitchTarget (AActor *other);
|
||||
|
|
|
@ -3518,6 +3518,16 @@ bool FSlide::BounceWall(AActor *mo)
|
|||
}
|
||||
line = bestslideline;
|
||||
|
||||
if (mo->flags & MF_MISSILE)
|
||||
{
|
||||
switch (mo->SpecialBounceHit(nullptr, line, nullptr))
|
||||
{
|
||||
case 1: return true;
|
||||
case 0: return false;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
if (line->special == Line_Horizon || ((mo->BounceFlags & BOUNCE_NotOnSky) && line->hitSkyWall(mo)))
|
||||
{
|
||||
mo->SeeSound = mo->BounceSound = NO_SOUND; // it might make a sound otherwise
|
||||
|
@ -3608,6 +3618,13 @@ bool P_BounceActor(AActor *mo, AActor *BlockingMobj, bool ontop)
|
|||
case 0: return false;
|
||||
default: break;
|
||||
}
|
||||
|
||||
switch (mo->SpecialBounceHit(BlockingMobj, nullptr, nullptr))
|
||||
{
|
||||
case 1: return true;
|
||||
case 0: return false;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
//Don't go through all of this if the actor is reflective and wants things to pass through them.
|
||||
|
|
|
@ -1528,6 +1528,17 @@ void AActor::PlayBounceSound(bool onfloor)
|
|||
|
||||
bool AActor::FloorBounceMissile (secplane_t &plane)
|
||||
{
|
||||
if (flags & MF_MISSILE)
|
||||
{
|
||||
switch (SpecialBounceHit(nullptr, nullptr, &plane))
|
||||
{
|
||||
// This one is backwards for some reason...
|
||||
case 1: return false;
|
||||
case 0: return true;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
// [ZZ] if bouncing missile hits a damageable sector(plane), it dies
|
||||
if (P_ProjectileHitPlane(this, -1) && bouncecount > 0)
|
||||
{
|
||||
|
@ -3178,6 +3189,21 @@ int AActor::SpecialMissileHit (AActor *victim)
|
|||
else return -1;
|
||||
}
|
||||
|
||||
// This virtual method only exists on the script side.
|
||||
int AActor::SpecialBounceHit(AActor* bounceMobj, line_t* bounceLine, secplane_t* bouncePlane)
|
||||
{
|
||||
IFVIRTUAL(AActor, SpecialBounceHit)
|
||||
{
|
||||
VMValue params[4] = { (DObject*)this, bounceMobj, bounceLine, bouncePlane };
|
||||
VMReturn ret;
|
||||
int retval;
|
||||
ret.IntAt(&retval);
|
||||
VMCall(func, params, 4, &ret, 1);
|
||||
return retval;
|
||||
}
|
||||
else return -1;
|
||||
}
|
||||
|
||||
bool AActor::AdjustReflectionAngle (AActor *thing, DAngle &angle)
|
||||
{
|
||||
if (flags2 & MF2_DONTREFLECT) return true;
|
||||
|
|
|
@ -543,6 +543,12 @@ class Actor : Thinker native
|
|||
return -1;
|
||||
}
|
||||
|
||||
// This is called when a missile bounces off something.
|
||||
virtual int SpecialBounceHit(Actor bounceMobj, Line bounceLine, SecPlane bouncePlane)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Called when the player presses 'use' and an actor is found, except if the
|
||||
// UseSpecial flag is set. Use level.ExecuteSpecial to call action specials
|
||||
// instead.
|
||||
|
|
Loading…
Reference in a new issue