Changeset 306

Show
Ignore:
Timestamp:
07/08/07 14:07:51 (1 year ago)
Author:
takkaria
Message:

Commit a patched-up version of Leon's dungeon patch. This probably makes the svn decidedly "beta". (closes #156)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/edit/vault.txt

    r305 r306  
    2121 
    2222# 'X' is for extra information - room type, rating, rows, and 
    23 # columns. Lesser vaults are room type 7 and have a maximum x-y size 
    24 # of 33x22; greater vaults are room type 8 and have a maximum size of 66x44. 
     23# columns. Lesser vaults are room type 6 and have a maximum x-y size 
     24# of 33x22; greater vaults are room type 7 and have a maximum size of 66x44. 
    2525 
    2626# 'D' lines describe the layout of the vault. Lines must be padded 
     
    5050 
    5151 
    52 ### Simple Vaults (type 7) -- maximum size 44x22 ### 
     52### Simple Vaults (type 6) -- maximum size 44x22 ### 
    5353 
    5454 
    5555N:1:round 
    56 X:7:5:12:20 
     56X:6:5:12:20 
    5757D:       %%%%%%        
    5858D:    %%%..##..%%%     
     
    7070 
    7171N:2:octagon 
    72 X:7:5:14:20 
     72X:6:5:14:20 
    7373D:   %%%%%%%%%%%%%%    
    7474D:  %%.##########.%%   
     
    8888 
    8989N:3:octagon 
    90 X:7:5:12:20 
     90X:6:5:12:20 
    9191D:    %%%%%%%%%%%%     
    9292D: %%%%..........%%%%  
     
    104104 
    105105N:4:square 
    106 X:7:5:12:20 
     106X:6:5:12:20 
    107107D:%%%%%%%%%%%%%%%%%%%% 
    108108D:%*.......&........*% 
     
    120120 
    121121N:5:diagonal 
    122 X:7:5:12:20 
     122X:6:5:12:20 
    123123D:%%%%%%%%%%%%%%%%%    
    124124D:%,,,##,,,,##....%%   
     
    136136 
    137137N:6:diagonal 
    138 X:7:5:12:20 
     138X:6:5:12:20 
    139139D:   %%%%%%%%%%%%%%%%% 
    140140D:  %%....##,,,,##,,,% 
     
    152152 
    153153N:7:square 
    154 X:7:5:12:20 
     154X:6:5:12:20 
    155155D:%%%%%%%%%%%%%%%%%%%% 
    156156D:%,################,% 
     
    168168 
    169169 
    170 ### Greater vaults (type 8) -- maximum size 66x44 ### 
     170### Greater vaults (type 7) -- maximum size 66x44 ### 
    171171 
    172172 
    173173N:10:huge 
    174 X:8:45:17:39 
     174X:7:45:17:39 
    175175D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    176176D:%XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX% 
     
    193193 
    194194N:11:large 
    195 X:8:35:18:40 
     195X:7:35:18:40 
    196196D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    197197D:%XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX% 
     
    215215 
    216216N:12:butterfly 
    217 X:8:25:18:40 
     217X:7:25:18:40 
    218218D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    219219D:%XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX% 
     
    237237 
    238238N:13:chambers 
    239 X:8:25:15:40 
     239X:7:25:15:40 
    240240D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    241241D:%&+.^..^..^..^..^..^..^..^..^..^..^..+&% 
     
    256256 
    257257N:14:Planet X 
    258 X:7:10:13:15 
     258X:6:10:13:15 
    259259D:%%%%%%%%%%%%%%% 
    260260D:%.............% 
     
    273273 
    274274N:15:Turnabout 
    275 X:7:10:12:15 
     275X:6:10:12:15 
    276276D:############### 
    277277D:#.............# 
     
    289289 
    290290N:16:Rooms 
    291 X:7:10:13:19 
     291X:6:10:13:19 
    292292D:%%%%%%%%%%%%%%%%%%% 
    293293D:%.................% 
     
    306306 
    307307N:17:Cross 
    308 X:7:10:13:20 
     308X:6:10:13:20 
    309309D:%%%%%%%%%%%%%%%%%%%% 
    310310D:%########++########% 
     
    323323 
    324324N:18:Central 
    325 X:7:12:10:12 
     325X:6:12:10:12 
    326326D:############ 
    327327D:#,#^^^^^^#,# 
     
    337337 
    338338N:19:Camouflaged 
    339 X:7:10:9:12 
     339X:6:10:9:12 
    340340D:%%%%%%%%%%%% 
    341341D:%XXXXXXXXXX% 
     
    350350 
    351351N:20:The I in the Storm 
    352 X:8:40:25:41 
     352X:7:40:25:41 
    353353D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    354354D:%XXXXXXXXXXXXXXXXXXX#XXXXXXXXXXXXXXXXXXX% 
     
    379379 
    380380N:21:The Bank From Hell 
    381 X:8:30:20:31 
     381X:7:30:20:31 
    382382D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    383383D:%XXXXXXXXXXXXXX+XXXXXXXXXXXXXX% 
     
    403403 
    404404N:22:Snake Maze 
    405 X:8:15:21:23 
     405X:7:15:21:23 
    406406D:%%%%%%%%%%%%%%%%%%%%%%% 
    407407D:%.....................% 
     
    428428 
    429429N:23:Roundabouts One 
    430 X:8:15:21:43 
     430X:7:15:21:43 
    431431D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    432432D:%#XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX% 
     
    453453 
    454454N:24:Roundabout Two 
    455 X:8:25:25:40 
     455X:7:25:25:40 
    456456D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    457457D:%XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX% 
     
    482482 
    483483N:25:Huge - Modified 
    484 X:8:45:17:39 
     484X:7:45:17:39 
    485485D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    486486D:%XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX% 
     
    503503 
    504504N:26:Mirrored Quartet 
    505 X:8:20:21:49 
     505X:7:20:21:49 
    506506D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    507507D:%XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX% 
     
    528528 
    529529N:27:False Wall 
    530 X:8:20:15:64 
     530X:7:20:15:64 
    531531D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    532532D:%X+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX+X% 
     
    547547 
    548548N:28:Divisi 
    549 X:8:35:31:55 
     549X:7:35:31:55 
    550550D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    551551D:%.....................................................% 
     
    582582 
    583583N:29:Curlicues One 
    584 X:8:15:23:44 
     584X:7:15:23:44 
    585585D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    586586D:%XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX% 
     
    609609 
    610610N:30:Bubbles 
    611 X:8:35:25:41 
     611X:7:35:25:41 
    612612D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    613613D:%XXX#XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX% 
     
    638638 
    639639N:31:Symmet 
    640 X:8:20:23:29 
     640X:7:20:23:29 
    641641D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    642642D:%...........................% 
     
    665665 
    666666N:32:Crown 
    667 X:8:12:19:28 
     667X:7:12:19:28 
    668668D:%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    669669D:%..........................% 
     
    688688 
    689689N:33:X^2 
    690 X:7:8:13:15 
     690X:6:8:13:15 
    691691D:%%%%%%%%%%%%%%% 
    692692D:%.............% 
     
    705705 
    706706N:34:V-vault 
    707 X:8:25:23:48 
     707X:7:25:23:48 
    708708D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    709709D:%XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX% 
     
    732732 
    733733N:35:Lesser vault ("Rock-Hard") 
    734 X:7:10:11:20 
     734X:6:10:11:20 
    735735D:%%%%%%%%%%%%%%%%%%%% 
    736736D:%..................% 
     
    747747 
    748748N:36:Lesser vault ("Miniature Cell") 
    749 X:7:5:5:5 
     749X:6:5:5:5 
    750750D:%%%%% 
    751751D:%#9#% 
     
    756756 
    757757N:37:Lesser vault ("Interlock") 
    758 X:7:10:12:17 
     758X:6:10:12:17 
    759759D:%%%%%%%%%%%%%%%%% 
    760760D:%......^^^......% 
     
    772772 
    773773N:38:Lesser vault ("Workaround") 
    774 X:7:14:19:21 
     774X:6:14:19:21 
    775775D:%%%%%%%%%%%%%%%%%%%%% 
    776776D:%...................% 
     
    795795 
    796796N:39:Greater vault ("Twisted Cube") 
    797 X:8:20:24:41 
     797X:7:20:24:41 
    798798D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    799799D:%.......................................% 
     
    823823 
    824824N:40:Greater vault ("Jigsaw") 
    825 X:8:25:16:49 
     825X:7:25:16:49 
    826826D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    827827D:%...............................................% 
     
    843843 
    844844N:41:Greater vault ("Hourglass") 
    845 X:8:24:37:27 
     845X:7:24:37:27 
    846846D:%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    847847D:%.........................% 
     
    885885 
    886886N:42:Greater vault ("Funnel") 
    887 X:8:15:21:23 
     887X:7:15:21:23 
    888888D:%%%%%%%%%%%%%%%%%%%%%%% 
    889889D:%XXXXXXXXXXXXXXXXXXXXX% 
     
    910910 
    911911N:43:Greater vault ("Mazer") 
    912 X:8:26:35:31 
     912X:7:26:35:31 
    913913D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    914914D:%.............................% 
     
    949949 
    950950N:44:Greater vault ("Orb") 
    951 X:8:16:27:27 
     951X:7:16:27:27 
    952952D:%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    953953D:%.........................% 
     
    980980 
    981981N:45:Greater vault ("Interstices") 
    982 X:8:22:19:45 
     982X:7:22:19:45 
    983983D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    984984D:%...........................................% 
     
    10031003 
    10041004N:46:Greater vault ("Sphere") 
    1005 X:8:25:25:47 
     1005X:7:25:25:47 
    10061006D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    10071007D:%.............................................% 
     
    10321032 
    10331033N:47:Greater vault ("Hellpit") 
    1034 X:8:20:19:60 
     1034X:7:20:19:60 
    10351035D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    10361036D:%..........................................................% 
     
    10551055 
    10561056N:48:Greater vault ("Target Practice") 
    1057 X:8:20:20:61 
     1057X:7:20:20:61 
    10581058D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    10591059D:%XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX% 
     
    10791079 
    10801080N:49:Greater vault ("Castle Death") 
    1081 X:8:35:20:60 
     1081X:7:35:20:60 
    10821082D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    10831083D:%XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX% 
     
    11031103 
    11041104N:50:Greater vault ("The Reward is Worth It") 
    1105 X:8:20:16:63 
     1105X:7:20:16:63 
    11061106D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    11071107D:%XXXXXXXXXXXXXXX##XXXXXXXXXXXXX#XXXXXXXXXXXXX##XXXXXXXXXXXXXXX% 
  • trunk/src/dungeon.c

    r291 r306  
    14921492        int i; 
    14931493 
    1494         int py = p_ptr->py; 
    1495         int px = p_ptr->px; 
    14961494 
    14971495 
     
    15471545        } 
    15481546 
    1549  
    1550         /* No stairs down from Quest */ 
    1551         if (is_quest(p_ptr->depth)) 
    1552         { 
    1553                 p_ptr->create_down_stair = FALSE; 
    1554         } 
    1555  
    1556         /* No stairs from town or if not allowed */ 
    1557         if (!p_ptr->depth || adult_no_stairs) 
    1558         { 
    1559                 p_ptr->create_down_stair = p_ptr->create_up_stair = FALSE; 
    1560         } 
    1561  
    1562         /* Make a staircase */ 
    1563         if (p_ptr->create_down_stair || p_ptr->create_up_stair) 
    1564         { 
    1565                 /* Place a staircase */ 
    1566                 if (cave_valid_bold(py, px)) 
    1567                 { 
    1568                         /* XXX XXX XXX */ 
    1569                         delete_object(py, px); 
    1570  
    1571                         /* Make stairs */ 
    1572                         if (p_ptr->create_down_stair) 
    1573                         { 
    1574                                 cave_set_feat(py, px, FEAT_MORE); 
    1575                         } 
    1576                         else 
    1577                         { 
    1578                                 cave_set_feat(py, px, FEAT_LESS); 
    1579                         } 
    1580  
    1581                         /* Mark the stairs as known */ 
    1582                         cave_info[py][px] |= (CAVE_MARK); 
    1583                 } 
    1584  
    1585                 /* Cancel the stair request */ 
    1586                 p_ptr->create_down_stair = p_ptr->create_up_stair = FALSE; 
    1587         } 
    15881547 
    15891548 
  • trunk/src/generate.c

    r305 r306  
    1 /* File: generate.c */ 
    2  
    3 /* 
    4  * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke 
    5  * 
    6  * This software may be copied and distributed for educational, research, 
    7  * and not for profit purposes provided that this copyright and statement 
    8  * are included in all such copies.  Other copyrights may also apply. 
    9  */ 
    10  
     1/* 
     2 * File: generate.c 
     3 * Purpose: Dungeon generation. 
     4 * 
     5 * Code for making, stocking, and populating levels when generated.   
     6 * Includes rooms of every kind, pits, vaults (inc. interpretation of  
     7 * vault.txt), streamers, tunnelling, etc.  Level feelings and other  
     8 * messages, autoscummer behavior.  Creation of the town. 
     9 * 
     10 * Copyright (c) 1997-2001 Ben Harrison, James E. Wilson, Robert A. Koeneke 
     11 * 
     12 * This work is free software; you can redistribute it and/or modify it 
     13 * under the terms of either: 
     14 * 
     15 * a) the GNU General Public License as published by the Free Software 
     16 *    Foundation, version 2, or 
     17 * 
     18 * b) the "Angband licence": 
     19 *    This software may be copied and distributed for educational, research, 
     20 *    and not for profit purposes provided that this copyright and statement 
     21 *    are included in all such copies.  Other copyrights may also apply. 
     22 */ 
    1123#include "angband.h" 
    1224 
    13 #include "script.h" 
    14  
    15  
    16 /* 
    17  * Note that Level generation is *not* an important bottleneck, 
    18  * though it can be annoyingly slow on older machines...  Thus 
    19  * we emphasize "simplicity" and "correctness" over "speed". 
     25 
     26 
     27/* 
     28 * Level generation is not an important bottleneck, though it can be  
     29 * annoyingly slow on older machines...  Thus we emphasize simplicity  
     30 * and correctness over speed.  See individual functions for notes. 
    2031 * 
    2132 * This entire file is only needed for generating levels. 
    2233 * This may allow smart compilers to only load it when needed. 
    2334 * 
    24  * Consider the "vault.txt" file for vault generation. 
    25  * 
    26  * In this file, we use the "special" granite and perma-wall sub-types, 
    27  * where "basic" is normal, "inner" is inside a room, "outer" is the 
    28  * outer wall of a room, and "solid" is the outer wall of the dungeon 
    29  * or any walls that may not be pierced by corridors.  Thus the only 
    30  * wall type that may be pierced by a corridor is the "outer granite" 
    31  * type.  The "basic granite" type yields the "actual" corridors. 
    32  * 
    33  * Note that we use the special "solid" granite wall type to prevent 
    34  * multiple corridors from piercing a wall in two adjacent locations, 
    35  * which would be messy, and we use the special "outer" granite wall 
    36  * to indicate which walls "surround" rooms, and may thus be "pierced" 
    37  * by corridors entering or leaving the room. 
    38  * 
    39  * Note that a tunnel which attempts to leave a room near the "edge" 
    40  * of the dungeon in a direction toward that edge will cause "silly" 
    41  * wall piercings, but will have no permanently incorrect effects, 
    42  * as long as the tunnel can *eventually* exit from another side. 
    43  * And note that the wall may not come back into the room by the 
    44  * hole it left through, so it must bend to the left or right and 
    45  * then optionally re-enter the room (at least 2 grids away).  This 
    46  * is not a problem since every room that is large enough to block 
    47  * the passage of tunnels is also large enough to allow the tunnel 
    48  * to pierce the room itself several times. 
    49  * 
    50  * Note that no two corridors may enter a room through adjacent grids, 
    51  * they must either share an entryway or else use entryways at least 
    52  * two grids apart.  This prevents "large" (or "silly") doorways. 
    53  * 
    54  * To create rooms in the dungeon, we first divide the dungeon up 
    55  * into "blocks" of 11x11 grids each, and require that all rooms 
    56  * occupy a rectangular group of blocks.  As long as each room type 
    57  * reserves a sufficient number of blocks, the room building routines 
    58  * will not need to check bounds.  Note that most of the normal rooms 
    59  * actually only use 23x11 grids, and so reserve 33x11 grids. 
    60  * 
    61  * Note that the use of 11x11 blocks (instead of the 33x11 panels) 
    62  * allows more variability in the horizontal placement of rooms, and 
    63  * at the same time has the disadvantage that some rooms (two thirds 
    64  * of the normal rooms) may be "split" by panel boundaries.  This can 
    65  * induce a situation where a player is in a room and part of the room 
    66  * is off the screen.  This can be so annoying that the player must set 
    67  * a special option to enable "non-aligned" room generation. 
    68  * 
    69  * Note that the dungeon generation routines are much different (2.7.5) 
    70  * and perhaps "DUN_ROOMS" should be less than 50. 
    71  * 
    72  * XXX XXX XXX Note that it is possible to create a room which is only 
    73  * connected to itself, because the "tunnel generation" code allows a 
    74  * tunnel to leave a room, wander around, and then re-enter the room. 
    75  * 
    76  * XXX XXX XXX Note that it is possible to create a set of rooms which 
    77  * are only connected to other rooms in that set, since there is nothing 
    78  * explicit in the code to prevent this from happening.  But this is less 
    79  * likely than the "isolated room" problem, because each room attempts to 
    80  * connect to another room, in a giant cycle, thus requiring at least two 
    81  * bizarre occurances to create an isolated section of the dungeon. 
    82  * 
    83  * Note that (2.7.9) monster pits have been split into monster "nests" 
    84  * and monster "pits".  The "nests" have a collection of monsters of a 
    85  * given type strewn randomly around the room (jelly, animal, or undead), 
    86  * while the "pits" have a collection of monsters of a given type placed 
    87  * around the room in an organized manner (orc, troll, giant, dragon, or 
    88  * demon).  Note that both "nests" and "pits" are now "level dependant", 
    89  * and both make 16 "expensive" calls to the "get_mon_num()" function. 
    90  * 
    91  * Note that the cave grid flags changed in a rather drastic manner 
    92  * for Angband 2.8.0 (and 2.7.9+), in particular, dungeon terrain 
    93  * features, such as doors and stairs and traps and rubble and walls, 
    94  * are all handled as a set of 64 possible "terrain features", and 
    95  * not as "fake" objects (440-479) as in pre-2.8.0 versions. 
    96  * 
    97  * The 64 new "dungeon features" will also be used for "visual display" 
    98  * but we must be careful not to allow, for example, the user to display 
    99  * hidden traps in a different way from floors, or secret doors in a way 
    100  * different from granite walls, or even permanent granite in a different 
    101  * way from granite.  XXX XXX XXX 
     35 * The "vault.txt" file is used to store vault generation info. 
    10236 */ 
    10337 
     
    10640 * Dungeon generation values 
    10741 */ 
    108 #define DUN_ROOMS       50    /* Number of rooms to attempt */ 
    109 #define DUN_UNUSUAL    200     /* Level/chance of unusual room */ 
    110 #define DUN_DEST        30      /* 1/chance of having a destroyed level */ 
     42#define DUN_ROOMS                      30     /* Number of rooms to attempt */ 
     43#define DEST_LEVEL_CHANCE      30      /* 1/chance of being a destroyed level */ 
     44 
    11145 
    11246/* 
    11347 * Dungeon tunnel generation values 
    11448 */ 
    115 #define DUN_TUN_RND     10      /* Chance of random direction */ 
    116 #define DUN_TUN_CHG     30      /* Chance of changing direction */ 
    117 #define DUN_TUN_CON     15      /* Chance of extra tunneling */ 
    118 #define DUN_TUN_PEN     25      /* Chance of doors at room entrances */ 
    119 #define DUN_TUN_JCT     90      /* Chance of doors at tunnel junctions */ 
     49#define DUN_TUN_RND     30      /* 1 in # chance of random direction */ 
     50#define DUN_TUN_ADJ     10      /* 1 in # chance of adjusting direction */ 
     51#define DUN_TUN_PEN     35      /* Chance of doors at room entrances */ 
     52#define DUN_TUN_JCT     70     /* Chance of doors at tunnel junctions */ 
    12053 
    12154/* 
    12255 * Dungeon streamer generation values 
    12356 */ 
    124 #define DUN_STR_DEN     5       /* Density of streamers */ 
    125 #define DUN_STR_RNG     2       /* Width of streamers */ 
     57#define DUN_STR_WID     2       /* Width of streamers (can sometimes be higher) */ 
    12658#define DUN_STR_MAG     3       /* Number of magma streamers */ 
    127 #define DUN_STR_MC      90    /* 1/chance of treasure per magma */ 
     59#define DUN_STR_MC      70    /* 1/chance of treasure per magma */ 
    12860#define DUN_STR_QUA     2       /* Number of quartz streamers */ 
    129 #define DUN_STR_QC      40      /* 1/chance of treasure per quartz */ 
    130  
    131 /* 
    132  * Dungeon treausre allocation values 
     61#define DUN_STR_QC      35      /* 1/chance of treasure per quartz */ 
     62#define DUN_STR_CHG     16      /* 1/(4 + chance) of altering direction */ 
     63 
     64/* 
     65 * Dungeon treasure allocation values 
    13366 */ 
    13467#define DUN_AMT_ROOM    9       /* Amount of objects for rooms */ 
     
    15285 
    15386 
    154  
    15587/* 
    15688 * Maximum numbers of rooms along each axis (currently 6x18) 
     
    15991#define MAX_ROOMS_COL   (DUNGEON_WID / BLOCK_WID) 
    16092 
     93/* 
     94 * Maximal number of room types 
     95 */ 
     96#define ROOM_MAX        8 
    16197 
    16298/* 
     
    164100 * These bounds are checked, though usually this is a formality. 
    165101 */ 
    166 #define CENT_MAX        100 
    167 #define DOOR_MAX        200 
    168 #define WALL_MAX        500 
    169 #define TUNN_MAX        900 
    170  
    171  
    172 /* 
    173  * Maximal number of room types 
    174  */ 
    175 #define ROOM_MAX        9 
    176  
    177  
     102#define CENT_MAX        DUN_ROOMS 
     103#define DOOR_MAX        100 
     104#define WALL_MAX        40 
     105#define TUNN_MAX        300 
     106#define STAIR_MAX       30 
    178107 
    179108/* 
    180109 * Simple structure to hold a map location 
    181110 */ 
    182  
    183111typedef struct coord coord; 
    184112 
     
    189117}; 
    190118 
    191  
    192 /* 
    193  * Room type information 
    194  */ 
    195  
    196 typedef struct room_data room_data; 
    197  
    198 struct room_data 
    199 
    200         /* Required size in blocks */ 
    201         s16b dy1, dy2, dx1, dx2; 
    202  
    203         /* Hack -- minimum level */ 
    204         s16b level; 
    205 }; 
    206  
    207  
    208 /* 
    209  * Structure to hold all "dungeon generation" data 
     119/* 
     120 * Structure to hold all dungeon generation data 
    210121 */ 
    211122 
     
    218129        coord cent[CENT_MAX]; 
    219130 
     131        /* Array to store whether rooms are connected or not. */ 
     132        bool connected[CENT_MAX]; 
     133 
    220134        /* Array of possible door locations */ 
    221135        int door_n; 
     
    230144        coord tunn[TUNN_MAX]; 
    231145 
     146        /* Array of good potential stair grids */ 
     147        int stair_n; 
     148        coord stair[STAIR_MAX]; 
     149 
    232150        /* Number of blocks along each axis */ 
    233151        int row_rooms; 
    234152        int col_rooms; 
    235153 
    236         /* Array of which blocks are used */ 
    237         bool room_map[MAX_ROOMS_ROW][MAX_ROOMS_COL]; 
    238  
    239         /* Hack -- there is a pit/nest on this level */ 
    240         bool crowded; 
     154        /* Array to store block usage */ 
     155        int room_map[MAX_ROOMS_ROW][MAX_ROOMS_COL]; 
    241156}; 
    242157 
    243  
    244158/* 
    245159 * Dungeon generation data -- see "cave_gen()" 
     
    249163 
    250164/* 
    251  * Array of room types (assumes 11x11 blocks) 
    252  */ 
    253 static const room_data room[ROOM_MAX] = 
    254 
    255         { 0, 0, 0, 0, 0 },              /* 0 = Nothing */ 
    256         { 0, 0, -1, 1, 1 },             /* 1 = Simple (33x11) */ 
    257         { 0, 0, -1, 1, 1 },             /* 2 = Overlapping (33x11) */ 
    258         { 0, 0, -1, 1, 3 },             /* 3 = Crossed (33x11) */ 
    259         { 0, 0, -1, 1, 3 },             /* 4 = Large (33x11) */ 
    260         { 0, 0, -1, 1, 5 },             /* 5 = Monster nest (33x11) */ 
    261         { 0, 0, -1, 1, 5 },             /* 6 = Monster pit (33x11) */ 
    262         { 0, 1, -1, 1, 5 },             /* 7 = Lesser vault (33x22) */ 
    263         { -1, 2, -2, 3, 10 }    /* 8 = Greater vault (66x44) */ 
     165 * Room type information 
     166 */ 
     167typedef struct room_data room_data; 
     168 
     169struct room_data 
     170
     171        /* Allocation information. */ 
     172        s16b room_gen_num[11]; 
     173 
     174        /* Minimum level on which room can appear. */ 
     175        byte min_level; 
    264176}; 
    265177 
    266  
    267  
    268 /* 
    269  * Always picks a correct direction 
    270  */ 
    271 static void correct_dir(int *rdir, int *cdir, int y1, int x1, int y2, int x2) 
    272 
    273         /* Extract vertical and horizontal directions */ 
    274         *rdir = (y1 == y2) ? 0 : (y1 < y2) ? 1 : -1; 
    275         *cdir = (x1 == x2) ? 0 : (x1 < x2) ? 1 : -1; 
    276  
    277         /* Never move diagonally */ 
    278         if (*rdir && *cdir) 
    279         { 
    280                 if (rand_int(100) < 50) 
    281                 { 
    282                         *rdir = 0; 
     178/* 
     179 * Table of values that control how many times each type of room will,  
     180 * on average, appear on 100 levels at various depths.  Each type of room  
     181 * has its own row, and each column corresponds to dungeon levels 0, 10,  
     182 * 20, and so on.  The final value is the minimum depth the room can appear  
     183 * at.  -LM- 
     184 * 
     185 * Level 101 and below use the values for level 100. 
     186 * 
     187 * Rooms with lots of monsters or loot may not be generated if the object or  
     188 * monster lists are already nearly full.  Rooms will not appear above their  
     189 * minimum depth.  No type of room (other than type 1) can appear more than  
     190 * DUN_ROOMS/2 times in any level. 
     191 * 
     192 * The entries for room type 1 are blank because these rooms are built once  
     193 * all other rooms are finished -- until the level fills up, or the room  
     194 * count reaches the limit (DUN_ROOMS). 
     195 */ 
     196static room_data room[ROOM_MAX] =  
     197
     198   /* Depth:          0   10   20   30   40   50   60   70   80   90  100   min */ 
     199 
     200   /* Nothing */  {{  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0 },  0 }, 
     201   /* Simple */   {{  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0 },  0 }, 
     202   /* Overlap */  {{ 60,  80, 100, 120, 140, 165, 180, 200, 220, 240, 260 },  1 }, 
     203   /* Cross */    {{  0,  25,  50,  70,  85, 100, 110, 120, 130, 140, 150 },  3 }, 
     204   /* Large */    {{  0,  25,  50,  70,  85, 100, 110, 120, 130, 140, 150 },  3 }, 
     205   /* Pit      */ {{  0,   6,  13,  28,  35,  40,  45,  45,  45,  45,  45 },  5 }, 
     206   /* L. Vault */ {{  0,   1,   4,   9,  16,  27,  40,  55,  70,  80,  90 },  5 }, 
     207   /* G. Vault */ {{  0,   0,   1,   2,   3,   4,   6,   7,   8,  10,  12 }, 20 } 
     208}; 
     209 
     210 
     211 
     212/* 
     213 * This table takes a depth, and returns a suitable monster symbol.  Depth  
     214 * input is assumed to be player depth.  It is also assumed that monsters  
     215 * can be generated slightly out of depth.  -LM- 
     216 * 
     217 * Depths greater than 60 should map to the row for level 60. 
     218 * 
     219 * - Symbol '*' is any creature of a randomly-chosen racial char. 
     220 * - Symbol '1' is any animal. 
     221 * - Symbol '2' is any insect ('a', 'c', 'l', 'F', 'I', 'K'). 
     222 * - Symbol '3' is any naga, snake, hydra, or other reptile. 
     223 * - Symbol '4' is any jelly, mold, icky thing ('i', 'j', or 'm'). 
     224 * 
     225 * - Symbol '%' is any orc, ogre, troll, or giant. 
     226 * - Symbol 'N' is any undead.  Upon occasion, deep in the dungeon, the  
     227 *   racial type may be forced to 'G', 'L', 'V', or 'W'. 
     228 * - Symbols 'p' and 'h' may sometimes be found in combination.  If they  
     229 *   are, they are usually all of a given class (magical, pious, natural,  
     230 *   assassination/thievery, or warrior) 
     231 * - Symbols 'E' and 'v' may be found in combination.  If they are, they  
     232 *   will always be of a given elemental type. 
     233 * - Symbols 'd' and 'D' both mean dragons of either char.  Dragons are  
     234 *   often of a particular type (blue, red, gold, shadow/ethereal etc.). 
     235 * - Symbols 'u' and 'U' may mean lesser demons, greater demons, or both,  
     236 *   depending on depth.  
     237 * - Symbol 'A' is angels. 
     238 *  
     239 * - Other symbols usually represent specific racial characters. 
     240 * 
     241 * 80% of the time, one of the first seven characters will be chosen.   
     242 * 20% of the time, one of the last six will be. 
     243 */ 
     244static char mon_symbol_at_depth[12][13] =  
     245
     246        /*      common pits                            rare pits         */ 
     247 
     248        /* Levels 5, 10, 15, and 20 */ 
     249        {'1', '1', '4', '4', '4', 'k', 'y',   '*', '*', '2', 'a', '3', 'S' }, 
     250        {'1', '4', '4', 'o', 'o', 'N', '2',   '*', 'C', 'f', 'a', '3', 'S' }, 
     251        {'1', '4', 'o', 'o', 'o', 'u', '*',   '#', '#', 'S', 'E', '3', 'Z' }, 
     252        {'1', '4', '4', 'o', 'T', 'T', '#',   'p', 'h', 'f', '2', '*', 'Z' }, 
     253 
     254        /* Levels 25, 30, 35, and 40 */ 
     255        {'1', '4', 'T', 'T', 'u', 'P', 'P',   'p', 'v', 'd', '2', 'S', '3' }, 
     256        {'1', '1', 'T', 'P', 'P', 'N', 'd',   'p', 'h', 'f', 'v', 'g', 'Z' }, 
     257        {'1', '4', 'T', 'P', 'N', 'u', 'd',   'p', 'H', 'E', '2', '*', '3' }, 
     258        {'1', '1', 'T', 'P', 'N', 'u', 'd',   'p', 'h', 'g', 'E', '*', 'Z' }, 
     259 
     260        /* Levels 45, 50, 55, and 60 */ 
     261        {'1', 'P', 'N', 'u', 'd', 'd', '*',   'p', 'h', 'v', 'E', '*', 'Z' }, 
     262        {'N', 'N', 'U', 'U', 'D', 'D', '*',   'p', 'h', 'v', 'T', 'B', 'Z' }, 
     263        {'1', 'N', 'U', 'U', 'D', 'D', '*',   'p', 'h', 'W', 'G', '*', 'Z' }, 
     264        {'N', 'N', 'U', 'U', 'D', 'D', '*',   'p', 'h', 'v', '*', 'D', 'Z' }  
     265}; 
     266 
     267/*  
     268 * Restrictions on monsters, used in pits, etc. 
     269 */ 
     270static bool allow_unique; 
     271static char d_char_req[10]; 
     272static byte d_attr_req[4]; 
     273static u32b racial_flag_mask; 
     274static u32b breath_flag_mask; 
     275 
     276 
     277 
     278/* 
     279 * Table of monster descriptions.  Used to make descriptions for kinds  
     280 * of pits and rooms of chambers that have no special names. 
     281 */ 
     282cptr d_char_req_desc[] = 
     283
     284        "B:bird", 
     285        "C:canine", 
     286        "D:dragon", 
     287        "E:elemental", 
     288        "F:dragon fly", 
     289        "G:ghost", 
     290        "H:hybrid", 
     291        "I:insect", 
     292        "J:snake", 
     293        "K:killer beetle", 
     294        "L:lich", 
     295        "M:multi-headed hydra", 
     296        "O:ogre", 
     297        "P:giant", 
     298        "Q:quylthulg", 
     299        "R:reptile", 
     300        "S:spider", 
     301        "T:troll", 
     302        "U:demon", 
     303        "V:vampire", 
     304        "W:wraith", 
     305        "Y:yeti", 
     306        "Z:zephyr hound", 
     307        "a:ant", 
     308        "b:bat", 
     309        "c:centipede", 
     310        "d:dragon", 
     311        "e:floating eye", 
     312        "f:feline", 
     313        "g:golem", 
     314        "h:humanoid", 
     315        "i:icky thing", 
     316        "j:jelly", 
     317        "k:kobold", 
     318        "l:louse", 
     319        "m:mold", 
     320        "n:naga", 
     321        "o:orc", 
     322        "p:human", 
     323        "q:quadruped", 
     324        "r:rodent", 
     325        "s:skeleton", 
     326        "t:townsperson", 
     327        "u:demon", 
     328        "v:vortex", 
     329        "w:worm", 
     330        "y:yeek", 
     331        "z:zombie", 
     332        ",:mushroom patch", 
     333        NULL 
     334}; 
     335 
     336 
     337 
     338 
     339/**************************************************************/ 
     340/*                                                            */ 
     341/*                 The monster-selection code                 */ 
     342/*                                                            */ 
     343/**************************************************************/ 
     344 
     345 
     346/* 
     347 * Use various selection criteria (set elsewhere) to restrict monster  
     348 * generation. 
     349 * 
     350 * This function is capable of selecting monsters by: 
     351 *   - racial symbol (may be any of the characters allowed) 
     352 *   - symbol color (may be any of up to four colors). 
     353 *   - racial flag(s) (monster may have any allowed flag) 
     354 *   - breath flag(s) (monster must have exactly the flags specified) 
     355 * 
     356 * Uniques may be forbidden, or allowed on rare occasions. 
     357 * 
     358 * Some situations (like the elemental war themed level) require special  
     359 * processing; this is done in helper functions called from this one. 
     360 */ 
     361static bool mon_select(int r_idx) 
     362
     363        monster_race *r_ptr = &r_info[r_idx]; 
     364        bool ok = FALSE; 
     365 
     366 
     367        /* Require that the monster symbol be correct. */ 
     368        if (d_char_req[0] != '\0') 
     369        { 
     370                if (strchr(d_char_req, r_ptr->d_char) == 0) return (FALSE); 
     371        } 
     372 
     373        /* Require correct racial type. */ 
     374        if (racial_flag_mask) 
     375        { 
     376                if (!(r_ptr->flags3 & (racial_flag_mask))) return (FALSE); 
     377 
     378                /* Hack -- no invisible undead until deep. */ 
     379                if ((p_ptr->depth < 40) && (r_ptr->flags3 & (RF3_UNDEAD)) &&  
     380                        (r_ptr->flags2 & (RF2_INVISIBLE))) return (FALSE); 
     381        } 
     382 
     383        /* Require that monster breaths be exactly those specified. */ 
     384        if (breath_flag_mask) 
     385        { 
     386                if (r_ptr->flags4 != breath_flag_mask) return (FALSE); 
     387        } 
     388 
     389        /* Require that the monster color be correct. */ 
     390        if (d_attr_req[0]) 
     391        { 
     392                /* Check all allowed colors, if given. */ 
     393                if ((d_attr_req[0]) && (r_ptr->d_attr == d_attr_req[0])) ok = TRUE; 
     394                if ((d_attr_req[1]) && (r_ptr->d_attr == d_attr_req[1])) ok = TRUE; 
     395                if ((d_attr_req[2]) && (r_ptr->d_attr == d_attr_req[2])) ok = TRUE; 
     396                if ((d_attr_req[3]) && (r_ptr->d_attr == d_attr_req[3])) ok = TRUE; 
     397 
     398                /* Hack -- No multihued dragons allowed in the arcane dragon pit. */ 
     399                if ((strchr(d_char_req, 'd') || strchr(d_char_req, 'D')) &&  
     400                        (d_attr_req[0] == TERM_VIOLET) &&  
     401                        (r_ptr->flags4 == (RF4_BR_ACID |  
     402                                RF4_BR_ELEC | RF4_BR_FIRE |  
     403                                RF4_BR_COLD | RF4_BR_POIS))) 
     404                { 
     405                        return (FALSE); 
     406                } 
     407 
     408                /* Doesn't match any of the given colors?  Not good. */ 
     409                if (!ok) return (FALSE); 
     410        } 
     411 
     412        /* Usually decline unique monsters. */ 
     413        if (r_ptr->flags1 & (RF1_UNIQUE)) 
     414        { 
     415                if (!allow_unique) return (FALSE); 
     416                else if (rand_int(5) != 0) return (FALSE); 
     417        } 
     418 
     419        /* Okay */ 
     420        return (TRUE); 
     421
     422 
     423 
     424/* 
     425 * Accept characters representing a race or group of monsters and  
     426 * an (adjusted) depth, and use these to set values for required racial  
     427 * type, monster symbol, monster symbol color, and breath type.  -LM- 
     428 * 
     429 * This function is called to set restrictions, point the monster  
     430 * allocation function to "mon_select()", and remake monster allocation.   
     431 * It undoes all of this things when called with the symbol '\0'. 
     432 *  
     433 * Describe the monsters (used by cheat_room) and determine if they  
     434 * should be neatly ordered or randomly placed (used in monster pits). 
     435 */ 
     436static char *mon_restrict(char symbol, byte depth, bool *ordered, bool unique_ok) 
     437
     438        int i, j; 
     439 
     440        /* Assume no definite name */ 
     441        char name[80] = "misc"; 
     442 
     443        /* Clear global monster restriction variables. */ 
     444        allow_unique = unique_ok; 
     445        for (i = 0; i < 10; i++) d_char_req[i] = '\0'; 
     446        for (i = 0; i < 4; i++) d_attr_req[i] = 0; 
     447        racial_flag_mask = 0; breath_flag_mask = 0; 
     448 
     449 
     450        /* No symbol, no restrictions. */ 
     451        if (symbol == '\0') 
     452        { 
     453                get_mon_num_hook = NULL; 
     454                get_mon_num_prep(); 
     455                return ("misc"); 
     456        } 
     457 
     458        /* Handle the "wild card" symbol '*'  */ 
     459        if (symbol == '*') 
     460        { 
     461                for (i = 0; i < 2500; i++) 
     462                { 
     463                        /* Get a random monster. */ 
     464                        j = randint(z_info->r_max - 1); 
     465 
     466                        /* Must be a real monster */ 
     467                        if (!r_info[j].rarity) continue; 
     468 
     469                        /* Try for close to depth, accept in-depth if necessary */ 
     470                        if (i < 200) 
     471                        { 
     472                                if ((!(r_info[j].flags1 & RF1_UNIQUE)) &&  
     473                                      (r_info[j].level != 0) &&  
     474                                      (r_info[j].level <= depth) &&  
     475                                      (ABS(r_info[j].level - p_ptr->depth) <  
     476                                      1 + (p_ptr->depth / 4))) break; 
     477                        } 
     478                        else 
     479                        { 
     480                                if ((!(r_info[j].flags1 & RF1_UNIQUE)) &&  
     481                                      (r_info[j].level != 0) &&  
     482                                      (r_info[j].level <= depth)) break; 
     483                        } 
     484                } 
     485 
     486                /* We've found a monster. */ 
     487                if (i < 2499) 
     488                { 
     489                        /* ...use that monster's symbol for all monsters. */ 
     490                        symbol = r_info[j].d_char; 
    283491                } 
    284492                else 
    285493                { 
    286                         *cdir = 0; 
    287                 } 
    288         } 
     494                        /* Paranoia - pit stays empty if no monster is found */ 
     495                        return (NULL); 
     496                } 
     497        } 
     498 
     499        /* Apply monster restrictions according to symbol. */ 
     500        switch (symbol) 
     501        { 
     502                /* All animals */ 
     503                case '1': 
     504                { 
     505                        strcpy(name, "animal"); 
     506                        racial_flag_mask = RF3_ANIMAL; 
     507                        *ordered = FALSE; 
     508                        break; 
     509                } 
     510 
     511                /* Insects */ 
     512                case '2': 
     513                { 
     514                        strcpy(name, "insect"); 
     515                        strcpy(d_char_req, "aclFIK"); 
     516                        *ordered = FALSE; 
     517                        break; 
     518                } 
     519 
     520                /* Reptiles */ 
     521