OSDN Git Service

randint() == 1, rand_int() == 0, rand_int() == 1 を全て one_in_()に、
[hengband/hengband.git] / src / spells3.c
index d3e716b..56fb157 100644 (file)
@@ -122,6 +122,9 @@ bool teleport_away(int m_idx, int dis, bool dec_valour)
        m_ptr->fy = ny;
        m_ptr->fx = nx;
 
+       /* Forget the counter target */
+       reset_target(m_ptr);
+
        /* Update the monster (new location) */
        update_mon(m_idx, TRUE);
 
@@ -708,6 +711,9 @@ static int choose_dungeon(cptr note)
                i = inkey();
                if (i == ESCAPE)
                {
+                       /* Free the "dun" array */
+                       C_KILL(dun, max_d_idx, s16b);
+
                        screen_load();
                        return 0;
                }
@@ -719,6 +725,10 @@ static int choose_dungeon(cptr note)
                else bell();
        }
        screen_load();
+
+       /* Free the "dun" array */
+       C_KILL(dun, max_d_idx, s16b);
+
        return select_dungeon;
 }
 
@@ -2158,6 +2168,42 @@ bool item_tester_hook_weapon_armour(object_type *o_ptr)
 
 
 /*
+ * Check if an object is nameless weapon or armour
+ */
+bool item_tester_hook_nameless_weapon_armour(object_type *o_ptr)
+{
+       if (o_ptr->name1 || o_ptr->art_name || o_ptr->name2 || o_ptr->xtra3)
+               return FALSE;
+
+       switch (o_ptr->tval)
+       {
+               case TV_SWORD:
+               case TV_HAFTED:
+               case TV_POLEARM:
+               case TV_DIGGING:
+               case TV_BOW:
+               case TV_BOLT:
+               case TV_ARROW:
+               case TV_SHOT:
+               case TV_DRAG_ARMOR:
+               case TV_HARD_ARMOR:
+               case TV_SOFT_ARMOR:
+               case TV_SHIELD:
+               case TV_CLOAK:
+               case TV_CROWN:
+               case TV_HELM:
+               case TV_BOOTS:
+               case TV_GLOVES:
+               {
+                       return (TRUE);
+               }
+       }
+
+       return (FALSE);
+}
+
+
+/*
  * Break the curse of an item
  */
 static void break_curse(object_type *o_ptr)
@@ -2379,7 +2425,7 @@ msg_print("
                msg_print("The enchantment failed.");
 #endif
 
-               if (randint(3)==1) chg_virtue(V_ENCHANT, -1);
+               if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
        }
        else
                chg_virtue(V_ENCHANT, 1);
@@ -2402,7 +2448,7 @@ bool artifact_scroll(void)
 
        item_tester_no_ryoute = TRUE;
        /* Enchant weapon/armour */
-       item_tester_hook = item_tester_hook_weapon_armour;
+       item_tester_hook = item_tester_hook_nameless_weapon_armour;
 
        /* Get an item */
 #ifdef JP
@@ -2517,7 +2563,7 @@ msg_print("
                msg_print("The enchantment failed.");
 #endif
 
-               if (randint(3)==1) chg_virtue(V_ENCHANT, -1);
+               if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
        }
        else
                chg_virtue(V_ENCHANT, 1);
@@ -2956,7 +3002,7 @@ s = "
 
 
                /* Back-fire */
