Beispiel #1
0
void MapGen::AddOres(int x, int z) 
{
  double xBlockpos = x<<4;
  double zBlockpos = z<<4;
  
  int blockX, blockZ, height;
  uint8 block;
  uint8 meta;
  
  for(int bX = 4; bX < 12; bX++) 
  {
    for(int bZ = 4; bZ < 12; bZ++) 
    {
      blockX = xBlockpos+bX;
      blockZ = zBlockpos+bZ;
      
      height = heightmap[(bZ<<4)+bX];
      height -= 5;
      
      for(int h = 10; h < height; h++)
      {
        Mineserver::get()->map()->getBlock(blockX, h, blockZ, &block, &meta);
        // No ore on air
        if(block == BLOCK_AIR)
          continue;
        
        int chance = mersenne.uniform(10000);

        // Coal ore
        if(h < 90 && chance < 70)
        {
          AddDeposit(blockX, h, blockZ, BLOCK_COAL_ORE, 4);
        }  
        
        // Iron ore
        if(h < 60 && chance < 30)
        {
          AddDeposit(blockX, h, blockZ, BLOCK_IRON_ORE, 3);
        }
        
        // Gold ore
        if(h < 32 && chance < 10)
        {
          AddDeposit(blockX, h, blockZ, BLOCK_GOLD_ORE, 2);
        }
        
        // Diamond ore
        if(h < 17 && chance < 8)
        {
          AddDeposit(blockX, h, blockZ, BLOCK_DIAMOND_ORE, 2);
        }
      }
    }
  }
}
Beispiel #2
0
void NetherGen::AddOre(int x, int z, int map, uint8_t type)
{
  int xBlockpos = x << 4;
  int zBlockpos = z << 4;

  int blockX, blockY, blockZ;
  uint8_t block;
  uint8_t meta;

  int count, startHeight;

  switch (type)
  {
  case BLOCK_GLOWSTONE:
    count = fastrand() % 4 + 15;
    startHeight = 128;
    break;
  case BLOCK_STATIONARY_LAVA:
    count = fastrand() % 20 + 20;
    startHeight = 128;
    break;
  }

  int i = 0;
  while (i < count)
  {
    blockX = fastrand() % 8 + 4;
    blockZ = fastrand() % 8 + 4;

    blockY = heightmap[(blockZ << 4) + blockX];
    blockY -= 5;

    // Check that startheight is not higher than height at that column
    if (blockY > startHeight)
    {
      blockY = startHeight;
    }

    blockX += xBlockpos;
    blockZ += zBlockpos;

    // Calculate Y
    blockY = fastrand() % blockY;

    i++;

    ServerInstance->map(map)->getBlock(blockX, blockY, blockZ, &block, &meta);
    // No ore in caves
    if (block != BLOCK_NETHERSTONE)
    {
      continue;
    }

    AddDeposit(blockX, blockY, blockZ, map, type, 2);

  }
}
Beispiel #3
0
	void GameIO::GenerateIsland(size_t islandSize, float positionx, float positiony, float positionz){
		float caves, center_falloff, plateau_falloff, density;
	    //foreach_xyz(1, size-1)
	    int x, y, z;
	    int start=1;
	    int end=islandSize-1;
		float xf, yf, zf;
		for(x=(start); x<(end); x++){
			for(y=(start); y<(end); y++){
				for(z=(start); z<(end); z++){
					xf=(float)x/(float)islandSize;
					yf=(float)y/(float)islandSize;
					zf=(float)z/(float)islandSize;

	        if(yf <= 0.8){
	            plateau_falloff = 1.0;
	        }
	        else if(0.8 < yf && yf < 0.9){
	            plateau_falloff = 1.0-(yf-0.8)*10.0;
	        }
	        else{
	            plateau_falloff = 0.0;
	        }

	        center_falloff = 0.1/(
	            pow((xf-0.5)*1.5, 2) +
	            pow((yf-1.0)*0.8, 2) +
	            pow((zf-0.5)*1.5, 2)
	        );

	        caves = pow(simplex_noise(1, xf*5, yf*5, zf*5), 3);
	        density = (
	            simplex_noise(5, xf, yf*0.5, zf) *
	            center_falloff *
	            plateau_falloff
	        );
	        density *= pow(
	            noise((xf+1)*3.0, (yf+1)*3.0, (zf+1)*3.0)+0.4, 1.8
	        );
	        if(caves<0.5){
	            density = 0;
	        }
	        std::map<std::string,Cube*> dictionary = *m_gameObjects;
	        if(density >3.1) {m_map->Set(x+(positionx-islandSize/2),y+(positiony-islandSize/2),z+(positionz-islandSize/2),dictionary[std::string("RockCube")]);}
			
			
			
	    }}}	
	    AddDeposit(islandSize,positionx,positiony,positionz); 
	    CoverWithDirt(islandSize,positionx,positiony,positionz);  
		AddGold(islandSize,positionx,positiony,positionz);
		
		//DeleteLonely(size,positionx,positiony,positionz); 
	}
