Changeset 306
- Timestamp:
- 07/08/07 14:07:51 (1 year ago)
- Files:
-
- trunk/lib/edit/vault.txt (modified) (49 diffs)
- trunk/src/dungeon.c (modified) (2 diffs)
- trunk/src/generate.c (modified) (80 diffs)
- trunk/src/init1.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/edit/vault.txt
r305 r306 21 21 22 22 # 'X' is for extra information - room type, rating, rows, and 23 # columns. Lesser vaults are room type 7and have a maximum x-y size24 # of 33x22; greater vaults are room type 8and 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. 25 25 26 26 # 'D' lines describe the layout of the vault. Lines must be padded … … 50 50 51 51 52 ### Simple Vaults (type 7) -- maximum size 44x22 ###52 ### Simple Vaults (type 6) -- maximum size 44x22 ### 53 53 54 54 55 55 N:1:round 56 X: 7:5:12:2056 X:6:5:12:20 57 57 D: %%%%%% 58 58 D: %%%..##..%%% … … 70 70 71 71 N:2:octagon 72 X: 7:5:14:2072 X:6:5:14:20 73 73 D: %%%%%%%%%%%%%% 74 74 D: %%.##########.%% … … 88 88 89 89 N:3:octagon 90 X: 7:5:12:2090 X:6:5:12:20 91 91 D: %%%%%%%%%%%% 92 92 D: %%%%..........%%%% … … 104 104 105 105 N:4:square 106 X: 7:5:12:20106 X:6:5:12:20 107 107 D:%%%%%%%%%%%%%%%%%%%% 108 108 D:%*.......&........*% … … 120 120 121 121 N:5:diagonal 122 X: 7:5:12:20122 X:6:5:12:20 123 123 D:%%%%%%%%%%%%%%%%% 124 124 D:%,,,##,,,,##....%% … … 136 136 137 137 N:6:diagonal 138 X: 7:5:12:20138 X:6:5:12:20 139 139 D: %%%%%%%%%%%%%%%%% 140 140 D: %%....##,,,,##,,,% … … 152 152 153 153 N:7:square 154 X: 7:5:12:20154 X:6:5:12:20 155 155 D:%%%%%%%%%%%%%%%%%%%% 156 156 D:%,################,% … … 168 168 169 169 170 ### Greater vaults (type 8) -- maximum size 66x44 ###170 ### Greater vaults (type 7) -- maximum size 66x44 ### 171 171 172 172 173 173 N:10:huge 174 X: 8:45:17:39174 X:7:45:17:39 175 175 D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 176 176 D:%XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX% … … 193 193 194 194 N:11:large 195 X: 8:35:18:40195 X:7:35:18:40 196 196 D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 197 197 D:%XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX% … … 215 215 216 216 N:12:butterfly 217 X: 8:25:18:40217 X:7:25:18:40 218 218 D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 219 219 D:%XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX% … … 237 237 238 238 N:13:chambers 239 X: 8:25:15:40239 X:7:25:15:40 240 240 D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 241 241 D:%&+.^..^..^..^..^..^..^..^..^..^..^..+&% … … 256 256 257 257 N:14:Planet X 258 X: 7:10:13:15258 X:6:10:13:15 259 259 D:%%%%%%%%%%%%%%% 260 260 D:%.............% … … 273 273 274 274 N:15:Turnabout 275 X: 7:10:12:15275 X:6:10:12:15 276 276 D:############### 277 277 D:#.............# … … 289 289 290 290 N:16:Rooms 291 X: 7:10:13:19291 X:6:10:13:19 292 292 D:%%%%%%%%%%%%%%%%%%% 293 293 D:%.................% … … 306 306 307 307 N:17:Cross 308 X: 7:10:13:20308 X:6:10:13:20 309 309 D:%%%%%%%%%%%%%%%%%%%% 310 310 D:%########++########% … … 323 323 324 324 N:18:Central 325 X: 7:12:10:12325 X:6:12:10:12 326 326 D:############ 327 327 D:#,#^^^^^^#,# … … 337 337 338 338 N:19:Camouflaged 339 X: 7:10:9:12339 X:6:10:9:12 340 340 D:%%%%%%%%%%%% 341 341 D:%XXXXXXXXXX% … … 350 350 351 351 N:20:The I in the Storm 352 X: 8:40:25:41352 X:7:40:25:41 353 353 D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 354 354 D:%XXXXXXXXXXXXXXXXXXX#XXXXXXXXXXXXXXXXXXX% … … 379 379 380 380 N:21:The Bank From Hell 381 X: 8:30:20:31381 X:7:30:20:31 382 382 D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 383 383 D:%XXXXXXXXXXXXXX+XXXXXXXXXXXXXX% … … 403 403 404 404 N:22:Snake Maze 405 X: 8:15:21:23405 X:7:15:21:23 406 406 D:%%%%%%%%%%%%%%%%%%%%%%% 407 407 D:%.....................% … … 428 428 429 429 N:23:Roundabouts One 430 X: 8:15:21:43430 X:7:15:21:43 431 431 D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 432 432 D:%#XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX% … … 453 453 454 454 N:24:Roundabout Two 455 X: 8:25:25:40455 X:7:25:25:40 456 456 D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 457 457 D:%XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX% … … 482 482 483 483 N:25:Huge - Modified 484 X: 8:45:17:39484 X:7:45:17:39 485 485 D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 486 486 D:%XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX% … … 503 503 504 504 N:26:Mirrored Quartet 505 X: 8:20:21:49505 X:7:20:21:49 506 506 D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 507 507 D:%XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX% … … 528 528 529 529 N:27:False Wall 530 X: 8:20:15:64530 X:7:20:15:64 531 531 D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 532 532 D:%X+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX+X% … … 547 547 548 548 N:28:Divisi 549 X: 8:35:31:55549 X:7:35:31:55 550 550 D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 551 551 D:%.....................................................% … … 582 582 583 583 N:29:Curlicues One 584 X: 8:15:23:44584 X:7:15:23:44 585 585 D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 586 586 D:%XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX% … … 609 609 610 610 N:30:Bubbles 611 X: 8:35:25:41611 X:7:35:25:41 612 612 D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 613 613 D:%XXX#XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX% … … 638 638 639 639 N:31:Symmet 640 X: 8:20:23:29640 X:7:20:23:29 641 641 D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 642 642 D:%...........................% … … 665 665 666 666 N:32:Crown 667 X: 8:12:19:28667 X:7:12:19:28 668 668 D:%%%%%%%%%%%%%%%%%%%%%%%%%%%% 669 669 D:%..........................% … … 688 688 689 689 N:33:X^2 690 X: 7:8:13:15690 X:6:8:13:15 691 691 D:%%%%%%%%%%%%%%% 692 692 D:%.............% … … 705 705 706 706 N:34:V-vault 707 X: 8:25:23:48707 X:7:25:23:48 708 708 D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 709 709 D:%XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX% … … 732 732 733 733 N:35:Lesser vault ("Rock-Hard") 734 X: 7:10:11:20734 X:6:10:11:20 735 735 D:%%%%%%%%%%%%%%%%%%%% 736 736 D:%..................% … … 747 747 748 748 N:36:Lesser vault ("Miniature Cell") 749 X: 7:5:5:5749 X:6:5:5:5 750 750 D:%%%%% 751 751 D:%#9#% … … 756 756 757 757 N:37:Lesser vault ("Interlock") 758 X: 7:10:12:17758 X:6:10:12:17 759 759 D:%%%%%%%%%%%%%%%%% 760 760 D:%......^^^......% … … 772 772 773 773 N:38:Lesser vault ("Workaround") 774 X: 7:14:19:21774 X:6:14:19:21 775 775 D:%%%%%%%%%%%%%%%%%%%%% 776 776 D:%...................% … … 795 795 796 796 N:39:Greater vault ("Twisted Cube") 797 X: 8:20:24:41797 X:7:20:24:41 798 798 D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 799 799 D:%.......................................% … … 823 823 824 824 N:40:Greater vault ("Jigsaw") 825 X: 8:25:16:49825 X:7:25:16:49 826 826 D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 827 827 D:%...............................................% … … 843 843 844 844 N:41:Greater vault ("Hourglass") 845 X: 8:24:37:27845 X:7:24:37:27 846 846 D:%%%%%%%%%%%%%%%%%%%%%%%%%%% 847 847 D:%.........................% … … 885 885 886 886 N:42:Greater vault ("Funnel") 887 X: 8:15:21:23887 X:7:15:21:23 888 888 D:%%%%%%%%%%%%%%%%%%%%%%% 889 889 D:%XXXXXXXXXXXXXXXXXXXXX% … … 910 910 911 911 N:43:Greater vault ("Mazer") 912 X: 8:26:35:31912 X:7:26:35:31 913 913 D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 914 914 D:%.............................% … … 949 949 950 950 N:44:Greater vault ("Orb") 951 X: 8:16:27:27951 X:7:16:27:27 952 952 D:%%%%%%%%%%%%%%%%%%%%%%%%%%% 953 953 D:%.........................% … … 980 980 981 981 N:45:Greater vault ("Interstices") 982 X: 8:22:19:45982 X:7:22:19:45 983 983 D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 984 984 D:%...........................................% … … 1003 1003 1004 1004 N:46:Greater vault ("Sphere") 1005 X: 8:25:25:471005 X:7:25:25:47 1006 1006 D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1007 1007 D:%.............................................% … … 1032 1032 1033 1033 N:47:Greater vault ("Hellpit") 1034 X: 8:20:19:601034 X:7:20:19:60 1035 1035 D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1036 1036 D:%..........................................................% … … 1055 1055 1056 1056 N:48:Greater vault ("Target Practice") 1057 X: 8:20:20:611057 X:7:20:20:61 1058 1058 D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1059 1059 D:%XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX% … … 1079 1079 1080 1080 N:49:Greater vault ("Castle Death") 1081 X: 8:35:20:601081 X:7:35:20:60 1082 1082 D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1083 1083 D:%XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX% … … 1103 1103 1104 1104 N:50:Greater vault ("The Reward is Worth It") 1105 X: 8:20:16:631105 X:7:20:16:63 1106 1106 D:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1107 1107 D:%XXXXXXXXXXXXXXX##XXXXXXXXXXXXX#XXXXXXXXXXXXX##XXXXXXXXXXXXXXX% trunk/src/dungeon.c
r291 r306 1492 1492 int i; 1493 1493 1494 int py = p_ptr->py;1495 int px = p_ptr->px;1496 1494 1497 1495 … … 1547 1545 } 1548 1546 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 else1577 {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 }1588 1547 1589 1548 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 */ 11 23 #include "angband.h" 12 24 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. 20 31 * 21 32 * This entire file is only needed for generating levels. 22 33 * This may allow smart compilers to only load it when needed. 23 34 * 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. 102 36 */ 103 37 … … 106 40 * Dungeon generation values 107 41 */ 108 #define DUN_ROOMS 50 /* Number of rooms to attempt */109 #define D UN_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 111 45 112 46 /* 113 47 * Dungeon tunnel generation values 114 48 */ 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 */ 120 53 121 54 /* 122 55 * Dungeon streamer generation values 123 56 */ 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) */ 126 58 #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 */ 128 60 #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 133 66 */ 134 67 #define DUN_AMT_ROOM 9 /* Amount of objects for rooms */ … … 152 85 153 86 154 155 87 /* 156 88 * Maximum numbers of rooms along each axis (currently 6x18) … … 159 91 #define MAX_ROOMS_COL (DUNGEON_WID / BLOCK_WID) 160 92 93 /* 94 * Maximal number of room types 95 */ 96 #define ROOM_MAX 8 161 97 162 98 /* … … 164 100 * These bounds are checked, though usually this is a formality. 165 101 */ 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 178 107 179 108 /* 180 109 * Simple structure to hold a map location 181 110 */ 182 183 111 typedef struct coord coord; 184 112 … … 189 117 }; 190 118 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 210 121 */ 211 122 … … 218 129 coord cent[CENT_MAX]; 219 130 131 /* Array to store whether rooms are connected or not. */ 132 bool connected[CENT_MAX]; 133 220 134 /* Array of possible door locations */ 221 135 int door_n; … … 230 144 coord tunn[TUNN_MAX]; 231 145 146 /* Array of good potential stair grids */ 147 int stair_n; 148 coord stair[STAIR_MAX]; 149 232 150 /* Number of blocks along each axis */ 233 151 int row_rooms; 234 152 int col_rooms; 235 153 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]; 241 156 }; 242 157 243 244 158 /* 245 159 * Dungeon generation data -- see "cave_gen()" … … 249 163 250 164 /* 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 */ 167 typedef struct room_data room_data; 168 169 struct 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; 264 176 }; 265 177 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 */ 196 static 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 */ 244 static 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 */ 270 static bool allow_unique; 271 static char d_char_req[10]; 272 static byte d_attr_req[4]; 273 static u32b racial_flag_mask; 274 static 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 */ 282 cptr 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 */ 361 static 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 */ 436 static 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; 283 491 } 284 492 else 285 493 { 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
