void BTPing::OnReceiveICMP() { double nResponseDuration = GetResponseDuration(); static double minY = 0.0, maxY = 100.0; if(nResponseDuration < minY) { minY = nResponseDuration; m_pWnd->m_OScopeCtrl.SetRange(minY, maxY, 1) ; } if(nResponseDuration > maxY) { maxY = nResponseDuration; m_pWnd->m_OScopeCtrl.SetRange(minY, maxY, 1) ; } m_pWnd->m_OScopeCtrl.AppendPoint(nResponseDuration); TCHAR wszLog[256], wszHost[256]; size_t hostlen; GetResponseAddress(wszHost, 256, &hostlen); wsprintf(wszLog, L"%d, %s, %d ms", GetResponseSequence(), wszHost, //GetResponseAddress(), GetResponseDuration()); m_pWnd->Log(wszLog); /* cout << endl << GetResponseSequence() << ". " << GetResponseDuration() << "ms" << " \t " << GetResponseAddress() << "\t" << GetResponseName() << endl << "Type: " << GetResponseType() << " Code: " << GetResponseCode() << " " << GetResponseMessage() << endl; if(GetResponseFinished()) cout << endl << "Data finshed." << endl; */ }
//----------------------------------------------------------------------------- // Purpose: Dispatches the result // Input : *response - //----------------------------------------------------------------------------- bool CAI_Expresser::SpeakDispatchResponse( AIConcept_t concept, AI_Response *result, IRecipientFilter *filter /* = NULL */ ) { char response[ 256 ]; result->GetResponse( response, sizeof( response ) ); float delay = result->GetDelay(); bool spoke = false; soundlevel_t soundlevel = result->GetSoundLevel(); if ( IsSpeaking() && concept[0] != 0 ) { DevMsg( "SpeakDispatchResponse: Entity ( %i/%s ) already speaking, forcing '%s'\n", GetOuter()->entindex(), STRING( GetOuter()->GetEntityName() ), concept ); // Tracker 15911: Can break the game if we stop an imported map placed lcs here, so only // cancel actor out of instanced scripted scenes. ywb RemoveActorFromScriptedScenes( GetOuter(), true /*instanced scenes only*/ ); GetOuter()->SentenceStop(); if ( IsRunningScriptedScene( GetOuter() ) ) { DevMsg( "SpeakDispatchResponse: Entity ( %i/%s ) refusing to speak due to scene entity, tossing '%s'\n", GetOuter()->entindex(), STRING( GetOuter()->GetEntityName() ), concept ); delete result; return false; } } switch ( result->GetType() ) { default: case RESPONSE_NONE: break; case RESPONSE_SPEAK: { if ( !result->ShouldntUseScene() ) { // This generates a fake CChoreoScene wrapping the sound.txt name spoke = SpeakAutoGeneratedScene( response, delay ); } else { float speakTime = GetResponseDuration( result ); GetOuter()->EmitSound( response ); DevMsg( "SpeakDispatchResponse: Entity ( %i/%s ) playing sound '%s'\n", GetOuter()->entindex(), STRING( GetOuter()->GetEntityName() ), response ); NoteSpeaking( speakTime, delay ); spoke = true; } } break; case RESPONSE_SENTENCE: { spoke = ( -1 != SpeakRawSentence( response, delay, VOL_NORM, soundlevel ) ) ? true : false; } break; case RESPONSE_SCENE: { spoke = SpeakRawScene( response, delay, result, filter ); } break; case RESPONSE_RESPONSE: { // This should have been recursively resolved already Assert( 0 ); } break; case RESPONSE_PRINT: { if ( g_pDeveloper->GetInt() > 0 ) { Vector vPrintPos; GetOuter()->CollisionProp()->NormalizedToWorldSpace( Vector(0.5,0.5,1.0f), &vPrintPos ); NDebugOverlay::Text( vPrintPos, response, true, 1.5 ); spoke = true; } } break; } if ( spoke ) { m_flLastTimeAcceptedSpeak = gpGlobals->curtime; if ( DebuggingSpeech() && g_pDeveloper->GetInt() > 0 && response && result->GetType() != RESPONSE_PRINT ) { Vector vPrintPos; GetOuter()->CollisionProp()->NormalizedToWorldSpace( Vector(0.5,0.5,1.0f), &vPrintPos ); NDebugOverlay::Text( vPrintPos, CFmtStr( "%s: %s", concept, response ), true, 1.5 ); } if ( result->IsApplyContextToWorld() ) { CBaseEntity *pEntity = CBaseEntity::Instance( engine->PEntityOfEntIndex( 0 ) ); if ( pEntity ) { pEntity->AddContext( result->GetContext() ); } } else { GetOuter()->AddContext( result->GetContext() ); } SetSpokeConcept( concept, result ); } else { delete result; } return spoke; }