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; }
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 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; }