func_train: Fix the moving sound from not stopping on certain variations

of this entity
This commit is contained in:
Marco Cawthorne 2021-02-14 00:21:35 +01:00
parent 8d262c9eb2
commit d5ae0c8dfd

View file

@ -57,6 +57,8 @@ class func_train:CBaseTrigger
string m_strStopSnd; string m_strStopSnd;
void(void) func_train; void(void) func_train;
virtual void(void) SoundMove;
virtual void(void) SoundStop;
virtual void(void) AfterSpawn; virtual void(void) AfterSpawn;
virtual void(void) PathNext; virtual void(void) PathNext;
virtual void(void) PathMove; virtual void(void) PathMove;
@ -82,6 +84,26 @@ func_train::Blocked(void)
} }
} }
void
func_train::SoundMove(void)
{
if (m_strMoveSnd) {
Sound_Play(this, CHAN_VOICE, m_strMoveSnd);
}
}
void
func_train::SoundStop(void)
{
if (m_strStopSnd) {
Sound_Play(this, CHAN_BODY, m_strStopSnd);
}
if (m_strMoveSnd) {
sound(this, CHAN_VOICE, "common/null.wav", 1.0, ATTN_NORM);
}
}
void void
func_train::PathMove(void) func_train::PathMove(void)
{ {
@ -110,10 +132,7 @@ func_train::PathMove(void)
return; return;
} }
/* more stuff for the ears */ SoundMove();
if (m_strMoveSnd) {
Sound_Play(this, CHAN_VOICE, m_strMoveSnd);
}
velocity = (vecVelocity * (1 / flTravelTime)); velocity = (vecVelocity * (1 / flTravelTime));
think = PathNext; think = PathNext;
@ -134,16 +153,7 @@ func_train::PathDone(void)
if (eNode.m_strMessage) { if (eNode.m_strMessage) {
eNode.Trigger(this, TRIG_TOGGLE); eNode.Trigger(this, TRIG_TOGGLE);
} }
SoundStop();
/* stuff for the ears */
if (m_strStopSnd) {
Sound_Play(this, CHAN_BODY, m_strStopSnd);
}
/* make the loopy noise stop */
if (m_strMoveSnd) {
sound(this, CHAN_VOICE, "common/null.wav", 1.0, ATTN_NORM);
}
} }
void void
@ -175,6 +185,7 @@ func_train::PathNext(void)
/* stop until triggered again */ /* stop until triggered again */
if (targetname) if (targetname)
if (eNode.spawnflags & PC_WAIT || spawnflags & TRAIN_WAIT) { if (eNode.spawnflags & PC_WAIT || spawnflags & TRAIN_WAIT) {
SoundStop();
return; return;
} }