void CAISense::PostUpdate(LTFLOAT fTimeDelta) { switch ( GetClass() ) { case scStimulation: // SeeEnemy, SeeEnemyFlashlight, HearEnemyFootstep { if ( m_bIncreasedStimulation ) { m_fStimulationTime = g_pLTServer->GetTime(); } else { DecreaseStimulation(fTimeDelta); } } break; case scDelay: // SeeEnemyFootprint, HearEnemyWeaponFire, HearEnemyWeaponImpact, SeeAllyDeath, HearAllyDeath, HearEnemyDisturbance, HearAllyPain, HearAllyWeaponFire { if ( m_bReacting ) { LTFLOAT fAwarenessModifier = 0.5f + (1.5f*GetAI()->GetAwareness()); m_fReactionDelayTimer += fTimeDelta*(fAwarenessModifier); } } break; } }
void CAISenseRecorderAbstract::HandleSenses(uint32 nCycle) { AISENSE_RECORD_MAP::iterator it; for(it = m_mapSenseRecords.begin(); it != m_mapSenseRecords.end(); ++it) { AISenseRecord* pSenseRecord = it->second; AIBM_Stimulus* pAIBM_Stimulus = pSenseRecord->pAIBM_Last_Stimulus; // If pAIBM_Stimulus is NULL, this sense has never been stimulated. if(pAIBM_Stimulus == LTNULL) { continue; } // Check for senses that were not updated this cycle. // Ignore senses that were not updated this cycle because // of a delayed stimulus. if((pSenseRecord->nCycle != nCycle) && (pSenseRecord->fReactionDelayTimer == 0.f)) { // Decrease the simulation, if there is any. if(pSenseRecord->fCurStimulation > 0.f) { LTBOOL bFalseStimulation = DecreaseStimulation(pSenseRecord, 1.0f); // If not a false stimulation, do not let the state handle the sense. if(!bFalseStimulation) { continue; } // If we have hit the false stimulation limit, treat it as a real stimulation. if( pSenseRecord->cFalseStimulation >= pAIBM_Stimulus->nFalseStimulationLimit ) { pSenseRecord->cFalseStimulation = 0; pSenseRecord->fCurStimulation = pAIBM_Stimulus->rngStimulationThreshhold.GetMax(); pSenseRecord->fMaxStimulation = pAIBM_Stimulus->rngStimulationThreshhold.GetMax(); AITRACE(AIShowSenses, (m_pSensing->GetSensingObject(), "Hit FalseStimulution Limit %d of %s\n", pAIBM_Stimulus->nFalseStimulationLimit, SenseToString(pSenseRecord->eSenseType)) ); } // Treat other false stimulations as other senses, // if an optional FalseStimulusSense was specified. else if( pAIBM_Stimulus->eFalseStimulusSense != kSense_InvalidType ) { AISenseRecord* pFalseStimulationSense = GetSense( pAIBM_Stimulus->eFalseStimulusSense ); if( pFalseStimulationSense ) { pFalseStimulationSense->pAIBM_Last_Stimulus = pAIBM_Stimulus; pFalseStimulationSense->hLastStimulusSource = pSenseRecord->hLastStimulusSource; pFalseStimulationSense->vLastStimulusPos = pSenseRecord->vLastStimulusPos; pFalseStimulationSense->eLastStimulusID = pSenseRecord->eLastStimulusID; pFalseStimulationSense->fCurStimulation = pAIBM_Stimulus->rngStimulationThreshhold.GetMax(); pFalseStimulationSense->fMaxStimulation = pAIBM_Stimulus->rngStimulationThreshhold.GetMax(); pFalseStimulationSense->fLastStimulationTime = pSenseRecord->fLastStimulationTime; pFalseStimulationSense->nLastStimulusAlarmLevel = 1; pFalseStimulationSense->nCycle = nCycle; } } } } // Invalidate hiding spots if AI can already see player. if( ( pSenseRecord->eSenseType == kSense_SeeEnemy ) && IsPlayer( pSenseRecord->hLastStimulusSource ) && IsAI( m_pSensing->GetSensingObject() ) && ( pSenseRecord->fCurStimulation >= 0.5f ) ) { CPlayerObj* pPlayer = (CPlayerObj*)g_pLTServer->HandleToObject( pSenseRecord->hLastStimulusSource ); CAI* pAI = (CAI*)g_pLTServer->HandleToObject( m_pSensing->GetSensingObject() ); if( pPlayer && pAI ) { pPlayer->SetVisibleToEnemyAI( pAI, true ); } } // Check if we're fully stimulated. if(pSenseRecord->fCurStimulation >= pAIBM_Stimulus->rngStimulationThreshhold.GetMax()) { // Wait for, or increment, ReactionDelay. if(pSenseRecord->fReactionDelayTimer >= pSenseRecord->fReactionDelayTime) { m_pSensing->HandleSenseTrigger( pSenseRecord ); pSenseRecord->fReactionDelayTimer = 0.f; pSenseRecord->fReactionDelayTime = 0.f; } else pSenseRecord->fReactionDelayTimer += m_pSensing->GetSenseUpdateRate(); } } }