1 /* omega copyright (c) 1987,1988,1989 by Laurence Raphael Brothers */
2 /* gen1.c */
3 /* level generator functions */
4 
5 #include "glob.h"
6 
7 
8 /* Deallocate current dungeon */
free_dungeon()9 void free_dungeon()
10 {
11 #ifndef SAVE_LEVELS
12   plv tlv;
13 
14   while (Dungeon != NULL) {
15     tlv = Dungeon;
16     Dungeon = Dungeon->next;
17     free_level(tlv);
18   }
19 #else
20   if (Dungeon != NULL)
21   {
22     sprintf(Str2,"om%d*.lev",Dungeon->environment);
23     kill_levels(Str2);
24   }
25 #endif
26 }
27 
28 
29 /* erase the level w/o deallocating it*/
clear_level(dungeon_level)30 void clear_level(dungeon_level)
31 struct level *dungeon_level;
32 {
33   int i,j;
34   if (dungeon_level != NULL) {
35     dungeon_level->generated = FALSE;
36     dungeon_level->numrooms = 0;
37     dungeon_level->tunnelled = 0;
38     dungeon_level->depth = 0;
39     dungeon_level->mlist = NULL;
40     dungeon_level->next = NULL;
41     dungeon_level->last_visited = time((long *) NULL);
42     for(i=0;i<MAXWIDTH;i++)
43       for(j=0;j<MAXLENGTH;j++) {
44 	dungeon_level->site[i][j].locchar = WALL;
45 	dungeon_level->site[i][j].showchar = SPACE;
46 	dungeon_level->site[i][j].creature = NULL;
47 	dungeon_level->site[i][j].things = NULL;
48 	dungeon_level->site[i][j].aux = difficulty()*20;
49 	dungeon_level->site[i][j].buildaux = 0;
50 	dungeon_level->site[i][j].p_locf = L_NO_OP;
51 	dungeon_level->site[i][j].lstatus = 0;
52 	dungeon_level->site[i][j].roomnumber = RS_WALLSPACE;
53       }
54   }
55 }
56 
57 
58 
59 /* Looks for level tolevel in current dungeon which is named by
60 Dungeon, which may be NULL. If the level is found, and rewrite_level
61 is FALSE, and the level has already been generated, nothing happens
62 beyond Level being set correctly. Otherwise the level is recreated
63 from scratch */
64 
change_level(fromlevel,tolevel,rewrite_level)65 void change_level(fromlevel,tolevel,rewrite_level)
66 char fromlevel,tolevel,rewrite_level;
67 {
68   struct level *thislevel = NULL;
69   Player.sx = -1; Player.sy = -1; /* sanctuary effect dispelled */
70 #ifndef SAVE_LEVELS
71   thislevel = findlevel(Dungeon,tolevel);
72   deepest[Current_Environment] = max(deepest[Current_Environment],tolevel);
73   if (thislevel == NULL) {
74     thislevel = ((plv) checkmalloc(sizeof(levtype)));
75 #else
76   thislevel = msdos_changelevel(Level,Current_Environment,tolevel);
77   deepest[Current_Environment] = max(deepest[Current_Environment],tolevel);
78   if (thislevel == NULL) {
79     thislevel = &TheLevel;
80 #endif
81     clear_level(thislevel);
82     Level = thislevel;
83     Level->next = Dungeon;
84     Dungeon = Level;
85   }
86   Level = thislevel;
87   if ((! Level->generated) || rewrite_level) {
88     initrand(Current_Environment, tolevel);
89     Level->environment = Current_Environment;
90     Level->depth = tolevel;
91     Level->generated = TRUE;
92     switch(Current_Environment) {
93     case E_CAVES:
94       if ((random_range(4)==0) && (tolevel < MaxDungeonLevels))
95 	room_level();
96       else cavern_level();
97       break;
98     case E_SEWERS:
99       if ((random_range(4)==0) && (tolevel < MaxDungeonLevels))
100 	room_level();
101       else sewer_level();
102       break;
103     case E_CASTLE:
104       room_level();
105       break;
106     case E_ASTRAL:
107       maze_level();
108       break;
109     case E_VOLCANO:
110       switch(random_range(3)) {
111       case 0: cavern_level(); break;
112       case 1: room_level(); break;
113       case 2: maze_level(); break;
114       }
115       break;
116     default: print3("This dungeon not implemented!"); break;
117     }
118     install_traps();
119     install_specials();
120     make_stairs(fromlevel);
121     make_stairs(fromlevel);
122     initrand(E_RESTORE, 0);
123     populate_level(Current_Environment);
124     stock_level();
125   }
126   find_stairs(fromlevel,tolevel);
127   ScreenOffset = Player.y - (ScreenLength/2);
128   show_screen();
129   screencheck(Player.y);
130   drawvision(Player.x,Player.y);
131   /* synchronize with player on level change */
132   Player.click = (Tick+1)%60;
133   roomcheck();
134 }
135 
136 
137 #ifndef SAVE_LEVELS
138 /* tries to find the level of depth levelnum in dungeon; if can't find
139    it returns NULL */
findlevel(dungeon,levelnum)140 plv findlevel(dungeon,levelnum)
141 struct level *dungeon;
142 char levelnum;
143 {
144   if (dungeon == NULL) return(NULL);
145   else {
146     while((dungeon->next != NULL) && (dungeon->depth != levelnum))
147       dungeon = dungeon->next;
148     if (dungeon->depth == levelnum) {
149       dungeon->last_visited = time((long *)NULL);
150       return(dungeon);
151     }
152     else return(NULL);
153   }
154 }
155 #endif
156 
157 
158 
159 /* keep going in one orthogonal direction or another until we hit our */
160 /* destination */
161 
straggle_corridor(fx,fy,tx,ty,loc,rsi)162 void straggle_corridor(fx,fy,tx,ty,loc,rsi)
163 int fx,fy,tx,ty;
164 Symbol loc;
165 char rsi;
166 {
167   int dx,dy;
168   while ((fx != tx) || (fy != ty)) {
169     dx = tx - fx;
170     dy = ty - fy;
171     if (random_range(abs(dx)+abs(dy)) < abs(dx))
172       corridor_crawl(&fx,&fy,sign(dx),0,random_range(abs(dx))+1,loc,rsi);
173     else corridor_crawl(&fx,&fy,0,sign(dy),random_range(abs(dy))+1,loc,rsi);
174   }
175 }
176 
177 
178 
makedoor(x,y)179 void makedoor(x,y)
180 int x,y;
181 {
182   if (random_range(20) <= Level->depth/10) {
183     Level->site[x][y].locchar = FLOOR;
184     lset(x,y,SECRET);
185   }
186   else if (random_range(20)<=Level->depth/2) {
187     Level->site[x][y].locchar = CLOSED_DOOR;
188     if (random_range(20) <= Level->depth/10)
189       lset(x,y,SECRET);
190     if (random_range(40) <= Level->depth)
191       Level->site[x][y].aux = LOCKED;
192     else Level->site[x][y].aux = UNLOCKED;
193   }
194   else {
195     Level->site[x][y].locchar = OPEN_DOOR;
196     Level->site[x][y].aux = UNLOCKED;
197   }
198   if (! loc_statusp(x,y,SECRET)) {
199     lset(x,y+1,STOPS);
200     lset(x+1,y,STOPS);
201     lset(x-1,y,STOPS);
202     lset(x,y-1,STOPS);
203     lset(x,y,STOPS);
204   }
205   Level->site[x][y].p_locf = L_NO_OP;
206   /* prevents water corridors from being instant death in sewers */
207 }
208 
209 
corridor_crawl(fx,fy,sx,sy,n,loc,rsi)210 void corridor_crawl(fx,fy,sx,sy,n,loc,rsi)
211 int *fx,*fy,sx,sy,n;
212 Symbol loc;
213 char rsi;
214 {
215   int i;
216   for (i=0;i<n;i++) {
217     *fx += sx;
218     *fy += sy;
219     if ((*fx < WIDTH) &&
220 	(*fx > -1) &&
221 	(*fy > -1) &&
222 	(*fy < LENGTH)) {
223       Level->site[*fx][*fy].locchar = loc;
224       if (Level->site[*fx][*fy].roomnumber == RS_WALLSPACE)
225 	Level->site[*fx][*fy].roomnumber = rsi;
226       if (loc==WATER)
227 	Level->site[*fx][*fy].p_locf = L_WATER;
228       else if (loc==FLOOR)
229 	Level->site[*fx][*fy].p_locf = L_NO_OP;
230       else if (loc==RUBBLE)
231 	Level->site[*fx][*fy].p_locf = L_RUBBLE;
232     }
233   }
234 }
235 
236 
237 
238 
239 
roomname(index)240 char *roomname(index)
241 int index;
242 {
243   switch(index) {
244   case RS_ZORCH:strcpy(Str4,"A place zorched by powerful magic.");break;
245   case RS_COURT:strcpy(Str4,"The Court of the ArchMage."); break;
246   case RS_CIRCLE:strcpy(Str4,"The Astral Demesne of the Circle of Sorcerors");
247     break;
248   case RS_MAGIC_ISLE: strcpy(Str4,"An island positively reeking of magic");
249     break;
250   case RS_STARPEAK: strcpy(Str4,"Near the oddly glowing peak of a mountain");
251     break;
252   case RS_VOLCANO: strcpy(Str4,"Deep within the bowels of the earth"); break;
253   case RS_HIGHASTRAL: strcpy(Str4,"The High Astral Plane"); break;
254   case RS_EARTHPLANE: strcpy(Str4,"The Plane of Earth"); break;
255   case RS_WATERPLANE: strcpy(Str4,"The Plane of Water"); break;
256   case RS_FIREPLANE: strcpy(Str4,"The Plane of Fire"); break;
257   case RS_AIRPLANE: strcpy(Str4,"The Plane of Air"); break;
258   case RS_KITCHEN: strcpy(Str4,"A kitchen"); break;
259   case RS_BATHROOM: strcpy(Str4,"A bathroom"); break;
260   case RS_BEDROOM: strcpy(Str4,"A bedroom"); break;
261   case RS_DININGROOM: strcpy(Str4,"A dining room"); break;
262   case RS_SECRETPASSAGE: strcpy(Str4,"A secret passage"); break;
263   case RS_CLOSET: strcpy(Str4,"A stuffy closet"); break;
264   case RS_ARENA: strcpy(Str4,"The Rampart Arena"); break;
265   case RS_DROWNED_SEWER: strcpy(Str4,"A water-filled sewer node"); break;
266   case RS_DRAINED_SEWER: strcpy(Str4,"An unused sewer node"); break;
267   case RS_SEWER_DUCT: strcpy(Str4,"A winding sewer duct"); break;
268   case RS_DESTINY: strcpy(Str4,"The Halls of Fate"); break;
269   case RS_DRUID: strcpy(Str4,"The Great Henge"); break;
270   case RS_HECATE: strcpy(Str4,"The Church of the Far Side"); break;
271   case RS_SET: strcpy(Str4,"The Temple of the Black Hand"); break;
272   case RS_ATHENA: strcpy(Str4,"The Parthenon"); break;
273   case RS_ODIN: strcpy(Str4,"The Shrine of the Noose"); break;
274   case RS_ADEPT: strcpy(Str4,"The Adept's Challenge"); break;
275   case RS_WYRM: strcpy(Str4,"The Sunken Cavern of the Great Wyrm."); break;
276   case RS_OCEAN: strcpy(Str4,"The Underground Ocean."); break;
277   case RS_PONDS: strcpy(Str4,"A series of subterranean pools and streams."); break;
278   case RS_DRAGONLORD: strcpy(Str4,"The Lair of the DragonLord."); break;
279   case RS_GOBLINKING: strcpy(Str4,"The Caves of the Goblins."); break;
280   case RS_CAVERN: strcpy(Str4,"A vast natural cavern."); break;
281   case RS_CORRIDOR: strcpy(Str4,"A dimly lit corridor."); break;
282   case RS_WALLSPACE: strcpy(Str4,"A niche hollowed out of the wall."); break;
283   case ROOMBASE+0: strcpy(Str4,"An abandoned garderobe."); break;
284   case ROOMBASE+1: strcpy(Str4,"A dungeon cell."); break;
285   case ROOMBASE+2: strcpy(Str4,"A tiled chamber."); break;
286   case ROOMBASE+3: strcpy(Str4,"A crystal cavern."); break;
287   case ROOMBASE+4: strcpy(Str4,"Someone's bedroom."); break;
288   case ROOMBASE+5: strcpy(Str4,"An old storeroom."); break;
289   case ROOMBASE+6: strcpy(Str4,"A room with charred walls."); break;
290   case ROOMBASE+7: strcpy(Str4,"A marble hall."); break;
291   case ROOMBASE+8: strcpy(Str4,"An eerie cave."); break;
292   case ROOMBASE+9: strcpy(Str4,"A ransacked treasure-chamber."); break;
293   case ROOMBASE+10: strcpy(Str4,"A smoke-filled room."); break;
294   case ROOMBASE+11: strcpy(Str4,"A well-appointed apartment."); break;
295   case ROOMBASE+12: strcpy(Str4,"An antechamber."); break;
296   case ROOMBASE+13: strcpy(Str4,"An unoccupied harem."); break;
297   case ROOMBASE+14: strcpy(Str4,"A multi-purpose room."); break;
298   case ROOMBASE+15: strcpy(Str4,"A room filled with stalactites."); break;
299   case ROOMBASE+16: strcpy(Str4,"An underground greenhouse."); break;
300   case ROOMBASE+17: strcpy(Str4,"A water closet."); break;
301   case ROOMBASE+18: strcpy(Str4,"A study."); break;
302   case ROOMBASE+19: strcpy(Str4,"A living room."); break;
303   case ROOMBASE+20: strcpy(Str4,"A comfortable den."); break;
304   case ROOMBASE+21: strcpy(Str4,"An abatoir."); break;
305   case ROOMBASE+22: strcpy(Str4,"A boudoir.");break;
306   case ROOMBASE+23: strcpy(Str4,"A star chamber.");break;
307   case ROOMBASE+24: strcpy(Str4,"A manmade cavern."); break;
308   case ROOMBASE+25: strcpy(Str4,"A sewer control room");break;
309   case ROOMBASE+26: strcpy(Str4,"A shrine to High Magic"); break;
310   case ROOMBASE+27: strcpy(Str4,"A magic laboratory"); break;
311   case ROOMBASE+28: strcpy(Str4,"A room with inscribed pentagram");break;
312   case ROOMBASE+29: strcpy(Str4,"A chamber with a blue crystal omega dais");
313     break;
314   default: strcpy(Str4,"A room of mystery and allure."); break;
315   }
316   return(Str4);
317 }
318 
319 
320 
321 /* puts the player on the first set of stairs from the apt level */
322 /* if can't find them, just drops player anywhere.... */
find_stairs(fromlevel,tolevel)323 void find_stairs(fromlevel,tolevel)
324 char fromlevel;
325 char tolevel;
326 {
327   int i,j,found=FALSE;
328   Symbol sitechar;
329   if (fromlevel > tolevel) sitechar = STAIRS_DOWN; else sitechar = STAIRS_UP;
330   for(i=0;i<WIDTH;i++)
331     for(j=0;j<LENGTH;j++)
332       if ((Level->site[i][j].locchar == sitechar) && (! found)) {
333 	found = TRUE;
334 	Player.x = i;
335 	Player.y = j;
336 	break;
337       }
338   if (! found) {
339     findspace(&Player.x,&Player.y,-1);
340     if (Level->environment != E_ASTRAL) {
341       Level->site[Player.x][Player.y].locchar = sitechar;
342       lset(Player.x, Player.y, CHANGED);
343     }
344   }
345 }
346 
347 
348 
install_traps()349 void install_traps()
350 {
351   int i,j;
352   for(i=0;i<WIDTH;i++)
353     for(j=0;j<LENGTH;j++)
354       if ((Level->site[i][j].locchar == FLOOR) &&
355 	  (Level->site[i][j].p_locf == L_NO_OP) &&
356 	  random_range(500) <= ((int)(Level->depth/6)))
357 	Level->site[i][j].p_locf = TRAP_BASE+random_range(NUMTRAPS);
358 }
359 
360 
361 
362 /* x, y, is top left corner, l is length of side, rsi is room string index */
363 /* baux is so all rooms will have a key field. */
build_square_room(x,y,l,rsi,baux)364 void build_square_room(x,y,l,rsi,baux)
365 int x,y,l;
366 char rsi;
367 int baux;
368 {
369   int i,j;
370 
371   for(i=x;i<=x+l;i++)
372     for(j=y;j<=y+l;j++){
373       Level->site[i][j].roomnumber = rsi;
374       Level->site[i][j].buildaux = baux;
375     }
376   for(i=x+1;i<x+l;i++)
377     for(j=y+1;j<y+l;j++) {
378       Level->site[i][j].locchar = FLOOR;
379       Level->site[i][j].p_locf = L_NO_OP;
380     }
381 }
382 
383 
384 
build_room(x,y,l,rsi,baux)385 void build_room(x,y,l,rsi,baux)
386 int x,y,l;
387 char rsi;
388 int baux;
389 {
390   build_square_room(x,y,l,rsi,baux);
391 }
392 
cavern_level()393 void cavern_level()
394 {
395   int i,fx,fy,tx,ty,t,l,e;
396   char rsi;
397 
398   Level->numrooms = 1;
399 
400   if ((Current_Dungeon == E_CAVES) && (Level->depth == CAVELEVELS))
401     rsi = RS_GOBLINKING;
402   else rsi = RS_CAVERN;
403   t = random_range(LENGTH/2);
404   l = random_range(WIDTH/2);
405   e = random_range(WIDTH/8)+WIDTH/8;
406   build_square_room(t,l,e,rsi,0);
407 
408   for (i=0;i<16;i++) {
409     findspace(&tx,&ty,-1);
410     fx = random_range(WIDTH-2)+1;
411     fy = random_range(LENGTH-2)+1;
412     straggle_corridor(fx,fy,tx,ty,FLOOR,RS_CORRIDOR);
413   }
414   while (random_range(3)==1) {
415     findspace(&tx,&ty,-1);
416     fx = random_range(WIDTH-2)+1;
417     fy = random_range(LENGTH-2)+1;
418     straggle_corridor(fx,fy,tx,ty,WATER,RS_PONDS);
419   }
420   if (Current_Dungeon == E_CAVES) {
421     if ((Level->depth == CAVELEVELS) && (! gamestatusp(COMPLETED_CAVES))) {
422       findspace(&tx,&ty,-1);
423       Level->mlist = ((pml) checkmalloc(sizeof(mltype)));
424       Level->mlist->next = NULL;
425       Level->mlist->m =
426 	Level->site[tx][ty].creature =
427 	  ((pmt) make_creature(GOBLIN_KING)); /* goblin king */
428       Level->mlist->m->x = tx;
429       Level->mlist->m->y = ty;
430     }
431   }
432   else if (Current_Environment == E_VOLCANO) {
433     if (Level->depth == VOLCANOLEVELS) {
434       findspace(&tx,&ty,-1);
435       Level->mlist = ((pml) checkmalloc(sizeof(mltype)));
436       Level->mlist->next = NULL;
437       Level->mlist->m =
438 	Level->site[tx][ty].creature =
439 	  ((pmt) make_creature(DEMON_EMP)); /* The dark emp */
440       Level->mlist->m->x = tx;
441       Level->mlist->m->y = ty;
442     }
443   }
444 }
445 
446 
447 
448 
449 
450 
451 
sewer_level()452 void sewer_level()
453 {
454   int i,tx,ty,t,l,e;
455   char rsi;
456   Symbol lchar;
457 
458   Level->numrooms = random_range(3)+3;
459   rsi = RS_DRAINED_SEWER;
460   for (i=0;i<Level->numrooms;i++) {
461     do {
462       t = random_range(LENGTH-10)+1;
463       l = random_range(WIDTH-10)+1;
464       e = 4;
465     } while ((Level->site[l][t].roomnumber == rsi) ||
466 	     (Level->site[l+e][t].roomnumber == rsi) ||
467 	     (Level->site[l][t+e].roomnumber == rsi) ||
468 	     (Level->site[l+e][t+e].roomnumber == rsi));
469     if (random_range(5)) {
470       lchar = FLOOR;
471       rsi = RS_DRAINED_SEWER;
472     }
473     else {
474       lchar = WATER;
475       rsi = RS_DROWNED_SEWER;
476     }
477     build_room(l,t,e,rsi,i);
478     sewer_corridor(l,t,-1,-1,lchar);
479     sewer_corridor(l+e,t,1,-1,lchar);
480     sewer_corridor(l,t+e,-1,1,lchar);
481     sewer_corridor(l+e,t+e,1,1,lchar);
482   }
483   if (Current_Dungeon == E_SEWERS) {
484     if ((Level->depth == SEWERLEVELS) && (! gamestatusp(COMPLETED_SEWERS))) {
485       findspace(&tx,&ty,-1);
486       Level->mlist = ((pml) checkmalloc(sizeof(mltype)));
487       Level->mlist->next = NULL;
488       Level->mlist->m =
489 	Level->site[tx][ty].creature =
490 	  ((pmt) make_creature(GREAT_WYRM)); /* The Great Wyrm */
491       Level->mlist->m->x = tx;
492       Level->mlist->m->y = ty;
493     }
494   }
495 }
496 
497 
498 
sewer_corridor(x,y,dx,dy,locchar)499 void sewer_corridor(x,y,dx,dy,locchar)
500 int x,y,dx,dy;
501 Symbol locchar;
502 {
503   int continuing = TRUE;
504   makedoor(x,y);
505   x+=dx;
506   y+=dy;
507   while(continuing) {
508     Level->site[x][y].locchar = locchar;
509     if (locchar == WATER)
510       Level->site[x][y].p_locf = L_WATER;
511     else Level->site[x][y].p_locf = L_NO_OP;
512     Level->site[x][y].roomnumber = RS_SEWER_DUCT;
513     x+=dx;
514     y+=dy;
515   if (locchar == WATER)
516     continuing = (inbounds(x,y) &&
517 		  ((Level->site[x][y].locchar == WALL) ||
518 		   (Level->site[x][y].locchar == WATER)));
519   else
520     continuing = (inbounds(x,y) &&
521 		  ((Level->site[x][y].roomnumber == RS_WALLSPACE) ||
522 		   (Level->site[x][y].roomnumber == RS_SEWER_DUCT)));
523   }
524   if (inbounds(x,y))
525     makedoor(x,y);
526 }
527 
528 
529 
530 
install_specials()531 void install_specials()
532 {
533   int i,j,x,y;
534 
535   for(x=0;x<WIDTH;x++)
536     for(y=0;y<LENGTH;y++)
537       if ((Level->site[x][y].locchar == FLOOR) &&
538 	  (Level->site[x][y].p_locf == L_NO_OP) &&
539 	  (random_range(300) < difficulty())) {
540 	i = random_range(100);
541 	if (i < 10) {
542 	  Level->site[x][y].locchar = ALTAR;
543 	  Level->site[x][y].p_locf = L_ALTAR;
544 	  Level->site[x][y].aux = random_range(10);
545 	}
546 	else if (i < 20) {
547 	  Level->site[x][y].locchar = WATER;
548 	  Level->site[x][y].p_locf = L_MAGIC_POOL;
549 	}
550 	else if (i < 35) {
551 	  Level->site[x][y].locchar = RUBBLE;
552 	  Level->site[x][y].p_locf = L_RUBBLE;
553 	}
554 	else if (i < 40) {
555 	  Level->site[x][y].locchar = LAVA;
556 	  Level->site[x][y].p_locf = L_LAVA;
557 	}
558 	else if (i < 45) {
559 	  Level->site[x][y].locchar = FIRE;
560 	  Level->site[x][y].p_locf = L_FIRE;
561 	}
562 	else if ((i < 50) && (Current_Environment != E_ASTRAL)) {
563 	  Level->site[x][y].locchar = LIFT;
564 	  Level->site[x][y].p_locf = L_LIFT;
565 	}
566 	else if ((i < 55) && (Current_Environment != E_VOLCANO)) {
567 	  Level->site[x][y].locchar = HEDGE;
568 	  Level->site[x][y].p_locf = L_HEDGE;
569 	}
570 	else if (i < 57) {
571 	  Level->site[x][y].locchar = HEDGE;
572 	  Level->site[x][y].p_locf = L_TRIFID;
573 	}
574 	else if (i< 70) {
575 	  Level->site[x][y].locchar = STATUE;
576 	  if (random_range(100) < difficulty())
577 	    for (j=0;j<8;j++) {
578 	      if (Level->site[x+Dirs[0][j]][y+Dirs[1][j]].p_locf != L_NO_OP)
579 		Level->site[x+Dirs[0][j]][y+Dirs[1][j]].locchar = FLOOR;
580 	      Level->site[x+Dirs[0][j]][y+Dirs[1][j]].p_locf =
581 		L_STATUE_WAKE;
582 	    }
583 	}
584 	else {
585 	  if (Current_Environment == E_VOLCANO) {
586 	    Level->site[x][y].locchar = LAVA;
587 	    Level->site[x][y].p_locf = L_LAVA;
588 	  }
589 	  else if (Current_Environment == E_ASTRAL) {
590 	    if (Level->depth == 1) {
591 	      Level->site[x][y].locchar = RUBBLE;
592 	      Level->site[x][y].p_locf = L_RUBBLE;
593 	    }
594 	    else if (Level->depth == 2) {
595 	      Level->site[x][y].locchar = FIRE;
596 	      Level->site[x][y].p_locf = L_FIRE;
597 	    }
598 	    else if (Level->depth == 3) {
599 	      Level->site[x][y].locchar = WATER;
600 	      Level->site[x][y].p_locf = L_WATER;
601 	    }
602 	    else if (Level->depth == 4) {
603 	      Level->site[x][y].locchar = ABYSS;
604 	      Level->site[x][y].p_locf = L_ABYSS;
605 	    }
606 	  }
607 	  else {
608 	    Level->site[x][y].locchar = WATER;
609 	    Level->site[x][y].p_locf = L_WATER;
610 	  }
611 	}
612       }
613 }
614