Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit ec6f8c2

Browse files
committed
Added position to HDFirearm DeactivationSound and Actor AlertSound since they were missing them. I don't think the latter is ever used, but it'll play the sound at the alarm point.
Added special handling to ActivateSound so it can account for global pitch while setting its own pitch. This'll be changed to be less wonky in future Made ActiveSound and DeactivationSound move with the gun making them.
1 parent 8208208 commit ec6f8c2

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

Entities/Actor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ ADD_SCRIPT_FUNCTION_NAMES(MOSRotating, "UpdateAI")
905905
// is there.
906906
// Return value: None.
907907

908-
virtual void AlarmPoint(const Vector &alarmPoint) { if (m_AlarmTimer.GetElapsedSimTimeMS() > 50) { m_AlarmTimer.Reset(); m_LastAlarmPos = m_PointingTarget = alarmPoint; m_AlarmSound.Play(); } }
908+
virtual void AlarmPoint(const Vector &alarmPoint) { if (m_AlarmTimer.GetElapsedSimTimeMS() > 50) { m_AlarmTimer.Reset(); m_LastAlarmPos = m_PointingTarget = alarmPoint; m_AlarmSound.Play(alarmPoint); } }
909909

910910

911911
//////////////////////////////////////////////////////////////////////////////////////////

Entities/HDFirearm.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,10 @@ int HDFirearm::ReadProperty(std::string propName, Reader &reader)
177177
}
178178
else if (propName == "FireSound")
179179
reader >> m_FireSound;
180-
else if (propName == "ActiveSound")
180+
else if (propName == "ActiveSound") {
181181
reader >> m_ActiveSound;
182-
else if (propName == "DeactivationSound")
182+
m_ActiveSound.SetAffectedByGlobalPitch(false); //Active sound (i.e. weapon spinup) modifies its pitch, so it has to account for global pitch on its own.
183+
} else if (propName == "DeactivationSound")
183184
reader >> m_DeactivationSound;
184185
else if (propName == "EmptySound")
185186
reader >> m_EmptySound;
@@ -584,7 +585,7 @@ void HDFirearm::Deactivate()
584585

585586
// Play the post-fire sound
586587
if (!m_DeactivationSound.IsBeingPlayed())
587-
m_DeactivationSound.Play();
588+
m_DeactivationSound.Play(m_Pos);
588589
}
589590

590591
//////////////////////////////////////////////////////////////////////////////////////////
@@ -693,6 +694,9 @@ void HDFirearm::Update()
693694
{
694695
HeldDevice::Update();
695696

697+
if (m_ActiveSound.IsBeingPlayed()) { m_ActiveSound.SetPosition(m_Pos); }
698+
if (m_DeactivationSound.IsBeingPlayed()) { m_DeactivationSound.SetPosition(m_Pos); }
699+
696700
/////////////////////////////////
697701
// Activation/firing logic
698702

@@ -1007,13 +1011,13 @@ void HDFirearm::Update()
10071011
if (m_Activated && !m_Reloading && m_ActivationTmr.GetElapsedSimTimeMS() < m_ActivationDelay)
10081012
{
10091013
animDuration = (int)LERP(0, m_ActivationDelay, (float)(m_SpriteAnimDuration * 10), (float)m_SpriteAnimDuration, m_ActivationTmr.GetElapsedSimTimeMS());
1010-
g_AudioMan.SetSoundPitch(&m_ActiveSound, LERP(0, m_ActivationDelay, 0, 1.0, m_ActivationTmr.GetElapsedSimTimeMS()));
1014+
g_AudioMan.SetSoundPitch(&m_ActiveSound, LERP(0, m_ActivationDelay, 0, 1.0, m_ActivationTmr.GetElapsedSimTimeMS()) * g_AudioMan.GetGlobalPitch());
10111015
}
10121016
// Spin down
10131017
if ((!m_Activated || m_Reloading) && m_LastFireTmr.GetElapsedSimTimeMS() < m_DeactivationDelay)
10141018
{
10151019
animDuration = (int)LERP(0, m_DeactivationDelay, (float)m_SpriteAnimDuration, (float)(m_SpriteAnimDuration * 10), m_LastFireTmr.GetElapsedSimTimeMS());
1016-
g_AudioMan.SetSoundPitch(&m_ActiveSound, LERP(0, m_DeactivationDelay, 1.0, 0, m_LastFireTmr.GetElapsedSimTimeMS()));
1020+
g_AudioMan.SetSoundPitch(&m_ActiveSound, LERP(0, m_DeactivationDelay, 1.0, 0, m_LastFireTmr.GetElapsedSimTimeMS()) * g_AudioMan.GetGlobalPitch());
10171021
}
10181022

10191023
if (animDuration > 0 && !(m_Reloading && m_LastFireTmr.GetElapsedSimTimeMS() >= m_DeactivationDelay))

0 commit comments

Comments
 (0)