OSDN Git Service

トラップ感知のアイテムを使ったとき、未判明のアイテムを使ってまわりに
authormogami <mogami@0568b783-4c39-0410-ac80-bf13821ea2a2>
Wed, 7 Aug 2002 15:55:23 +0000 (15:55 +0000)
committermogami <mogami@0568b783-4c39-0410-ac80-bf13821ea2a2>
Wed, 7 Aug 2002 15:55:23 +0000 (15:55 +0000)
トラップが無かったときは感知済み範囲の表示に影響しないように修正。

src/cmd5.c
src/cmd6.c
src/dungeon.c
src/externs.h
src/mind.c
src/racial.c
src/spells2.c

index b15640e..4f1b775 100644 (file)
@@ -1059,7 +1059,7 @@ static bool cast_life_spell(int spell)
                (void)lite_area(damroll(2, (plev / 2)), (plev / 10) + 1);
                break;
        case 4: /* Detect Traps + Secret Doors */
-               (void)detect_traps(DETECT_RAD_DEFAULT);
+               (void)detect_traps(DETECT_RAD_DEFAULT, TRUE);
                (void)detect_doors(DETECT_RAD_DEFAULT);
                (void)detect_stairs(DETECT_RAD_DEFAULT);
                break;
@@ -1211,7 +1211,7 @@ static bool cast_sorcery_spell(int spell)
                teleport_player(10);
                break;
        case 2: /* Detect Doors and Traps */
-               (void)detect_traps(DETECT_RAD_DEFAULT);
+               (void)detect_traps(DETECT_RAD_DEFAULT, TRUE);
                (void)detect_doors(DETECT_RAD_DEFAULT);
                (void)detect_stairs(DETECT_RAD_DEFAULT);
                break;
@@ -1367,7 +1367,7 @@ static bool cast_nature_spell(int spell)
                        damroll(3 + ((plev - 1) / 5), 4));
                break;
        case 2: /* Detect Doors & Traps */
-               (void)detect_traps(DETECT_RAD_DEFAULT);
+               (void)detect_traps(DETECT_RAD_DEFAULT, TRUE);
                (void)detect_doors(DETECT_RAD_DEFAULT);
                (void)detect_stairs(DETECT_RAD_DEFAULT);
                break;
