本文整理汇总了C++中CNavigator::GetNodePosition方法的典型用法代码示例。如果您正苦于以下问题:C++ CNavigator::GetNodePosition方法的具体用法?C++ CNavigator::GetNodePosition怎么用?C++ CNavigator::GetNodePosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CNavigator
的用法示例。
在下文中一共展示了CNavigator::GetNodePosition方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NPC_BSSearchStart
void NPC_BSSearchStart( int homeWp, bState_t bState )
{
//FIXME: Reimplement
NPCInfo->homeWp = homeWp;
NPCInfo->tempBehavior = bState;
NPCInfo->aiFlags |= NPCAI_ENROUTE_TO_HOMEWP;
NPCInfo->investigateDebounceTime = 0;
navigator.GetNodePosition( homeWp, NPCInfo->tempGoal->currentOrigin );
NPCInfo->tempGoal->waypoint = homeWp;
//gi.Printf("\nHeading for wp %d...\n", NPCInfo->homeWp);
}
示例2: NAVNEW_TestNodeConnectionBlocked
qboolean NAVNEW_TestNodeConnectionBlocked( int wp1, int wp2, gentity_t *ignoreEnt, int goalEntNum, qboolean checkWorld, qboolean checkEnts )
{//see if the direct path between 2 nodes is blocked by architecture or an ent
vec3_t pos1, pos2, mins, maxs;
trace_t trace;
int clipmask = MASK_NPCSOLID|CONTENTS_BOTCLIP;
int ignoreEntNum;
if ( !checkWorld && !checkEnts )
{//duh, nothing to trace against
return qfalse;
}
navigator.GetNodePosition( wp1, pos1 );
navigator.GetNodePosition( wp2, pos2 );
if ( !checkWorld )
{
clipmask &= ~(CONTENTS_SOLID|CONTENTS_MONSTERCLIP|CONTENTS_BOTCLIP);
}
if ( !checkEnts )
{
clipmask &= ~CONTENTS_BODY;
}
if ( ignoreEnt )
{
VectorCopy( ignoreEnt->mins, mins );
VectorCopy( ignoreEnt->maxs, maxs );
ignoreEntNum = ignoreEnt->s.number;
}
else
{
VectorCopy( playerMins, mins );
VectorCopy( playerMaxs, maxs );
ignoreEntNum = ENTITYNUM_NONE;
}
mins[2] += STEPSIZE;
//don't let box get inverted
if ( mins[2] > maxs[2] )
{
mins[2] = maxs[2];
}
gi.trace( &trace, pos1, mins, maxs, pos2, ignoreEntNum, clipmask, G2_NOCOLLIDE, 0 );
if ( trace.fraction >= 1.0f || trace.entityNum == goalEntNum )
{//clear or hit goal
return qfalse;
}
//hit something we weren't supposed to
return qtrue;
}
示例3: NPC_BSSearch
//.........这里部分代码省略.........
{
NPC_SetAnim(NPC, SETANIM_BOTH, BOTH_GUARD_LOOKAROUND1, SETANIM_FLAG_NORMAL);
}
else
{
NPC_SetAnim(NPC, SETANIM_BOTH, BOTH_GUARD_IDLE1, SETANIM_FLAG_NORMAL);
}
NPCInfo->investigateDebounceTime = level.time + Q_irand(3000, 10000);
}
else
{
NPC_MoveToGoal( qtrue );
}
}
else
{
//We're there
if ( NPCInfo->investigateDebounceTime > level.time )
{
//Still waiting around for a bit
//Turn angles every now and then to look around
if ( NPCInfo->tempGoal->waypoint != WAYPOINT_NONE )
{
if ( !Q_irand( 0, 30 ) )
{
int numEdges = navigator.GetNodeNumEdges( NPCInfo->tempGoal->waypoint );
if ( numEdges != WAYPOINT_NONE )
{
int branchNum = Q_irand( 0, numEdges - 1 );
vec3_t branchPos, lookDir;
int nextWp = navigator.GetNodeEdge( NPCInfo->tempGoal->waypoint, branchNum );
navigator.GetNodePosition( nextWp, branchPos );
VectorSubtract( branchPos, NPCInfo->tempGoal->currentOrigin, lookDir );
NPCInfo->desiredYaw = AngleNormalize360( vectoyaw( lookDir ) + Q_flrand( -45, 45 ) );
}
//pick an angle +-45 degrees off of the dir of a random branch
//from NPCInfo->tempGoal->waypoint
//int branch = Q_irand( 0, (waypoints[NPCInfo->tempGoal->waypoint].numNeighbors - 1) );
//int nextWp = waypoints[NPCInfo->tempGoal->waypoint].nextWaypoint[branch][NPCInfo->stats.moveType];
//vec3_t lookDir;
//VectorSubtract( waypoints[nextWp].origin, NPCInfo->tempGoal->currentOrigin, lookDir );
//Look in that direction +- 45 degrees
//NPCInfo->desiredYaw = AngleNormalize360( vectoyaw( lookDir ) + Q_flrand( -45, 45 ) );
}
}
//gi.Printf(".");
}
else
{//Just finished waiting
NPC->waypoint = NAV_FindClosestWaypointForEnt( NPC, WAYPOINT_NONE );
if ( NPC->waypoint == NPCInfo->homeWp )
{
int numEdges = navigator.GetNodeNumEdges( NPCInfo->tempGoal->waypoint );
if ( numEdges != WAYPOINT_NONE )
{
int branchNum = Q_irand( 0, numEdges - 1 );
int nextWp = navigator.GetNodeEdge( NPCInfo->homeWp, branchNum );
navigator.GetNodePosition( nextWp, NPCInfo->tempGoal->currentOrigin );
NPCInfo->tempGoal->waypoint = nextWp;
}
/*
//Pick a random branch
int branch = Q_irand( 0, (waypoints[NPCInfo->homeWp].numNeighbors - 1) );
int nextWp = waypoints[NPCInfo->homeWp].nextWaypoint[branch][NPCInfo->stats.moveType];
VectorCopy( waypoints[nextWp].origin, NPCInfo->tempGoal->currentOrigin );
NPCInfo->tempGoal->waypoint = nextWp;
//gi.Printf("\nHeading for wp %d...\n", waypoints[NPCInfo->homeWp].nextWaypoint[branch][NPCInfo->stats.moveType]);
*/
}
else
{//At a branch, so return home
navigator.GetNodePosition( NPCInfo->homeWp, NPCInfo->tempGoal->currentOrigin );
NPCInfo->tempGoal->waypoint = NPCInfo->homeWp;
/*
VectorCopy( waypoints[NPCInfo->homeWp].origin, NPCInfo->tempGoal->currentOrigin );
NPCInfo->tempGoal->waypoint = NPCInfo->homeWp;
//gi.Printf("\nHeading for wp %d...\n", NPCInfo->homeWp);
*/
}
NPCInfo->investigateDebounceTime = 0;
//Start moving toward our tempGoal
NPCInfo->goalEntity = NPCInfo->tempGoal;
NPC_MoveToGoal( qtrue );
}
}
NPC_UpdateAngles( qtrue, qtrue );
}
示例4: NPC_BSFlee
void NPC_BSFlee( void )
{//FIXME: keep checking for danger
if ( TIMER_Done( NPC, "flee" ) && NPCInfo->tempBehavior == BS_FLEE )
{
NPCInfo->tempBehavior = BS_DEFAULT;
NPCInfo->squadState = SQUAD_IDLE;
//FIXME: should we set some timer to make him stay in this spot for a bit,
//so he doesn't just suddenly turn around and come back at the enemy?
//OR, just stop running toward goal for last second or so of flee?
}
if ( NPC_CheckSurrender() )
{
return;
}
gentity_t *goal = NPCInfo->goalEntity;
if ( !goal )
{
goal = NPCInfo->lastGoalEntity;
if ( !goal )
{//???!!!
goal = NPCInfo->tempGoal;
}
}
if ( goal )
{
qboolean reverseCourse = qtrue;
//FIXME: if no weapon, find one and run to pick it up?
//Let's try to find a waypoint that gets me away from this thing
if ( NPC->waypoint == WAYPOINT_NONE )
{
NPC->waypoint = NAV_GetNearestNode( NPC, NPC->lastWaypoint );
}
if ( NPC->waypoint != WAYPOINT_NONE )
{
int numEdges = navigator.GetNodeNumEdges( NPC->waypoint );
if ( numEdges != WAYPOINT_NONE )
{
vec3_t dangerDir;
int nextWp;
VectorSubtract( NPCInfo->investigateGoal, NPC->currentOrigin, dangerDir );
VectorNormalize( dangerDir );
for ( int branchNum = 0; branchNum < numEdges; branchNum++ )
{
vec3_t branchPos, runDir;
nextWp = navigator.GetNodeEdge( NPC->waypoint, branchNum );
navigator.GetNodePosition( nextWp, branchPos );
VectorSubtract( branchPos, NPC->currentOrigin, runDir );
VectorNormalize( runDir );
if ( DotProduct( runDir, dangerDir ) > Q_flrand( 0, 0.5 ) )
{//don't run toward danger
continue;
}
//FIXME: don't want to ping-pong back and forth
NPC_SetMoveGoal( NPC, branchPos, 0, qtrue );
reverseCourse = qfalse;
break;
}
}
}
qboolean moved = NPC_MoveToGoal( qfalse );//qtrue? (do try to move straight to (away from) goal)
if ( NPC->s.weapon == WP_NONE && (moved == qfalse || reverseCourse) )
{//No weapon and no escape route... Just cower? Need anim.
NPC_Surrender();
NPC_UpdateAngles( qtrue, qtrue );
return;
}
//If our move failed, then just run straight away from our goal
//FIXME: We really shouldn't do this.
if ( moved == qfalse )
{
vec3_t dir;
float dist;
if ( reverseCourse )
{
VectorSubtract( NPC->currentOrigin, goal->currentOrigin, dir );
}
else
{
VectorSubtract( goal->currentOrigin, NPC->currentOrigin, dir );
}
NPCInfo->distToGoal = dist = VectorNormalize( dir );
NPCInfo->desiredYaw = vectoyaw( dir );
NPCInfo->desiredPitch = 0;
ucmd.forwardmove = 127;
}
else if ( reverseCourse )
{
//ucmd.forwardmove *= -1;
//ucmd.rightmove *= -1;
//VectorScale( NPC->client->ps.moveDir, -1, NPC->client->ps.moveDir );
//.........这里部分代码省略.........
示例5: NPC_BSWander
void NPC_BSWander (void)
{//FIXME: don't actually go all the way to the next waypoint, just move in fits and jerks...?
if ( !NPCInfo->investigateDebounceTime )
{//Starting out
float minGoalReachedDistSquared = 64;//32*32;
vec3_t vec;
//Keep moving toward our tempGoal
NPCInfo->goalEntity = NPCInfo->tempGoal;
VectorSubtract ( NPCInfo->tempGoal->currentOrigin, NPC->currentOrigin, vec);
if ( NPCInfo->tempGoal->waypoint != WAYPOINT_NONE )
{
minGoalReachedDistSquared = 64;
}
if ( VectorLengthSquared( vec ) < minGoalReachedDistSquared )
{
//Close enough, just got there
NPC->waypoint = NAV_FindClosestWaypointForEnt( NPC, WAYPOINT_NONE );
if( !Q_irand(0, 1) )
{
NPC_SetAnim(NPC, SETANIM_BOTH, BOTH_GUARD_LOOKAROUND1, SETANIM_FLAG_NORMAL);
}
else
{
NPC_SetAnim(NPC, SETANIM_BOTH, BOTH_GUARD_IDLE1, SETANIM_FLAG_NORMAL);
}
//Just got here, so Look around for a while
NPCInfo->investigateDebounceTime = level.time + Q_irand(3000, 10000);
}
else
{
//Keep moving toward goal
NPC_MoveToGoal( qtrue );
}
}
else
{
//We're there
if ( NPCInfo->investigateDebounceTime > level.time )
{
//Still waiting around for a bit
//Turn angles every now and then to look around
if ( NPCInfo->tempGoal->waypoint != WAYPOINT_NONE )
{
if ( !Q_irand( 0, 30 ) )
{
int numEdges = navigator.GetNodeNumEdges( NPCInfo->tempGoal->waypoint );
if ( numEdges != WAYPOINT_NONE )
{
int branchNum = Q_irand( 0, numEdges - 1 );
vec3_t branchPos, lookDir;
int nextWp = navigator.GetNodeEdge( NPCInfo->tempGoal->waypoint, branchNum );
navigator.GetNodePosition( nextWp, branchPos );
VectorSubtract( branchPos, NPCInfo->tempGoal->currentOrigin, lookDir );
NPCInfo->desiredYaw = AngleNormalize360( vectoyaw( lookDir ) + Q_flrand( -45, 45 ) );
}
}
}
}
else
{//Just finished waiting
NPC->waypoint = NAV_FindClosestWaypointForEnt( NPC, WAYPOINT_NONE );
if ( NPC->waypoint != WAYPOINT_NONE )
{
int numEdges = navigator.GetNodeNumEdges( NPC->waypoint );
if ( numEdges != WAYPOINT_NONE )
{
int branchNum = Q_irand( 0, numEdges - 1 );
int nextWp = navigator.GetNodeEdge( NPC->waypoint, branchNum );
navigator.GetNodePosition( nextWp, NPCInfo->tempGoal->currentOrigin );
NPCInfo->tempGoal->waypoint = nextWp;
}
NPCInfo->investigateDebounceTime = 0;
//Start moving toward our tempGoal
NPCInfo->goalEntity = NPCInfo->tempGoal;
NPC_MoveToGoal( qtrue );
}
}
}
NPC_UpdateAngles( qtrue, qtrue );
}
示例6: if
/*
-------------------------
NAVNEW_MoveToGoal
-------------------------
*/
int NAVNEW_MoveToGoal( gentity_t *self, navInfo_t &info )
{
int bestNode = WAYPOINT_NONE;
qboolean foundClearPath = qfalse;
vec3_t origin;
navInfo_t tempInfo;
qboolean setBlockedInfo = qtrue;
qboolean inGoalWP;
int numTries = 0;
memcpy( &tempInfo, &info, sizeof( tempInfo ) );
//Must have a goal entity to move there
if( self->NPC->goalEntity == NULL )
return WAYPOINT_NONE;
if ( self->waypoint == WAYPOINT_NONE && self->noWaypointTime > level.time )
{//didn't have a valid one in about the past second, don't look again just yet
return WAYPOINT_NONE;
}
if ( self->NPC->goalEntity->waypoint == WAYPOINT_NONE && self->NPC->goalEntity->noWaypointTime > level.time )
{//didn't have a valid one in about the past second, don't look again just yet
return WAYPOINT_NONE;
}
if ( self->noWaypointTime > level.time &&
self->NPC->goalEntity->noWaypointTime > level.time )
{//just use current waypoints
bestNode = navigator.GetBestNodeAltRoute( self->waypoint, self->NPC->goalEntity->waypoint, bestNode );
}
//FIXME!!!!: this is making them wiggle back and forth between waypoints
else if ( (bestNode = navigator.GetBestPathBetweenEnts( self, self->NPC->goalEntity, NF_CLEAR_PATH )) == NODE_NONE )//!NAVNEW_GetWaypoints( self, qtrue ) )
{//one of us didn't have a valid waypoint!
if ( self->waypoint == NODE_NONE )
{//don't even try to find one again for a bit
self->noWaypointTime = level.time + Q_irand( 500, 1500 );
}
if ( self->NPC->goalEntity->waypoint == NODE_NONE )
{//don't even try to find one again for a bit
self->NPC->goalEntity->noWaypointTime = level.time + Q_irand( 500, 1500 );
}
return WAYPOINT_NONE;
}
else
{
if ( self->NPC->goalEntity->noWaypointTime < level.time )
{
self->NPC->goalEntity->noWaypointTime = level.time + Q_irand( 500, 1500 );
}
}
while( !foundClearPath )
{
/*inBestWP = */inGoalWP = qfalse;
/*
bestNode = navigator.GetBestNodeAltRoute( self->waypoint, self->NPC->goalEntity->waypoint, bestNode );
*/
if ( bestNode == WAYPOINT_NONE )
{
goto failed;
}
//see if we can get directly to the next node off bestNode en route to goal's node...
//NOTE: shouldn't be necc. now
/*
int oldBestNode = bestNode;
bestNode = NAV_TestBestNode( self, self->waypoint, bestNode, qtrue );//, self->NPC->goalEntity->waypoint );//
//NOTE: Guaranteed to return something
if ( bestNode != oldBestNode )
{//we were blocked somehow
if ( setBlockedInfo )
{
self->NPC->aiFlags |= NPCAI_BLOCKED;
navigator.GetNodePosition( oldBestNode, NPCInfo->blockedDest );
}
}
*/
navigator.GetNodePosition( bestNode, origin );
/*
if ( !goalWPFailed )
{//we haven't already tried to go straight to goal or goal's wp
if ( bestNode == self->NPC->goalEntity->waypoint )
{//our bestNode is the goal's wp
if ( NAV_HitNavGoal( self->currentOrigin, self->mins, self->maxs, origin, navigator.GetNodeRadius( bestNode ), FlyingCreature( self ) ) )
{//we're in the goal's wp
inGoalWP = qtrue;
//we're in the goalEntity's waypoint already
//so head for the goalEntity since we know it's clear of architecture
//FIXME: this is pretty stupid because the NPCs try to go straight
// towards their goal before then even try macro_nav...
VectorCopy( self->NPC->goalEntity->currentOrigin, origin );
}
}
}
*/
//.........这里部分代码省略.........