OSDN Git Service

object_type.xtra1の使用を廃止してart_flagsを使うようにした。これにより、object_type.xtra1は今のところ完全に使われていないメンバ...
authorhabu <habu@0568b783-4c39-0410-ac80-bf13821ea2a2>
Tue, 26 Feb 2002 10:47:52 +0000 (10:47 +0000)
committerhabu <habu@0568b783-4c39-0410-ac80-bf13821ea2a2>
Tue, 26 Feb 2002 10:47:52 +0000 (10:47 +0000)
one_sustain()、one_resistance()、one_ability()などの関数を用意し、これまでマジックナンバーだった、random_resistance(...,randint(22)+16)のような指定をすべてこれらで置き変えた。
セーブファイル互換性のためにload.cでxtra1とxtra2を見てart_flagsに耐性等をコンバートするコードも追加した。

src/artifact.c
src/cmd6.c
src/externs.h
src/load.c
src/object1.c
src/object2.c
src/xtra2.c

index b749bce..75b4ff9 100644 (file)
 #define ACTIVATION_CHANCE 3
 
 
+/*
+ * Choose one random sustain
+ */
+void one_sustain(object_type *o_ptr)
+{
+       switch (randint0(6))
+       {
+               case 0: o_ptr->art_flags2 |= (TR2_SUST_STR); break;
+               case 1: o_ptr->art_flags2 |= (TR2_SUST_INT); break;
+               case 2: o_ptr->art_flags2 |= (TR2_SUST_WIS); break;
+               case 3: o_ptr->art_flags2 |= (TR2_SUST_DEX); break;
+               case 4: o_ptr->art_flags2 |= (TR2_SUST_CON); break;
+               case 5: o_ptr->art_flags2 |= (TR2_SUST_CHR); break;
+       }
+}
+
+
+/*
+ * Choose one random high resistance
+ */
+void one_high_resistance(object_type *o_ptr)
+{
+       switch (randint0(12))
+       {
+               case  0: o_ptr->art_flags2 |= (TR2_RES_POIS);   break;
+               case  1: o_ptr->art_flags2 |= (TR2_RES_LITE);   break;
+               case  2: o_ptr->art_flags2 |= (TR2_RES_DARK);   break;
+               case  3: o_ptr->art_flags2 |= (TR2_RES_SHARDS); break;
+               case  4: o_ptr->art_flags2 |= (TR2_RES_BLIND);  break;
+               case  5: o_ptr->art_flags2 |= (TR2_RES_CONF);   break;
+               case  6: o_ptr->art_flags2 |= (TR2_RES_SOUND);  break;
+               case  7: o_ptr->art_flags2 |= (TR2_RES_NETHER); break;
+               case  8: o_ptr->art_flags2 |= (TR2_RES_NEXUS);  break;
+               case  9: o_ptr->art_flags2 |= (TR2_RES_CHAOS);  break;
+               case 10: o_ptr->art_flags2 |= (TR2_RES_DISEN);  break;
+               case 11: o_ptr->art_flags2 |= (TR2_RES_FEAR);   break;
+       }
+}
+
+
+/*
+ * Choose one random high resistance ( except poison and disenchantment )
+ */
+void one_loadly_high_resistance(object_type *o_ptr)
+{
+       switch (randint0(10))
+       {
+               case 0: o_ptr->art_flags2 |= (TR2_RES_LITE);   break;
+               case 1: o_ptr->art_flags2 |= (TR2_RES_DARK);   break;
+               case 2: o_ptr->art_flags2 |= (TR2_RES_SHARDS); break;
+               case 3: o_ptr->art_flags2 |= (TR2_RES_BLIND);  break;
+               case 4: o_ptr->art_flags2 |= (TR2_RES_CONF);   break;
+               case 5: o_ptr->art_flags2 |= (TR2_RES_SOUND);  break;
+               case 6: o_ptr->art_flags2 |= (TR2_RES_NETHER); break;
+               case 7: o_ptr->art_flags2 |= (TR2_RES_NEXUS);  break;
+               case 8: o_ptr->art_flags2 |= (TR2_RES_CHAOS);  break;
+               case 9: o_ptr->art_flags2 |= (TR2_RES_FEAR);   break;
+       }
+}
+
+
+/*
+ * Choose one random element resistance
+ */
+void one_ele_resistance(object_type *o_ptr)
+{
+       switch (randint0(4))
+       {
+               case  0: o_ptr->art_flags2 |= (TR2_RES_ACID); break;
+               case  1: o_ptr->art_flags2 |= (TR2_RES_ELEC); break;
+               case  2: o_ptr->art_flags2 |= (TR2_RES_COLD); break;
+               case  3: o_ptr->art_flags2 |= (TR2_RES_FIRE); break;
+       }
+}
+
+
+/*
+ * Choose one random element or poison resistance
+ */
+void one_dragon_ele_resistance(object_type *o_ptr)
+{
+       if (one_in_(7))
+       {
+               o_ptr->art_flags2 |= (TR2_RES_POIS);
+       }
+       else
+       {
+               one_ele_resistance(o_ptr);
+       }
+}
+
+
+/*
+ * Choose one random resistance
+ */
+void one_resistance(object_type *o_ptr)
+{
+       if (one_in_(3))
+       {
+               one_ele_resistance(o_ptr);
+       }
+       else
+       {
+               one_high_resistance(o_ptr);
+       }
+}
+
+
+/*
+ * Choose one random ability
+ */
+void one_ability(object_type *o_ptr)
+{
+       switch (randint0(8))
+       {
+               case 0: o_ptr->art_flags3 |= (TR3_FEATHER);     break;
+               case 1: o_ptr->art_flags3 |= (TR3_LITE);        break;
+               case 2: o_ptr->art_flags3 |= (TR3_SEE_INVIS);   break;
+               case 3: o_ptr->art_flags3 |= (TR3_WARNING);     break;
+               case 4: o_ptr->art_flags3 |= (TR3_SLOW_DIGEST); break;
+               case 5: o_ptr->art_flags3 |= (TR3_REGEN);       break;
+               case 6: o_ptr->art_flags2 |= (TR2_FREE_ACT);    break;
+               case 7: o_ptr->art_flags2 |= (TR2_HOLD_LIFE);   break;
+       }
+}
+
+
 static void curse_artifact(object_type * o_ptr)
 {
        if (o_ptr->pval > 0) o_ptr->pval = 0 - (o_ptr->pval + randint1(4));
@@ -260,151 +387,148 @@ static void random_plus(object_type * o_ptr, bool is_scroll)
 }
 
 
