| | 22 | * Note that Level generation is *not* an important bottleneck, |
|---|
| | 23 | * though it can be annoyingly slow on older machines... Thus |
|---|
| | 24 | * we emphasize "simplicity" and "correctness" over "speed". |
|---|
| | 25 | * |
|---|
| | 26 | * This entire file is only needed for generating levels. |
|---|
| | 27 | * This may allow smart compilers to only load it when needed. |
|---|
| | 28 | * |
|---|
| | 29 | * Consider the "vault.txt" file for vault generation. |
|---|
| | 30 | * |
|---|
| | 31 | * In this file, we use the "special" granite and perma-wall sub-types, |
|---|
| | 32 | * where "basic" is normal, "inner" is inside a room, "outer" is the |
|---|
| | 33 | * outer wall of a room, and "solid" is the outer wall of the dungeon |
|---|
| | 34 | * or any walls that may not be pierced by corridors. Thus the only |
|---|
| | 35 | * wall type that may be pierced by a corridor is the "outer granite" |
|---|
| | 36 | * type. The "basic granite" type yields the "actual" corridors. |
|---|
| | 37 | * |
|---|
| | 38 | * Note that we use the special "solid" granite wall type to prevent |
|---|
| | 39 | * multiple corridors from piercing a wall in two adjacent locations, |
|---|
| | 40 | * which would be messy, and we use the special "outer" granite wall |
|---|
| | 41 | * to indicate which walls "surround" rooms, and may thus be "pierced" |
|---|
| | 42 | * by corridors entering or leaving the room. |
|---|
| | 43 | * |
|---|
| | 44 | * Note that a tunnel which attempts to leave a room near the "edge" |
|---|
| | 45 | * of the dungeon in a direction toward that edge will cause "silly" |
|---|
| | 46 | * wall piercings, but will have no permanently incorrect effects, |
|---|
| | 47 | * as long as the tunnel can *eventually* exit from another side. |
|---|
| | 48 | * And note that the wall may not come back into the room by the |
|---|
| | 49 | * hole it left through, so it must bend to the left or right and |
|---|
| | 50 | * then optionally re-enter the room (at least 2 grids away). This |
|---|
| | 51 | * is not a problem since every room that is large enough to block |
|---|
| | 52 | * the passage of tunnels is also large enough to allow the tunnel |
|---|
| | 53 | * to pierce the room itself several times. |
|---|
| | 54 | * |
|---|
| | 55 | * Note that no two corridors may enter a room through adjacent grids, |
|---|
| | 56 | * they must either share an entryway or else use entryways at least |
|---|
| | 57 | * two grids apart. This prevents "large" (or "silly") doorways. |
|---|
| | 58 | * |
|---|
| | 59 | * To create rooms in the dungeon, we first divide the dungeon up |
|---|
| | 60 | * into "blocks" of 11x11 grids each, and require that all rooms |
|---|
| | 61 | * occupy a rectangular group of blocks. As long as each room type |
|---|
| | 62 | * reserves a sufficient number of blocks, the room building routines |
|---|
| | 63 | * will not need to check bounds. Note that most of the normal rooms |
|---|
| | 64 | * actually only use 23x11 grids, and so reserve 33x11 grids. |
|---|
| | 65 | * |
|---|
| | 66 | * Note that the use of 11x11 blocks (instead of the 33x11 panels) |
|---|
| | 67 | * allows more variability in the horizontal placement of rooms, and |
|---|
| | 68 | * at the same time has the disadvantage that some rooms (two thirds |
|---|
| | 69 | * of the normal rooms) may be "split" by panel boundaries. This can |
|---|
| | 70 | * induce a situation where a player is in a room and part of the room |
|---|
| | 71 | * is off the screen. This can be so annoying that the player must set |
|---|
| | 72 | * a special option to enable "non-aligned" room generation. |
|---|
| | 73 | * |
|---|
| | 74 | * Note that the dungeon generation routines are much different (2.7.5) |
|---|
| | 75 | * and perhaps "DUN_ROOMS" should be less than 50. |
|---|
| | 76 | * |
|---|
| | 77 | * XXX XXX XXX Note that it is possible to create a room which is only |
|---|
| | 78 | * connected to itself, because the "tunnel generation" code allows a |
|---|
| | 79 | * tunnel to leave a room, wander around, and then re-enter the room. |
|---|
| | 80 | * |
|---|
| | 81 | * XXX XXX XXX Note that it is possible to create a set of rooms which |
|---|
| | 82 | * are only connected to other rooms in that set, since there is nothing |
|---|
| | 83 | * explicit in the code to prevent this from happening. But this is less |
|---|
| | 84 | * likely than the "isolated room" problem, because each room attempts to |
|---|
| | 85 | * connect to another room, in a giant cycle, thus requiring at least two |
|---|
| | 86 | * bizarre occurances to create an isolated section of the dungeon. |
|---|
| | 87 | * |
|---|
| | 88 | * Note that (2.7.9) monster pits have been split into monster "nests" |
|---|
| | 89 | * and monster "pits". The "nests" have a collection of monsters of a |
|---|
| | 90 | * given type strewn randomly around the room (jelly, animal, or undead), |
|---|
| | 91 | * while the "pits" have a collection of monsters of a given type placed |
|---|
| | 92 | * around the room in an organized manner (orc, troll, giant, dragon, or |
|---|
| | 93 | * demon). Note that both "nests" and "pits" are now "level dependant", |
|---|
| | 94 | * and both make 16 "expensive" calls to the "get_mon_num()" function. |
|---|
| | 95 | * |
|---|
| | 96 | * Note that the cave grid flags changed in a rather drastic manner |
|---|
| | 97 | * for Angband 2.8.0 (and 2.7.9+), in particular, dungeon terrain |
|---|
| | 98 | * features, such as doors and stairs and traps and rubble and walls, |
|---|
| | 99 | * are all handled as a set of 64 possible "terrain features", and |
|---|
| | 100 | * not as "fake" objects (440-479) as in pre-2.8.0 versions. |
|---|
| | 101 | * |
|---|
| | 102 | * The 64 new "dungeon features" will also be used for "visual display" |
|---|
| | 103 | * but we must be careful not to allow, for example, the user to display |
|---|
| | 104 | * hidden traps in a different way from floors, or secret doors in a way |
|---|
| | 105 | * different from granite walls, or even permanent granite in a different |
|---|
| | 106 | * way from granite. XXX XXX XXX |
|---|
| | 107 | */ |
|---|
| | 108 | |
|---|
| | 109 | |
|---|
| | 110 | /* |
|---|
| 170 | | /* |
|---|
| 171 | | * Table of values that control how many times each type of room will, |
|---|
| 172 | | * on average, appear on 100 levels at various depths. Each type of room |
|---|
| 173 | | * has its own row, and each column corresponds to dungeon levels 0, 10, |
|---|
| 174 | | * 20, and so on. The final value is the minimum depth the room can appear |
|---|
| 175 | | * at. -LM- |
|---|
| 176 | | * |
|---|
| 177 | | * Level 101 and below use the values for level 100. |
|---|
| 178 | | * |
|---|
| 179 | | * Rooms with lots of monsters or loot may not be generated if the object or |
|---|
| 180 | | * monster lists are already nearly full. Rooms will not appear above their |
|---|
| 181 | | * minimum depth. No type of room (other than type 1) can appear more than |
|---|
| 182 | | * DUN_ROOMS/2 times in any level. |
|---|
| 183 | | * |
|---|
| 184 | | * The entries for room type 1 are blank because these rooms are built once |
|---|
| 185 | | * all other rooms are finished -- until the level fills up, or the room |
|---|
| 186 | | * count reaches the limit (DUN_ROOMS). |
|---|
| 187 | | */ |
|---|
| 188 | | static room_data room[ROOM_MAX] = |
|---|
| 189 | | { |
|---|
| 190 | | /* Depth: 0 10 20 30 40 50 60 70 80 90 100 min */ |
|---|
| 191 | | |
|---|
| 192 | | /* Nothing */ {{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0 }, |
|---|
| 193 | | /* Simple */ {{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0 }, |
|---|
| 194 | | /* Overlap */ {{ 60, 80, 100, 120, 140, 165, 180, 200, 220, 240, 260 }, 1 }, |
|---|
| 195 | | /* Cross */ {{ 0, 25, 50, 70, 85, 100, 110, 120, 130, 140, 150 }, 3 }, |
|---|
| 196 | | /* Large */ {{ 0, 25, 50, 70, 85, 100, 110, 120, 130, 140, 150 }, 3 }, |
|---|
| 197 | | /* Pit */ {{ 0, 6, 13, 28, 35, 40, 45, 45, 45, 45, 45 }, 5 }, |
|---|
| 198 | | /* L. Vault */ {{ 0, 1, 4, 9, 16, 27, 40, 55, 70, 80, 90 }, 5 }, |
|---|
| 199 | | /* G. Vault */ {{ 0, 0, 1, 2, 3, 4, 6, 7, 8, 10, 12 }, 20 } |
|---|
| 200 | | }; |
|---|
| 201 | | |
|---|
| 202 | | |
|---|
| 203 | | |
|---|
| 204 | | /* |
|---|
| 205 | | * This table takes a depth, and returns a suitable monster symbol. Depth |
|---|
| 206 | | * input is assumed to be player depth. It is also assumed that monsters |
|---|
| 207 | | * can be generated slightly out of depth. -LM- |
|---|
| 208 | | * |
|---|
| 209 | | * Depths greater than 60 should map to the row for level 60. |
|---|
| 210 | | * |
|---|
| 211 | | * - Symbol '*' is any creature of a randomly-chosen racial char. |
|---|
| 212 | | * - Symbol '1' is any animal. |
|---|
| 213 | | * - Symbol '2' is any insect ('a', 'c', 'l', 'F', 'I', 'K'). |
|---|
| 214 | | * - Symbol '3' is any naga, snake, hydra, or other reptile. |
|---|
| 215 | | * - Symbol '4' is any jelly, mold, icky thing ('i', 'j', or 'm'). |
|---|
| 216 | | * |
|---|
| 217 | | * - Symbol '%' is any orc, ogre, troll, or giant. |
|---|
| 218 | | * - Symbol 'N' is any undead. Upon occasion, deep in the dungeon, the |
|---|
| 219 | | * racial type may be forced to 'G', 'L', 'V', or 'W'. |
|---|
| 220 | | * - Symbols 'p' and 'h' may sometimes be found in combination. If they |
|---|
| 221 | | * are, they are usually all of a given class (magical, pious, natural, |
|---|
| 222 | | * assassination/thievery, or warrior) |
|---|
| 223 | | * - Symbols 'E' and 'v' may be found in combination. If they are, they |
|---|
| 224 | | * will always be of a given elemental type. |
|---|
| 225 | | * - Symbols 'd' and 'D' both mean dragons of either char. Dragons are |
|---|
| 226 | | * often of a particular type (blue, red, gold, shadow/ethereal etc.). |
|---|
| 227 | | * - Symbols 'u' and 'U' may mean lesser demons, greater demons, or both, |
|---|
| 228 | | * depending on depth. |
|---|
| 229 | | * - Symbol 'A' is angels. |
|---|
| 230 | | * |
|---|
| 231 | | * - Other symbols usually represent specific racial characters. |
|---|
| 232 | | * |
|---|
| 233 | | * 80% of the time, one of the first seven characters will be chosen. |
|---|
| 234 | | * 20% of the time, one of the last six will be. |
|---|
| 235 | | */ |
|---|
| 236 | | static char mon_symbol_at_depth[12][13] = |
|---|
| 237 | | { |
|---|
| 238 | | /* common pits rare pits */ |
|---|
| 239 | | |
|---|
| 240 | | /* Levels 5, 10, 15, and 20 */ |
|---|
| 241 | | {'1', '1', '4', '4', '4', 'k', 'y', '*', '*', '2', 'a', '3', 'S' }, |
|---|
| 242 | | {'1', '4', '4', 'o', 'o', 'N', '2', '*', 'C', 'f', 'a', '3', 'S' }, |
|---|
| 243 | | {'1', '4', 'o', 'o', 'o', 'u', '*', '#', '#', 'S', 'E', '3', 'Z' }, |
|---|
| 244 | | {'1', '4', '4', 'o', 'T', 'T', '#', 'p', 'h', 'f', '2', '*', 'Z' }, |
|---|
| 245 | | |
|---|
| 246 | | /* Levels 25, 30, 35, and 40 */ |
|---|
| 247 | | {'1', '4', 'T', 'T', 'u', 'P', 'P', 'p', 'v', 'd', '2', 'S', '3' }, |
|---|
| 248 | | {'1', '1', 'T', 'P', 'P', 'N', 'd', 'p', 'h', 'f', 'v', 'g', 'Z' }, |
|---|
| 249 | | {'1', '4', 'T', 'P', 'N', 'u', 'd', 'p', 'H', 'E', '2', '*', '3' }, |
|---|
| 250 | | {'1', '1', 'T', 'P', 'N', 'u', 'd', 'p', 'h', 'g', 'E', '*', 'Z' }, |
|---|
| 251 | | |
|---|
| 252 | | /* Levels 45, 50, 55, and 60 */ |
|---|
| 253 | | {'1', 'P', 'N', 'u', 'd', 'd', '*', 'p', 'h', 'v', 'E', '*', 'Z' }, |
|---|
| 254 | | {'N', 'N', 'U', 'U', 'D', 'D', '*', 'p', 'h', 'v', 'T', 'B', 'Z' }, |
|---|
| 255 | | {'1', 'N', 'U', 'U', 'D', 'D', '*', 'p', 'h', 'W', 'G', '*', 'Z' }, |
|---|
| 256 | | {'N', 'N', 'U', 'U', 'D', 'D', '*', 'p', 'h', 'v', '*', 'D', 'Z' } |
|---|
| 257 | | }; |
|---|
| 258 | | |
|---|
| 259 | | /* |
|---|
| 260 | | * Restrictions on monsters, used in pits, etc. |
|---|
| 261 | | */ |
|---|
| 262 | | static bool allow_unique; |
|---|
| 263 | | static char d_char_req[10]; |
|---|
| 264 | | static byte d_attr_req[4]; |
|---|
| 265 | | static u32b racial_flag_mask; |
|---|
| 266 | | static u32b breath_flag_mask; |
|---|
| 267 | | |
|---|
| 268 | | |
|---|
| 269 | | |
|---|
| 270 | | /* |
|---|
| 271 | | * Table of monster descriptions. Used to make descriptions for kinds |
|---|
| 272 | | * of pits and rooms of chambers that have no special names. |
|---|
| 273 | | */ |
|---|
| 274 | | cptr d_char_req_desc[] = |
|---|
| 275 | | { |
|---|
| 276 | | "B:bird", |
|---|
| 277 | | "C:canine", |
|---|
| 278 | | "D:dragon", |
|---|
| 279 | | "E:elemental", |
|---|
| 280 | | "F:dragon fly", |
|---|
| 281 | | "G:ghost", |
|---|
| 282 | | "H:hybrid", |
|---|
| 283 | | "I:insect", |
|---|
| 284 | | "J:snake", |
|---|
| 285 | | "K:killer beetle", |
|---|
| 286 | | "L:lich", |
|---|
| 287 | | "M:multi-headed hydra", |
|---|
| 288 | | "O:ogre", |
|---|
| 289 | | "P:giant", |
|---|
| 290 | | "Q:quylthulg", |
|---|
| 291 | | "R:reptile", |
|---|
| 292 | | "S:spider", |
|---|
| 293 | | "T:troll", |
|---|
| 294 | | "U:demon", |
|---|
| 295 | | "V:vampire", |
|---|
| 296 | | "W:wraith", |
|---|
| 297 | | "Y:yeti", |
|---|
| 298 | | "Z:zephyr hound", |
|---|
| 299 | | "a:ant", |
|---|
| 300 | | "b:bat", |
|---|
| 301 | | "c:centipede", |
|---|
| 302 | | "d:dragon", |
|---|
| 303 | | "e:floating eye", |
|---|
| 304 | | "f:feline", |
|---|
| 305 | | "g:golem", |
|---|
| 306 | | "h:humanoid", |
|---|
| 307 | | "i:icky thing", |
|---|
| 308 | | "j:jelly", |
|---|
| 309 | | "k:kobold", |
|---|
| 310 | | "l:louse", |
|---|
| 311 | | "m:mold", |
|---|
| 312 | | "n:naga", |
|---|
| 313 | | "o:orc", |
|---|
| 314 | | "p:human", |
|---|
| 315 | | "q:quadruped", |
|---|
| 316 | | "r:rodent", |
|---|
| 317 | | "s:skeleton", |
|---|
| 318 | | "t:townsperson", |
|---|
| 319 | | "u:demon", |
|---|
| 320 | | "v:vortex", |
|---|
| 321 | | "w:worm", |
|---|
| 322 | | "y:yeek", |
|---|
| 323 | | "z:zombie", |
|---|
| 324 | | ",:mushroom patch", |
|---|
| 325 | | NULL |
|---|
| 326 | | }; |
|---|
| 327 | | |
|---|
| 328 | | |
|---|
| 329 | | |
|---|
| 330 | | |
|---|
| 331 | | /**************************************************************/ |
|---|
| 332 | | /* */ |
|---|
| 333 | | /* The monster-selection code */ |
|---|
| 334 | | /* */ |
|---|
| 335 | | /**************************************************************/ |
|---|
| 336 | | |
|---|
| 337 | | |
|---|
| 338 | | /* |
|---|
| 339 | | * Use various selection criteria (set elsewhere) to restrict monster |
|---|
| 340 | | * generation. |
|---|
| 341 | | * |
|---|
| 342 | | * This function is capable of selecting monsters by: |
|---|
| 343 | | * - racial symbol (may be any of the characters allowed) |
|---|
| 344 | | * - symbol color (may be any of up to four colors). |
|---|
| 345 | | * - racial flag(s) (monster may have any allowed flag) |
|---|
| 346 | | * - breath flag(s) (monster must have exactly the flags specified) |
|---|
| 347 | | * |
|---|
| 348 | | * Uniques may be forbidden, or allowed on rare occasions. |
|---|
| 349 | | * |
|---|
| 350 | | * Some situations (like the elemental war themed level) require special |
|---|
| 351 | | * processing; this is done in helper functions called from this one. |
|---|
| 352 | | */ |
|---|
| 353 | | static bool mon_select(int r_idx) |
|---|
| 354 | | { |
|---|
| 355 | | monster_race *r_ptr = &r_info[r_idx]; |
|---|
| 356 | | bool ok = FALSE; |
|---|
| 357 | | |
|---|
| 358 | | |
|---|
| 359 | | /* Require that the monster symbol be correct. */ |
|---|
| 360 | | if (d_char_req[0] != '\0') |
|---|
| 361 | | { |
|---|
| 362 | | if (strchr(d_char_req, r_ptr->d_char) == 0) return (FALSE); |
|---|
| 363 | | } |
|---|
| 364 | | |
|---|
| 365 | | /* Require correct racial type. */ |
|---|
| 366 | | if (racial_flag_mask) |
|---|
| 367 | | { |
|---|
| 368 | | if (!(r_ptr->flags3 & (racial_flag_mask))) return (FALSE); |
|---|
| 369 | | |
|---|
| 370 | | /* Hack -- no invisible undead until deep. */ |
|---|
| 371 | | if ((p_ptr->depth < 40) && (r_ptr->flags3 & (RF3_UNDEAD)) && |
|---|
| 372 | | (r_ptr->flags2 & (RF2_INVISIBLE))) return (FALSE); |
|---|
| 373 | | } |
|---|
| 374 | | |
|---|
| 375 | | /* Require that monster breaths be exactly those specified. */ |
|---|
| 376 | | if (breath_flag_mask) |
|---|
| 377 | | { |
|---|
| 378 | | if (r_ptr->flags4 != breath_flag_mask) return (FALSE); |
|---|
| 379 | | } |
|---|
| 380 | | |
|---|
| 381 | | /* Require that the monster color be correct. */ |
|---|
| 382 | | if (d_attr_req[0]) |
|---|
| 383 | | { |
|---|
| 384 | | /* Check all allowed colors, if given. */ |
|---|
| 385 | | if ((d_attr_req[0]) && (r_ptr->d_attr == d_attr_req[0])) ok = TRUE; |
|---|
| 386 | | if ((d_attr_req[1]) && (r_ptr->d_attr == d_attr_req[1])) ok = TRUE; |
|---|
| 387 | | if ((d_attr_req[2]) && (r_ptr->d_attr == d_attr_req[2])) ok = TRUE; |
|---|
| 388 | | if ((d_attr_req[3]) && (r_ptr->d_attr == d_attr_req[3])) ok = TRUE; |
|---|
| 389 | | |
|---|
| 390 | | /* Hack -- No multihued dragons allowed in the arcane dragon pit. */ |
|---|
| 391 | | if ((strchr(d_char_req, 'd') || strchr(d_char_req, 'D')) && |
|---|
| 392 | | (d_attr_req[0] == TERM_VIOLET) && |
|---|
| 393 | | (r_ptr->flags4 == (RF4_BR_ACID | |
|---|
| 394 | | RF4_BR_ELEC | RF4_BR_FIRE | |
|---|
| 395 | | RF4_BR_COLD | RF4_BR_POIS))) |
|---|
| 396 | | { |
|---|
| 397 | | return (FALSE); |
|---|
| 398 | | } |
|---|
| 399 | | |
|---|
| 400 | | /* Doesn't match any of the given colors? Not good. */ |
|---|
| 401 | | if (!ok) return (FALSE); |
|---|
| 402 | | } |
|---|
| 403 | | |
|---|
| 404 | | /* Usually decline unique monsters. */ |
|---|
| 405 | | if (r_ptr->flags1 & (RF1_UNIQUE)) |
|---|
| 406 | | { |
|---|
| 407 | | if (!allow_unique) return (FALSE); |
|---|
| 408 | | else if (rand_int(5) != 0) return (FALSE); |
|---|
| 409 | | } |
|---|
| 410 | | |
|---|
| 411 | | /* Okay */ |
|---|
| 412 | | return (TRUE); |
|---|
| 413 | | } |
|---|
| 414 | | |
|---|
| 415 | | |
|---|
| 416 | | /* |
|---|
| 417 | | * Accept characters representing a race or group of monsters and |
|---|
| 418 | | * an (adjusted) depth, and use these to set values for required racial |
|---|
| 419 | | * type, monster symbol, monster symbol color, and breath type. -LM- |
|---|
| 420 | | * |
|---|
| 421 | | * This function is called to set restrictions, point the monster |
|---|
| 422 | | * allocation function to "mon_select()", and remake monster allocation. |
|---|
| 423 | | * It undoes all of this things when called with the symbol '\0'. |
|---|
| 424 | | * |
|---|
| 425 | | * Describe the monsters (used by cheat_room) and determine if they |
|---|
| 426 | | * should be neatly ordered or randomly placed (used in monster pits). |
|---|
| 427 | | */ |
|---|
| 428 | | static char *mon_restrict(char symbol, byte depth, bool *ordered, bool unique_ok) |
|---|
| 429 | | { |
|---|
| 430 | | int i, j; |
|---|
| 431 | | |
|---|
| 432 | | /* Assume no definite name */ |
|---|
| 433 | | char name[80] = "misc"; |
|---|
| 434 | | |
|---|
| 435 | | /* Clear global monster restriction variables. */ |
|---|
| 436 | | allow_unique = unique_ok; |
|---|
| 437 | | for (i = 0; i < 10; i++) d_char_req[i] = '\0'; |
|---|
| 438 | | for (i = 0; i < 4; i++) d_attr_req[i] = 0; |
|---|
| 439 | | racial_flag_mask = 0; breath_flag_mask = 0; |
|---|
| 440 | | |
|---|
| 441 | | |
|---|
| 442 | | /* No symbol, no restrictions. */ |
|---|
| 443 | | if (symbol == '\0') |
|---|
| 444 | | { |
|---|
| 445 | | get_mon_num_hook = NULL; |
|---|
| 446 | | get_mon_num_prep(); |
|---|
| 447 | | return ("misc"); |
|---|
| 448 | | } |
|---|
| 449 | | |
|---|
| 450 | | /* Handle the "wild card" symbol '*' */ |
|---|
| 451 | | if (symbol == '*') |
|---|
| 452 | | { |
|---|
| 453 | | for (i = 0; i < 2500; i++) |
|---|
| 454 | | { |
|---|
| 455 | | /* Get a random monster. */ |
|---|
| 456 | | j = randint(z_info->r_max - 1); |
|---|
| 457 | | |
|---|
| 458 | | /* Must be a real monster */ |
|---|
| 459 | | if (!r_info[j].rarity) continue; |
|---|
| 460 | | |
|---|
| 461 | | /* Try for close to depth, accept in-depth if necessary */ |
|---|
| 462 | | if (i < 200) |
|---|
| 463 | | { |
|---|
| 464 | | if ((!(r_info[j].flags1 & RF1_UNIQUE)) && |
|---|
| 465 | | (r_info[j].level != 0) && |
|---|
| 466 | | (r_info[j].level <= depth) && |
|---|
| 467 | | (ABS(r_info[j].level - p_ptr->depth) < |
|---|
| 468 | | 1 + (p_ptr->depth / 4))) break; |
|---|
| 469 | | } |
|---|
| 470 | | else |
|---|
| 471 | | { |
|---|
| 472 | | if ((!(r_info[j].flags1 & RF1_UNIQUE)) && |
|---|
| 473 | | (r_info[j].level != 0) && |
|---|
| 474 | | (r_info[j].level <= depth)) break; |
|---|
| 475 | | } |
|---|
| 476 | | } |
|---|
| 477 | | |
|---|
| 478 | | /* We've found a monster. */ |
|---|
| 479 | | if (i < 2499) |
|---|
| 480 | | { |
|---|
| 481 | | /* ...use that monster's symbol for all monsters. */ |
|---|
| 482 | | symbol = r_info[j].d_char; |
|---|
| | 271 | |
|---|
| | 272 | |
|---|
| | 273 | /* |
|---|
| | 274 | * Always picks a correct direction |
|---|
| | 275 | */ |
|---|
| | 276 | static void correct_dir(int *rdir, int *cdir, int y1, int x1, int y2, int x2) |
|---|
| | 277 | { |
|---|
| | 278 | /* Extract vertical and horizontal directions */ |
|---|
| | 279 | *rdir = (y1 == y2) ? 0 : (y1 < y2) ? 1 : -1; |
|---|
| | 280 | *cdir = (x1 == x2) ? 0 : (x1 < x2) ? 1 : -1; |
|---|
| | 281 | |
|---|
| | 282 | /* Never move diagonally */ |
|---|
| | 283 | if (*rdir && *cdir) |
|---|
| | 284 | { |
|---|
| | 285 | if (rand_int(100) < 50) |
|---|
| | 286 | { |
|---|
| | 287 | *rdir = 0; |
|---|
| 486 | | /* Paranoia - pit stays empty if no monster is found */ |
|---|
| 487 | | return (NULL); |
|---|
| 488 | | } |
|---|
| 489 | | } |
|---|
| 490 | | |
|---|
| 491 | | /* Apply monster restrictions according to symbol. */ |
|---|
| 492 | | switch (symbol) |
|---|
| 493 | | { |
|---|
| 494 | | /* All animals */ |
|---|
| 495 | | case '1': |
|---|
| 496 | | { |
|---|
| 497 | | strcpy(name, "animal"); |
|---|
| 498 | | racial_flag_mask = RF3_ANIMAL; |
|---|
| 499 | | *ordered = FALSE; |
|---|
| 500 | | break; |
|---|
| 501 | | } |
|---|
| 502 | | |
|---|
| 503 | | /* Insects */ |
|---|
| 504 | | case '2': |
|---|
| 505 | | { |
|---|
| 506 | | strcpy(name, "insect"); |
|---|
| 507 | | strcpy(d_char_req, "aclFIK"); |
|---|
| 508 | | *ordered = FALSE; |
|---|
| 509 | | break; |
|---|
| 510 | | } |
|---|
| 511 | | |
|---|
| 512 | | /* Reptiles */ |
|---|
| 513 | | case '3': |
|---|
| 514 | | { |
|---|
| 515 | | strcpy(name, "reptile"); |
|---|
| 516 | | strcpy(d_char_req, "nJRM"); |
|---|
| 517 | | *ordered = FALSE; |
|---|
| 518 | | break; |
|---|
| 519 | | } |
|---|
| 520 | | |
|---|
| 521 | | /* Jellies, etc. */ |
|---|
| 522 | | case '4': |
|---|
| 523 | | { |
|---|
| 524 | | strcpy(name, "jelly"); |
|---|
| 525 | | strcpy(d_char_req, "ijm,"); |
|---|
| 526 | | *ordered = FALSE; |
|---|
| 527 | | break; |
|---|
| 528 | | } |
|---|
| 529 | | |
|---|
| 530 | | /* Humans and humaniods */ |
|---|
| 531 | | case 'p': |
|---|
| 532 | | case 'h': |
|---|
| 533 | | { |
|---|
| 534 | | /* 'p's and 'h's can coexist. */ |
|---|
| 535 | | if (rand_int(3) == 0) |
|---|
| 536 | | { |
|---|
| 537 | | strcpy(d_char_req, "ph"); |
|---|
| 538 | | |
|---|
| 539 | | /* If so, they will usually all be of similar classes. */ |
|---|
| 540 | | if (rand_int(4) != 0) |
|---|
| 541 | | { |
|---|
| 542 | | /* Randomizer. */ |
|---|
| 543 | | i = rand_int(5); |
|---|
| 544 | | |
|---|
| 545 | | /* Magicians and necromancers */ |
|---|
| 546 | | if (i == 0) |
|---|
| 547 | | { |
|---|
| 548 | | d_attr_req[0] = TERM_RED; |
|---|
| 549 | | d_attr_req[1] = TERM_L_RED; |
|---|
| 550 | | d_attr_req[2] = TERM_VIOLET; |
|---|
| 551 | | strcpy(name, "school of sorcery"); |
|---|
| 552 | | } |
|---|
| 553 | | /* Priests and paladins */ |
|---|
| 554 | | else if (i == 1) |
|---|
| 555 | | { |
|---|
| 556 | | d_attr_req[0] = TERM_GREEN; |
|---|
| 557 | | d_attr_req[1] = TERM_L_GREEN; |
|---|
| 558 | | d_attr_req[2] = TERM_WHITE; |
|---|
| 559 | | d_attr_req[3] = TERM_L_WHITE; |
|---|
| 560 | | strcpy(name, "temple of piety"); |
|---|
| 561 | | } |
|---|
| 562 | | /* Druids and ninjas */ |
|---|
| 563 | | else if (i == 2) |
|---|
| 564 | | { |
|---|
| 565 | | d_attr_req[0] = TERM_ORANGE; |
|---|
| 566 | | d_attr_req[1] = TERM_YELLOW; |
|---|
| 567 | | strcpy(name, "gathering of nature"); |
|---|
| 568 | | } |
|---|
| 569 | | /* Thieves and assassins */ |
|---|
| 570 | | else if (i == 3) |
|---|
| 571 | | { |
|---|
| 572 | | d_attr_req[0] = TERM_BLUE; |
|---|
| 573 | | d_attr_req[1] = TERM_L_BLUE; |
|---|
| 574 | | d_attr_req[2] = TERM_SLATE; |
|---|
| 575 | | d_attr_req[3] = TERM_L_DARK; |
|---|
| 576 | | strcpy(name, "den of thieves"); |
|---|
| 577 | | } |
|---|
| 578 | | /* Warriors and rangers */ |
|---|
| 579 | | else |
|---|
| 580 | | { |
|---|
| 581 | | d_attr_req[0] = TERM_UMBER; |
|---|
| 582 | | d_attr_req[1] = TERM_L_UMBER; |
|---|
| 583 | | strcpy(name, "fighter's hall"); |
|---|
| 584 | | } |
|---|
| 585 | | } |
|---|
| 586 | | else |
|---|
| 587 | | { |
|---|
| 588 | | strcpy(name, "humans and humaniods"); |
|---|
| 589 | | } |
|---|
| 590 | | } |
|---|
| 591 | | |
|---|
| 592 | | /* Usually, just accept the symbol. */ |
|---|
| 593 | | else |
|---|
| 594 | | { |
|---|
| 595 | | d_char_req[0] = symbol; |
|---|
| 596 | | |
|---|
| 597 | | if (symbol == 'p') strcpy(name, "human"); |
|---|
| 598 | | else if (symbol == 'h') strcpy(name, "humanoid"); |
|---|
| 599 | | } |
|---|
| 600 | | |
|---|
| 601 | | *ordered = FALSE; |
|---|
| 602 | | break; |
|---|
| 603 | | } |
|---|
| 604 | | |
|---|
| 605 | | /* Orcs */ |
|---|
| 606 | | case 'o': |
|---|
| 607 | | { |
|---|
| 608 | | strcpy(name, "orc"); |
|---|
| 609 | | strcpy(d_char_req, "o"); |
|---|
| 610 | | *ordered = TRUE; |
|---|
| 611 | | break; |
|---|
| 612 | | } |
|---|
| 613 | | |
|---|
| 614 | | /* Trolls */ |
|---|
| 615 | | case 'T': |
|---|
| 616 | | { |
|---|
| 617 | | strcpy(name, "troll"); |
|---|
| 618 | | strcpy(d_char_req, "T"); |
|---|
| 619 | | *ordered = TRUE; |
|---|
| 620 | | break; |
|---|
| 621 | | } |
|---|
| 622 | | |
|---|
| 623 | | /* Giants (sometimes ogres at low levels) */ |
|---|
| 624 | | case 'P': |
|---|
| 625 | | { |
|---|
| 626 | | strcpy(name, "giant"); |
|---|
| 627 | | if ((p_ptr->depth < 30) && (rand_int(3) == 0)) |
|---|
| 628 | | strcpy(d_char_req, "O"); |
|---|
| 629 | | else strcpy(d_char_req, "P"); |
|---|
| 630 | | *ordered = TRUE; |
|---|
| 631 | | break; |
|---|
| 632 | | } |
|---|
| 633 | | |
|---|
| 634 | | /* Orcs, ogres, trolls, or giants */ |
|---|
| 635 | | case '%': |
|---|
| 636 | | { |
|---|
| 637 | | strcpy(name, "moria"); |
|---|
| 638 | | strcpy(d_char_req, "oOPT"); |
|---|
| 639 | | *ordered = FALSE; |
|---|
| 640 | | break; |
|---|
| 641 | | } |
|---|
| 642 | | |
|---|
| 643 | | /* Monsters found in caves */ |
|---|
| 644 | | case '0': |
|---|
| 645 | | { |
|---|
| 646 | | strcpy(name, "dungeon monsters"); |
|---|
| 647 | | strcpy(d_char_req, "ykoOT"); |
|---|
| 648 | | *ordered = FALSE; |
|---|
| 649 | | break; |
|---|
| 650 | | } |
|---|
| 651 | | |
|---|
| 652 | | |
|---|
| 653 | | |
|---|
| 654 | | /* Undead */ |
|---|
| 655 | | case 'N': |
|---|
| 656 | | { |
|---|
| 657 | | /* Sometimes, restrict by symbol. */ |
|---|
| 658 | | if ((depth > 40) && (rand_int(3) == 0)) |
|---|
| 659 | | { |
|---|
| 660 | | for (i = 0; i < 500; i++) |
|---|
| 661 | | { |
|---|
| 662 | | /* Find a suitable monster near depth. */ |
|---|
| 663 | | j = randint(z_info->r_max - 1); |
|---|
| 664 | | |
|---|
| 665 | | /* Require a non-unique undead. */ |
|---|
| 666 | | if ((r_info[j].flags3 & RF3_UNDEAD) && |
|---|
| 667 | | (!(r_info[j].flags1 & RF1_UNIQUE)) && |
|---|
| 668 | | (strchr("GLWV", r_info[j].d_char)) && |
|---|
| 669 | | (ABS(r_info[j].level - p_ptr->depth) < |
|---|
| 670 | | 1 + (p_ptr->depth / 4))) |
|---|
| 671 | | { |
|---|
| 672 | | break; |
|---|
| 673 | | } |
|---|
| 674 | | } |
|---|
| 675 | | |
|---|
| 676 | | /* If we find a monster, */ |
|---|
| 677 | | if (i < 499) |
|---|
| 678 | | { |
|---|
| 679 | | /* Use that monster's symbol for all monsters */ |
|---|
| 680 | | d_char_req[0] = r_info[j].d_char; |
|---|
| 681 | | |
|---|
| 682 | | /* No pit name (yet) */ |
|---|
| 683 | | |
|---|
| 684 | | /* In this case, we do order the monsters */ |
|---|
| 685 | | *ordered = TRUE; |
|---|
| 686 | | } |
|---|
| 687 | | else |
|---|
| 688 | | { |
|---|
| 689 | | /* Accept any undead. */ |
|---|
| 690 | | strcpy(name, "undead"); |
|---|
| 691 | | racial_flag_mask = RF3_UNDEAD; |
|---|
| 692 | | *ordered = FALSE; |
|---|
| 693 | | } |
|---|
| 694 | | } |
|---|
| 695 | | else |
|---|
| 696 | | { |
|---|
| 697 | | /* No restrictions on symbol. */ |
|---|
| 698 | | strcpy(name, "undead"); |
|---|
| 699 | | racial_flag_mask = RF3_UNDEAD; |
|---|
| 700 | | *ordered = FALSE; |
|---|
| 701 | | } |
|---|
| 702 | | break; |
|---|
| 703 | | } |
|---|
| 704 | | |
|---|
| 705 | | /* Demons */ |
|---|
| 706 | | case 'u': |
|---|
| 707 | | case 'U': |
|---|
| 708 | | { |
|---|
| 709 | | strcpy(name, "demon"); |
|---|
| 710 | | if (depth > 55) strcpy(d_char_req, "U"); |
|---|
| 711 | | else if (depth < 40) strcpy(d_char_req, "u"); |
|---|
| 712 | | else strcpy(d_char_req, "uU"); |
|---|
| 713 | | *ordered = TRUE; |
|---|
| 714 | | break; |
|---|
| 715 | | } |
|---|
| 716 | | |
|---|
| 717 | | /* Dragons */ |
|---|
| 718 | | case 'd': |
|---|
| 719 | | case 'D': |
|---|
| 720 | | { |
|---|
| 721 | | strcpy(d_char_req, "dD"); |
|---|
| 722 | | |
|---|
| 723 | | /* Dragons usually associate with others of their kind. */ |
|---|
| 724 | | if (rand_int(6) != 0) |
|---|
| 725 | | { |
|---|
| 726 | | /* Dragons of a single kind are ordered. */ |
|---|
| 727 | | *ordered = TRUE; |
|---|
| 728 | | |
|---|
| 729 | | /* Some dragon types are not found everywhere */ |
|---|
| 730 | | if (depth > 70) i = rand_int(35); |
|---|
| 731 | | else if (depth > 45) i = rand_int(32); |
|---|
| 732 | | else if (depth > 32) i = rand_int(30); |
|---|
| 733 | | else if (depth > 23) i = rand_int(28); |
|---|
| 734 | | else i = rand_int(24); |
|---|
| 735 | | |
|---|
| 736 | | if (i < 4) |
|---|
| 737 | | { |
|---|
| 738 | | breath_flag_mask = (RF4_BR_ACID); |
|---|
| 739 | | strcpy(name, "dragon - acid"); |
|---|
| 740 | | } |
|---|
| 741 | | else if (i < 8) |
|---|
| 742 | | { |
|---|
| 743 | | breath_flag_mask = (RF4_BR_ELEC); |
|---|
| 744 | | strcpy(name, "dragon - electricity"); |
|---|
| 745 | | } |
|---|
| 746 | | else if (i < 12) |
|---|
| 747 | | { |
|---|
| 748 | | breath_flag_mask = (RF4_BR_FIRE); |
|---|
| 749 | | strcpy(name, "dragon - fire"); |
|---|
| 750 | | } |
|---|
| 751 | | else if (i < 16) |
|---|
| 752 | | { |
|---|
| 753 | | breath_flag_mask = (RF4_BR_COLD); |
|---|
| 754 | | strcpy(name, "dragon - cold"); |
|---|
| 755 | | } |
|---|
| 756 | | else if (i < 20) |
|---|
| 757 | | { |
|---|
| 758 | | breath_flag_mask = (RF4_BR_POIS); |
|---|
| 759 | | strcpy(name, "dragon - poison"); |
|---|
| 760 | | } |
|---|
| 761 | | else if (i < 24) |
|---|
| 762 | | { |
|---|
| 763 | | breath_flag_mask = (RF4_BR_ACID | |
|---|
| 764 | | RF4_BR_ELEC | RF4_BR_FIRE | |
|---|
| 765 | | RF4_BR_COLD | RF4_BR_POIS); |
|---|
| 766 | | strcpy(name, "dragon - multihued"); |
|---|
| 767 | | } |
|---|
| 768 | | else if (i < 26) |
|---|
| 769 | | { |
|---|
| 770 | | breath_flag_mask = (RF4_BR_CONF); |
|---|
| 771 | | strcpy(name, "dragon - confusion"); |
|---|
| 772 | | } |
|---|
| 773 | | else if (i < 28) |
|---|
| 774 | | { |
|---|
| 775 | | breath_flag_mask = (RF4_BR_SOUN); |
|---|
| 776 | | strcpy(name, "dragon - sound"); |
|---|
| 777 | | } |
|---|
| 778 | | else if (i < 30) |
|---|
| 779 | | { |
|---|
| 780 | | breath_flag_mask = (RF4_BR_LITE | |
|---|
| 781 | | RF4_BR_DARK); |
|---|
| 782 | | strcpy(name, "dragon - ethereal"); |
|---|
| 783 | | } |
|---|
| 784 | | |
|---|
| 785 | | /* Chaos, Law, Balance, Power, etc.) */ |
|---|
| 786 | | else |
|---|
| 787 | | { |
|---|
| 788 | |   |
|---|