Exemple #1
0
/* loads the city level */
void load_city(int populate)
{
    int i,j;
    pml ml;
    char site;
    map *city;
    map *maze;

    initrand(E_CITY, 0);

    /* Get the hedge maze (which is in the city). */
    maze = map_open(MAP_hedges);
    /* Choose a random level from it. */
    map_setLevel(maze, random_range(map_getDepth(maze)));

    /* Get the city. */
    city = map_open(MAP_city);
    map_setLevel(city,0);

    TempLevel = Level;
    if (ok_to_free(TempLevel)) {
#ifndef SAVE_LEVELS
        free_level(TempLevel);
#endif
        TempLevel = NULL;
    }
#ifndef SAVE_LEVELS
    Level = ((plv) checkmalloc(sizeof(levtype)));
#else
    msdos_changelevel(TempLevel,0,-1);
    Level = &TheLevel;
#endif
    clear_level(Level);
    Level->depth = 0;
    Level->environment = E_CITY;

    /* WDT: Rampart, as a special case, has its width stored in a
    * global variable. */
    WIDTH = Level->level_width = map_getWidth(city);
    LENGTH = Level->level_length = map_getLength(city);

    for(j=0; j<Level->level_length; j++) {
        for(i=0; i<Level->level_width; i++) {
            lset(i,j,SEEN);
            site = map_getSiteChar(city,i,j);
            switch(site) {
                /*
                case '@':
                Player.x = i; Player.y = j;
                Level->site[i][j].locchar = FLOOR;
                break;
                */
            case 'g':
                Level->site[i][j].locchar = FLOOR;
                Level->site[i][j].p_locf = L_GARDEN;
                break;
            case 'y':
                Level->site[i][j].locchar = FLOOR;
                Level->site[i][j].p_locf = L_CEMETARY;
                break;
            case 'p': /* WDT: each of these places needs to be assigned
					  * a function (or replaced with an 'x' in the map)
					  */
            case '!':
            case 'I':
            case 'E':
            case 'e':
            case 'x':
                assign_city_function(i,j);
                break;
            case 't':
                Level->site[i][j].locchar = FLOOR;
                Level->site[i][j].p_locf = L_TEMPLE;
                CitySiteList[L_TEMPLE-CITYSITEBASE][0] = TRUE;
                CitySiteList[L_TEMPLE-CITYSITEBASE][1] = i;
                CitySiteList[L_TEMPLE-CITYSITEBASE][2] = j;
                break;
#if 0 /* WDT: HACK!  The new city doesn't use portcullis traps, but has other
                * uses for 'T'.  Um...  I'd rather have a use for them (that's what
                * the jail is supposed to be), so this will stay only for now; with
                    * any luck we'll have things fixed up before the next release. */
                    case 'T':
                    Level->site[i][j].locchar = FLOOR;
                    Level->site[i][j].p_locf = L_PORTCULLIS_TRAP;
                    Level->site[i][j].aux = NOCITYMOVE;
                    break;
#endif /* end of hack */
                    case 'R':
                    Level->site[i][j].locchar = FLOOR;
                    Level->site[i][j].p_locf = L_RAISE_PORTCULLIS;
                    Level->site[i][j].aux = NOCITYMOVE;
                    break;
                    case '7':
                    Level->site[i][j].locchar = FLOOR;
                    Level->site[i][j].p_locf = L_PORTCULLIS;
                    Level->site[i][j].aux = NOCITYMOVE;
                    break;
                    case 'C':
                    Level->site[i][j].locchar = OPEN_DOOR;
                    Level->site[i][j].p_locf = L_COLLEGE;
                    CitySiteList[L_COLLEGE-CITYSITEBASE][0] = TRUE;
                    CitySiteList[L_COLLEGE-CITYSITEBASE][1] = i;
                    CitySiteList[L_COLLEGE-CITYSITEBASE][2] = j;
                    break;
                    case 's':
                    Level->site[i][j].locchar = OPEN_DOOR;
                    Level->site[i][j].p_locf = L_SORCERORS;
                    CitySiteList[L_SORCERORS-CITYSITEBASE][0] = TRUE;
                    CitySiteList[L_SORCERORS-CITYSITEBASE][1] = i;
                    CitySiteList[L_SORCERORS-CITYSITEBASE][2] = j;
                    break;
                    case 'M':
                    Level->site[i][j].locchar = OPEN_DOOR;
                    Level->site[i][j].p_locf = L_MERC_GUILD;
                    CitySiteList[L_MERC_GUILD-CITYSITEBASE][0] = TRUE;
                    CitySiteList[L_MERC_GUILD-CITYSITEBASE][1] = i;
                    CitySiteList[L_MERC_GUILD-CITYSITEBASE][2] = j;
                    break;
                    case 'K':
                    Level->site[i][j].locchar = OPEN_DOOR;
                    Level->site[i][j].p_locf = L_MONASTERY;
                    CitySiteList[L_MONASTERY-CITYSITEBASE][0] = TRUE;
                    CitySiteList[L_MONASTERY-CITYSITEBASE][1] = i;
                    CitySiteList[L_MONASTERY-CITYSITEBASE][2] = j;
                    break;
                    case 'c':
                    Level->site[i][j].locchar = OPEN_DOOR;
                    Level->site[i][j].p_locf = L_CASTLE;
                    CitySiteList[L_CASTLE-CITYSITEBASE][0] = TRUE;
                    CitySiteList[L_CASTLE-CITYSITEBASE][1] = i;
                    CitySiteList[L_CASTLE-CITYSITEBASE][2] = j;
                    break;
                    case '?':
            {
                static int myI = -1, myJ;
                char site;
                if ( myI == -1 )
            {
                /* If this is the first time we've seen the hedge maze,
                * set this as its corner. */
                myI = i;
                myJ = j;
            }
    site = map_getSiteChar(maze, i - myI, j - myJ);
        mazesite(site,i,j,populate);
    }
    break;
    case 'P':
        Level->site[i][j].locchar = OPEN_DOOR;
        Level->site[i][j].p_locf = L_ORDER;
        CitySiteList[L_ORDER-CITYSITEBASE][0] = TRUE;
        CitySiteList[L_ORDER-CITYSITEBASE][1] = i;
        CitySiteList[L_ORDER-CITYSITEBASE][2] = j;
        break;
    case 'H':
        Level->site[i][j].locchar = OPEN_DOOR;
        Level->site[i][j].p_locf = L_CHARITY;
        CitySiteList[L_CHARITY-CITYSITEBASE][0] = TRUE;
        CitySiteList[L_CHARITY-CITYSITEBASE][1] = i;
        CitySiteList[L_CHARITY-CITYSITEBASE][2] = j;
        break;
    case 'h':
        Level->site[i][j].locchar = FLOOR;
        if (populate)
            make_horse(i,j); /* from village.c */
        break;
    case 'j':
        Level->site[i][j].locchar = FLOOR;
        if (populate)
            make_justiciar(i,j);
        break;
    case 'J':
        Level->site[i][j].locchar = CLOSED_DOOR;
        Level->site[i][j].p_locf = L_JAIL;
        break;
    case 'A':
        Level->site[i][j].locchar = OPEN_DOOR;
        Level->site[i][j].p_locf = L_ARENA;
        CitySiteList[L_ARENA-CITYSITEBASE][0] = TRUE;
        CitySiteList[L_ARENA-CITYSITEBASE][1] = i;
        CitySiteList[L_ARENA-CITYSITEBASE][2] = j;
        break;
    case 'B':
        Level->site[i][j].locchar = OPEN_DOOR;
        Level->site[i][j].p_locf = L_BANK;
        CitySiteList[L_BANK-CITYSITEBASE][0] = TRUE;
        CitySiteList[L_BANK-CITYSITEBASE][1] = i;
        CitySiteList[L_BANK-CITYSITEBASE][2] = j;
        lset(i,j,STOPS);
        lset(i,j+1,STOPS);
        lset(i+1,j,STOPS);
        lset(i-1,j,STOPS);
        lset(i,j-1,STOPS);
        break;
    case 'i':
        Level->site[i][j].locchar = OPEN_DOOR;
        Level->site[i][j].p_locf = L_TOURIST;
        CitySiteList[L_TOURIST-CITYSITEBASE][1] = i;
        CitySiteList[L_TOURIST-CITYSITEBASE][2] = j;
        lset(i,j,STOPS);
        lset(i,j+1,STOPS);
        lset(i+1,j,STOPS);
        lset(i-1,j,STOPS);
        lset(i,j-1,STOPS);
        break;
    case 'X':
        Level->site[i][j].locchar = FLOOR;
        Level->site[i][j].p_locf = L_COUNTRYSIDE;
        CitySiteList[L_COUNTRYSIDE-CITYSITEBASE][0] = TRUE;
        CitySiteList[L_COUNTRYSIDE-CITYSITEBASE][1] = i;
        CitySiteList[L_COUNTRYSIDE-CITYSITEBASE][2] = j;
        break;
    case 'v':
        Level->site[i][j].locchar = FLOOR;
        Level->site[i][j].p_locf = L_VAULT;
        Level->site[i][j].aux = NOCITYMOVE;
        lset(i,j,SECRET);
        break;
    case 'S':
        Level->site[i][j].locchar = FLOOR;
        Level->site[i][j].aux = NOCITYMOVE;
        lset(i,j,SECRET);
        break;
    case 'G':
        Level->site[i][j].locchar = FLOOR;
        if (populate) {
            make_site_monster(i,j,GUARD);
            Level->site[i][j].creature->aux1 = i;
            Level->site[i][j].creature->aux2 = j;
        }
        break;
    case 'u':
        Level->site[i][j].locchar = FLOOR;
        if (populate)
            make_minor_undead(i,j);
        break;
    case 'U':
        Level->site[i][j].locchar = FLOOR;
        if (populate)
            make_major_undead(i,j);
        break;
    case 'V':
        Level->site[i][j].showchar = WALL;
        Level->site[i][j].locchar = FLOOR;
        Level->site[i][j].p_locf = L_VAULT;
        if (populate)
            make_site_treasure(i,j,5);
        Level->site[i][j].aux = NOCITYMOVE;
        lset(i,j,SECRET);
        break;
    case '%':
        Level->site[i][j].showchar = WALL;
        Level->site[i][j].locchar = FLOOR;
        Level->site[i][j].p_locf = L_TRAP_SIREN;
        if (populate)
            make_site_treasure(i,j,5);
        Level->site[i][j].aux = NOCITYMOVE;
        lset(i,j,SECRET);
        break;
    case '$':
        Level->site[i][j].locchar = FLOOR;
        if (populate)
            make_site_treasure(i,j,5);
        break;
    case '2':
        Level->site[i][j].locchar = ALTAR;
        Level->site[i][j].p_locf = L_ALTAR;
        Level->site[i][j].aux = ODIN;
        break;
    case '3':
        Level->site[i][j].locchar = ALTAR;
        Level->site[i][j].p_locf = L_ALTAR;
        Level->site[i][j].aux = SET;
        break;
    case '4':
        Level->site[i][j].locchar = ALTAR;
        Level->site[i][j].p_locf = L_ALTAR;
        Level->site[i][j].aux = ATHENA;
        break;
    case '5':
        Level->site[i][j].locchar = ALTAR;
        Level->site[i][j].p_locf = L_ALTAR;
        Level->site[i][j].aux = HECATE;
        break;
    case '6':
        Level->site[i][j].locchar = ALTAR;
        Level->site[i][j].p_locf = L_ALTAR;
        Level->site[i][j].aux = DESTINY;
        break;
    case '^':
        Level->site[i][j].showchar = WALL;
        Level->site[i][j].locchar = FLOOR;
        Level->site[i][j].p_locf = TRAP_BASE+random_range(NUMTRAPS);
        lset(i,j,SECRET);
        break;
    case '"':
        Level->site[i][j].locchar = HEDGE;
        break;
    case '~':
        Level->site[i][j].locchar = WATER;
        Level->site[i][j].p_locf = L_WATER;
        break;
    case '=':
        Level->site[i][j].locchar = WATER;
        Level->site[i][j].p_locf = L_MAGIC_POOL;
        break;
    case '*':
        Level->site[i][j].locchar = WALL;
        Level->site[i][j].aux = 10;
        break;
    case '#':
        Level->site[i][j].locchar = WALL;
        Level->site[i][j].aux = 500;
        break;
    case 'T':/* currently meaningless in large city map. */
    case '>':  /* currently meaningless outside of maze.*/
    case '.':
        Level->site[i][j].locchar = FLOOR;
        break;
    case ',':
        Level->site[i][j].showchar = WALL;
        Level->site[i][j].locchar = FLOOR;
        Level->site[i][j].aux = NOCITYMOVE;
        lset(i,j,SECRET);
        break;
    case '-':
    case 'D': /* WDT: should all Ds be changed to -, or should D be given
					  * special treatment? */
        Level->site[i][j].locchar = CLOSED_DOOR;
        break;
    case '1':
        Level->site[i][j].locchar = STATUE;
        break;
    default:
        printf("\nOops... missed a case [%d,%d]: '%c' (%d)\n", i,j,site,site);
        morewait();
    }

    if (loc_statusp(i,j,SEEN)) {
        if (loc_statusp(i,j,SECRET))
            Level->site[i][j].showchar = WALL;
        else Level->site[i][j].showchar = Level->site[i][j].locchar;
    }
}
}
map_close(maze);
map_close(city);
City = Level;

       /* make all city monsters asleep, and shorten their wakeup range to 2 */
       /* to prevent players from being molested by vicious monsters on */
       /* the streets */
