//========================================================= // IdleSound //========================================================= void CISlave::IdleSound(void) { if(RANDOM_LONG(0, 2) == 0) { SENTENCEG_PlayRndSz(ENT(pev), "SLV_IDLE", 0.85, ATTN_NORM, 0, m_voicePitch); } #if 0 int side = RANDOM_LONG( 0, 1 ) * 2 - 1; ClearBeams( ); ArmBeam( side ); UTIL_MakeAimVectors( pev->angles ); Vector vecSrc = pev->origin + gpGlobals->v_right * 2 * side; MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSrc ); WRITE_BYTE(TE_DLIGHT); WRITE_COORD(vecSrc.x); // X WRITE_COORD(vecSrc.y); // Y WRITE_COORD(vecSrc.z); // Z WRITE_BYTE( 8 ); // radius * 0.1 WRITE_BYTE( 255 ); // r WRITE_BYTE( 180 ); // g WRITE_BYTE( 96 ); // b WRITE_BYTE( 10 ); // time * 10 WRITE_BYTE( 0 ); // decay * 0.1 MESSAGE_END( ); EMIT_SOUND_DYN( ENT(pev), CHAN_WEAPON, "debris/zap1.wav", 1, ATTN_NORM, 0, 100 ); #endif }
int CAI_Expresser::SpeakRawSentence( const char *pszSentence, float delay, float volume, soundlevel_t soundlevel, CBaseEntity *pListener ) { int sentenceIndex = -1; if ( !pszSentence ) return sentenceIndex; if ( pszSentence[0] == AI_SP_SPECIFIC_SENTENCE ) { sentenceIndex = SENTENCEG_Lookup( pszSentence ); if( sentenceIndex == -1 ) { // sentence not found return -1; } CPASAttenuationFilter filter( GetOuter(), soundlevel ); CBaseEntity::EmitSentenceByIndex( filter, GetOuter()->entindex(), CHAN_VOICE, sentenceIndex, volume, soundlevel, 0, GetVoicePitch()); } else { sentenceIndex = SENTENCEG_PlayRndSz( GetOuter()->NetworkProp()->edict(), pszSentence, volume, soundlevel, 0, GetVoicePitch() ); } SpeechMsg( GetOuter(), "SpeakRawSentence( %s, %f) %f\n", pszSentence, delay, engine->SentenceLength( sentenceIndex ) ); NoteSpeaking( engine->SentenceLength( sentenceIndex ), delay ); return sentenceIndex; }
//========================================================= // ALertSound - scream //========================================================= void CISlave::AlertSound(void) { if(m_hEnemy != NULL) { SENTENCEG_PlayRndSz(ENT(pev), "SLV_ALERT", 0.85, ATTN_NORM, 0, m_voicePitch); CallForHelp("monster_alien_slave", 512, m_hEnemy, m_vecEnemyLKP); } }
//========================================================= // FIdleSpeak // ask question of nearby friend, or make statement //========================================================= int CSittingScientist :: FIdleSpeak ( void ) { // try to start a conversation, or make statement int pitch; if (!FOkToSpeak()) return FALSE; // set global min delay for next conversation CTalkMonster::g_talkWaitTime = gpGlobals->time + RANDOM_FLOAT(4.8, 5.2); pitch = GetVoicePitch(); // if there is a friend nearby to speak to, play sentence, set friend's response time, return // try to talk to any standing or sitting scientists nearby CBaseEntity *pentFriend = FindNearestFriend(FALSE); if (pentFriend && RANDOM_LONG(0,1)) { CTalkMonster *pTalkMonster = GetClassPtr((CTalkMonster *)pentFriend->pev); pTalkMonster->SetAnswerQuestion( this ); IdleHeadTurn(pentFriend->pev->origin); SENTENCEG_PlayRndSz( ENT(pev), m_szGrp[TLK_PQUESTION], 1.0, ATTN_IDLE, 0, pitch ); // set global min delay for next conversation CTalkMonster::g_talkWaitTime = gpGlobals->time + RANDOM_FLOAT(4.8, 5.2); return TRUE; } // otherwise, play an idle statement if (RANDOM_LONG(0,1)) { SENTENCEG_PlayRndSz( ENT(pev), m_szGrp[TLK_PIDLE], 1.0, ATTN_IDLE, 0, pitch ); // set global min delay for next conversation CTalkMonster::g_talkWaitTime = gpGlobals->time + RANDOM_FLOAT(4.8, 5.2); return TRUE; } // never spoke CTalkMonster::g_talkWaitTime = 0; return FALSE; }
//========================================================= // ALertSound - scream //========================================================= void CNPC_Vortigaunt::AlertSound( void ) { if ( GetEnemy() != NULL ) { SENTENCEG_PlayRndSz( edict(), "SLV_ALERT", 0.85, SNDLVL_NORM, 0, m_iVoicePitch ); Vector vecTmp = GetEnemy()->GetAbsOrigin(); CallForHelp( "monster_alien_slave", 512, GetEnemy(), vecTmp ); } }
void CMTalkMonster::PlaySentence( const char *pszSentence, float duration, float volume, float attenuation ) { if ( !pszSentence ) return; Talk ( duration ); CMTalkMonster::g_talkWaitTime = gpGlobals->time + duration + 2.0; if ( pszSentence[0] == '!' ) EMIT_SOUND_DYN( edict(), CHAN_VOICE, pszSentence, volume, attenuation, 0, GetVoicePitch()); else SENTENCEG_PlayRndSz( edict(), pszSentence, volume, attenuation, 0, GetVoicePitch() ); // If you say anything, don't greet the player - you may have already spoken to them SetBits(m_bitsSaid, bit_saidHelloPlayer); }
int UTIL_EmitGroupnameSuit(edict_t *entity, const char *groupname) { float fvol; int pitch = PITCH_NORM; int sentenceIndex = -1; fvol = suitvolume.GetFloat(); if (random->RandomInt(0,1)) pitch = random->RandomInt(0,6) + 98; // If friendlies are talking, reduce the volume of the suit if ( !g_AIFriendliesTalkSemaphore.IsAvailable( GetContainingEntity( entity ) ) ) { fvol *= 0.3; } if (fvol > 0.05) sentenceIndex = SENTENCEG_PlayRndSz(entity, groupname, fvol, SNDLVL_NORM, 0, pitch); return sentenceIndex; }
//========================================================= // IdleSound //========================================================= void CNPC_Vortigaunt::IdleSound( void ) { if ( random->RandomInt( 0, 2 ) == 0) SENTENCEG_PlayRndSz( edict(), "SLV_IDLE", 0.85, SNDLVL_NORM, 0, m_iVoicePitch); }