OSDN Git Service

randint() == 1, rand_int() == 0, rand_int() == 1 を全て one_in_()に、
authorhabu <habu@0568b783-4c39-0410-ac80-bf13821ea2a2>
Fri, 15 Feb 2002 13:29:31 +0000 (13:29 +0000)
committerhabu <habu@0568b783-4c39-0410-ac80-bf13821ea2a2>
Fri, 15 Feb 2002 13:29:31 +0000 (13:29 +0000)
randint() != 1, rand_int() != 0, rand_int() != 1 を全て !one_in_()に置き変えた。
この作業中にユニークにダメージを与えた時に1/3でV_INDIVIDUALISMを-1する所の判定が&と&&を間違えているのを見つけたのでついでに直した。
ちゃんとできてるか不安なので、作業前の状態にone_in_prev,作業後の状態にone_in_afterというタグを付けておく。

25 files changed:
src/artifact.c
src/cave.c
src/cmd1.c
src/cmd2.c
src/cmd5.c
src/cmd6.c
src/dungeon.c
src/effects.c
src/generate.c
src/mane.c
src/melee1.c
src/melee2.c
src/monster2.c
src/mspells1.c
src/mspells2.c
src/mspells3.c
src/object2.c
src/racial.c
src/rooms.c
src/spells1.c
src/spells2.c
src/spells3.c
src/store.c
src/streams.c
src/xtra2.c

index 9e69651..fddc4c1 100644 (file)
@@ -34,14 +34,14 @@ static void curse_artifact(object_type * o_ptr)
 
        o_ptr->art_flags3 |= (TR3_HEAVY_CURSE | TR3_CURSED);
 
-       if (randint(4) == 1) o_ptr->art_flags3 |= TR3_PERMA_CURSE;
-       if (randint(3) == 1) o_ptr->art_flags3 |= TR3_TY_CURSE;
-       if (randint(2) == 1) o_ptr->art_flags3 |= TR3_AGGRAVATE;
-       if (randint(3) == 1) o_ptr->art_flags3 |= TR3_DRAIN_EXP;
-       if (randint(2) == 1) o_ptr->art_flags3 |= TR3_TELEPORT;
-       else if (randint(3) == 1) o_ptr->art_flags3 |= TR3_NO_TELE;
-
-       if ((p_ptr->pclass != CLASS_WARRIOR) && (p_ptr->pclass != CLASS_ARCHER) && (p_ptr->pclass != CLASS_CAVALRY) && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH) && (randint(3) == 1))
+       if (one_in_(4)) o_ptr->art_flags3 |= TR3_PERMA_CURSE;
+       if (one_in_(3)) o_ptr->art_flags3 |= TR3_TY_CURSE;
+       if (one_in_(2)) o_ptr->art_flags3 |= TR3_AGGRAVATE;
+       if (one_in_(3)) o_ptr->art_flags3 |= TR3_DRAIN_EXP;
+       if (one_in_(2)) o_ptr->art_flags3 |= TR3_TELEPORT;
+       else if (one_in_(3)) o_ptr->art_flags3 |= TR3_NO_TELE;
+
+       if ((p_ptr->pclass != CLASS_WARRIOR) && (p_ptr->pclass != CLASS_ARCHER) && (p_ptr->pclass != CLASS_CAVALRY) && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH) && one_in_(3))
                o_ptr->art_flags3 |= TR3_NO_MAGIC;
 
        o_ptr->ident |= IDENT_CURSED;
@@ -57,19 +57,19 @@ static void random_plus(object_type * o_ptr, bool is_scroll)
                if (!(o_ptr->art_flags1 & TR1_STR))
                {
                        o_ptr->art_flags1 |= TR1_STR;
-                       if (randint(2) == 1) return; /* 50% chance of being a "free" power */
+                       if (one_in_(2)) return; /* 50% chance of being a "free" power */
                }
 
                if (!(o_ptr->art_flags1 & TR1_CON))
                {
                        o_ptr->art_flags1 |= TR1_CON;
-                       if (randint(2) == 1) return;
+                       if (one_in_(2)) return;
                }
 
                if (!(o_ptr->art_flags1 & TR1_DEX))
                {
                        o_ptr->art_flags1 |= TR1_DEX;
-                       if (randint(2) == 1) return;
+                       if (one_in_(2)) return;
                }
        }
        else if (artifact_bias == BIAS_MAGE)
@@ -77,12 +77,12 @@ static void random_plus(object_type * o_ptr, bool is_scroll)
                if (!(o_ptr->art_flags1 & TR1_INT))
                {
                        o_ptr->art_flags1 |= TR1_INT;
-                       if (randint(2) == 1) return;
+                       if (one_in_(2)) return;
                }
                if ((o_ptr->tval == TV_GLOVES) && !(o_ptr->art_flags1 & TR1_MAGIC_MASTERY))
                {
                        o_ptr->art_flags1 |= TR1_MAGIC_MASTERY;
-                       if (randint(2) == 1) return;
+                       if (one_in_(2)) return;
                }
        }
        else if (artifact_bias == BIAS_PRIESTLY)
@@ -90,7 +90,7 @@ static void random_plus(object_type * o_ptr, bool is_scroll)
                if (!(o_ptr->art_flags1 & TR1_WIS))
                {
                        o_ptr->art_flags1 |= TR1_WIS;
-                       if (randint(2) == 1) return;
+                       if (one_in_(2)) return;
                }
        }
        else if (artifact_bias == BIAS_RANGER)
@@ -98,19 +98,19 @@ static void random_plus(object_type * o_ptr, bool is_scroll)
                if (!(o_ptr->art_flags1 & TR1_DEX))
                {
                        o_ptr->art_flags1 |= TR1_DEX;
-                       if (randint(2) == 1) return;
+                       if (one_in_(2)) return;
                }
 
                if (!(o_ptr->art_flags1 & TR1_CON))
                {
                        o_ptr->art_flags1 |= TR1_CON;
-                       if (randint(2) == 1) return; /* 50% chance of being a "free" power */
+                       if (one_in_(2)) return; /* 50% chance of being a "free" power */
                }
 
                if (!(o_ptr->art_flags1 & TR1_STR))
                {
                        o_ptr->art_flags1 |= TR1_STR;
-                       if (randint(2) == 1) return;
+                       if (one_in_(2)) return;
                }
        }
        else if (artifact_bias == BIAS_ROGUE)
@@ -118,12 +118,12 @@ static void random_plus(object_type * o_ptr, bool is_scroll)
                if (!(o_ptr->art_flags1 & TR1_STEALTH))
                {
                        o_ptr->art_flags1 |= TR1_STEALTH;
-                       if (randint(2) == 1) return;
+                       if (one_in_(2)) return;
                }
                if (!(o_ptr->art_flags1 & TR1_SEARCH))
                {
                        o_ptr->art_flags1 |= TR1_SEARCH;
-                       if (randint(2) == 1) return;
+                       if (one_in_(2)) return;
                }
        }
        else if (artifact_bias == BIAS_STR)
@@ -131,7 +131,7 @@ static void random_plus(object_type * o_ptr, bool is_scroll)
                if (!(o_ptr->art_flags1 & TR1_STR))
                {
                        o_ptr->art_flags1 |= TR1_STR;
-                       if (randint(2) == 1) return;
+                       if (one_in_(2)) return;
                }
        }
        else if (artifact_bias == BIAS_WIS)
@@ -139,7 +139,7 @@ static void random_plus(object_type * o_ptr, bool is_scroll)
                if (!(o_ptr->art_flags1 & TR1_WIS))
                {
                        o_ptr->art_flags1 |= TR1_WIS;
-                       if (randint(2) == 1) return;
+                       if (one_in_(2)) return;
                }
        }
        else if (artifact_bias == BIAS_INT)
@@ -147,7 +147,7 @@ static void random_plus(object_type * o_ptr, bool is_scroll)
                if (!(o_ptr->art_flags1 & TR1_INT))
                {
                        o_ptr->art_flags1 |= TR1_INT;
-                       if (randint(2) == 1) return;
+                       if (one_in_(2)) return;
                }
        }
        else if (artifact_bias == BIAS_DEX)
@@ -155,7 +155,7 @@ static void random_plus(object_type * o_ptr, bool is_scroll)
                if (!(o_ptr->art_flags1 & TR1_DEX))
                {
                        o_ptr->art_flags1 |= TR1_DEX;
-                       if (randint(2) == 1) return;
+                       if (one_in_(2)) return;
                }
        }
        else if (artifact_bias == BIAS_CON)
@@ -163,7 +163,7 @@ static void random_plus(object_type * o_ptr, bool is_scroll)
                if (!(o_ptr->art_flags1 & TR1_CON))
                {
                        o_ptr->art_flags1 |= TR1_CON;
-                       if (randint(2) == 1) return;
+                       if (one_in_(2)) return;
                }
        }
        else if (artifact_bias == BIAS_CHR)
@@ -171,7 +171,7 @@ static void random_plus(object_type * o_ptr, bool is_scroll)
                if (!(o_ptr->art_flags1 & TR1_CHR))
                {
                        o_ptr->art_flags1 |= TR1_CHR;
-                       if (randint(2) == 1) return;
+                       if (one_in_(2)) return;
                }
        }
 
@@ -180,7 +180,7 @@ static void random_plus(object_type * o_ptr, bool is_scroll)
                if (!(o_ptr->art_flags3 & TR3_DEC_MANA) && one_in_(3))
                {
                        o_ptr->art_flags3 |= TR3_DEC_MANA;
-                       if (randint(2) == 1) return;
+                       if (one_in_(2)) return;
                }
        }
 
@@ -189,59 +189,59 @@ static void random_plus(object_type * o_ptr, bool is_scroll)
        case 1: case 2:
                o_ptr->art_flags1 |= TR1_STR;
                /*  if (is_scroll) msg_print("It makes you feel strong!"); */
-               if (!artifact_bias && randint(13) != 1)
+               if (!artifact_bias && !one_in_(13))
                        artifact_bias = BIAS_STR;
-               else if (!artifact_bias && randint(7) == 1)
+               else if (!artifact_bias && one_in_(7))
                        artifact_bias = BIAS_WARRIOR;
                break;
        case 3: case 4:
                o_ptr->art_flags1 |= TR1_INT;
                /*  if (is_scroll) msg_print("It makes you feel smart!"); */
-               if (!artifact_bias && randint(13) != 1)
+               if (!artifact_bias && !one_in_(13))
                        artifact_bias = BIAS_INT;
-               else if (!artifact_bias && randint(7) == 1)
+               else if (!artifact_bias && one_in_(7))
                        artifact_bias = BIAS_MAGE;
                break;
        case 5: case 6:
                o_ptr->art_flags1 |= TR1_WIS;
                /*  if (is_scroll) msg_print("It makes you feel wise!"); */
-               if (!artifact_bias && randint(13) != 1)
+               if (!artifact_bias && !one_in_(13))
                        artifact_bias = BIAS_WIS;
-               else if (!artifact_bias && randint(7) == 1)
+               else if (!artifact_bias && one_in_(7))
                        artifact_bias = BIAS_PRIESTLY;
                break;
        case 7: case 8:
                o_ptr->art_flags1 |= TR1_DEX;
                /*  if (is_scroll) msg_print("It makes you feel nimble!"); */
-               if (!artifact_bias && randint(13) != 1)
+               if (!artifact_bias && !one_in_(13))
                        artifact_bias = BIAS_DEX;
-               else if (!artifact_bias && randint(7) == 1)
+               else if (!artifact_bias && one_in_(7))
                        artifact_bias = BIAS_ROGUE;
                break;
        case 9: case 10:
                o_ptr->art_flags1 |= TR1_CON;
                /*  if (is_scroll) msg_print("It makes you feel healthy!"); */
-               if (!artifact_bias && randint(13) != 1)
+               if (!artifact_bias && !one_in_(13))
                        artifact_bias = BIAS_CON;
-               else if (!artifact_bias && randint(9) == 1)
+               else if (!artifact_bias && one_in_(9))
                        artifact_bias = BIAS_RANGER;
                break;
        case 11: case 12:
                o_ptr->art_flags1 |= TR1_CHR;
                /*  if (is_scroll) msg_print("It makes you look great!"); */
-               if (!artifact_bias && randint(13) != 1)
+               if (!artifact_bias && !one_in_(13))
                        artifact_bias = BIAS_CHR;
                break;
        case 13: case 14:
                o_ptr->art_flags1 |= TR1_STEALTH;
                /*  if (is_scroll) msg_print("It looks muffled."); */
-               if (!artifact_bias && randint(3) == 1)
+               if (!artifact_bias && one_in_(3))
                        artifact_bias = BIAS_ROGUE;
                break;
        case 15: case 16:
                o_ptr->art_flags1 |= TR1_SEARCH;
                /*  if (is_scroll) msg_print("It makes you see better."); */
-               if (!artifact_bias && randint(9) == 1)
+               if (!artifact_bias && one_in_(9))
                        artifact_bias = BIAS_RANGER;
                break;
        case 17: case 18:
@@ -251,7 +251,7 @@ static void random_plus(object_type * o_ptr, bool is_scroll)
        case 19:
                o_ptr->art_flags1 |= TR1_SPEED;
                /*  if (is_scroll) msg_print("It makes you move faster!"); */
-               if (!artifact_bias && randint(11) == 1)
+               if (!artifact_bias && one_in_(11))
                        artifact_bias = BIAS_ROGUE;
                break;
        case 20: case 21:
@@ -264,7 +264,7 @@ static void random_plus(object_type * o_ptr, bool is_scroll)
                {
                        o_ptr->art_flags1 |= TR1_BLOWS;
                        /*  if (is_scroll) msg_print("It seems faster!"); */
-                       if (!artifact_bias && randint(11) == 1)
+                       if (!artifact_bias && one_in_(11))
                                artifact_bias = BIAS_WARRIOR;
                }
                break;
@@ -281,13 +281,13 @@ void random_resistance(object_type * o_ptr, bool is_scroll, int specific)
                        if (!(o_ptr->art_flags2 & TR2_RES_ACID))
                        {
                                o_ptr->art_flags2 |= TR2_RES_ACID;
-                               if (randint(2) == 1) return;
+                               if (one_in_(2)) return;
                        }
-                       if ((randint(BIAS_LUCK) == 1) && !(o_ptr->art_flags2 & TR2_IM_ACID))
+                       if (one_in_(BIAS_LUCK) && !(o_ptr->art_flags2 & TR2_IM_ACID))
                        {
                                o_ptr->art_flags2 |= TR2_IM_ACID;
                                if (!one_in_(IM_LUCK)) o_ptr->art_flags2 &= ~(TR2_IM_ELEC | TR2_IM_COLD | TR2_IM_FIRE);
-                               if (randint(2) == 1) return;
+                               if (one_in_(2)) return;
                        }
                }
                else if (artifact_bias == BIAS_ELEC)
@@ -295,19 +295,19 @@ void random_resistance(object_type * o_ptr, bool is_scroll, int specific)
                        if (!(o_ptr->art_flags2 & TR2_RES_ELEC))
                        {
                                o_ptr->art_flags2 |= TR2_RES_ELEC;
-                               if (randint(2) == 1) return;
+                               if (one_in_(2)) return;
                        }
                        if ((o_ptr->tval >= TV_CLOAK) && (o_ptr->tval <= TV_HARD_ARMOR) &&
                           !(o_ptr->art_flags3 & TR3_SH_ELEC))
                        {
                                o_ptr->art_flags3 |= TR3_SH_ELEC;
-                               if (randint(2) == 1) return;
+                               if (one_in_(2)) return;
                        }
-                       if (randint(BIAS_LUCK) == 1 && !(o_ptr->art_flags2 & TR2_IM_ELEC))
+                       if (one_in_(BIAS_LUCK) && !(o_ptr->art_flags2 & TR2_IM_ELEC))
                        {
                                o_ptr->art_flags2 |= TR2_IM_ELEC;
                                if (!one_in_(IM_LUCK)) o_ptr->art_flags2 &= ~(TR2_IM_ACID | TR2_IM_COLD | TR2_IM_FIRE);
-                               if (randint(2) == 1) return;
+                               if (one_in_(2)) return;
                        }
                }
                else if (artifact_bias == BIAS_FIRE)
@@ -315,21 +315,21 @@ void random_resistance(object_type * o_ptr, bool is_scroll, int specific)
                        if (!(o_ptr->art_flags2 & TR2_RES_FIRE))
                        {
                                o_ptr->art_flags2 |= TR2_RES_FIRE;
-                               if (randint(2) == 1) return;
+                               if (one_in_(2)) return;
                        }
                        if ((o_ptr->tval >= TV_CLOAK) &&
                            (o_ptr->tval <= TV_HARD_ARMOR) &&
                            !(o_ptr->art_flags3 & TR3_SH_FIRE))
                        {
                                o_ptr->art_flags3 |= TR3_SH_FIRE;
-                               if (randint(2) == 1) return;
+                               if (one_in_(2)) return;
                        }
-                       if ((randint(BIAS_LUCK) == 1) &&
+                       if (one_in_(BIAS_LUCK) &&
                            !(o_ptr->art_flags2 & TR2_IM_FIRE))
                        {
                                o_ptr->art_flags2 |= TR2_IM_FIRE;
                                if (!one_in_(IM_LUCK)) o_ptr->art_flags2 &= ~(TR2_IM_ELEC | TR2_IM_COLD | TR2_IM_ACID);
-                               if (randint(2) == 1) return;
+                               if (one_in_(2)) return;
                        }
                }
                else if (artifact_bias == BIAS_COLD)
