Ticket #156: generate.c

File generate.c, 114.1 kB (added by takkaria, 1 year ago)

New generate.c for V 2.9.3

Line 
1
2 /* File: generate.c */
3
4 /*
5  * Dungeon generation
6  *
7  * Code for making, stocking, and populating levels when generated. 
8  * Includes rooms of every kind, pits, vaults (inc. interpretation of
9  * vault.txt), streamers, tunnelling, etc.  Level feelings and other
10  * messages, autoscummer behavior.  Creation of the town.
11  *
12  * Copyright (c) 2001 Ben Harrison, James E. Wilson, Robert A. Koeneke
13  *
14  * This software may be copied and distributed for educational, research,
15  * and not for profit purposes provided that this copyright and statement
16  * are included in all such copies.  Other copyrights may also apply.
17  */
18
19 #include "angband.h"
20
21
22
23 /*
24  * Level generation is not an important bottleneck, though it can be
25  * annoyingly slow on older machines...  Thus we emphasize simplicity
26  * and correctness over speed.  See individual functions for notes.
27  *
28  * This entire file is only needed for generating levels.
29  * This may allow smart compilers to only load it when needed.
30  *
31  * The "vault.txt" file is used to store vault generation info.
32  */
33
34
35 /*
36  * Dungeon generation values
37  */
38 #define DUN_ROOMS                       30      /* Number of rooms to attempt */
39 #define DEST_LEVEL_CHANCE       30      /* 1/chance of being a destroyed level */
40
41
42 /*
43  * Dungeon tunnel generation values
44  */
45 #define DUN_TUN_RND     30      /* 1 in # chance of random direction */
46 #define DUN_TUN_ADJ     10      /* 1 in # chance of adjusting direction */
47 #define DUN_TUN_PEN     35      /* Chance of doors at room entrances */
48 #define DUN_TUN_JCT     70     /* Chance of doors at tunnel junctions */
49
50 /*
51  * Dungeon streamer generation values
52  */
53 #define DUN_STR_WID     2       /* Width of streamers (can sometimes be higher) */
54 #define DUN_STR_MAG     3       /* Number of magma streamers */
55 #define DUN_STR_MC      70      /* 1/chance of treasure per magma */
56 #define DUN_STR_QUA     2       /* Number of quartz streamers */
57 #define DUN_STR_QC      35      /* 1/chance of treasure per quartz */
58 #define DUN_STR_CHG     16      /* 1/(4 + chance) of altering direction */
59
60 /*
61  * Dungeon treasure allocation values
62  */
63 #define DUN_AMT_ROOM    9       /* Amount of objects for rooms */
64 #define DUN_AMT_ITEM    3       /* Amount of objects for rooms/corridors */
65 #define DUN_AMT_GOLD    3       /* Amount of treasure for rooms/corridors */
66
67 /*
68  * Hack -- Dungeon allocation "places"
69  */
70 #define ALLOC_SET_CORR          1       /* Hallway */
71 #define ALLOC_SET_ROOM          2       /* Room */
72 #define ALLOC_SET_BOTH          3       /* Anywhere */
73
74 /*
75  * Hack -- Dungeon allocation "types"
76  */
77 #define ALLOC_TYP_RUBBLE        1       /* Rubble */
78 #define ALLOC_TYP_TRAP          3       /* Trap */
79 #define ALLOC_TYP_GOLD          4       /* Gold */
80 #define ALLOC_TYP_OBJECT        5       /* Object */
81
82
83 /*
84  * Maximum numbers of rooms along each axis (currently 6x18)
85  */
86 #define MAX_ROOMS_ROW   (DUNGEON_HGT / BLOCK_HGT)
87 #define MAX_ROOMS_COL   (DUNGEON_WID / BLOCK_WID)
88
89 /*
90  * Maximal number of room types
91  */
92 #define ROOM_MAX        8
93
94 /*
95  * Bounds on some arrays used in the "dun_data" structure.
96  * These bounds are checked, though usually this is a formality.
97  */
98 #define CENT_MAX        DUN_ROOMS
99 #define DOOR_MAX        100
100 #define WALL_MAX        40
101 #define TUNN_MAX        300
102 #define STAIR_MAX       30
103
104 /*
105  * Simple structure to hold a map location
106  */
107 typedef struct coord coord;
108
109 struct coord
110 {
111         byte y;
112         byte x;
113 };
114
115 /*
116  * Structure to hold all dungeon generation data
117  */
118
119 typedef struct dun_data dun_data;
120
121 struct dun_data
122 {
123         /* Array of centers of rooms */
124         int cent_n;
125         coord cent[CENT_MAX];
126
127         /* Array to store whether rooms are connected or not. */
128         bool connected[CENT_MAX];
129
130         /* Array of possible door locations */
131         int door_n;
132         coord door[DOOR_MAX];
133
134         /* Array of wall piercing locations */
135         int wall_n;
136         coord wall[WALL_MAX];
137
138         /* Array of tunnel grids */
139         int tunn_n;
140         coord tunn[TUNN_MAX];
141
142         /* Array of good potential stair grids */
143         int stair_n;
144         coord stair[STAIR_MAX];
145
146         /* Number of blocks along each axis */
147         int row_rooms;
148         int col_rooms;
149
150         /* Array to store block usage */
151         int room_map[MAX_ROOMS_ROW][MAX_ROOMS_COL];
152 };
153
154 /*
155  * Dungeon generation data -- see "cave_gen()"
156  */
157 static dun_data *dun;
158
159
160 /*
161  * Room type information
162  */
163 typedef struct room_data room_data;
164
165 struct room_data
166 {
167         /* Allocation information. */
168         s16b room_gen_num[11];
169
170         /* Minimum level on which room can appear. */
171         byte min_level;
172 };
173
174 /*
175  * Table of values that control how many times each type of room will,
176  * on average, appear on 100 levels at various depths.  Each type of room
177  * has its own row, and each column corresponds to dungeon levels 0, 10,
178  * 20, and so on.  The final value is the minimum depth the room can appear
179  * at.  -LM-
180  *
181  * Level 101 and below use the values for level 100.
182  *
183  * Rooms with lots of monsters or loot may not be generated if the object or
184  * monster lists are already nearly full.  Rooms will not appear above their
185  * minimum depth.  No type of room (other than type 1) can appear more than
186  * DUN_ROOMS/2 times in any level.
187  *
188  * The entries for room type 1 are blank because these rooms are built once
189  * all other rooms are finished -- until the level fills up, or the room
190  * count reaches the limit (DUN_ROOMS).
191  */
192 static room_data room[ROOM_MAX] =
193 {
194    /* Depth:          0   10   20   30   40   50   60   70   80   90  100   min */
195
196    /* Nothing */  {{  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0 },  0 },
197    /* Simple */   {{  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0 },  0 },
198    /* Overlap */  {{ 60,  80, 100, 120, 140, 165, 180, 200, 220, 240, 260 },  1 },
199    /* Cross */    {{  0,  25,  50,  70,  85, 100, 110, 120, 130, 140, 150 },  3 },
200    /* Large */    {{  0,  25,  50,  70,  85, 100, 110, 120, 130, 140, 150 },  3 },
201    /* Pit      */ {{  0,   6,  13,  28,  35,  40,  45,  45,  45,  45,  45 },  5 },
202    /* L. Vault */ {{  0,   1,   4,   9,  16,  27,  40,  55,  70,  80,  90 },  5 },
203    /* G. Vault */ {{  0,   0,   1,   2,   3,   4,   6,   7,   8,  10,  12 }, 20 }
204 };
205
206
207
208 /*
209  * This table takes a depth, and returns a suitable monster symbol.  Depth
210  * input is assumed to be player depth.  It is also assumed that monsters
211  * can be generated slightly out of depth.  -LM-
212  *
213  * Depths greater than 60 should map to the row for level 60.
214  *
215  * - Symbol '*' is any creature of a randomly-chosen racial char.
216  * - Symbol '1' is any animal.
217  * - Symbol '2' is any insect ('a', 'c', 'l', 'F', 'I', 'K').
218  * - Symbol '3' is any naga, snake, hydra, or other reptile.
219  * - Symbol '4' is any jelly, mold, icky thing ('i', 'j', or 'm').
220  *
221  * - Symbol '%' is any orc, ogre, troll, or giant.
222  * - Symbol 'N' is any undead.  Upon occasion, deep in the dungeon, the
223  *   racial type may be forced to 'G', 'L', 'V', or 'W'.
224  * - Symbols 'p' and 'h' may sometimes be found in combination.  If they
225  *   are, they are usually all of a given class (magical, pious, natural,
226  *   assassination/thievery, or warrior)
227  * - Symbols 'E' and 'v' may be found in combination.  If they are, they
228  *   will always be of a given elemental type.
229  * - Symbols 'd' and 'D' both mean dragons of either char.  Dragons are
230  *   often of a particular type (blue, red, gold, shadow/ethereal etc.).
231  * - Symbols 'u' and 'U' may mean lesser demons, greater demons, or both,
232  *   depending on depth.
233  * - Symbol 'A' is angels.
234  *
235  * - Other symbols usually represent specific racial characters.
236  *
237  * 80% of the time, one of the first seven characters will be chosen. 
238  * 20% of the time, one of the last six will be.
239  */
240 static char mon_symbol_at_depth[12][13] =
241 {
242         /*      common pits                            rare pits         */
243
244         /* Levels 5, 10, 15, and 20 */
245         {'1', '1', '4', '4', '4', 'k', 'y',   '*', '*', '2', 'a', '3', 'S' },
246         {'1', '4', '4', 'o', 'o', 'N', '2',   '*', 'C', 'f', 'a', '3', 'S' },
247         {'1', '4', 'o', 'o', 'o', 'u', '*',   '#', '#', 'S', 'E', '3', 'Z' },
248         {'1', '4', '4', 'o', 'T', 'T', '#',   'p', 'h', 'f', '2', '*', 'Z' },
249
250         /* Levels 25, 30, 35, and 40 */
251         {'1', '4', 'T', 'T', 'u', 'P', 'P',   'p', 'v', 'd', '2', 'S', '3' },
252         {'1', '1', 'T', 'P', 'P', 'N', 'd',   'p', 'h', 'f', 'v', 'g', 'Z' },
253         {'1', '4', 'T', 'P', 'N', 'u', 'd',   'p', 'H', 'E', '2', '*', '3' },
254         {'1', '1', 'T', 'P', 'N', 'u', 'd',   'p', 'h', 'g', 'E', '*', 'Z' },
255
256         /* Levels 45, 50, 55, and 60 */
257         {'1', 'P', 'N', 'u', 'd', 'd', '*',   'p', 'h', 'v', 'E', '*', 'Z' },
258         {'N', 'N', 'U', 'U', 'D', 'D', '*',   'p', 'h', 'v', 'T', 'B', 'Z' },
259         {'1', 'N', 'U', 'U', 'D', 'D', '*',   'p', 'h', 'W', 'G', '*', 'Z' },
260         {'N', 'N', 'U', 'U', 'D', 'D', '*',   'p', 'h', 'v', '*', 'D', 'Z' }
261 };
262
263 /*
264  * Restrictions on monsters, used in pits, etc.
265  */
266 static bool allow_unique;
267 static char d_char_req[10];
268 static byte d_attr_req[4];
269 static u32b racial_flag_mask;
270 static u32b breath_flag_mask;
271
272
273
274 /*
275  * Table of monster descriptions.  Used to make descriptions for kinds
276  * of pits and rooms of chambers that have no special names.
277  */
278 cptr d_char_req_desc[] =
279 {
280         "B:bird",
281         "C:canine",
282         "D:dragon",
283         "E:elemental",
284         "F:dragon fly",
285         "G:ghost",
286         "H:hybrid",
287         "I:insect",
288         "J:snake",
289         "K:killer beetle",
290         "L:lich",
291         "M:multi-headed hydra",
292         "O:ogre",
293         "P:giant",
294         "Q:quylthulg",
295         "R:reptile",
296         "S:spider",
297         "T:troll",
298         "U:demon",
299         "V:vampire",
300         "W:wraith",
301         "Y:yeti",
302         "Z:zephyr hound",
303         "a:ant",
304         "b:bat",
305         "c:centipede",
306         "d:dragon",
307         "e:floating eye",
308         "f:feline",
309         "g:golem",
310         "h:humanoid",
311         "i:icky thing",
312         "j:jelly",
313         "k:kobold",
314         "l:louse",
315         "m:mold",
316         "n:naga",
317         "o:orc",
318         "p:human",
319         "q:quadruped",
320         "r:rodent",
321         "s:skeleton",
322         "t:townsperson",
323         "u:demon",
324         "v:vortex",
325         "w:worm",
326         "y:yeek",
327         "z:zombie",
328         ",:mushroom patch",
329         NULL
330 };
331
332
333
334
335 /**************************************************************/
336 /*                                                            */
337 /*                 The monster-selection code                 */
338 /*                                                            */
339 /**************************************************************/
340
341
342 /*
343  * Use various selection criteria (set elsewhere) to restrict monster
344  * generation.
345  *
346  * This function is capable of selecting monsters by:
347  *   - racial symbol (may be any of the characters allowed)
348  *   - symbol color (may be any of up to four colors).
349  *   - racial flag(s) (monster may have any allowed flag)
350  *   - breath flag(s) (monster must have exactly the flags specified)
351  *
352  * Uniques may be forbidden, or allowed on rare occasions.
353  *
354  * Some situations (like the elemental war themed level) require special
355  * processing; this is done in helper functions called from this one.
356  */
357 static bool mon_select(int r_idx)
358 {
359         monster_race *r_ptr = &r_info[r_idx];
360         bool ok = FALSE;
361
362
363         /* Require that the monster symbol be correct. */
364         if (d_char_req[0] != '\0')
365         {
366                 if (strchr(d_char_req, r_ptr->d_char) == 0) return (FALSE);
367         }
368
369         /* Require correct racial type. */
370         if (racial_flag_mask)
371         {
372                 if (!(r_ptr->flags3 & (racial_flag_mask))) return (FALSE);
373
374                 /* Hack -- no invisible undead until deep. */
375                 if ((p_ptr->depth < 40) && (r_ptr->flags3 & (RF3_UNDEAD)) &&
376                         (r_ptr->flags2 & (RF2_INVISIBLE))) return (FALSE);
377         }
378
379         /* Require that monster breaths be exactly those specified. */
380         if (breath_flag_mask)
381         {
382                 if (r_ptr->flags4 != breath_flag_mask) return (FALSE);
383         }
384
385         /* Require that the monster color be correct. */
386         if (d_attr_req[0])
387         {
388                 /* Check all allowed colors, if given. */
389                 if ((d_attr_req[0]) && (r_ptr->d_attr == d_attr_req[0])) ok = TRUE;
390                 if ((d_attr_req[1]) && (r_ptr->d_attr == d_attr_req[1])) ok = TRUE;
391                 if ((d_attr_req[2]) && (r_ptr->d_attr == d_attr_req[2])) ok = TRUE;
392                 if ((d_attr_req[3]) && (r_ptr->d_attr == d_attr_req[3])) ok = TRUE;
393
394                 /* Hack -- No multihued dragons allowed in the arcane dragon pit. */
395                 if ((strchr(d_char_req, 'd') || strchr(d_char_req, 'D')) &&
396                         (d_attr_req[0] == TERM_VIOLET) &&
397                         (r_ptr->flags4 == (RF4_BR_ACID |
398                                 RF4_BR_ELEC | RF4_BR_FIRE |
399                                 RF4_BR_COLD | RF4_BR_POIS)))
400                 {
401                         return (FALSE);
402                 }
403
404                 /* Doesn't match any of the given colors?  Not good. */
405                 if (!ok) return (FALSE);
406         }
407
408         /* Usually decline unique monsters. */
409         if (r_ptr->flags1 & (RF1_UNIQUE))
410         {
411                 if (!allow_unique) return (FALSE);
412                 else if (rand_int(5) != 0) return (FALSE);
413         }
414
415         /* Okay */
416         return (TRUE);
417 }
418
419
420 /*
421  * Accept characters representing a race or group of monsters and
422  * an (adjusted) depth, and use these to set values for required racial
423  * type, monster symbol, monster symbol color, and breath type.  -LM-
424  *
425  * This function is called to set restrictions, point the monster
426  * allocation function to "mon_select()", and remake monster allocation. 
427  * It undoes all of this things when called with the symbol '\0'.
428  *
429  * Describe the monsters (used by cheat_room) and determine if they
430  * should be neatly ordered or randomly placed (used in monster pits).
431  */
432 static char *mon_restrict(char symbol, byte depth, bool *ordered, bool unique_ok)
433 {
434         int i, j;
435
436         /* Assume no definite name */
437         char name[80] = "misc";
438
439         /* Clear global monster restriction variables. */
440         allow_unique = unique_ok;
441         for (i = 0; i < 10; i++) d_char_req[i] = '\0';
442         for (i = 0; i < 4; i++) d_attr_req[i] = 0;
443         racial_flag_mask = 0; breath_flag_mask = 0;
444
445
446         /* No symbol, no restrictions. */
447         if (symbol == '\0')
448         {
449                 get_mon_num_hook = NULL;
450                 get_mon_num_prep();
451                 return ("misc");
452         }
453
454         /* Handle the "wild card" symbol '*'  */
455         if (symbol == '*')
456         {
457                 for (i = 0; i < 2500; i++)
458                 {
459                         /* Get a random monster. */
460                         j = randint(z_info->r_max - 1);
461
462                         /* Must be a real monster */
463                         if (!r_info[j].rarity) continue;
464
465                         /* Try for close to depth, accept in-depth if necessary */
466                         if (i < 200)
467                         {
468                                 if ((!(r_info[j].flags1 & RF1_UNIQUE)) &&
469                                       (r_info[j].level != 0) &&
470                                       (r_info[j].level <= depth) &&
471                                       (ABS(r_info[j].level - p_ptr->depth) <
472                                       1 + (p_ptr->depth / 4))) break;
473                         }
474                         else
475                         {
476                                 if ((!(r_info[j].flags1 & RF1_UNIQUE)) &&
477                                       (r_info[j].level != 0) &&
478                                       (r_info[j].level <= depth)) break;
479                         }
480                 }
481
482                 /* We've found a monster. */
483                 if (i < 2499)
484                 {
485                         /* ...use that monster's symbol for all monsters. */
486                         symbol = r_info[j].d_char;
487                 }
488                 else
489                 {
490                         /* Paranoia - pit stays empty if no monster is found */
491                         return (NULL);
492                 }
493         }
494
495         /* Apply monster restrictions according to symbol. */
496         switch (symbol)
497         {
498                 /* All animals */
499                 case '1':
500                 {
501                         strcpy(name, "animal");
502                         racial_flag_mask = RF3_ANIMAL;
503                         *ordered = FALSE;
504                         break;
505                 }
506
507                 /* Insects */
508                 case '2':
509                 {
510                         strcpy(name, "insect");
511                         strcpy(d_char_req, "aclFIK");
512                         *ordered = FALSE;
513                         break;
514                 }
515
516                 /* Reptiles */
517                 case '3':
518                 {
519                         strcpy(name, "reptile");
520                         strcpy(d_char_req, "nJRM");
521                         *ordered = FALSE;
522                         break;
523                 }
524
525                 /* Jellies, etc. */
526                 case '4':
527                 {
528                         strcpy(name, "jelly");
529                         strcpy(d_char_req, "ijm,");
530                         *ordered = FALSE;
531                         break;
532                 }
533
534                 /* Humans and humaniods */
535                 case 'p':
536                 case 'h':
537                 {
538                         /* 'p's and 'h's can coexist. */
539                         if (rand_int(3) == 0)
540                         {
541                                 strcpy(d_char_req, "ph");
542
543                                 /* If so, they will usually all be of similar classes. */
544                                 if (rand_int(4) != 0)
545                                 {
546                                         /* Randomizer. */
547                                         i = rand_int(5);
548
549                                         /* Magicians and necromancers */
550                                         if (i == 0)
551                                         {
552                                                 d_attr_req[0] = TERM_RED;
553                                                 d_attr_req[1] = TERM_L_RED;
554                                                 d_attr_req[2] = TERM_VIOLET;
555                                                 strcpy(name, "school of sorcery");
556                                         }
557                                         /* Priests and paladins */
558                                         else if (i == 1)
559                                         {
560                                                 d_attr_req[0] = TERM_GREEN;
561                                                 d_attr_req[1] = TERM_L_GREEN;
562                                                 d_attr_req[2] = TERM_WHITE;
563                                                 d_attr_req[3] = TERM_L_WHITE;
564                                                 strcpy(name, "temple of piety");
565                                         }
566                                         /* Druids and ninjas */
567                                         else if (i == 2)
568                                         {
569                                                 d_attr_req[0] = TERM_ORANGE;
570                                                 d_attr_req[1] = TERM_YELLOW;
571                                                 strcpy(name, "gathering of nature");
572                                         }
573                                         /* Thieves and assassins */
574                                         else if (i == 3)
575                                         {
576                                                 d_attr_req[0] = TERM_BLUE;
577                                                 d_attr_req[1] = TERM_L_BLUE;
578                                                 d_attr_req[2] = TERM_SLATE;
579                                                 d_attr_req[3] = TERM_L_DARK;
580                                                 strcpy(name, "den of thieves");
581                                         }
582                                         /* Warriors and rangers */
583                                         else
584                                         {
585                                                 d_attr_req[0] = TERM_UMBER;
586                                                 d_attr_req[1] = TERM_L_UMBER;
587                                                 strcpy(name, "fighter's hall");
588                                         }
589                                 }
590                                 else
591                                 {
592                                         strcpy(name, "humans and humaniods");
593                                 }
594                         }
595
596                         /* Usually, just accept the symbol. */
597                         else
598                         {
599                                 d_char_req[0] = symbol;
600
601                                 if (symbol == 'p') strcpy(name, "human");
602                                 else if (symbol == 'h') strcpy(name, "humanoid");
603                         }
604
605                         *ordered = FALSE;
606                         break;
607                 }
608
609                 /* Orcs */
610                 case 'o':
611                 {
612                         strcpy(name, "orc");
613                         strcpy(d_char_req, "o");
614                         *ordered = TRUE;
615                         break;
616                 }
617
618                 /* Trolls */
619                 case 'T':
620                 {
621                         strcpy(name, "troll");
622                         strcpy(d_char_req, "T");
623                         *ordered = TRUE;
624                         break;
625                 }
626
627                 /* Giants (sometimes ogres at low levels) */
628                 case 'P':
629                 {
630                         strcpy(name, "giant");
631                         if ((p_ptr->depth < 30) && (rand_int(3) == 0))
632                              strcpy(d_char_req, "O");
633                         else strcpy(d_char_req, "P");
634                         *ordered = TRUE;
635                         break;
636                 }
637
638                 /* Orcs, ogres, trolls, or giants */
639                 case '%':
640                 {
641                         strcpy(name, "moria");
642                         strcpy(d_char_req, "oOPT");
643                         *ordered = FALSE;
644                         break;
645                 }
646
647                 /* Monsters found in caves */
648                 case '0':
649                 {
650                         strcpy(name, "dungeon monsters");
651                         strcpy(d_char_req, "ykoOT");
652                         *ordered = FALSE;
653                         break;
654                 }
655
656
657
658                 /* Undead */
659                 case 'N':
660                 {
661                         /* Sometimes, restrict by symbol. */
662                         if ((depth > 40) && (rand_int(3) == 0))
663                         {
664                                 for (i = 0; i < 500; i++)
665                                 {
666                                         /* Find a suitable monster near depth. */
667                                         j = randint(z_info->r_max - 1);
668
669                                         /* Require a non-unique undead. */
670                                         if ((r_info[j].flags3 & RF3_UNDEAD) &&
671                                             (!(r_info[j].flags1 & RF1_UNIQUE)) &&
672                                             (strchr("GLWV", r_info[j].d_char)) &&
673                                             (ABS(r_info[j].level - p_ptr->depth) <
674                                             1 + (p_ptr->depth / 4)))
675                                         {
676                                                 break;
677                                         }
678                                 }
679
680                                 /* If we find a monster, */
681                                 if (i < 499)
682                                 {
683                                         /* Use that monster's symbol for all monsters */
684                                         d_char_req[0] = r_info[j].d_char;
685
686                                         /* No pit name (yet) */
687
688                                         /* In this case, we do order the monsters */
689                                         *ordered = TRUE;
690                                 }
691                                 else
692                                 {
693                                         /* Accept any undead. */
694                                         strcpy(name, "undead");
695                                         racial_flag_mask = RF3_UNDEAD;
696                                         *ordered = FALSE;
697                                 }
698                         }
699                         else
700                         {
701                                 /* No restrictions on symbol. */
702                                 strcpy(name, "undead");
703                                 racial_flag_mask = RF3_UNDEAD;
704                                 *ordered = FALSE;
705                         }
706                         break;
707                 }
708
709                 /* Demons */
710                 case 'u':
711                 case 'U':
712                 {
713                         strcpy(name, "demon");
714                         if (depth > 55)      strcpy(d_char_req, "U");
715                         else if (depth < 40) strcpy(d_char_req, "u");
716                         else                 strcpy(d_char_req, "uU");
717                         *ordered = TRUE;
718                         break;
719                 }
720
721                 /* Dragons */
722                 case 'd':
723                 case 'D':
724                 {
725                         strcpy(d_char_req, "dD");
726
727                         /* Dragons usually associate with others of their kind. */
728                         if (rand_int(6) != 0)
729                         {
730                                 /* Dragons of a single kind are ordered. */
731                                 *ordered = TRUE;
732
733                                 /* Some dragon types are not found everywhere */
734                                 if (depth > 70) i = rand_int(35);
735                                 else if (depth > 45) i = rand_int(32);
736                                 else if (depth > 32) i = rand_int(30);
737                                 else if (depth > 23) i = rand_int(28);
738                                 else i = rand_int(24);
739
740                                 if (i < 4)
741                                 {
742                                         breath_flag_mask = (RF4_BR_ACID);
743                                         strcpy(name, "dragon - acid");
744                                 }
745                                 else if (i < 8)
746