LTBOOL CAIGoalDrawWeapon::HandleDamage(const DamageStruct& damage) { super::HandleDamage( damage ); // Activate the goal. CAIHuman* pAIHuman = (CAIHuman*)m_pAI; if( pAIHuman->HasHolsterString() && !pAIHuman->GetPrimaryWeapon() ) { m_bRequiresImmediateResponse = LTTRUE; SetCurToBaseImportance(); } // HACK: for TO2 AI with grenades. else if( ( m_pAI->GetPrimaryWeaponType() == kAIWeap_Thrown ) && pAIHuman->HasHolsterString() ) { m_bRequiresImmediateResponse = LTTRUE; SetCurToBaseImportance(); } // END HACK // Always return false to allow normal damage handling. return LTFALSE; }
LTBOOL CAIGoalFollowFootprint::HandleGoalSenseTrigger(AISenseRecord* pSenseRecord) { if( super::HandleGoalSenseTrigger(pSenseRecord) ) { // Do not investigate without a weapon. CAIHuman* pAIHuman = (CAIHuman*)m_pAI; if( !( m_pAI->GetPrimaryWeapon() || pAIHuman->HasHolsterString() ) ) { return LTFALSE; } // Record whatever triggered this goal. m_vStimulusPos = pSenseRecord->vLastStimulusPos; m_fStimulationTime = pSenseRecord->fLastStimulationTime; m_pAI->Target(m_hStimulusSource); // Update the alarm level with this investigation. m_pAI->IncrementAlarmLevel( pSenseRecord->nLastStimulusAlarmLevel ); return LTTRUE; } return LTFALSE; }
AINode* CAIGoalMenace::HandleGoalAttractors() { // Do not search for attractors if AI has no weapon. CAIHuman* pAIHuman = (CAIHuman*)m_pAI; if( ( !m_pAI->GetPrimaryWeapon() ) && ( !pAIHuman->HasHolsterString() ) ) { return LTNULL; } return super::HandleGoalAttractors(); }
void CAIGoalDisappearReappearEvasive::RecalcImportance() { // If we're unarmed, disappear and reappear with a weapon. CAIHuman* pAIHuman = (CAIHuman*)m_pAI; if( ( !m_pAI->GetPrimaryWeapon() ) && ( !pAIHuman->HasHolsterString() ) && m_pAI->HasBackupHolsterString() ) { m_bForceDisappear = LTTRUE; m_fNextUpdateTime = 0.f; SetCurToBaseImportance(); } }
LTBOOL CAIGoalDrawWeapon::HandleGoalSenseTrigger(AISenseRecord* pSenseRecord) { if( super::HandleGoalSenseTrigger(pSenseRecord) ) { CAIHuman* pAIHuman = (CAIHuman*)m_pAI; if( pAIHuman->HasHolsterString() && !pAIHuman->GetPrimaryWeapon() ) { return LTTRUE; } // HACK: for TO2 AI with grenades. if( ( m_pAI->GetPrimaryWeaponType() == kAIWeap_Thrown ) && pAIHuman->HasHolsterString() ) { return LTTRUE; } // END HACK } return LTFALSE; }
void CAIGoalDisappearReappearEvasive::HandleStateDisappearReappear() { // Always reappear with a weapon. CAIHuman* pAIHuman = (CAIHuman*)m_pAI; if( ( m_pAI->GetState()->GetStateStatus() == kSStat_Moving ) && ( !m_pAI->GetPrimaryWeapon() ) && ( !pAIHuman->HasHolsterString() ) && m_pAI->HasBackupHolsterString() ) { m_pAI->SetHolsterString( m_pAI->GetBackupHolsterString() ); } super::HandleStateDisappearReappear(); }
LTBOOL CAIGoalRespondToBackup::HandleGoalSenseTrigger(AISenseRecord* pSenseRecord) { if(super::HandleGoalSenseTrigger(pSenseRecord)) { // Do not respond without a weapon. CAIHuman* pAIHuman = (CAIHuman*)m_pAI; if( !( m_pAI->GetPrimaryWeapon() || pAIHuman->HasHolsterString() ) ) { return LTFALSE; } // Reset the response counter if the enemy is actually seen. if( pSenseRecord->eSenseType == kSense_SeeEnemy ) { m_cResponses = 0; m_fCurImportance = 0.f; if( m_hNodeBackup ) { m_hNodeBackup = LTNULL; m_pAI->ResetBaseSenseFlags(); m_bRequiresUpdates = LTFALSE; } } else if( !m_pGoalMgr->IsCurGoal( this ) ) { m_hNodeBackup = pSenseRecord->hLastStimulusTarget; AINodeBackup* pNodeBackup = (AINodeBackup*)g_pLTServer->HandleToObject( m_hNodeBackup ); if( pNodeBackup ) { m_cArrivalCount = pNodeBackup->GetArrivalCount(); } m_pAI->SetCurSenseFlags( kSense_SeeEnemy | kSense_SeeDangerousProjectile | kSense_SeeCatchableProjectile ); m_bRequiresUpdates = LTTRUE; } } // Always return false. Only activate once the backup node is unlocked. return LTFALSE; }
AINode* CAIGoalAttackProp::HandleGoalAttractors() { // Check if already attacking a prop. if( m_pAI->GetState()->GetStateType() != kState_HumanAttackProp ) { CAIHuman* pAIHuman = (CAIHuman*)m_pAI; if( pAIHuman->HasHolsterString() || pAIHuman->GetPrimaryWeapon()) { AIGBM_GoalTemplate* pTemplate = g_pAIGoalButeMgr->GetTemplate( GetGoalType() ); AIASSERT(pTemplate->cAttractors > 0, m_pAI->m_hObject, "CAIGoalAbstract::HandleGoalAttractors: Goal has no attractors."); // Check if attractors are triggering activateability. AINode* pNode; for(uint32 iAttractor=0; iAttractor < pTemplate->cAttractors; ++iAttractor) { pNode = g_pAINodeMgr->FindNearestNodeInRadius(m_pAI, pTemplate->aAttractors[iAttractor], m_pAI->GetPosition(), pTemplate->fAttractorDistSqr * m_fBaseImportance, LTTRUE); if(pNode != LTNULL) { HOBJECT hObject; if ( LT_OK == FindNamedObject(pNode->GetObject(), hObject) ) { Prop* pProp = (Prop*)g_pLTServer->HandleToObject(hObject); if(pProp->GetState() != kState_PropDestroyed) { AIASSERT(pNode->GetType() == kNode_UseObject, m_pAI->m_hObject, "CAIGoalAttackProp::HandleGoalAttractors: AINode is not of type UseObject."); m_hNode = pNode->m_hObject; SetCurToBaseImportance(); return pNode; } } // Disable node if prop has been destroyed. pNode->Disable(); } } } m_hNode = LTNULL; } return LTNULL; }
LTBOOL CAIGoalDistress::HandleGoalSenseTrigger(AISenseRecord* pSenseRecord) { if( super::HandleGoalSenseTrigger(pSenseRecord) ) { // Do not distress if we are armed. CAIHuman* pAIHuman = (CAIHuman*)m_pAI; if( m_pAI->GetPrimaryWeapon() || pAIHuman->HasHolsterString() ) { return LTFALSE; } // Only distress if see a character with a dangerous weapon aimed at me. m_pAI->Target( m_hStimulusSource ); if( m_pAI->GetBrain()->TargetIsAimingAtMe() ) { return LTTRUE; } } return LTFALSE; }