-void random_resistance(object_type * o_ptr, bool is_scroll, int specific)
+static void random_resistance(object_type * o_ptr, bool is_scroll)
 {
-       if (!specific) /* To avoid a number of possible bugs */
+       if (artifact_bias == BIAS_ACID)
        {
-               if (artifact_bias == BIAS_ACID)
+               if (!(o_ptr->art_flags2 & TR2_RES_ACID))
                {
-                       if (!(o_ptr->art_flags2 & TR2_RES_ACID))
-                       {
-                               o_ptr->art_flags2 |= TR2_RES_ACID;
-                               if (one_in_(2)) return;
-                       }
-                       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 (one_in_(2)) return;
-                       }
+                       o_ptr->art_flags2 |= TR2_RES_ACID;
+                       if (one_in_(2)) return;
                }
-               else if (artifact_bias == BIAS_ELEC)
+               if (one_in_(BIAS_LUCK) && !(o_ptr->art_flags2 & TR2_IM_ACID))
                {
-                       if (!(o_ptr->art_flags2 & TR2_RES_ELEC))
-                       {
-                               o_ptr->art_flags2 |= TR2_RES_ELEC;
-                               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 (one_in_(2)) return;
-                       }
-                       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 (one_in_(2)) return;
-                       }
+                       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 (one_in_(2)) return;
                }
-               else if (artifact_bias == BIAS_FIRE)
+       }
+       else if (artifact_bias == BIAS_ELEC)
+       {
+               if (!(o_ptr->art_flags2 & TR2_RES_ELEC))
                {
-                       if (!(o_ptr->art_flags2 & TR2_RES_FIRE))
-                       {
-                               o_ptr->art_flags2 |= TR2_RES_FIRE;
-                               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 (one_in_(2)) return;
-                       }
-                       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 (one_in_(2)) return;
-                       }
+                       o_ptr->art_flags2 |= TR2_RES_ELEC;
+                       if (one_in_(2)) return;
                }
-               else if (artifact_bias == BIAS_COLD)
+               if ((o_ptr->tval >= TV_CLOAK) && (o_ptr->tval <= TV_HARD_ARMOR) &&
+                   !(o_ptr->art_flags3 & TR3_SH_ELEC))
                {
-                       if (!(o_ptr->art_flags2 & TR2_RES_COLD))
-                       {
-                               o_ptr->art_flags2 |= TR2_RES_COLD;
-                               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 (one_in_(2)) return;
-                       }
-                       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 (one_in_(2)) return;
-                       }
+                       o_ptr->art_flags3 |= TR3_SH_ELEC;
+                       if (one_in_(2)) return;
                }
-               else if (artifact_bias == BIAS_POIS)
+               if (one_in_(BIAS_LUCK) && !(o_ptr->art_flags2 & TR2_IM_ELEC))
                {
-                       if (!(o_ptr->art_flags2 & TR2_RES_POIS))
-                       {
-                               o_ptr->art_flags2 |= TR2_RES_POIS;
-                               if (one_in_(2)) return;
-                       }
+                       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 (one_in_(2)) return;
                }
