This commit is contained in:
Major Cooke 2023-01-21 11:35:07 -06:00
parent bf803ce2e9
commit 93bc2a3caf
4 changed files with 54 additions and 0 deletions

View file

@ -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);

View file

@ -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.

View file

@ -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;

View file

@ -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.