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

Commit e1c0009

Browse files
committed
Various little fixes to HDFirearm PreFireSound and DeactivationSound handling, to make them behave better (especially deactivation sound, oof)
PreFireSound and DeactivationSound will now fadeout instead of stopping outright
1 parent c35842f commit e1c0009

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

Entities/HDFirearm.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ int HDFirearm::ReadProperty(const std::string_view &propName, Reader &reader) {
175175
} else if (propName == "DeactivationSound") {
176176
m_DeactivationSound = new SoundContainer;
177177
reader >> m_DeactivationSound;
178-
m_DeactivationSound->SetSoundOverlapMode(SoundContainer::SoundOverlapMode::RESTART);
179178
} else if (propName == "EmptySound") {
180179
m_EmptySound = new SoundContainer;
181180
reader >> m_EmptySound;
@@ -619,6 +618,7 @@ void HDFirearm::Activate() {
619618
HeldDevice::Activate();
620619

621620
if (!IsReloading()) {
621+
if (m_DeactivationSound && m_DeactivationSound->IsBeingPlayed()) { m_DeactivationSound->FadeOut(); }
622622
if (m_ActiveSound && !m_ActiveSound->IsBeingPlayed()) { m_ActiveSound->Play(this->m_Pos); }
623623
if (m_PreFireSound && !wasActivated && !m_PreFireSound->IsBeingPlayed()) { m_PreFireSound->Play(this->m_Pos); }
624624
}
@@ -636,9 +636,9 @@ void HDFirearm::Deactivate() {
636636
HeldDevice::Deactivate();
637637
m_FiredOnce = false;
638638

639-
if (m_PreFireSound) { m_PreFireSound->Stop(); }
639+
if (m_PreFireSound) { m_PreFireSound->FadeOut(); }
640640
if (m_FireSound && m_FireSound->GetLoopSetting() == -1) { m_FireSound->Stop(); }
641-
if (m_DeactivationSound && wasActivated && m_pMagazine && !m_pMagazine->IsEmpty()) { m_DeactivationSound->Play(m_Pos); }
641+
if (m_DeactivationSound && wasActivated && m_FiredLastFrame) { m_DeactivationSound->Play(m_Pos); }
642642
}
643643

644644
//////////////////////////////////////////////////////////////////////////////////////////
@@ -683,7 +683,10 @@ void HDFirearm::Reload()
683683

684684
// Stop any activation
685685
m_Activated = false;
686-
if (m_FireSound && m_FireSound->GetLoopSetting() == -1 && m_FireSound->IsBeingPlayed()) { m_FireSound->Stop(); }
686+
if (m_FireSound && m_FireSound->IsBeingPlayed()) {
687+
if (m_FireSound->GetLoopSetting() == -1) { m_FireSound->Stop(); }
688+
if (m_DeactivationSound) { m_DeactivationSound->Play(); }
689+
}
687690
if (m_ReloadStartSound) { m_ReloadStartSound->Play(m_Pos); }
688691

689692
m_ReloadTmr.Reset();
@@ -955,11 +958,9 @@ void HDFirearm::Update()
955958
// Do stuff to deactivate after being activated
956959
if (!m_Activated)
957960
{
958-
if (m_AlreadyClicked && m_FiredLastFrame && m_DeactivationSound) { m_DeactivationSound->Play(m_Pos); }
959961
// Reset the click indicator.
960962
m_AlreadyClicked = false;
961963

962-
if (m_PreFireSound) { m_PreFireSound->Stop(); }
963964
// Stop any looping activation sounds
964965
if (m_FireSound && m_FireSound->GetLoopSetting() == -1)// && m_FireSound->IsBeingPlayed())
965966
m_FireSound->Stop();

0 commit comments

Comments
 (0)