-               else if (artifact_bias == BIAS_WARRIOR)
+       }
+       else if (artifact_bias == BIAS_FIRE)
+       {
+               if (!(o_ptr->art_flags2 & TR2_RES_FIRE))
                {
-                       if (!one_in_(3) && (!(o_ptr->art_flags2 & TR2_RES_FEAR)))
-                       {
-                               o_ptr->art_flags2 |= TR2_RES_FEAR;
-                               if (one_in_(2)) return;
-                       }
-                       if (one_in_(3) && (!(o_ptr->art_flags3 & TR3_NO_MAGIC)))
-                       {
-                               o_ptr->art_flags3 |= TR3_NO_MAGIC;
-                               if (one_in_(2)) return;
-                       }
+                       o_ptr->art_flags2 |= TR2_RES_FIRE;
+                       if (one_in_(2)) return;
                }
-               else if (artifact_bias == BIAS_NECROMANTIC)
+               if ((o_ptr->tval >= TV_CLOAK) &&
+                   (o_ptr->tval <= TV_HARD_ARMOR) &&
+                   !(o_ptr->art_flags3 & TR3_SH_FIRE))
                {
-                       if (!(o_ptr->art_flags2 & TR2_RES_NETHER))
-                       {
-                               o_ptr->art_flags2 |= TR2_RES_NETHER;
-                               if (one_in_(2)) return;
-                       }
-                       if (!(o_ptr->art_flags2 & TR2_RES_POIS))
-                       {
-                               o_ptr->art_flags2 |= TR2_RES_POIS;
-                               if (one_in_(2)) return;
-                       }
-                       if (!(o_ptr->art_flags2 & TR2_RES_DARK))
-                       {
-                               o_ptr->art_flags2 |= TR2_RES_DARK;
-                               if (one_in_(2)) return;
-                       }
+                       o_ptr->art_flags3 |= TR3_SH_FIRE;
+                       if (one_in_(2)) return;
                }
-               else if (artifact_bias == BIAS_CHAOS)
+               if (one_in_(BIAS_LUCK) &&
+                   !(o_ptr->art_flags2 & TR2_IM_FIRE))
                {
-                       if (!(o_ptr->art_flags2 & TR2_RES_CHAOS))
-                       {
-                               o_ptr->art_flags2 |= TR2_RES_CHAOS;
-                               if (one_in_(2)) return;
-                       }
-                       if (!(o_ptr->art_flags2 & TR2_RES_CONF))
-                       {
-                               o_ptr->art_flags2 |= TR2_RES_CONF;
-                               if (one_in_(2)) return;
-                       }
-                       if (!(o_ptr->art_flags2 & TR2_RES_DISEN))
-                       {
-                               o_ptr->art_flags2 |= TR2_RES_DISEN;
-                               if (one_in_(2)) return;
-                       }
+                       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 (one_in_(2)) return;
+               }
+       }
+       else if (artifact_bias == BIAS_COLD)
+       {
+               if (!(o_ptr->art_flags2 & TR2_RES_COLD))
+               {
+                       o_ptr->art_flags2 |= TR2_RES_COLD;
+                       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 (one_in_(2)) return;
+               }
+               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 (one_in_(2)) return;
+               }
+       }
+       else if (artifact_bias == BIAS_POIS)
+       {
+               if (!(o_ptr->art_flags2 & TR2_RES_POIS))
+               {
+                       o_ptr->art_flags2 |= TR2_RES_POIS;
+                       if (one_in_(2)) return;
+               }
+       }
+       else if (artifact_bias == BIAS_WARRIOR)
+       {
+               if (!one_in_(3) && (!(o_ptr->art_flags2 & TR2_RES_FEAR)))
+               {
+                       o_ptr->art_flags2 |= TR2_RES_FEAR;
+                       if (one_in_(2)) return;
+               }
+               if (one_in_(3) && (!(o_ptr->art_flags3 & TR3_NO_MAGIC)))
+               {
+                       o_ptr->art_flags3 |= TR3_NO_MAGIC;
+                       if (one_in_(2)) return;
+               }
+       }
+       else if (artifact_bias == BIAS_NECROMANTIC)
+       {
+               if (!(o_ptr->art_flags2 & TR2_RES_NETHER))
+               {
+                       o_ptr->art_flags2 |= TR2_RES_NETHER;
+                       if (one_in_(2)) return;
+               }
+               if (!(o_ptr->art_flags2 & TR2_RES_POIS))
+               {
+                       o_ptr->art_flags2 |= TR2_RES_POIS;
+                       if (one_in_(2)) return;
+               }
+               if (!(o_ptr->art_flags2 & TR2_RES_DARK))
+               {
+                       o_ptr->art_flags2 |= TR2_RES_DARK;
+                       if (one_in_(2)) return;
+               }
+       }
+       else if (artifact_bias == BIAS_CHAOS)
+       {
+               if (!(o_ptr->art_flags2 & TR2_RES_CHAOS))
+               {
+                       o_ptr->art_flags2 |= TR2_RES_CHAOS;
+                       if (one_in_(2)) return;
+               }
+               if (!(o_ptr->art_flags2 & TR2_RES_CONF))
+               {
+                       o_ptr->art_flags2 |= TR2_RES_CONF;
+                       if (one_in_(2)) return;
+               }
+               if (!(o_ptr->art_flags2 & TR2_RES_DISEN))
+               {
+                       o_ptr->art_flags2 |= TR2_RES_DISEN;
+                       if (one_in_(2)) return;
                }
        }
 
