LTBOOL CAISenseHearAllyDeath::Update(HOBJECT hStimulus, LTFLOAT fTimeDelta)
{
	if ( !IsBody(hStimulus) ) return LTFALSE;

	CDeathScene* pDeathScene = g_pCharacterMgr->GetDeathScene(hStimulus);

	if ( !pDeathScene ) return LTFALSE;

	// Time has got to be greater than the death scene noise time but not too much greater

    if ( g_pLTServer->GetTime() > pDeathScene->GetNoiseTime() &&
         g_pLTServer->GetTime() < pDeathScene->GetNoiseTime() + 1.0f )
	{
		// Noise has to be within audible radius

        LTFLOAT fDistance = VEC_DIST(pDeathScene->GetPosition(), m_pAI->GetPosition());
        LTFLOAT fDeathSceneNoiseDistance = g_pAIButeMgr->GetSenses()->fAllyDeathNoiseDistance;
		fDeathSceneNoiseDistance *= pDeathScene->GetNoiseVolume();

		if ( fDistance < (m_fDistance + fDeathSceneNoiseDistance) )
		{
			React();

			// Record the stimulus position

			m_vStimulusPosition = pDeathScene->GetPosition();

            return LTTRUE;
		}
	}

	// Gotta check the pain noise too (using same criterion as pain noise)

    if ( g_pLTServer->GetTime() > pDeathScene->GetLastPainTime() &&
         g_pLTServer->GetTime() < pDeathScene->GetLastPainTime() + 1.0f )
	{
		// LastPain has to be within audible radius

        LTFLOAT fDistance = VEC_DIST(pDeathScene->GetPosition(), m_pAI->GetPosition());
        LTFLOAT fPainNoiseDistance = g_pAIButeMgr->GetSenses()->fAllyPainNoiseDistance;
		fPainNoiseDistance *= pDeathScene->GetLastPainVolume();

		if ( fDistance < (m_fDistance + fPainNoiseDistance) )
		{
            return LTTRUE;
		}
	}

    return LTFALSE;
}