NSTalkMonster: pause CHAN_VOICE and resume when unpaused.

This commit is contained in:
Marco Cawthorne 2022-05-04 10:59:42 -07:00
parent 7d780118ae
commit ef6c200751
Signed by: eukara
GPG Key ID: C196CD8BA993248A
4 changed files with 22 additions and 2 deletions

View File

@ -19,7 +19,7 @@
which is our basic entity model.
This is a very low-level class. You're never meant to use this.
Use NSEntity as a basis for your classes
Use NSEntity as a basis for your classes.
*/
class NSIO
@ -50,11 +50,15 @@ class NSIO
virtual void(float) Save;
virtual void(string,string) Restore;
/* save game */
nonvirtual void(float, string, float) SaveFloat;
nonvirtual void(float, string, int) SaveInt;
nonvirtual void(float, string, string) SaveString;
nonvirtual void(float, string, vector) SaveVector;
nonvirtual void(float, string, bool) SaveBool;
/* load game */
nonvirtual float(string) ReadFloat;
nonvirtual int(string) ReadInt;
nonvirtual string(string) ReadString;

View File

@ -222,7 +222,8 @@ class NSMonster:NSSurfacePropEntity
void(void) NSMonster;
#ifdef SERVER
#ifdef SERVER
/* overrides */
virtual void(float) Save;
virtual void(string,string) Restore;

View File

@ -72,6 +72,8 @@ class NSTalkMonster:NSMonster
sound_t *m_pSentenceQue;
int m_iSentenceCount;
int m_iSentencePos;
float m_sndVoiceOffs;
bool m_bWasPaused;
#endif
void(void) NSTalkMonster;

View File

@ -777,6 +777,19 @@ NSTalkMonster::predraw(void)
m_flBaseTime = frame1time;
ProcessWordQue();
if (serverkeyfloat(SERVERKEY_PAUSESTATE) != 1) {
if (m_bWasPaused == true) {
soundupdate(this, CHAN_VOICE, "", 1.0, ATTN_NORM, 0, 0, -m_sndVoiceOffs);
}
m_sndVoiceOffs = getsoundtime(this, CHAN_VOICE);
m_bWasPaused = false;
} else {
if (m_bWasPaused == false) {
soundupdate(this, CHAN_VOICE, "", 0.0, ATTN_NORM, 0, 0, -m_sndVoiceOffs);
}
m_bWasPaused = true;
}
return render;
}