-       switch (specific ? specific : randint1(42))
+       switch (randint1(42))
        {
                case 1:
                        if (!one_in_(WEIRD_LUCK))
-                               random_resistance(o_ptr, is_scroll, specific);
+                               random_resistance(o_ptr, is_scroll);
                        else
                        {
                                o_ptr->art_flags2 |= TR2_IM_ACID;
@@ -414,7 +538,7 @@ void random_resistance(object_type * o_ptr, bool is_scroll, int specific)
                        break;
                case 2:
                        if (!one_in_(WEIRD_LUCK))
-                               random_resistance(o_ptr, is_scroll, specific);
+                               random_resistance(o_ptr, is_scroll);
                        else
                        {
                                o_ptr->art_flags2 |= TR2_IM_ELEC;
@@ -424,7 +548,7 @@ void random_resistance(object_type * o_ptr, bool is_scroll, int specific)
                        break;
                case 3:
                        if (!one_in_(WEIRD_LUCK))
-                               random_resistance(o_ptr, is_scroll, specific);
+                               random_resistance(o_ptr, is_scroll);
                        else
                        {
                                o_ptr->art_flags2 |= TR2_IM_COLD;
@@ -434,7 +558,7 @@ void random_resistance(object_type * o_ptr, bool is_scroll, int specific)
                        break;
                case 4:
                        if (!one_in_(WEIRD_LUCK))
-                               random_resistance(o_ptr, is_scroll, specific);
+                               random_resistance(o_ptr, is_scroll);
                        else
                        {
                                o_ptr->art_flags2 |= TR2_IM_FIRE;
@@ -534,7 +658,7 @@ void random_resistance(object_type * o_ptr, bool is_scroll, int specific)
                        if (o_ptr->tval >= TV_CLOAK && o_ptr->tval <= TV_HARD_ARMOR)
                                o_ptr->art_flags3 |= TR3_SH_ELEC;
                        else
-                               random_resistance(o_ptr, is_scroll, specific);
+                               random_resistance(o_ptr, is_scroll);
                        if (!artifact_bias)
                                artifact_bias = BIAS_ELEC;
                        break;
@@ -542,7 +666,7 @@ void random_resistance(object_type * o_ptr, bool is_scroll, int specific)
                        if (o_ptr->tval >= TV_CLOAK && o_ptr->tval <= TV_HARD_ARMOR)
                                o_ptr->art_flags3 |= TR3_SH_FIRE;
                        else
-                               random_resistance(o_ptr, is_scroll, specific);
+                               random_resistance(o_ptr, is_scroll);
                        if (!artifact_bias)
                                artifact_bias = BIAS_FIRE;
                        break;
@@ -551,13 +675,13 @@ void random_resistance(object_type * o_ptr, bool is_scroll, int specific)
                            o_ptr->tval == TV_HELM || o_ptr->tval == TV_HARD_ARMOR)
                                o_ptr->art_flags2 |= TR2_REFLECT;
                        else
-                               random_resistance(o_ptr, is_scroll, specific);
+                               random_resistance(o_ptr, is_scroll);
                        break;
                case 42:
                        if (o_ptr->tval >= TV_CLOAK && o_ptr->tval <= TV_HARD_ARMOR)
                                o_ptr->art_flags3 |= TR3_SH_COLD;
                        else
-                               random_resistance(o_ptr, is_scroll, specific);
+                               random_resistance(o_ptr, is_scroll);
                        if (!artifact_bias)
                                artifact_bias = BIAS_COLD;
                        break;
@@ -1517,7 +1641,7 @@ bool create_artifact(object_type *o_ptr, bool a_scroll)
                                        }
                                }
                                else
-                                       random_resistance(o_ptr, a_scroll, FALSE);
+                                       random_resistance(o_ptr, a_scroll);
                                break;
                        case 5:
                                random_misc(o_ptr, a_scroll);
@@ -2811,7 +2935,7 @@ void random_artifact_resistance(object_type * o_ptr)
                        o_ptr->art_flags1 |= (TR1_CHAOTIC << randint0(18));
                dummy = randint1(2);
                for (i = 0; i < dummy; i++)
-                       random_resistance(o_ptr, FALSE, randint1(34) + 4);
+                       one_resistance(o_ptr);
                dummy = 2;
                for (i = 0; i < dummy; i++)
                {
@@ -2888,17 +3012,12 @@ void random_artifact_resistance(object_type * o_ptr)
 
        if (give_power)
        {
-               o_ptr->xtra1 = EGO_XTRA_ABILITY;
-
-               /* Randomize the "xtra" power */
-               if (o_ptr->xtra1) o_ptr->xtra2 = randint1(256);
+               one_ability(o_ptr);
        }
 
-       artifact_bias = 0;
-
        if (give_resistance)
        {
-               random_resistance(o_ptr, FALSE, randint1(22) + 16);
+               one_high_resistance(o_ptr);
        }
 }
 
index 0f313b2..474d531 100644 (file)
@@ -5497,7 +5497,7 @@ msg_print("
                                        o_ptr->art_flags1 |= (TR1_CHAOTIC << randint0(18));
                                dummy = randint1(2);
                                for (i = 0; i < dummy; i++)
-                                       random_resistance(o_ptr, FALSE, randint1(34) + 4);
+                                       one_resistance(o_ptr);
                                dummy = 2;
                                for (i = 0; i < dummy; i++)
                                {
index d428bdd..f099d54 100644 (file)
@@ -1287,8 +1287,14 @@ extern bool summon_possible(int y1, int x1);
 extern bool monst_spell_monst(int m_idx);
 
 /* artifact.c */
+extern void one_sustain(object_type *o_ptr);
+extern void one_high_resistance(object_type *o_ptr);
+extern void one_loadly_high_resistance(object_type *o_ptr);
+extern void one_ele_resistance(object_type *o_ptr);
+extern void one_dragon_ele_resistance(object_type *o_ptr);
+extern void one_resistance(object_type *o_ptr);
+extern void one_ability(object_type *o_ptr);
 extern bool create_artifact(object_type *o_ptr, bool a_scroll);
-extern void random_resistance(object_type * q_ptr, bool is_scroll, int specific);
 extern bool activate_random_artifact(object_type * o_ptr);
 extern void random_artifact_resistance(object_type * o_ptr);
 extern void create_named_art(int a_idx, int y, int x);
index 4ff5cfe..48ba889 100644 (file)
@@ -350,6 +350,54 @@ static void rd_item(object_type *o_ptr)
        /* Special powers */
        rd_byte(&o_ptr->xtra1);
        rd_byte(&o_ptr->xtra2);
+
+       if (o_ptr->xtra1 == EGO_XTRA_SUSTAIN)
+       {
+               switch (o_ptr->xtra2 % 6)
+               {
+                       case 0: o_ptr->art_flags2 |= (TR2_SUST_STR); break;
+                       case 1: o_ptr->art_flags2 |= (TR2_SUST_INT); break;
+                       case 2: o_ptr->art_flags2 |= (TR2_SUST_WIS); break;
+                       case 3: o_ptr->art_flags2 |= (TR2_SUST_DEX); break;
+                       case 4: o_ptr->art_flags2 |= (TR2_SUST_CON); break;
+                       case 5: o_ptr->art_flags2 |= (TR2_SUST_CHR); break;
+               }
+               o_ptr->xtra1 = o_ptr->xtra2 = 0;
+       }
+       else if (o_ptr->xtra1 == EGO_XTRA_POWER)
+       {
+               switch (o_ptr->xtra2 % 11)
+               {
+                       case  0: o_ptr->art_flags2 |= (TR2_RES_BLIND);  break;
+                       case  1: o_ptr->art_flags2 |= (TR2_RES_CONF);   break;
+                       case  2: o_ptr->art_flags2 |= (TR2_RES_SOUND);  break;
+                       case  3: o_ptr->art_flags2 |= (TR2_RES_SHARDS); break;
+                       case  4: o_ptr->art_flags2 |= (TR2_RES_NETHER); break;
+                       case  5: o_ptr->art_flags2 |= (TR2_RES_NEXUS);  break;
+                       case  6: o_ptr->art_flags2 |= (TR2_RES_CHAOS);  break;
+                       case  7: o_ptr->art_flags2 |= (TR2_RES_DISEN);  break;
+                       case  8: o_ptr->art_flags2 |= (TR2_RES_POIS);   break;
+                       case  9: o_ptr->art_flags2 |= (TR2_RES_DARK);   break;
+                       case 10: o_ptr->art_flags2 |= (TR2_RES_LITE);   break;
+               }
+               o_ptr->xtra1 = o_ptr->xtra2 = 0;
+       }               
+       else if (o_ptr->xtra1 == EGO_XTRA_ABILITY)
+       {
+               switch (o_ptr->xtra2 % 8)
+               {
+                       case 0: o_ptr->art_flags3 |= (TR3_FEATHER);     break;
+                       case 1: o_ptr->art_flags3 |= (TR3_LITE);        break;
+                       case 2: o_ptr->art_flags3 |= (TR3_SEE_INVIS);   break;
+                       case 3: o_ptr->art_flags3 |= (TR3_WARNING);     break;
+                       case 4: o_ptr->art_flags3 |= (TR3_SLOW_DIGEST); break;
+                       case 5: o_ptr->art_flags3 |= (TR3_REGEN);       break;
+                       case 6: o_ptr->art_flags2 |= (TR2_FREE_ACT);    break;
+                       case 7: o_ptr->art_flags2 |= (TR2_HOLD_LIFE);   break;
+               }
+               o_ptr->xtra1 = o_ptr->xtra2 = 0;
+       }
+
        if (z_older_than(10, 2, 3))
        {
                o_ptr->xtra3 = 0;
index 74fe9be..c8a81d6 100644 (file)
@@ -138,68 +138,6 @@ void object_flags(object_type *o_ptr, u32b *f1, u32b *f2, u32b *f3)
                (*f3) |= o_ptr->art_flags3;
        }
 
-       /* Extra powers */
-       if (!(o_ptr->art_name))
-       {
-               switch (o_ptr->xtra1)
-               {
-                       case EGO_XTRA_SUSTAIN:
-                       {
-                               /* Choose a sustain */
-                               switch (o_ptr->xtra2 % 6)
-                               {
-                                       case 0: (*f2) |= (TR2_SUST_STR); break;
-                                       case 1: (*f2) |= (TR2_SUST_INT); break;
-                                       case 2: (*f2) |= (TR2_SUST_WIS); break;
-                                       case 3: (*f2) |= (TR2_SUST_DEX); break;
-                                       case 4: (*f2) |= (TR2_SUST_CON); break;
-                                       case 5: (*f2) |= (TR2_SUST_CHR); break;
-                               }
-
-                               break;
-                       }
-
-                       case EGO_XTRA_POWER:
-                       {
-                               /* Choose a power */
-                               switch (o_ptr->xtra2 % 11)
-                               {
-                                       case  0: (*f2) |= (TR2_RES_BLIND);  break;
-                                       case  1: (*f2) |= (TR2_RES_CONF);   break;
-                                       case  2: (*f2) |= (TR2_RES_SOUND);  break;
-                                       case  3: (*f2) |= (TR2_RES_SHARDS); break;
-                                       case  4: (*f2) |= (TR2_RES_NETHER); break;
-                                       case  5: (*f2) |= (TR2_RES_NEXUS);  break;
-                                       case  6: (*f2) |= (TR2_RES_CHAOS);  break;
-                                       case  7: (*f2) |= (TR2_RES_DISEN);  break;
-                                       case  8: (*f2) |= (TR2_RES_POIS);   break;
-                                       case  9: (*f2) |= (TR2_RES_DARK);   break;
-                                       case 10: (*f2) |= (TR2_RES_LITE);   break;
-                               }
-
-                               break;
-                       }
-
-                       case EGO_XTRA_ABILITY:
-                       {
-                               /* Choose an ability */
-                               switch (o_ptr->xtra2 % 8)
-                               {
-                                       case 0: (*f3) |= (TR3_FEATHER);     break;
-                                       case 1: (*f3) |= (TR3_LITE);        break;
-                                       case 2: (*f3) |= (TR3_SEE_INVIS);   break;
-                                       case 3: (*f3) |= (TR3_WARNING);     break;
-                                       case 4: (*f3) |= (TR3_SLOW_DIGEST); break;
-                                       case 5: (*f3) |= (TR3_REGEN);       break;
-                                       case 6: (*f2) |= (TR2_FREE_ACT);    break;
-                                       case 7: (*f2) |= (TR2_HOLD_LIFE);   break;
-                               }
-
-                               break;
-                       }
-               }
-       }
-
        if ((o_ptr->tval > TV_CAPTURE) && o_ptr->xtra3)
        {
                if (o_ptr->xtra3 < 33)
@@ -336,68 +274,6 @@ void object_flags_known(object_type *o_ptr, u32b *f1, u32b *f2, u32b *f3)
                        (*f2) |= o_ptr->art_flags2;
                        (*f3) |= o_ptr->art_flags3;
                }
-
-               if (!(o_ptr->art_name))
-               {
-                       /* Extra powers */
-                       switch (o_ptr->xtra1)
-                       {
-                               case EGO_XTRA_SUSTAIN:
-                               {
-                                       /* Choose a sustain */
-                                       switch (o_ptr->xtra2 % 6)
-                                       {
-                                               case 0: (*f2) |= (TR2_SUST_STR); break;
-                                               case 1: (*f2) |= (TR2_SUST_INT); break;
-                                               case 2: (*f2) |= (TR2_SUST_WIS); break;
-                                               case 3: (*f2) |= (TR2_SUST_DEX); break;
-                                               case 4: (*f2) |= (TR2_SUST_CON); break;
-                                               case 5: (*f2) |= (TR2_SUST_CHR); break;
-                                       }
-
-                                       break;
-                               }
-
-                               case EGO_XTRA_POWER:
-                               {
-                                       /* Choose a power */
-                                       switch (o_ptr->xtra2 % 11)
-                                       {
-                                               case  0: (*f2) |= (TR2_RES_BLIND);  break;
-                                               case  1: (*f2) |= (TR2_RES_CONF);   break;
-                                               case  2: (*f2) |= (TR2_RES_SOUND);  break;
-                                               case  3: (*f2) |= (TR2_RES_SHARDS); break;
-                                               case  4: (*f2) |= (TR2_RES_NETHER); break;
-                                               case  5: (*f2) |= (TR2_RES_NEXUS);  break;
-                                               case  6: (*f2) |= (TR2_RES_CHAOS);  break;
-                                               case  7: (*f2) |= (TR2_RES_DISEN);  break;
-                                               case  8: (*f2) |= (TR2_RES_POIS);   break;
-                                               case  9: (*f2) |= (TR2_RES_DARK);   break;
-                                               case 10: (*f2) |= (TR2_RES_LITE);   break;
-                                       }
-
-                                       break;
-                               }
-
-                               case EGO_XTRA_ABILITY:
-                               {
-                                       /* Choose an ability */
-                                       switch (o_ptr->xtra2 % 8)
-                                       {
-                                               case 0: (*f3) |= (TR3_FEATHER);     break;
-                                               case 1: (*f3) |= (TR3_LITE);        break;
-                                               case 2: (*f3) |= (TR3_SEE_INVIS);   break;
-                                               case 3: (*f3) |= (TR3_WARNING);     break;
-                                               case 4: (*f3) |= (TR3_SLOW_DIGEST); break;
-                                               case 5: (*f3) |= (TR3_REGEN);       break;
-                                               case 6: (*f2) |= (TR2_FREE_ACT);    break;
-                                               case 7: (*f2) |= (TR2_HOLD_LIFE);   break;
-                                       }
-
-                                       break;
-                               }
-                       }
-               }
        }
 
        if ((o_ptr->tval > TV_CAPTURE) && o_ptr->xtra3)
index 823c433..3a4e129 100644 (file)
@@ -2232,8 +2232,6 @@ static void a_m_aux_1(object_type *o_ptr, int level, int power)
                todam2 = (todam2+1)/2;
        }
 
-       artifact_bias = 0;
-
        /* Good */
        if (power > 0)
        {
@@ -2332,26 +2330,28 @@ static void a_m_aux_1(object_type *o_ptr, int level, int power)
                                case EGO_HA:
                                        if (one_in_(4) && (level > 40))
                                                o_ptr->art_flags1 |= TR1_BLOWS;
+                                       one_sustain(o_ptr);
                                        break;
                                case EGO_DF:
                                        if (one_in_(3))
                                                o_ptr->art_flags2 |= TR2_RES_POIS;
-                                       random_resistance(o_ptr, FALSE, randint1(22)+16);
+                                       one_high_resistance(o_ptr);
+                                       one_sustain(o_ptr);
                                        break;
                                case EGO_SLAY_DRAGON:
-                                       random_resistance(o_ptr, FALSE, randint1(12) + 4);
+                                       one_ele_resistance(o_ptr);
                                        break;
                                case EGO_KILL_DRAGON:
-                                       random_resistance(o_ptr, FALSE, randint1(12) + 4);
+                                       one_ele_resistance(o_ptr);
                                        if (one_in_(3))
                                                o_ptr->art_flags2 |= TR2_RES_POIS;
-                                       random_resistance(o_ptr, FALSE, randint1(14) + 4);
+                                       one_dragon_ele_resistance(o_ptr);
                                case EGO_WEST:
                                        if (one_in_(3))
                                                o_ptr->art_flags2 |= TR2_RES_FEAR;
                                        break;
                                case EGO_CHAOTIC:
-                                       random_resistance(o_ptr, FALSE, (randint1(34) + 4));
+                                       one_resistance(o_ptr);
                                        break;
                                case EGO_SLAYING_WEAPON:
                                        if (one_in_(3)) /* double damage */
@@ -2381,9 +2381,11 @@ static void a_m_aux_1(object_type *o_ptr, int level, int power)
                                        }
                                        break;
                                case EGO_TRUMP:
-                                       random_resistance(o_ptr, FALSE, (randint1(22) + 16));
+                                       one_high_resistance(o_ptr);
                                        if (one_in_(5))
                                                o_ptr->art_flags1 |= TR1_SLAY_DEMON;
+                                       if (one_in_(7))
+                                               one_ability(o_ptr);
                                        break;
                                case EGO_PATTERN:
                                        if (one_in_(3))
@@ -2392,7 +2394,7 @@ static void a_m_aux_1(object_type *o_ptr, int level, int power)
                                                o_ptr->art_flags1 |= TR1_DEX;
                                        if (one_in_(5))
                                                o_ptr->art_flags2 |= TR2_RES_FEAR;
-                                       random_resistance(o_ptr, FALSE, (randint1(22) + 16));
+                                       one_high_resistance(o_ptr);
                                        break;
                                case EGO_SHARPNESS:
                                        o_ptr->pval = m_bonus(5, level) + 1;
@@ -2403,6 +2405,9 @@ static void a_m_aux_1(object_type *o_ptr, int level, int power)
                                        else
                                                o_ptr->pval = m_bonus(3, level);
                                        break;
+                               case EGO_BLESS_BLADE:
+                                       one_ability(o_ptr);
+                                       break;
                                }
 
                                if (!o_ptr->art_name)
@@ -2449,7 +2454,7 @@ static void a_m_aux_1(object_type *o_ptr, int level, int power)
                                switch (o_ptr->name2)
                                {
                                case EGO_EXTRA_MIGHT:
-                                       random_resistance(o_ptr, FALSE, rand_range(5, 38));
+                                       one_resistance(o_ptr);
                                        break;
                                }
                        }
