Export PlayDiveOrSurfaceSounds to ZScript and made it virtual for mods to customize the diving and surfacing sounds

This commit is contained in:
nashmuhandes 2024-08-09 03:44:46 +08:00 committed by Rachael Alexanderson
parent 95b264bdb6
commit 8043370ef1
3 changed files with 39 additions and 16 deletions

View File

@ -1411,6 +1411,7 @@ public:
bool IsMapActor();
bool SetState (FState *newstate, bool nofunction=false);
void SplashCheck();
void PlayDiveOrSurfaceSounds(int oldlevel = 0);
bool UpdateWaterLevel (bool splash=true);
bool isFast();
bool isSlow();

View File

@ -4614,6 +4614,23 @@ void AActor::SplashCheck()
return;
}
//==========================================================================
//
// AActor::PlayDiveOrSurfaceSounds
//
// Plays diving or surfacing sounds for the player
//
//==========================================================================
void AActor::PlayDiveOrSurfaceSounds(int oldlevel)
{
IFVIRTUAL(AActor, PlayDiveOrSurfaceSounds)
{
VMValue params[2] = { (DObject *)this, oldlevel };
VMCall(func, params, 2, nullptr, 0);
}
}
//==========================================================================
//
// AActor::UpdateWaterLevel
@ -4637,21 +4654,7 @@ bool AActor::UpdateWaterLevel(bool dosplash)
if (player != nullptr)
{
if (oldlevel < 3 && waterlevel == 3)
{
// Our head just went under.
S_Sound(this, CHAN_VOICE, 0, "*dive", 1, ATTN_NORM);
}
else if (oldlevel == 3 && waterlevel < 3)
{
// Our head just came up.
if (player->air_finished > Level->maptime)
{
// We hadn't run out of air yet.
S_Sound(this, CHAN_VOICE, 0, "*surface", 1, ATTN_NORM);
}
// If we were running out of air, then ResetAirSupply() will play *gasp.
}
PlayDiveOrSurfaceSounds(oldlevel);
}
return false; // we did the splash ourselves

View File

@ -1450,6 +1450,25 @@ class Actor : Thinker native
}
}
virtual void PlayDiveOrSurfaceSounds(int oldlevel)
{
if (oldlevel < 3 && WaterLevel == 3)
{
// Our head just went under.
A_StartSound("*dive", CHAN_VOICE, attenuation: ATTN_NORM);
}
else if (oldlevel == 3 && WaterLevel < 3)
{
// Our head just came up.
if (player.air_finished > Level.maptime)
{
// We hadn't run out of air yet.
A_StartSound("*surface", CHAN_VOICE, attenuation: ATTN_NORM);
}
// If we were running out of air, then ResetAirSupply() will play *gasp.
}
}
//----------------------------------------------------------------------------
//
// PROC A_CheckSkullDone