OSDN Git Service

ダンジョンの主の配置コードを関数にまとめた. また, *破壊*等で消えた
authornothere <nothere@0568b783-4c39-0410-ac80-bf13821ea2a2>
Fri, 20 Jun 2003 12:17:29 +0000 (12:17 +0000)
committernothere <nothere@0568b783-4c39-0410-ac80-bf13821ea2a2>
Fri, 20 Jun 2003 12:17:29 +0000 (12:17 +0000)
ダンジョンの主をalloc_monster()から再生成する場合は, それだけでモンス
ター配置1回分になるように修正.

src/externs.h
src/generate.c
src/monster2.c

index 17e0268..7150722 100644 (file)
@@ -869,6 +869,7 @@ extern void update_monsters(bool full);
 extern bool place_monster_aux(int who, int y, int x, int r_idx, u32b mode);
 extern bool place_monster(int y, int x, u32b mode);
 extern bool alloc_horde(int y, int x);
+extern bool alloc_guardian(void);
 extern bool alloc_monster(int dis, u32b mode);
 extern bool summon_specific(int who, int y1, int x1, int lev, int type, u32b mode);
 extern bool summon_named_creature (int who, int oy, int ox, int r_idx, u32b mode);
index 8ea9a51..7b9d444 100644 (file)
@@ -1083,30 +1083,8 @@ msg_format("
                alloc_object(ALLOC_SET_BOTH, ALLOC_TYP_GOLD, randnor(DUN_AMT_GOLD, 3));
        }
 
-       /* Put an Artifact and Artifact Guardian is requested */
-       if (d_info[dungeon_type].final_guardian && (d_info[dungeon_type].maxdepth == dun_level))
-       {
-               int oy;
-               int ox;
-               int try = 4000;
-
-               /* Find a good position */
-               while(try)
-               {
-                       /* Get a random spot */
-                       oy = randint1(cur_hgt - 4) + 2;
-                       ox = randint1(cur_wid - 4) + 2;
-
-                       /* Is it a good spot ? */
-                       if (cave_empty_bold2(oy, ox) && monster_can_cross_terrain(cave[oy][ox].feat, &r_info[d_info[dungeon_type].final_guardian]))
-                       {
-                               /* Place the guardian */
-                               if (place_monster_aux(0, oy, ox, d_info[dungeon_type].final_guardian, (PM_ALLOW_GROUP | PM_NO_KAGE | PM_NO_PET))) break;
-                       }
-                       /* One less try */
-                       try--;
-               }
-       }
+       /* Put the Guardian */
+       (void)alloc_guardian();
 
        if (empty_level && (!one_in_(DARK_EMPTY) || (randint1(100) > dun_level)) && !(d_info[dungeon_type].flags1 & DF1_DARKNESS))
        {
index 3fe3f5a..ca6df59 100644 (file)
@@ -3846,31 +3846,21 @@ bool alloc_horde(int y, int x)
 #endif /* MONSTER_HORDES */
 
 
-
 /*
- * Attempt to allocate a random monster in the dungeon.
- *
- * Place the monster at least "dis" distance from the player.
- *
- * Use "slp" to choose the initial "sleep" status
- *
- * Use "monster_level" for the monster level
+ * Put the Guardian
  */
-bool alloc_monster(int dis, u32b mode)
+bool alloc_guardian(void)
 {
-       int                     y = 0, x = 0;
-       int         attempts_left = 10000;
        int guardian = d_info[dungeon_type].final_guardian;
 
-       /* Put an Guardian */
-       if(guardian && d_info[dungeon_type].maxdepth == dun_level && r_info[guardian].cur_num < r_info[guardian].max_num )
+       if (guardian && (d_info[dungeon_type].maxdepth == dun_level) && (r_info[guardian].cur_num < r_info[guardian].max_num))
        {
                int oy;
                int ox;
                int try = 4000;
 
                /* Find a good position */
-               while(try)
+               while (try)
                {
                        /* Get a random spot */
                        oy = randint1(cur_hgt - 4) + 2;
@@ -3880,13 +3870,34 @@ bool alloc_monster(int dis, u32b mode)
                        if (cave_empty_bold2(oy, ox) && monster_can_cross_terrain(cave[oy][ox].feat, &r_info[guardian]))
                        {
                                /* Place the guardian */
-                               if (place_monster_aux(0, oy, ox, guardian, (PM_ALLOW_GROUP | PM_NO_KAGE | PM_NO_PET))) break;
+                               if (place_monster_aux(0, oy, ox, guardian, (PM_ALLOW_GROUP | PM_NO_KAGE | PM_NO_PET))) return TRUE;
                        }
+
                        /* One less try */
                        try--;
                }
        }
 
+       return FALSE;
+}
+
+
+/*
+ * Attempt to allocate a random monster in the dungeon.
+ *
+ * Place the monster at least "dis" distance from the player.
+ *
+ * Use "slp" to choose the initial "sleep" status
+ *
+ * Use "monster_level" for the monster level
+ */
+bool alloc_monster(int dis, u32b mode)
+{
+       int                     y = 0, x = 0;
+       int         attempts_left = 10000;
+
+       /* Put the Guardian */
+       if (alloc_guardian()) return TRUE;
 
        /* Find a legal, distant, unoccupied, space */
        while (attempts_left--)