for(ml=Level->mlist; ml!=NULL; ml=ml->next) {
    m_status_reset(ml->m,AWAKE);
    ml->m->wakeup = 2;
}
initrand(E_RESTORE, 0);
}
Exemple #2
0
/* loads the house level into Level*/
void load_house(int kind, int populate)
{
  map *home;
  int i,j;
  char site;
  int stops;
  
  TempLevel = Level;
  initrand(Current_Environment, Player.x + Player.y + hour()*10);
  if (ok_to_free(TempLevel)) {
#ifndef SAVE_LEVELS
    free_level(TempLevel);
#endif
    TempLevel = NULL;
  }
#ifndef SAVE_LEVELS
  Level = ((plv) checkmalloc(sizeof(levtype)));
#else
  msdos_changelevel(TempLevel,0,-1);
  Level = &TheLevel;
#endif
  clear_level(Level);
  switch(kind) {
  case E_HOUSE:
    home = map_open(MAP_house);
    break;
  case E_MANSION:
    home = map_open(MAP_mansion);
    break;
  default:
  case E_HOVEL:
    home = map_open(MAP_hovel);
    break;
  }
  Level->level_width=map_getWidth(home);
  Level->level_length=map_getLength(home);
  map_setLevel(home, 0);
  
  stops = 0;
  for(j=0;j<Level->level_length;j++) {
    for(i=0;i<Level->level_width;i++) {
      if (kind == E_HOVEL) Level->site[i][j].lstatus = SEEN;
      else Level->site[i][j].lstatus = 0;
      Level->site[i][j].roomnumber = RS_CORRIDOR;
      Level->site[i][j].p_locf = L_NO_OP;
      site = map_getSiteChar(home,i,j);
      switch(site) {
      case 'N':
	Level->site[i][j].locchar = FLOOR;
	Level->site[i][j].roomnumber = RS_BEDROOM;
	if (random_range(2) && populate) make_house_npc(i,j);
	break;
      case 'H':
	Level->site[i][j].locchar = FLOOR;
	Level->site[i][j].roomnumber = RS_BEDROOM;
	if (random_range(2) && populate) make_mansion_npc(i,j);
	break;
      case 'D':
	Level->site[i][j].locchar = FLOOR;
	Level->site[i][j].roomnumber = RS_DININGROOM;
	break;
      case '.':
	Level->site[i][j].locchar = FLOOR;
	if (stops) {
	  lset(i,j,STOPS);
	  stops = 0;
	}
	break;
      case 'c':
	Level->site[i][j].locchar = FLOOR;
	Level->site[i][j].roomnumber = RS_CLOSET;
	break;
      case 'G':
	Level->site[i][j].locchar = FLOOR;
	Level->site[i][j].roomnumber = RS_BATHROOM;
	break;
      case 'B':
	Level->site[i][j].locchar = FLOOR;
	Level->site[i][j].roomnumber = RS_BEDROOM;
	break;
      case 'K':
	Level->site[i][j].locchar = FLOOR;
	Level->site[i][j].roomnumber = RS_KITCHEN;
	break;
      case 'S':
	Level->site[i][j].locchar = FLOOR;
	Level->site[i][j].showchar = WALL;
	lset(i,j,SECRET);
	Level->site[i][j].roomnumber = RS_SECRETPASSAGE;
	break;
      case '3':
	Level->site[i][j].locchar = SAFE;
	Level->site[i][j].showchar = WALL;
	lset(i,j,SECRET);
	Level->site[i][j].p_locf = L_SAFE;
	break;
      case '^':
	Level->site[i][j].locchar = FLOOR;
	Level->site[i][j].p_locf = TRAP_BASE+random_range(NUMTRAPS);
	break;
      case 'P':
	Level->site[i][j].locchar = PORTCULLIS;
	Level->site[i][j].p_locf = L_PORTCULLIS;
	break;
      case 'R':
	Level->site[i][j].locchar = FLOOR;
	Level->site[i][j].p_locf = L_RAISE_PORTCULLIS;
	break;
      case 'p':
	Level->site[i][j].locchar = FLOOR;
	Level->site[i][j].p_locf = L_PORTCULLIS;
	break;
      case 'T':
	Level->site[i][j].locchar = FLOOR;
	Level->site[i][j].p_locf = L_PORTCULLIS_TRAP;
	break;
      case 'X':
	Level->site[i][j].locchar = FLOOR;
	Level->site[i][j].p_locf = L_HOUSE_EXIT;
	stops = 1;
	break;
      case '#':
	Level->site[i][j].locchar = WALL;
	switch (kind) {
	  case E_HOVEL: Level->site[i][j].aux = 10; break;
	  case E_HOUSE: Level->site[i][j].aux = 50; break;
	  case E_MANSION: Level->site[i][j].aux = 150; break;
	}
	break;
      case '|':
	Level->site[i][j].locchar = OPEN_DOOR;
	Level->site[i][j].roomnumber = RS_CORRIDOR;
	lset(i,j,STOPS);
	break;
      case '+':
	Level->site[i][j].locchar = CLOSED_DOOR;
	Level->site[i][j].roomnumber = RS_CORRIDOR;
	Level->site[i][j].aux = LOCKED;
	lset(i,j,STOPS);
	break;
      case 'd':
	Level->site[i][j].locchar = FLOOR;
	Level->site[i][j].roomnumber = RS_CORRIDOR;
	if (populate)
	  make_site_monster(i,j,DOBERMAN);
	break;
      case 'a':
	Level->site[i][j].locchar = FLOOR;
	Level->site[i][j].roomnumber = RS_CORRIDOR;
	Level->site[i][j].p_locf = L_TRAP_SIREN;
	break;
      case 'A':
	Level->site[i][j].locchar = FLOOR;
	Level->site[i][j].roomnumber = RS_CORRIDOR;
	if (populate)
	  make_site_monster(i,j,AUTO_MINOR); /* automaton */
	break;
      }
      Level->site[i][j].showchar = ' ';
    }
  }
  map_close(home);
  initrand(E_RESTORE, 0);
}