Better HN
topnewbestaskshowjobs
Log inSign up

JustForFun

7 karma · joined Apr 4, 2017 (9y ago) · 6 submissions

Submissions

comment 9y ago · link · parent

From AIActionAttackFromNode.cpp:

// ----------------------------------------------------------------------- // // // ROUTINE: CAIActionAttackFromNode::ValidateContextPreconditions // // PURPOSE: Return true if real-time preconditions are valid. // // ----------------------------------------------------------------------- //

bool CAIActionAttackFromNode::ValidateContextPreconditions( CAI* pAI, CAIWorldState& wsWorldStateGoal, bool bIsPlanning ) { // Intentionally do not call super::ValidateContextPreconditions(). // Firing from a node ignores range.

// AI does not have a weapon of the correct type

if (!AIWeaponUtils::HasWeaponType(pAI, GetWeaponType(), bIsPlanning)) { return false; }

// AI does not have any ammo required by this weapon type.

if ( !AIWeaponUtils::HasAmmo(pAI, GetWeaponType(), bIsPlanning ) ) { return false; }

// AI must already be at a node.

SAIWORLDSTATE_PROP* pProp = pAI->GetAIWorldState()->GetWSProp( kWSK_AtNode, pAI->m_hObject ); if( !( pProp && pProp->hWSValue ) ) { return false; } HOBJECT hNode = pProp->hWSValue;

// Node must be derived from SmartObject.

HCLASS hTest = g_pLTServer->GetClass( "AINodeSmartObject" ); HCLASS hClass = g_pLTServer->GetObjectClass( hNode ); if( !g_pLTServer->IsKindOf( hClass, hTest ) ) { return false; }

// Node must be correct type.

AINode* pNode = (AINode*)g_pLTServer->HandleToObject( pProp->hWSValue ); if( !( pNode && ( pNode->GetType() == m_pActionRecord->eNodeType ) ) ) { return false; }

// The node must be valid in terms of FOV.

if( pAI->HasTarget( kTarget_Character | kTarget_Object | kTarget_CombatOpportunity ) && pNode->IsNodeValid( pAI, pAI->GetPosition(), pAI->GetAIBlackBoard()->GetBBTargetObject(), kThreatPos_TargetPos, m_dwNodeStatus ) ) { return true; }

// Preconditions are not valid.

return false; } // ----------------------------------------------------------------------- //

comment 9y ago · link · parent

Pretty good. Extraction point is really harder from time to time.

-- JustForFun.

comment 9y ago · link · parent

Killzone 3, Shadow Of Mordor, Transformers 3: Fall Of Cybertron....

All these 3 use planning (the planner in SOM is the grand grand son of F.E.A.R.'s -- other 2 use HTN planning) for the AI.

    ;-)
-- JustForFun.

comment 9y ago · link · parent

Patch the game to 1.08 first. Then install the F.E.A.R. SDK. Then find a copy of Visual Studio 2003. Now, you can even recompile the whole game in Release, Final and Debug mode. -- JustForFun.

comment 9y ago · link · parent

The idea of reusing A* was amazing, but what it really means is that all the actions are implemented as C++ classes. This is just a consequence (of reuse A*); but in fact it's a breakthrough in terms of planning runtime. On current average machines, GOAP in F.E.A.R. builds plans in far less than 1 milli-second.

Whereas academic planners at the time were struggling with PDDL (a symbolic declarative language for describing planning domains -- i.e. problems and actions which can appear in plans), GOAP rewrites all the actions in C++. Then, no problem for procedural preconditions and postconditions, for instance: just call C++ code to check what you have to.

-- JustForFun.

comment 9y ago · link · parent

Well, actually, STALKER used GOAP as well:

https://aigamedev.com/open/interviews/stalker-alife/

Enjoy.

-- JustForFun.