Exemple #1
0
/* this is a little messy, but it's heirarchical. Build a player, then give
 * it a brain, then add it to the list of enemies in a flock */
void AIFlockLoadAll(aiflock_t *flock, const char *md2File, 
				const char *skinFile, int nBots){

  /* this function uses sizeX, sizeY which are globals */
  player_t *chump1, *chump2;
  ai_t *enemy;
  float sPosX, sPosY, sPosZ, sYaw;
  float centerX, centerZ;
  int i;
  
  if(nBots < 1)
    return;

  /* pick a random center somewhere on the map */
  centerX = (sizeX - 20)*IRMAX*(rand()) + 10;
  centerZ = (sizeZ - 20)*IRMAX*(rand()) + 10;
  
  /* setup the first bot and then make all others use his skin */
  sPosX = 20*UNIRAND(1.0) + centerX;
  sPosZ = 20*UNIRAND(1.0) + centerZ;
  sPosY = TerrainGetHeight(ground, sPosX, sPosZ) + MOD_HEIGHT2;
  sYaw = (180)*IRMAX*rand();
  
  chump1 = PlayerNew(); 
  PlayerLoad(chump1, md2File, skinFile);
  PlayerSetPosition(chump1, sPosX, sPosY, sPosZ);
  PlayerSetForwardByAngle(chump1, 0, sYaw);
  PlayerSetUpVector(chump1, 0.0, 1.0, 0.0);
  PlayerSetAnimation(chump1, PLAYER_ANIM_IDLE0);
  enemy = AINew(chump1);
  enemy->threshold = (rand()%4)+1; /* give him an attack threshold between
									* one and 5 */
  EListAppend(flock->bots, enemy);
  flock->nBots++;

  /* now repeat for all other bots */
  for(i = 1; i < nBots; i++){
    sPosX = 20*(UNIRAND(1.0)) + centerX;
    sPosZ = 20*(UNIRAND(1.0)) + centerZ;
    sPosY = TerrainGetHeight(ground, sPosX, sPosZ) + MOD_HEIGHT2;
    sYaw = (180)*IRMAX*rand();
 
    chump2 = PlayerNew(); 
    PlayerLoadUseSameModel(chump2, chump1);
    PlayerSetPosition(chump2, sPosX, sPosY, sPosZ);
    PlayerSetForwardByAngle(chump2, 0, 180);
    PlayerSetUpVector(chump2, 0.0, 1.0, 0.0);
    PlayerSetAnimation(chump2, PLAYER_ANIM_IDLE0);
    enemy = AINew(chump2);
    enemy->threshold = (rand()%4)+1; 
	EListAppend(flock->bots, enemy);
    flock->nBots++;
  }

  return;
}
bool E_scene_main_game::load()
{
	if (already_loaded)
		return true;
	
	clearScreen();
	pGlobalInfos->GUI_SetEvenListener(this);
	
	AINew();
	switch (pGlobalInfos->GetAILevel())
	{
		case 0:
			min_per_game=3;// Add 1 second for animation time ;)
			break;
			
		case 7:
			min_per_game=90;
			break;
			
		default:
			min_per_game=pGlobalInfos->GetAILevel()*10;
			break;
	}
#ifdef DEBUG
	printf("AI min_per_game is set to : %ld minutes\n",min_per_game);
	printf("A game is set to : %ld minutes\n",moves_to_tc);
#endif

	
	//TODO : check pGlobalInfos to see if the player want 2D or 3D interface
	chessboard = new C3DGraphicChessboard(); // 3D Chessboard
	chessboard->load();
	
	SquareXSelected=-1;
	SquareZSelected=-1;
	FutureXSquare=-1;
	FutureZSquare=-1;
	
	pGlobalInfos->GUI_setScene(GUI_SCENE_MAIN_GAME);
	pGlobalInfos->GUI_displayResult(no_result);

	
	player_color  = WHITE;
	current_color = player_color;
	game_mode = pGlobalInfos->GetGameMode();
					
	game_is_over=false;
	promotion=false;
	piece_for_promotion='q';
	
	FAILE_AI_thread=NULL;
	AI_comp_is_done=false;
	
	init_fade_out();
	fade_out=true;
	fade_in=false;
	
	finish_loading();
	return true;
}