@@ -337,20 +337,20 @@ void random_resistance(object_type * o_ptr, bool is_scroll, int specific)
                        if (!(o_ptr->art_flags2 & TR2_RES_COLD))
                        {
                                o_ptr->art_flags2 |= TR2_RES_COLD;
-                               if (randint(2) == 1) return;
+                               if (one_in_(2)) return;
                        }
                        if ((o_ptr->tval >= TV_CLOAK) &&
                            (o_ptr->tval <= TV_HARD_ARMOR) &&
                            !(o_ptr->art_flags3 & TR3_SH_COLD))
                        {
                                o_ptr->art_flags3 |= TR3_SH_COLD;
-                               if (randint(2) == 1) return;
+                               if (one_in_(2)) return;
                        }
-                       if (randint(BIAS_LUCK) == 1 && !(o_ptr->art_flags2 & TR2_IM_COLD))
+                       if (one_in_(BIAS_LUCK) && !(o_ptr->art_flags2 & TR2_IM_COLD))
                        {
                                o_ptr->art_flags2 |= TR2_IM_COLD;
                                if (!one_in_(IM_LUCK)) o_ptr->art_flags2 &= ~(TR2_IM_ELEC | TR2_IM_ACID | TR2_IM_FIRE);
-                               if (randint(2) == 1) return;
+                               if (one_in_(2)) return;
                        }
                }
                else if (artifact_bias == BIAS_POIS)
@@ -358,20 +358,20 @@ void random_resistance(object_type * o_ptr, bool is_scroll, int specific)
                        if (!(o_ptr->art_flags2 & TR2_RES_POIS))
                        {
                                o_ptr->art_flags2 |= TR2_RES_POIS;
-                               if (randint(2) == 1) return;
+                               if (one_in_(2)) return;
                        }
                }
                else if (artifact_bias == BIAS_WARRIOR)
                {
-                       if (randint(3) != 1 && (!(o_ptr->art_flags2 & TR2_RES_FEAR)))
+                       if (!one_in_(3) && (!(o_ptr->art_flags2 & TR2_RES_FEAR)))
                        {
                                o_ptr->art_flags2 |= TR2_RES_FEAR;
-                               if (randint(2) == 1) return;
+                               if (one_in_(2)) return;
                        }
-                       if ((randint(3) == 1) && (!(o_ptr->art_flags3 & TR3_NO_MAGIC)))
+                       if (one_in_(3) && (!(o_ptr->art_flags3 & TR3_NO_MAGIC)))
                        {
                                o_ptr->art_flags3 |= TR3_NO_MAGIC;
-                               if (randint(2) == 1) return;
+                               if (one_in_(2)) return;
                        }
                }
                else if (artifact_bias == BIAS_NECROMANTIC)
@@ -379,17 +379,17 @@ void random_resistance(object_type * o_ptr, bool is_scroll, int specific)
                        if (!(o_ptr->art_flags2 & TR2_RES_NETHER))
                        {
                                o_ptr->art_flags2 |= TR2_RES_NETHER;
-                               if (randint(2) == 1) return;
+                               if (one_in_(2)) return;
                        }
                        if (!(o_ptr->art_flags2 & TR2_RES_POIS))
                        {
                                o_ptr->art_flags2 |= TR2_RES_POIS;
-                               if (randint(2) == 1) return;
+                               if (one_in_(2)) return;
                        }
                        if (!(o_ptr->art_flags2 & TR2_RES_DARK))
                        {
                                o_ptr->art_flags2 |= TR2_RES_DARK;
-                               if (randint(2) == 1) return;
+                               if (one_in_(2)) return;
                        }
                }
                else if (artifact_bias == BIAS_CHAOS)
@@ -397,17 +397,17 @@ void random_resistance(object_type * o_ptr, bool is_scroll, int specific)
                        if (!(o_ptr->art_flags2 & TR2_RES_CHAOS))
                        {
                                o_ptr->art_flags2 |= TR2_RES_CHAOS;
-                               if (randint(2) == 1) return;
+                               if (one_in_(2)) return;
                        }
                        if (!(o_ptr->art_flags2 & TR2_RES_CONF))
                        {
                                o_ptr->art_flags2 |= TR2_RES_CONF;
-                               if (randint(2) == 1) return;
+                               if (one_in_(2)) return;
                        }
                        if (!(o_ptr->art_flags2 & TR2_RES_DISEN))
                        {
                                o_ptr->art_flags2 |= TR2_RES_DISEN;
-                               if (randint(2) == 1) return;
+                               if (one_in_(2)) return;
                        }
                }
        }
@@ -415,7 +415,7 @@ void random_resistance(object_type * o_ptr, bool is_scroll, int specific)
        switch (specific ? specific : randint(42))
        {
                case 1:
-                       if (randint(WEIRD_LUCK) != 1)
+                       if (!one_in_(WEIRD_LUCK))
                                random_resistance(o_ptr, is_scroll, specific);
                        else
                        {
@@ -426,7 +426,7 @@ void random_resistance(object_type * o_ptr, bool is_scroll, int specific)
                        }
                        break;
                case 2:
-                       if (randint(WEIRD_LUCK) != 1)
+                       if (!one_in_(WEIRD_LUCK))
                                random_resistance(o_ptr, is_scroll, specific);
                        else
                        {
@@ -437,7 +437,7 @@ void random_resistance(object_type * o_ptr, bool is_scroll, int specific)
                        }
                        break;
                case 3:
-                       if (randint(WEIRD_LUCK) != 1)
+                       if (!one_in_(WEIRD_LUCK))
                                random_resistance(o_ptr, is_scroll, specific);
                        else
                        {
@@ -448,7 +448,7 @@ void random_resistance(object_type * o_ptr, bool is_scroll, int specific)
                        }
                        break;
                case 4:
-                       if (randint(WEIRD_LUCK) != 1)
+                       if (!one_in_(WEIRD_LUCK))
                                random_resistance(o_ptr, is_scroll, specific);
                        else
                        {
@@ -494,18 +494,18 @@ void random_resistance(object_type * o_ptr, bool is_scroll, int specific)
                case 18:
                        o_ptr->art_flags2 |= TR2_RES_POIS;
                        /*  if (is_scroll) msg_print("It makes breathing easier for you."); */
-                       if (!artifact_bias && randint(4) != 1)
+                       if (!artifact_bias && !one_in_(4))
                                artifact_bias = BIAS_POIS;
-                       else if (!artifact_bias && randint(2) == 1)
+                       else if (!artifact_bias && one_in_(2))
                                artifact_bias = BIAS_NECROMANTIC;
-                       else if (!artifact_bias && randint(2) == 1)
+                       else if (!artifact_bias && one_in_(2))
                                artifact_bias = BIAS_ROGUE;
                        break;
                case 19:
                case 20:
                        o_ptr->art_flags2 |= TR2_RES_FEAR;
                        /*  if (is_scroll) msg_print("It makes you feel brave!"); */
-                       if (!artifact_bias && randint(3) == 1)
+                       if (!artifact_bias && one_in_(3))
                                artifact_bias = BIAS_WARRIOR;
                        break;
                case 21:
@@ -525,7 +525,7 @@ void random_resistance(object_type * o_ptr, bool is_scroll, int specific)
                case 26:
                        o_ptr->art_flags2 |= TR2_RES_CONF;
                        /*  if (is_scroll) msg_print("It makes you feel very determined.");*/
-                       if (!artifact_bias && randint(6) == 1)
+                       if (!artifact_bias && one_in_(6))
                                artifact_bias = BIAS_CHAOS;
                        break;
                case 27:
@@ -542,7 +542,7 @@ void random_resistance(object_type * o_ptr, bool is_scroll, int specific)
                case 32:
                        o_ptr->art_flags2 |= TR2_RES_NETHER;
                        /*  if (is_scroll) msg_print("It makes you feel like visiting a graveyard!");*/
-                       if (!artifact_bias && randint(3) == 1)
+                       if (!artifact_bias && one_in_(3))
                                artifact_bias = BIAS_NECROMANTIC;
                        break;
                case 33:
@@ -554,7 +554,7 @@ void random_resistance(object_type * o_ptr, bool is_scroll, int specific)
                case 36:
                        o_ptr->art_flags2 |= TR2_RES_CHAOS;
                        /*  if (is_scroll) msg_print("It makes you feel very firm.");*/
-                       if (!artifact_bias && randint(2) == 1)
+                       if (!artifact_bias && one_in_(2))
                                artifact_bias = BIAS_CHAOS;
                        break;
                case 37:
@@ -605,7 +605,7 @@ static void random_misc(object_type * o_ptr, bool is_scroll)
                if (!(o_ptr->art_flags2 & TR2_SUST_CON))
                {
                        o_ptr->art_flags2 |= TR2_SUST_CON;
-                       if (randint(2) == 1) return;
+                       if (one_in_(2)) return;
                }
        }
        else if (artifact_bias == BIAS_STR)
@@ -613,7 +613,7 @@ static void random_misc(object_type * o_ptr, bool is_scroll)
                if (!(o_ptr->art_flags2 & TR2_SUST_STR))
                {
                        o_ptr->art_flags2 |= TR2_SUST_STR;
-                       if (randint(2) == 1) return;
+                       if (one_in_(2)) return;
                }
        }
        else if (artifact_bias == BIAS_WIS)
@@ -621,7 +621,7 @@ static void random_misc(object_type * o_ptr, bool is_scroll)
                if (!(o_ptr->art_flags2 & TR2_SUST_WIS))
                {
                        o_ptr->art_flags2 |= TR2_SUST_WIS;
-                       if (randint(2) == 1) return;
+                       if (one_in_(2)) return;
                }
        }
        else if (artifact_bias == BIAS_INT)
@@ -629,7 +629,7 @@ static void random_misc(object_type * o_ptr, bool is_scroll)
                if (!(o_ptr->art_flags2 & TR2_SUST_INT))
                {
                        o_ptr->art_flags2 |= TR2_SUST_INT;
-                       if (randint(2) == 1) return;
+                       if (one_in_(2)) return;
                }
        }
        else if (artifact_bias == BIAS_DEX)
@@ -637,7 +637,7 @@ static void random_misc(object_type * o_ptr, bool is_scroll)
                if (!(o_ptr->art_flags2 & TR2_SUST_DEX))
                {
                        o_ptr->art_flags2 |= TR2_SUST_DEX;
-                       if (randint(2) == 1) return;
+                       if (one_in_(2)) return;
                }
        }
        else if (artifact_bias == BIAS_CON)
@@ -645,7 +645,7 @@ static void random_misc(object_type * o_ptr, bool is_scroll)
                if (!(o_ptr->art_flags2 & TR2_SUST_CON))
                {
                        o_ptr->art_flags2 |= TR2_SUST_CON;
-                       if (randint(2) == 1) return;
+                       if (one_in_(2)) return;
                }
        }
        else if (artifact_bias == BIAS_CHR)
@@ -653,7 +653,7 @@ static void random_misc(object_type * o_ptr, bool is_scroll)
                if (!(o_ptr->art_flags2 & TR2_SUST_CHR))
                {
                        o_ptr->art_flags2 |= TR2_SUST_CHR;
-                       if (randint(2) == 1) return;
+                       if (one_in_(2)) return;
                }
        }
        else if (artifact_bias == BIAS_CHAOS)
@@ -661,7 +661,7 @@ static void random_misc(object_type * o_ptr, bool is_scroll)
                if (!(o_ptr->art_flags3 & TR3_TELEPORT))
                {
                        o_ptr->art_flags3 |= TR3_TELEPORT;
-                       if (randint(2) == 1) return;
+                       if (one_in_(2)) return;
                }
        }
        else if (artifact_bias == BIAS_FIRE)
@@ -719,9 +719,9 @@ static void random_misc(object_type * o_ptr, bool is_scroll)
                case 9:
                        o_ptr->art_flags2 |= TR2_HOLD_LIFE;
                        /*  if (is_scroll) msg_print("It makes you feel immortal.");*/
-                       if (!artifact_bias && (randint(5) == 1))
+                       if (!artifact_bias && one_in_(5))
                                artifact_bias = BIAS_PRIESTLY;
-                       else if (!artifact_bias && (randint(6) == 1))
+                       else if (!artifact_bias && one_in_(6))
                                artifact_bias = BIAS_NECROMANTIC;
                        break;
                case 10:
@@ -741,10 +741,10 @@ static void random_misc(object_type * o_ptr, bool is_scroll)
                        /*  if (is_scroll) msg_print("It makes you see the air!");*/
                        break;
                case 18:
-                       if (randint(3) == 1) break;
+                       if (one_in_(3)) break;
                        o_ptr->art_flags3 |= TR3_TELEPATHY;
                        /*  if (is_scroll) msg_print("It makes you hear voices inside your head!");*/
-                       if (!artifact_bias && (randint(9) == 1))
+                       if (!artifact_bias && one_in_(9))
                                artifact_bias = BIAS_MAGE;
                        break;
                case 19:
@@ -805,7 +805,7 @@ static void random_slay(object_type *o_ptr, bool is_scroll)
                if (!(o_ptr->art_flags1 & TR1_CHAOTIC))
                {
                        o_ptr->art_flags1 |= TR1_CHAOTIC;
-                       if (randint(2) == 1) return;
+                       if (one_in_(2)) return;
                }
        }
 
@@ -822,12 +822,12 @@ static void random_slay(object_type *o_ptr, bool is_scroll)
                if (!(o_ptr->art_flags1 & TR1_VAMPIRIC))
                {
                        o_ptr->art_flags1 |= TR1_VAMPIRIC;
-                       if (randint(2) == 1) return;
+                       if (one_in_(2)) return;
                }
-               if (!(o_ptr->art_flags1 & TR1_BRAND_POIS) && (randint(2) == 1))
+               if (!(o_ptr->art_flags1 & TR1_BRAND_POIS) && one_in_(2))
                {
                        o_ptr->art_flags1 |= TR1_BRAND_POIS;
-                       if (randint(2) == 1) return;
+                       if (one_in_(2)) return;
                }
        }
 
@@ -836,7 +836,7 @@ static void random_slay(object_type *o_ptr, bool is_scroll)
                if (!(o_ptr->art_flags1 & TR1_SLAY_ANIMAL))
                {
                        o_ptr->art_flags1 |= TR1_SLAY_ANIMAL;
-                       if (randint(2) == 1) return;
+                       if (one_in_(2)) return;
                }
        }
 
@@ -852,7 +852,7 @@ static void random_slay(object_type *o_ptr, bool is_scroll)
                if (!(o_ptr->art_flags1 & TR1_BRAND_POIS))
                {
                        o_ptr->art_flags1 |= TR1_BRAND_POIS;
-                       if (randint(2) == 1) return;
+                       if (one_in_(2)) return;
                }
        }
 
@@ -861,7 +861,7 @@ static void random_slay(object_type *o_ptr, bool is_scroll)
                if (!(o_ptr->art_flags1 & TR1_BRAND_POIS))
                {
                        o_ptr->art_flags1 |= TR1_BRAND_POIS;
-                       if (randint(2) == 1) return;
+                       if (one_in_(2)) return;
                }
        }
 
@@ -870,7 +870,7 @@ static void random_slay(object_type *o_ptr, bool is_scroll)
                if (!(o_ptr->art_flags1 & TR1_BRAND_FIRE))
                {
                        o_ptr->art_flags1 |= TR1_BRAND_FIRE;
-                       if (randint(2) == 1) return;
+                       if (one_in_(2)) return;
                }
        }
 
@@ -879,7 +879,7 @@ static void random_slay(object_type *o_ptr, bool is_scroll)
                if (!(o_ptr->art_flags1 & TR1_BRAND_COLD))
                {
                        o_ptr->art_flags1 |= TR1_BRAND_COLD;
-                       if (randint(2) == 1) return;
+                       if (one_in_(2)) return;
                }
        }
 
@@ -888,7 +888,7 @@ static void random_slay(object_type *o_ptr, bool is_scroll)
                if (!(o_ptr->art_flags1 & TR1_BRAND_ELEC))
                {
                        o_ptr->art_flags1 |= TR1_BRAND_ELEC;
-                       if (randint(2) == 1) return;
+                       if (one_in_(2)) return;
                }
        }
 
@@ -897,7 +897,7 @@ static void random_slay(object_type *o_ptr, bool is_scroll)
                if (!(o_ptr->art_flags1 & TR1_BRAND_ACID))
                {
                        o_ptr->art_flags1 |= TR1_BRAND_ACID;
-                       if (randint(2) == 1) return;
+                       if (one_in_(2)) return;
                }
        }
 
@@ -906,17 +906,17 @@ static void random_slay(object_type *o_ptr, bool is_scroll)
                if (!(o_ptr->art_flags1 & TR1_SLAY_EVIL))
                {
                        o_ptr->art_flags1 |= TR1_SLAY_EVIL;
-                       if (randint(2) == 1) return;
+                       if (one_in_(2)) return;
                }
                if (!(o_ptr->art_flags1 & TR1_SLAY_UNDEAD))
                {
                        o_ptr->art_flags1 |= TR1_SLAY_UNDEAD;
-                       if (randint(2) == 1) return;
+                       if (one_in_(2)) return;
                }
                if (!(o_ptr->art_flags1 & TR1_SLAY_DEMON))
                {
                        o_ptr->art_flags1 |= TR1_SLAY_DEMON;
-                       if (randint(2) == 1) return;
+                       if (one_in_(2)) return;
                }
        }
 
