OSDN Git Service

忍者は暗闇の洞窟で地形やアイテムが丸見えだったが, モンスターがこれに
[hengband/hengband.git] / src / streams.c
index f3c8f98..f00ab01 100644 (file)
@@ -6,11 +6,11 @@
  */
 
 /*
- * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
+ * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
  *
- * This software may be copied and distributed for educational, research, and
- * not for profit purposes provided that this copyright and statement are
- * included in all such copies.
+ * This software may be copied and distributed for educational, research,
+ * and not for profit purposes provided that this copyright and statement
+ * are included in all such copies.  Other copyrights may also apply.
  */
 
 #include "angband.h"
@@ -44,7 +44,7 @@ static void recursive_river(int x1, int y1, int x2, int y2, int feat1, int feat2
                if (dy != 0)
                {
                        /* perturbation perpendicular to path */
-                       changex = randint(abs(dy)) * 2 - abs(dy);
+                       changex = randint1(abs(dy)) * 2 - abs(dy);
                }
                else
                {
@@ -54,7 +54,7 @@ static void recursive_river(int x1, int y1, int x2, int y2, int feat1, int feat2
                if (dx != 0)
                {
                        /* perturbation perpendicular to path */
-                       changey = randint(abs(dx)) * 2 - abs(dx);
+                       changey = randint1(abs(dx)) * 2 - abs(dx);
                }
                else
                {
@@ -72,11 +72,11 @@ static void recursive_river(int x1, int y1, int x2, int y2, int feat1, int feat2
                recursive_river(x1 + dx + changex, y1 + dy + changey, x2, y2, feat1, feat2, width);
 
                /* Split the river some of the time - junctions look cool */
-               if ((randint(DUN_WAT_CHG) == 1) && (width > 0))
+               if (one_in_(DUN_WAT_CHG) && (width > 0))
                {
                        recursive_river(x1 + dx + changex, y1 + dy + changey,
-                                       x1 + 8 * (dx + changex), y1 + 8 * (dy + changey),
-                                       feat1, feat2, width - 1);
+                                       x1 + 8 * (dx + changex), y1 + 8 * (dy + changey),
+                                       feat1, feat2, width - 1);
                }
        }
        else
@@ -95,7 +95,7 @@ static void recursive_river(int x1, int y1, int x2, int y2, int feat1, int feat2
                                {
                                        for (tx = x - width - 1; tx <= x + width + 1; tx++)
                                        {
-                                               if (!in_bounds(ty, tx)) continue;
+                                               if (!in_bounds2(ty, tx)) continue;
 
                                                c_ptr = &cave[ty][tx];
 
@@ -116,10 +116,13 @@ static void recursive_river(int x1, int y1, int x2, int y2, int feat1, int feat2
                                                else
                                                        c_ptr->feat = feat1;
 
+                                               /* Clear garbage of hidden trap or door */
+                                               c_ptr->mimic = 0;
+
                                                /* Lava terrain glows */
                                                if ((feat1 == FEAT_DEEP_LAVA) ||  (feat1 == FEAT_SHAL_LAVA))
                                                {
-                                                       c_ptr->info |= CAVE_GLOW;
+                                                       if (!(d_info[dungeon_type].flags1 & DF1_DARKNESS)) c_ptr->info |= CAVE_GLOW;
                                                }
 
                                                /* Hack -- don't teleport here */
@@ -145,16 +148,16 @@ void add_river(int feat1, int feat2)
 
 
        /* Hack -- Choose starting point */
-       y2 = randint(cur_hgt / 2 - 2) + cur_hgt / 2;
-       x2 = randint(cur_wid / 2 - 2) + cur_wid / 2;
+       y2 = randint1(cur_hgt / 2 - 2) + cur_hgt / 2;
+       x2 = randint1(cur_wid / 2 - 2) + cur_wid / 2;
 
        /* Hack -- Choose ending point somewhere on boundary */
-       switch(randint(4))
+       switch(randint1(4))
        {
                case 1:
                {
                        /* top boundary */
-                       x1 = randint(cur_wid-2)+1;
+                       x1 = randint1(cur_wid-2)+1;
                        y1 = 1;
                        break;
                }
@@ -162,26 +165,26 @@ void add_river(int feat1, int feat2)
                {
                        /* left boundary */
                        x1 = 1;
-                       y1 = randint(cur_hgt-2)+1;
+                       y1 = randint1(cur_hgt-2)+1;
                        break;
                }
                case 3:
                {
                        /* right boundary */
                        x1 = cur_wid-1;
-                       y1 = randint(cur_hgt-2)+1;
+                       y1 = randint1(cur_hgt-2)+1;
                        break;
                }
                case 4:
                {
                        /* bottom boundary */
-                       x1 = randint(cur_wid-2)+1;
+                       x1 = randint1(cur_wid-2)+1;
                        y1 = cur_hgt-1;
                        break;
                }
        }
 
-       wid = randint(DUN_WAT_RNG);
+       wid = randint1(DUN_WAT_RNG);
        recursive_river(x1, y1, x2, y2, feat1, feat2, wid);
 
        /* Hack - Save the location as a "room" */
@@ -212,11 +215,11 @@ void build_streamer(int feat, int chance)
        cave_type *c_ptr;
 
        /* Hack -- Choose starting point */
-       y = rand_spread(cur_hgt / 2, 10);
-       x = rand_spread(cur_wid / 2, 15);
+       y = rand_spread(cur_hgt / 2, cur_hgt / 6);
+       x = rand_spread(cur_wid / 2, cur_wid / 6);
 
        /* Choose a random compass direction */
-       dir = ddd[rand_int(8)];
+       dir = ddd[randint0(8)];
 
        /* Place streamer into dungeon */
        while (dummy < SAFE_MAX_ATTEMPTS)
@@ -233,7 +236,7 @@ void build_streamer(int feat, int chance)
                        {
                                ty = rand_spread(y, d);
                                tx = rand_spread(x, d);
-                               if (!in_bounds(ty, tx)) continue;
+                               if (!in_bounds2(ty, tx)) continue;
                                break;
                        }
 
@@ -247,7 +250,7 @@ void build_streamer(int feat, int chance)
                        if ((feat >= FEAT_MAGMA) && (feat <= FEAT_WALL_SOLID))
                        {
                                if (!is_extra_grid(c_ptr) && !is_inner_grid(c_ptr) && !is_outer_grid(c_ptr) && !is_solid_grid(c_ptr)) continue;
-                               if ((c_ptr->feat >= FEAT_DOOR_HEAD) && (c_ptr->feat <= FEAT_SECRET)) continue;
+                               if (is_closed_door(c_ptr->feat)) continue;
                                if ((feat == FEAT_MAGMA) || (feat == FEAT_QUARTZ)) treasure = TRUE;
                        }
                        else
@@ -258,8 +261,16 @@ void build_streamer(int feat, int chance)
                        /* Clear previous contents, add proper vein type */
                        c_ptr->feat = feat;
 
-                       /* Hack -- Add some (known) treasure */
-                       if (treasure && (rand_int(chance) == 0)) c_ptr->feat += 0x04;
+                       /* Paranoia: Clear mimic field */
+                       c_ptr->mimic = 0;
+
+                       /* Hack -- Add some known treasure */
+                       if (treasure && one_in_(chance))
+                               c_ptr->feat += (FEAT_MAGMA_K - FEAT_MAGMA);
+
+                       /* Hack -- Add some hidden treasure */
+                       else if (treasure && one_in_(chance/4))
+                               c_ptr->feat += (FEAT_MAGMA_H - FEAT_MAGMA);
                }
 
                if (dummy >= SAFE_MAX_ATTEMPTS)
@@ -305,7 +316,6 @@ void place_trees(int x, int y)
                        c_ptr = &cave[j][i];
 
                        if (c_ptr->info & CAVE_ICKY) continue;
-                       if (c_ptr->info & CAVE_TRAP) continue;
                        if (c_ptr->o_idx) continue;
 
                        /* Want square to be in the circle and accessable. */
@@ -315,9 +325,9 @@ void place_trees(int x, int y)
                                 * Clear previous contents, add feature
                                 * The border mainly gets trees, while the center gets rubble
                                 */
-                               if ((distance(j, i, y, x) > 1) || (randint(100) < 25))
+                               if ((distance(j, i, y, x) > 1) || (randint1(100) < 25))
                                {
-                                       if (randint(100) < 75)
+                                       if (randint1(100) < 75)
                                                cave[j][i].feat = FEAT_TREES;
                                }
                                else
@@ -325,14 +335,17 @@ void place_trees(int x, int y)
                                        cave[j][i].feat = FEAT_RUBBLE;
                                }
 
+                               /* Clear garbage of hidden trap or door */
+                               c_ptr->mimic = 0;
+
                                /* Light area since is open above */
-                               cave[j][i].info |= (CAVE_GLOW | CAVE_ROOM);
+                               if (!(d_info[dungeon_type].flags1 & DF1_DARKNESS)) cave[j][i].info |= (CAVE_GLOW | CAVE_ROOM);
                        }
                }
        }
 
        /* No up stairs in ironman mode */
-       if (!ironman_downward && (randint(3) == 1))
+       if (!ironman_downward && one_in_(3))
        {
                /* up stair */
                cave[y][x].feat = FEAT_LESS;
@@ -345,89 +358,22 @@ void place_trees(int x, int y)
  */
 void destroy_level(void)
 {
-       int y1, x1, y, x, k, t, n;
-
-       cave_type *c_ptr;
+       int y1, x1, n;
 
        /* Note destroyed levels */
 #ifdef JP
-if (cheat_room) msg_print("Ç˲õ¤µ¤ì¤¿³¬");
+       if (cheat_room) msg_print("Ç˲õ¤µ¤ì¤¿³¬");
 #else
        if (cheat_room) msg_print("Destroyed Level");
 #endif
 
-
        /* Drop a few epi-centers (usually about two) */
-       for (n = 0; n < randint(5); n++)
+       for (n = 0; n < randint1(5); n++)
        {
                /* Pick an epi-center */
                x1 = rand_range(5, cur_wid - 1 - 5);
                y1 = rand_range(5, cur_hgt - 1 - 5);
 
-               /* Big area of affect */
-               for (y = (y1 - 15); y <= (y1 + 15); y++)
-               {
-                       for (x = (x1 - 15); x <= (x1 + 15); x++)
-                       {
-                               /* Skip illegal grids */
-                               if (!in_bounds(y, x)) continue;
-
-                               /* Extract the distance */
-                               k = distance(y1, x1, y, x);
-
-                               /* Stay in the circle of death */
-                               if (k >= 16) continue;
-
-                               /* Delete the monster (if any) */
-                               delete_monster(y, x);
-
-                               /* Access the grid */
-                               c_ptr = &cave[y][x];
-
-                               /* Destroy valid grids */
-                               if (cave_valid_grid(c_ptr))
-                               {
-                                       /* Delete objects */
-                                       delete_object(y, x);
-
-                                       /* Wall (or floor) type */
-                                       t = rand_int(200);
-
-                                       /* Granite */
-                                       if (t < 20)
-                                       {
-                                               /* Create granite wall */
-                                               place_extra_grid(c_ptr);
-                                       }
-
-                                       /* Quartz */
-                                       else if (t < 70)
-                                       {
-                                               /* Create quartz vein */
-                                               c_ptr->feat = FEAT_QUARTZ;
-                                       }
-
-                                       /* Magma */
-                                       else if (t < 100)
-                                       {
-                                               /* Create magma vein */
-                                               c_ptr->feat = FEAT_MAGMA;
-                                       }
-
-                                       /* Floor */
-                                       else
-                                       {
-                                               /* Create floor */
-                                               place_floor_grid(c_ptr);
-                                       }
-
-                                       /* No longer part of a room or vault */
-                                       c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
-
-                                       /* No longer illuminated or known */
-                                       c_ptr->info &= ~(CAVE_MARK | CAVE_GLOW);
-                               }
-                       }
-               }
+               (void)destroy_area(y1, x1, 15, TRUE);
        }
 }