@@ -2501,12 +2506,10 @@ static void dragon_resist(object_type * o_ptr)
 {
        do
        {
-               artifact_bias = 0;
-
                if (one_in_(4))
-                       random_resistance(o_ptr, FALSE, (randint1(14) + 4));
+                       one_dragon_ele_resistance(o_ptr);
                else
-                       random_resistance(o_ptr, FALSE, (randint1(22) + 16));
+                       one_high_resistance(o_ptr);
        }
        while (one_in_(2));
 }
@@ -2524,8 +2527,6 @@ static void a_m_aux_2(object_type *o_ptr, int level, int power)
 
        int toac2 = m_bonus(10, level);
 
-       artifact_bias = 0;
-
        /* Good */
        if (power > 0)
        {
@@ -2594,7 +2595,10 @@ static void a_m_aux_2(object_type *o_ptr, int level, int power)
                                                o_ptr->to_a = 0;
                                        }
                                        else
+                                       {
                                                o_ptr->name2 = EGO_PERMANENCE;
+                                               one_high_resistance(o_ptr);
+                                       }
                                        break;
                                }
 
@@ -2615,7 +2619,10 @@ static void a_m_aux_2(object_type *o_ptr, int level, int power)
                                        case EGO_RESISTANCE:
                                                if (one_in_(4))
                                                        o_ptr->art_flags2 |= TR2_RES_POIS;
