codemp/game/NPC_sounds.c File Reference

#include "b_local.h"
#include "../icarus/Q3_Interface.h"

Go to the source code of this file.

Functions

void G_SpeechEvent (gentity_t *self, int event)
void G_AddVoiceEvent (gentity_t *self, int event, int speakDebounceTime)
void NPC_PlayConfusionSound (gentity_t *self)


Function Documentation

void G_AddVoiceEvent gentity_t self,
int  event,
int  speakDebounceTime
 

Definition at line 23 of file NPC_sounds.c.

References gNPC_t::blockedSpeechDebounceTime, gentity_s::client, EV_ANGER1, EV_CHASE1, EV_GIVEUP1, EV_SUSPICIOUS5, G_SpeechEvent(), gentity_t, level, gentity_s::NPC, PM_DEAD, playerState_s::pm_type, gclient_s::ps, SCF_NO_ALERT_TALK, SCF_NO_COMBAT_TALK, gNPC_t::scriptFlags, TID_CHAN_VOICE, level_locals_t::time, and trap_ICARUS_TaskIDPending().

Referenced by G_SetEnemy(), Jedi_Ambush(), Jedi_PlayBlockedPushSound(), Jedi_PlayDeflectSound(), NPC_BSGM_Attack(), NPC_CheckCharmed(), NPC_ChoosePainAnimation(), NPC_GM_Pain(), NPC_Grenadier_Pain(), NPC_Grenadier_PlayConfusionSound(), NPC_HandleAIFlags(), NPC_Jedi_Pain(), NPC_Jedi_PlayConfusionSound(), NPC_PlayConfusionSound(), NPC_Respond(), NPC_Sniper_Pain(), NPC_Sniper_PlayConfusionSound(), NPC_ST_Pain(), and NPC_Surrender().

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 }

void G_SpeechEvent gentity_t self,
int  event
 

Definition at line 2082 of file g_utils.c.

References G_AddEvent(), and gentity_t.

Referenced by G_AddVoiceEvent().

02083 {
02084         G_AddEvent(self, event, 0);
02085 }

void NPC_PlayConfusionSound gentity_t self  ) 
 

Definition at line 66 of file NPC_sounds.c.

References gNPC_t::blockedSpeechDebounceTime, BS_DEFAULT, gentity_s::client, gentity_s::enemy, EV_CONFUSE1, EV_CONFUSE2, EV_CONFUSE3, G_AddVoiceEvent(), G_ClearEnemy(), gentity_t, gentity_s::health, gNPC_t::investigateCount, gNPC_t::investigateDebounceTime, level, renderInfo_s::lookTarget, gentity_s::NPC, gNPC_t::pauseTime, Q_irand(), gclient_s::renderInfo, gNPC_t::tempBehavior, level_locals_t::time, TIMER_Done(), and TIMER_Set().

Referenced by ForceTelepathyCheckDirectNPCTarget().

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 }