本文整理汇总了C++中CAI_Node类的典型用法代码示例。如果您正苦于以下问题:C++ CAI_Node类的具体用法?C++ CAI_Node怎么用?C++ CAI_Node使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CAI_Node类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateNodes
//=========================================================
// Crea un jefe.
//=========================================================
void CDirector_Manager::SpawnBoss()
{
// Actualizamos los nodos candidatos para la creación.
UpdateNodes();
// ¡No hay nodos!
if ( SpawnNodes.Count() <= 0 )
return;
for ( int i = 0; i < MAX_TRIES; ++i )
{
// Seleccionamos un nodo candidato al azar.
CAI_Node *pNode = GetRandomNode();
// El nodo no existe.
if ( !pNode )
continue;
// Obtenemos la ubicación del nodo.
Vector vecOrigin = pNode->GetPosition(HULL_MEDIUM_TALL);
bool bSpawn = AddBoss(vecOrigin);
// El hijo no se ha podido crear.
if ( !bSpawn )
continue;
return;
}
// No se pudo crear al Jefe, intentarlo en otro momento.
Director()->BossPendient = true;
}
示例2: GetNavigator
void CASW_Alien_Jumper::LockJumpNode( void )
{
if ( HasSpawnFlags( SF_ANTLION_USE_GROUNDCHECKS ) == false )
return;
if ( GetNavigator()->GetPath() == NULL )
return;
if ( asw_test_new_alien_jump.GetBool() == false )
return;
AI_Waypoint_t *pWaypoint = GetNavigator()->GetPath()->GetCurWaypoint();
while ( pWaypoint )
{
AI_Waypoint_t *pNextWaypoint = pWaypoint->GetNext();
if ( pNextWaypoint && pNextWaypoint->NavType() == NAV_JUMP && pWaypoint->iNodeID != NO_NODE )
{
CAI_Node *pNode = GetNavigator()->GetNetwork()->GetNode( pWaypoint->iNodeID );
if ( pNode )
{
//NDebugOverlay::Box( pNode->GetOrigin(), Vector( -16, -16, -16 ), Vector( 16, 16, 16 ), 255, 0, 0, 0, 2 );
pNode->Lock( 0.5f );
break;
}
}
else
{
pWaypoint = pWaypoint->GetNext();
}
}
}
示例3: FindPickerAINode
//-----------------------------------------------------------------------------
// Purpose: For destroying nodes in wc edit mode
// Input :
// Output :
//-----------------------------------------------------------------------------
void NWCEdit::DestroyAINode( CBasePlayer *pPlayer )
{
// -------------------------------------------------------------
// Check that WC is running with the right map version
// -------------------------------------------------------------
if (!IsWCVersionValid())
{
return;
}
if (!pPlayer)
{
return;
}
NodeType_e nNodeType = NODE_GROUND;
if (g_pAINetworkManager->GetEditOps()->m_bAirEditMode)
{
nNodeType = NODE_AIR;
}
CAI_Node* pAINode = FindPickerAINode(pPlayer, nNodeType);
if (pAINode)
{
int status = Editor_DeleteNode(g_pAINetworkManager->GetEditOps()->m_pNodeIndexTable[pAINode->GetId()], false);
if (status == Editor_BadCommand)
{
Msg( "Worldcraft failed on deletion...\n" );
}
else if (status == Editor_OK)
{
// Mark this node as deleted and changed
pAINode->SetType( NODE_DELETED );
pAINode->m_eNodeInfo |= bits_NODE_WC_CHANGED;
// Note that network needs to be rebuild
g_pAINetworkManager->GetEditOps()->SetRebuildFlags();
g_pAINetworkManager->GetEditOps()->m_pLastDeletedNode = pAINode;
// Now go through at delete any dynamic links that were attached to this node
for (int link = 0; link < pAINode->NumLinks(); link++)
{
int nSrcID = pAINode->GetLinkByIndex(link)->m_iSrcID;
int nDstID = pAINode->GetLinkByIndex(link)->m_iDestID;
if (CAI_DynamicLink::GetDynamicLink(nSrcID, nDstID))
{
int nWCSrcID = g_pAINetworkManager->GetEditOps()->m_pNodeIndexTable[nSrcID];
int nWCDstID = g_pAINetworkManager->GetEditOps()->m_pNodeIndexTable[nDstID];
int status = Editor_DeleteNodeLink(nWCSrcID, nWCDstID);
if (status == Editor_BadCommand)
{
Msg( "Worldcraft failed on node link deletion...\n" );
}
}
}
}
}
}
示例4: ComputeWaypointType
//-----------------------------------------------------------------------------
// Computes the link type
//-----------------------------------------------------------------------------
Navigation_t CAI_Pathfinder::ComputeWaypointType( CAI_Node **ppNodes, int parentID, int destID )
{
Navigation_t navType = NAV_NONE;
CAI_Node *pNode = ppNodes[parentID];
for (int link=0; link < pNode->NumLinks();link++)
{
if (pNode->GetLinkByIndex(link)->DestNodeID(parentID) == destID)
{
// BRJ 10/1/02
// FIXME: pNPC->CapabilitiesGet() is actually the mechanism by which fliers
// filter out the bitfields in the waypoint type (most importantly, bits_MOVE_CAP_GROUND)
// that would cause the waypoint distance to be computed in a 2D, as opposed to 3D fashion
// This is a super-scary weak link if you ask me.
int linkMoveTypeBits = pNode->GetLinkByIndex(link)->m_iAcceptedMoveTypes[GetHullType()];
int moveTypeBits = ( linkMoveTypeBits & CapabilitiesGet());
if ( !moveTypeBits && linkMoveTypeBits == bits_CAP_MOVE_JUMP )
{
Assert( pNode->GetHint() && pNode->GetHint()->HintType() == HINT_JUMP_OVERRIDE );
ppNodes[destID]->Lock(0.3);
moveTypeBits = linkMoveTypeBits;
}
Navigation_t linkType = MoveBitsToNavType( moveTypeBits );
// This will only trigger if the links disagree about their nav type
Assert( (navType == NAV_NONE) || (navType == linkType) );
navType = linkType;
break;
}
}
// @TODO (toml 10-15-02): one would not expect to come out of the above logic
// with NAV_NONE. However, if a graph is newly built, it can contain malformed
// links that are referred to by the destination node, not the source node.
// This has to be fixed
if ( navType == NAV_NONE )
{
pNode = ppNodes[destID];
for (int link=0; link < pNode->NumLinks();link++)
{
if (pNode->GetLinkByIndex(link)->DestNodeID(parentID) == destID)
{
int npcMoveBits = CapabilitiesGet();
int nodeMoveBits = pNode->GetLinkByIndex(link)->m_iAcceptedMoveTypes[GetHullType()];
int moveTypeBits = ( npcMoveBits & nodeMoveBits );
Navigation_t linkType = MoveBitsToNavType( moveTypeBits );
Assert( (navType == NAV_NONE) || (navType == linkType) );
navType = linkType;
DevMsg( "Note: Strange link found between nodes in AI node graph\n" );
break;
}
}
}
AssertMsg( navType != NAV_NONE, "Pathfinder appears to have output a path with consecutive nodes thate are not actually connected\n" );
return navType;
}
示例5: Assert
void CAI_DynamicLinkController::GenerateLinksFromVolume()
{
Assert( m_ControlledLinks.Count() == 0 );
int nNodes = g_pBigAINet->NumNodes();
CAI_Node **ppNodes = g_pBigAINet->AccessNodes();
const float MinDistCareSq = Square(MAX_NODE_LINK_DIST + 0.1);
const Vector &origin = WorldSpaceCenter();
Vector vAbsMins, vAbsMaxs;
CollisionProp()->WorldSpaceAABB( &vAbsMins, &vAbsMaxs );
vAbsMins -= Vector( 1, 1, 1 );
vAbsMaxs += Vector( 1, 1, 1 );
for ( int i = 0; i < nNodes; i++ )
{
CAI_Node *pNode = ppNodes[i];
const Vector &nodeOrigin = pNode->GetOrigin();
if ( origin.DistToSqr(nodeOrigin) < MinDistCareSq )
{
int nLinks = pNode->NumLinks();
for ( int j = 0; j < nLinks; j++ )
{
CAI_Link *pLink = pNode->GetLinkByIndex( j );
int iLinkDest = pLink->DestNodeID( i );
if ( iLinkDest > i )
{
const Vector &originOther = ppNodes[iLinkDest]->GetOrigin();
if ( origin.DistToSqr(originOther) < MinDistCareSq )
{
if ( IsBoxIntersectingRay( vAbsMins, vAbsMaxs, nodeOrigin, originOther - nodeOrigin ) )
{
Assert( IsBoxIntersectingRay( vAbsMins, vAbsMaxs, originOther, nodeOrigin - originOther ) );
CAI_DynamicLink *pLink = (CAI_DynamicLink *)CreateEntityByName( "info_node_link" );
pLink->m_nSrcID = i;
pLink->m_nDestID = iLinkDest;
pLink->m_nSrcEditID = g_pAINetworkManager->GetEditOps()->GetWCIdFromNodeId( pLink->m_nSrcID );
pLink->m_nDestEditID = g_pAINetworkManager->GetEditOps()->GetWCIdFromNodeId( pLink->m_nDestID );
pLink->m_nLinkState = m_nLinkState;
pLink->m_strAllowUse = m_strAllowUse;
pLink->m_bFixedUpIds = true;
pLink->m_bNotSaved = true;
pLink->Spawn();
m_ControlledLinks.AddToTail( pLink );
}
}
}
}
}
}
}
示例6: VPROF_BUDGET
void CAI_RadialLinkController::ModifyNodeLinks( bool bMakeStale )
{
int nNodes = g_pBigAINet->NumNodes();
CAI_Node **ppNodes = g_pBigAINet->AccessNodes();
VPROF_BUDGET("ModifyLinks", "ModifyLinks");
const float MinDistCareSq = Square( ai_radial_max_link_dist.GetFloat() + 0.1 );
for ( int i = 0; i < nNodes; i++ )
{
CAI_Node *pNode = ppNodes[i];
const Vector &nodeOrigin = pNode->GetOrigin();
if ( m_vecAtRestOrigin.DistToSqr(nodeOrigin) < MinDistCareSq )
{
int nLinks = pNode->NumLinks();
for ( int j = 0; j < nLinks; j++ )
{
CAI_Link *pLink = pNode->GetLinkByIndex( j );
int iLinkDest = pLink->DestNodeID( i );
if ( iLinkDest > i )
{
bool bQualify = true;
if( ( (pLink->m_iAcceptedMoveTypes[HULL_HUMAN]||pLink->m_iAcceptedMoveTypes[HULL_WIDE_HUMAN]) & bits_CAP_MOVE_GROUND) == 0 )
{
// Micro-optimization: Ignore any connection that's not a walking connection for humans.(sjb)
bQualify = false;
}
const Vector &originOther = ppNodes[iLinkDest]->GetOrigin();
if ( bQualify && m_vecAtRestOrigin.DistToSqr(originOther) < MinDistCareSq )
{
if ( IsRayIntersectingSphere(nodeOrigin, originOther - nodeOrigin, m_vecAtRestOrigin, m_flRadius) )
{
if( bMakeStale )
{
pLink->m_LinkInfo |= bits_LINK_STALE_SUGGESTED;
pLink->m_timeStaleExpires = FLT_MAX;
}
else
{
pLink->m_LinkInfo &= ~bits_LINK_STALE_SUGGESTED;
}
}
}
}
}
}
}
}
示例7: GetOuter
void CAI_StandoffBehavior::UnlockHintNode()
{
CAI_Hint *pHintNode = GetOuter()->m_pHintNode;
if ( pHintNode )
{
if ( pHintNode->IsLocked() && pHintNode->IsLockedBy( GetOuter() ) )
pHintNode->Unlock();
CAI_Node *pNode = pHintNode->GetNode();
if ( pNode && pNode->IsLocked() )
pNode->Unlock();
GetOuter()->m_pHintNode = NULL;
}
}
示例8: while
//=========================================================
// Verificaciones después de crear al NPC.
//=========================================================
bool CDirector_Manager::PostSpawn(CAI_BaseNPC *pNPC)
{
bool bStuck = true;
while ( bStuck )
{
trace_t tr;
UTIL_TraceHull(pNPC->GetAbsOrigin(), pNPC->GetAbsOrigin(), pNPC->WorldAlignMins(), pNPC->WorldAlignMaxs(), MASK_NPCSOLID, pNPC, COLLISION_GROUP_NONE, &tr);
if ( tr.fraction != 1.0 && tr.m_pEnt )
{
// Nos hemos atorado en un objeto con fisicas.
if ( FClassnameIs(tr.m_pEnt, "prop_physics") )
{
// Lo ajustamos como "No solido" para que el bucle lo ignore.
tr.m_pEnt->AddSolidFlags(FSOLID_NOT_SOLID);
// Removemos el objeto.
UTIL_RemoveImmediate(tr.m_pEnt);
continue;
}
// Nos hemos atorado con una pared o algo del mundo.
if ( tr.m_pEnt->IsWorld() )
{
// No... no podemos eliminar una pared...
// Removemos el NPC para evitar eventos sobrenaturales.
UTIL_RemoveImmediate(pNPC);
return false;
}
// No es un objeto con físicas ni del mundo.
// Intentamos encontrar una nueva ubicación para el hijo.
//DevMsg("[MANAGER] <%s> STUCK!!!! \r\n", tr.m_pEnt->GetClassname());
CAI_Node *pNode = GetRandomNode();
// Nada
if ( !pNode )
UTIL_RemoveImmediate(pNPC);
pNPC->SetAbsOrigin(pNode->GetPosition(HULL_HUMAN));
}
bStuck = false;
}
return true;
}
示例9: FixupTargetNode
void CAI_Hint::OnRestore()
{
BaseClass::OnRestore();
m_NodeData.nNodeID = g_pAINetworkManager->GetEditOps()->GetNodeIdFromWCId( m_NodeData.nWCNodeID );
FixupTargetNode();
CAI_Node *pNode = GetNode();
if ( !pNode )
{
if ( m_NodeData.nWCNodeID > 0 )
DevMsg("Warning: AI hint has incorrect or no AI node\n");
}
else
{
m_NodeData.vecPosition = pNode->GetOrigin();
Teleport( &m_NodeData.vecPosition, NULL, NULL );
pNode->SetHint( this );
}
}
示例10:
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
CAI_Link *CAI_DynamicLink::FindLink()
{
CAI_Node * pSrcNode = g_pBigAINet->GetNode(m_nSrcID, false);
if ( pSrcNode )
{
int numLinks = pSrcNode->NumLinks();
for (int i=0;i<numLinks;i++)
{
CAI_Link* pLink = pSrcNode->GetLinkByIndex(i);
if (((pLink->m_iSrcID == m_nSrcID )&&
(pLink->m_iDestID == m_nDestID)) ||
((pLink->m_iSrcID == m_nDestID)&&
(pLink->m_iDestID == m_nSrcID )) )
{
return pLink;
}
}
}
return NULL;
}
示例11: PrespawnAlienAtRandomNode
void CASW_Spawn_Manager::PrespawnAlienAtRandomNode(const char *szAlienClass, const int iNumAliens, const int iHull, const Vector &playerStartPos, const int iNumNodes)
{
for (int i = 0; i < iNumAliens; ++i)
{
CAI_Node *pNode = NULL;
for (int k = 0; k < 30; ++k)
{
int node_id = RandomInt(0, iNumNodes - 1);
pNode = g_pBigAINet->GetNode(node_id);
if (!pNode || pNode->GetType() != NODE_GROUND)
continue;
else if (pNode->GetOrigin().DistToSqr(playerStartPos) < 1000 * 1000)
{
continue;
}
if (ValidSpawnPoint(pNode->GetPosition(iHull), NAI_Hull::Mins(iHull), NAI_Hull::Maxs(iHull), true, false))
{
// Raise the end position a little up off the floor, place the npc and drop him down
CBaseEntity *pAlien = SpawnAlienAt(szAlienClass, pNode->GetPosition(iHull) + Vector(0.f, 0.f, 12.f), RandomAngle(0, 360));
IASW_Spawnable_NPC *pSpawnable = dynamic_cast<IASW_Spawnable_NPC*>(pAlien);
if (pSpawnable)
{
pSpawnable->SetAlienOrders(AOT_SpreadThenHibernate, vec3_origin, NULL);
}
if (asw_director_debug.GetBool() && pAlien)
{
Msg("Spawned alien at %f %f %f\n", pAlien->GetAbsOrigin());
NDebugOverlay::Cross3D(pAlien->GetAbsOrigin(), 8.0f, 255, 0, 0, true, 20.0f);
}
if (pAlien)
break;
}
}
}
}
示例12: UpdateCandidateNodes
bool CASW_Spawn_Manager::FindHordePosition()
{
// need to find a suitable place from which to spawn a horde
// this place should:
// - be far enough away from the marines so the whole horde can spawn before the marines get there
// - should have a clear path to the marines
UpdateCandidateNodes();
// decide if the horde is going to come from behind or in front
bool bNorth = RandomFloat() < 0.7f;
if ( m_northCandidateNodes.Count() <= 0 )
{
bNorth = false;
}
else if ( m_southCandidateNodes.Count() <= 0 )
{
bNorth = true;
}
CUtlVector<int> &candidateNodes = bNorth ? m_northCandidateNodes : m_southCandidateNodes;
if ( candidateNodes.Count() <= 0 )
{
if ( asw_director_debug.GetBool() )
{
Msg( " Failed to find horde pos as there are no candidate nodes\n" );
}
return false;
}
int iMaxTries = 3; // количество попыток найти место для спавна волны
for ( int i=0 ; i<iMaxTries ; i++ )
{
int iChosen = RandomInt( 0, candidateNodes.Count() - 1);
CAI_Node *pNode = GetNetwork()->GetNode( candidateNodes[iChosen] );
if ( !pNode )
continue;
float flDistance = 0;
CASW_Marine *pMarine = dynamic_cast<CASW_Marine*>(UTIL_ASW_NearestMarine( pNode->GetPosition( CANDIDATE_ALIEN_HULL ), flDistance ));
if ( !pMarine )
{
if ( asw_director_debug.GetBool() )
{
Msg( " Failed to find horde pos as there is no nearest marine\n" );
}
return false;
}
// check if there's a route from this node to the marine(s)
AI_Waypoint_t *pRoute = ASWPathUtils()->BuildRoute( pNode->GetPosition( CANDIDATE_ALIEN_HULL ), pMarine->GetAbsOrigin(), NULL, 100 );
if ( !pRoute )
{
if ( asw_director_debug.GetInt() >= 2 )
{
Msg( " Discarding horde node %d as there's no route.\n", iChosen );
}
continue;
}
if ( bNorth && UTIL_ASW_DoorBlockingRoute( pRoute, true ) )
{
if ( asw_director_debug.GetInt() >= 2 )
{
Msg( " Discarding horde node %d as there's a door in the way.\n", iChosen );
}
DeleteRoute( pRoute );
continue;
}
m_vecHordePosition = pNode->GetPosition( CANDIDATE_ALIEN_HULL ) + Vector( 0, 0, 32 );
// spawn facing the nearest marine
Vector vecDir = pMarine->GetAbsOrigin() - m_vecHordePosition;
vecDir.z = 0;
vecDir.NormalizeInPlace();
VectorAngles( vecDir, m_angHordeAngle );
if ( asw_director_debug.GetInt() >= 2 )
{
Msg( " Accepting horde node %d.\n", iChosen );
}
DeleteRoute( pRoute );
return true;
}
if ( asw_director_debug.GetBool() )
{
Msg( " Failed to find horde pos as we tried 3 times to build routes to possible locations, but failed\n" );
}
return false;
}
示例13: ClientPrint
//=========================================================
// Actualiza los mejores nodos para la creación de hijos.
//=========================================================
void CDirector_Manager::UpdateNodes()
{
// Aún no toca actualizar.
if ( CandidateUpdateTimer.HasStarted() && !CandidateUpdateTimer.IsElapsed() )
return;
// Empezar el cronometro.
CandidateUpdateTimer.Start(director_update_nodes.GetFloat());
// ¡Este mapa no tiene nodos!
if ( !GetNetwork() || !GetNetwork()->NumNodes() )
{
ClientPrint(UTIL_InPlayerByIndex(1), HUD_PRINTCENTER, "#NoNODES");
Warning("[NODOS] Este mapa no tiene nodos de movimiento.\r\n");
return;
}
int iNumNodes = GetNetwork()->NumNodes();
SpawnNodes.Purge(); // Limpiamos la lista de nodos.
// Revisamos cada nodo.
for ( int i = 0; i < iNumNodes; ++i )
{
CAI_Node *pNode = GetNetwork()->GetNode(i);
// El nodo ya no existe o no es de suelo.
if ( !pNode || pNode->GetType() != NODE_GROUND )
continue;
// Buscar al jugador más cercano.
float flDistance = 0;
Vector vecPos = pNode->GetPosition(HULL_HUMAN);
CIN_Player *pPlayer = UTIL_GetNearestInPlayer(vecPos, flDistance);
// ¡Ninguno!
if ( !pPlayer )
return;
ConVarRef director_debug("director_debug");
ConVarRef director_min_distance("director_min_distance");
ConVarRef director_max_distance("director_max_distance");
ConVarRef director_spawn_outview("director_spawn_outview");
CBaseEntity *pChild = gEntList.FindEntityByNameNearest(CHILD_NAME, vecPos, 20);
CBaseEntity *pSpawn = gEntList.FindEntityByClassname(NULL, "info_player_start");
if ( pSpawn )
{
float spawnDistance = vecPos.DistTo(pSpawn->GetAbsOrigin());
// Este nodo esta muy cerca del Spawn.
if ( spawnDistance < SPAWN_OUT_DISTANCE )
continue;
}
// Hay un hijo aquí.
if ( pChild )
continue;
// Este nodo esta muy lejos o muy cerca.
if ( flDistance > director_max_distance.GetFloat() || flDistance < director_min_distance.GetFloat() )
continue;
// No usar nodos que esten a la vista de los jugadores.
if ( director_spawn_outview.GetBool() )
{
if ( UTIL_IsPlayersVisible(vecPos) )
continue;
}
// Marcamos al nodo afortunado.
if ( director_debug.GetBool() )
NDebugOverlay::Box(vecPos, -Vector(5, 5, 5), Vector(5, 5, 5), 32, 32, 128, 10, 6.0f);
// Lo agregamos a la lista.
SpawnNodes.AddToTail(i);
}
}
示例14: SpawnRandomParasitePack
bool CASW_Spawn_Manager::SpawnRandomParasitePack( int nParasites )
{
int iNumNodes = g_pBigAINet->NumNodes();
if ( iNumNodes < 6 )
return false;
int nHull = HULL_TINY;
CUtlVector<CASW_Open_Area*> aAreas;
for ( int i = 0; i < 6; i++ )
{
CAI_Node *pNode = NULL;
int nTries = 0;
while ( nTries < 5 && ( !pNode || pNode->GetType() != NODE_GROUND ) )
{
pNode = g_pBigAINet->GetNode( RandomInt( 0, iNumNodes ) );
nTries++;
}
if ( pNode )
{
CASW_Open_Area *pArea = FindNearbyOpenArea( pNode->GetOrigin(), HULL_MEDIUMBIG );
if ( pArea && pArea->m_nTotalLinks > 30 )
{
// test if there's room to spawn a shieldbug at that spot
if ( ValidSpawnPoint( pArea->m_pNode->GetPosition( nHull ), NAI_Hull::Mins( nHull ), NAI_Hull::Maxs( nHull ), true, false ) )
{
aAreas.AddToTail( pArea );
}
else
{
delete pArea;
}
}
}
// stop searching once we have 3 acceptable candidates
if ( aAreas.Count() >= 3 )
break;
}
// find area with the highest connectivity
CASW_Open_Area *pBestArea = NULL;
for ( int i = 0; i < aAreas.Count(); i++ )
{
CASW_Open_Area *pArea = aAreas[i];
if ( !pBestArea || pArea->m_nTotalLinks > pBestArea->m_nTotalLinks )
{
pBestArea = pArea;
}
}
if ( pBestArea )
{
for ( int i = 0; i < nParasites; i++ )
{
// raise the position by 12 units, a workaround for parasites
// falling through displacements
CBaseEntity *pAlien = SpawnAlienAt( "asw_parasite", pBestArea->m_pNode->GetPosition( nHull ) + Vector(0.f, 0.f, 12.f), RandomAngle( 0, 360 ) );
IASW_Spawnable_NPC *pSpawnable = dynamic_cast<IASW_Spawnable_NPC*>( pAlien );
if ( pSpawnable )
{
pSpawnable->SetAlienOrders(AOT_SpreadThenHibernate, vec3_origin, NULL);
}
if ( asw_director_debug.GetBool() && pAlien )
{
Msg( "Spawned parasite at %f %f %f\n", pAlien->GetAbsOrigin() );
NDebugOverlay::Cross3D( pAlien->GetAbsOrigin(), 8.0f, 255, 0, 0, true, 20.0f );
}
}
aAreas.PurgeAndDeleteElements();
return true;
}
aAreas.PurgeAndDeleteElements();
return false;
}
示例15: GetCommander
bool CASW_Weapon_Blink::SetBlinkDestination()
{
CASW_Player *pPlayer = GetCommander();
if ( !pPlayer )
return false;
CASW_Marine *pMarine = GetMarine();
if ( !pMarine )
return false;
Vector vecStart = pPlayer->GetCrosshairTracePos() + Vector( 0, 0, 30 );
Vector vecEnd = pPlayer->GetCrosshairTracePos() - Vector( 0, 0, 30 );
trace_t tr;
UTIL_TraceHull( vecStart, vecEnd, pMarine->WorldAlignMins(), pMarine->WorldAlignMaxs(), MASK_PLAYERSOLID_BRUSHONLY, pMarine, COLLISION_GROUP_PLAYER_MOVEMENT, &tr );
if ( tr.startsolid || tr.allsolid )
{
m_vecInvalidDestination = vecStart;
return false;
}
if ( pMarine->GetAbsOrigin().DistTo( tr.endpos ) > asw_blink_range.GetFloat() )
{
m_vecInvalidDestination = tr.endpos;
return false;
}
Vector vecDest = tr.endpos;
// now see if we can build an AI path from the marine to this spot
bool bValidRoute = false;
if ( !pMarine->GetPathfinder() )
{
m_vecInvalidDestination = vecDest;
return false;
}
AI_Waypoint_t *pRoute = pMarine->GetPathfinder()->BuildRoute( pMarine->GetAbsOrigin(), vecDest, NULL, 30, NAV_GROUND, bits_BUILD_GROUND | bits_BUILD_IGNORE_NPCS );
if ( pRoute && !UTIL_ASW_DoorBlockingRoute( pRoute, true ) )
{
if ( !UTIL_ASW_BrushBlockingRoute( pRoute, MASK_PLAYERSOLID_BRUSHONLY, COLLISION_GROUP_PLAYER_MOVEMENT ) )
{
// if end node of the route is too Z different, then abort, to stop people jumping on top of walls
AI_Waypoint_t *pLast = pRoute->GetLast();
if ( pLast )
{
AI_Waypoint_t *pNode = pLast->GetPrev();
if ( !pNode || fabs( pNode->GetPos().z - pLast->GetPos().z ) < 80.0f )
{
bValidRoute = true;
}
}
}
}
if ( !bValidRoute )
{
// find the closest node to the dest and try to path there instead
CAI_Network *pNetwork = pMarine->GetNavigator() ? pMarine->GetNavigator()->GetNetwork() : NULL;
if ( pNetwork )
{
int nNode = pNetwork->NearestNodeToPoint( vecDest, false );
if ( nNode != NO_NODE )
{
CAI_Node *pNode = pNetwork->GetNode( nNode );
if ( pNode && pNode->GetType() == NODE_GROUND )
{
vecDest = pNode->GetOrigin();
if ( pRoute )
{
ASWPathUtils()->DeleteRoute( pRoute );
pRoute = NULL;
}
pRoute = pMarine->GetPathfinder()->BuildRoute( pMarine->GetAbsOrigin(), vecDest, NULL, 30, NAV_GROUND, bits_BUILD_GROUND | bits_BUILD_IGNORE_NPCS );
if ( pRoute && !UTIL_ASW_DoorBlockingRoute( pRoute, true ) )
{
if ( !UTIL_ASW_BrushBlockingRoute( pRoute, MASK_PLAYERSOLID_BRUSHONLY, COLLISION_GROUP_PLAYER_MOVEMENT ) )
{
bValidRoute = true;
}
}
if ( !bValidRoute )
{
m_vecInvalidDestination = vecDest;
}
}
}
}
}
if ( !bValidRoute )
{
if ( pRoute )
{
ASWPathUtils()->DeleteRoute( pRoute );
pRoute = NULL;
}
return false;
}
//.........这里部分代码省略.........