-                                               random_resistance(o_ptr, FALSE, (randint1(22) + 16));
+                                               one_high_resistance(o_ptr);
+                                               break;
+                                       case EGO_ELVENKIND:
+                                               one_high_resistance(o_ptr);
                                                break;
                                        case EGO_DWARVEN:
                                                if (o_ptr->tval != TV_HARD_ARMOR)
@@ -2668,7 +2675,7 @@ static void a_m_aux_2(object_type *o_ptr, int level, int power)
                                switch (o_ptr->name2)
                                {
                                case EGO_ENDURANCE:
-                                       random_resistance(o_ptr, FALSE, (randint1(34) + 4));
+                                       if (!one_in_(3)) one_high_resistance(o_ptr);
                                        if (one_in_(4)) o_ptr->art_flags2 |= TR2_RES_POIS;
                                        break;
                                case EGO_REFLECTION:
@@ -2704,7 +2711,7 @@ static void a_m_aux_2(object_type *o_ptr, int level, int power)
                                switch (o_ptr->name2)
                                {
                                case EGO_POWER:
-                                       random_resistance(o_ptr, FALSE, (randint1(22) + 16));
+                                       one_high_resistance(o_ptr);
                                        break;
                                }
                        }
@@ -2745,7 +2752,7 @@ static void a_m_aux_2(object_type *o_ptr, int level, int power)
                                case EGO_SLOW_DESCENT:
                                        if (one_in_(2))
                                        {
-                                               random_resistance(o_ptr, FALSE, (randint1(22) + 16));
+                                               one_high_resistance(o_ptr);
                                        }
                                        break;
                                }
