Allow passing sound volume to PlayBounceSound in ZScript

This commit is contained in:
nashmuhandes 2025-01-23 23:52:02 +08:00 committed by Ricardo Luís Vaz Silva
parent f239025f8e
commit 27b6cb2f72
5 changed files with 13 additions and 11 deletions

View file

@ -863,7 +863,7 @@ public:
void Howl (); void Howl ();
// plays bouncing sound // plays bouncing sound
void PlayBounceSound(bool onfloor); void PlayBounceSound(bool onfloor, double volume);
// plays pushing sound // plays pushing sound
void PlayPushSound(); void PlayPushSound();

View file

@ -3753,7 +3753,7 @@ bool P_BounceActor(AActor *mo, AActor *BlockingMobj, bool ontop)
if (fabs(speed) < EQUAL_EPSILON) speed = 0; if (fabs(speed) < EQUAL_EPSILON) speed = 0;
mo->Angles.Yaw = angle; mo->Angles.Yaw = angle;
mo->VelFromAngle(speed); mo->VelFromAngle(speed);
mo->PlayBounceSound(true); mo->PlayBounceSound(true, 1.0);
} }
else else
{ {
@ -3781,7 +3781,7 @@ bool P_BounceActor(AActor *mo, AActor *BlockingMobj, bool ontop)
mo->Vel *= mo->bouncefactor; mo->Vel *= mo->bouncefactor;
} }
mo->PlayBounceSound(true); mo->PlayBounceSound(true, 1.0);
if (mo->BounceFlags & BOUNCE_MBF) // Bring it to rest below a certain speed if (mo->BounceFlags & BOUNCE_MBF) // Bring it to rest below a certain speed
{ {
if (fabs(mo->Vel.Z) < mo->Mass * mo->GetGravity() / 64) if (fabs(mo->Vel.Z) < mo->Mass * mo->GetGravity() / 64)

View file

@ -1708,7 +1708,7 @@ DEFINE_ACTION_FUNCTION(AActor, ExplodeMissile)
} }
void AActor::PlayBounceSound(bool onfloor) void AActor::PlayBounceSound(bool onfloor, double volume)
{ {
if (!onfloor && (BounceFlags & BOUNCE_NoWallSound)) if (!onfloor && (BounceFlags & BOUNCE_NoWallSound))
{ {
@ -1717,17 +1717,18 @@ void AActor::PlayBounceSound(bool onfloor)
if (!(BounceFlags & BOUNCE_Quiet)) if (!(BounceFlags & BOUNCE_Quiet))
{ {
volume = clamp(volume, 0.0, 1.0);
if (BounceFlags & BOUNCE_UseSeeSound) if (BounceFlags & BOUNCE_UseSeeSound)
{ {
S_Sound (this, CHAN_VOICE, 0, SeeSound, 1, ATTN_IDLE); S_Sound (this, CHAN_VOICE, 0, SeeSound, (float)volume, ATTN_IDLE);
} }
else if (onfloor || !WallBounceSound.isvalid()) else if (onfloor || !WallBounceSound.isvalid())
{ {
S_Sound (this, CHAN_VOICE, 0, BounceSound, 1, ATTN_IDLE); S_Sound (this, CHAN_VOICE, 0, BounceSound, (float)volume, ATTN_IDLE);
} }
else else
{ {
S_Sound (this, CHAN_VOICE, 0, WallBounceSound, 1, ATTN_IDLE); S_Sound (this, CHAN_VOICE, 0, WallBounceSound, (float)volume, ATTN_IDLE);
} }
} }
} }
@ -1841,7 +1842,7 @@ bool AActor::FloorBounceMissile (secplane_t &plane, bool is3DFloor)
AngleFromVel(); AngleFromVel();
} }
PlayBounceSound(true); PlayBounceSound(true, 1.0);
// Set bounce state // Set bounce state
if (BounceFlags & BOUNCE_UseBounceState) if (BounceFlags & BOUNCE_UseBounceState)
@ -2321,7 +2322,7 @@ static double P_XYMovement (AActor *mo, DVector2 scroll)
// Struck a wall // Struck a wall
if (P_BounceWall (mo)) if (P_BounceWall (mo))
{ {
mo->PlayBounceSound(false); mo->PlayBounceSound(false, 1.0);
return Oldfloorz; return Oldfloorz;
} }
} }

View file

@ -1860,8 +1860,9 @@ DEFINE_ACTION_FUNCTION(AActor, PlayBounceSound)
{ {
PARAM_SELF_PROLOGUE(AActor); PARAM_SELF_PROLOGUE(AActor);
PARAM_BOOL(onFloor); PARAM_BOOL(onFloor);
PARAM_FLOAT(volume);
self->PlayBounceSound(onFloor); self->PlayBounceSound(onFloor, volume);
return 0; return 0;
} }

View file

@ -871,7 +871,7 @@ class Actor : Thinker native
native bool BounceActor(Actor blocking, bool onTop); native bool BounceActor(Actor blocking, bool onTop);
native bool BounceWall(Line l = null); native bool BounceWall(Line l = null);
native bool BouncePlane(readonly<SecPlane> plane, bool is3DFloor = false); native bool BouncePlane(readonly<SecPlane> plane, bool is3DFloor = false);
native void PlayBounceSound(bool onFloor); native void PlayBounceSound(bool onFloor, double volume = 1.0);
native bool ReflectOffActor(Actor blocking); native bool ReflectOffActor(Actor blocking);
clearscope double PitchTo(Actor target, double zOfs = 0, double targZOfs = 0, bool absolute = false) const clearscope double PitchTo(Actor target, double zOfs = 0, double targZOfs = 0, bool absolute = false) const