NPC_sounds.cpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. //NPC_sounds.cpp
  2. // leave this line at the top for all NPC_xxxx.cpp files...
  3. #include "g_headers.h"
  4. #include "b_local.h"
  5. #include "Q3_Interface.h"
  6. /*
  7. void NPC_AngerSound (void)
  8. {
  9. if(NPCInfo->investigateSoundDebounceTime)
  10. return;
  11. NPCInfo->investigateSoundDebounceTime = 1;
  12. // switch((int)NPC->client->race)
  13. // {
  14. // case RACE_KLINGON:
  15. //G_Sound(NPC, G_SoundIndex(va("sound/mgtest/klingon/talk%d.wav", Q_irand(1, 4))));
  16. // break;
  17. // }
  18. }
  19. */
  20. extern void G_SpeechEvent( gentity_t *self, int event );
  21. void G_AddVoiceEvent( gentity_t *self, int event, int speakDebounceTime )
  22. {
  23. if ( !self->NPC )
  24. {
  25. return;
  26. }
  27. if ( !self->client || self->client->ps.pm_type >= PM_DEAD )
  28. {
  29. return;
  30. }
  31. if ( self->NPC->blockedSpeechDebounceTime > level.time )
  32. {
  33. return;
  34. }
  35. if ( Q3_TaskIDPending( self, TID_CHAN_VOICE ) )
  36. {
  37. return;
  38. }
  39. if ( self->client && self->client->NPC_class == CLASS_SABOTEUR )
  40. {
  41. if ( self->client->ps.powerups[PW_CLOAKED]
  42. || self->client->ps.powerups[PW_UNCLOAKING] > level.time )
  43. {//I'm cloaked (or still decloaking), so don't talk and give away my position...
  44. //don't make any combat voice noises, but still make pain and death sounds
  45. if ( (event >= EV_ANGER1 && event <= EV_VICTORY3)
  46. || (event >= EV_CHASE1 && event <= EV_SUSPICIOUS5) )
  47. {
  48. return;
  49. }
  50. if ( event >= EV_GIVEUP1 && event <= EV_SUSPICIOUS5 )
  51. {
  52. return;
  53. }
  54. }
  55. }
  56. 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) )
  57. {
  58. return;
  59. }
  60. if ( (self->NPC->scriptFlags&SCF_NO_ALERT_TALK) && (event >= EV_GIVEUP1 && event <= EV_SUSPICIOUS5) )
  61. {
  62. return;
  63. }
  64. //FIXME: Also needs to check for teammates. Don't want
  65. // everyone babbling at once
  66. //NOTE: was losing too many speech events, so we do it directly now, screw networking!
  67. //G_AddEvent( self, event, 0 );
  68. G_SpeechEvent( self, event );
  69. //won't speak again for 5 seconds (unless otherwise specified)
  70. self->NPC->blockedSpeechDebounceTime = level.time + ((speakDebounceTime==0) ? 5000 : speakDebounceTime);
  71. }
  72. void NPC_PlayConfusionSound( gentity_t *self )
  73. {
  74. if ( self->health > 0 )
  75. {
  76. if ( self->enemy ||//was mad
  77. !TIMER_Done( self, "enemyLastVisible" ) ||//saw something suspicious
  78. self->client->renderInfo.lookTarget == 0//was looking at player
  79. )
  80. {
  81. self->NPC->blockedSpeechDebounceTime = 0;//make sure we say this
  82. G_AddVoiceEvent( self, Q_irand( EV_CONFUSE2, EV_CONFUSE3 ), 2000 );
  83. }
  84. else if ( self->NPC && self->NPC->investigateDebounceTime+self->NPC->pauseTime > level.time )//was checking something out
  85. {
  86. self->NPC->blockedSpeechDebounceTime = 0;//make sure we say this
  87. G_AddVoiceEvent( self, EV_CONFUSE1, 2000 );
  88. }
  89. //G_AddVoiceEvent( self, Q_irand(EV_CONFUSE1, EV_CONFUSE3), 2000 );
  90. }
  91. //reset him to be totally unaware again
  92. TIMER_Set( self, "enemyLastVisible", 0 );
  93. self->NPC->tempBehavior = BS_DEFAULT;
  94. //self->NPC->behaviorState = BS_PATROL;
  95. G_ClearEnemy( self );//FIXME: or just self->enemy = NULL;?
  96. self->NPC->investigateCount = 0;
  97. }