@@ -1419,7 +1419,7 @@ take_hit(DAMAGE_NOESCAPE, damroll(2, 2), "
                break;
        case 10: /* Nature Awareness -- downgraded */
                map_area(DETECT_RAD_MAP);
-               (void)detect_traps(DETECT_RAD_DEFAULT);
+               (void)detect_traps(DETECT_RAD_DEFAULT, TRUE);
                (void)detect_doors(DETECT_RAD_DEFAULT);
                (void)detect_stairs(DETECT_RAD_DEFAULT);
                (void)detect_monsters_normal(DETECT_RAD_DEFAULT);
@@ -3339,7 +3339,7 @@ static bool cast_arcane_spell(int spell)
                (void)set_cut(p_ptr->cut - 10);
                break;
        case 8: /* Detect Doors & Traps */
-               (void)detect_traps(DETECT_RAD_DEFAULT);
+               (void)detect_traps(DETECT_RAD_DEFAULT, TRUE);
                (void)detect_doors(DETECT_RAD_DEFAULT);
                (void)detect_stairs(DETECT_RAD_DEFAULT);
                break;
index 33d9cc2..4b8b889 100644 (file)
@@ -1208,7 +1208,7 @@ msg_print("
                        wiz_lite(TRUE, FALSE);
                        (void)do_inc_stat(A_INT);
                        (void)do_inc_stat(A_WIS);
-                       (void)detect_traps(DETECT_RAD_DEFAULT);
+                       (void)detect_traps(DETECT_RAD_DEFAULT, TRUE);
                        (void)detect_doors(DETECT_RAD_DEFAULT);
                        (void)detect_stairs(DETECT_RAD_DEFAULT);
                        (void)detect_treasure(DETECT_RAD_DEFAULT);
@@ -1472,7 +1472,7 @@ void do_cmd_quaff_potion(void)
  * include scrolls with no effects but recharge or identify, which are
  * cancelled before use.  XXX Reading them still takes a turn, though.
  */
-static void do_cmd_read_scroll_aux(int item)
+static void do_cmd_read_scroll_aux(int item, bool known)
 {
        int         k, used_up, ident, lev;
        object_type *o_ptr;
@@ -1768,7 +1768,7 @@ static void do_cmd_read_scroll_aux(int item)
 
                case SV_SCROLL_DETECT_TRAP:
                {
-                       if (detect_traps(DETECT_RAD_DEFAULT)) ident = TRUE;
+                       if (detect_traps(DETECT_RAD_DEFAULT, known)) ident = TRUE;
                        break;
                }
 
@@ -2159,6 +2159,7 @@ static bool item_tester_hook_readable(object_type *o_ptr)
 
 void do_cmd_read_scroll(void)
 {
+       object_type *o_ptr;
        int  item;
        cptr q, s;
 
@@ -2214,12 +2215,24 @@ void do_cmd_read_scroll(void)
 
        if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
 
+       /* Get the item (in the pack) */
+       if (item >= 0)
+       {
+               o_ptr = &inventory[item];
+       }
+
+       /* Get the item (on the floor) */
+       else
+       {
+               o_ptr = &o_list[0 - item];
+       }
+
        /* Read the scroll */
-       do_cmd_read_scroll_aux(item);
+       do_cmd_read_scroll_aux(item, object_aware_p(o_ptr));
 }
 
 
-static int staff_effect(int sval, bool *use_charge, bool magic)
+static int staff_effect(int sval, bool *use_charge, bool magic, bool known)
 {
        int k;
        int ident = FALSE;
@@ -2364,7 +2377,7 @@ static int staff_effect(int sval, bool *use_charge, bool magic)
 
                case SV_STAFF_DETECT_TRAP:
                {
-                       if (detect_traps(DETECT_RAD_DEFAULT)) ident = TRUE;
+                       if (detect_traps(DETECT_RAD_DEFAULT, known)) ident = TRUE;
                        break;
                }
 
@@ -2665,7 +2678,7 @@ static void do_cmd_use_staff_aux(int item)
        /* Sound */
        sound(SOUND_ZAP);
 
-       ident = staff_effect(o_ptr->sval, &use_charge, FALSE);
+       ident = staff_effect(o_ptr->sval, &use_charge, FALSE, object_aware_p(o_ptr));
 
        if (!(object_aware_p(o_ptr)))
        {
@@ -3282,7 +3295,7 @@ static int rod_effect(int sval, int dir, bool *use_charge, bool magic)
        {
                case SV_ROD_DETECT_TRAP:
                {
-                       if (detect_traps(DETECT_RAD_DEFAULT)) ident = TRUE;
+                       if (detect_traps(DETECT_RAD_DEFAULT, dir ? TRUE : FALSE)) ident = TRUE;
                        break;
                }
 
@@ -3519,7 +3532,8 @@ static int rod_effect(int sval, int dir, bool *use_charge, bool magic)
  */
 static void do_cmd_zap_rod_aux(int item)
 {
-       int         ident, chance, dir, lev, fail;
+       int ident, chance, lev, fail;
+        int dir = 0;
        object_type *o_ptr;
        bool success;
 
@@ -4109,7 +4123,7 @@ take_hit(DAMAGE_LOSELIFE, damroll(3,8), "
                                take_hit(DAMAGE_LOSELIFE, damroll(3, 8), "the Jewel of Judgement", -1);
 #endif
 
-                               (void)detect_traps(DETECT_RAD_DEFAULT);
+                               (void)detect_traps(DETECT_RAD_DEFAULT, TRUE);
                                (void)detect_doors(DETECT_RAD_DEFAULT);
                                (void)detect_stairs(DETECT_RAD_DEFAULT);
 
@@ -6558,7 +6572,7 @@ msg_print("
                                return;
                        }
 
-                 do_cmd_read_scroll_aux(item);
+                 do_cmd_read_scroll_aux(item, TRUE);
                  break;
                }
 
@@ -7152,7 +7166,7 @@ msg_print("
                }
                else
                {
-                       staff_effect(sval, &use_charge, TRUE);
+                       staff_effect(sval, &use_charge, TRUE, TRUE);
                        if (!use_charge) return;
 
                        /* Delayed optimization */
index 766d106..9a438c9 100644 (file)
@@ -1344,7 +1344,7 @@ static void gere_music(s32b music)
                 case MUSIC_DETECT:
                 case MUSIC_DETECT+1:
                 case MUSIC_DETECT+2:
-                       detect_traps(DETECT_RAD_DEFAULT);
+                       detect_traps(DETECT_RAD_DEFAULT, TRUE);
                        detect_doors(DETECT_RAD_DEFAULT);
                        detect_stairs(DETECT_RAD_DEFAULT);
                        if ((p_ptr->lev > 14)  && (music  < MUSIC_DETECT+3)) p_ptr->magic_num1[0] = music+1;
index fb1abd6..274c14a 100644 (file)
@@ -928,7 +928,7 @@ extern void seal_of_mirror(int dam);
 /* spells2.c */
 extern void message_pain(int m_idx, int dam);
 extern void self_knowledge(void);
-extern bool detect_traps(int range);
+extern bool detect_traps(int range, bool known);
 extern bool detect_doors(int range);
 extern bool detect_stairs(int range);
 extern bool detect_treasure(int range);
index be4ed09..9d2bdd4 100644 (file)
@@ -861,7 +861,7 @@ static bool cast_mindcrafter_spell(int spell)
                        b = detect_monsters_normal(DETECT_RAD_DEFAULT);
                        if (plev > 14) b |= detect_monsters_invis(DETECT_RAD_DEFAULT);
                        if (plev > 4)  {
-                               b |= detect_traps(DETECT_RAD_DEFAULT);
+                               b |= detect_traps(DETECT_RAD_DEFAULT, TRUE);
                                b |= detect_doors(DETECT_RAD_DEFAULT);
                        }
                }
@@ -1597,7 +1597,7 @@ static bool cast_ninja_spell(int spell)
                detect_monsters_normal(DETECT_RAD_DEFAULT);
                if (plev > 4)
                {
-                       detect_traps(DETECT_RAD_DEFAULT);
+                       detect_traps(DETECT_RAD_DEFAULT, TRUE);
                        detect_doors(DETECT_RAD_DEFAULT);
                        detect_stairs(DETECT_RAD_DEFAULT);
                }
index 549cdcd..2cddf47 100644 (file)
@@ -1547,7 +1547,7 @@ msg_print("
                                msg_print("You examine your surroundings.");
 #endif
 
-                               (void)detect_traps(DETECT_RAD_DEFAULT);
+                               (void)detect_traps(DETECT_RAD_DEFAULT, TRUE);
                                (void)detect_doors(DETECT_RAD_DEFAULT);
                                (void)detect_stairs(DETECT_RAD_DEFAULT);
                        }
@@ -1803,7 +1803,7 @@ msg_print("
                                msg_print("You examine your surroundings.");
 #endif
 
-                               (void)detect_traps(DETECT_RAD_DEFAULT);
+                               (void)detect_traps(DETECT_RAD_DEFAULT, TRUE);
                                (void)detect_doors(DETECT_RAD_DEFAULT);
                                (void)detect_stairs(DETECT_RAD_DEFAULT);
                        }
index 58831a0..0756304 100644 (file)
@@ -3491,7 +3491,7 @@ prt("[
 /*
  * Detect all traps on current panel
  */
-bool detect_traps(int range)
+bool detect_traps(int range, bool known)
 {
        int             x, y;
        bool            detect = FALSE;
@@ -3512,7 +3512,7 @@ bool detect_traps(int range)
                        c_ptr = &cave[y][x];
 
                        /* Mark as detected */
-                       if (dist <= range)
+                       if (dist <= range && known)
                        {
                                if (dist <= range - 1)
                                        c_ptr->info |= (CAVE_IN_DETECT);
@@ -4497,7 +4497,7 @@ bool detect_all(int range)
        bool detect = FALSE;
 
        /* Detect everything */
-       if (detect_traps(range)) detect = TRUE;
+       if (detect_traps(range, TRUE)) detect = TRUE;
        if (detect_doors(range)) detect = TRUE;
        if (detect_stairs(range)) detect = TRUE;
        if (detect_treasure(range)) detect = TRUE;