@@ -933,23 +933,23 @@ static void random_slay(object_type *o_ptr, bool is_scroll)
                        case 4:
                                o_ptr->art_flags1 |= TR1_SLAY_EVIL;
                                /*  if (is_scroll) msg_print("You hate evil creatures.");*/
-                               if (!artifact_bias && (randint(2) == 1))
+                               if (!artifact_bias && one_in_(2))
                                        artifact_bias = BIAS_LAW;
-                               else if (!artifact_bias && (randint(9) == 1))
+                               else if (!artifact_bias && one_in_(9))
                                        artifact_bias = BIAS_PRIESTLY;
                                break;
                        case 5:
                        case 6:
                                o_ptr->art_flags1 |= TR1_SLAY_UNDEAD;
                                /*  if (is_scroll) msg_print("You hate undead creatures.");*/
-                               if (!artifact_bias && (randint(9) == 1))
+                               if (!artifact_bias && one_in_(9))
                                        artifact_bias = BIAS_PRIESTLY;
                                break;
                        case 7:
                        case 8:
                                o_ptr->art_flags1 |= TR1_SLAY_DEMON;
                                /*  if (is_scroll) msg_print("You hate demons.");*/
-                               if (!artifact_bias && (randint(9) == 1))
+                               if (!artifact_bias && one_in_(9))
                                        artifact_bias = BIAS_PRIESTLY;
                                break;
                        case 9:
@@ -982,7 +982,7 @@ static void random_slay(object_type *o_ptr, bool is_scroll)
                                {
                                        o_ptr->art_flags1 |= TR1_VORPAL;
                                        /* if (is_scroll) msg_print("It looks extremely sharp!");*/
-                                       if (!artifact_bias && (randint(9) == 1))
+                                       if (!artifact_bias && one_in_(9))
                                                artifact_bias = BIAS_WARRIOR;
                                }
                                else
@@ -1024,9 +1024,9 @@ static void random_slay(object_type *o_ptr, bool is_scroll)
                        case 30:
                                o_ptr->art_flags1 |= TR1_BRAND_POIS;
                                /*  if (is_scroll) msg_print("It smells rotten.");*/
-                               if (!artifact_bias && (randint(3) != 1))
+                               if (!artifact_bias && !one_in_(3))
                                        artifact_bias = BIAS_POIS;
-                               else if (!artifact_bias && randint(6) == 1)
+                               else if (!artifact_bias && one_in_(6))
                                        artifact_bias = BIAS_NECROMANTIC;
                                else if (!artifact_bias)
                                        artifact_bias = BIAS_ROGUE;
@@ -1041,7 +1041,7 @@ static void random_slay(object_type *o_ptr, bool is_scroll)
                                o_ptr->art_flags1 |= TR1_FORCE_WEPON;
                                /*  if (is_scroll) msg_print("It looks consuming your MP!");*/
                                if (!artifact_bias)
-                                       artifact_bias = ((randint(2)==1) ? BIAS_MAGE : BIAS_PRIESTLY);
+                                       artifact_bias = (one_in_(2) ? BIAS_MAGE : BIAS_PRIESTLY);
                                break;
                        default:
                                o_ptr->art_flags1 |= TR1_CHAOTIC;
@@ -1061,14 +1061,14 @@ static void random_slay(object_type *o_ptr, bool is_scroll)
                                o_ptr->art_flags3 |= TR3_XTRA_MIGHT;
                                if (!one_in_(7)) o_ptr->art_flags3 &= ~(TR3_XTRA_SHOTS);
                                /*  if (is_scroll) msg_print("It looks mightier than before."); */
-                               if (!artifact_bias && randint(9) == 1)
+                               if (!artifact_bias && one_in_(9))
                                        artifact_bias = BIAS_RANGER;
                                break;
                        default:
                                o_ptr->art_flags3 |= TR3_XTRA_SHOTS;
                                if (!one_in_(7)) o_ptr->art_flags3 &= ~(TR3_XTRA_MIGHT);
                                /*  if (is_scroll) msg_print("It seems faster!"); */
-                               if (!artifact_bias && randint(9) == 1)
+                               if (!artifact_bias && one_in_(9))
                                        artifact_bias = BIAS_RANGER;
                        break;
                }
