예제 #1
0
void MakeSpecialRooms()
{
  int i, j;
  int c_tier;
  int c_room;
  int biggest_room_sz = 0;
  int biggest_room_n = -1;
  int rtyp[8] = {0};
  int ctyp;
  int x, y;
	
  /* Special rooms are:
   *
   * - Boss rooms, every 1/(number of bosses)th of the total rooms.
   *
   * - PSI key rooms, every 1/2(number of bosses)th of the total
   *   rooms that isn't a boss room.
   *
   * (By default, eg with 3000 rooms and 3 bosses, this will generate a 
   *  boss room in rooms 1000, 2000 and 3000 and a PSI key room in rooms 
   *  500, 1500 and 2500. TODO: test for other numbers)
   *
   * - Artifact rooms (biggest non-boss room of a given distance tier)
   *		Tiers: 5-9  10-14  15-19  20-24  25-29  30-34  35-39  40-44
   */
	
  /* boss rooms */
  for (i = 0; i < NUM_REGULAR_BOSSES; i++) {
    c_room = (((i + 1) * (NUM_ROOMS / NUM_REGULAR_BOSSES)) - 1);
    map.rooms[c_room].room_type = ROOM_BOSS;
    map.rooms[c_room].room_param = i;
  }
  /* power object rooms */
  for (i = 0; i < NUM_REGULAR_BOSSES; i++) {
    c_room = (((i + 1) * (NUM_ROOMS / NUM_REGULAR_BOSSES)) - 
              (NUM_ROOMS / NUM_REGULAR_BOSSES / 2) - 1);
    map.rooms[c_room].room_type = ROOM_PSI_KEY;
    map.rooms[c_room].room_param = i;
  }
	
  /* artifact rooms */
  for (c_tier = 0; c_tier < 8; c_tier++) {
    biggest_room_sz = 0;
    for (c_room = 0; c_room < NUM_ROOMS; c_room++) {
      if (map.rooms[c_room].room_type == 0) {
        if (map.rooms[c_room].s_dist >= (c_tier*5+5)) {
          if (map.rooms[c_room].s_dist <= (c_tier*5+9)) {
            if (RoomSize(c_room) > biggest_room_sz) {
              biggest_room_sz = RoomSize(c_room);
              biggest_room_n = c_room;
            }
          }
        }
      }
    }
    map.rooms[biggest_room_n].room_type = ROOM_ART_CHALLENGE;
		
    /* pick a # */
    for (;;) {
      ctyp = rand()%8;
      if (rtyp[ctyp] == 0) {
        rtyp[ctyp] = 1;
        break;
      }
    }
		
    map.rooms[biggest_room_n].room_param = ctyp;
		
    /*printf("Artifact room for tier %d is room %d (size %d), with artifact %d\n", c_tier, biggest_room_n, biggest_room_sz, ctyp); */
  }
	
  /* place of power
   * The room with the highest s_dist that is not of any other type */
	
  for (i = 0; i < NUM_ROOMS; i++) {
    if (map.rooms[i].s_dist > map.rooms[place_of_power].s_dist) {
      if (map.rooms[i].room_type == 0) {
        place_of_power = i;
      }
    }
  }

  map.rooms[place_of_power].room_type = ROOM_PLACE_OF_POWER;
	
  /* Now place some checkpoints in the remaining rooms
   * Normally, we would have a checkpoint for every 30
   * rooms, BUT since we aren't using that method any
   * more, we will simply use an equivalent--namely, to
   * divide the map into an 8x8 grid and place one
   * checkpoint per square.
   */

  for (y = 0; y < 8; y++) {
    for (x = 0; x < 8; x++) {
      j = -1;
      for (i = 0; i < 20; i++) {
        j = GetRoom(rand() % 64 + x * 64, rand() % 64 + y * 64);
                
        if (j >= 0) {
          if (map.rooms[j].room_type == 0) {
            Put(map.rooms[j].x + map.rooms[j].w / 2, map.rooms[j].y + map.rooms[j].h / 2, 25, j);
            map.rooms[j].checkpoint = 1;
            break;
          }
        }
      }
    }
  }
	
  next_check--;
}
예제 #2
0
파일: mapgen.c 프로젝트: bart9h/meritous
void MakeSpecialRooms()
{
	int i, j;
	int c_tier;
	int c_room;
	int biggest_room_sz = 0;
	int biggest_room_n = -1;
	int rtyp[8] = {0};
	int ctyp;
	int x, y;
	
	// Special rooms are:
	// - Boss rooms @ 500, 1000, 1500, 2000, 2500, 3000
	// - Artifact rooms (biggest non-boss room of a given tier)
	//		Tiers: 5-9  10-14  15-19  20-24  25-29  30-34  35-39  40-44
	
	// boss rooms
	for (i = 0; i < 3; i++) {
		c_room = i*1000+999;
		rooms[c_room].room_type = 2;
		rooms[c_room].room_param = i;
	}
	// power object rooms
	for (i = 0; i < 3; i++) {
		c_room = i*1000+499;
		rooms[c_room].room_type = 5;
		rooms[c_room].room_param = i;
	}
	
	// artifact rooms
	for (c_tier = 0; c_tier < 8; c_tier++) {
		biggest_room_sz = 0;
		for (c_room = 0; c_room < 3000; c_room++) {
			if (rooms[c_room].room_type == 0) {
				if (rooms[c_room].s_dist >= (c_tier*5+5)) {
					if (rooms[c_room].s_dist <= (c_tier*5+9)) {
						if (RoomSize(c_room) > biggest_room_sz) {
							biggest_room_sz = RoomSize(c_room);
							biggest_room_n = c_room;
						}
					}
				}
			}
		}
		rooms[biggest_room_n].room_type = 3;
		
		// pick a #
		for (;;) {
			ctyp = rand()%8;
			if (rtyp[ctyp] == 0) {
				rtyp[ctyp] = 1;
				break;
			}
		}
		
		rooms[biggest_room_n].room_param = ctyp;
		
		//printf("Artifact room for tier %d is room %d (size %d), with artifact %d\n", c_tier, biggest_room_n, biggest_room_sz, ctyp);
	}
	
	// place of power
	// The room with the highest s_dist that is not of any other type
	
	for (i = 0; i < 3000; i++) {
		if (rooms[i].s_dist > rooms[place_of_power].s_dist) {
			if (rooms[i].room_type == 0) {
				place_of_power = i;
			}
		}
	}

	rooms[place_of_power].room_type = 6;
	
	// Now place some checkpoints in the remaining rooms
	// Normally, we would have a checkpoint for every 30
	// rooms, BUT since we aren't using that method any
	// more, we will simply use an equivalent--namely, to
	// divide the map into an 8x8 grid and place one
	// checkpoint per square

	for (y = 0; y < 8; y++) {
		for (x = 0; x < 8; x++) {
			j = -1;
			for (i = 0; i < 20; i++) {
				j = GetRoom(rand() % 64 + x * 64, rand() % 64 + y * 64);
                
                if (j >= 0) {
                    if (rooms[j].room_type == 0) {
                        Put(rooms[j].x + rooms[j].w / 2, rooms[j].y + rooms[j].h / 2, 25, j);
                        rooms[j].checkpoint = 1;
                        break;
                    }
                }
			}
		}
	}
	
	next_check--;
}