codemp/game/NPC_sounds.c

Go to the documentation of this file.
00001 //NPC_sounds.cpp
00002 #include "b_local.h"
00003 #include "../icarus/Q3_Interface.h"
00004 
00005 /*
00006 void NPC_AngerSound (void)
00007 {
00008         if(NPCInfo->investigateSoundDebounceTime)
00009                 return;
00010 
00011         NPCInfo->investigateSoundDebounceTime = 1;
00012 
00013 //      switch((int)NPC->client->race)
00014 //      {
00015 //      case RACE_KLINGON:
00016                 //G_Sound(NPC, G_SoundIndex(va("sound/mgtest/klingon/talk%d.wav",       Q_irand(1, 4))));
00017 //              break;
00018 //      }
00019 }
00020 */
00021 
00022 extern void G_SpeechEvent( gentity_t *self, int event );
00023 void G_AddVoiceEvent( gentity_t *self, int event, int speakDebounceTime )
00024 {
00025         if ( !self->NPC )
00026         {
00027                 return;
00028         }
00029 
00030         if ( !self->client || self->client->ps.pm_type >= PM_DEAD )
00031         {
00032                 return;
00033         }
00034 
00035         if ( self->NPC->blockedSpeechDebounceTime > level.time )
00036         {
00037                 return;
00038         }
00039 
00040         if ( trap_ICARUS_TaskIDPending( self, TID_CHAN_VOICE ) )
00041         {
00042                 return;
00043         }
00044 
00045         
00046         if ( (self->NPC->scriptFlags&SCF_NO_COMBAT_TALK) && ( (event >= EV_ANGER1 && event <= EV_VICTORY3) || (event >= EV_CHASE1 && event <= EV_SUSPICIOUS5) ) )//(event < EV_FF_1A || event > EV_FF_3C) && (event < EV_RESPOND1 || event > EV_MISSION3) )
00047         {
00048                 return;
00049         }
00050         
00051         if ( (self->NPC->scriptFlags&SCF_NO_ALERT_TALK) && (event >= EV_GIVEUP1 && event <= EV_SUSPICIOUS5) )
00052         {
00053                 return;
00054         }
00055         //FIXME: Also needs to check for teammates. Don't want
00056         //              everyone babbling at once
00057 
00058         //NOTE: was losing too many speech events, so we do it directly now, screw networking!
00059         //G_AddEvent( self, event, 0 );
00060         G_SpeechEvent( self, event );
00061 
00062         //won't speak again for 5 seconds (unless otherwise specified)
00063         self->NPC->blockedSpeechDebounceTime = level.time + ((speakDebounceTime==0) ? 5000 : speakDebounceTime);
00064 }
00065 
00066 void NPC_PlayConfusionSound( gentity_t *self )
00067 {
00068         if ( self->health > 0 )
00069         {
00070                 if ( self->enemy ||//was mad
00071                                 !TIMER_Done( self, "enemyLastVisible" ) ||//saw something suspicious
00072                                 self->client->renderInfo.lookTarget     == 0//was looking at player
00073                         )
00074                 {
00075                         self->NPC->blockedSpeechDebounceTime = 0;//make sure we say this
00076                         G_AddVoiceEvent( self, Q_irand( EV_CONFUSE2, EV_CONFUSE3 ), 2000 );
00077                 }
00078                 else if ( self->NPC && self->NPC->investigateDebounceTime+self->NPC->pauseTime > level.time )//was checking something out
00079                 {
00080                         self->NPC->blockedSpeechDebounceTime = 0;//make sure we say this
00081                         G_AddVoiceEvent( self, EV_CONFUSE1, 2000 );
00082                 }
00083                 //G_AddVoiceEvent( self, Q_irand(EV_CONFUSE1, EV_CONFUSE3), 2000 );
00084         }
00085         //reset him to be totally unaware again
00086         TIMER_Set( self, "enemyLastVisible", 0 );
00087         self->NPC->tempBehavior = BS_DEFAULT;
00088         
00089         //self->NPC->behaviorState = BS_PATROL;
00090         G_ClearEnemy( self );//FIXME: or just self->enemy = NULL;?
00091 
00092         self->NPC->investigateCount = 0;
00093 }