Beispiel #4
0
void MapGen::AddOre(int x, int z, int map, uint8_t type) 
{
  sChunk *chunk = Mineserver::get()->map(map)->chunks.getChunk(x,z);

  int blockX, blockY, blockZ;
  uint8_t block;

  // Parameters for deposits
  int count, startHeight, minDepoSize, maxDepoSize;
  
  switch(type) {
    case BLOCK_COAL_ORE:
      count = fastrand()%10 + 20; // 20-30 coal deposits
      startHeight = 90;
      minDepoSize = 3;
      maxDepoSize = 7;
      break;
    case BLOCK_IRON_ORE:
      count = fastrand()%8 + 10; // 10-18 iron deposits
      startHeight = 60;
      minDepoSize = 2;
      maxDepoSize = 5;
      break;
    case BLOCK_GOLD_ORE:
      count = fastrand()%4 + 5; // 4-9 gold deposits
      startHeight = 32;
      minDepoSize = 2;
      maxDepoSize = 4;
      break;
    case BLOCK_DIAMOND_ORE:
      count = fastrand()%1 + 2; // 1-3 diamond deposits
      startHeight = 17;
      minDepoSize = 1;
      maxDepoSize = 2;
      break;
    case BLOCK_REDSTONE_ORE:
      count = fastrand()%5 + 5; // 5-10 redstone deposits
      startHeight = 25;
      minDepoSize = 2;
      maxDepoSize = 4;
      break;
    case BLOCK_LAPIS_ORE:
      count = fastrand()%1 + 2; // 1-3 lapis lazuli deposits
      startHeight = 17;
      minDepoSize = 1;
      maxDepoSize = 2;
      break;
    case BLOCK_GRAVEL:
      count = fastrand()%10 + 20; // 20-30 gravel deposits
      startHeight = 90;
      minDepoSize = 4;
      maxDepoSize = 10;
      break;
    default:
      return;
  }

  int i = 0;
  while(i < count)
  {
    blockX = fastrand()%8 + 4;
    blockZ = fastrand()%8 + 4;

    blockY = heightmap[(blockZ<<4)+blockX];
    blockY -= 5;

    // Check that startheight is not higher than height at that column
    if(blockY > startHeight)
    {
      blockY = startHeight;
    }

    //blockX += xBlockpos;
    //blockZ += zBlockpos;

    // Calculate Y
    blockY = fastrand()%blockY;

    i++;

    block = chunk->blocks[blockY + ((blockZ << 7) + (blockX << 11))];
    // No ore in caves
    if(block == BLOCK_AIR)
      continue;
        
    AddDeposit(blockX, blockY, blockZ, map, type, minDepoSize, maxDepoSize, chunk);

  }
}
Beispiel #5
0
void BiomeGen::AddOre(int x, int z, int map, uint8_t type)
{
  sChunk* chunk = ServerInstance->map(map)->getChunk(x, z);

  int blockX, blockY, blockZ;
  uint8_t block;

  // Parameters for deposits
  int startHeight, minDepoSize, maxDepoSize;
  unsigned int count;

  switch (type)
  {
  case BLOCK_COAL_ORE:
    count = uniform_20_30(); // 20-30 coal deposits
    startHeight = 90;
    minDepoSize = 8;
    maxDepoSize = 20;
    break;
  case BLOCK_IRON_ORE:
    count = uniform_10_18(); // 10-18 iron deposits
    startHeight = 60;
    minDepoSize = 5;
    maxDepoSize = 10;
    break;
  case BLOCK_GOLD_ORE:
    count = uniform_4_9(); // 4-9 gold deposits
    startHeight = 32;
    minDepoSize = 5;
    maxDepoSize = 8;
    break;
  case BLOCK_DIAMOND_ORE:
    count = uniform_1_3(); // 1-3 diamond deposits
    startHeight = 17;
    minDepoSize = 4;
    maxDepoSize = 7;
    break;
  case BLOCK_REDSTONE_ORE:
    count = uniform_5_10(); // 5-10 redstone deposits
    startHeight = 25;
    minDepoSize = 5;
    maxDepoSize = 20;
    break;
  case BLOCK_LAPIS_ORE:
    count = uniform_1_3(); // 1-3 lapis lazuli deposits
    startHeight = 17;
    minDepoSize = 5;
    maxDepoSize = 20;
    break;
  case BLOCK_GRAVEL:
    count = uniform_10_30(); // 10-30 gravel deposits
    startHeight = 90;
    minDepoSize = 5;
    maxDepoSize = 50;
    break;
  default:
    return;
  }

  for (unsigned int i = 0; i < count; ++i)
  {
    blockX = uniform_8_12();
    blockZ = uniform_8_12();

    blockY = heightmap_pointer[(blockZ << 4) + blockX];
    blockY -= 5;

    // Check that startheight is not higher than height at that column
    if (blockY > startHeight)
    {
      blockY = startHeight;
    }

    //blockX += xBlockpos;
    //blockZ += zBlockpos;

    // Calculate Y
    blockY = uniformUINT(0, blockY);

    
    block = chunk->blocks[blockX + (blockZ << 4) + (blockY << 8)];

    // No ore in caves
    if (block == BLOCK_AIR)
    {
      continue;
    }

    AddDeposit(blockX, blockY, blockZ, map, type, minDepoSize, maxDepoSize, chunk);
  }
}