-               if (rand_int(recharge_strength) == 0)
+               if (one_in_(recharge_strength))
                {
                        /* Activate the failure code. */
                        fail = TRUE;
@@ -2995,7 +3041,7 @@ s = "
                if (recharge_strength < 0) recharge_strength = 0;
 
                /* Back-fire */
-               if (rand_int(recharge_strength) == 0)
+               if (one_in_(recharge_strength))
                {
                        /* Activate the failure code. */
                        fail = TRUE;
@@ -3073,19 +3119,19 @@ msg_format("
                                /* 10% chance to blow up one rod, otherwise draining. */
                                if (o_ptr->tval == TV_ROD)
                                {
-                                       if (randint(10) == 1) fail_type = 2;
+                                       if (one_in_(10)) fail_type = 2;
                                        else fail_type = 1;
                                }
                                /* 75% chance to blow up one wand, otherwise draining. */
                                else if (o_ptr->tval == TV_WAND)
                                {
-                                       if (randint(3) != 1) fail_type = 2;
+                                       if (!one_in_(3)) fail_type = 2;
                                        else fail_type = 1;
                                }
                                /* 50% chance to blow up one staff, otherwise no effect. */
                                else if (o_ptr->tval == TV_STAFF)
                                {
-                                       if (randint(2) == 1) fail_type = 2;
+                                       if (one_in_(2)) fail_type = 2;
                                        else fail_type = 0;
                                }
                        }
@@ -3096,13 +3142,13 @@ msg_format("
                                /* 33% chance to blow up one rod, otherwise draining. */
                                if (o_ptr->tval == TV_ROD)
                                {
-                                       if (randint(3) == 1) fail_type = 2;
+                                       if (one_in_(3)) fail_type = 2;
                                        else fail_type = 1;
                                }
                                /* 20% chance of the entire stack, else destroy one wand. */
                                else if (o_ptr->tval == TV_WAND)
                                {
-                                       if (randint(5) == 1) fail_type = 3;
+                                       if (one_in_(5)) fail_type = 3;
                                        else fail_type = 2;
                                }
                                /* Blow up one staff. */
@@ -3120,9 +3166,9 @@ msg_format("
                                if (o_ptr->tval == TV_ROD)
                                {
 #ifdef JP
-msg_print("ËâÎϤ¬µÕÊ®¼Í¤·¤Æ¡¢¥í¥Ã¥É¤«¤é¤µ¤é¤ËËâÎϤòµÛ¤¤¼è¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
+msg_print("ËâÎϤòµÛ¤¤¼è¤ë¤Î¤Ë¼ºÇÔ¤·¤¿¡£¥í¥Ã¥É¤ÎËâÎϤÏÁ´¤Æȯ»¶¤·¤Æ¤·¤Þ¤Ã¤¿¡£");
 #else
-                                       msg_print("The recharge backfires, draining the rod further!");
+                                       msg_print("You failed to absorb magic power. All magic power of your rod had gone!");
 #endif
 
                                        if (o_ptr->timeout < 10000)
@@ -3338,7 +3384,7 @@ msg_format("%s 
                return TRUE;
        }
 
-       if (!(o_ptr->art_name || o_ptr->name1 || o_ptr->name2) || (randint(3) == 1))
+       if (!(o_ptr->art_name || o_ptr->name1 || o_ptr->name2) || one_in_(3))
        {
                /* Describe */
 #ifdef JP
@@ -4987,7 +5033,7 @@ void acid_dam(int dam, cptr kb_str, int monspell)
        if (double_resist) dam = (dam + 2) / 3;
 
        if ((!(double_resist || p_ptr->resist_acid)) &&
-           randint(HURT_CHANCE) == 1)
+           one_in_(HURT_CHANCE))
                (void)do_dec_stat(A_CHR);
 
        /* If any armor gets hit, defend the player */
@@ -5027,7 +5073,7 @@ void elec_dam(int dam, cptr kb_str, int monspell)
        if (double_resist) dam = (dam + 2) / 3;
 
        if ((!(double_resist || p_ptr->resist_elec)) &&
-           randint(HURT_CHANCE) == 1)
+           one_in_(HURT_CHANCE))
                (void)do_dec_stat(A_DEX);
 
        /* Take damage */
@@ -5064,7 +5110,7 @@ void fire_dam(int dam, cptr kb_str, int monspell)
        if (double_resist) dam = (dam + 2) / 3;
 
        if ((!(double_resist || p_ptr->resist_fire)) &&
-           randint(HURT_CHANCE) == 1)
+           one_in_(HURT_CHANCE))
                (void)do_dec_stat(A_STR);
 
        /* Take damage */
@@ -5100,7 +5146,7 @@ void cold_dam(int dam, cptr kb_str, int monspell)
        if (double_resist) dam = (dam + 2) / 3;
 
        if ((!(double_resist || p_ptr->resist_cold)) &&
-           randint(HURT_CHANCE) == 1)
+           one_in_(HURT_CHANCE))
                (void)do_dec_stat(A_STR);
 
        /* Take damage */
@@ -5578,7 +5624,7 @@ s = "
                recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
 
                /* Back-fire */
-               if (rand_int(recharge_strength) == 0)
+               if (one_in_(recharge_strength))
                {
                        /* Activate the failure code. */
                        fail = TRUE;
@@ -5610,7 +5656,7 @@ msg_print("
                if (recharge_strength < 0) recharge_strength = 0;
 
                /* Back-fire */
-               if (rand_int(recharge_strength) == 0)
+               if (one_in_(recharge_strength))
                {
                        /* Activate the failure code. */
                        fail = TRUE;
@@ -5702,19 +5748,19 @@ msg_format("
                                /* 10% chance to blow up one rod, otherwise draining. */
                                if (o_ptr->tval == TV_ROD)
                                {
-                                       if (randint(10) == 1) fail_type = 2;
+                                       if (one_in_(10)) fail_type = 2;
                                        else fail_type = 1;
                                }
                                /* 75% chance to blow up one wand, otherwise draining. */
                                else if (o_ptr->tval == TV_WAND)
                                {
-                                       if (randint(3) != 1) fail_type = 2;
+                                       if (!one_in_(3)) fail_type = 2;
                                        else fail_type = 1;
                                }
                                /* 50% chance to blow up one staff, otherwise no effect. */
                                else if (o_ptr->tval == TV_STAFF)
                                {
-                                       if (randint(2) == 1) fail_type = 2;
+                                       if (one_in_(2)) fail_type = 2;
                                        else fail_type = 0;
                                }
                        }
@@ -5725,13 +5771,13 @@ msg_format("
                                /* 33% chance to blow up one rod, otherwise draining. */
                                if (o_ptr->tval == TV_ROD)
                                {
-                                       if (randint(3) == 1) fail_type = 2;
+                                       if (one_in_(3)) fail_type = 2;
                                        else fail_type = 1;
                                }
                                /* 20% chance of the entire stack, else destroy one wand. */
                                else if (o_ptr->tval == TV_WAND)
                                {
-                                       if (randint(5) == 1) fail_type = 3;
+                                       if (one_in_(5)) fail_type = 3;
                                        else fail_type = 2;
                                }
                                /* Blow up one staff. */