CAIHumanStateAttackMove::CAIHumanStateAttackMove() { m_pStrategyFollowPath = AI_FACTORY_NEW(CAIHumanStrategyFollowPath); m_pStrategyShoot = AI_FACTORY_NEW(CAIHumanStrategyShootBurst); m_eAttackMove = kAP_None; m_bTurnedAround = LTFALSE; }
void CAICentralKnowledgeMgr::Load(ILTMessage_Read *pMsg) { EnumAICentralKnowledgeType eKnowledgeType; uint32 cKnowledge; LOAD_DWORD(cKnowledge); CAICentralKnowledgeRecord* pAICentralKnowledgeRecord; for( uint32 iKnowledge=0; iKnowledge < cKnowledge; ++iKnowledge ) { LOAD_DWORD_CAST( eKnowledgeType, EnumAICentralKnowledgeType ); pAICentralKnowledgeRecord = AI_FACTORY_NEW( CAICentralKnowledgeRecord ); pAICentralKnowledgeRecord->Load(pMsg); // Some Knowledge records may have handles to objects that have transitioned // to a new level. Delete these records. if( ( !pAICentralKnowledgeRecord->m_pAI ) || ( !pAICentralKnowledgeRecord->m_pKnowledgeTarget ) ) { AI_FACTORY_DELETE( pAICentralKnowledgeRecord ); } else { m_mapCentralKnowledge.insert( AICENTRAL_KNOWLEDGE_MAP::value_type( eKnowledgeType, pAICentralKnowledgeRecord ) ); } } }
CAIHumanStateAttackProne::CAIHumanStateAttackProne() { m_pStrategyShoot = AI_FACTORY_NEW(CAIHumanStrategyShootBurst); m_fStayProneTime = 0.f; m_fLastFiredTime = 0.f; m_fHalfMinDistSqr = 0.f; }
void CAICentralKnowledgeMgr::RegisterKnowledge(EnumAICentralKnowledgeType eKnowledgeType, ILTBaseClass *pAI, ILTBaseClass *pKnowledgeTarget, LTBOOL bLinkKnowledge) { AIASSERT( pAI, LTNULL, "CAICentralKnowledgeMgr::RegisterKnowledge: Knowledge without an associated AI." ); AIASSERT( eKnowledgeType != kCK_InvalidType, pAI->m_hObject, "CAICentralKnowledgeMgr::RegisterKnowledge: Knowledge needs a valid type." ); CAICentralKnowledgeRecord* pAICentralKnowledgeRecord = AI_FACTORY_NEW( CAICentralKnowledgeRecord ); pAICentralKnowledgeRecord->m_eKnowledgeType = eKnowledgeType; pAICentralKnowledgeRecord->m_pAI = pAI; pAICentralKnowledgeRecord->m_hAI = pAI ? pAI->m_hObject : LTNULL; pAICentralKnowledgeRecord->m_pKnowledgeTarget = pKnowledgeTarget; pAICentralKnowledgeRecord->m_hKnowledgeTarget = pKnowledgeTarget ? pKnowledgeTarget->m_hObject : LTNULL; pAICentralKnowledgeRecord->m_bLinkKnowledge = bLinkKnowledge; m_mapCentralKnowledge.insert( AICENTRAL_KNOWLEDGE_MAP::value_type( eKnowledgeType, pAICentralKnowledgeRecord ) ); }
void CAIPlan::Load(ILTMessage_Read *pMsg) { int nSteps = 0; LOAD_INT(nSteps); m_lstAIPlanSteps.reserve(nSteps); for (int i = 0; i < nSteps; ++i) { CAIPlanStep* pPlanStep = AI_FACTORY_NEW( CAIPlanStep ); pPlanStep->wsWorldState.Load(pMsg); LOAD_INT_CAST(pPlanStep->eAIAction, EnumAIActionType); m_lstAIPlanSteps.push_back(pPlanStep); } LOAD_INT(m_iPlanStep); LOAD_COBJECT(m_pAI, CAI); LOAD_TIME(m_fPlanActivationTime); }
//---------------------------------------------------------------------------- // // ROUTINE: CAIHumanStateObstruct::ConstructAIClass() // // PURPOSE: Handle initialization of all variables whose value is known // at construction of the class (without the AI present) and // which are potentially not initialized later. // //---------------------------------------------------------------------------- CAIHumanStateObstruct::CAIHumanStateObstruct() { m_pStrategyFollowPath = AI_FACTORY_NEW(CAIHumanStrategyFollowPath); m_fCloseEnoughDistSqr = 0.0; }
bool CAIPlanner::BuildPlan( CAI* pAI, CAIGoalAbstract* pGoal ) { //track our performance ///CTimedSystemBlock TimingBlock(g_tsAIPlanner); // Initialize the planner. m_AStarMapPlanner.InitAStarMapPlanner( pAI ); m_AStarGoalPlanner.InitAStarGoalPlanner( pAI, &m_AStarMapPlanner, pGoal ); // Set the start of the search to -1, indicating that // the search starts from the AIGoal rather than from // an AIAction. m_AStar.SetAStarSource( (ENUM_AStarNodeID)-1 ); // Run the AStar machine to search for a valid plan // to satisfy the AIGoal. AITRACE( AIShowPlanner, ( pAI->m_hObject, "Planner starting AStar for Goal '%s'...", s_aszGoalTypes[pGoal->GetGoalType()] ) ); m_AStar.RunAStar( pAI ); // If after the search the current node is NULL, then no // valid plan was found. CAIAStarNodePlanner* pNode = (CAIAStarNodePlanner*)( m_AStar.GetAStarNodeCur() ); if( !pNode ) { AITRACE( AIShowPlanner, ( pAI->m_hObject, "No plan found." ) ); return false; } // Create a new plan. CAIPlan* pPlan = AI_FACTORY_NEW( CAIPlan ); AITRACE( AIShowPlanner, ( pAI->m_hObject, "Found plan:" ) ); // Iterate over nodes in the planner's search path, // and add them to the plan. EnumAIActionType eAction; CAIPlanStep* pPlanStep; AIPLAN_STEP_LIST::iterator itPlan = pPlan->m_lstAIPlanSteps.end(); while( pNode ) { // If the AIAction is Invalid, this is the final node. eAction = m_AStarMapPlanner.ConvertID_AStarNode2AIAction( pNode->eAStarNodeID ); if( eAction == kAct_InvalidType ) { break; } // Create a new plan step. pPlanStep = AI_FACTORY_NEW( CAIPlanStep ); // Set the AIAction for this plan step. AITRACE( AIShowPlanner, ( pAI->m_hObject, " Action: %s", s_aszActionTypes[eAction] ) ); pPlanStep->eAIAction = eAction; // Advance the plan to the next node. pNode = (CAIAStarNodePlanner*)( pNode->pAStarParent ); // Copy the world state from the node. // This is the world state that should be achieved // taking this step of the plan. pPlanStep->wsWorldState.CopyWorldState( pNode->wsWorldStateGoal ); // Add the new step to the plan. pPlan->m_lstAIPlanSteps.push_back( pPlanStep ); } // Set the new plan for the AIGoal. pGoal->SetAIPlan( pPlan ); // Successfully built a plan. return true; }