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;
}
Ejemplo n.º 2
0
CScanner::DetectState CScanner::UpdateDetect()
{
	CCharacter* pChar   = g_pCharacterMgr->LookForEnemy(this);
	CDeathScene* pScene = g_pCharacterMgr->LookForDeathScene(this);

	if (pChar || pScene)
	{


		// Set the focus timer if it hasn't been set...(i.e., the
		// first time we see a "situation")...

        LTBOOL bFocus = !!(GetFocusTime() > 0.0f);

		if (bFocus && !m_FocusTimer.GetDuration())
		{
			m_FocusTimer.Start(GetFocusTime());
		}
		else if (!bFocus || m_FocusTimer.Stopped())
		{
			// Only process detection once (unless it is reset
			// someplace else...)...

			if (m_bCanProcessDetection)
			{
				if (pChar)
				{
					SetLastDetectedEnemy(pChar->m_hObject);
				}
				else if (pScene)
				{
					SetLastDetectedDeathPos(pScene->GetPosition());
				}

				SendTriggerMsgToObjects(this, m_hstrSpotTarget, m_hstrSpotMessage);

                m_bCanProcessDetection = LTFALSE;
			}

			return DS_DETECTED;
		}

		return DS_FOCUSING;
	}
	else
	{
		// If the focus timer has stopped (i.e., we tried to focus on
		// a character but he moved before we detected him, stop the
		// timer (which will reset the duration)...

		if (m_FocusTimer.Stopped())
		{
			m_FocusTimer.Stop();
		}
		else
		{
			return DS_FOCUSING;
		}
	}

	return DS_CLEAR;
}