Esempio n. 1
0
static AIValue_t directPathTo( gentity_t *self, const AIValue_t *params )
{
	AIEntity_t e = ( AIEntity_t ) AIUnBoxInt( params[ 0 ] );
	botEntityAndDistance_t ed = AIEntityToGentity( self, e );

	if ( e == E_GOAL )
	{
		return AIBoxInt( self->botMind->nav.directPathToGoal );
	}
	else if ( ed.ent )
	{
		botTarget_t target;
		BotSetTarget( &target, ed.ent, nullptr );
		return AIBoxInt( BotPathIsWalkable( self, target ) );
	}

	return AIBoxInt( false );
}
Esempio n. 2
0
static AIValue_t inAttackRange( gentity_t *self, const AIValue_t *params )
{
	botTarget_t target;
	AIEntity_t et = ( AIEntity_t ) AIUnBoxInt( params[ 0 ] );
	botEntityAndDistance_t e = AIEntityToGentity( self ,et );

	if ( !e.ent )
	{
		return AIBoxInt( false );
	}

	BotSetTarget( &target, e.ent, nullptr );

	if ( BotTargetInAttackRange( self, target ) )
	{
		return AIBoxInt( true );
	}

	return AIBoxInt( false );
}
Esempio n. 3
0
static AIValue_t isVisible( gentity_t *self, const AIValue_t *params )
{
	botTarget_t target;
	AIEntity_t et = ( AIEntity_t ) AIUnBoxInt( params[ 0 ] );
	botEntityAndDistance_t e = AIEntityToGentity( self, et );

	if ( !e.ent )
	{
		return AIBoxInt( false );
	}

	BotSetTarget( &target, e.ent, nullptr );

	if ( BotTargetIsVisible( self, target, CONTENTS_SOLID ) )
	{
		if ( BotEnemyIsValid( self, e.ent ) )
		{
			self->botMind->enemyLastSeen = level.time;
		}
		return AIBoxInt( true );
	}

	return AIBoxInt( false );
}
Esempio n. 4
0
void G_BotSpectatorThink( gentity_t *self )
{
	char buf[MAX_STRING_CHARS];
	//hacky ping fix
	self->client->ps.ping = rand() % 50 + 50;

	//acknowledge recieved console messages
	//MUST be done
	while ( trap_BotGetServerCommand( self->client->ps.clientNum, buf, sizeof( buf ) ) );

	if ( self->client->ps.pm_flags & PMF_QUEUED )
	{
		//we're queued to spawn, all good
		//check for humans in the spawn que
		{
			spawnQueue_t *sq;
			if ( self->client->pers.team != TEAM_NONE )
			{
				sq = &level.team[ self->client->pers.team ].spawnQueue;
			}
			else
			{
				sq = nullptr;
			}

			if ( sq && PlayersBehindBotInSpawnQueue( self ) )
			{
				G_RemoveFromSpawnQueue( sq, self->s.number );
				G_PushSpawnQueue( sq, self->s.number );
			}
		}
		return;
	}

	//reset stuff
	BotSetTarget( &self->botMind->goal, nullptr, nullptr );
	self->botMind->bestEnemy.ent = nullptr;
	BotResetEnemyQueue( &self->botMind->enemyQueue );
	self->botMind->currentNode = nullptr;
	memset( &self->botMind->nav, 0, sizeof( self->botMind->nav ) );
	self->botMind->futureAimTime = 0;
	self->botMind->futureAimTimeInterval = 0;
	self->botMind->numRunningNodes = 0;
	memset( self->botMind->runningNodes, 0, sizeof( self->botMind->runningNodes ) );

	if ( self->client->sess.restartTeam == TEAM_NONE )
	{
		int teamnum = self->client->pers.team;
		int clientNum = self->client->ps.clientNum;

		if ( teamnum == TEAM_HUMANS )
		{
			self->client->pers.classSelection = PCL_HUMAN_NAKED;
			self->client->ps.stats[STAT_CLASS] = PCL_HUMAN_NAKED;
			BotSetNavmesh( self, PCL_HUMAN_NAKED );
			//we want to spawn with rifle unless it is disabled or we need to build
			if ( g_bot_rifle.integer )
			{
				self->client->pers.humanItemSelection = WP_MACHINEGUN;
			}
			else
			{
				self->client->pers.humanItemSelection = WP_HBUILD;
			}
		}
		else if ( teamnum == TEAM_ALIENS )
		{
			self->client->pers.classSelection = PCL_ALIEN_LEVEL0;
			self->client->ps.stats[STAT_CLASS] = PCL_ALIEN_LEVEL0;
			BotSetNavmesh( self, PCL_ALIEN_LEVEL0 );
		}

		G_PushSpawnQueue( &level.team[ teamnum ].spawnQueue, clientNum );
	}
}