00001
00002 #include "b_local.h"
00003 #include "../icarus/Q3_Interface.h"
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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) ) )
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
00056
00057
00058
00059
00060 G_SpeechEvent( self, event );
00061
00062
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 ||
00071 !TIMER_Done( self, "enemyLastVisible" ) ||
00072 self->client->renderInfo.lookTarget == 0
00073 )
00074 {
00075 self->NPC->blockedSpeechDebounceTime = 0;
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 )
00079 {
00080 self->NPC->blockedSpeechDebounceTime = 0;
00081 G_AddVoiceEvent( self, EV_CONFUSE1, 2000 );
00082 }
00083
00084 }
00085
00086 TIMER_Set( self, "enemyLastVisible", 0 );
00087 self->NPC->tempBehavior = BS_DEFAULT;
00088
00089
00090 G_ClearEnemy( self );
00091
00092 self->NPC->investigateCount = 0;
00093 }