Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
hzqst committed Jan 20, 2024
1 parent f74012c commit 59c89e1
Showing 1 changed file with 27 additions and 41 deletions.
68 changes: 27 additions & 41 deletions Plugins/CaptionMod/exportfuncs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -920,60 +920,46 @@ void __fastcall ScClient_SoundEngine_PlayFMODSound(void* pSoundEngine, int, int

if (g_bPlayedFMODSound)
{
if (name)
bool ignore = false;
float distance = 0;
float avol = 1;

if (flags & (SND_STOP | SND_CHANGE_VOL | SND_CHANGE_PITCH))
{
bool ignore = false;
float distance = 0;
float avol = 1;
ignore = true;
}

if (flags & (SND_STOP | SND_CHANGE_VOL | SND_CHANGE_PITCH))
{
ignore = true;
}
if (!ignore)
{
auto szLevelName = gEngfuncs.pfnGetLevelName();

if (!ignore)
if (szLevelName[0])
{
auto szLevelName = gEngfuncs.pfnGetLevelName();

if (szLevelName[0])
if (origin && !(origin[0] == 0 && origin[1] == 0 && origin[2] == 0) && attenuation > 0 && EngineGetViewEntity())
{
if (origin && !(origin[0] == 0 && origin[1] == 0 && origin[2] == 0) && attenuation > 0 && EngineGetViewEntity())
{
float vecLocalOrigin[3];
VectorCopy(EngineGetViewEntity()->origin, vecLocalOrigin);

float vecDirection[3];
VectorSubtract(origin, vecLocalOrigin, vecDirection);

distance = VectorLength(vecDirection);
float vecLocalOrigin[3];
VectorCopy(EngineGetViewEntity()->origin, vecLocalOrigin);

avol = fvol * (1.0f - distance * (attenuation / 1000.0f));
if (avol < 0)
avol = 0;
}
}
}
float vecDirection[3];
VectorSubtract(origin, vecLocalOrigin, vecDirection);

if (!ignore)
{
if (name[0] == '!' || name[0] == '#')
{
if (!ScClient_StartSentence(name, distance, avol))
{
distance = VectorLength(vecDirection);

}
ignore = true;
avol = fvol * (1.0f - distance * (attenuation / 1000.0f));
if (avol < 0)
avol = 0;
}
}
}

if (!ignore)
{
ScClient_StartWave(name, distance, avol, g_iCurrentPlayingFMODSoundLengthMs);
}
if (!ignore && !name && sentenceIndex >= 0)
{
//TODO: Sentence support
}
else

if (!ignore && name)
{
gEngfuncs.Con_DPrintf("ScClient_SoundEngine_PlayFMODSound: sentenceIndex %d\n", sentenceIndex);
ScClient_StartWave(name, distance, avol, g_iCurrentPlayingFMODSoundLengthMs);
}
}

Expand Down

0 comments on commit 59c89e1

Please sign in to comment.