@@ -2777,16 +2784,17 @@ static void a_m_aux_2(object_type *o_ptr, int level, int power)
                                        switch (o_ptr->name2)
                                        {
                                        case EGO_MAGI:
-                                               random_resistance(o_ptr, FALSE, (randint1(22) + 16));
+                                               one_high_resistance(o_ptr);
+                                               one_ability(o_ptr);
                                                break;
                                        case EGO_MIGHT:
-                                               random_resistance(o_ptr, FALSE, (randint1(22) + 16));
+                                               one_high_resistance(o_ptr);
                                                break;
                                        case EGO_TELEPATHY:
                                        case EGO_REGENERATION:
                                                break;
                                        case EGO_LORDLINESS:
-                                               random_resistance(o_ptr, FALSE, (randint1(22) + 16));
+                                               one_high_resistance(o_ptr);
                                                break;
                                        case EGO_SEEING:
                                                if (one_in_(3)) o_ptr->art_flags3 |= TR3_TELEPATHY;
@@ -2876,6 +2884,9 @@ static void a_m_aux_2(object_type *o_ptr, int level, int power)
 
                                switch (o_ptr->name2)
                                {
+                               case EGO_AMAN:
+                                       one_high_resistance(o_ptr);
+                                       break;
                                case EGO_BAT:
                                        o_ptr->to_d -= 6;
                                        o_ptr->to_h -= 6;
@@ -2906,9 +2917,6 @@ static void a_m_aux_2(object_type *o_ptr, int level, int power)
  */
 static void a_m_aux_3(object_type *o_ptr, int level, int power)
 {
-
-       artifact_bias = 0;
-
        /* Apply magic (good or bad) according to type */
        switch (o_ptr->tval)
        {
@@ -3006,7 +3014,7 @@ static void a_m_aux_3(object_type *o_ptr, int level, int power)
                                {
                                        do
                                        {
-                                               random_resistance(o_ptr, FALSE, randint1(20) + 18);
+                                               one_loadly_high_resistance(o_ptr);
                                        }
                                        while (one_in_(4));
 
@@ -3329,8 +3337,8 @@ static void a_m_aux_3(object_type *o_ptr, int level, int power)
                                                        break;
                                                case SV_RING_LORDLY:
                                                        if (!one_in_(20)) break;
-                                                       random_resistance(o_ptr, FALSE, randint1(20) + 18);
-                                                       random_resistance(o_ptr, FALSE, randint1(20) + 18);
+                                                       one_loadly_high_resistance(o_ptr);
+                                                       one_loadly_high_resistance(o_ptr);
                                                        o_ptr->name2 = EGO_RING_TRUE;
                                                        break;
                                                case SV_RING_SUSTAIN:
@@ -3467,7 +3475,7 @@ static void a_m_aux_3(object_type *o_ptr, int level, int power)
 
                                case SV_AMULET_RESISTANCE:
                                {
-                                       if (one_in_(3)) random_resistance(o_ptr, FALSE, (randint1(34) + 4));
+                                       if (one_in_(5)) one_high_resistance(o_ptr);
                                        if (one_in_(5)) o_ptr->art_flags2 |= TR2_RES_POIS;
                                }
                                break;
@@ -4251,70 +4259,6 @@ void apply_magic(object_type *o_ptr, int lev, bool okay, bool good, bool great,
        {
                ego_item_type *e_ptr = &e_info[o_ptr->name2];
 
-               /* Hack -- extra powers */
-               switch (o_ptr->name2)
-               {
-                       /* Weapon (Holy Avenger) */
-                       case EGO_HA:
-                       {
-                               o_ptr->xtra1 = EGO_XTRA_SUSTAIN;
-                               break;
-                       }
-
-                       /* Weapon (Defender) */
-                       case EGO_DF:
-                       {
-                               o_ptr->xtra1 = EGO_XTRA_SUSTAIN;
-                               break;
-                       }
-
-                       /* Weapon (Blessed) */
-                       case EGO_BLESS_BLADE:
-                       {
-                               o_ptr->xtra1 = EGO_XTRA_ABILITY;
-                               break;
-                       }
-
-                       /* Trump weapon */
-                       case EGO_TRUMP:
-                       {
-                               if (one_in_(7)) o_ptr->xtra1 = EGO_XTRA_ABILITY;
-                               break;
-                       }
-
-                       /* Robe of Permanance */
-                       case EGO_PERMANENCE:
-                       {
-                               o_ptr->xtra1 = EGO_XTRA_POWER;
-                               break;
-                       }
-
-                       /* Armor of Elvenkind */
-                       case EGO_ELVENKIND:
-                       {
-                               o_ptr->xtra1 = EGO_XTRA_POWER;
-                               break;
-                       }
-
-                       /* Crown of the Magi */
-                       case EGO_MAGI:
-                       {
-                               o_ptr->xtra1 = EGO_XTRA_ABILITY;
-                               break;
-                       }
-
-                       /* Cloak of Aman */
-                       case EGO_AMAN:
-                       {
-                               o_ptr->xtra1 = EGO_XTRA_POWER;
-                               break;
-                       }
-               }
-
-               /* Randomize the "xtra" power */
-               if (o_ptr->xtra1 && !o_ptr->art_name)
-                       o_ptr->xtra2 = randint1(256);
-
                /* Hack -- acquire "broken" flag */
                if (!e_ptr->cost) o_ptr->ident |= (IDENT_BROKEN);
 
index e11f87b..defb087 100644 (file)
@@ -4713,7 +4713,7 @@ msg_print("
                        object_prep(q_ptr, lookup_kind(dummy, dummy2));
                        q_ptr->to_h = 3 + randint1(dun_level) % 10;
                        q_ptr->to_d = 3 + randint1(dun_level) % 10;
-                       random_resistance(q_ptr, FALSE, randint1(34) + 4);
+                       one_resistance(q_ptr);
                        q_ptr->name2 = EGO_CHAOTIC;
 
                        /* Drop it in the dungeon */