예제 #1
0
qboolean NPC_FindEnemy( qboolean checkAlerts )
{
	gentity_t *newenemy;

	//We're ignoring all enemies for now
	//if( NPC->svFlags & SVF_IGNORE_ENEMIES )
	if (0) //rwwFIXMEFIXME: support for flag
	{
		G_ClearEnemy( NPC );
		return qfalse;
	}

	//we can't pick up any enemies for now
	if( NPCInfo->confusionTime > level.time )
	{
		return qfalse;
	}

	//Don't want a new enemy
	//rwwFIXMEFIXME: support for locked enemy
	//if ( ( ValidEnemy( NPC->enemy ) ) && ( NPC->svFlags & SVF_LOCKEDENEMY ) )
	//	return qtrue;

	//See if the player is closer than our current enemy
	if ( NPC_CheckPlayerDistance() )
	{
		return qtrue;
	}

	//Otherwise, turn off the flag
//	NPC->svFlags &= ~SVF_LOCKEDENEMY;
	//See if the player is closer than our current enemy
	if ( NPC->client->NPC_class != CLASS_RANCOR 
		&& NPC->client->NPC_class != CLASS_WAMPA
		//&& NPC->client->NPC_class != CLASS_SAND_CREATURE
		&& NPC_CheckPlayerDistance() )
	{//rancors, wampas & sand creatures don't care if player is closer, they always go with closest
		return qtrue;
	}

	//If we've gotten here alright, then our target it still valid
	if ( NPC_ValidEnemy( NPC->enemy ) )
		return qtrue;

	newenemy = NPC_PickEnemyExt( checkAlerts );

	//if we found one, take it as the enemy
	if( NPC_ValidEnemy( newenemy ) )
	{
		G_SetEnemy( NPC, newenemy );
		return qtrue;
	}

	return qfalse;
}
예제 #2
0
qboolean NPC_FindEnemy( qboolean checkAlerts = qfalse )
{
	//We're ignoring all enemies for now
	if( NPC->svFlags & SVF_IGNORE_ENEMIES )
	{
		G_ClearEnemy( NPC );
		return qfalse;
	}

	//we can't pick up any enemies for now
	if( NPCInfo->confusionTime > level.time )
	{
		return qfalse;
	}

	//Don't want a new enemy
	if ( ( ValidEnemy( NPC->enemy ) ) && ( NPC->svFlags & SVF_LOCKEDENEMY ) )
		return qtrue;

	//See if the player is closer than our current enemy
	if ( NPC_CheckPlayerDistance() )
	{
		return qtrue;
	}

	//Otherwise, turn off the flag
	NPC->svFlags &= ~SVF_LOCKEDENEMY;

	//If we've gotten here alright, then our target it still valid
	if ( NPC_ValidEnemy( NPC->enemy ) )
		return qtrue;

	gentity_t *newenemy = NPC_PickEnemyExt( checkAlerts );

	//if we found one, take it as the enemy
	if( NPC_ValidEnemy( newenemy ) )
	{
		G_SetEnemy( NPC, newenemy );
		return qtrue;
	}

	return qfalse;
}
예제 #3
0
qboolean NPC_MoveToGoal( qboolean tryStraight ) 
{
	qboolean ENEMY_VISIBLE = qfalse;

	if ( PM_InKnockDown( &NPC->client->ps ) || ( ( NPC->s.legsAnim >= BOTH_PAIN1 ) && ( NPC->s.legsAnim <= BOTH_PAIN18 ) ) )
	{// If taking full body pain, don't move...
		return qfalse;
	}

	if (!NPC->enemy)
	{
		NPCInfo->goalEntity = NPC->enemy = NPC_PickEnemyExt( qtrue );
	}

	if (NPC->enemy)
		ENEMY_VISIBLE = NPC_EnemyVisible( NPC, NPC->enemy );

	if (NPC->enemy 
		&& ENEMY_VISIBLE
		&& NPC->s.weapon == WP_SABER
		&& Distance(NPC->r.currentOrigin, NPC->enemy->r.currentOrigin) > 96)
	{// Enemy is visible, but out of range for lghtsaber... Move closer
		NPC->client->ps.speed = NPCInfo->stats.walkSpeed;
	}
	else if (NPC->enemy && !ENEMY_VISIBLE)
	{// Have an enemy that is not currently visible...
		if (NPC->genericValue14 < level.time)
		{// Give up...
			NPC->enemy = NULL;
			NPCInfo->goalEntity = NULL;
			NPC->longTermGoal = -1;
		}

		NPC->client->ps.speed = NPCInfo->stats.walkSpeed;
	}
	else if (NPC->enemy && ENEMY_VISIBLE)
	{// Enemy is visible and in range, no need to move at the moment...
		NPC->client->ps.speed = NPCInfo->stats.walkSpeed;
		return qfalse;
	}
	else
	{// No enemy at all, continue to follow routes...
		if (NPC->genericValue14 < level.time)
		{// Give up...
			NPC->enemy = NULL;
			NPCInfo->goalEntity = NULL;
			NPC->longTermGoal = -1;
		}

		NPC->client->ps.speed = NPCInfo->stats.walkSpeed;
	}

	// Do the actual routing and movement...
	if (!NPC_FollowRoutes())
	{
		//G_Printf("NPC_FollowRoutes failed!\n");
		return qfalse;
	}

#if	AI_TIMERS
	navTime += GetTime( startTime );
#endif//	AI_TIMERS

	return qtrue;
}
예제 #4
0
파일: NPC_utils.c 프로젝트: jwginge/ojpa
qboolean NPC_FindEnemy( qboolean checkAlerts )
{//RACC - checks to see if our enemy is still valid.  Updates if it is not.
	gentity_t *newenemy;

	//[CoOp] SP Code
	//reenabling the IGNORE_ENEMIES flag
	if( NPC->NPC->scriptFlags & SCF_IGNORE_ENEMIES )
	//We're ignoring all enemies for now
	//if( NPC->svFlags & SVF_IGNORE_ENEMIES )
	//if (0) //rwwFIXMEFIXME: support for flag
	//[/CoOp]
	{
		G_ClearEnemy( NPC );
		return qfalse;
	}

	//we can't pick up any enemies for now
	if( NPCInfo->confusionTime > level.time )
	{
		//[CoOp] SP Code
		G_ClearEnemy( NPC );
		//[/CoOp]
		return qfalse;
	}

	//[CoOp] SP Code
	//Don't want a new enemy
	if ( ( ValidEnemy( NPC->enemy ) ) && ( NPC->NPC->aiFlags & NPCAI_LOCKEDENEMY ) )
		return qtrue;
	
	//See if the player is closer than our current enemy
	if ( NPC->client->NPC_class != CLASS_RANCOR 
		&& NPC->client->NPC_class != CLASS_WAMPA
		&& NPC->client->NPC_class != CLASS_SAND_CREATURE
		&& NPC_CheckPlayerDistance() )
	{//rancors, wampas & sand creatures don't care if player is closer, they always go with closest
		return qtrue;
	}
	/* This shouldn't be here. SP Code
	//See if the player is closer than our current enemy
	if ( NPC_CheckPlayerDistance() )
	{
		return qtrue;
	}*/
	

	//Otherwise, turn off the flag since if we have a locked enemy at this point,
	//the enemy is invalid.
	NPC->NPC->aiFlags &= ~NPCAI_LOCKEDENEMY;
//	NPC->svFlags &= ~SVF_LOCKEDENEMY;
	/* Moved up.  SP Code
	//See if the player is closer than our current enemy
	if ( NPC->client->NPC_class != CLASS_RANCOR 
		&& NPC->client->NPC_class != CLASS_WAMPA
		//&& NPC->client->NPC_class != CLASS_SAND_CREATURE
		&& NPC_CheckPlayerDistance() )
	{//rancors, wampas & sand creatures don't care if player is closer, they always go with closest
		return qtrue;
	}
	*/
	//[/CoOp]

	//If we've gotten here alright, then our target it still valid
	if ( NPC_ValidEnemy( NPC->enemy ) )
		return qtrue;

	newenemy = NPC_PickEnemyExt( checkAlerts );

	//if we found one, take it as the enemy
	if( NPC_ValidEnemy( newenemy ) )
	{
		G_SetEnemy( NPC, newenemy );
		return qtrue;
	}

	//[CoOp] SP Code.  Remove enemy since they're not valid at this point.
	G_ClearEnemy( NPC );
	//[/CoOp]
	return qfalse;
}