4 #include "generate.h"
\r
9 * @brief Vault
\92n
\8c`
\82ð
\89ñ
\93]
\81A
\8fã
\89º
\8d¶
\89E
\94½
\93]
\82·
\82é
\82½
\82ß
\82Ì
\8dÀ
\95W
\95Ï
\8a·
\82ð
\95Ô
\82· / coordinate translation code
\r
10 * @param x
\95Ï
\8a·
\82µ
\82½
\82¢
\93_
\82ÌX
\8dÀ
\95W
\8eQ
\8fÆ
\83|
\83C
\83\93\83^
\r
11 * @param y
\95Ï
\8a·
\82µ
\82½
\82¢
\93_
\82ÌY
\8dÀ
\95W
\8eQ
\8fÆ
\83|
\83C
\83\93\83^
\r
12 * @param xoffset Vault
\90¶
\90¬
\8e\9e\82Ì
\8aî
\8f\80X
\8dÀ
\95W
\r
13 * @param yoffset Vault
\90¶
\90¬
\8e\9e\82Ì
\8aî
\8f\80Y
\8dÀ
\95W
\r
14 * @param transno
\8f\88\97\9dID
\r
17 static void coord_trans(POSITION *x, POSITION *y, POSITION xoffset, POSITION yoffset, int transno)
\r
23 * transno specifies what transformation is required. (0-7)
\r
24 * The lower two bits indicate by how much the vault is rotated,
\r
25 * and the upper bit indicates a reflection.
\r
26 * This is done by using rotation matrices... however since
\r
27 * these are mostly zeros for rotations by 90 degrees this can
\r
28 * be expressed simply in terms of swapping and inverting the
\r
29 * x and y coordinates.
\r
31 for (i = 0; i < transno % 4; i++)
\r
33 /* rotate by 90 degrees */
\r
41 /* Reflect depending on status of 3rd bit. */
\r
45 /* Add offsets so vault stays in the first quadrant */
\r
52 * @brief Vault
\82ð
\83t
\83\8d\83A
\82É
\94z
\92u
\82·
\82é / Hack -- fill in "vault" rooms
\r
53 * @param yval
\90¶
\90¬
\8aî
\8f\80Y
\8dÀ
\95W
\r
54 * @param xval
\90¶
\90¬
\8aî
\8f\80X
\8dÀ
\95W
\r
55 * @param ymax Vault
\82ÌY
\83T
\83C
\83Y
\r
56 * @param xmax Vault
\82ÌX
\83T
\83C
\83Y
\r
57 * @param data Vault
\82Ì
\83f
\81[
\83^
\95¶
\8e\9a\97ñ
\r
58 * @param xoffset
\95Ï
\8a·
\8aî
\8f\80X
\8dÀ
\95W
\r
59 * @param yoffset
\95Ï
\8a·
\8aî
\8f\80Y
\8dÀ
\95W
\r
60 * @param transno
\95Ï
\8a·ID
\r
63 static void build_vault(POSITION yval, POSITION xval, POSITION ymax, POSITION xmax, cptr data,
\r
64 POSITION xoffset, POSITION yoffset, int transno)
\r
66 POSITION dx, dy, x, y, i, j;
\r
70 /* Place dungeon features and objects */
\r
71 for (t = data, dy = 0; dy < ymax; dy++)
\r
73 for (dx = 0; dx < xmax; dx++, t++)
\r
75 /* prevent loop counter from being overwritten */
\r
80 coord_trans(&i, &j, xoffset, yoffset, transno);
\r
82 /* Extract the location */
\r
83 if (transno % 2 == 0)
\r
85 /* no swap of x/y */
\r
86 x = xval - (xmax / 2) + i;
\r
87 y = yval - (ymax / 2) + j;
\r
92 x = xval - (ymax / 2) + i;
\r
93 y = yval - (xmax / 2) + j;
\r
96 /* Hack -- skip "non-grids" */
\r
97 if (*t == ' ') continue;
\r
99 /* Access the grid */
\r
100 c_ptr = &cave[y][x];
\r
102 /* Lay down a floor */
\r
103 place_floor_grid(c_ptr);
\r
105 /* Remove any mimic */
\r
108 /* Part of a vault */
\r
109 c_ptr->info |= (CAVE_ROOM | CAVE_ICKY);
\r
111 /* Analyze the grid */
\r
114 /* Granite wall (outer) */
\r
116 place_outer_noperm_grid(c_ptr);
\r
119 /* Granite wall (inner) */
\r
121 place_inner_grid(c_ptr);
\r
124 /* Glass wall (inner) */
\r
126 place_inner_grid(c_ptr);
\r
127 c_ptr->feat = feat_glass_wall;
\r
130 /* Permanent wall (inner) */
\r
132 place_inner_perm_grid(c_ptr);
\r
135 /* Permanent glass wall (inner) */
\r
137 place_inner_perm_grid(c_ptr);
\r
138 c_ptr->feat = feat_permanent_glass_wall;
\r
141 /* Treasure/trap */
\r
143 if (randint0(100) < 75)
\r
145 place_object(y, x, 0L);
\r
155 place_secret_door(y, x, DOOR_DEFAULT);
\r
158 /* Secret glass doors */
\r
160 place_secret_door(y, x, DOOR_GLASS_DOOR);
\r
161 if (is_closed_door(c_ptr->feat)) c_ptr->mimic = feat_glass_wall;
\r
166 place_secret_door(y, x, DOOR_CURTAIN);
\r
174 /* Black market in a dungeon */
\r
176 set_cave_feat(y, x, feat_black_market);
\r
177 store_init(NO_TOWN, STORE_BLACK);
\r
182 set_cave_feat(y, x, feat_pattern_start);
\r
186 set_cave_feat(y, x, feat_pattern_1);
\r
190 set_cave_feat(y, x, feat_pattern_2);
\r
194 set_cave_feat(y, x, feat_pattern_3);
\r
198 set_cave_feat(y, x, feat_pattern_4);
\r
202 set_cave_feat(y, x, feat_pattern_end);
\r
206 set_cave_feat(y, x, feat_pattern_exit);
\r
210 /* Reward for Pattern walk */
\r
211 object_level = base_level + 12;
\r
212 place_object(y, x, AM_GOOD | AM_GREAT);
\r
213 object_level = base_level;
\r
220 /* Place dungeon monsters and objects */
\r
221 for (t = data, dy = 0; dy < ymax; dy++)
\r
223 for (dx = 0; dx < xmax; dx++, t++)
\r
225 /* prevent loop counter from being overwritten */
\r
229 /* Flip / rotate */
\r
230 coord_trans(&i, &j, xoffset, yoffset, transno);
\r
232 /* Extract the location */
\r
233 if (transno % 2 == 0)
\r
235 /* no swap of x/y */
\r
236 x = xval - (xmax / 2) + i;
\r
237 y = yval - (ymax / 2) + j;
\r
242 x = xval - (ymax / 2) + i;
\r
243 y = yval - (xmax / 2) + j;
\r
246 /* Hack -- skip "non-grids" */
\r
247 if (*t == ' ') continue;
\r
249 /* Analyze the symbol */
\r
255 monster_level = base_level + 5;
\r
256 place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
\r
257 monster_level = base_level;
\r
261 /* Meaner monster */
\r
264 monster_level = base_level + 11;
\r
265 place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
\r
266 monster_level = base_level;
\r
270 /* Meaner monster, plus treasure */
\r
273 monster_level = base_level + 9;
\r
274 place_monster(y, x, PM_ALLOW_SLEEP);
\r
275 monster_level = base_level;
\r
276 object_level = base_level + 7;
\r
277 place_object(y, x, AM_GOOD);
\r
278 object_level = base_level;
\r
282 /* Nasty monster and treasure */
\r
285 monster_level = base_level + 40;
\r
286 place_monster(y, x, PM_ALLOW_SLEEP);
\r
287 monster_level = base_level;
\r
288 object_level = base_level + 20;
\r
289 place_object(y, x, AM_GOOD | AM_GREAT);
\r
290 object_level = base_level;
\r
294 /* Monster and/or object */
\r
297 if (randint0(100) < 50)
\r
299 monster_level = base_level + 3;
\r
300 place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
\r
301 monster_level = base_level;
\r
303 if (randint0(100) < 50)
\r
305 object_level = base_level + 7;
\r
306 place_object(y, x, 0L);
\r
307 object_level = base_level;
\r
320 * @brief
\83^
\83C
\83v7
\82Ì
\95\94\89®
\81cv_info.txt
\82æ
\82è
\8f¬
\8c^vault
\82ð
\90¶
\90¬
\82·
\82é / Type 7 -- simple vaults (see "v_info.txt")
\r
323 bool build_type7(void)
\r
325 vault_type *v_ptr = NULL;
\r
328 POSITION xval, yval;
\r
329 POSITION xoffset, yoffset;
\r
332 /* Pick a lesser vault */
\r
333 for (dummy = 0; dummy < SAFE_MAX_ATTEMPTS; dummy++)
\r
335 /* Access a random vault record */
\r
336 v_ptr = &v_info[randint0(max_v_idx)];
\r
338 /* Accept the first lesser vault */
\r
339 if (v_ptr->typ == 7) break;
\r
342 /* No lesser vault found */
\r
343 if (dummy >= SAFE_MAX_ATTEMPTS)
\r
345 msg_print_wizard(CHEAT_DUNGEON, _("
\8f¬
\8c^
\8cÅ
\92èVault
\82ð
\94z
\92u
\82Å
\82«
\82Ü
\82¹
\82ñ
\82Å
\82µ
\82½
\81B", "Could not place lesser vault."));
\r
349 /* pick type of transformation (0-7) */
\r
350 transno = randint0(8);
\r
352 /* calculate offsets */
\r
356 /* Some huge vault cannot be ratated to fit in the dungeon */
\r
357 if (x + 2 > cur_hgt - 2)
\r
359 /* Forbid 90 or 270 degree ratation */
\r
363 coord_trans(&x, &y, 0, 0, transno);
\r
383 /* Find and reserve some space in the dungeon. Get center of room. */
\r
384 if (!find_space(&yval, &xval, abs(y), abs(x))) return FALSE;
\r
387 v_ptr = &v_info[2];
\r
391 msg_format_wizard(CHEAT_DUNGEON, _("
\8f¬
\8c^Vault(%s)
\82ð
\90¶
\90¬
\82µ
\82Ü
\82µ
\82½
\81B", "Lesser vault (%s)."), v_name + v_ptr->name);
\r
393 /* Hack -- Build the vault */
\r
394 build_vault(yval, xval, v_ptr->hgt, v_ptr->wid,
\r
395 v_text + v_ptr->text, xoffset, yoffset, transno);
\r
401 * @brief
\83^
\83C
\83v8
\82Ì
\95\94\89®
\81cv_info.txt
\82æ
\82è
\91å
\8c^vault
\82ð
\90¶
\90¬
\82·
\82é / Type 8 -- greater vaults (see "v_info.txt")
\r
404 bool build_type8(void)
\r
408 POSITION xval, yval;
\r
411 int xoffset, yoffset;
\r
413 /* Pick a greater vault */
\r
414 for (dummy = 0; dummy < SAFE_MAX_ATTEMPTS; dummy++)
\r
416 /* Access a random vault record */
\r
417 v_ptr = &v_info[randint0(max_v_idx)];
\r
419 /* Accept the first greater vault */
\r
420 if (v_ptr->typ == 8) break;
\r
423 /* No greater vault found */
\r
424 if (dummy >= SAFE_MAX_ATTEMPTS)
\r
426 msg_print_wizard(CHEAT_DUNGEON, _("
\91å
\8c^
\8cÅ
\92èVault
\82ð
\94z
\92u
\82Å
\82«
\82Ü
\82¹
\82ñ
\82Å
\82µ
\82½
\81B", "Could not place greater vault."));
\r
430 /* pick type of transformation (0-7) */
\r
431 transno = randint0(8);
\r
433 /* calculate offsets */
\r
437 /* Some huge vault cannot be ratated to fit in the dungeon */
\r
438 if (x + 2 > cur_hgt - 2)
\r
440 /* Forbid 90 or 270 degree ratation */
\r
444 coord_trans(&x, &y, 0, 0, transno);
\r
465 * Try to allocate space for room. If fails, exit
\r
467 * Hack -- Prepare a bit larger space (+2, +2) to
\r
468 * prevent generation of vaults with no-entrance.
\r
470 /* Find and reserve some space in the dungeon. Get center of room. */
\r
471 if (!find_space(&yval, &xval, (POSITION)(abs(y) + 2), (POSITION)(abs(x) + 2))) return FALSE;
\r
474 v_ptr = &v_info[76 + randint1(3)];
\r
477 msg_format_wizard(CHEAT_DUNGEON, _("
\91å
\8c^
\8cÅ
\92èVault(%s)
\82ð
\90¶
\90¬
\82µ
\82Ü
\82µ
\82½
\81B", "Greater vault (%s)."), v_name + v_ptr->name);
\r
479 /* Hack -- Build the vault */
\r
480 build_vault(yval, xval, v_ptr->hgt, v_ptr->wid,
\r
481 v_text + v_ptr->text, xoffset, yoffset, transno);
\r