@@ -1084,11 +1084,11 @@ static void give_activation_power(object_type *o_ptr)
        {
                if (artifact_bias == BIAS_ELEC)
                {
-                       if (randint(3) != 1)
+                       if (!one_in_(3))
                        {
                                type = ACT_BO_ELEC_1;
                        }
-                       else if (randint(5) != 1)
+                       else if (!one_in_(5))
                        {
                                type = ACT_BA_ELEC_2;
                        }
@@ -1105,11 +1105,11 @@ static void give_activation_power(object_type *o_ptr)
                }
                else if (artifact_bias == BIAS_FIRE)
                {
-                       if (randint(3) != 1)
+                       if (!one_in_(3))
                        {
                                type = ACT_BO_FIRE_1;
                        }
-                       else if (randint(5) != 1)
+                       else if (!one_in_(5))
                        {
                                type = ACT_BA_FIRE_1;
                        }
@@ -1122,11 +1122,11 @@ static void give_activation_power(object_type *o_ptr)
                else if (artifact_bias == BIAS_COLD)
                {
                        chance = 101;
-                       if (randint(3) != 1)
+                       if (!one_in_(3))
                                type = ACT_BO_COLD_1;
-                       else if (randint(3) != 1)
+                       else if (!one_in_(3))
                                type = ACT_BA_COLD_1;
-                       else if (randint(3) != 1)
+                       else if (!one_in_(3))
                                type = ACT_BA_COLD_2;
                        else
                                type = ACT_BA_COLD_3;
@@ -1134,7 +1134,7 @@ static void give_activation_power(object_type *o_ptr)
                else if (artifact_bias == BIAS_CHAOS)
                {
                        chance = 50;
-                       if (randint(6) == 1)
+                       if (one_in_(6))
                                type = ACT_SUMMON_DEMON;
                        else
                                type = ACT_CALL_CHAOS;
@@ -1143,21 +1143,21 @@ static void give_activation_power(object_type *o_ptr)
                {
                        chance = 101;
 
-                       if (randint(13) == 1)
+                       if (one_in_(13))
                                type = ACT_CHARM_UNDEAD;
-                       else if (randint(12) == 1)
+                       else if (one_in_(12))
                                type = ACT_BANISH_EVIL;
-                       else if (randint(11) == 1)
+                       else if (one_in_(11))
                                type = ACT_DISP_EVIL;
-                       else if (randint(10) == 1)
+                       else if (one_in_(10))
                                type = ACT_PROT_EVIL;
-                       else if (randint(9) == 1)
+                       else if (one_in_(9))
                                type = ACT_CURE_1000;
-                       else if (randint(8) == 1)
+                       else if (one_in_(8))
                                type = ACT_CURE_700;
-                       else if (randint(7) == 1)
+                       else if (one_in_(7))
                                type = ACT_REST_ALL;
-                       else if (randint(6) == 1)
+                       else if (one_in_(6))
                                type = ACT_REST_LIFE;
                        else
                                type = ACT_CURE_MW;
@@ -1165,19 +1165,19 @@ static void give_activation_power(object_type *o_ptr)
                else if (artifact_bias == BIAS_NECROMANTIC)
                {
                        chance = 101;
-                       if (randint(66) == 1)
+                       if (one_in_(66))
                                type = ACT_WRAITH;
-                       else if (randint(13) == 1)
+                       else if (one_in_(13))
                                type = ACT_DISP_GOOD;
-                       else if (randint(9) == 1)
+                       else if (one_in_(9))
                                type = ACT_MASS_GENO;
-                       else if (randint(8) == 1)
+                       else if (one_in_(8))
                                type = ACT_GENOCIDE;
-                       else if (randint(13) == 1)
+                       else if (one_in_(13))
                                type = ACT_SUMMON_UNDEAD;
-                       else if (randint(9) == 1)
+                       else if (one_in_(9))
                                type = ACT_VAMPIRE_2;
-                       else if (randint(6) == 1)
+                       else if (one_in_(6))
                                type = ACT_CHARM_UNDEAD;
                        else
                                type = ACT_VAMPIRE_1;
@@ -1185,9 +1185,9 @@ static void give_activation_power(object_type *o_ptr)
                else if (artifact_bias == BIAS_LAW)
                {
                        chance = 101;
-                       if (randint(8) == 1)
+                       if (one_in_(8))
                                type = ACT_BANISH_EVIL;
-                       else if (randint(4) == 1)
+                       else if (one_in_(4))
                                type = ACT_DISP_EVIL;
                        else
                                type = ACT_PROT_EVIL;
@@ -1195,13 +1195,13 @@ static void give_activation_power(object_type *o_ptr)
                else if (artifact_bias == BIAS_ROGUE)
                {
                        chance = 101;
-                       if (randint(50) == 1)
+                       if (one_in_(50))
                                type = ACT_SPEED;
-                       else if (randint(4) == 1)
+                       else if (one_in_(4))
                                type = ACT_SLEEP;
-                       else if (randint(3) == 1)
+                       else if (one_in_(3))
                                type = ACT_DETECT_ALL;
-                       else if (randint(8) == 1)
+                       else if (one_in_(8))
                                type = ACT_ID_FULL;
                        else
                                type = ACT_ID_PLAIN;
@@ -1209,11 +1209,11 @@ static void give_activation_power(object_type *o_ptr)
                else if (artifact_bias == BIAS_MAGE)
                {
                        chance = 66;
-                       if (randint(20) == 1)
+                       if (one_in_(20))
                                type = ACT_SUMMON_ELEMENTAL;
-                       else if (randint(10) == 1)
+                       else if (one_in_(10))
                                type = ACT_SUMMON_PHANTOM;
-                       else if (randint(5) == 1)
+                       else if (one_in_(5))
                                type = ACT_RUNE_EXPLO;
                        else
                                type = ACT_ESP;
@@ -1221,7 +1221,7 @@ static void give_activation_power(object_type *o_ptr)
                else if (artifact_bias == BIAS_WARRIOR)
                {
                        chance = 80;
-                       if (randint(100) == 1)
+                       if (one_in_(100))
                                type = ACT_INVULN;
                        else
                                type = ACT_BERSERK;
@@ -1229,15 +1229,15 @@ static void give_activation_power(object_type *o_ptr)
                else if (artifact_bias == BIAS_RANGER)
                {
                        chance = 101;
-                       if (randint(20) == 1)
+                       if (one_in_(20))
                                type = ACT_CHARM_ANIMALS;
-                       else if (randint(7) == 1)
+                       else if (one_in_(7))
                                type = ACT_SUMMON_ANIMAL;
-                       else if (randint(6) == 1)
+                       else if (one_in_(6))
                                type = ACT_CHARM_ANIMAL;
-                       else if (randint(4) == 1)
+                       else if (one_in_(4))
                                type = ACT_RESIST_ALL;
-                       else if (randint(3) == 1)
+                       else if (one_in_(3))
                                type = ACT_SATIATE;
                        else
                                type = ACT_CURE_POISON;
@@ -1469,7 +1469,7 @@ bool create_artifact(object_type *o_ptr, bool a_scroll)
        o_ptr->art_flags3 |= k_info[o_ptr->k_idx].flags3;
        if (o_ptr->pval) has_pval = TRUE;
 
-       if (a_scroll && (randint(4) == 1))
+       if (a_scroll && one_in_(4))
        {
                switch (p_ptr->pclass)
                {
@@ -1549,15 +1549,15 @@ bool create_artifact(object_type *o_ptr, bool a_scroll)
 
        strcpy(new_name, "");
 
-       if (!a_scroll && (randint(A_CURSED) == 1))
+       if (!a_scroll && one_in_(A_CURSED))
                a_cursed = TRUE;
        if (((o_ptr->tval == TV_AMULET) || (o_ptr->tval == TV_RING)) && cursed_p(o_ptr))
                a_cursed = TRUE;
 
-       while ((randint(powers) == 1) || (randint(7) == 1) || (randint(10) == 1))
+       while (one_in_(powers) || one_in_(7) || one_in_(10))
                powers++;
 
-       if (!a_cursed && (randint(WEIRD_LUCK) == 1))
+       if (!a_cursed && one_in_(WEIRD_LUCK))
                powers *= 2;
 
        if (a_cursed) powers /= 2;
@@ -1621,10 +1621,10 @@ bool create_artifact(object_type *o_ptr, bool a_scroll)
                        {
                                o_ptr->pval++;
                        }
-                       while (o_ptr->pval < randint(5) || randint(o_ptr->pval) == 1);
+                       while (o_ptr->pval < randint(5) || one_in_(o_ptr->pval));
                }
 
-               if ((o_ptr->pval > 4) && (randint(WEIRD_LUCK) != 1))
+               if ((o_ptr->pval > 4) && !one_in_(WEIRD_LUCK))
                        o_ptr->pval = 4;
        }
 
@@ -2307,7 +2307,7 @@ bool activate_random_artifact(object_type * o_ptr)
 
                case ACT_SUMMON_ELEMENTAL:
                {
-                       bool pet = (randint(3) == 1);
+                       bool pet = one_in_(3);
                        bool group = !(pet && (plev < 50));
 
                        if (summon_specific((pet ? -1 : 0), py, px, ((plev * 3) / 2), SUMMON_ELEMENTAL, group, FALSE, pet, FALSE, (bool)(!pet)))
@@ -2341,7 +2341,7 @@ bool activate_random_artifact(object_type * o_ptr)
 
                case ACT_SUMMON_DEMON:
                {
-                       bool pet = (randint(3) == 1);
+                       bool pet = one_in_(3);
                        bool group = !(pet && (plev < 50));
 
                        if (summon_specific((pet ? -1 : 0), py, px, ((plev * 3) / 2), SUMMON_DEMON, group, FALSE, pet, FALSE, (bool)(!pet)))
@@ -2374,7 +2374,7 @@ bool activate_random_artifact(object_type * o_ptr)
 
                case ACT_SUMMON_UNDEAD:
                {
-                       bool pet = (randint(3) == 1);
+                       bool pet = one_in_(3);
                        bool group;
                        bool unique_okay;
                        int type;
@@ -2382,7 +2382,7 @@ bool activate_random_artifact(object_type * o_ptr)
                        type = (plev > 47 ? SUMMON_HI_UNDEAD : SUMMON_UNDEAD);
                        if (pet)
                        {
-                               group = (((plev > 24) && (randint(3) == 1)) ? TRUE : FALSE);
+                               group = (((plev > 24) && one_in_(3)) ? TRUE : FALSE);
                                unique_okay = FALSE;
                        }
                        else
@@ -2926,7 +2926,7 @@ void random_artifact_resistance(object_type * o_ptr)
                case ART_AZAGHAL:
                        {
                                /* Give a resistance OR a power */
-                               if (randint(2) == 1) give_resistance = TRUE;
+                               if (one_in_(2)) give_resistance = TRUE;
                                else give_power = TRUE;
                        }
                        break;
index e94e1ea..9332a81 100644 (file)
@@ -1495,7 +1495,7 @@ void map_info(int y, int x, byte *ap, char *cp)
                                        }
                                        else
                                        {
-                                               (*cp) = (randint(25) == 1 ?
+                                               (*cp) = (one_in_(25) ?
                                                        image_object_hack[rand_int(strlen(image_object_hack))] :
                                                        image_monster_hack[rand_int(strlen(image_monster_hack))]);
                                        }
index 3770e5b..cc9eb44 100644 (file)
@@ -1865,7 +1865,7 @@ static void hit_trap(bool break_trap)
                                {
                                        stop_ty = activate_ty_curse(stop_ty, &count);
                                }
-                               while (randint(6) == 1);
+                               while (one_in_(6));
                        }
                        break;
                }
@@ -2545,7 +2545,7 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
                {
                        if (p_ptr->migite && p_ptr->hidarite)
                        {
-                               success_hit = (randint(2) == 1);
+                               success_hit = one_in_(2);
                        }
                        else success_hit = TRUE;
                }
@@ -2610,9 +2610,9 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
                        object_flags(o_ptr, &f1, &f2, &f3);
 
                        /* Select a chaotic effect (50% chance) */
-                       if ((f1 & TR1_CHAOTIC) && (randint(2) == 1))
+                       if ((f1 & TR1_CHAOTIC) && one_in_(2))
                        {
-                               if (randint(10)==1)
+                               if (one_in_(10))
                                chg_virtue(V_CHANCE, 1);
 
                                if (randint(5) < 3)
@@ -2620,17 +2620,17 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
                                        /* Vampiric (20%) */
                                        chaos_effect = 1;
                                }
-                               else if (randint(250) == 1)
+                               else if (one_in_(250))
                                {
                                        /* Quake (0.12%) */
                                        chaos_effect = 2;
                                }
-                               else if (randint(10) != 1)
+                               else if (!one_in_(10))
                                {
                                        /* Confusion (26.892%) */
                                        chaos_effect = 3;
                                }
-                               else if (randint(2) == 1)
+                               else if (one_in_(2))
                                {
                                        /* Teleport away (1.494%) */
                                        chaos_effect = 4;
@@ -2840,7 +2840,7 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
                                        k = (3 * k) / 2;
                                }
 
-                               if ((p_ptr->impact[hand] && ((k > 50) || randint(7) == 1)) ||
+                               if ((p_ptr->impact[hand] && ((k > 50) || one_in_(7))) ||
                                         (chaos_effect == 2) || (mode == HISSATSU_QUAKE))
                                {
                                        do_quake = TRUE;
@@ -2857,7 +2857,7 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
 
                                        int inc_chance = (o_ptr->name1 == ART_VORPAL_BLADE) ? 2 : 4;
 
-                                       if ((o_ptr->name1 == ART_CHAINSWORD) && (randint(2) != 1))
+                                       if ((o_ptr->name1 == ART_CHAINSWORD) && !one_in_(2))
                                        {
                                                char chainsword_noise[1024];
 #ifdef JP
@@ -3069,7 +3069,7 @@ msg_format("
                                        msg_format("You critically injured %s!", m_name);
 #endif
                                }
-                               else if (((m_ptr->hp < maxhp/2) && one_in_((p_ptr->num_blow[0]+p_ptr->num_blow[1]+1)*10)) || (((one_in_(666)) || ((backstab || fuiuchi) && one_in_(11))) && !(r_ptr->flags1 & RF1_UNIQUE) && !(r_ptr->flags7 & RF7_UNIQUE2)))
+                               else if (((m_ptr->hp < maxhp/2) && one_in_((p_ptr->num_blow[0]+p_ptr->num_blow[1]+1)*10)) || ((one_in_(666) || ((backstab || fuiuchi) && one_in_(11))) && !(r_ptr->flags1 & RF1_UNIQUE) && !(r_ptr->flags7 & RF7_UNIQUE2)))
                                {
                                        if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE2) || (m_ptr->hp >= maxhp/2))
                                        {
@@ -3393,7 +3393,7 @@ msg_format("
                        backstab = FALSE; /* Clumsy! */
                        fuiuchi = FALSE; /* Clumsy! */
 
-                       if ((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE) && (randint(3) == 1))
+                       if ((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE) && one_in_(3))
                        {
                                u32b f1, f2, f3;
 
@@ -3478,7 +3478,7 @@ msg_format("
                                }
 
                                k = critical_norm(o_ptr->weight, o_ptr->to_h, k, p_ptr->to_h[hand], mode);
-                               if (randint(6) == 1)
+                               if (one_in_(6))
                                {
                                        int mult = 2;
 #ifdef JP
@@ -3524,7 +3524,7 @@ msg_format("
 
        if (drain_left != MAX_VAMPIRIC_DRAIN)
        {
-               if (randint(4)==1)
+               if (one_in_(4))
                {
                        chg_virtue(V_UNLIFE, 1);
                }
index a31ea63..67801ed 100644 (file)
@@ -745,7 +745,7 @@ static void chest_trap(int y, int x, s16b o_idx)
        if (trap & (CHEST_H_SUMMON))
        {
                /* Summon demons. */
-               if (rand_int(4) == 0)
+               if (one_in_(4))
                {
 #ifdef JP
                        msg_print("±ê¤Èⲫ¤Î±À¤ÎÃæ¤Ë°­Ë⤬»Ñ¤ò¸½¤·¤¿¡ª");
@@ -761,7 +761,7 @@ static void chest_trap(int y, int x, s16b o_idx)
                }
 
                /* Summon dragons. */
-               else if (rand_int(3) == 0)
+               else if (one_in_(3))
                {
 #ifdef JP
                        msg_print("°Å°Ç¤Ë¥É¥é¥´¥ó¤Î±Æ¤¬¤Ü¤ó¤ä¤ê¤È¸½¤ì¤¿¡ª");
@@ -776,7 +776,7 @@ static void chest_trap(int y, int x, s16b o_idx)
                }
 
                /* Summon hybrids. */
-               else if (rand_int(2) == 0)
+               else if (one_in_(2))
                {
 #ifdef JP
                        msg_print("´ñ̯¤Ê»Ñ¤Î²øʪ¤¬½±¤Ã¤ÆÍ褿¡ª");
@@ -826,12 +826,12 @@ static void chest_trap(int y, int x, s16b o_idx)
                        if (randint(100+o_ptr->pval*2) > p_ptr->skill_sav)
                        {
 #ifdef JP
-                               if (rand_int(6) == 0) take_hit(DAMAGE_NOESCAPE, damroll(5, 20), "ÇËÌǤΥȥé¥Ã¥×¤ÎÊõÈ¢", -1);
+                               if (one_in_(6)) take_hit(DAMAGE_NOESCAPE, damroll(5, 20), "ÇËÌǤΥȥé¥Ã¥×¤ÎÊõÈ¢", -1);
 #else
-                               if (rand_int(6) == 0) take_hit(DAMAGE_NOESCAPE, damroll(5, 20), "a chest dispel-player trap", -1);
+                               if (one_in_(6)) take_hit(DAMAGE_NOESCAPE, damroll(5, 20), "a chest dispel-player trap", -1);
 #endif
-                               else if (rand_int(5) == 0) (void)set_cut(p_ptr->cut + 200);
-                               else if (rand_int(4) == 0)
+                               else if (one_in_(5)) (void)set_cut(p_ptr->cut + 200);
+                               else if (one_in_(4))
                                {
                                        if (!p_ptr->free_act) 
                                                (void)set_paralyzed(p_ptr->paralyzed + 2 + 
@@ -840,8 +840,8 @@ static void chest_trap(int y, int x, s16b o_idx)
                                                (void)set_stun(p_ptr->stun + 10 + 
                                                rand_int(100));
                                }
-                               else if (rand_int(3) == 0) apply_disenchant(0);
-                               else if (rand_int(2) == 0)
+                               else if (one_in_(3)) apply_disenchant(0);
+                               else if (one_in_(2))
                                {
                                        (void)do_dec_stat(A_STR);
                                        (void)do_dec_stat(A_DEX);
@@ -4596,7 +4596,7 @@ msg_print("
                if (super_boomerang) back_chance += 100;
                object_desc(o2_name, q_ptr, FALSE, 0);
 
-               if((back_chance > 30) && ((randint(100) != 1) || super_boomerang))
+               if((back_chance > 30) && (!one_in_(100) || super_boomerang))
                {
                        for (i = cur_dis-1;i>0;i--)
                        {
index 9e516b5..ad39f75 100644 (file)
@@ -773,7 +773,7 @@ s = "
                                k++;
 
                                /* Hack -- Apply the randomizer */
-                               if (rand_int(k) == 0) gift = spell;
+                               if (one_in_(k)) gift = spell;
                        }
                }
 
@@ -1823,7 +1823,7 @@ msg_print("
                break;
        case 23: /* Summon monster, demon */
                {
-                       bool pet = (randint(3) == 1);
+                       bool pet = one_in_(3);
                        bool group = !(pet && (plev < 50));
 
                        if (summon_specific((pet ? -1 : 0), py, px, (plev * 3) / 2, SUMMON_DEMON, group, FALSE, pet, FALSE, (bool)(!pet)))
@@ -1955,7 +1955,7 @@ static bool cast_death_spell(int spell)
                fire_ball(GF_HELL_FIRE, dir,
                        damroll(3 + ((plev - 1) / 5), 4), 0);
 
-               if (randint(5) == 1)
+               if (one_in_(5))
                {   /* Special effect first */
                        dummy = randint(1000);
                        if (dummy == 666)
@@ -2258,14 +2258,14 @@ msg_print("
                break;
        case 25: /* Raise the Dead */
                {
-                       bool pet = (randint(3) == 1);
+                       bool pet = one_in_(3);
                        bool group;
                        int type;
 
                        type = (plev > 47 ? SUMMON_HI_UNDEAD : SUMMON_UNDEAD);
                        if (pet)
                        {
-                               group = (((plev > 24) && (randint(3) == 1)) ? TRUE : FALSE);
+                               group = (((plev > 24) && one_in_(3)) ? TRUE : FALSE);
                        }
                        else
                        {
@@ -3028,7 +3028,7 @@ msg_print("
                case 22: /* Living Trump */
                        if (success)
                        {
-                               if (randint(7) == 1)
+                               if (one_in_(7))
                                        /* Teleport control */
                                        dummy = 12;
                                else
@@ -3585,7 +3585,7 @@ msg_print("
                brand_weapon(rand_int(17));
                break;
        case 30: /* Living Trump */
-               if (randint(7) == 1)
+               if (one_in_(7))
                        /* Teleport control */
                        dummy = 12;
                else
@@ -3725,7 +3725,7 @@ msg_print("
                break;
        case 15: /* Summon monster, demon */
        {
-               bool pet = (randint(3) != 1);
+               bool pet = !one_in_(3);
                bool group = !(pet && (plev < 50));
 
                if (summon_specific((pet ? -1 : 0), py, px, plev*2/3+randint(plev/2), SUMMON_DEMON, group, FALSE, pet, FALSE, (bool)(!pet)))
@@ -4612,7 +4612,7 @@ msg_print("
                }
                else if ((o_ptr->tval == TV_DEATH_BOOK) && (randint(100) < spell))
                {
-                       if ((sval == 3) && (randint(2) == 1))
+                       if ((sval == 3) && one_in_(2))
                        {
                                sanity_blast(0, TRUE);
                        }
@@ -4630,7 +4630,7 @@ msg_print("
                                take_hit(DAMAGE_LOSELIFE, damroll(o_ptr->sval + 1, 6), "a miscast Death spell", -1);
 #endif
 
-                               if ((spell > 15) && (randint(6) == 1) && !p_ptr->hold_life)
+                               if ((spell > 15) && one_in_(6) && !p_ptr->hold_life)
                                        lose_exp(spell * 250);
                        }
                }
index 01aa8ef..50f6442 100644 (file)
@@ -2610,7 +2610,7 @@ static void do_cmd_use_staff_aux(int item)
        chance = chance - lev;
 
        /* Give everyone a (slight) chance */
-       if ((chance < USE_DEVICE) && (rand_int(USE_DEVICE - chance + 1) == 0))
+       if ((chance < USE_DEVICE) && one_in_(USE_DEVICE - chance + 1))
        {
                chance = USE_DEVICE;
        }
@@ -3143,7 +3143,7 @@ static void do_cmd_aim_wand_aux(int item)
        chance = chance - lev;
 
        /* Give everyone a (slight) chance */
-       if ((chance < USE_DEVICE) && (rand_int(USE_DEVICE - chance + 1) == 0))
+       if ((chance < USE_DEVICE) && one_in_(USE_DEVICE - chance + 1))
        {
                chance = USE_DEVICE;
        }
@@ -5144,11 +5144,11 @@ msg_print("
 #endif
 
                                /* Confusing. */
-                               if (rand_int(5) == 0) (void)set_confused(p_ptr->confused +
+                               if (one_in_(5)) (void)set_confused(p_ptr->confused +
                                        randint(10));
 
                                /* Exercise a little care... */
-                               if (rand_int(20) == 0)
+                               if (one_in_(20))
 #ifdef JP
                                        take_hit(DAMAGE_LOSELIFE, damroll(4, 10), "´í¸±¤ÊÈëÌ©", -1);
 #else
@@ -5321,7 +5321,7 @@ msg_print("
                        }
                        case ART_ARRYU:
                        {
-                               bool pet = (randint(5) != 1);
+                               bool pet = !one_in_(5);
 
                                if (summon_specific((pet ? -1 : 0), py, px, ((p_ptr->lev * 3) / 2), SUMMON_HOUND, TRUE, FALSE, pet, FALSE, (bool)(!pet)))
                                {
@@ -5548,7 +5548,7 @@ msg_print("
                        }
                        case ART_JIZO:
                        {
-                               bool pet = (randint(5) != 1);
+                               bool pet = !one_in_(5);
 
                                if (summon_named_creature(py, px, MON_JIZOTAKO, FALSE, TRUE, FALSE, pet))
                                {
index 38957af..399b59a 100644 (file)
@@ -719,7 +719,7 @@ static bool pattern_effect(void)
                return FALSE;
 
        if ((prace_is_(RACE_AMBERITE)) &&
-           (p_ptr->cut > 0) && (randint(10) == 1))
+           (p_ptr->cut > 0) && one_in_(10))
        {
                wreck_the_pattern();
        }
@@ -777,7 +777,7 @@ take_hit(DAMAGE_NOESCAPE, 200, "
        }
        else
        {
-               if ((prace_is_(RACE_AMBERITE)) && (randint(2) != 1))
+               if ((prace_is_(RACE_AMBERITE)) && !one_in_(2))
                        return TRUE;
                else if (!p_ptr->invuln)
 #ifdef JP
@@ -978,7 +978,7 @@ static void regen_monsters(void)
                        frac = m_ptr->maxhp / 100;
 
                        /* Hack -- Minimal regeneration rate */
-                       if (!frac) if (randint(2) == 1) frac = 1;
+                       if (!frac) if (one_in_(2)) frac = 1;
 
                        /* Hack -- Some monsters regenerate quickly */
                        if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
@@ -1028,7 +1028,7 @@ static void regen_captured_monsters(void)
                        frac = o_ptr->xtra5 / 100;
 
                        /* Hack -- Minimal regeneration rate */
-                       if (!frac) if (randint(2) == 1) frac = 1;
+                       if (!frac) if (one_in_(2)) frac = 1;
 
                        /* Hack -- Some monsters regenerate quickly */
                        if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
@@ -1713,7 +1713,7 @@ if (cheat_xtra) msg_print("
        /*** Process the monsters ***/
 
        /* Check for creature generation. */
-       if ((rand_int(d_info[dungeon_type].max_m_alloc_chance) == 0) &&
+       if (one_in_(d_info[dungeon_type].max_m_alloc_chance) &&
            !p_ptr->inside_arena && !p_ptr->inside_quest && !p_ptr->inside_battle)
        {
                /* Make a new monster */
@@ -2662,7 +2662,7 @@ msg_print("
        /*** Process mutation effects ***/
        if (p_ptr->muta2 && !p_ptr->inside_battle && !p_ptr->wild_mode)
        {
-               if ((p_ptr->muta2 & MUT2_BERS_RAGE) && (randint(3000) == 1))
+               if ((p_ptr->muta2 & MUT2_BERS_RAGE) && one_in_(3000))
                {
                        disturb(0, 0);
 #ifdef JP
@@ -2788,7 +2788,7 @@ msg_print("
                }
 
                if ((p_ptr->muta2 & MUT2_PROD_MANA) &&
-                   !p_ptr->anti_magic && (randint(9000) == 1))
+                   !p_ptr->anti_magic && one_in_(9000))
                {
                        int dire = 0;
                        disturb(0, 0);
@@ -2807,7 +2807,7 @@ msg_print("
                if ((p_ptr->muta2 & MUT2_ATT_DEMON) &&
                    !p_ptr->anti_magic && (randint(6666) == 666))
                {
-                       bool pet = (randint(6) == 1);
+                       bool pet = one_in_(6);
                        bool not_pet = (bool)(!pet);
 
                        if (summon_specific((pet ? -1 : 0), py, px,
@@ -2823,10 +2823,10 @@ msg_print("
                        }
                }
 
-               if ((p_ptr->muta2 & MUT2_SPEED_FLUX) && (randint(6000) == 1))
+               if ((p_ptr->muta2 & MUT2_SPEED_FLUX) && one_in_(6000))
                {
                        disturb(0, 0);
-                       if (randint(2) == 1)
+                       if (one_in_(2))
                        {
 #ifdef JP
 msg_print("ÀºÎÏŪ¤Ç¤Ê¤¯¤Ê¤Ã¤¿µ¤¤¬¤¹¤ë¡£");
@@ -2862,7 +2862,7 @@ msg_print("
                        }
                        msg_print(NULL);
                }
-               if ((p_ptr->muta2 & MUT2_BANISH_ALL) && (randint(9000) == 1))
+               if ((p_ptr->muta2 & MUT2_BANISH_ALL) && one_in_(9000))
                {
                        disturb(0, 0);
 #ifdef JP
@@ -2939,7 +2939,7 @@ msg_print("
                if ((p_ptr->muta2 & MUT2_ATT_ANIMAL) &&
                   !p_ptr->anti_magic && one_in_(7000))
                {
-                       bool pet = (randint(3) == 1);
+                       bool pet = one_in_(3);
                        bool not_pet = (bool)(!pet);
 
                        if (summon_specific((pet ? -1 : 0), py, px, dun_level, SUMMON_ANIMAL,
@@ -3039,13 +3039,13 @@ msg_print("
 #endif
 
                                msg_print(NULL);
-                               (void)dec_stat(which_stat, randint(6) + 6, randint(3) == 1);
+                               (void)dec_stat(which_stat, randint(6) + 6, one_in_(3));
                        }
                }
                if ((p_ptr->muta2 & MUT2_ATT_DRAGON) &&
                   !p_ptr->anti_magic && one_in_(3000))
                {
-                       bool pet = (randint(5) == 1);
+                       bool pet = one_in_(5);
                        bool not_pet = (bool)(!pet);
 
                        if (summon_specific((pet ? -1 : 0), py, px, dun_level, SUMMON_DRAGON,
@@ -3274,7 +3274,7 @@ msg_print("
        }
 
        /* Rarely, take damage from the Jewel of Judgement */
-       if ((randint(999) == 1) && !p_ptr->anti_magic)
+       if (one_in_(999) && !p_ptr->anti_magic)
        {
                if ((inventory[INVEN_LITE].tval) &&
                    (inventory[INVEN_LITE].sval == SV_LITE_THRAIN))
@@ -3305,7 +3305,7 @@ take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), "
                if (!p_ptr->inside_battle)
                {
                        /* TY Curse */
-                       if ((f3 & TR3_TY_CURSE) && (randint(TY_CURSE_CHANCE) == 1))
+                       if ((f3 & TR3_TY_CURSE) && one_in_(TY_CURSE_CHANCE))
                        {
                                int count = 0;
 
@@ -3313,7 +3313,7 @@ take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), "
                        }
 
                        /* Make a chainsword noise */
-                       if ((o_ptr->name1 == ART_CHAINSWORD) && randint(CHAINSWORD_NOISE) == 1)
+                       if ((o_ptr->name1 == ART_CHAINSWORD) && one_in_(CHAINSWORD_NOISE))
                        {
                                char noise[1024];
 #ifdef JP
@@ -4690,7 +4690,7 @@ msg_print("
                default:
                {
                        if (flush_failure) flush();
-                       if (randint(2) == 1)
+                       if (one_in_(2))
                        {
                                char error_m[1024];
                                sound(SOUND_ILLEGAL);
index 9cef99d..0c6f61a 100644 (file)
@@ -3326,7 +3326,7 @@ msg_print("Ƭ
                        break;
                }
 
-               if (randint(1000) < v || randint(16) == 1)
+               if (randint(1000) < v || one_in_(16))
                {
 #ifdef JP
 msg_print("³ä¤ì¤ë¤è¤¦¤ÊƬÄˤ¬¤¹¤ë¡£");
@@ -3334,12 +3334,12 @@ msg_print("
                        msg_print("A vicious blow hits your head.");
 #endif
 
-                       if (randint(3) == 1)
+                       if (one_in_(3))
                        {
                                if (!p_ptr->sustain_int) (void)do_dec_stat(A_INT);
                                if (!p_ptr->sustain_wis) (void)do_dec_stat(A_WIS);
                        }
-                       else if (randint(2) == 1)
+                       else if (one_in_(2))
                        {
                                if (!p_ptr->sustain_int) (void)do_dec_stat(A_INT);
                        }
@@ -3610,7 +3610,7 @@ msg_print("
                /* Notice */
                notice = TRUE;
 
-               if (randint(1000) < v || randint(16) == 1)
+               if (randint(1000) < v || one_in_(16))
                {
                        if (!p_ptr->sustain_chr)
                        {
@@ -4529,7 +4529,7 @@ void do_poly_wounds(void)
        s16b wounds = p_ptr->cut;
        s16b hit_p = (p_ptr->mhp - p_ptr->chp);
        s16b change = damroll(p_ptr->lev, 5);
-       bool Nasty_effect = (randint(5) == 1);
+       bool Nasty_effect = one_in_(5);
 
        if (!(wounds || hit_p || Nasty_effect)) return;
 
@@ -4571,7 +4571,7 @@ msg_print("
 
        chg_virtue(V_CHANCE, 1);
 
-       if ((power > rand_int(20)) && (rand_int(3) == 1) && (p_ptr->prace != RACE_ANDROID))
+       if ((power > rand_int(20)) && one_in_(3) && (p_ptr->prace != RACE_ANDROID))
        {
                char effect_msg[80] = "";
                int new_race, expfact, goalexpfact, h_percent;
@@ -4579,7 +4579,7 @@ msg_print("
                /* Some form of racial polymorph... */
                power -= 10;
 
-               if ((power > rand_int(5)) && (rand_int(4) == 1))
+               if ((power > rand_int(5)) && one_in_(4))
                {
                        /* sex change */
                        power -= 2;
@@ -4608,7 +4608,7 @@ sprintf(effect_msg, "
                        }
                }
 
-               if ((power > rand_int(30)) && (rand_int(5) == 1))
+               if ((power > rand_int(30)) && one_in_(5))
                {
                        int tmp = 0;
 
@@ -4617,9 +4617,9 @@ sprintf(effect_msg, "
 
                        while (tmp < 6)
                        {
-                               if (rand_int(2) == 1)
+                               if (one_in_(2))
                                {
-                                       (void)dec_stat(tmp, randint(6) + 6, (randint(3) == 1));
+                                       (void)dec_stat(tmp, randint(6) + 6, one_in_(3));
                                        power -= 1;
                                }
                                tmp++;
@@ -4651,7 +4651,7 @@ sprintf(effect_msg, "
                        }
                }
 
-               while ((power > rand_int(20)) && (rand_int(10) == 1))
+               while ((power > rand_int(20)) && one_in_(10))
                {
                        /* Polymorph into a less mutated form */
                        power -= 10;
@@ -4755,7 +4755,7 @@ msg_print("
                lite_spot(py, px);
        }
 
-       if ((power > rand_int(30)) && (rand_int(6) == 1))
+       if ((power > rand_int(30)) && one_in_(6))
        {
                int tmp = 0;
 
@@ -4770,10 +4770,10 @@ msg_format("%s
 
                while (tmp < 6)
                {
-                       (void)dec_stat(tmp, randint(6) + 6, (randint(3) == 1));
+                       (void)dec_stat(tmp, randint(6) + 6, one_in_(3));
                        tmp++;
                }
-               if (randint(6) == 1)
+               if (one_in_(6))
                {
 #ifdef JP
 msg_print("¸½ºß»Ñ¤ÇÀ¸¤­¤Æ¤¤¤¯¤Î¤Ïº¤Æñ¤Ê¤è¤¦¤À¡ª");
@@ -4787,7 +4787,7 @@ take_hit(DAMAGE_LOSELIFE, damroll(randint(10), p_ptr->lev), "
                }
        }
 
-       if ((power > rand_int(20)) && (rand_int(4) == 1))
+       if ((power > rand_int(20)) && one_in_(4))
        {
                power -= 10;
 
@@ -4795,7 +4795,7 @@ take_hit(DAMAGE_LOSELIFE, damroll(randint(10), p_ptr->lev), "
                do_cmd_rerate(FALSE);
        }
 
-       while ((power > rand_int(15)) && (rand_int(3) == 1))
+       while ((power > rand_int(15)) && one_in_(3))
        {
                power -= 7;
                (void)gain_random_mutation(0);
@@ -4867,7 +4867,7 @@ bool take_hit(int damage_type, int damage, cptr hit_from, int monspell)
                                msg_print("The attack cuts your shield of invulnerability open!");
 #endif
                        }
-                       else if (randint(PENETRATE_INVULNERABILITY) == 1)
+                       else if (one_in_(PENETRATE_INVULNERABILITY))
                        {
 #ifdef JP
                                msg_print("̵Ũ¤Î¥Ð¥ê¥¢¤òÇˤäƹ¶·â¤µ¤ì¤¿¡ª");
@@ -4916,14 +4916,14 @@ bool take_hit(int damage_type, int damage, cptr hit_from, int monspell)
                        else
                        {
                                damage /= 2;
-                               if ((damage == 0) && (randint(2) == 1)) damage = 1;
+                               if ((damage == 0) && one_in_(2)) damage = 1;
                        }
                }
 
                if ((p_ptr->special_defense & KATA_MUSOU))
                {
                        damage /= 2;
-                       if ((damage == 0) && (randint(2) == 1)) damage = 1;
+                       if ((damage == 0) && one_in_(2)) damage = 1;
                }
        } /* not if LOSELIFE USELIFE */
 
index 6e82837..9f67767 100644 (file)
@@ -446,7 +446,7 @@ static bool cave_gen(void)
        dun_tun_jct = rand_range(DUN_TUN_JCT_MIN, DUN_TUN_JCT_MAX);
 
        /* Empty arena levels */
-       if (ironman_empty_levels || ((d_info[dungeon_type].flags1 & DF1_ARENA) && (empty_levels && (randint(EMPTY_LEVEL) == 1))))
+       if (ironman_empty_levels || ((d_info[dungeon_type].flags1 & DF1_ARENA) && (empty_levels && one_in_(EMPTY_LEVEL))))
        {
                empty_level = TRUE;
 
@@ -481,7 +481,7 @@ msg_print("
 
 #ifdef ALLOW_CAVERNS_AND_LAKES
        /* Possible "destroyed" level */
-       if ((dun_level > 30) && (rand_int(DUN_DEST*2) == 0) && (small_levels) && (d_info[dungeon_type].flags1 & DF1_DESTROY))
+       if ((dun_level > 30) && one_in_(DUN_DEST*2) && (small_levels) && (d_info[dungeon_type].flags1 & DF1_DESTROY))
        {
                destroyed = TRUE;
 
@@ -490,7 +490,7 @@ msg_print("
        }
 
        /* Make a lake some of the time */
-       if ((rand_int(LAKE_LEVEL) == 0) && !empty_level && !destroyed &&
+       if (one_in_(LAKE_LEVEL) && !empty_level && !destroyed &&
            (d_info[dungeon_type].flags1 & DF1_LAKE_MASK))
        {
                int count = 0;
@@ -723,7 +723,7 @@ if (cheat_room) msg_print("
        /* Make a hole in the dungeon roof sometimes at level 1 */
        if ((dun_level == 1) && terrain_streams)
        {
-               while (randint(DUN_MOS_DEN) == 1)
+               while (one_in_(DUN_MOS_DEN))
                {
                        place_trees(randint(cur_wid - 2), randint(cur_hgt - 2));
                }
@@ -733,7 +733,7 @@ if (cheat_room) msg_print("
        if (destroyed) destroy_level();
 
        /* Hack -- Add some rivers */
-       if ((randint(3) == 1) && (randint(dun_level) > 5) && terrain_streams)
+       if (one_in_(3) && (randint(dun_level) > 5) && terrain_streams)
        {
                /* Choose water or lava */
                if ((randint(MAX_DEPTH * 2) - 1 > dun_level) && (d_info[dungeon_type].flags1 & DF1_WATER_RIVER))
@@ -1077,7 +1077,7 @@ msg_format("
                 }
        }
 
-       if ((empty_level && ((randint(DARK_EMPTY) != 1) || (randint(100) > dun_level))) && !(d_info[dungeon_type].flags1 & DF1_DARKNESS))
+       if ((empty_level && (!one_in_(DARK_EMPTY) || (randint(100) > dun_level))) && !(d_info[dungeon_type].flags1 & DF1_DARKNESS))
        {
                /* Lite the cave */
                for (y = 0; y < cur_hgt; y++)
@@ -1354,7 +1354,7 @@ static bool level_gen(cptr *why)
        int level_height, level_width;
 
        if ((always_small_levels || ironman_small_levels ||
-           ((randint(SMALL_LEVEL) == 1) && small_levels) ||
+           (one_in_(SMALL_LEVEL) && small_levels) ||
             (d_info[dungeon_type].flags1 & DF1_BEGINNER) ||
            (d_info[dungeon_type].flags1 & DF1_SMALLEST)) &&
            !(d_info[dungeon_type].flags1 & DF1_BIG))
index 803bbc2..25f7d49 100644 (file)
@@ -1009,7 +1009,7 @@ msg_print("
 #endif
 
                }
-               else if (randint(2) == 1)
+               else if (one_in_(2))
                {
 #ifdef JP
 msg_format("%s¤Ï¾²¤òÆͤ­ÇˤäÆÄÀ¤ó¤Ç¤¤¤Ã¤¿¡£", m_name);
index 2af5bfa..f03210f 100644 (file)
@@ -678,7 +678,7 @@ bool make_attack_normal(int m_idx)
                                        }
                                        else
                                        {
-                                               if (randint(3) == 1)
+                                               if (one_in_(3))
 #ifdef JP
                                                        act = "¤Ï¢öËͤé¤Ï³Ú¤·¤¤²È²¢ö¤È²Î¤Ã¤Æ¤¤¤ë¡£";
                                                else
@@ -1740,7 +1740,7 @@ bool make_attack_normal(int m_idx)
                                        if ((randint(100) < 11) && (p_ptr->prace != RACE_ANDROID))
                                        {
                                                /* 1% chance for perm. damage */
-                                               bool perm = (randint(10) == 1);
+                                               bool perm = one_in_(10);
                                                if (dec_stat(A_CON, randint(10), perm)) obvious = TRUE;
                                        }
 
index c864fd7..8ab0d35 100644 (file)
@@ -237,7 +237,7 @@ msg_format("%^s
                if(dam > 0)
                {
                        dam /= 100;
-                       if((dam == 0) && (randint(3) == 1)) dam = 1;
+                       if((dam == 0) && one_in_(3)) dam = 1;
                }
                if (dam==0)
                {
@@ -1954,7 +1954,7 @@ act = "%s
                        case RBE_EAT_GOLD:
                                {
                                        pt = damage = 0;
-                                       if (randint(2) == 1) blinked = TRUE;
+                                       if (one_in_(2)) blinked = TRUE;
                                        break;
                                }
 
@@ -2850,7 +2850,7 @@ msg_format("%^s
        {
                /* Hack! "Cyber" monster makes noise... */
                if (m_ptr->r_idx == MON_CYBER &&
-                   (randint(CYBERNOISE) == 1) &&
+                   one_in_(CYBERNOISE) &&
                    !m_ptr->ml && (m_ptr->cdis <= MAX_SIGHT))
                {
                        if (disturb_minor) disturb(FALSE, FALSE);
@@ -2864,7 +2864,7 @@ msg_print("
 
                /* Some monsters can speak */
                if ((r_ptr->flags2 & RF2_CAN_SPEAK) && aware &&
-                       (randint(SPEAK_CHANCE) == 1) &&
+                       one_in_(SPEAK_CHANCE) &&
                        player_has_los_bold(oy, ox))
                {
                        char m_name[80];
@@ -3152,7 +3152,7 @@ msg_format("%^s%s", m_name, monmessage);
                        /* Monster destroyed a wall */
                        did_kill_wall = TRUE;
 
-                       if (randint(GRINDNOISE) == 1)
+                       if (one_in_(GRINDNOISE))
                        {
 #ifdef JP
 msg_print("¥®¥·¥®¥·¤¤¤¦²»¤¬Ê¹¤³¤¨¤ë¡£");
@@ -4165,7 +4165,7 @@ void monster_gain_exp(int m_idx, int s_idx)
                if (!(r_ptr->flags1 & RF1_UNIQUE) && !p_ptr->inside_arena)
                {
                        /* Allow some small variation per monster */
-                 if(rand_int(4) == 1){
+                 if(one_in_(4)){
                        i = extract_energy[r_ptr->speed] / 3;
                        if (i) m_ptr->mspeed += rand_spread(0, i);
                  }
index 7dac357..b719258 100644 (file)
@@ -1488,7 +1488,7 @@ void monster_desc(char *desc, monster_type *m_ptr, int mode)
        /* Are we hallucinating? (Idea from Nethack...) */
        if (p_ptr->image)
        {
-               if (randint(2) == 1)
+               if (one_in_(2))
                {
 #ifdef JP
 if (!get_rnd_line("silly_j.txt", m_ptr->r_idx, silly_name))
@@ -1884,7 +1884,7 @@ msg_format("%s%s
 
                                funny_desc[rand_int(MAX_SAN_FUNNY)], m_name);
 
-                       if (randint(3) == 1)
+                       if (one_in_(3))
                        {
                                msg_print(funny_comments[rand_int(MAX_SAN_COMMENT)]);
                                p_ptr->image = p_ptr->image + randint(r_ptr->level);
@@ -2564,7 +2564,7 @@ void choose_new_monster(int m_idx, bool born, int r_idx)
        m_ptr->mspeed = r_ptr->speed;
        /* Hack -- small racial variety */
        /* Allow some small variation per monster */
-       if(rand_int(4) == 1){
+       if(one_in_(4)){
                i = extract_energy[r_ptr->speed] / 3;
                if (i) m_ptr->mspeed += rand_spread(0, i);
        }
@@ -2897,7 +2897,7 @@ msg_print("
        if (!(r_ptr->flags1 & RF1_UNIQUE) && !p_ptr->inside_arena)
        {
                /* Allow some small variation per monster */
-         if(rand_int(4) == 1){
+         if(one_in_(4)){
                i = extract_energy[r_ptr->speed] / 3;
                if (i) m_ptr->mspeed += rand_spread(0, i);
          }
@@ -3596,11 +3596,11 @@ static bool summon_specific_okay(int r_idx)
                /* Do not summon enemies of the pets */
                if ((p_ptr->align < -9) && (r_ptr->flags3 & RF3_GOOD))
                {
-                       if (!(one_in_((0-p_ptr->align)/2+1))) return FALSE;
+                       if (!one_in_((0-p_ptr->align)/2+1)) return FALSE;
                }
                else if ((p_ptr->align > 9) && (r_ptr->flags3 & RF3_EVIL))
                {
-                       if (!(one_in_(p_ptr->align/2+1))) return FALSE;
+                       if (!one_in_(p_ptr->align/2+1)) return FALSE;
                }
        }
 
index 49753e9..da1f3e4 100644 (file)
@@ -3602,7 +3602,7 @@ msg_format("%^s
                                                        if(get_check_strict("Do you follow it? ", 1))
 #endif
                                                        {
-                                                               if (randint(3) == 1)
+                                                               if (one_in_(3))
                                                                {
                                                                        teleport_player(200);
 #ifdef JP
index 71df382..cd60b73 100644 (file)
@@ -3377,7 +3377,7 @@ msg_format("%^s
                                                                if(get_check_strict("Do you follow it? ", 1))
 #endif
                                                                {
-                                                                       if (randint(3) == 1)
+                                                                       if (one_in_(3))
                                                                        {
                                                                                teleport_player(200);
 #ifdef JP
index 2fbb9c0..8d20767 100644 (file)
@@ -1502,7 +1502,7 @@ msg_print("
 #endif
 
                }
-               else if (randint(2) == 1)
+               else if (one_in_(2))
                {
 #ifdef JP
 msg_format("%s¤Ï¾²¤òÆͤ­ÇˤäÆÄÀ¤ó¤Ç¤¤¤Ã¤¿¡£", m_name);
index 4cffc3d..7aedf3a 100644 (file)
@@ -620,7 +620,7 @@ s16b get_obj_num(int level)
        if ((level > 0) && !(d_info[dungeon_type].flags1 & DF1_BEGINNER))
        {
                /* Occasional "boost" */
-               if (rand_int(GREAT_OBJ) == 0)
+               if (one_in_(GREAT_OBJ))
                {
                        /* What a bizarre calculation */
                        level = 1 + (level * MAX_DEPTH / randint(MAX_DEPTH));
@@ -2051,11 +2051,11 @@ static bool make_artifact_special(object_type *o_ptr)
                        int d = (a_ptr->level - dun_level) * 2;
 
                        /* Roll for out-of-depth creation */
-                       if (rand_int(d) != 0) continue;
+                       if (!one_in_(d)) continue;
                }
 
                /* Artifact "rarity roll" */
-               if (rand_int(a_ptr->rarity) != 0) continue;
+               if (!one_in_(a_ptr->rarity)) continue;
 
                /* Find the base object */
                k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
@@ -2067,7 +2067,7 @@ static bool make_artifact_special(object_type *o_ptr)
                        int d = (k_info[k_idx].level - object_level) * 5;
 
                        /* Roll for out-of-depth creation */
-                       if (rand_int(d) != 0) continue;
+                       if (!one_in_(d)) continue;
                }
 
                /* Assign the template */
@@ -2132,11 +2132,11 @@ static bool make_artifact(object_type *o_ptr)
                        int d = (a_ptr->level - dun_level) * 2;
 
                        /* Roll for out-of-depth creation */
-                       if (rand_int(d) != 0) continue;
+                       if (!one_in_(d)) continue;
                }
 
                /* We must make the "rarity roll" */
-               if (rand_int(a_ptr->rarity) != 0) continue;
+               if (!one_in_(a_ptr->rarity)) continue;
 
                /* Hack -- mark the item as an artifact */
                o_ptr->name1 = i;
@@ -2263,7 +2263,7 @@ static void a_m_aux_1(object_type *o_ptr, int level, int power)
                        /* Very good */
                        if (power > 1)
                        {
-                               if (randint(30) == 1)
+                               if (one_in_(30))
                                        create_artifact(o_ptr, FALSE);
                                else
                                        /* Special Ego-item */
@@ -2314,11 +2314,11 @@ static void a_m_aux_1(object_type *o_ptr, int level, int power)
                                switch (o_ptr->name2)
                                {
                                case EGO_HA:
-                                       if ((randint(4) == 1) && (level > 40))
+                                       if (one_in_(4) && (level > 40))
                                                o_ptr->art_flags1 |= TR1_BLOWS;
                                        break;
                                case EGO_DF:
-                                       if (randint(3) == 1)
+                                       if (one_in_(3))
                                                o_ptr->art_flags2 |= TR2_RES_POIS;
                                        random_resistance(o_ptr, FALSE, randint(22)+16);
                                        break;
@@ -2327,18 +2327,18 @@ static void a_m_aux_1(object_type *o_ptr, int level, int power)
                                        break;
                                case EGO_KILL_DRAGON:
                                        random_resistance(o_ptr, FALSE, randint(12) + 4);
-                                       if (randint(3) == 1)
+                                       if (one_in_(3))
                                                o_ptr->art_flags2 |= TR2_RES_POIS;
                                        random_resistance(o_ptr, FALSE, randint(14) + 4);
                                case EGO_WEST:
-                                       if (randint(3) == 1)
+                                       if (one_in_(3))
                                                o_ptr->art_flags2 |= TR2_RES_FEAR;
                                        break;
                                case EGO_CHAOTIC:
                                        random_resistance(o_ptr, FALSE, (randint(34) + 4));
                                        break;
                                case EGO_SLAYING_WEAPON:
-                                       if (randint(3) == 1) /* double damage */
+                                       if (one_in_(3)) /* double damage */
                                                o_ptr->dd *= 2;
                                        else
                                        {
@@ -2346,35 +2346,35 @@ static void a_m_aux_1(object_type *o_ptr, int level, int power)
                                                {
                                                        o_ptr->dd++;
                                                }
-                                               while (randint(o_ptr->dd) == 1);
+                                               while (one_in_(o_ptr->dd));
                                                
                                                do
                                                {
                                                        o_ptr->ds++;
                                                }
-                                               while (randint(o_ptr->ds) == 1);
+                                               while (one_in_(o_ptr->ds));
                                        }
                                        
-                                       if (randint(5) == 1)
+                                       if (one_in_(5))
                                        {
                                                o_ptr->art_flags1 |= TR1_BRAND_POIS;
                                        }
-                                       if (o_ptr->tval == TV_SWORD && (randint(3) == 1))
+                                       if (o_ptr->tval == TV_SWORD && one_in_(3))
                                        {
                                                o_ptr->art_flags1 |= TR1_VORPAL;
                                        }
                                        break;
                                case EGO_TRUMP:
                                        random_resistance(o_ptr, FALSE, (randint(22) + 16));
-                                       if (randint(5) == 1)
+                                       if (one_in_(5))
                                                o_ptr->art_flags1 |= TR1_SLAY_DEMON;
                                        break;
                                case EGO_PATTERN:
-                                       if (randint(3) == 1)
+                                       if (one_in_(3))
                                                o_ptr->art_flags2 |= TR2_HOLD_LIFE;
-                                       if (randint(3) == 1)
+                                       if (one_in_(3))
                                                o_ptr->art_flags1 |= TR1_DEX;
-                                       if (randint(5) == 1)
+                                       if (one_in_(5))
                                                o_ptr->art_flags2 |= TR2_RES_FEAR;
                                        random_resistance(o_ptr, FALSE, (randint(22) + 16));
                                        break;
@@ -2382,7 +2382,7 @@ static void a_m_aux_1(object_type *o_ptr, int level, int power)
                                        o_ptr->pval = m_bonus(5, level) + 1;
                                        break;
                                case EGO_EARTHQUAKES:
-                                       if ((randint(3) == 1) && (level > 60))
+                                       if (one_in_(3) && (level > 60))
                                                o_ptr->art_flags1 |= TR1_BLOWS;
                                        else
                                                o_ptr->pval = m_bonus(3, level);
@@ -2392,7 +2392,7 @@ static void a_m_aux_1(object_type *o_ptr, int level, int power)
                                if (!o_ptr->art_name)
                                {
                                        /* Hack -- Super-charge the damage dice */
-                                       while (rand_int(10L * o_ptr->dd * o_ptr->ds) == 0) o_ptr->dd++;
+                                       while (one_in_(10L * o_ptr->dd * o_ptr->ds)) o_ptr->dd++;
 
                                        /* Hack -- Lower the damage dice */
                                        if (o_ptr->dd > 9) o_ptr->dd = 9;
@@ -2459,7 +2459,7 @@ static void a_m_aux_1(object_type *o_ptr, int level, int power)
                                }
 
                                /* Hack -- super-charge the damage dice */
-                               while (rand_int(10L * o_ptr->dd * o_ptr->ds) == 0) o_ptr->dd++;
+                               while (one_in_(10L * o_ptr->dd * o_ptr->ds)) o_ptr->dd++;
 
                                /* Hack -- restrict the damage dice */
                                if (o_ptr->dd > 9) o_ptr->dd = 9;
@@ -2487,12 +2487,12 @@ static void dragon_resist(object_type * o_ptr)
        {
                artifact_bias = 0;
 
-               if (randint(4) == 1)
+               if (one_in_(4))
                        random_resistance(o_ptr, FALSE, (randint(14) + 4));
                else
                        random_resistance(o_ptr, FALSE, (randint(22) + 16));
        }
-       while (randint(2) == 1);
+       while (one_in_(2));
 }
 
 
@@ -2549,7 +2549,7 @@ static void a_m_aux_2(object_type *o_ptr, int level, int power)
                {
                        /* Rating boost */
                        rating += 30;
-                       if(rand_int(50) == 1)
+                       if(one_in_(50))
                                create_artifact(o_ptr, FALSE);
 
                        /* Mention the item */
@@ -2609,7 +2609,7 @@ static void a_m_aux_2(object_type *o_ptr, int level, int power)
                                                }
                                                else
                                                {
-                                                       if (randint(4) == 1)
+                                                       if (one_in_(4))
                                                                o_ptr->art_flags1 |= TR1_CON;
                                                        break;
                                                }
@@ -2634,7 +2634,7 @@ static void a_m_aux_2(object_type *o_ptr, int level, int power)
                                /* Mention the item */
                                if (cheat_peek) object_mention(o_ptr);
                                dragon_resist(o_ptr);
-                               if (randint(3) != 1) break;
+                               if (!one_in_(3)) break;
                        }
 
                        /* Very good */
@@ -2672,7 +2672,7 @@ static void a_m_aux_2(object_type *o_ptr, int level, int power)
                                /* Mention the item */
                                if (cheat_peek) object_mention(o_ptr);
                                dragon_resist(o_ptr);
-                               if (randint(3) != 1) break;
+                               if (!one_in_(3)) break;
                        }
                        if (power > 1)
                        {
@@ -2710,7 +2710,7 @@ static void a_m_aux_2(object_type *o_ptr, int level, int power)
                                /* Mention the item */
                                if (cheat_peek) object_mention(o_ptr);
                                dragon_resist(o_ptr);
-                               if (randint(3) != 1) break;
+                               if (!one_in_(3)) break;
                        }
                        /* Very good */
                        if (power > 1)
@@ -2801,7 +2801,7 @@ static void a_m_aux_2(object_type *o_ptr, int level, int power)
                                /* Mention the item */
                                if (cheat_peek) object_mention(o_ptr);
                                dragon_resist(o_ptr);
-                               if (randint(3) != 1) break;
+                               if (!one_in_(3)) break;
                        }
 
                        /* Very good */
@@ -2993,7 +2993,7 @@ static void a_m_aux_3(object_type *o_ptr, int level, int power)
                                        {
                                                random_resistance(o_ptr, FALSE, randint(20) + 18);
                                        }
-                                       while (randint(4) == 1);
+                                       while (one_in_(4));
 
                                        /* Bonus to armor class */
                                        o_ptr->to_a = 10 + randint(5) + m_bonus(10, level);
@@ -3190,7 +3190,7 @@ static void a_m_aux_3(object_type *o_ptr, int level, int power)
                                        break;
                                }
                        }
-                       if (randint(400) == 1 && (power > 0) && !(o_ptr->ident & IDENT_CURSED) && (level > 79))
+                       if (one_in_(400) && (power > 0) && !(o_ptr->ident & IDENT_CURSED) && (level > 79))
                        {
                                o_ptr->pval = MIN(o_ptr->pval,4);
                                /* Randart amulet */
@@ -3452,8 +3452,8 @@ static void a_m_aux_3(object_type *o_ptr, int level, int power)
 
                                case SV_AMULET_RESISTANCE:
                                {
-                                       if (randint(3) == 1) random_resistance(o_ptr, FALSE, (randint(34) + 4));
-                                       if (randint(5) == 1) o_ptr->art_flags2 |= TR2_RES_POIS;
+                                       if (one_in_(3)) random_resistance(o_ptr, FALSE, (randint(34) + 4));
+                                       if (one_in_(5)) o_ptr->art_flags2 |= TR2_RES_POIS;
                                }
                                break;
 
@@ -3530,7 +3530,7 @@ static void a_m_aux_3(object_type *o_ptr, int level, int power)
                                        break;
                                }
                        }
-                       if (randint(150) == 1 && (power > 0) && !(o_ptr->ident & IDENT_CURSED) && (level > 79))
+                       if (one_in_(150) && (power > 0) && !(o_ptr->ident & IDENT_CURSED) && (level > 79))
                        {
                                o_ptr->pval = MIN(o_ptr->pval,4);
                                /* Randart amulet */
@@ -4259,7 +4259,7 @@ void apply_magic(object_type *o_ptr, int lev, bool okay, bool good, bool great,
                        /* Trump weapon */
                        case EGO_TRUMP:
                        {
-                               if (randint(7) == 1) o_ptr->xtra1 = EGO_XTRA_ABILITY;
+                               if (one_in_(7)) o_ptr->xtra1 = EGO_XTRA_ABILITY;
                                break;
                        }
 
@@ -4506,7 +4506,7 @@ bool make_object(object_type *j_ptr, bool good, bool great)
 
 
        /* Generate a special object, or a normal object */
-       if ((rand_int(prob) != 0) || !make_artifact_special(j_ptr))
+       if (!one_in_(prob) || !make_artifact_special(j_ptr))
        {
                int k_idx;
 
@@ -4671,7 +4671,7 @@ bool make_gold(object_type *j_ptr)
        i = ((randint(object_level + 2) + 2) / 2) - 1;
 
        /* Apply "extra" magic */
-       if (rand_int(GREAT_OBJ) == 0)
+       if (one_in_(GREAT_OBJ))
        {
                i += randint(object_level + 1);
        }
@@ -4921,7 +4921,7 @@ s16b drop_near(object_type *j_ptr, int chance, int y, int x)
                        if (s > bs) bn = 0;
 
                        /* Apply the randomizer to equivalent values */
-                       if ((++bn >= 2) && (rand_int(bn) != 0)) continue;
+                       if ((++bn >= 2) && !one_in_(bn)) continue;
 
                        /* Keep score */
                        bs = s;
@@ -6402,7 +6402,7 @@ bool process_frakir(int xx, int yy)
        else old_damage = old_damage/2;
 
        c_ptr = &cave[yy][xx];
-       if (((is_trap(c_ptr->feat) && !easy_disarm) || (c_ptr->info & CAVE_TRAP)) && randint(13)!=1)
+       if (((is_trap(c_ptr->feat) && !easy_disarm) || (c_ptr->info & CAVE_TRAP)) && !one_in_(13))
        {
                object_type *o_ptr = choose_warning_item();
 
index 502ea5e..01a5452 100644 (file)
@@ -1817,7 +1817,7 @@ msg_print("
                case RACE_DRACONIAN:
                        if (racial_aux(1, plev, A_CON, 12))
                        {
-                               int  Type = ((randint(3) == 1) ? GF_COLD : GF_FIRE);
+                               int  Type = (one_in_(3) ? GF_COLD : GF_FIRE);
 #ifdef JP
 cptr Type_desc = ((Type == GF_COLD) ? "Î䵤" : "±ê");
 #else
@@ -1836,7 +1836,7 @@ cptr Type_desc = ((Type == GF_COLD) ? "
                                                case CLASS_IMITATOR:
                                                case CLASS_ARCHER:
                                                case CLASS_SMITH:
-                                                       if (randint(3) == 1)
+                                                       if (one_in_(3))
                                                        {
                                                                Type = GF_MISSILE;
 #ifdef JP
@@ -1865,7 +1865,7 @@ Type_desc = "
                                                case CLASS_RED_MAGE:
                                                case CLASS_BLUE_MAGE:
                                                case CLASS_MIRROR_MASTER:
-                                                       if (randint(3) == 1)
+                                                       if (one_in_(3))
                                                        {
                                                                Type = GF_MANA;
 #ifdef JP
@@ -1887,7 +1887,7 @@ Type_desc = "
                                                        }
                                                        break;
                                                case CLASS_CHAOS_WARRIOR:
-                                                       if (randint(3) != 1)
+                                                       if (!one_in_(3))
                                                        {
                                                                Type = GF_CONFUSION;
 #ifdef JP
@@ -1911,7 +1911,7 @@ Type_desc = "
                                                case CLASS_MONK:
                                                case CLASS_SAMURAI:
                                                case CLASS_FORCETRAINER:
-                                                       if (randint(3) != 1)
+                                                       if (!one_in_(3))
                                                        {
                                                                Type = GF_CONFUSION;
 #ifdef JP
@@ -1933,7 +1933,7 @@ Type_desc = "
                                                        }
                                                        break;
                                                case CLASS_MINDCRAFTER:
-                                                       if (randint(3) != 1)
+                                                       if (!one_in_(3))
                                                        {
                                                                Type = GF_CONFUSION;
 #ifdef JP
@@ -1956,7 +1956,7 @@ Type_desc = "
                                                        break;
                                                case CLASS_PRIEST:
                                                case CLASS_PALADIN:
-                                                       if (randint(3) == 1)
+                                                       if (one_in_(3))
                                                        {
                                                                Type = GF_HELL_FIRE;
 #ifdef JP
@@ -1979,7 +1979,7 @@ Type_desc = "
                                                        break;
                                                case CLASS_ROGUE:
                                                case CLASS_NINJA:
-                                                       if (randint(3) == 1)
+                                                       if (one_in_(3))
                                                        {
                                                                Type = GF_DARK;
 #ifdef JP
@@ -2001,7 +2001,7 @@ Type_desc = "
                                                        }
                                                        break;
                                                case CLASS_BARD:
-                                                       if (randint(3) != 1)
+                                                       if (!one_in_(3))
                                                        {
                                                                Type = GF_SOUND;
 #ifdef JP
index 34a9eaf..2e8850b 100644 (file)
@@ -352,7 +352,7 @@ static void build_type1(int by0, int bx0)
 
 
        /* Hack -- Occasional pillar room */
-       if (rand_int(20) == 0)
+       if (one_in_(20))
        {
                for (y = y1; y <= y2; y += 2)
                {
@@ -365,7 +365,7 @@ static void build_type1(int by0, int bx0)
        }
 
        /* Hack -- Occasional room with four pillars */
-       else if (rand_int(20) == 0)
+       else if (one_in_(20))
        {
                if ((y1 + 4 < y2) && (x1 + 4 < x2))
                {
@@ -384,7 +384,7 @@ static void build_type1(int by0, int bx0)
        }
 
        /* Hack -- Occasional ragged-edge room */
-       else if (rand_int(50) == 0)
+       else if (one_in_(50))
        {
                for (y = y1 + 2; y <= y2 - 2; y += 2)
                {
@@ -402,7 +402,7 @@ static void build_type1(int by0, int bx0)
                }
        }
        /* Hack -- Occasional divided room */
-       else if (rand_int(50) == 0)
+       else if (one_in_(50))
        {
                if (randint(100) < 50)
                {
@@ -739,7 +739,7 @@ static void build_type3(int by0, int bx0)
                case 3:
                {
                        /* Occasionally pinch the center shut */
-                       if (rand_int(3) == 0)
+                       if (one_in_(3))
                        {
                                /* Pinch the east/west sides */
                                for (y = y1b; y <= y2b; y++)
@@ -762,7 +762,7 @@ static void build_type3(int by0, int bx0)
                                }
 
                                /* Sometimes shut using secret doors */
-                               if (rand_int(3) == 0)
+                               if (one_in_(3))
                                {
                                        place_secret_door(yval, x1a - 1);
                                        place_secret_door(yval, x2a + 1);
@@ -772,7 +772,7 @@ static void build_type3(int by0, int bx0)
                        }
 
                        /* Occasionally put a "plus" in the center */
-                       else if (rand_int(3) == 0)
+                       else if (one_in_(3))
                        {
                                c_ptr = &cave[yval][xval];
                                place_inner_grid(c_ptr);
@@ -787,7 +787,7 @@ static void build_type3(int by0, int bx0)
                        }
 
                        /* Occasionally put a pillar in the center */
-                       else if (rand_int(3) == 0)
+                       else if (one_in_(3))
                        {
                                c_ptr = &cave[yval][xval];
                                place_inner_grid(c_ptr);
@@ -978,7 +978,7 @@ static void build_type4(int by0, int bx0)
                        }
 
                        /* Occasionally, two more Large Inner Pillars */
-                       if (rand_int(2) == 0)
+                       if (one_in_(2))
                        {
                                tmp = randint(2);
                                for (y = yval - 1; y <= yval + 1; y++)
@@ -997,7 +997,7 @@ static void build_type4(int by0, int bx0)
                        }
 
                        /* Occasionally, some Inner rooms */
-                       if (rand_int(3) == 0)
+                       if (one_in_(3))
                        {
                                /* Long horizontal walls */
                                for (x = xval - 5; x <= xval + 5; x++)
@@ -1023,8 +1023,8 @@ static void build_type4(int by0, int bx0)
                                vault_monsters(yval, xval + 2, randint(2));
 
                                /* Objects */
-                               if (rand_int(3) == 0) place_object(yval, xval - 2, FALSE, FALSE);
-                               if (rand_int(3) == 0) place_object(yval, xval + 2, FALSE, FALSE);
+                               if (one_in_(3)) place_object(yval, xval - 2, FALSE, FALSE);
+                               if (one_in_(3)) place_object(yval, xval + 2, FALSE, FALSE);
                        }
 
                        break;
@@ -4115,7 +4115,7 @@ static void r_visit(int y1, int x1, int y2, int x2,
        place_floor_bold(y, x);
 
        /* setup order of adjacent node visits */
-       if (rand_int(3) == 0)
+       if (one_in_(3))
        {
                /* pick a random ordering */
                for (i = 0; i < 4; i++)
@@ -4356,7 +4356,7 @@ static void build_mini_c_vault(int x0, int y0, int xsize, int ysize)
        }
 
        /* Make a couple of entrances */
-       if (randint(2) == 1)
+       if (one_in_(2))
        {
                /* left and right */
                y = randint(dy) + dy / 2;
@@ -4447,7 +4447,7 @@ static void build_recursive_room(int x1, int y1, int x2, int y2, int power)
                        }
 
                        /* Make a couple of entrances */
-                       if (randint(2) == 1)
+                       if (one_in_(2))
                        {
                                /* left and right */
                                y = randint(ysize) + y1;
@@ -4524,7 +4524,7 @@ static void build_recursive_room(int x1, int y1, int x2, int y2, int power)
                        /* Make a door */
                        y = randint(ysize - 3) + y1 + 1;
 
-                       if (randint(2) == 1)
+                       if (one_in_(2))
                        {
                                /* left */
                                place_floor_bold(y, x1 + 1);
@@ -5091,7 +5091,7 @@ static void build_type12(int by0, int bx0)
                }
        }
 
-       if (emptyflag && (randint(2) == 1))
+       if (emptyflag && one_in_(2))
        {
                /* Build the vault */
                build_small_room(x0, y0);
index 4f95dc7..2e73fc7 100644 (file)
@@ -2053,7 +2053,7 @@ note = "
                                dam *= 3; dam /= randint(6) + 6;
                                if (seen) r_ptr->r_flags3 |= (RF3_IM_POIS);
                        }
-                       else if (randint(3) == 1) do_poly = TRUE;
+                       else if (one_in_(3)) do_poly = TRUE;
                        break;
                }
 
@@ -2294,7 +2294,7 @@ note = "
                        do_conf = (5 + randint(11) + r) / (r + 1);
                        if ((r_ptr->flags4 & RF4_BR_CHAO) ||
                            (m_ptr->r_idx == MON_STORMBRINGER) ||
-                           ((r_ptr->flags3 & RF3_DEMON) && (randint(3) == 1)))
+                           ((r_ptr->flags3 & RF3_DEMON) && one_in_(3)))
                        {
 #ifdef JP
 note = "¤Ë¤ÏÂÑÀ­¤¬¤¢¤ë¡£";
@@ -2818,7 +2818,7 @@ note = "
                                if (((r_ptr->flags3 & RF3_UNDEAD) ||
                                          (r_ptr->flags3 & RF3_DEMON)) &&
                                          (r_ptr->level > p_ptr->lev / 2) &&
-                                         (randint(2) == 1))
+                                         one_in_(2))
                                {
                                        note = NULL;
 #ifdef JP
@@ -2844,7 +2844,7 @@ msg_print("
                                                /* Injure +/- confusion */
                                                monster_desc(killer, m_ptr, 0x88);
                                                take_hit(DAMAGE_ATTACK, dam, killer, -1);  /* has already been /3 */
-                                               if (randint(4) == 1)
+                                               if (one_in_(4))
                                                {
                                                        switch (randint(4))
                                                        {
@@ -2878,7 +2878,7 @@ note = "
                                }
                        }
 
-                       if ((dam > 0) && (randint(4) == 1))
+                       if ((dam > 0) && one_in_(4))
                        {
                                switch (randint(4))
                                {
@@ -2956,7 +2956,7 @@ note = "
                                if (((r_ptr->flags3 & RF3_UNDEAD) ||
                                     (r_ptr->flags3 & RF3_DEMON)) &&
                                     (r_ptr->level > p_ptr->lev / 2) &&
-                                    (randint(2) == 1))
+                                    (one_in_(2)))
                                {
                                        note = NULL;
 #ifdef JP
@@ -3130,7 +3130,7 @@ note_dies = "
                                if (((r_ptr->flags3 & RF3_UNDEAD) ||
                                     (r_ptr->flags3 & RF3_DEMON)) &&
                                     (r_ptr->level > p_ptr->lev / 2) &&
-                                    (randint(2) == 1))
+                                    (one_in_(2)))
                                {
                                        note = NULL;
 #ifdef JP
@@ -6043,7 +6043,7 @@ msg_print("
 #endif
 
                                        earthquake(ty, tx, 4 + rand_int(4));
-                                       if (randint(6) != 1) break;
+                                       if (!one_in_(6)) break;
                                }
                        case 3: case 4: case 5: case 6:
                                if (!count)
@@ -6056,7 +6056,7 @@ msg_print("
 #endif
 
                                        project(0, 8, ty,tx, dam, GF_MANA, curse_flg, -1);
-                                       if (randint(6) != 1) break;
+                                       if (!one_in_(6)) break;
                                }
                        case 7: case 8:
                                if (!count)
@@ -6069,7 +6069,7 @@ msg_print("
 
                                        if (m_ptr->r_idx) teleport_away(c_ptr->m_idx, damroll(10, 10), FALSE);
                                        if (one_in_(13)) count += activate_hi_summon(ty, tx, TRUE);
-                                       if (randint(6) != 1) break;
+                                       if (!one_in_(6)) break;
                                }
                        case 9: case 10: case 11:
 #ifdef JP
@@ -6079,13 +6079,13 @@ msg_print("
 #endif
 
                                project(0, 7, ty, tx, 50, GF_DISINTEGRATE, curse_flg, -1);
-                               if (randint(6) != 1) break;
+                               if (!one_in_(6)) break;
                        case 12: case 13: case 14: case 15: case 16:
                                aggravate_monsters(0);
-                               if (randint(6) != 1) break;
+                               if (!one_in_(6)) break;
                        case 17: case 18:
                                count += activate_hi_summon(ty, tx, TRUE);
-                               if (randint(6) != 1) break;
+                               if (!one_in_(6)) break;
                        case 19: case 20: case 21: case 22:
                        {
                                bool pet = FALSE, friendly = FALSE;
@@ -6099,7 +6099,7 @@ msg_print("
                                        pet = TRUE;
                                }
                                count += summon_specific((pet ? -1 : 0), py, px, (pet ? p_ptr->lev*2/3+randint(p_ptr->lev/2) : dun_level), 0, TRUE, friendly, pet, FALSE, (bool)(!pet));
-                               if (randint(6) != 1) break;
+                               if (!one_in_(6)) break;
                        }
                        case 23: case 24: case 25:
                                if (p_ptr->hold_life && (rand_int(100) < 75)) break;
@@ -6111,7 +6111,7 @@ msg_print("
 
                                if (p_ptr->hold_life) lose_exp(p_ptr->exp / 160);
                                else lose_exp(p_ptr->exp / 16);
-                               if (randint(6) != 1) break;
+                               if (!one_in_(6)) break;
                        case 26: case 27: case 28:
                        {
                                int i = 0;
@@ -6123,7 +6123,7 @@ msg_print("
                                                {
                                                        (void)do_dec_stat(i);
                                                }
-                                               while (randint(2) == 1);
+                                               while (one_in_(2));
 
                                                i++;
                                        }
@@ -6136,7 +6136,7 @@ msg_print("
                        }
                        }
                }
-               while (randint(5) == 1);
+               while (one_in_(5));
        }
 
        if (p_ptr->inside_battle)
@@ -6272,7 +6272,7 @@ static bool project_p(int who, cptr who_name, int r, int y, int x, int dam, int
        if (!who) return (FALSE);
        if (who == p_ptr->riding) return (FALSE);
 
-       if ((p_ptr->reflect || p_ptr->tim_reflect || ((p_ptr->special_defense & KATA_FUUJIN) && !p_ptr->blind)) && !a_rad && (randint(10) != 1) && (typ != GF_PSY_SPEAR))
+       if ((p_ptr->reflect || p_ptr->tim_reflect || ((p_ptr->special_defense & KATA_FUUJIN) && !p_ptr->blind)) && !a_rad && !one_in_(10) && (typ != GF_PSY_SPEAR))
        {
                byte t_y, t_x;
                int max_attempts = 10;
@@ -6399,7 +6399,7 @@ if (fuzzy) msg_print("
                        if (double_resist) dam = (dam + 2) / 3;
 
                        if ((!(double_resist || p_ptr->resist_pois)) &&
-                            randint(HURT_CHANCE) == 1)
+                            one_in_(HURT_CHANCE))
                        {
                                do_dec_stat(A_CON);
                        }
@@ -6430,7 +6430,7 @@ if (fuzzy) msg_print("
                        {
                                set_poisoned(p_ptr->poisoned + rand_int(dam) + 10);
 
-                               if (randint(5) == 1) /* 6 */
+                               if (one_in_(5)) /* 6 */
                                {
 #ifdef JP
 msg_print("´ñ·ÁŪ¤ÊÊѿȤò¿ë¤²¤¿¡ª");
@@ -6438,13 +6438,13 @@ msg_print("
                                        msg_print("You undergo a freakish metamorphosis!");
 #endif
 
-                                       if (randint(4) == 1) /* 4 */
+                                       if (one_in_(4)) /* 4 */
                                                do_poly_self();
                                        else
                                                mutate_player();
                                }
 
-                               if (randint(6) == 1)
+                               if (one_in_(6))
                                {
                                        inven_damage(set_acid_destroy, 2);
                                }
@@ -6631,7 +6631,7 @@ if (fuzzy) msg_print("
                                set_confused(p_ptr->confused + randint(5) + 5);
                        }
 
-                       if (randint(5) == 1)
+                       if (one_in_(5))
                        {
                                inven_damage(set_cold_destroy, 3);
                        }
@@ -6660,7 +6660,7 @@ if (fuzzy) msg_print("̵
                        if (!p_ptr->resist_chaos)
                        {
                                (void)set_image(p_ptr->image + randint(10));
-                               if (randint(3) == 1)
+                               if (one_in_(3))
                                {
 #ifdef JP
 msg_print("¤¢¤Ê¤¿¤Î¿ÈÂΤϥ«¥ª¥¹¤ÎÎϤÇDZ¤¸¶Ê¤²¤é¤ì¤¿¡ª");
@@ -6706,7 +6706,7 @@ msg_print("
                                        lose_exp(5000 + (p_ptr->exp / 100) * MON_DRAIN_LIFE);
                                }
                        }
-                       if (!p_ptr->resist_chaos || (randint(9) == 1))
+                       if (!p_ptr->resist_chaos || one_in_(9))
                        {
                                inven_damage(set_elec_destroy, 2);
                                inven_damage(set_fire_destroy, 2);
@@ -6733,7 +6733,7 @@ if (fuzzy) msg_print("
                                (void)set_cut(p_ptr->cut + dam);
                        }
 
-                       if (!p_ptr->resist_shard || (randint(13) == 1))
+                       if (!p_ptr->resist_shard || one_in_(13))
                        {
                                inven_damage(set_cold_destroy, 2);
                        }
@@ -6761,7 +6761,7 @@ if (fuzzy) msg_print("
                                (void)set_stun(p_ptr->stun + k);
                        }
 
-                       if (!p_ptr->resist_sound || (randint(13) == 1))
+                       if (!p_ptr->resist_sound || one_in_(13))
                        {
                                inven_damage(set_cold_destroy, 2);
                        }
@@ -6873,7 +6873,7 @@ if (fuzzy) msg_print("
                                (void)set_cut(p_ptr->  cut + ( dam / 2));
                        }
 
-                       if ((!p_ptr->resist_shard) || (randint(12) == 1))
+                       if ((!p_ptr->resist_shard) || one_in_(12))
                        {
                                inven_damage(set_cold_destroy, 3);
                        }
@@ -7096,7 +7096,7 @@ msg_print("
                                dam = (dam * 2) / 3;
                        }
 
-                       if (!p_ptr->ffall || (randint(13) == 1))
+                       if (!p_ptr->ffall || one_in_(13))
                        {
                                inven_damage(set_cold_destroy, 2);
                        }
@@ -7228,7 +7228,7 @@ if (fuzzy) msg_print("
 #endif
 
                        take_hit(DAMAGE_ATTACK, dam, killer, monspell);
-                       if (!p_ptr->resist_shard || (randint(13) == 1))
+                       if (!p_ptr->resist_shard || one_in_(13))
                        {
                                if (!p_ptr->immune_fire) inven_damage(set_fire_destroy, 2);
                                inven_damage(set_cold_destroy, 2);
@@ -7256,7 +7256,7 @@ if (fuzzy) msg_print("
                                (void)set_stun(p_ptr->stun + randint(15));
                        }
 
-                       if ((!(p_ptr->resist_cold || p_ptr->oppose_cold || music_singing(MUSIC_RESIST) || (p_ptr->special_defense & KATA_MUSOU))) || (randint(12) == 1))
+                       if ((!(p_ptr->resist_cold || p_ptr->oppose_cold || music_singing(MUSIC_RESIST) || (p_ptr->special_defense & KATA_MUSOU))) || one_in_(12))
                        {
                                if (!p_ptr->immune_cold) inven_damage(set_cold_destroy, 3);
                        }
@@ -8654,7 +8654,7 @@ bool project(int who, int rad, int y, int x, int dam, int typ, int flg, int mons
                        {
                                monster_race *ref_ptr = &r_info[m_list[cave[y][x].m_idx].r_idx];
 
-                               if ((ref_ptr->flags2 & RF2_REFLECTING) && (randint(10) != 1 && !(flg & PROJECT_NO_REF) && (!who || dist_hack > 1)))
+                               if ((ref_ptr->flags2 & RF2_REFLECTING) && (!one_in_(10) && !(flg & PROJECT_NO_REF) && (!who || dist_hack > 1)))
                                {
                                        byte t_y, t_x;
                                        int max_attempts = 10;
index c32aedf..2c27729 100644 (file)
@@ -6512,9 +6512,9 @@ void call_chaos(void)
        };
 
        Chaos_type = hurt_types[rand_int(31)];
-       if (randint(4) == 1) line_chaos = TRUE;
+       if (one_in_(4)) line_chaos = TRUE;
 
-       if (randint(6) == 1)
+       if (one_in_(6))
        {
                for (dummy = 1; dummy < 10; dummy++)
                {
@@ -6527,7 +6527,7 @@ void call_chaos(void)
                        }
                }
        }
-       else if (randint(3) == 1)
+       else if (one_in_(3))
        {
                fire_ball(Chaos_type, 0, 500, 8);
        }
@@ -6567,7 +6567,7 @@ msg_print("
 #endif
 
                                earthquake(py, px, 5 + rand_int(10));
-                               if (randint(6) != 1) break;
+                               if (!one_in_(6)) break;
                        }
                case 30: case 31:
                        if (!(*count))
@@ -6585,7 +6585,7 @@ msg_print("
 #else
                                take_hit(DAMAGE_NOESCAPE, dam, "released pure mana", -1);
 #endif
-                               if (randint(6) != 1) break;
+                               if (!one_in_(6)) break;
                        }
                case 32: case 33:
                        if (!(*count))
@@ -6598,7 +6598,7 @@ msg_print("
 
                                teleport_player(damroll(10, 10));
                                if (rand_int(13)) (*count) += activate_hi_summon(py, px, FALSE);
-                               if (randint(6) != 1) break;
+                               if (!one_in_(6)) break;
                        }
                case 34:
 #ifdef JP
@@ -6617,16 +6617,16 @@ msg_print("
                                take_hit(DAMAGE_NOESCAPE, 50, "surge of energy", -1);
 #endif
                        }
-                       if (randint(6) != 1) break;
+                       if (!one_in_(6)) break;
                case 1: case 2: case 3: case 16: case 17:
                        aggravate_monsters(0);
-                       if (randint(6) != 1) break;
+                       if (!one_in_(6)) break;
                case 4: case 5: case 6:
                        (*count) += activate_hi_summon(py, px, FALSE);
-                       if (randint(6) != 1) break;
+                       if (!one_in_(6)) break;
                case 7: case 8: case 9: case 18:
                        (*count) += summon_specific(0, py, px, dun_level, 0, TRUE, FALSE, FALSE, TRUE, TRUE);
-                       if (randint(6) != 1) break;
+                       if (!one_in_(6)) break;
                case 10: case 11: case 12:
 #ifdef JP
 msg_print("À¸Ì¿ÎϤ¬ÂΤ«¤éµÛ¤¤¼è¤é¤ì¤¿µ¤¤¬¤¹¤ë¡ª");
@@ -6635,7 +6635,7 @@ msg_print("
 #endif
 
                        lose_exp(p_ptr->exp / 16);
-                       if (randint(6) != 1) break;
+                       if (!one_in_(6)) break;
                case 13: case 14: case 15: case 19: case 20:
                        if (stop_ty || (p_ptr->free_act && (randint(125) < p_ptr->skill_sav)) || (p_ptr->pclass == CLASS_BERSERKER))
                        {
@@ -6655,10 +6655,10 @@ msg_print("Ħ
                                        set_paralyzed(p_ptr->paralyzed + randint(13));
                                stop_ty = TRUE;
                        }
-                       if (randint(6) != 1) break;
+                       if (!one_in_(6)) break;
                case 21: case 22: case 23:
                        (void)do_dec_stat(rand_int(6));
-                       if (randint(6) != 1) break;
+                       if (!one_in_(6)) break;
                case 24:
 #ifdef JP
 msg_print("¤Û¤¨¡©»ä¤Ïï¡©¤³¤³¤Ç²¿¤·¤Æ¤ë¡©");
@@ -6667,7 +6667,7 @@ msg_print("
 #endif
 
                        lose_all_info();
-                       if (randint(6) != 1) break;
+                       if (!one_in_(6)) break;
                case 25:
                        /*
                         * Only summon Cyberdemons deep in the dungeon.
@@ -6678,7 +6678,7 @@ msg_print("
                                stop_ty = TRUE;
                                break;
                        }
-                       if (randint(6) != 1) break;
+                       if (!one_in_(6)) break;
                default:
                        while (i < 6)
                        {
@@ -6686,13 +6686,13 @@ msg_print("
                                {
                                        (void)do_dec_stat(i);
                                }
-                               while (randint(2) == 1);
+                               while (one_in_(2));
 
                                i++;
                        }
                }
        }
-       while ((randint(3) == 1) && !stop_ty);
+       while (one_in_(3) && !stop_ty);
 
        return stop_ty;
 }
index ab6b0ff..56fb157 100644 (file)
@@ -2425,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);
@@ -2563,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);
@@ -3002,7 +3002,7 @@ s = "
 
 
                /* Back-fire */
-               if (rand_int(recharge_strength) == 0)
+               if (one_in_(recharge_strength))
                {
                        /* Activate the failure code. */
                        fail = TRUE;
@@ -3041,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;
@@ -3119,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;
                                }
                        }
@@ -3142,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. */
@@ -3384,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
@@ -5033,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 */
@@ -5073,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 */
@@ -5110,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 */
@@ -5146,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 */
@@ -5624,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;
@@ -5656,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;
@@ -5748,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;
                                }
                        }
@@ -5771,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. */
index deae7d6..fd492cb 100644 (file)
@@ -319,7 +319,7 @@ static void say_comment_1(void)
 #endif
 
 
-       if (randint(RUMOR_CHANCE) == 1)
+       if (one_in_(RUMOR_CHANCE))
        {
 #ifdef JP
 msg_print("Ź¼ç¤Ï¼ª¤¦¤Á¤·¤¿:");
@@ -570,7 +570,7 @@ static void purchase_analyze(s32b price, s32b value, s32b guess)
                msg_print(comment_7b[rand_int(MAX_COMMENT_7B)]);
 
                chg_virtue(V_JUSTICE, -1);
-               if (randint(4)==1)
+               if (one_in_(4))
                        chg_virtue(V_HONOUR, -1);
 
                /* Sound */
@@ -583,9 +583,9 @@ static void purchase_analyze(s32b price, s32b value, s32b guess)
                /* Comment */
                msg_print(comment_7c[rand_int(MAX_COMMENT_7C)]);
 
-               if (randint(4)==1)
+               if (one_in_(4))
                        chg_virtue(V_HONOUR, -1);
-               else if (randint(4)==1)
+               else if (one_in_(4))
                        chg_virtue(V_HONOUR, 1);
 
                /* Sound */
@@ -598,9 +598,9 @@ static void purchase_analyze(s32b price, s32b value, s32b guess)
                /* Comment */
                msg_print(comment_7d[rand_int(MAX_COMMENT_7D)]);
 
-               if (randint(2)==1)
+               if (one_in_(2))
                        chg_virtue(V_HONOUR, -1);
-               if (randint(4)==1)
+               if (one_in_(4))
                        chg_virtue(V_HONOUR, 1);
 
                if (10 * price < value)
@@ -1067,7 +1067,7 @@ static void mass_produce(object_type *o_ptr)
                case TV_WAND:
                case TV_STAFF:
                {
-                       if ((cur_store_num == STORE_BLACK) && (randint(3) == 1))
+                       if ((cur_store_num == STORE_BLACK) && one_in_(3))
                        {
                                if (cost < 1601L) size += damroll(1, 5);
                                else if (cost < 3201L) size += damroll(1, 3);
@@ -1088,19 +1088,19 @@ static void mass_produce(object_type *o_ptr)
        {
                discount = 0;
        }
-       else if (rand_int(25) == 0)
+       else if (one_in_(25))
        {
                discount = 25;
        }
-       else if (rand_int(150) == 0)
+       else if (one_in_(150))
        {
                discount = 50;
        }
-       else if (rand_int(300) == 0)
+       else if (one_in_(300))
        {
                discount = 75;
        }
-       else if (rand_int(500) == 0)
+       else if (one_in_(500))
        {
                discount = 90;
        }
@@ -3421,7 +3421,7 @@ msg_format("%s
                                if (st_ptr->stock_num == 0)
                                {
                                        /* Shuffle */
-                                       if (rand_int(STORE_SHUFFLE) == 0)
+                                       if (one_in_(STORE_SHUFFLE))
                                        {
                                                char buf[80];
                                                /* Message */
index f3c8f98..e7da296 100644 (file)
@@ -72,7 +72,7 @@ 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),
@@ -259,7 +259,7 @@ void build_streamer(int feat, int chance)
                        c_ptr->feat = feat;
 
                        /* Hack -- Add some (known) treasure */
-                       if (treasure && (rand_int(chance) == 0)) c_ptr->feat += 0x04;
+                       if (treasure && one_in_(chance)) c_ptr->feat += 0x04;
                }
 
                if (dummy >= SAFE_MAX_ATTEMPTS)
@@ -332,7 +332,7 @@ void place_trees(int x, int y)
        }
 
        /* 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;
index dc7627b..5706110 100644 (file)
@@ -94,7 +94,7 @@ void check_experience(void)
                        }
                        if (p_ptr->prace == RACE_BEASTMAN)
                        {
-                               if (randint(5) == 1) level_mutation = TRUE;
+                               if (one_in_(5)) level_mutation = TRUE;
                        }
                        level_inc_stat = TRUE;
 
@@ -811,7 +811,7 @@ msg_print("
        }
 
        /* Drop a dead corpse? */
-       if ((randint(r_ptr->flags1 & RF1_UNIQUE ? 1 : 4) == 1) &&
+       if (one_in_(r_ptr->flags1 & RF1_UNIQUE ? 1 : 4) &&
            ((r_ptr->flags9 & RF9_DROP_CORPSE) ||
             (r_ptr->flags9 & RF9_DROP_SKELETON)) &&
            !(p_ptr->inside_arena || p_ptr->inside_battle || (m_ptr->smart & SM_CLONED) || ((m_ptr->r_idx == today_mon) && is_pet(m_ptr))))
@@ -834,11 +834,11 @@ msg_print("
                        /* Lots of damage in one blow */
                        if ((0 - ((m_ptr->maxhp) / 4)) > m_ptr->hp)
                        {
-                               if (randint(5) == 1) corpse = TRUE;
+                               if (one_in_(5)) corpse = TRUE;
                        }
                        else
                        {
-                               if (randint(5) != 1) corpse = TRUE;
+                               if (!one_in_(5)) corpse = TRUE;
                        }
                }
 
@@ -866,7 +866,7 @@ msg_print("
        if (m_ptr->r_idx == MON_DAWN &&
            !(p_ptr->inside_arena || p_ptr->inside_battle))
        {
-               if (randint(7) != 1)
+               if (!one_in_(7))
                {
                        int wy = py, wx = px;
                        int attempts = 100;
@@ -1129,7 +1129,7 @@ msg_print("
 
                        if (m_ptr->r_idx == MON_OBERON)
                        {
-                               if (randint(3) == 1)
+                               if (one_in_(3))
                                {
                                        a_idx = ART_THRAIN;
                                        chance = 33;
@@ -1197,7 +1197,7 @@ msg_print("
                        }
                        else if (m_ptr->r_idx == MON_SAURON)
                        {
-                               if (randint(10) == 1)
+                               if (one_in_(10))
                                {
                                        a_idx = ART_POWER;
                                        chance = 100;
@@ -1210,7 +1210,7 @@ msg_print("
                        }
                        else if (m_ptr->r_idx == MON_BRAND)
                        {
-                               if (randint(3) != 1)
+                               if (!one_in_(3))
                                {
                                        a_idx = ART_BRAND;
                                        chance = 25;
@@ -1223,7 +1223,7 @@ msg_print("
                        }
                        else if (m_ptr->r_idx == MON_CORWIN)
                        {
-                               if (randint(3) != 1)
+                               if (!one_in_(3))
                                {
                                        a_idx = ART_GRAYSWANDIR;
                                        chance = 33;
@@ -1511,7 +1511,7 @@ int mon_damage_mod(monster_type *m_ptr, int dam, bool is_psy_spear)
        if ((r_ptr->flags3 & RF3_RES_ALL) && dam > 0)
        {
                dam /= 100;
-               if((dam == 0) && (randint(3) == 1)) dam = 1;
+               if((dam == 0) && one_in_(3)) dam = 1;
        }
 
        if (m_ptr->invulner)
@@ -1527,7 +1527,7 @@ msg_print("
 #endif
                        }
                }
-               else if (!(randint(PENETRATE_INVULNERABILITY) == 1))
+               else if (!one_in_(PENETRATE_INVULNERABILITY))
                {
                        return (0);
                }
@@ -1721,7 +1721,7 @@ bool mon_take_hit(int m_idx, int dam, bool *fear, cptr note)
                monster_desc(m_name, m_ptr, 0x100);
 
                /* Don't kill Amberites */
-               if ((r_ptr->flags3 & RF3_AMBERITE) && (randint(2) == 1))
+               if ((r_ptr->flags3 & RF3_AMBERITE) && one_in_(2))
                {
                        int curses = 1 + randint(3);
                        bool stop_ty = FALSE;
@@ -1794,7 +1794,7 @@ msg_format("%^s
                        chg_virtue(V_VITALITY, -2);
                }
 
-               if ((r_ptr->flags1 & RF1_UNIQUE) & (randint(3)==1))
+               if ((r_ptr->flags1 & RF1_UNIQUE) && one_in_(3))
                        chg_virtue(V_INDIVIDUALISM, -1);
 
                if (m_ptr->r_idx == MON_BEGGAR || m_ptr->r_idx == MON_LEPER)
@@ -1873,7 +1873,7 @@ msg_format("%^s
 
                if ((r_ptr->flags3 & RF3_ANIMAL) && !(r_ptr->flags3 & RF3_EVIL) && !(r_ptr->flags4 & ~(RF4_NOMAGIC_MASK))  && !(r_ptr->flags5 & ~(RF5_NOMAGIC_MASK)) && !(r_ptr->flags6 & ~(RF6_NOMAGIC_MASK)))
                {
-                       if (randint(4)==1) chg_virtue(V_NATURE, -1);
+                       if (one_in_(4)) chg_virtue(V_NATURE, -1);
                }
 
                if((r_ptr->flags1 & RF1_UNIQUE) && record_destroy_uniq)
@@ -4423,7 +4423,7 @@ void gain_level_reward(int chosen_reward)
        else if (!(p_ptr->lev % 13)) nasty_chance = 3;
        else if (!(p_ptr->lev % 14)) nasty_chance = 12;
 
-       if (randint(nasty_chance) == 1)
+       if (one_in_(nasty_chance))
                type = randint(20); /* Allow the 'nasty' effects */
        else
                type = randint(15) + 5; /* Or disallow them */
@@ -4444,7 +4444,7 @@ sprintf(wrath_reason, "%s
 
        effect = chaos_rewards[p_ptr->chaos_patron][type];
 
-       if ((randint(6) == 1) && !chosen_reward)
+       if (one_in_(6) && !chosen_reward)
        {
 #ifdef JP
 msg_format("%^s¤ÏË«Èþ¤È¤·¤Æ¤¢¤Ê¤¿¤òÆÍÁ³ÊÑ°Û¤µ¤»¤¿¡£",
@@ -4874,7 +4874,7 @@ msg_print("
                        msg_print("'Stay, mortal, and let me mold thee.'");
 #endif
 
-                       if ((randint(3) == 1) && !(chaos_stats[p_ptr->chaos_patron] < 0))
+                       if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
                                do_inc_stat(chaos_stats[p_ptr->chaos_patron]);
                        else
                                do_inc_stat(rand_int(6));
@@ -4899,7 +4899,7 @@ msg_print("
                        msg_print("'I grow tired of thee, mortal.'");
 #endif
 
-                       if ((randint(3) == 1) && !(chaos_stats[p_ptr->chaos_patron] < 0))
+                       if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
                                do_dec_stat(chaos_stats[p_ptr->chaos_patron]);
                        else
                                (void)do_dec_stat(rand_int(6));
@@ -5114,7 +5114,7 @@ msg_print("
 #endif
                                        break;
                                case 3:
-                                       if (randint(2) == 1)
+                                       if (one_in_(2))
                                        {
                                                if (!buki_motteruka(INVEN_RARM)) break;
                                                object_desc(o_name, &inventory[INVEN_RARM], TRUE, 0);
@@ -5171,8 +5171,8 @@ msg_print("
                        }
                        activate_hi_summon(py, px, FALSE);
                        (void)activate_ty_curse(FALSE, &count);
-                       if (randint(2) == 1) (void)curse_weapon(FALSE, INVEN_RARM);
-                       if (randint(2) == 1) (void)curse_armor();
+                       if (one_in_(2)) (void)curse_weapon(FALSE, INVEN_RARM);
+                       if (one_in_(2)) (void)curse_armor();
                        break;
                case REW_DESTRUCT:
 #ifdef JP