OSDN Git Service

Suppress gcc warning
[hengband/hengband.git] / src / artifact.c
index 8b3ed28..ad5a8bd 100644 (file)
@@ -12,6 +12,7 @@
 
 
 /* Chance of using syllables to form the name instead of the "template" files */
+#define SINDARIN_NAME   10
 #define TABLE_NAME      20
 #define A_CURSED        13
 #define WEIRD_LUCK      12
 #define ACTIVATION_CHANCE 3
 
 
-static void curse_artifact(object_type * o_ptr)
+/*
+ * Use for biased artifact creation
+ */
+static int artifact_bias;
+
+
+/*
+ * Choose one random sustain
+ */
+void one_sustain(object_type *o_ptr)
+{
+       switch (randint0(6))
+       {
+               case 0: add_flag(o_ptr->art_flags, TR_SUST_STR); break;
+               case 1: add_flag(o_ptr->art_flags, TR_SUST_INT); break;
+               case 2: add_flag(o_ptr->art_flags, TR_SUST_WIS); break;
+               case 3: add_flag(o_ptr->art_flags, TR_SUST_DEX); break;
+               case 4: add_flag(o_ptr->art_flags, TR_SUST_CON); break;
+               case 5: add_flag(o_ptr->art_flags, TR_SUST_CHR); break;
+       }
+}
+
+
+/*
+ * Choose one random high resistance
+ */
+void one_high_resistance(object_type *o_ptr)
+{
+       switch (randint0(12))
+       {
+               case  0: add_flag(o_ptr->art_flags, TR_RES_POIS);   break;
+               case  1: add_flag(o_ptr->art_flags, TR_RES_LITE);   break;
+               case  2: add_flag(o_ptr->art_flags, TR_RES_DARK);   break;
+               case  3: add_flag(o_ptr->art_flags, TR_RES_SHARDS); break;
+               case  4: add_flag(o_ptr->art_flags, TR_RES_BLIND);  break;
+               case  5: add_flag(o_ptr->art_flags, TR_RES_CONF);   break;
+               case  6: add_flag(o_ptr->art_flags, TR_RES_SOUND);  break;
+               case  7: add_flag(o_ptr->art_flags, TR_RES_NETHER); break;
+               case  8: add_flag(o_ptr->art_flags, TR_RES_NEXUS);  break;
+               case  9: add_flag(o_ptr->art_flags, TR_RES_CHAOS);  break;
+               case 10: add_flag(o_ptr->art_flags, TR_RES_DISEN);  break;
+               case 11: add_flag(o_ptr->art_flags, TR_RES_FEAR);   break;
+       }
+}
+
+
+/*
+ * Choose one random high resistance ( except poison and disenchantment )
+ */
+void one_lordly_high_resistance(object_type *o_ptr)
+{
+       switch (randint0(10))
+       {
+               case 0: add_flag(o_ptr->art_flags, TR_RES_LITE);   break;
+               case 1: add_flag(o_ptr->art_flags, TR_RES_DARK);   break;
+               case 2: add_flag(o_ptr->art_flags, TR_RES_SHARDS); break;
+               case 3: add_flag(o_ptr->art_flags, TR_RES_BLIND);  break;
+               case 4: add_flag(o_ptr->art_flags, TR_RES_CONF);   break;
+               case 5: add_flag(o_ptr->art_flags, TR_RES_SOUND);  break;
+               case 6: add_flag(o_ptr->art_flags, TR_RES_NETHER); break;
+               case 7: add_flag(o_ptr->art_flags, TR_RES_NEXUS);  break;
+               case 8: add_flag(o_ptr->art_flags, TR_RES_CHAOS);  break;
+               case 9: add_flag(o_ptr->art_flags, TR_RES_FEAR);   break;
+       }
+}
+
+
+/*
+ * Choose one random element resistance
+ */
+void one_ele_resistance(object_type *o_ptr)
+{
+       switch (randint0(4))
+       {
+               case  0: add_flag(o_ptr->art_flags, TR_RES_ACID); break;
+               case  1: add_flag(o_ptr->art_flags, TR_RES_ELEC); break;
+               case  2: add_flag(o_ptr->art_flags, TR_RES_COLD); break;
+               case  3: add_flag(o_ptr->art_flags, TR_RES_FIRE); break;
+       }
+}
+
+
+/*
+ * Choose one random element or poison resistance
+ */
+void one_dragon_ele_resistance(object_type *o_ptr)
+{
+       if (one_in_(7))
+       {
+               add_flag(o_ptr->art_flags, TR_RES_POIS);
+       }
+       else
+       {
+               one_ele_resistance(o_ptr);
+       }
+}
+
+
+/*
+ * Choose one lower rank esp
+ */
+void one_low_esp(object_type *o_ptr)
+{
+       switch (randint1(10))
+       {
+       case 1:  add_flag(o_ptr->art_flags, TR_ESP_ANIMAL);   break;
+       case 2:  add_flag(o_ptr->art_flags, TR_ESP_UNDEAD);   break;
+       case 3:  add_flag(o_ptr->art_flags, TR_ESP_DEMON);   break;
+       case 4:  add_flag(o_ptr->art_flags, TR_ESP_ORC);   break;
+       case 5:  add_flag(o_ptr->art_flags, TR_ESP_TROLL);   break;
+       case 6:  add_flag(o_ptr->art_flags, TR_ESP_GIANT);   break;
+       case 7:  add_flag(o_ptr->art_flags, TR_ESP_DRAGON);   break;
+       case 8:  add_flag(o_ptr->art_flags, TR_ESP_HUMAN);   break;
+       case 9:  add_flag(o_ptr->art_flags, TR_ESP_GOOD);   break;
+       case 10: add_flag(o_ptr->art_flags, TR_ESP_UNIQUE);   break;
+       }
+}
+
+
+
+/*
+ * 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)
 {
-       if (o_ptr->pval > 0) o_ptr->pval = 0 - (o_ptr->pval + randint(4));
-       if (o_ptr->to_a > 0) o_ptr->to_a = 0 - (o_ptr->to_a + randint(4));
-       if (o_ptr->to_h > 0) o_ptr->to_h = 0 - (o_ptr->to_h + randint(4));
-       if (o_ptr->to_d > 0) o_ptr->to_d = 0 - (o_ptr->to_d + randint(4));
+       switch (randint0(10))
+       {
+       case 0: add_flag(o_ptr->art_flags, TR_LEVITATION);     break;
+       case 1: add_flag(o_ptr->art_flags, TR_LITE);        break;
+       case 2: add_flag(o_ptr->art_flags, TR_SEE_INVIS);   break;
+       case 3: add_flag(o_ptr->art_flags, TR_WARNING);     break;
+       case 4: add_flag(o_ptr->art_flags, TR_SLOW_DIGEST); break;
+       case 5: add_flag(o_ptr->art_flags, TR_REGEN);       break;
+       case 6: add_flag(o_ptr->art_flags, TR_FREE_ACT);    break;
+       case 7: add_flag(o_ptr->art_flags, TR_HOLD_LIFE);   break;
+       case 8:
+       case 9:
+               one_low_esp(o_ptr);
+               break;
+       }
+}
 
-       o_ptr->art_flags3 |= (TR3_HEAVY_CURSE | TR3_CURSED);
+/*
+ * Choose one random activation
+ */
+void one_activation(object_type *o_ptr)
+{
+       int type = 0;
+       int chance = 0;
 
-       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;
+       while (randint1(100) >= chance)
+       {
+               type = randint1(255);
+               switch (type)
+               {
+                       case ACT_SUNLIGHT:
+                       case ACT_BO_MISS_1:
+                       case ACT_BA_POIS_1:
+                       case ACT_BO_ELEC_1:
+                       case ACT_BO_ACID_1:
+                       case ACT_BO_COLD_1:
+                       case ACT_BO_FIRE_1:
+                       case ACT_CONFUSE:
+                       case ACT_SLEEP:
+                       case ACT_QUAKE:
+                       case ACT_CURE_LW:
+                       case ACT_CURE_MW:
+                       case ACT_CURE_POISON:
+                       case ACT_BERSERK:
+                       case ACT_LIGHT:
+                       case ACT_MAP_LIGHT:
+                       case ACT_DEST_DOOR:
+                       case ACT_STONE_MUD:
+                       case ACT_TELEPORT:
+                               chance = 101;
+                               break;
+                       case ACT_BA_COLD_1:
+                       case ACT_BA_FIRE_1:
+                       case ACT_DRAIN_1:
+                       case ACT_TELE_AWAY:
+                       case ACT_ESP:
+                       case ACT_RESIST_ALL:
+                       case ACT_DETECT_ALL:
+                       case ACT_RECALL:
+                       case ACT_SATIATE:
+                       case ACT_RECHARGE:
+                               chance = 85;
+                               break;
+                       case ACT_TERROR:
+                       case ACT_PROT_EVIL:
+                       case ACT_ID_PLAIN:
+                               chance = 75;
+                               break;
+                       case ACT_DRAIN_2:
+                       case ACT_VAMPIRE_1:
+                       case ACT_BO_MISS_2:
+                       case ACT_BA_FIRE_2:
+                       case ACT_REST_LIFE:
+                               chance = 66;
+                               break;
+                       case ACT_BA_FIRE_3:
+                       case ACT_BA_COLD_3:
+                       case ACT_BA_ELEC_3:
+                       case ACT_WHIRLWIND:
+                       case ACT_VAMPIRE_2:
+                       case ACT_CHARM_ANIMAL:
+                               chance = 50;
+                               break;
+                       case ACT_SUMMON_ANIMAL:
+                               chance = 40;
+                               break;
+                       case ACT_DISP_EVIL:
+                       case ACT_BA_MISS_3:
+                       case ACT_DISP_GOOD:
+                       case ACT_BANISH_EVIL:
+                       case ACT_GENOCIDE:
+                       case ACT_MASS_GENO:
+                       case ACT_CHARM_UNDEAD:
+                       case ACT_CHARM_OTHER:
+                       case ACT_SUMMON_PHANTOM:
+                       case ACT_REST_ALL:
+                       case ACT_RUNE_EXPLO:
+                               chance = 33;
+                               break;
+                       case ACT_CALL_CHAOS:
+                       case ACT_ROCKET:
+                       case ACT_CHARM_ANIMALS:
+                       case ACT_CHARM_OTHERS:
+                       case ACT_SUMMON_ELEMENTAL:
+                       case ACT_CURE_700:
+                       case ACT_SPEED:
+                       case ACT_ID_FULL:
+                       case ACT_RUNE_PROT:
+                               chance = 25;
+                               break;
+                       case ACT_CURE_1000:
+                       case ACT_XTRA_SPEED:
+                       case ACT_DETECT_XTRA:
+                       case ACT_DIM_DOOR:
+                               chance = 10;
+                               break;
+                       case ACT_SUMMON_UNDEAD:
+                       case ACT_SUMMON_DEMON:
+                       case ACT_WRAITH:
+                       case ACT_INVULN:
+                       case ACT_ALCHEMY:
+                               chance = 5;
+                               break;
+                       default:
+                               chance = 0;
+               }
+       }
 
-       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))
-               o_ptr->art_flags3 |= TR3_NO_MAGIC;
+       /* A type was chosen... */
+       o_ptr->xtra2 = type;
+       add_flag(o_ptr->art_flags, TR_ACTIVATE);
+       o_ptr->timeout = 0;
+}
 
-       o_ptr->ident |= IDENT_CURSED;
+static void curse_artifact(object_type * o_ptr)
+{
+       if (o_ptr->pval > 0) o_ptr->pval = 0 - (o_ptr->pval + randint1(4));
+       if (o_ptr->to_a > 0) o_ptr->to_a = 0 - (o_ptr->to_a + randint1(4));
+       if (o_ptr->to_h > 0) o_ptr->to_h = 0 - (o_ptr->to_h + randint1(4));
+       if (o_ptr->to_d > 0) o_ptr->to_d = 0 - (o_ptr->to_d + randint1(4));
+
+       o_ptr->curse_flags |= (TRC_HEAVY_CURSE | TRC_CURSED);
+       remove_flag(o_ptr->art_flags, TR_BLESSED);
+
+       if (one_in_(4)) o_ptr->curse_flags |= TRC_PERMA_CURSE;
+       if (one_in_(3)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
+       if (one_in_(2)) add_flag(o_ptr->art_flags, TR_AGGRAVATE);
+       if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
+       if (one_in_(6)) add_flag(o_ptr->art_flags, TR_ADD_L_CURSE);
+       if (one_in_(9)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
+       if (one_in_(2)) add_flag(o_ptr->art_flags, TR_TELEPORT);
+       else if (one_in_(3)) add_flag(o_ptr->art_flags, TR_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))
+               add_flag(o_ptr->art_flags, TR_NO_MAGIC);
 }
 
 
-static void random_plus(object_type * o_ptr, bool is_scroll)
+static void random_plus(object_type * o_ptr)
 {
-       int this_type = (o_ptr->tval < TV_BOOTS ? 23 : 19);
+       int this_type = (object_is_weapon_ammo(o_ptr) ? 23 : 19);
 
-       if (artifact_bias == BIAS_WARRIOR)
+       switch (artifact_bias)
        {
-               if (!(o_ptr->art_flags1 & TR1_STR))
+       case BIAS_WARRIOR:
+               if (!(have_flag(o_ptr->art_flags, TR_STR)))
                {
-                       o_ptr->art_flags1 |= TR1_STR;
-                       if (randint(2) == 1) return; /* 50% chance of being a "free" power */
+                       add_flag(o_ptr->art_flags, TR_STR);
+                       if (one_in_(2)) return;
                }
 
-               if (!(o_ptr->art_flags1 & TR1_CON))
+               if (!(have_flag(o_ptr->art_flags, TR_CON)))
                {
-                       o_ptr->art_flags1 |= TR1_CON;
-                       if (randint(2) == 1) return;
+                       add_flag(o_ptr->art_flags, TR_CON);
+                       if (one_in_(2)) return;
                }
 
-               if (!(o_ptr->art_flags1 & TR1_DEX))
+               if (!(have_flag(o_ptr->art_flags, TR_DEX)))
                {
-                       o_ptr->art_flags1 |= TR1_DEX;
-                       if (randint(2) == 1) return;
+                       add_flag(o_ptr->art_flags, TR_DEX);
+                       if (one_in_(2)) return;
                }
-       }
-       else if (artifact_bias == BIAS_MAGE)
-       {
-               if (!(o_ptr->art_flags1 & TR1_INT))
+               break;
+
+       case BIAS_MAGE:
+               if (!(have_flag(o_ptr->art_flags, TR_INT)))
                {
-                       o_ptr->art_flags1 |= TR1_INT;
-                       if (randint(2) == 1) return;
+                       add_flag(o_ptr->art_flags, TR_INT);
+                       if (one_in_(2)) return;
                }
-               if ((o_ptr->tval == TV_GLOVES) && !(o_ptr->art_flags1 & TR1_MAGIC_MASTERY))
+               if ((o_ptr->tval == TV_GLOVES) && !(have_flag(o_ptr->art_flags, TR_MAGIC_MASTERY)))
                {
-                       o_ptr->art_flags1 |= TR1_MAGIC_MASTERY;
-                       if (randint(2) == 1) return;
+                       add_flag(o_ptr->art_flags, TR_MAGIC_MASTERY);
+                       if (one_in_(2)) return;
                }
-       }
-       else if (artifact_bias == BIAS_PRIESTLY)
-       {
-               if (!(o_ptr->art_flags1 & TR1_WIS))
+               break;
+
+       case BIAS_PRIESTLY:
+               if (!(have_flag(o_ptr->art_flags, TR_WIS)))
                {
-                       o_ptr->art_flags1 |= TR1_WIS;
-                       if (randint(2) == 1) return;
+                       add_flag(o_ptr->art_flags, TR_WIS);
+                       if (one_in_(2)) return;
                }
-       }
-       else if (artifact_bias == BIAS_RANGER)
-       {
-               if (!(o_ptr->art_flags1 & TR1_DEX))
+               break;
+
+       case BIAS_RANGER:
+               if (!(have_flag(o_ptr->art_flags, TR_DEX)))
                {
-                       o_ptr->art_flags1 |= TR1_DEX;
-                       if (randint(2) == 1) return;
+                       add_flag(o_ptr->art_flags, TR_DEX);
+                       if (one_in_(2)) return;
                }
 
-               if (!(o_ptr->art_flags1 & TR1_CON))
+               if (!(have_flag(o_ptr->art_flags, TR_CON)))
                {
-                       o_ptr->art_flags1 |= TR1_CON;
-                       if (randint(2) == 1) return; /* 50% chance of being a "free" power */
+                       add_flag(o_ptr->art_flags, TR_CON);
+                       if (one_in_(2)) return;
                }
 
-               if (!(o_ptr->art_flags1 & TR1_STR))
+               if (!(have_flag(o_ptr->art_flags, TR_STR)))
                {
-                       o_ptr->art_flags1 |= TR1_STR;
-                       if (randint(2) == 1) return;
+                       add_flag(o_ptr->art_flags, TR_STR);
+                       if (one_in_(2)) return;
                }
-       }
-       else if (artifact_bias == BIAS_ROGUE)
-       {
-               if (!(o_ptr->art_flags1 & TR1_STEALTH))
+               break;
+
+       case BIAS_ROGUE:
+               if (!(have_flag(o_ptr->art_flags, TR_STEALTH)))
                {
-                       o_ptr->art_flags1 |= TR1_STEALTH;
-                       if (randint(2) == 1) return;
+                       add_flag(o_ptr->art_flags, TR_STEALTH);
+                       if (one_in_(2)) return;
                }
-               if (!(o_ptr->art_flags1 & TR1_SEARCH))
+               if (!(have_flag(o_ptr->art_flags, TR_SEARCH)))
                {
-                       o_ptr->art_flags1 |= TR1_SEARCH;
-                       if (randint(2) == 1) return;
+                       add_flag(o_ptr->art_flags, TR_SEARCH);
+                       if (one_in_(2)) return;
                }
-       }
-       else if (artifact_bias == BIAS_STR)
-       {
-               if (!(o_ptr->art_flags1 & TR1_STR))
+               break;
+
+       case BIAS_STR:
+               if (!(have_flag(o_ptr->art_flags, TR_STR)))
                {
-                       o_ptr->art_flags1 |= TR1_STR;
-                       if (randint(2) == 1) return;
+                       add_flag(o_ptr->art_flags, TR_STR);
+                       if (one_in_(2)) return;
                }
-       }
-       else if (artifact_bias == BIAS_WIS)
-       {
-               if (!(o_ptr->art_flags1 & TR1_WIS))
+               break;
+
+       case BIAS_WIS:
+               if (!(have_flag(o_ptr->art_flags, TR_WIS)))
                {
-                       o_ptr->art_flags1 |= TR1_WIS;
-                       if (randint(2) == 1) return;
+                       add_flag(o_ptr->art_flags, TR_WIS);
+                       if (one_in_(2)) return;
                }
-       }
-       else if (artifact_bias == BIAS_INT)
-       {
-               if (!(o_ptr->art_flags1 & TR1_INT))
+               break;
+
+       case BIAS_INT:
+               if (!(have_flag(o_ptr->art_flags, TR_INT)))
                {
-                       o_ptr->art_flags1 |= TR1_INT;
-                       if (randint(2) == 1) return;
+                       add_flag(o_ptr->art_flags, TR_INT);
+                       if (one_in_(2)) return;
                }
-       }
-       else if (artifact_bias == BIAS_DEX)
-       {
-               if (!(o_ptr->art_flags1 & TR1_DEX))
+               break;
+
+       case BIAS_DEX:
+               if (!(have_flag(o_ptr->art_flags, TR_DEX)))
                {
-                       o_ptr->art_flags1 |= TR1_DEX;
-                       if (randint(2) == 1) return;
+                       add_flag(o_ptr->art_flags, TR_DEX);
+                       if (one_in_(2)) return;
                }
-       }
-       else if (artifact_bias == BIAS_CON)
-       {
-               if (!(o_ptr->art_flags1 & TR1_CON))
+               break;
+
+       case BIAS_CON:
+               if (!(have_flag(o_ptr->art_flags, TR_CON)))
                {
-                       o_ptr->art_flags1 |= TR1_CON;
-                       if (randint(2) == 1) return;
+                       add_flag(o_ptr->art_flags, TR_CON);
+                       if (one_in_(2)) return;
                }
-       }
-       else if (artifact_bias == BIAS_CHR)
-       {
-               if (!(o_ptr->art_flags1 & TR1_CHR))
+               break;
+
+       case BIAS_CHR:
+               if (!(have_flag(o_ptr->art_flags, TR_CHR)))
                {
-                       o_ptr->art_flags1 |= TR1_CHR;
-                       if (randint(2) == 1) return;
+                       add_flag(o_ptr->art_flags, TR_CHR);
+                       if (one_in_(2)) return;
                }
+               break;
        }
 
        if ((artifact_bias == BIAS_MAGE || artifact_bias == BIAS_PRIESTLY) && (o_ptr->tval == TV_SOFT_ARMOR) && (o_ptr->sval == SV_ROBE))
        {
-               if (!(o_ptr->art_flags3 & TR3_DEC_MANA) && one_in_(3))
+               if (!(have_flag(o_ptr->art_flags, TR_DEC_MANA)) && one_in_(3))
                {
-                       o_ptr->art_flags3 |= TR3_DEC_MANA;
-                       if (randint(2) == 1) return;
+                       add_flag(o_ptr->art_flags, TR_DEC_MANA);
+                       if (one_in_(2)) return;
                }
        }
 
-       switch (randint(this_type))
+       switch (randint1(this_type))
        {
        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)
+               add_flag(o_ptr->art_flags, TR_STR);
+               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)
+               add_flag(o_ptr->art_flags, TR_INT);
+               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)
+               add_flag(o_ptr->art_flags, TR_WIS);
+               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)
+               add_flag(o_ptr->art_flags, TR_DEX);
+               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)
+               add_flag(o_ptr->art_flags, TR_CON);
+               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)
+               add_flag(o_ptr->art_flags, TR_CHR);
+               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)
+               add_flag(o_ptr->art_flags, TR_STEALTH);
+               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)
+               add_flag(o_ptr->art_flags, TR_SEARCH);
+               if (!artifact_bias && one_in_(9))
                        artifact_bias = BIAS_RANGER;
                break;
        case 17: case 18:
-               o_ptr->art_flags1 |= TR1_INFRA;
-               /*  if (is_scroll) msg_print("It makes you see tiny red animals.");*/
+               add_flag(o_ptr->art_flags, TR_INFRA);
                break;
        case 19:
-               o_ptr->art_flags1 |= TR1_SPEED;
-               /*  if (is_scroll) msg_print("It makes you move faster!"); */
-               if (!artifact_bias && randint(11) == 1)
+               add_flag(o_ptr->art_flags, TR_SPEED);
+               if (!artifact_bias && one_in_(11))
                        artifact_bias = BIAS_ROGUE;
                break;
        case 20: case 21:
-               o_ptr->art_flags1 |= TR1_TUNNEL;
-               /*  if (is_scroll) msg_print("Gravel flies from it!"); */
+               add_flag(o_ptr->art_flags, TR_TUNNEL);
                break;
        case 22: case 23:
-               if (o_ptr->tval == TV_BOW) random_plus(o_ptr, is_scroll);
+               if (o_ptr->tval == TV_BOW) random_plus(o_ptr);
                else
                {
-                       o_ptr->art_flags1 |= TR1_BLOWS;
-                       /*  if (is_scroll) msg_print("It seems faster!"); */
-                       if (!artifact_bias && randint(11) == 1)
+                       add_flag(o_ptr->art_flags, TR_BLOWS);
+                       if (!artifact_bias && one_in_(11))
                                artifact_bias = BIAS_WARRIOR;
                }
                break;
@@ -272,188 +539,204 @@ 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)
 {
-       if (!specific) /* To avoid a number of possible bugs */
+       switch (artifact_bias)
        {
-               if (artifact_bias == BIAS_ACID)
+       case BIAS_ACID:
+               if (!(have_flag(o_ptr->art_flags, TR_RES_ACID)))
                {
-                       if (!(o_ptr->art_flags2 & TR2_RES_ACID))
-                       {
-                               o_ptr->art_flags2 |= TR2_RES_ACID;
-                               if (randint(2) == 1) return;
-                       }
-                       if ((randint(BIAS_LUCK) == 1) && !(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;
-                       }
+                       add_flag(o_ptr->art_flags, TR_RES_ACID);
+                       if (one_in_(2)) return;
                }
-               else if (artifact_bias == BIAS_ELEC)
+               if (one_in_(BIAS_LUCK) && !(have_flag(o_ptr->art_flags, TR_IM_ACID)))
                {
-                       if (!(o_ptr->art_flags2 & TR2_RES_ELEC))
-                       {
-                               o_ptr->art_flags2 |= TR2_RES_ELEC;
-                               if (randint(2) == 1) 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 (randint(BIAS_LUCK) == 1 && !(o_ptr->art_flags2 & TR2_IM_ELEC))
+                       add_flag(o_ptr->art_flags, TR_IM_ACID);
+                       if (!one_in_(IM_LUCK))
                        {
-                               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;
+                               remove_flag(o_ptr->art_flags, TR_IM_ELEC);
+                               remove_flag(o_ptr->art_flags, TR_IM_COLD);
+                               remove_flag(o_ptr->art_flags, TR_IM_FIRE);
                        }
+                       if (one_in_(2)) return;
                }
-               else if (artifact_bias == BIAS_FIRE)
+               break;
+
+       case BIAS_ELEC:
+               if (!(have_flag(o_ptr->art_flags, TR_RES_ELEC)))
                {
-                       if (!(o_ptr->art_flags2 & TR2_RES_FIRE))
-                       {
-                               o_ptr->art_flags2 |= TR2_RES_FIRE;
-                               if (randint(2) == 1) 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 ((randint(BIAS_LUCK) == 1) &&
-                           !(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;
-                       }
+                       add_flag(o_ptr->art_flags, TR_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) &&
+                   !(have_flag(o_ptr->art_flags, TR_SH_ELEC)))
                {
-                       if (!(o_ptr->art_flags2 & TR2_RES_COLD))
-                       {
-                               o_ptr->art_flags2 |= TR2_RES_COLD;
-                               if (randint(2) == 1) 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 (randint(BIAS_LUCK) == 1 && !(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;
-                       }
+                       add_flag(o_ptr->art_flags, TR_SH_ELEC);
+                       if (one_in_(2)) return;
                }
-               else if (artifact_bias == BIAS_POIS)
+               if (one_in_(BIAS_LUCK) && !(have_flag(o_ptr->art_flags, TR_IM_ELEC)))
                {
-                       if (!(o_ptr->art_flags2 & TR2_RES_POIS))
+                       add_flag(o_ptr->art_flags, TR_IM_ELEC);
+                       if (!one_in_(IM_LUCK))
                        {
-                               o_ptr->art_flags2 |= TR2_RES_POIS;
-                               if (randint(2) == 1) return;
+                               remove_flag(o_ptr->art_flags, TR_IM_ACID);
+                               remove_flag(o_ptr->art_flags, TR_IM_COLD);
+                               remove_flag(o_ptr->art_flags, TR_IM_FIRE);
                        }
+
+                       if (one_in_(2)) return;
+               }
+               break;
+
+       case BIAS_FIRE:
+               if (!(have_flag(o_ptr->art_flags, TR_RES_FIRE)))
+               {
+                       add_flag(o_ptr->art_flags, TR_RES_FIRE);
+                       if (one_in_(2)) return;
                }
-               else if (artifact_bias == BIAS_WARRIOR)
+               if ((o_ptr->tval >= TV_CLOAK) &&
+                   (o_ptr->tval <= TV_HARD_ARMOR) &&
+                   !(have_flag(o_ptr->art_flags, TR_SH_FIRE)))
                {
-                       if (randint(3) != 1 && (!(o_ptr->art_flags2 & TR2_RES_FEAR)))
-                       {
-                               o_ptr->art_flags2 |= TR2_RES_FEAR;
-                               if (randint(2) == 1) return;
-                       }
-                       if ((randint(3) == 1) && (!(o_ptr->art_flags3 & TR3_NO_MAGIC)))
-                       {
-                               o_ptr->art_flags3 |= TR3_NO_MAGIC;
-                               if (randint(2) == 1) return;
-                       }
+                       add_flag(o_ptr->art_flags, TR_SH_FIRE);
+                       if (one_in_(2)) return;
                }
-               else if (artifact_bias == BIAS_NECROMANTIC)
+               if (one_in_(BIAS_LUCK) &&
+                   !(have_flag(o_ptr->art_flags, TR_IM_FIRE)))
                {
-                       if (!(o_ptr->art_flags2 & TR2_RES_NETHER))
-                       {
-                               o_ptr->art_flags2 |= TR2_RES_NETHER;
-                               if (randint(2) == 1) return;
-                       }
-                       if (!(o_ptr->art_flags2 & TR2_RES_POIS))
+                       add_flag(o_ptr->art_flags, TR_IM_FIRE);
+                       if (!one_in_(IM_LUCK))
                        {
-                               o_ptr->art_flags2 |= TR2_RES_POIS;
-                               if (randint(2) == 1) return;
-                       }
-                       if (!(o_ptr->art_flags2 & TR2_RES_DARK))
-                       {
-                               o_ptr->art_flags2 |= TR2_RES_DARK;
-                               if (randint(2) == 1) return;
+                               remove_flag(o_ptr->art_flags, TR_IM_ELEC);
+                               remove_flag(o_ptr->art_flags, TR_IM_COLD);
+                               remove_flag(o_ptr->art_flags, TR_IM_ACID);
                        }
+                       if (one_in_(2)) return;
                }
-               else if (artifact_bias == BIAS_CHAOS)
+               break;
+
+       case BIAS_COLD:
+               if (!(have_flag(o_ptr->art_flags, TR_RES_COLD)))
                {
-                       if (!(o_ptr->art_flags2 & TR2_RES_CHAOS))
-                       {
-                               o_ptr->art_flags2 |= TR2_RES_CHAOS;
-                               if (randint(2) == 1) return;
-                       }
-                       if (!(o_ptr->art_flags2 & TR2_RES_CONF))
-                       {
-                               o_ptr->art_flags2 |= TR2_RES_CONF;
-                               if (randint(2) == 1) return;
-                       }
-                       if (!(o_ptr->art_flags2 & TR2_RES_DISEN))
+                       add_flag(o_ptr->art_flags, TR_RES_COLD);
+                       if (one_in_(2)) return;
+               }
+               if ((o_ptr->tval >= TV_CLOAK) &&
+                   (o_ptr->tval <= TV_HARD_ARMOR) &&
+                   !(have_flag(o_ptr->art_flags, TR_SH_COLD)))
+               {
+                       add_flag(o_ptr->art_flags, TR_SH_COLD);
+                       if (one_in_(2)) return;
+               }
+               if (one_in_(BIAS_LUCK) && !(have_flag(o_ptr->art_flags, TR_IM_COLD)))
+               {
+                       add_flag(o_ptr->art_flags, TR_IM_COLD);
+                       if (!one_in_(IM_LUCK))
                        {
-                               o_ptr->art_flags2 |= TR2_RES_DISEN;
-                               if (randint(2) == 1) return;
+                               remove_flag(o_ptr->art_flags, TR_IM_ELEC);
+                               remove_flag(o_ptr->art_flags, TR_IM_ACID);
+                               remove_flag(o_ptr->art_flags, TR_IM_FIRE);
                        }
+                       if (one_in_(2)) return;
+               }
+               break;
+
+       case BIAS_POIS:
+               if (!(have_flag(o_ptr->art_flags, TR_RES_POIS)))
+               {
+                       add_flag(o_ptr->art_flags, TR_RES_POIS);
+                       if (one_in_(2)) return;
+               }
+               break;
+
+       case BIAS_WARRIOR:
+               if (!one_in_(3) && (!(have_flag(o_ptr->art_flags, TR_RES_FEAR))))
+               {
+                       add_flag(o_ptr->art_flags, TR_RES_FEAR);
+                       if (one_in_(2)) return;
+               }
+               if (one_in_(3) && (!(have_flag(o_ptr->art_flags, TR_NO_MAGIC))))
+               {
+                       add_flag(o_ptr->art_flags, TR_NO_MAGIC);
+                       if (one_in_(2)) return;
+               }
+               break;
+
+       case BIAS_NECROMANTIC:
+               if (!(have_flag(o_ptr->art_flags, TR_RES_NETHER)))
+               {
+                       add_flag(o_ptr->art_flags, TR_RES_NETHER);
+                       if (one_in_(2)) return;
+               }
+               if (!(have_flag(o_ptr->art_flags, TR_RES_POIS)))
+               {
+                       add_flag(o_ptr->art_flags, TR_RES_POIS);
+                       if (one_in_(2)) return;
+               }
+               if (!(have_flag(o_ptr->art_flags, TR_RES_DARK)))
+               {
+                       add_flag(o_ptr->art_flags, TR_RES_DARK);
+                       if (one_in_(2)) return;
+               }
+               break;
+
+       case BIAS_CHAOS:
+               if (!(have_flag(o_ptr->art_flags, TR_RES_CHAOS)))
+               {
+                       add_flag(o_ptr->art_flags, TR_RES_CHAOS);
+                       if (one_in_(2)) return;
+               }
+               if (!(have_flag(o_ptr->art_flags, TR_RES_CONF)))
+               {
+                       add_flag(o_ptr->art_flags, TR_RES_CONF);
+                       if (one_in_(2)) return;
                }
+               if (!(have_flag(o_ptr->art_flags, TR_RES_DISEN)))
+               {
+                       add_flag(o_ptr->art_flags, TR_RES_DISEN);
+                       if (one_in_(2)) return;
+               }
+               break;
        }
 
-       switch (specific ? specific : randint(42))
+       switch (randint1(42))
        {
                case 1:
-                       if (randint(WEIRD_LUCK) != 1)
-                               random_resistance(o_ptr, is_scroll, specific);
+                       if (!one_in_(WEIRD_LUCK))
+                               random_resistance(o_ptr);
                        else
                        {
-                               o_ptr->art_flags2 |= TR2_IM_ACID;
-                               /*  if (is_scroll) msg_print("It looks totally incorruptible."); */
+                               add_flag(o_ptr->art_flags, TR_IM_ACID);
                                if (!artifact_bias)
                                        artifact_bias = BIAS_ACID;
                        }
                        break;
                case 2:
-                       if (randint(WEIRD_LUCK) != 1)
-                               random_resistance(o_ptr, is_scroll, specific);
+                       if (!one_in_(WEIRD_LUCK))
+                               random_resistance(o_ptr);
                        else
                        {
-                               o_ptr->art_flags2 |= TR2_IM_ELEC;
-                               /*  if (is_scroll) msg_print("It looks completely grounded."); */
+                               add_flag(o_ptr->art_flags, TR_IM_ELEC);
                                if (!artifact_bias)
                                        artifact_bias = BIAS_ELEC;
                        }
                        break;
                case 3:
-                       if (randint(WEIRD_LUCK) != 1)
-                               random_resistance(o_ptr, is_scroll, specific);
+                       if (!one_in_(WEIRD_LUCK))
+                               random_resistance(o_ptr);
                        else
                        {
-                               o_ptr->art_flags2 |= TR2_IM_COLD;
-                               /*  if (is_scroll) msg_print("It feels very warm."); */
+                               add_flag(o_ptr->art_flags, TR_IM_COLD);
                                if (!artifact_bias)
                                        artifact_bias = BIAS_COLD;
                        }
                        break;
                case 4:
-                       if (randint(WEIRD_LUCK) != 1)
-                               random_resistance(o_ptr, is_scroll, specific);
+                       if (!one_in_(WEIRD_LUCK))
+                               random_resistance(o_ptr);
                        else
                        {
-                               o_ptr->art_flags2 |= TR2_IM_FIRE;
-                               /*  if (is_scroll) msg_print("It feels very cool."); */
+                               add_flag(o_ptr->art_flags, TR_IM_FIRE);
                                if (!artifact_bias)
                                        artifact_bias = BIAS_FIRE;
                        }
@@ -461,135 +744,119 @@ void random_resistance(object_type * o_ptr, bool is_scroll, int specific)
                case 5:
                case 6:
                case 13:
-                       o_ptr->art_flags2 |= TR2_RES_ACID;
-                       /*  if (is_scroll) msg_print("It makes your stomach rumble."); */
+                       add_flag(o_ptr->art_flags, TR_RES_ACID);
                        if (!artifact_bias)
                                artifact_bias = BIAS_ACID;
                        break;
                case 7:
                case 8:
                case 14:
-                       o_ptr->art_flags2 |= TR2_RES_ELEC;
-                       /*  if (is_scroll) msg_print("It makes you feel grounded."); */
+                       add_flag(o_ptr->art_flags, TR_RES_ELEC);
                        if (!artifact_bias)
                                artifact_bias = BIAS_ELEC;
                        break;
                case 9:
                case 10:
                case 15:
-                       o_ptr->art_flags2 |= TR2_RES_FIRE;
-                       /*  if (is_scroll) msg_print("It makes you feel cool!");*/
+                       add_flag(o_ptr->art_flags, TR_RES_FIRE);
                        if (!artifact_bias)
                                artifact_bias = BIAS_FIRE;
                        break;
                case 11:
                case 12:
                case 16:
-                       o_ptr->art_flags2 |= TR2_RES_COLD;
-                       /*  if (is_scroll) msg_print("It makes you feel full of hot air!");*/
+                       add_flag(o_ptr->art_flags, TR_RES_COLD);
                        if (!artifact_bias)
                                artifact_bias = BIAS_COLD;
                        break;
                case 17:
                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)
+                       add_flag(o_ptr->art_flags, TR_RES_POIS);
+                       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)
+                       add_flag(o_ptr->art_flags, TR_RES_FEAR);
+                       if (!artifact_bias && one_in_(3))
                                artifact_bias = BIAS_WARRIOR;
                        break;
                case 21:
-                       o_ptr->art_flags2 |= TR2_RES_LITE;
-                       /*  if (is_scroll) msg_print("It makes everything look darker.");*/
+                       add_flag(o_ptr->art_flags, TR_RES_LITE);
                        break;
                case 22:
-                       o_ptr->art_flags2 |= TR2_RES_DARK;
-                       /*  if (is_scroll) msg_print("It makes everything look brighter.");*/
+                       add_flag(o_ptr->art_flags, TR_RES_DARK);
                        break;
                case 23:
                case 24:
-                       o_ptr->art_flags2 |= TR2_RES_BLIND;
-                       /*  if (is_scroll) msg_print("It makes you feel you are wearing glasses.");*/
+                       add_flag(o_ptr->art_flags, TR_RES_BLIND);
                        break;
                case 25:
                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)
+                       add_flag(o_ptr->art_flags, TR_RES_CONF);
+                       if (!artifact_bias && one_in_(6))
                                artifact_bias = BIAS_CHAOS;
                        break;
                case 27:
                case 28:
-                       o_ptr->art_flags2 |= TR2_RES_SOUND;
-                       /*  if (is_scroll) msg_print("It makes you feel deaf!");*/
+                       add_flag(o_ptr->art_flags, TR_RES_SOUND);
                        break;
                case 29:
                case 30:
-                       o_ptr->art_flags2 |= TR2_RES_SHARDS;
-                       /*  if (is_scroll) msg_print("It makes your skin feel thicker.");*/
+                       add_flag(o_ptr->art_flags, TR_RES_SHARDS);
                        break;
                case 31:
                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)
+                       add_flag(o_ptr->art_flags, TR_RES_NETHER);
+                       if (!artifact_bias && one_in_(3))
                                artifact_bias = BIAS_NECROMANTIC;
                        break;
                case 33:
                case 34:
-                       o_ptr->art_flags2 |= TR2_RES_NEXUS;
-                       /*  if (is_scroll) msg_print("It makes you feel normal.");*/
+                       add_flag(o_ptr->art_flags, TR_RES_NEXUS);
                        break;
                case 35:
                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)
+                       add_flag(o_ptr->art_flags, TR_RES_CHAOS);
+                       if (!artifact_bias && one_in_(2))
                                artifact_bias = BIAS_CHAOS;
                        break;
                case 37:
                case 38:
-                       o_ptr->art_flags2 |= TR2_RES_DISEN;
-                       /*  if (is_scroll) msg_print("It is surrounded by a static feeling.");*/
+                       add_flag(o_ptr->art_flags, TR_RES_DISEN);
                        break;
                case 39:
                        if (o_ptr->tval >= TV_CLOAK && o_ptr->tval <= TV_HARD_ARMOR)
-                               o_ptr->art_flags3 |= TR3_SH_ELEC;
+                               add_flag(o_ptr->art_flags, TR_SH_ELEC);
                        else
-                               random_resistance(o_ptr, is_scroll, specific);
+                               random_resistance(o_ptr);
                        if (!artifact_bias)
                                artifact_bias = BIAS_ELEC;
                        break;
                case 40:
                        if (o_ptr->tval >= TV_CLOAK && o_ptr->tval <= TV_HARD_ARMOR)
-                               o_ptr->art_flags3 |= TR3_SH_FIRE;
+                               add_flag(o_ptr->art_flags, TR_SH_FIRE);
                        else
-                               random_resistance(o_ptr, is_scroll, specific);
+                               random_resistance(o_ptr);
                        if (!artifact_bias)
                                artifact_bias = BIAS_FIRE;
                        break;
                case 41:
                        if (o_ptr->tval == TV_SHIELD || o_ptr->tval == TV_CLOAK ||
                            o_ptr->tval == TV_HELM || o_ptr->tval == TV_HARD_ARMOR)
-                               o_ptr->art_flags2 |= TR2_REFLECT;
+                               add_flag(o_ptr->art_flags, TR_REFLECT);
                        else
-                               random_resistance(o_ptr, is_scroll, specific);
+                               random_resistance(o_ptr);
                        break;
                case 42:
                        if (o_ptr->tval >= TV_CLOAK && o_ptr->tval <= TV_HARD_ARMOR)
-                               o_ptr->art_flags3 |= TR3_SH_COLD;
+                               add_flag(o_ptr->art_flags, TR_SH_COLD);
                        else
-                               random_resistance(o_ptr, is_scroll, specific);
+                               random_resistance(o_ptr);
                        if (!artifact_bias)
                                artifact_bias = BIAS_COLD;
                        break;
@@ -598,177 +865,158 @@ void random_resistance(object_type * o_ptr, bool is_scroll, int specific)
 
 
 
-static void random_misc(object_type * o_ptr, bool is_scroll)
+static void random_misc(object_type * o_ptr)
 {
-       if (artifact_bias == BIAS_RANGER)
+       switch (artifact_bias)
        {
-               if (!(o_ptr->art_flags2 & TR2_SUST_CON))
+       case BIAS_RANGER:
+               if (!(have_flag(o_ptr->art_flags, TR_SUST_CON)))
                {
-                       o_ptr->art_flags2 |= TR2_SUST_CON;
-                       if (randint(2) == 1) return;
+                       add_flag(o_ptr->art_flags, TR_SUST_CON);
+                       if (one_in_(2)) return;
                }
-       }
-       else if (artifact_bias == BIAS_STR)
-       {
-               if (!(o_ptr->art_flags2 & TR2_SUST_STR))
+               break;
+
+       case BIAS_STR:
+               if (!(have_flag(o_ptr->art_flags, TR_SUST_STR)))
                {
-                       o_ptr->art_flags2 |= TR2_SUST_STR;
-                       if (randint(2) == 1) return;
+                       add_flag(o_ptr->art_flags, TR_SUST_STR);
+                       if (one_in_(2)) return;
                }
-       }
-       else if (artifact_bias == BIAS_WIS)
-       {
-               if (!(o_ptr->art_flags2 & TR2_SUST_WIS))
+               break;
+
+       case BIAS_WIS:
+               if (!(have_flag(o_ptr->art_flags, TR_SUST_WIS)))
                {
-                       o_ptr->art_flags2 |= TR2_SUST_WIS;
-                       if (randint(2) == 1) return;
+                       add_flag(o_ptr->art_flags, TR_SUST_WIS);
+                       if (one_in_(2)) return;
                }
-       }
-       else if (artifact_bias == BIAS_INT)
-       {
-               if (!(o_ptr->art_flags2 & TR2_SUST_INT))
+               break;
+
+       case BIAS_INT:
+               if (!(have_flag(o_ptr->art_flags, TR_SUST_INT)))
                {
-                       o_ptr->art_flags2 |= TR2_SUST_INT;
-                       if (randint(2) == 1) return;
+                       add_flag(o_ptr->art_flags, TR_SUST_INT);
+                       if (one_in_(2)) return;
                }
-       }
-       else if (artifact_bias == BIAS_DEX)
-       {
-               if (!(o_ptr->art_flags2 & TR2_SUST_DEX))
+               break;
+
+       case BIAS_DEX:
+               if (!(have_flag(o_ptr->art_flags, TR_SUST_DEX)))
                {
-                       o_ptr->art_flags2 |= TR2_SUST_DEX;
-                       if (randint(2) == 1) return;
+                       add_flag(o_ptr->art_flags, TR_SUST_DEX);
+                       if (one_in_(2)) return;
                }
-       }
-       else if (artifact_bias == BIAS_CON)
-       {
-               if (!(o_ptr->art_flags2 & TR2_SUST_CON))
+               break;
+
+       case BIAS_CON:
+               if (!(have_flag(o_ptr->art_flags, TR_SUST_CON)))
                {
-                       o_ptr->art_flags2 |= TR2_SUST_CON;
-                       if (randint(2) == 1) return;
+                       add_flag(o_ptr->art_flags, TR_SUST_CON);
+                       if (one_in_(2)) return;
                }
-       }
-       else if (artifact_bias == BIAS_CHR)
-       {
-               if (!(o_ptr->art_flags2 & TR2_SUST_CHR))
+               break;
+
+       case BIAS_CHR:
+               if (!(have_flag(o_ptr->art_flags, TR_SUST_CHR)))
                {
-                       o_ptr->art_flags2 |= TR2_SUST_CHR;
-                       if (randint(2) == 1) return;
+                       add_flag(o_ptr->art_flags, TR_SUST_CHR);
+                       if (one_in_(2)) return;
                }
-       }
-       else if (artifact_bias == BIAS_CHAOS)
-       {
-               if (!(o_ptr->art_flags3 & TR3_TELEPORT))
+               break;
+
+       case BIAS_CHAOS:
+               if (!(have_flag(o_ptr->art_flags, TR_TELEPORT)))
                {
-                       o_ptr->art_flags3 |= TR3_TELEPORT;
-                       if (randint(2) == 1) return;
+                       add_flag(o_ptr->art_flags, TR_TELEPORT);
+                       if (one_in_(2)) return;
                }
-       }
-       else if (artifact_bias == BIAS_FIRE)
-       {
-               if (!(o_ptr->art_flags3 & TR3_LITE))
+               break;
+
+       case BIAS_FIRE:
+               if (!(have_flag(o_ptr->art_flags, TR_LITE)))
                {
-                       o_ptr->art_flags3 |= TR3_LITE; /* Freebie */
+                       add_flag(o_ptr->art_flags, TR_LITE); /* Freebie */
                }
+               break;
        }
 
-       switch (randint(31))
+       switch (randint1(33))
        {
                case 1:
-                       o_ptr->art_flags2 |= TR2_SUST_STR;
-                       /*  if (is_scroll) msg_print("It makes you feel you cannot become weaker."); */
+                       add_flag(o_ptr->art_flags, TR_SUST_STR);
                        if (!artifact_bias)
                                artifact_bias = BIAS_STR;
                        break;
                case 2:
-                       o_ptr->art_flags2 |= TR2_SUST_INT;
-                       /*  if (is_scroll) msg_print("It makes you feel you cannot become more stupid.");*/
+                       add_flag(o_ptr->art_flags, TR_SUST_INT);
                        if (!artifact_bias)
                                artifact_bias = BIAS_INT;
                        break;
                case 3:
-                       o_ptr->art_flags2 |= TR2_SUST_WIS;
-                       /*  if (is_scroll) msg_print("It makes you feel you cannot become simpler.");*/
+                       add_flag(o_ptr->art_flags, TR_SUST_WIS);
                        if (!artifact_bias)
                                artifact_bias = BIAS_WIS;
                        break;
                case 4:
-                       o_ptr->art_flags2 |= TR2_SUST_DEX;
-                       /*  if (is_scroll) msg_print("It makes you feel you cannot become clumsier.");*/
+                       add_flag(o_ptr->art_flags, TR_SUST_DEX);
                        if (!artifact_bias)
                                artifact_bias = BIAS_DEX;
                        break;
                case 5:
-                       o_ptr->art_flags2 |= TR2_SUST_CON;
-                       /*  if (is_scroll) msg_print("It makes you feel you cannot become less healthy.");*/
+                       add_flag(o_ptr->art_flags, TR_SUST_CON);
                        if (!artifact_bias)
                                artifact_bias = BIAS_CON;
                        break;
                case 6:
-                       o_ptr->art_flags2 |= TR2_SUST_CHR;
-                       /*  if (is_scroll) msg_print("It makes you feel you cannot become uglier.");*/
+                       add_flag(o_ptr->art_flags, TR_SUST_CHR);
                        if (!artifact_bias)
                                artifact_bias = BIAS_CHR;
                        break;
                case 7:
                case 8:
                case 14:
-                       o_ptr->art_flags2 |= TR2_FREE_ACT;
-                       /*  if (is_scroll) msg_print("It makes you feel like a young rebel!");*/
+                       add_flag(o_ptr->art_flags, TR_FREE_ACT);
                        break;
                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))
+                       add_flag(o_ptr->art_flags, TR_HOLD_LIFE);
+                       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:
                case 11:
-                       o_ptr->art_flags3 |= TR3_LITE;
-                       /*  if (is_scroll) msg_print("It starts shining.");*/
+                       add_flag(o_ptr->art_flags, TR_LITE);
                        break;
                case 12:
                case 13:
-                       o_ptr->art_flags3 |= TR3_FEATHER;
-                       /*  if (is_scroll) msg_print("It feels lighter.");*/
+                       add_flag(o_ptr->art_flags, TR_LEVITATION);
                        break;
                case 15:
                case 16:
                case 17:
-                       o_ptr->art_flags3 |= TR3_SEE_INVIS;
-                       /*  if (is_scroll) msg_print("It makes you see the air!");*/
-                       break;
-               case 18:
-                       if (randint(3) == 1) 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))
-                               artifact_bias = BIAS_MAGE;
+                       add_flag(o_ptr->art_flags, TR_SEE_INVIS);
                        break;
                case 19:
                case 20:
-                       o_ptr->art_flags3 |= TR3_SLOW_DIGEST;
-                       /*  if (is_scroll) msg_print("It makes you feel less hungry.");*/
+                       add_flag(o_ptr->art_flags, TR_SLOW_DIGEST);
                        break;
                case 21:
                case 22:
-                       o_ptr->art_flags3 |= TR3_REGEN;
-                       /*  if (is_scroll) msg_print("It looks as good as new.");*/
+                       add_flag(o_ptr->art_flags, TR_REGEN);
                        break;
                case 23:
-                       o_ptr->art_flags3 |= TR3_TELEPORT;
-                       /*  if (is_scroll) msg_print("Its position feels uncertain!");*/
+                       add_flag(o_ptr->art_flags, TR_TELEPORT);
                        break;
                case 24:
                case 25:
                case 26:
-                       if (o_ptr->tval >= TV_BOOTS && o_ptr->tval <= TV_DRAG_ARMOR)
-                               random_misc(o_ptr, is_scroll);
+                       if (object_is_armour(o_ptr))
+                               random_misc(o_ptr);
                        else
                        {
-                               o_ptr->to_a = 4 + randint(11);
+                               o_ptr->to_a = 4 + randint1(11);
                        }
                        break;
                case 27:
@@ -776,9 +1024,9 @@ static void random_misc(object_type * o_ptr, bool is_scroll)
                case 29:
                {
                        int bonus_h, bonus_d;
-                       o_ptr->art_flags3 |= TR3_SHOW_MODS;
-                       bonus_h = 4 + (randint(11));
-                       bonus_d = 4 + (randint(11));
+                       add_flag(o_ptr->art_flags, TR_SHOW_MODS);
+                       bonus_h = 4 + (randint1(11));
+                       bonus_d = 4 + (randint1(11));
                        if ((o_ptr->tval != TV_SWORD) && (o_ptr->tval != TV_POLEARM) && (o_ptr->tval != TV_HAFTED) && (o_ptr->tval != TV_DIGGING) && (o_ptr->tval != TV_GLOVES) && (o_ptr->tval != TV_RING))
                        {
                                bonus_h /= 2;
@@ -789,327 +1037,386 @@ static void random_misc(object_type * o_ptr, bool is_scroll)
                        break;
                }
                case 30:
-                       o_ptr->art_flags3 |= TR3_NO_MAGIC;
+                       add_flag(o_ptr->art_flags, TR_NO_MAGIC);
                        break;
                case 31:
-                       o_ptr->art_flags3 |= TR3_NO_TELE;
+                       add_flag(o_ptr->art_flags, TR_NO_TELE);
+                       break;
+               case 32:
+                       add_flag(o_ptr->art_flags, TR_WARNING);
+                       break;
+
+               case 18:
+                       switch (randint1(3))
+                       {
+                       case 1:
+                               add_flag(o_ptr->art_flags, TR_ESP_EVIL);
+                               if (!artifact_bias && one_in_(3))
+                                       artifact_bias = BIAS_LAW;
+                               break;
+                       case 2:
+                               add_flag(o_ptr->art_flags, TR_ESP_NONLIVING);
+                               if (!artifact_bias && one_in_(3))
+                                       artifact_bias = BIAS_MAGE;
+                               break;
+                       case 3:
+                               add_flag(o_ptr->art_flags, TR_TELEPATHY);
+                               if (!artifact_bias && one_in_(9))
+                                       artifact_bias = BIAS_MAGE;
+                               break;
+                       }
+                       break;
+
+               case 33:
+               {
+                       int idx[3];
+                       int n = randint1(3);
+
+                       idx[0] = randint1(8);
+
+                       idx[1] = randint1(7);
+                       if (idx[1] >= idx[0]) idx[1]++;
+
+                       idx[2] = randint1(6);
+                       if (idx[2] >= idx[0]) idx[2]++;
+                       if (idx[2] >= idx[1]) idx[2]++;
+
+                       while (n--) switch (idx[n])
+                       {
+                       case 1:
+                               add_flag(o_ptr->art_flags, TR_ESP_ANIMAL);
+                               if (!artifact_bias && one_in_(4))
+                                       artifact_bias = BIAS_RANGER;
+                               break;
+                       case 2:
+                               add_flag(o_ptr->art_flags, TR_ESP_UNDEAD);
+                               if (!artifact_bias && one_in_(3))
+                                       artifact_bias = BIAS_PRIESTLY;
+                               else if (!artifact_bias && one_in_(6))
+                                       artifact_bias = BIAS_NECROMANTIC;
+                               break;
+                       case 3:
+                               add_flag(o_ptr->art_flags, TR_ESP_DEMON);
+                               break;
+                       case 4:
+                               add_flag(o_ptr->art_flags, TR_ESP_ORC);
+                               break;
+                       case 5:
+                               add_flag(o_ptr->art_flags, TR_ESP_TROLL);
+                               break;
+                       case 6:
+                               add_flag(o_ptr->art_flags, TR_ESP_GIANT);
+                               break;
+                       case 7:
+                               add_flag(o_ptr->art_flags, TR_ESP_HUMAN);
+                               if (!artifact_bias && one_in_(6))
+                                       artifact_bias = BIAS_ROGUE;
+                               break;
+                       case 8:
+                               add_flag(o_ptr->art_flags, TR_ESP_GOOD);
+                               if (!artifact_bias && one_in_(3))
+                                       artifact_bias = BIAS_LAW;
+                               break;
+                       case 9:
+                               add_flag(o_ptr->art_flags, TR_ESP_UNIQUE);
+                               if (!artifact_bias && one_in_(3))
+                                       artifact_bias = BIAS_LAW;
+                               break;
+                       }
                        break;
+               }
        }
 }
 
 
-static void random_slay(object_type *o_ptr, bool is_scroll)
+static void random_slay(object_type *o_ptr)
 {
-       if (artifact_bias == BIAS_CHAOS && (o_ptr->tval != TV_BOW))
+       if (o_ptr->tval == TV_BOW)
        {
-               if (!(o_ptr->art_flags1 & TR1_CHAOTIC))
+               switch (randint1(6))
                {
-                       o_ptr->art_flags1 |= TR1_CHAOTIC;
-                       if (randint(2) == 1) return;
+                       case 1:
+                       case 2:
+                       case 3:
+                               add_flag(o_ptr->art_flags, TR_XTRA_MIGHT);
+                               if (!one_in_(7)) remove_flag(o_ptr->art_flags, TR_XTRA_SHOTS);
+                               if (!artifact_bias && one_in_(9))
+                                       artifact_bias = BIAS_RANGER;
+                               break;
+                       default:
+                               add_flag(o_ptr->art_flags, TR_XTRA_SHOTS);
+                               if (!one_in_(7)) remove_flag(o_ptr->art_flags, TR_XTRA_MIGHT);
+                               if (!artifact_bias && one_in_(9))
+                                       artifact_bias = BIAS_RANGER;
+                       break;
                }
-       }
 
-       else if (artifact_bias == BIAS_PRIESTLY &&
-          (o_ptr->tval == TV_SWORD || o_ptr->tval == TV_POLEARM) &&
-         !(o_ptr->art_flags3 & TR3_BLESSED))
-       {
-               /* A free power for "priestly" random artifacts */
-               o_ptr->art_flags3 |= TR3_BLESSED;
+               return;
        }
 
-       else if (artifact_bias == BIAS_NECROMANTIC && (o_ptr->tval != TV_BOW))
+       switch (artifact_bias)
        {
-               if (!(o_ptr->art_flags1 & TR1_VAMPIRIC))
+       case BIAS_CHAOS:
+               if (!(have_flag(o_ptr->art_flags, TR_CHAOTIC)))
                {
-                       o_ptr->art_flags1 |= TR1_VAMPIRIC;
-                       if (randint(2) == 1) return;
+                       add_flag(o_ptr->art_flags, TR_CHAOTIC);
+                       if (one_in_(2)) return;
                }
-               if (!(o_ptr->art_flags1 & TR1_BRAND_POIS) && (randint(2) == 1))
+               break;
+
+       case BIAS_PRIESTLY:
+               if((o_ptr->tval == TV_SWORD || o_ptr->tval == TV_POLEARM) &&
+                  !(have_flag(o_ptr->art_flags, TR_BLESSED)))
                {
-                       o_ptr->art_flags1 |= TR1_BRAND_POIS;
-                       if (randint(2) == 1) return;
+                       /* A free power for "priestly" random artifacts */
+                       add_flag(o_ptr->art_flags, TR_BLESSED);
                }
-       }
+               break;
 
-       else if (artifact_bias == BIAS_RANGER && (o_ptr->tval != TV_BOW))
-       {
-               if (!(o_ptr->art_flags1 & TR1_SLAY_ANIMAL))
+       case BIAS_NECROMANTIC:
+               if (!(have_flag(o_ptr->art_flags, TR_VAMPIRIC)))
                {
-                       o_ptr->art_flags1 |= TR1_SLAY_ANIMAL;
-                       if (randint(2) == 1) return;
+                       add_flag(o_ptr->art_flags, TR_VAMPIRIC);
+                       if (one_in_(2)) return;
                }
-       }
+               if (!(have_flag(o_ptr->art_flags, TR_BRAND_POIS)) && one_in_(2))
+               {
+                       add_flag(o_ptr->art_flags, TR_BRAND_POIS);
+                       if (one_in_(2)) return;
+               }
+               break;
 
-       else if (artifact_bias == BIAS_ROGUE && (o_ptr->tval != TV_BOW))
-       {
+       case BIAS_RANGER:
+               if (!(have_flag(o_ptr->art_flags, TR_SLAY_ANIMAL)))
+               {
+                       add_flag(o_ptr->art_flags, TR_SLAY_ANIMAL);
+                       if (one_in_(2)) return;
+               }
+               break;
+
+       case BIAS_ROGUE:
                if ((((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DAGGER)) ||
                     ((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_SPEAR))) &&
-                        !(o_ptr->art_flags2 & TR2_THROW))
+                        !(have_flag(o_ptr->art_flags, TR_THROW)))
                {
                        /* Free power for rogues... */
-                       o_ptr->art_flags2 |= TR2_THROW;
+                       add_flag(o_ptr->art_flags, TR_THROW);
                }
-               if (!(o_ptr->art_flags1 & TR1_BRAND_POIS))
+               if (!(have_flag(o_ptr->art_flags, TR_BRAND_POIS)))
                {
-                       o_ptr->art_flags1 |= TR1_BRAND_POIS;
-                       if (randint(2) == 1) return;
+                       add_flag(o_ptr->art_flags, TR_BRAND_POIS);
+                       if (one_in_(2)) return;
                }
-       }
+               break;
 
-       else if (artifact_bias == BIAS_POIS && (o_ptr->tval != TV_BOW))
-       {
-               if (!(o_ptr->art_flags1 & TR1_BRAND_POIS))
+       case BIAS_POIS:
+               if (!(have_flag(o_ptr->art_flags, TR_BRAND_POIS)))
                {
-                       o_ptr->art_flags1 |= TR1_BRAND_POIS;
-                       if (randint(2) == 1) return;
+                       add_flag(o_ptr->art_flags, TR_BRAND_POIS);
+                       if (one_in_(2)) return;
                }
-       }
+               break;
 
-       else if (artifact_bias == BIAS_FIRE && (o_ptr->tval != TV_BOW))
-       {
-               if (!(o_ptr->art_flags1 & TR1_BRAND_FIRE))
+       case BIAS_FIRE:
+               if (!(have_flag(o_ptr->art_flags, TR_BRAND_FIRE)))
                {
-                       o_ptr->art_flags1 |= TR1_BRAND_FIRE;
-                       if (randint(2) == 1) return;
+                       add_flag(o_ptr->art_flags, TR_BRAND_FIRE);
+                       if (one_in_(2)) return;
                }
-       }
+               break;
 
-       else if (artifact_bias == BIAS_COLD && (o_ptr->tval != TV_BOW))
-       {
-               if (!(o_ptr->art_flags1 & TR1_BRAND_COLD))
+       case BIAS_COLD:
+               if (!(have_flag(o_ptr->art_flags, TR_BRAND_COLD)))
                {
-                       o_ptr->art_flags1 |= TR1_BRAND_COLD;
-                       if (randint(2) == 1) return;
+                       add_flag(o_ptr->art_flags, TR_BRAND_COLD);
+                       if (one_in_(2)) return;
                }
-       }
+               break;
 
-       else if (artifact_bias == BIAS_ELEC && (o_ptr->tval != TV_BOW))
-       {
-               if (!(o_ptr->art_flags1 & TR1_BRAND_ELEC))
+       case BIAS_ELEC:
+               if (!(have_flag(o_ptr->art_flags, TR_BRAND_ELEC)))
                {
-                       o_ptr->art_flags1 |= TR1_BRAND_ELEC;
-                       if (randint(2) == 1) return;
+                       add_flag(o_ptr->art_flags, TR_BRAND_ELEC);
+                       if (one_in_(2)) return;
                }
-       }
+               break;
 
-       else if (artifact_bias == BIAS_ACID && (o_ptr->tval != TV_BOW))
-       {
-               if (!(o_ptr->art_flags1 & TR1_BRAND_ACID))
+       case BIAS_ACID:
+               if (!(have_flag(o_ptr->art_flags, TR_BRAND_ACID)))
                {
-                       o_ptr->art_flags1 |= TR1_BRAND_ACID;
-                       if (randint(2) == 1) return;
+                       add_flag(o_ptr->art_flags, TR_BRAND_ACID);
+                       if (one_in_(2)) return;
                }
-       }
+               break;
 
-       else if (artifact_bias == BIAS_LAW && (o_ptr->tval != TV_BOW))
-       {
-               if (!(o_ptr->art_flags1 & TR1_SLAY_EVIL))
+       case BIAS_LAW:
+               if (!(have_flag(o_ptr->art_flags, TR_SLAY_EVIL)))
                {
-                       o_ptr->art_flags1 |= TR1_SLAY_EVIL;
-                       if (randint(2) == 1) return;
+                       add_flag(o_ptr->art_flags, TR_SLAY_EVIL);
+                       if (one_in_(2)) return;
                }
-               if (!(o_ptr->art_flags1 & TR1_SLAY_UNDEAD))
+               if (!(have_flag(o_ptr->art_flags, TR_SLAY_UNDEAD)))
                {
-                       o_ptr->art_flags1 |= TR1_SLAY_UNDEAD;
-                       if (randint(2) == 1) return;
+                       add_flag(o_ptr->art_flags, TR_SLAY_UNDEAD);
+                       if (one_in_(2)) return;
                }
-               if (!(o_ptr->art_flags1 & TR1_SLAY_DEMON))
+               if (!(have_flag(o_ptr->art_flags, TR_SLAY_DEMON)))
                {
-                       o_ptr->art_flags1 |= TR1_SLAY_DEMON;
-                       if (randint(2) == 1) return;
+                       add_flag(o_ptr->art_flags, TR_SLAY_DEMON);
+                       if (one_in_(2)) return;
                }
+               break;
        }
 
-       if (o_ptr->tval != TV_BOW)
-       {
-               switch (randint(34))
-               {
-                       case 1:
-                       case 2:
-                               o_ptr->art_flags1 |= TR1_SLAY_ANIMAL;
-                               /*  if (is_scroll) msg_print("You start hating animals.");*/
-                               break;
-                       case 3:
-                       case 4:
-                               o_ptr->art_flags1 |= TR1_SLAY_EVIL;
-                               /*  if (is_scroll) msg_print("You hate evil creatures.");*/
-                               if (!artifact_bias && (randint(2) == 1))
-                                       artifact_bias = BIAS_LAW;
-                               else if (!artifact_bias && (randint(9) == 1))
-                                       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))
-                                       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))
-                                       artifact_bias = BIAS_PRIESTLY;
-                               break;
-                       case 9:
-                       case 10:
-                               o_ptr->art_flags1 |= TR1_SLAY_ORC;
-                               /*  if (is_scroll) msg_print("You hate orcs.");*/
-                               break;
-                       case 11:
-                       case 12:
-                               o_ptr->art_flags1 |= TR1_SLAY_TROLL;
-                               /*  if (is_scroll) msg_print("You hate trolls.");*/
-                               break;
-                       case 13:
-                       case 14:
-                               o_ptr->art_flags1 |= TR1_SLAY_GIANT;
-                               /*  if (is_scroll) msg_print("You hate giants.");*/
-                               break;
-                       case 15:
-                       case 16:
-                               o_ptr->art_flags1 |= TR1_SLAY_DRAGON;
-                               /*  if (is_scroll) msg_print("You hate dragons.");*/
-                               break;
-                       case 17:
-                               o_ptr->art_flags1 |= TR1_KILL_DRAGON;
-                               /*  if (is_scroll) msg_print("You feel an intense hatred of dragons.");*/
-                               break;
-                       case 18:
-                       case 19:
-                               if (o_ptr->tval == TV_SWORD)
-                               {
-                                       o_ptr->art_flags1 |= TR1_VORPAL;
-                                       /* if (is_scroll) msg_print("It looks extremely sharp!");*/
-                                       if (!artifact_bias && (randint(9) == 1))
-                                               artifact_bias = BIAS_WARRIOR;
-                               }
-                               else
-                                       random_slay(o_ptr, is_scroll);
-                               break;
-                       case 20:
-                               o_ptr->art_flags1 |= TR1_IMPACT;
-                               /* if (is_scroll) msg_print("The ground trembles beneath you.");*/
-                               break;
-                       case 21:
-                       case 22:
-                               o_ptr->art_flags1 |= TR1_BRAND_FIRE;
-                               /*  if (is_scroll) msg_print("It feels hot!");*/
-                               if (!artifact_bias)
-                                       artifact_bias = BIAS_FIRE;
-                               break;
-                       case 23:
-                       case 24:
-                               o_ptr->art_flags1 |= TR1_BRAND_COLD;
-                               /*  if (is_scroll) msg_print("It feels cold!");*/
-                               if (!artifact_bias)
-                                       artifact_bias = BIAS_COLD;
-                               break;
-                       case 25:
-                       case 26:
-                               o_ptr->art_flags1 |= TR1_BRAND_ELEC;
-                               /*  if (is_scroll) msg_print("Ouch! You get zapped!");*/
-                               if (!artifact_bias)
-                                       artifact_bias = BIAS_ELEC;
-                               break;
-                       case 27:
-                       case 28:
-                               o_ptr->art_flags1 |= TR1_BRAND_ACID;
-                               /*  if (is_scroll) msg_print("Its smell makes you feel dizzy.");*/
-                               if (!artifact_bias)
-                                       artifact_bias = BIAS_ACID;
-                               break;
-                       case 29:
-                       case 30:
-                               o_ptr->art_flags1 |= TR1_BRAND_POIS;
-                               /*  if (is_scroll) msg_print("It smells rotten.");*/
-                               if (!artifact_bias && (randint(3) != 1))
-                                       artifact_bias = BIAS_POIS;
-                               else if (!artifact_bias && randint(6) == 1)
-                                       artifact_bias = BIAS_NECROMANTIC;
-                               else if (!artifact_bias)
-                                       artifact_bias = BIAS_ROGUE;
-                               break;
-                       case 31:
-                               o_ptr->art_flags1 |= TR1_VAMPIRIC;
-                               /*  if (is_scroll) msg_print("You think it bit you!");*/
-                               if (!artifact_bias)
-                                       artifact_bias = BIAS_NECROMANTIC;
-                               break;
-                       case 32:
-                               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);
-                               break;
-                       default:
-                               o_ptr->art_flags1 |= TR1_CHAOTIC;
-                               /*  if (is_scroll) msg_print("It looks very confusing.");*/
-                               if (!artifact_bias)
-                                       artifact_bias = BIAS_CHAOS;
-                               break;
-               }
-       }
-       else
+       switch (randint1(36))
        {
-               switch (randint(6))
-               {
-                       case 1:
-                       case 2:
-                       case 3:
-                               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)
-                                       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)
-                                       artifact_bias = BIAS_RANGER;
+               case 1:
+               case 2:
+                       add_flag(o_ptr->art_flags, TR_SLAY_ANIMAL);
                        break;
-               }
-       }
-}
-
-
-static void give_activation_power(object_type *o_ptr)
-{
-       int type = 0, chance = 0;
-
-       if (artifact_bias)
-       {
-               if (artifact_bias == BIAS_ELEC)
-               {
-                       if (randint(3) != 1)
-                       {
-                               type = ACT_BO_ELEC_1;
-                       }
-                       else if (randint(5) != 1)
-                       {
-                               type = ACT_BA_ELEC_2;
-                       }
-                       else
-                       {
-                               type = ACT_BA_ELEC_3;
-                       }
-                       chance = 101;
-               }
-               else if (artifact_bias == BIAS_POIS)
-               {
+               case 3:
+               case 4:
+                       add_flag(o_ptr->art_flags, TR_SLAY_EVIL);
+                       if (!artifact_bias && one_in_(2))
+                               artifact_bias = BIAS_LAW;
+                       else if (!artifact_bias && one_in_(9))
+                               artifact_bias = BIAS_PRIESTLY;
+                       break;
+               case 5:
+               case 6:
+                       add_flag(o_ptr->art_flags, TR_SLAY_UNDEAD);
+                       if (!artifact_bias && one_in_(9))
+                               artifact_bias = BIAS_PRIESTLY;
+                       break;
+               case 7:
+               case 8:
+                       add_flag(o_ptr->art_flags, TR_SLAY_DEMON);
+                       if (!artifact_bias && one_in_(9))
+                               artifact_bias = BIAS_PRIESTLY;
+                       break;
+               case 9:
+               case 10:
+                       add_flag(o_ptr->art_flags, TR_SLAY_ORC);
+                       break;
+               case 11:
+               case 12:
+                       add_flag(o_ptr->art_flags, TR_SLAY_TROLL);
+                       break;
+               case 13:
+               case 14:
+                       add_flag(o_ptr->art_flags, TR_SLAY_GIANT);
+                       break;
+               case 15:
+               case 16:
+                       add_flag(o_ptr->art_flags, TR_SLAY_DRAGON);
+                       break;
+               case 17:
+                       add_flag(o_ptr->art_flags, TR_KILL_DRAGON);
+                       break;
+               case 18:
+               case 19:
+                       if (o_ptr->tval == TV_SWORD)
+                       {
+                               add_flag(o_ptr->art_flags, TR_VORPAL);
+                               if (!artifact_bias && one_in_(9))
+                                       artifact_bias = BIAS_WARRIOR;
+                       }
+                       else
+                               random_slay(o_ptr);
+                       break;
+               case 20:
+                       add_flag(o_ptr->art_flags, TR_IMPACT);
+                       break;
+               case 21:
+               case 22:
+                       add_flag(o_ptr->art_flags, TR_BRAND_FIRE);
+                       if (!artifact_bias)
+                               artifact_bias = BIAS_FIRE;
+                       break;
+               case 23:
+               case 24:
+                       add_flag(o_ptr->art_flags, TR_BRAND_COLD);
+                       if (!artifact_bias)
+                               artifact_bias = BIAS_COLD;
+                       break;
+               case 25:
+               case 26:
+                       add_flag(o_ptr->art_flags, TR_BRAND_ELEC);
+                       if (!artifact_bias)
+                               artifact_bias = BIAS_ELEC;
+                       break;
+               case 27:
+               case 28:
+                       add_flag(o_ptr->art_flags, TR_BRAND_ACID);
+                       if (!artifact_bias)
+                               artifact_bias = BIAS_ACID;
+                       break;
+               case 29:
+               case 30:
+                       add_flag(o_ptr->art_flags, TR_BRAND_POIS);
+                       if (!artifact_bias && !one_in_(3))
+                               artifact_bias = BIAS_POIS;
+                       else if (!artifact_bias && one_in_(6))
+                               artifact_bias = BIAS_NECROMANTIC;
+                       else if (!artifact_bias)
+                               artifact_bias = BIAS_ROGUE;
+                       break;
+               case 31:
+                       add_flag(o_ptr->art_flags, TR_VAMPIRIC);
+                       if (!artifact_bias)
+                               artifact_bias = BIAS_NECROMANTIC;
+                       break;
+               case 32:
+                       add_flag(o_ptr->art_flags, TR_FORCE_WEAPON);
+                       if (!artifact_bias)
+                               artifact_bias = (one_in_(2) ? BIAS_MAGE : BIAS_PRIESTLY);
+                       break;
+               case 33:
+               case 34:
+                       add_flag(o_ptr->art_flags, TR_SLAY_HUMAN);
+                       break;
+               default:
+                       add_flag(o_ptr->art_flags, TR_CHAOTIC);
+                       if (!artifact_bias)
+                               artifact_bias = BIAS_CHAOS;
+                       break;
+       }
+}
+
+
+static void give_activation_power(object_type *o_ptr)
+{
+       int type = 0, chance = 0;
+
+       switch (artifact_bias)
+       {
+               case BIAS_ELEC:
+                       if (!one_in_(3))
+                       {
+                               type = ACT_BO_ELEC_1;
+                       }
+                       else if (!one_in_(5))
+                       {
+                               type = ACT_BA_ELEC_2;
+                       }
+                       else
+                       {
+                               type = ACT_BA_ELEC_3;
+                       }
+                       chance = 101;
+                       break;
+
+               case BIAS_POIS:
                        type = ACT_BA_POIS_1;
                        chance = 101;
-               }
-               else if (artifact_bias == BIAS_FIRE)
-               {
-                       if (randint(3) != 1)
+                       break;
+
+               case BIAS_FIRE:
+                       if (!one_in_(3))
                        {
                                type = ACT_BO_FIRE_1;
                        }
-                       else if (randint(5) != 1)
+                       else if (!one_in_(5))
                        {
                                type = ACT_BA_FIRE_1;
                        }
@@ -1118,244 +1425,154 @@ static void give_activation_power(object_type *o_ptr)
                                type = ACT_BA_FIRE_2;
                        }
                        chance = 101;
-               }
-               else if (artifact_bias == BIAS_COLD)
-               {
+                       break;
+
+               case 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;
-               }
-               else if (artifact_bias == BIAS_CHAOS)
-               {
+                       break;
+
+               case BIAS_CHAOS:
                        chance = 50;
-                       if (randint(6) == 1)
+                       if (one_in_(6))
                                type = ACT_SUMMON_DEMON;
                        else
                                type = ACT_CALL_CHAOS;
-               }
-               else if (artifact_bias == BIAS_PRIESTLY)
-               {
+                       break;
+
+               case BIAS_PRIESTLY:
                        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;
-               }
-               else if (artifact_bias == BIAS_NECROMANTIC)
-               {
+                       break;
+
+               case 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;
-               }
-               else if (artifact_bias == BIAS_LAW)
-               {
+                       break;
+
+               case 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;
-               }
-               else if (artifact_bias == BIAS_ROGUE)
-               {
+                       break;
+
+               case 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;
-               }
-               else if (artifact_bias == BIAS_MAGE)
-               {
+                       break;
+
+               case 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;
-               }
-               else if (artifact_bias == BIAS_WARRIOR)
-               {
+                       break;
+
+               case BIAS_WARRIOR:
                        chance = 80;
-                       if (randint(100) == 1)
+                       if (one_in_(100))
                                type = ACT_INVULN;
                        else
                                type = ACT_BERSERK;
-               }
-               else if (artifact_bias == BIAS_RANGER)
-               {
+                       break;
+
+               case 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;
-               }
+                       break;
        }
 
-       while (!type || (randint(100) >= chance))
+       if (!type || (randint1(100) >= chance))
        {
-               type = randint(255);
-               switch (type)
-               {
-                       case ACT_SUNLIGHT:
-                       case ACT_BO_MISS_1:
-                       case ACT_BA_POIS_1:
-                       case ACT_BO_ELEC_1:
-                       case ACT_BO_ACID_1:
-                       case ACT_BO_COLD_1:
-                       case ACT_BO_FIRE_1:
-                       case ACT_CONFUSE:
-                       case ACT_SLEEP:
-                       case ACT_QUAKE:
-                       case ACT_CURE_LW:
-                       case ACT_CURE_MW:
-                       case ACT_CURE_POISON:
-                       case ACT_BERSERK:
-                       case ACT_LIGHT:
-                       case ACT_MAP_LIGHT:
-                       case ACT_DEST_DOOR:
-                       case ACT_STONE_MUD:
-                       case ACT_TELEPORT:
-                               chance = 101;
-                               break;
-                       case ACT_BA_COLD_1:
-                       case ACT_BA_FIRE_1:
-                       case ACT_DRAIN_1:
-                       case ACT_TELE_AWAY:
-                       case ACT_ESP:
-                       case ACT_RESIST_ALL:
-                       case ACT_DETECT_ALL:
-                       case ACT_RECALL:
-                       case ACT_SATIATE:
-                       case ACT_RECHARGE:
-                               chance = 85;
-                               break;
-                       case ACT_TERROR:
-                       case ACT_PROT_EVIL:
-                       case ACT_ID_PLAIN:
-                               chance = 75;
-                               break;
-                       case ACT_DRAIN_2:
-                       case ACT_VAMPIRE_1:
-                       case ACT_BO_MISS_2:
-                       case ACT_BA_FIRE_2:
-                       case ACT_REST_LIFE:
-                               chance = 66;
-                               break;
-                       case ACT_BA_COLD_3:
-                       case ACT_BA_ELEC_3:
-                       case ACT_WHIRLWIND:
-                       case ACT_VAMPIRE_2:
-                       case ACT_CHARM_ANIMAL:
-                               chance = 50;
-                               break;
-                       case ACT_SUMMON_ANIMAL:
-                               chance = 40;
-                               break;
-                       case ACT_DISP_EVIL:
-                       case ACT_BA_MISS_3:
-                       case ACT_DISP_GOOD:
-                       case ACT_BANISH_EVIL:
-                       case ACT_GENOCIDE:
-                       case ACT_MASS_GENO:
-                       case ACT_CHARM_UNDEAD:
-                       case ACT_CHARM_OTHER:
-                       case ACT_SUMMON_PHANTOM:
-                       case ACT_REST_ALL:
-                       case ACT_RUNE_EXPLO:
-                               chance = 33;
-                               break;
-                       case ACT_CALL_CHAOS:
-                       case ACT_ROCKET:
-                       case ACT_CHARM_ANIMALS:
-                       case ACT_CHARM_OTHERS:
-                       case ACT_SUMMON_ELEMENTAL:
-                       case ACT_CURE_700:
-                       case ACT_SPEED:
-                       case ACT_ID_FULL:
-                       case ACT_RUNE_PROT:
-                               chance = 25;
-                               break;
-                       case ACT_CURE_1000:
-                       case ACT_XTRA_SPEED:
-                       case ACT_DETECT_XTRA:
-                       case ACT_DIM_DOOR:
-                               chance = 10;
-                               break;
-                       case ACT_SUMMON_UNDEAD:
-                       case ACT_SUMMON_DEMON:
-                       case ACT_WRAITH:
-                       case ACT_INVULN:
-                       case ACT_ALCHEMY:
-                               chance = 5;
-                               break;
-                       default:
-                               chance = 0;
-               }
+               one_activation(o_ptr);
+               return;
        }
 
        /* A type was chosen... */
        o_ptr->xtra2 = type;
-       o_ptr->art_flags3 |= TR3_ACTIVATE;
+       add_flag(o_ptr->art_flags, TR_ACTIVATE);
        o_ptr->timeout = 0;
 }
 
 
 static void get_random_name(char *return_name, bool armour, int power)
 {
-       if (randint(100) <= TABLE_NAME)
+       int prob = randint1(100);
+
+       if (prob <= SINDARIN_NAME)
+       {
+               get_table_sindarin(return_name);
+       }
+       else if (prob <= TABLE_NAME)
        {
                get_table_name(return_name);
        }
@@ -1370,35 +1587,31 @@ static void get_random_name(char *return_name, bool armour, int power)
                                {
                                        case 0:
 #ifdef JP
-filename = "a_cursed_j.txt";
+                                               filename = "a_cursed_j.txt";
 #else
                                                filename = "a_cursed.txt";
 #endif
-
                                                break;
                                        case 1:
 #ifdef JP
-filename = "a_low_j.txt";
+                                               filename = "a_low_j.txt";
 #else
                                                filename = "a_low.txt";
 #endif
-
                                                break;
                                        case 2:
 #ifdef JP
-filename = "a_med_j.txt";
+                                               filename = "a_med_j.txt";
 #else
                                                filename = "a_med.txt";
 #endif
-
                                                break;
                                        default:
 #ifdef JP
-filename = "a_high_j.txt";
+                                               filename = "a_high_j.txt";
 #else
                                                filename = "a_high.txt";
 #endif
-
                                }
                                break;
                        default:
@@ -1406,41 +1619,37 @@ filename = "a_high_j.txt";
                                {
                                        case 0:
 #ifdef JP
-filename = "w_cursed_j.txt";
+                                               filename = "w_cursed_j.txt";
 #else
                                                filename = "w_cursed.txt";
 #endif
-
                                                break;
                                        case 1:
 #ifdef JP
-filename = "w_low_j.txt";
+                                               filename = "w_low_j.txt";
 #else
                                                filename = "w_low.txt";
 #endif
-
                                                break;
                                        case 2:
 #ifdef JP
-filename = "w_med_j.txt";
+                                               filename = "w_med_j.txt";
 #else
                                                filename = "w_med.txt";
 #endif
-
                                                break;
                                        default:
 #ifdef JP
-filename = "w_high_j.txt";
+                                               filename = "w_high_j.txt";
 #else
                                                filename = "w_high.txt";
 #endif
-
                                }
                }
 
                (void)get_rnd_line(filename, artifact_bias, return_name);
 #ifdef JP
if(return_name[0]==0)get_table_name(return_name);
               if (return_name[0] == 0) get_table_name(return_name);
 #endif
        }
 }
@@ -1450,26 +1659,27 @@ bool create_artifact(object_type *o_ptr, bool a_scroll)
 {
        char    new_name[1024];
        int     has_pval = 0;
-       int     powers = randint(5) + 1;
-       int     max_type = (o_ptr->tval < TV_BOOTS ? 7 : 5);
+       int     powers = randint1(5) + 1;
+       int     max_type = (object_is_weapon_ammo(o_ptr) ? 7 : 5);
        int     power_level;
        s32b    total_flags;
        bool    a_cursed = FALSE;
        int     warrior_artifact_bias = 0;
+       int i;
 
-
+       /* Reset artifact bias */
        artifact_bias = 0;
 
        /* Nuke enchantments */
        o_ptr->name1 = 0;
        o_ptr->name2 = 0;
 
-       o_ptr->art_flags1 |= k_info[o_ptr->k_idx].flags1;
-       o_ptr->art_flags2 |= k_info[o_ptr->k_idx].flags2;
-       o_ptr->art_flags3 |= k_info[o_ptr->k_idx].flags3;
+       for (i = 0; i < TR_FLAG_SIZE; i++)
+               o_ptr->art_flags[i] |= k_info[o_ptr->k_idx].flags[i];
+
        if (o_ptr->pval) has_pval = TRUE;
 
-       if (a_scroll && (randint(4) == 1))
+       if (a_scroll && one_in_(4))
        {
                switch (p_ptr->pclass)
                {
@@ -1497,7 +1707,7 @@ bool create_artifact(object_type *o_ptr, bool a_scroll)
                                warrior_artifact_bias = 25;
                                break;
                        case CLASS_RANGER:
-                       case CLASS_MIRROR_MASTER:
+                       case CLASS_SNIPER:
                                artifact_bias = BIAS_RANGER;
                                warrior_artifact_bias = 30;
                                break;
@@ -1520,35 +1730,45 @@ bool create_artifact(object_type *o_ptr, bool a_scroll)
                                break;
                        case CLASS_MINDCRAFTER:
                        case CLASS_BARD:
-                               if (randint(5) > 2) artifact_bias = BIAS_PRIESTLY;
+                               if (randint1(5) > 2) artifact_bias = BIAS_PRIESTLY;
                                break;
                        case CLASS_TOURIST:
-                               if (randint(5) > 2) artifact_bias = BIAS_WARRIOR;
+                               if (randint1(5) > 2) artifact_bias = BIAS_WARRIOR;
                                break;
                        case CLASS_IMITATOR:
-                               if (randint(2) > 1) artifact_bias = BIAS_RANGER;
+                               if (randint1(2) > 1) artifact_bias = BIAS_RANGER;
                                break;
                        case CLASS_BEASTMASTER:
                                artifact_bias = BIAS_CHR;
                                warrior_artifact_bias = 50;
                                break;
-               }
-       }
-
-       if (a_scroll && (randint(100) <= warrior_artifact_bias))
-               artifact_bias = BIAS_WARRIOR;
-
-       strcpy(new_name, "");
+                       case CLASS_MIRROR_MASTER:
+                               if (randint1(4) > 1) 
+                               {
+                                   artifact_bias = BIAS_MAGE;
+                               }
+                               else
+                               {
+                                   artifact_bias = BIAS_ROGUE;
+                               }
+                               break;
+               }
+       }
+
+       if (a_scroll && (randint1(100) <= warrior_artifact_bias))
+               artifact_bias = BIAS_WARRIOR;
+
+       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))
+       if (((o_ptr->tval == TV_AMULET) || (o_ptr->tval == TV_RING)) && object_is_cursed(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;
@@ -1556,14 +1776,14 @@ bool create_artifact(object_type *o_ptr, bool a_scroll)
        /* Main loop */
        while (powers--)
        {
-               switch (randint(max_type))
+               switch (randint1(max_type))
                {
                        case 1: case 2:
-                               random_plus(o_ptr, a_scroll);
+                               random_plus(o_ptr);
                                has_pval = TRUE;
                                break;
                        case 3: case 4:
-                               if (one_in_(2) && (o_ptr->tval < TV_BOOTS) && (o_ptr->tval != TV_BOW))
+                               if (one_in_(2) && object_is_weapon_ammo(o_ptr) && (o_ptr->tval != TV_BOW))
                                {
                                        if (a_cursed && !one_in_(13)) break;
                                        if (one_in_(13))
@@ -1576,16 +1796,16 @@ bool create_artifact(object_type *o_ptr, bool a_scroll)
                                        }
                                }
                                else
-                                       random_resistance(o_ptr, a_scroll, FALSE);
+                                       random_resistance(o_ptr);
                                break;
                        case 5:
-                               random_misc(o_ptr, a_scroll);
+                               random_misc(o_ptr);
                                break;
                        case 6: case 7:
-                               random_slay(o_ptr, a_scroll);
+                               random_slay(o_ptr);
                                break;
                        default:
-                               if (wizard) msg_print("Switch error in create_artifact!");
+                               if (p_ptr->wizard) msg_print("Switch error in create_artifact!");
                                powers++;
                }
        };
@@ -1593,16 +1813,16 @@ bool create_artifact(object_type *o_ptr, bool a_scroll)
        if (has_pval)
        {
 #if 0
-               o_ptr->art_flags3 |= TR3_SHOW_MODS;
+               add_flag(o_ptr->art_flags, TR_SHOW_MODS);
 
                /* This one commented out by gw's request... */
                if (!a_scroll)
-                       o_ptr->art_flags3 |= TR3_HIDE_TYPE;
+                       add_flag(o_ptr->art_flags, TR_HIDE_TYPE);
 #endif
 
-               if (o_ptr->art_flags1 & TR1_BLOWS)
+               if (have_flag(o_ptr->art_flags, TR_BLOWS))
                {
-                       o_ptr->pval = randint(2);
+                       o_ptr->pval = randint1(2);
                        if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_HAYABUSA))
                                o_ptr->pval++;
                }
@@ -1612,26 +1832,28 @@ 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 < randint1(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;
        }
 
        /* give it some plusses... */
-       if (o_ptr->tval >= TV_BOOTS && o_ptr->tval <= TV_DRAG_ARMOR)
-               o_ptr->to_a += randint(o_ptr->to_a > 19 ? 1 : 20 - o_ptr->to_a);
-       else if (o_ptr->tval <= TV_SWORD)
+       if (object_is_armour(o_ptr))
+               o_ptr->to_a += randint1(o_ptr->to_a > 19 ? 1 : 20 - o_ptr->to_a);
+       else if (object_is_weapon_ammo(o_ptr))
        {
-               o_ptr->to_h += randint(o_ptr->to_h > 19 ? 1 : 20 - o_ptr->to_h);
-               o_ptr->to_d += randint(o_ptr->to_d > 19 ? 1 : 20 - o_ptr->to_d);
-               if ((o_ptr->art_flags1 & TR1_WIS) && (o_ptr->pval > 0)) o_ptr->art_flags3 |= TR3_BLESSED;
+               o_ptr->to_h += randint1(o_ptr->to_h > 19 ? 1 : 20 - o_ptr->to_h);
+               o_ptr->to_d += randint1(o_ptr->to_d > 19 ? 1 : 20 - o_ptr->to_d);
+               if ((have_flag(o_ptr->art_flags, TR_WIS)) && (o_ptr->pval > 0)) add_flag(o_ptr->art_flags, TR_BLESSED);
        }
 
        /* Just to be sure */
-       o_ptr->art_flags3 |= (TR3_IGNORE_ACID | TR3_IGNORE_ELEC |
-                             TR3_IGNORE_FIRE | TR3_IGNORE_COLD);
+       add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
+       add_flag(o_ptr->art_flags, TR_IGNORE_ELEC);
+       add_flag(o_ptr->art_flags, TR_IGNORE_FIRE);
+       add_flag(o_ptr->art_flags, TR_IGNORE_COLD);
 
        total_flags = flag_cost(o_ptr, o_ptr->pval);
        if (cheat_peek) msg_format("%ld", total_flags);
@@ -1639,101 +1861,81 @@ bool create_artifact(object_type *o_ptr, bool a_scroll)
        if (a_cursed) curse_artifact(o_ptr);
 
        if (!a_cursed &&
-           (randint((o_ptr->tval >= TV_BOOTS)
-           ? ACTIVATION_CHANCE * 2 : ACTIVATION_CHANCE) == 1))
+           one_in_(object_is_armour(o_ptr) ? ACTIVATION_CHANCE * 2 : ACTIVATION_CHANCE))
        {
                o_ptr->xtra2 = 0;
                give_activation_power(o_ptr);
        }
 
-       if ((o_ptr->tval >= TV_BOOTS) && (o_ptr->tval <= TV_DRAG_ARMOR))
+       if (object_is_armour(o_ptr))
        {
                while ((o_ptr->to_d+o_ptr->to_h) > 20)
                {
                        if (one_in_(o_ptr->to_d) && one_in_(o_ptr->to_h)) break;
-                       o_ptr->to_d -= (s16b)rand_int(3);
-                       o_ptr->to_h -= (s16b)rand_int(3);
+                       o_ptr->to_d -= (s16b)randint0(3);
+                       o_ptr->to_h -= (s16b)randint0(3);
                }
                while ((o_ptr->to_d+o_ptr->to_h) > 10)
                {
                        if (one_in_(o_ptr->to_d) || one_in_(o_ptr->to_h)) break;
-                       o_ptr->to_d -= (s16b)rand_int(3);
-                       o_ptr->to_h -= (s16b)rand_int(3);
+                       o_ptr->to_d -= (s16b)randint0(3);
+                       o_ptr->to_h -= (s16b)randint0(3);
                }
        }
 
-       if (((artifact_bias == BIAS_MAGE) || (artifact_bias == BIAS_INT)) && (o_ptr->tval == TV_GLOVES)) o_ptr->art_flags2 |= TR2_FREE_ACT;
+       if (((artifact_bias == BIAS_MAGE) || (artifact_bias == BIAS_INT)) && (o_ptr->tval == TV_GLOVES)) add_flag(o_ptr->art_flags, TR_FREE_ACT);
 
        if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI))
        {
                o_ptr->to_h = 0;
                o_ptr->to_d = 0;
-               o_ptr->art_flags1 &= ~(TR1_BLOWS);
-               o_ptr->art_flags1 &= ~(TR1_FORCE_WEPON);
-               o_ptr->art_flags1 &= ~(TR1_SLAY_ANIMAL);
-               o_ptr->art_flags1 &= ~(TR1_SLAY_EVIL);
-               o_ptr->art_flags1 &= ~(TR1_SLAY_UNDEAD);
-               o_ptr->art_flags1 &= ~(TR1_SLAY_DEMON);
-               o_ptr->art_flags1 &= ~(TR1_SLAY_ORC);
-               o_ptr->art_flags1 &= ~(TR1_SLAY_TROLL);
-               o_ptr->art_flags1 &= ~(TR1_SLAY_GIANT);
-               o_ptr->art_flags1 &= ~(TR1_SLAY_DRAGON);
-               o_ptr->art_flags1 &= ~(TR1_KILL_DRAGON);
-               o_ptr->art_flags1 &= ~(TR1_VORPAL);
-               o_ptr->art_flags1 &= ~(TR1_BRAND_POIS);
-               o_ptr->art_flags1 &= ~(TR1_BRAND_ACID);
-               o_ptr->art_flags1 &= ~(TR1_BRAND_ELEC);
-               o_ptr->art_flags1 &= ~(TR1_BRAND_FIRE);
-               o_ptr->art_flags1 &= ~(TR1_BRAND_COLD);
+               remove_flag(o_ptr->art_flags, TR_BLOWS);
+               remove_flag(o_ptr->art_flags, TR_FORCE_WEAPON);
+               remove_flag(o_ptr->art_flags, TR_SLAY_ANIMAL);
+               remove_flag(o_ptr->art_flags, TR_SLAY_EVIL);
+               remove_flag(o_ptr->art_flags, TR_SLAY_UNDEAD);
+               remove_flag(o_ptr->art_flags, TR_SLAY_DEMON);
+               remove_flag(o_ptr->art_flags, TR_SLAY_ORC);
+               remove_flag(o_ptr->art_flags, TR_SLAY_TROLL);
+               remove_flag(o_ptr->art_flags, TR_SLAY_GIANT);
+               remove_flag(o_ptr->art_flags, TR_SLAY_DRAGON);
+               remove_flag(o_ptr->art_flags, TR_KILL_DRAGON);
+               remove_flag(o_ptr->art_flags, TR_SLAY_HUMAN);
+               remove_flag(o_ptr->art_flags, TR_VORPAL);
+               remove_flag(o_ptr->art_flags, TR_BRAND_POIS);
+               remove_flag(o_ptr->art_flags, TR_BRAND_ACID);
+               remove_flag(o_ptr->art_flags, TR_BRAND_ELEC);
+               remove_flag(o_ptr->art_flags, TR_BRAND_FIRE);
+               remove_flag(o_ptr->art_flags, TR_BRAND_COLD);
        }
 
-       if (o_ptr->tval >= TV_BOOTS)
+       if (!object_is_weapon_ammo(o_ptr))
        {
+               /* For armors */
                if (a_cursed) power_level = 0;
                else if (total_flags < 15000) power_level = 1;
-               else if (total_flags < 25000) power_level = 2;
+               else if (total_flags < 35000) power_level = 2;
                else power_level = 3;
        }
 
        else
        {
+               /* For weapons */
                if (a_cursed) power_level = 0;
                else if (total_flags < 20000) power_level = 1;
-               else if (total_flags < 35000) power_level = 2;
+               else if (total_flags < 45000) power_level = 2;
                else power_level = 3;
        }
 
        if (a_scroll)
        {
-               char dummy_name[80];
-               strcpy(dummy_name, "");
-               (void)identify_fully_aux(o_ptr);
-
+               char dummy_name[80] = "";
 #ifdef JP
-               if (!(get_string("¤³¤Î¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤ò²¿¤È̾ÉÕ¤±¤Þ¤¹¤«¡©", dummy_name, 80)))
+               cptr ask_msg = "¤³¤Î¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤ò²¿¤È̾ÉÕ¤±¤Þ¤¹¤«¡©";
 #else
-               if (!(get_string("What do you want to call the artifact? ", dummy_name, 80)))
+               cptr ask_msg = "What do you want to call the artifact? ";
 #endif
 
-               {
-                       get_random_name(new_name, (bool)(o_ptr->tval >= TV_BOOTS), power_level);
-               }
-               else
-               {
-#ifdef JP
-                       strcpy(new_name, "¡Ô");
-#else
-                       strcpy(new_name, "'");
-#endif
-
-                       strcat(new_name, dummy_name);
-#ifdef JP
-                       strcat(new_name, "¡Õ¤È¤¤¤¦Ì¾¤Î");
-#else
-                       strcat(new_name, "'");
-#endif
-
-               }
                /* Identify it fully */
                object_aware(o_ptr);
                object_known(o_ptr);
@@ -1741,31 +1943,48 @@ bool create_artifact(object_type *o_ptr, bool a_scroll)
                /* Mark the item as fully known */
                o_ptr->ident |= (IDENT_MENTAL);
 
+               /* For being treated as random artifact in screen_object() */
+               o_ptr->art_name = quark_add("");
+
+               (void)screen_object(o_ptr, 0L);
+
+               if (!get_string(ask_msg, dummy_name, sizeof dummy_name)
+                   || !dummy_name[0])
+               {
+                       /* Cancelled */
+                       if (one_in_(2))
+                       {
+                               get_table_sindarin_aux(dummy_name);
+                       }
+                       else
+                       {
+                               get_table_name_aux(dummy_name);
+                       }
+               }
+
+#ifdef JP
+               sprintf(new_name, "¡Ô%s¡Õ", dummy_name);
+#else
+               sprintf(new_name, "'%s'", dummy_name);
+#endif
+
                chg_virtue(V_INDIVIDUALISM, 2);
                chg_virtue(V_ENCHANT, 5);
-
        }
        else
        {
-               get_random_name(new_name, (bool)(o_ptr->tval >= TV_BOOTS), power_level);
+               get_random_name(new_name, object_is_armour(o_ptr), power_level);
        }
 
        if (cheat_xtra)
        {
-               if (artifact_bias)
-#ifdef JP
-msg_format("±¿¤ÎÊФä¿¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È: %d¡£", artifact_bias);
-#else
-                       msg_format("Biased artifact: %d.", artifact_bias);
-#endif
-
-               else
 #ifdef JP
-msg_print("¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤Ë±¿¤ÎÊФê¤Ê¤·¡£");
+               if (artifact_bias) msg_format("±¿¤ÎÊФä¿¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È: %d¡£", artifact_bias);
+               else msg_print("¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤Ë±¿¤ÎÊФê¤Ê¤·¡£");
 #else
-                       msg_print("No bias in artifact.");
+               if (artifact_bias) msg_format("Biased artifact: %d.", artifact_bias);
+               else msg_print("No bias in artifact.");
 #endif
-
        }
 
        /* Save the inscription */
@@ -1778,15 +1997,115 @@ msg_print("
 }
 
 
-bool activate_random_artifact(object_type * o_ptr)
+int activation_index(object_type *o_ptr)
+{
+       /* Give priority to weaponsmith's essential activations */
+       if (object_is_smith(o_ptr))
+       {
+               switch (o_ptr->xtra3-1)
+               {
+               case ESSENCE_TMP_RES_ACID: return ACT_RESIST_ACID;
+               case ESSENCE_TMP_RES_ELEC: return ACT_RESIST_ELEC;
+               case ESSENCE_TMP_RES_FIRE: return ACT_RESIST_FIRE;
+               case ESSENCE_TMP_RES_COLD: return ACT_RESIST_COLD;
+               case TR_IMPACT: return ACT_QUAKE;
+               }
+       }
+
+       if (object_is_fixed_artifact(o_ptr))
+       {
+               if (have_flag(a_info[o_ptr->name1].flags, TR_ACTIVATE))
+               {
+                       return a_info[o_ptr->name1].act_idx;
+               }
+       }
+       if (object_is_ego(o_ptr))
+       {
+               if (have_flag(e_info[o_ptr->name2].flags, TR_ACTIVATE))
+               {
+                       return e_info[o_ptr->name2].act_idx;
+               }
+       }
+       if (!object_is_random_artifact(o_ptr))
+       {
+               if (have_flag(k_info[o_ptr->k_idx].flags, TR_ACTIVATE))
+               {
+                       return k_info[o_ptr->k_idx].act_idx;
+               }
+       }
+
+       return o_ptr->xtra2;
+}
+
+const activation_type* find_activation_info(object_type *o_ptr)
+{
+       const int index = activation_index(o_ptr);
+       const activation_type* p;
+
+       for (p = activation_info; p->flag != NULL; ++ p) {
+               if (p->index == index)
+               {
+                       return p;
+               }
+       }
+
+       return NULL;
+}
+
+
+/* Dragon breath activation */
+static bool activate_dragon_breath(object_type *o_ptr)
+{
+       u32b flgs[4]; /* for resistance flags */
+       int type[20];
+       cptr name[20];
+       int i, dir, t, n = 0;
+
+       if (!get_aim_dir(&dir)) return FALSE;
+
+       object_flags(o_ptr, flgs);
+
+       for (i = 0; dragonbreath_info[i].flag != 0; i++)
+       {
+               if (have_flag(flgs, dragonbreath_info[i].flag))
+               {
+                       type[n] = dragonbreath_info[i].type;
+                       name[n] = dragonbreath_info[i].name;
+                       n++;
+               }
+       }
+
+       /* Paranoia */
+       if (n == 0) return FALSE;
+
+       /* Stop speaking */
+       if (music_singing_any()) stop_singing();
+       if (hex_spelling_any()) stop_hex_spell_all();
+
+       t = randint0(n);
+       msg_format(_("¤¢¤Ê¤¿¤Ï%s¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£", "You breathe %s."), name[t]);
+       fire_ball(type[t], dir, 250, -4);
+
+       return TRUE;
+}
+
+
+bool activate_random_artifact(object_type *o_ptr)
 {
        int plev = p_ptr->lev;
        int k, dir, dummy = 0;
-
-       if (!o_ptr->art_name) return FALSE; /* oops? */
+       cptr name = k_name + k_info[o_ptr->k_idx].name;
+       const activation_type* const act_ptr = find_activation_info(o_ptr);
+
+       /* Paranoia */
+       if (!act_ptr) {
+               /* Maybe forgot adding information to activation_info table ? */
+               msg_print("Activation information is not found.");
+               return FALSE;
+       }
 
        /* Activate for attack */
-       switch (o_ptr->xtra2)
+       switch (act_ptr->index)
        {
                case ACT_SUNLIGHT:
                {
@@ -1796,9 +2115,7 @@ bool activate_random_artifact(object_type * o_ptr)
 #else
                        msg_print("A line of sunlight appears.");
 #endif
-
-                       (void)lite_line(dir);
-                       o_ptr->timeout = 10;
+                       (void)lite_line(dir, damroll(6, 8));
                        break;
                }
 
@@ -1809,10 +2126,8 @@ bool activate_random_artifact(object_type * o_ptr)
 #else
                        msg_print("It glows extremely brightly...");
 #endif
-
                        if (!get_aim_dir(&dir)) return FALSE;
                        fire_bolt(GF_MISSILE, dir, damroll(2, 6));
-                       o_ptr->timeout = 2;
                        break;
                }
 
@@ -1823,10 +2138,8 @@ bool activate_random_artifact(object_type * o_ptr)
 #else
                        msg_print("It throbs deep green...");
 #endif
-
                        if (!get_aim_dir(&dir)) return FALSE;
                        fire_ball(GF_POIS, dir, 12, 3);
-                       o_ptr->timeout = rand_int(4) + 4;
                        break;
                }
 
@@ -1837,10 +2150,8 @@ bool activate_random_artifact(object_type * o_ptr)
 #else
                        msg_print("It is covered in sparks...");
 #endif
-
                        if (!get_aim_dir(&dir)) return FALSE;
                        fire_bolt(GF_ELEC, dir, damroll(4, 8));
-                       o_ptr->timeout = rand_int(5) + 5;
                        break;
                }
 
@@ -1851,10 +2162,8 @@ bool activate_random_artifact(object_type * o_ptr)
 #else
                        msg_print("It is covered in acid...");
 #endif
-
                        if (!get_aim_dir(&dir)) return FALSE;
                        fire_bolt(GF_ACID, dir, damroll(5, 8));
-                       o_ptr->timeout = rand_int(6) + 6;
                        break;
                }
 
@@ -1865,10 +2174,8 @@ bool activate_random_artifact(object_type * o_ptr)
 #else
                        msg_print("It is covered in frost...");
 #endif
-
                        if (!get_aim_dir(&dir)) return FALSE;
                        fire_bolt(GF_COLD, dir, damroll(6, 8));
-                       o_ptr->timeout = rand_int(7) + 7;
                        break;
                }
 
@@ -1879,10 +2186,8 @@ bool activate_random_artifact(object_type * o_ptr)
 #else
                        msg_print("It is covered in fire...");
 #endif
-
                        if (!get_aim_dir(&dir)) return FALSE;
                        fire_bolt(GF_FIRE, dir, damroll(9, 8));
-                       o_ptr->timeout = rand_int(8) + 8;
                        break;
                }
 
@@ -1893,10 +2198,8 @@ bool activate_random_artifact(object_type * o_ptr)
 #else
                        msg_print("It is covered in frost...");
 #endif
-
                        if (!get_aim_dir(&dir)) return FALSE;
                        fire_ball(GF_COLD, dir, 48, 2);
-                       o_ptr->timeout = 400;
                        break;
                }
 
@@ -1907,918 +2210,1760 @@ bool activate_random_artifact(object_type * o_ptr)
 #else
                        msg_print("It glows an intense red...");
 #endif
-
                        if (!get_aim_dir(&dir)) return FALSE;
                        fire_ball(GF_FIRE, dir, 72, 2);
-                       o_ptr->timeout = 400;
                        break;
                }
 
                case ACT_DRAIN_1:
                {
 #ifdef JP
-                       msg_print("¤½¤ì¤Ï¹õ¤¯µ±¤¤¤¿...");
+                       msg_format("¤¢¤Ê¤¿¤Ï%s¤ËŨ¤òÄù¤á»¦¤¹¤è¤¦Ì¿¤¸¤¿¡£", name);
+#else
+                       msg_format("You order the %s to strangle your opponent.", name);
+#endif
+                       if (!get_aim_dir(&dir)) return FALSE;
+                       if (drain_life(dir, 100))
+                       break;
+               }
+
+               case ACT_BA_COLD_2:
+               {
+#ifdef JP
+                       msg_print("¤½¤ì¤ÏÀĤ¯·ã¤·¤¯µ±¤¤¤¿...");
+#else
+                       msg_print("It glows an intense blue...");
+#endif
+                       if (!get_aim_dir(&dir)) return FALSE;
+                       fire_ball(GF_COLD, dir, 100, 2);
+                       break;
+               }
+
+               case ACT_BA_ELEC_2:
+               {
+#ifdef JP
+                       msg_print("Åŵ¤¤¬¥Ñ¥Á¥Ñ¥Á²»¤òΩ¤Æ¤¿...");
+#else
+                       msg_print("It crackles with electricity...");
+#endif
+                       if (!get_aim_dir(&dir)) return FALSE;
+                       fire_ball(GF_ELEC, dir, 100, 3);
+                       break;
+               }
+
+               case ACT_BA_FIRE_2:
+               {
+#ifdef JP
+                       msg_format("%s¤«¤é±ê¤¬¿á¤­½Ð¤·¤¿...", name);
+#else
+                       msg_format("The %s rages in fire...", name);
+#endif
+                       if (!get_aim_dir(&dir)) return FALSE;
+                       fire_ball(GF_FIRE, dir, 120, 3);
+                       break;
+               }
+
+               case ACT_DRAIN_2:
+               {
+#ifdef JP
+                       msg_print("¹õ¤¯µ±¤¤¤Æ¤¤¤ë...");
+#else
+                       msg_print("It glows black...");
+#endif
+                       if (!get_aim_dir(&dir)) return FALSE;
+                       drain_life(dir, 120);
+                       break;
+               }
+
+               case ACT_VAMPIRE_1:
+               {
+                       if (!get_aim_dir(&dir)) return FALSE;
+                       for (dummy = 0; dummy < 3; dummy++)
+                       {
+                               if (drain_life(dir, 50))
+                               hp_player(50);
+                       }
+                       break;
+               }
+
+               case ACT_BO_MISS_2:
+               {
+#ifdef JP
+                       msg_print("ËâË¡¤Î¥È¥²¤¬¸½¤ì¤¿...");
+#else
+                       msg_print("It grows magical spikes...");
+#endif
+                       if (!get_aim_dir(&dir)) return FALSE;
+                       fire_bolt(GF_ARROW, dir, 150);
+                       break;
+               }
+
+               case ACT_BA_FIRE_3:
+               {
+#ifdef JP
+                       msg_print("¿¼ÀÖ¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
+#else
+                       msg_print("It glows deep red...");
+#endif
+                       if (!get_aim_dir(&dir)) return FALSE;
+                       fire_ball(GF_FIRE, dir, 300, 3);
+                       break;
+               }
+
+               case ACT_BA_COLD_3:
+               {
+#ifdef JP
+                       msg_print("ÌÀ¤ë¤¯Çò¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
+#else
+                       msg_print("It glows bright white...");
+#endif
+                       if (!get_aim_dir(&dir)) return FALSE;
+                       fire_ball(GF_COLD, dir, 400, 3);
+                       break;
+               }
+
+               case ACT_BA_ELEC_3:
+               {
+#ifdef JP
+                       msg_print("¿¼ÀÄ¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
+#else
+                       msg_print("It glows deep blue...");
+#endif
+                       if (!get_aim_dir(&dir)) return FALSE;
+                       fire_ball(GF_ELEC, dir, 500, 3);
+                       break;
+               }
+
+               case ACT_WHIRLWIND:
+               {
+                       {
+                               int y = 0, x = 0;
+                               cave_type       *c_ptr;
+                               monster_type    *m_ptr;
+
+                               for (dir = 0; dir <= 9; dir++)
+                               {
+                                       y = py + ddy[dir];
+                                       x = px + ddx[dir];
+                                       c_ptr = &cave[y][x];
+
+                                       /* Get the monster */
+                                       m_ptr = &m_list[c_ptr->m_idx];
+
+                                       /* Hack -- attack monsters */
+                                       if (c_ptr->m_idx && (m_ptr->ml || cave_have_flag_bold(y, x, FF_PROJECT)))
+                                               py_attack(y, x, 0);
+                               }
+                       }
+                       break;
+               }
+
+               case ACT_VAMPIRE_2:
+               {
+                       if (!get_aim_dir(&dir)) return FALSE;
+                       for (dummy = 0; dummy < 3; dummy++)
+                       {
+                               if (drain_life(dir, 100))
+                               hp_player(100);
+                       }
+                       break;
+               }
+
+
+               case ACT_CALL_CHAOS:
+               {
+#ifdef JP
+                       msg_print("ÍÍ¡¹¤Ê¿§¤Î²Ð²Ö¤òȯ¤·¤Æ¤¤¤ë...");
+#else
+                       msg_print("It glows in scintillating colours...");
+#endif
+                       call_chaos();
+                       break;
+               }
+
+               case ACT_ROCKET:
+               {
+                       if (!get_aim_dir(&dir)) return FALSE;
+#ifdef JP
+                       msg_print("¥í¥±¥Ã¥È¤òȯ¼Í¤·¤¿¡ª");
+#else
+                       msg_print("You launch a rocket!");
+#endif
+                       fire_ball(GF_ROCKET, dir, 250 + plev*3, 2);
+                       break;
+               }
+
+               case ACT_DISP_EVIL:
+               {
+#ifdef JP
+                       msg_print("¿ÀÀ»¤ÊÊ·°Ïµ¤¤¬½¼Ëþ¤·¤¿...");
+#else
+                       msg_print("It floods the area with goodness...");
+#endif
+                       dispel_evil(p_ptr->lev * 5);
+                       break;
+               }
+
+               case ACT_BA_MISS_3:
+               {
+                       if (!get_aim_dir(&dir)) return FALSE;
+#ifdef JP
+                       msg_print("¤¢¤Ê¤¿¤Ï¥¨¥ì¥á¥ó¥È¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
+#else
+                       msg_print("You breathe the elements.");
+#endif
+                       fire_ball(GF_MISSILE, dir, 300, -4);
+                       break;
+               }
+
+               case ACT_DISP_GOOD:
+               {
+#ifdef JP
+                       msg_print("¼Ù°­¤ÊÊ·°Ïµ¤¤¬½¼Ëþ¤·¤¿...");
+#else
+                       msg_print("It floods the area with evil...");
+#endif
+                       dispel_good(p_ptr->lev * 5);
+                       break;
+               }
+
+               case ACT_BO_MANA:
+               {
+#ifdef JP
+                       msg_format("%s¤ËËâË¡¤Î¥È¥²¤¬¸½¤ì¤¿...", name);
+#else
+                       msg_format("The %s grows magical spikes...", name);
+#endif
+                       if (!get_aim_dir(&dir)) return FALSE;
+                       fire_bolt(GF_ARROW, dir, 150);
+                       break;
+               }
+
+               case ACT_BA_WATER:
+               {
+#ifdef JP
+                       msg_format("%s¤¬¿¼¤¤ÀÄ¿§¤Ë¸ÝÆ°¤·¤Æ¤¤¤ë...", name);
+#else
+                       msg_format("The %s throbs deep blue...", name);
+#endif
+                       if (!get_aim_dir(&dir)) return FALSE;
+                       fire_ball(GF_WATER, dir, 200, 3);
+                       break;
+               }
+
+               case ACT_BA_DARK:
+               {
+#ifdef JP
+                       msg_format("%s¤¬¿¼¤¤°Ç¤Ëʤ¤ï¤ì¤¿...", name);
+#else
+                       msg_format("The %s is coverd in pitch-darkness...", name);
+#endif
+                       if (!get_aim_dir(&dir)) return FALSE;
+                       fire_ball(GF_DARK, dir, 250, 4);
+                       break;
+               }
+
+               case ACT_BA_MANA:
+               {
+#ifdef JP
+                       msg_format("%s¤¬ÀÄÇò¤¯¸÷¤Ã¤¿¡¥¡¥¡¥", name);
+#else
+                       msg_format("The %s glows pale...", name);
+#endif
+                       if (!get_aim_dir(&dir)) return FALSE;
+                       fire_ball(GF_MANA, dir, 250, 4);
+                       break;
+               }
+
+               case ACT_PESTICIDE:
+               {
+#ifdef JP
+                       msg_print("¤¢¤Ê¤¿¤Ï³²Ãî¤ò°ìÁݤ·¤¿¡£");
+#else
+                       msg_print("You exterminate small life.");
+#endif
+                       (void)dispel_monsters(4);
+                       break;
+               }
+
+               case ACT_BLINDING_LIGHT:
+               {
+#ifdef JP
+                       msg_format("%s¤¬âÁ¤·¤¤¸÷¤Çµ±¤¤¤¿...", name);
+#else
+                       msg_format("The %s gleams with blinding light...", name);
+#endif
+                       fire_ball(GF_LITE, 0, 300, 6);
+                       confuse_monsters(3 * p_ptr->lev / 2);
+                       break;
+               }
+
+               case ACT_BIZARRE:
+               {
+#ifdef JP
+                       msg_format("%s¤Ï¼¿¹õ¤Ëµ±¤¤¤¿...", name);
+#else
+                       msg_format("The %s glows intensely black...", name);
+#endif
+                       if (!get_aim_dir(&dir)) return FALSE;
+                       ring_of_power(dir);
+                       break;
+               }
+
+               case ACT_CAST_BA_STAR:
+               {
+                       int num = damroll(5, 3);
+                       int y, x;
+                       int attempts;
+#ifdef JP
+                       msg_format("%s¤¬°ðºÊ¤Çʤ¤ï¤ì¤¿...", name);
+#else
+                       msg_format("The %s is surrounded by lightning...", name);
+#endif
+                       for (k = 0; k < num; k++)
+                       {
+                               attempts = 1000;
+
+                               while (attempts--)
+                               {
+                                       scatter(&y, &x, py, px, 4, 0);
+
+                                       if (!cave_have_flag_bold(y, x, FF_PROJECT)) continue;
+
+                                       if (!player_bold(y, x)) break;
+                               }
+
+                               project(0, 3, y, x, 150, GF_ELEC,
+                                                       (PROJECT_THRU | PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL), -1);
+                       }
+
+                       break;
+               }
+
+               case ACT_BLADETURNER:
+               {
+                       if (!get_aim_dir(&dir)) return FALSE;
+#ifdef JP
+                       msg_print("¤¢¤Ê¤¿¤Ï¥¨¥ì¥á¥ó¥È¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
+#else
+                       msg_print("You breathe the elements.");
+#endif
+                       fire_ball(GF_MISSILE, dir, 300, -4);
+#ifdef JP
+                       msg_print("³»¤¬ÍÍ¡¹¤Ê¿§¤Ëµ±¤¤¤¿...");
+#else
+                       msg_print("Your armor glows many colours...");
+#endif
+                       (void)set_afraid(0);
+                       (void)set_hero(randint1(50) + 50, FALSE);
+                       (void)hp_player(10);
+                       (void)set_blessed(randint1(50) + 50, FALSE);
+                       (void)set_oppose_acid(randint1(50) + 50, FALSE);
+                       (void)set_oppose_elec(randint1(50) + 50, FALSE);
+                       (void)set_oppose_fire(randint1(50) + 50, FALSE);
+                       (void)set_oppose_cold(randint1(50) + 50, FALSE);
+                       (void)set_oppose_pois(randint1(50) + 50, FALSE);
+                       break;
+               }
+               case ACT_BA_ACID_1:
+               {
+                       if (!get_aim_dir(&dir)) return FALSE;
+                       fire_ball(GF_ACID, dir, 100, 2);
+                       break;
+               }
+
+               case ACT_BR_FIRE:
+               {
+                       if (!get_aim_dir(&dir)) return FALSE;
+                       fire_ball(GF_FIRE, dir, 200, -2);
+                       if ((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_FLAMES))
+                       {
+                               (void)set_oppose_fire(randint1(20) + 20, FALSE);
+                       }
+                       break;
+               }
+               case ACT_BR_COLD:
+               {
+                       if (!get_aim_dir(&dir)) return FALSE;
+                       fire_ball(GF_COLD, dir, 200, -2);
+                       if ((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_ICE))
+                       {
+                               (void)set_oppose_cold(randint1(20) + 20, FALSE);
+                       }
+                       break;
+               }
+               case ACT_BR_DRAGON:
+               {
+                       if (!activate_dragon_breath(o_ptr)) return FALSE;
+                       break;
+               }
+
+               /* Activate for other offensive action */
+
+               case ACT_CONFUSE:
+               {
+#ifdef JP
+                       msg_print("ÍÍ¡¹¤Ê¿§¤Î²Ð²Ö¤òȯ¤·¤Æ¤¤¤ë...");
+#else
+                       msg_print("It glows in scintillating colours...");
+#endif
+                       if (!get_aim_dir(&dir)) return FALSE;
+                       confuse_monster(dir, 20);
+                       break;
+               }
+
+               case ACT_SLEEP:
+               {
+#ifdef JP
+                       msg_print("¿¼ÀÄ¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
+#else
+                       msg_print("It glows deep blue...");
+#endif
+                       sleep_monsters_touch();
+                       break;
+               }
+
+               case ACT_QUAKE:
+               {
+                       earthquake(py, px, 5);
+                       break;
+               }
+
+               case ACT_TERROR:
+               {
+                       turn_monsters(40 + p_ptr->lev);
+                       break;
+               }
+
+               case ACT_TELE_AWAY:
+               {
+                       if (!get_aim_dir(&dir)) return FALSE;
+                       (void)fire_beam(GF_AWAY_ALL, dir, plev);
+                       break;
+               }
+
+               case ACT_BANISH_EVIL:
+               {
+                       if (banish_evil(100))
+                       {
+#ifdef JP
+                               msg_print("¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤ÎÎϤ¬¼Ù°­¤òÂǤÁʧ¤Ã¤¿¡ª");
+#else
+                               msg_print("The power of the artifact banishes evil!");
+#endif
+                       }
+                       break;
+               }
+
+               case ACT_GENOCIDE:
+               {
+#ifdef JP
+                       msg_print("¿¼ÀÄ¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
+#else
+                       msg_print("It glows deep blue...");
+#endif
+                       (void)symbol_genocide(200, TRUE);
+                       break;
+               }
+
+               case ACT_MASS_GENO:
+               {
+#ifdef JP
+                       msg_print("¤Ò¤É¤¯±Ô¤¤²»¤¬Î®¤ì½Ð¤¿...");
+#else
+                       msg_print("It lets out a long, shrill note...");
+#endif
+                       (void)mass_genocide(200, TRUE);
+                       break;
+               }
+
+               case ACT_SCARE_AREA:
+               {
+                       if (music_singing_any()) stop_singing();
+                       if (hex_spelling_any()) stop_hex_spell_all();
+#ifdef JP
+                       msg_print("¤¢¤Ê¤¿¤ÏÎ϶¯¤¤ÆÍÉ÷¤ò¿á¤­ÌĤ餷¤¿¡£¼þ°Ï¤ÎŨ¤¬¿Ì¤¨¾å¤Ã¤Æ¤¤¤ë!");
+#else
+                       msg_print("You wind a mighty blast; your enemies tremble!");
+#endif
+                       (void)turn_monsters((3 * p_ptr->lev / 2) + 10);
+                       break;
+               }
+
+               case ACT_AGGRAVATE:
+               {
+                       if (o_ptr->name1 == ART_HYOUSIGI)
+                       {
+#ifdef JP
+                               msg_print("Çï»ÒÌÚ¤òÂǤä¿¡£");
+#else
+                               msg_print("You beat Your wooden clappers.");
+#endif
+                       }
+                       else
+                       {
+#ifdef JP
+                               msg_format("%s¤ÏÉÔ²÷¤Êʪ²»¤òΩ¤Æ¤¿¡£", name);
+#else
+                               msg_format("The %s sounds an unpleasant noise.", name);
+#endif
+                       }
+                       aggravate_monsters(0);
+                       break;
+               }
+
+               /* Activate for summoning / charming */
+
+               case ACT_CHARM_ANIMAL:
+               {
+                       if (!get_aim_dir(&dir)) return FALSE;
+                       (void)charm_animal(dir, plev * 2);
+                       break;
+               }
+
+               case ACT_CHARM_UNDEAD:
+               {
+                       if (!get_aim_dir(&dir)) return FALSE;
+                       (void)control_one_undead(dir, plev * 2);
+                       break;
+               }
+
+               case ACT_CHARM_OTHER:
+               {
+                       if (!get_aim_dir(&dir)) return FALSE;
+                       (void)charm_monster(dir, plev * 2);
+                       break;
+               }
+
+               case ACT_CHARM_ANIMALS:
+               {
+                       (void)charm_animals(plev * 2);
+                       break;
+               }
+
+               case ACT_CHARM_OTHERS:
+               {
+                       charm_monsters(plev * 2);
+                       break;
+               }
+
+               case ACT_SUMMON_ANIMAL:
+               {
+                       (void)summon_specific(-1, py, px, plev, SUMMON_ANIMAL_RANGER, (PM_ALLOW_GROUP | PM_FORCE_PET));
+                       break;
+               }
+
+               case ACT_SUMMON_PHANTOM:
+               {
+#ifdef JP
+                       msg_print("¸¸Îî¤ò¾¤´­¤·¤¿¡£");
+#else
+                       msg_print("You summon a phantasmal servant.");
+#endif
+                       (void)summon_specific(-1, py, px, dun_level, SUMMON_PHANTOM, (PM_ALLOW_GROUP | PM_FORCE_PET));
+                       break;
+               }
+
+               case ACT_SUMMON_ELEMENTAL:
+               {
+                       bool pet = one_in_(3);
+                       u32b mode = 0L;
+
+                       if (!(pet && (plev < 50))) mode |= PM_ALLOW_GROUP;
+                       if (pet) mode |= PM_FORCE_PET;
+                       else mode |= PM_NO_PET;
+
+                       if (summon_specific((pet ? -1 : 0), py, px, ((plev * 3) / 2), SUMMON_ELEMENTAL, mode))
+                       {
+#ifdef JP
+                               msg_print("¥¨¥ì¥á¥ó¥¿¥ë¤¬¸½¤ì¤¿...");
+#else
+                               msg_print("An elemental materializes...");
+#endif
+                               if (pet)
+#ifdef JP
+                                       msg_print("¤¢¤Ê¤¿¤ËÉþ½¾¤·¤Æ¤¤¤ë¤è¤¦¤À¡£");
+#else
+                                       msg_print("It seems obedient to you.");
+#endif
+                               else
+#ifdef JP
+                                       msg_print("¤½¤ì¤ò¥³¥ó¥È¥í¡¼¥ë¤Ç¤­¤Ê¤«¤Ã¤¿¡ª");
+#else
+                                       msg_print("You fail to control it!");
+#endif
+                       }
+
+                       break;
+               }
+
+               case ACT_SUMMON_DEMON:
+               {
+                       bool pet = one_in_(3);
+                       u32b mode = 0L;
+
+                       if (!(pet && (plev < 50))) mode |= PM_ALLOW_GROUP;
+                       if (pet) mode |= PM_FORCE_PET;
+                       else mode |= PM_NO_PET;
+
+                       if (summon_specific((pet ? -1 : 0), py, px, ((plev * 3) / 2), SUMMON_DEMON, mode))
+                       {
+#ifdef JP
+                               msg_print("ⲫ¤Î°­½­¤¬½¼Ëþ¤·¤¿¡£");
+#else
+                               msg_print("The area fills with a stench of sulphur and brimstone.");
+#endif
+                               if (pet)
+#ifdef JP
+                                       msg_print("¡Ö¤´ÍѤǤ´¤¶¤¤¤Þ¤¹¤«¡¢¤´¼ç¿ÍÍÍ¡×");
+#else
+                                       msg_print("'What is thy bidding... Master?'");
+#endif
+                               else
+#ifdef JP
+                                       msg_print("¡ÖNON SERVIAM! Wretch! ¤ªÁ°¤Îº²¤òĺ¤¯¤¾¡ª¡×");
 #else
-                       msg_print("It glows black...");
+                                       msg_print("'NON SERVIAM! Wretch! I shall feast on thy mortal soul!'");
 #endif
+                       }
 
-                       if (!get_aim_dir(&dir)) return FALSE;
-                       if (drain_life(dir, 100))
-                       o_ptr->timeout = rand_int(100) + 100;
                        break;
                }
 
-               case ACT_BA_COLD_2:
+               case ACT_SUMMON_UNDEAD:
                {
+                       bool pet = one_in_(3);
+                       int type;
+                       u32b mode = 0L;
+
+                       type = (plev > 47 ? SUMMON_HI_UNDEAD : SUMMON_UNDEAD);
+
+                       if (!pet || ((plev > 24) && one_in_(3))) mode |= PM_ALLOW_GROUP;
+                       if (pet) mode |= PM_FORCE_PET;
+                       else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
+
+                       if (summon_specific((pet ? -1 : 0), py, px, ((plev * 3) / 2), type, mode))
+                       {
 #ifdef JP
-                       msg_print("¤½¤ì¤ÏÀĤ¯·ã¤·¤¯µ±¤¤¤¿...");
+                               msg_print("Î䤿¤¤É÷¤¬¤¢¤Ê¤¿¤Î¼þ¤ê¤Ë¿á¤­»Ï¤á¤¿¡£¤½¤ì¤ÏÉåÇÔ½­¤ò±¿¤ó¤Ç¤¤¤ë...");
 #else
-                       msg_print("It glows an intense blue...");
+                               msg_print("Cold winds begin to blow around you, carrying with them the stench of decay...");
 #endif
-
-                       if (!get_aim_dir(&dir)) return FALSE;
-                       fire_ball(GF_COLD, dir, 100, 2);
-                       o_ptr->timeout = 300;
-                       break;
-               }
-
-               case ACT_BA_ELEC_2:
-               {
+                               if (pet)
 #ifdef JP
-                       msg_print("Åŵ¤¤¬¥Ñ¥Á¥Ñ¥Á²»¤òΩ¤Æ¤¿...");
+                                       msg_print("¸Å¤¨¤Î»à¤»¤ë¼Ô¶¦¤¬¤¢¤Ê¤¿¤Ë»Å¤¨¤ë¤¿¤áÅÚ¤«¤éᴤä¿¡ª");
 #else
-                       msg_print("It crackles with electricity...");
+                                       msg_print("Ancient, long-dead forms arise from the ground to serve you!");
 #endif
-
-                       if (!get_aim_dir(&dir)) return FALSE;
-                       fire_ball(GF_ELEC, dir, 100, 3);
-                       o_ptr->timeout = 500;
-                       break;
-               }
-
-               case ACT_DRAIN_2:
-               {
+                               else
 #ifdef JP
-                       msg_print("¹õ¤¯µ±¤¤¤Æ¤¤¤ë...");
+                                       msg_print("»à¼Ô¤¬á´¤Ã¤¿¡£Ì²¤ê¤ò˸¤²¤ë¤¢¤Ê¤¿¤òȳ¤¹¤ë¤¿¤á¤Ë¡ª");
 #else
-                       msg_print("It glows black...");
+                                       msg_print("'The dead arise... to punish you for disturbing them!'");
 #endif
+                       }
 
-                       if (!get_aim_dir(&dir)) return FALSE;
-                       drain_life(dir, 120);
-                       o_ptr->timeout = 400;
                        break;
                }
 
-               case ACT_VAMPIRE_1:
+               case ACT_SUMMON_HOUND:
                {
-                       if (!get_aim_dir(&dir)) return FALSE;
-                       for (dummy = 0; dummy < 3; dummy++)
+                       u32b mode = PM_ALLOW_GROUP;
+                       bool pet = !one_in_(5);
+                       if (pet) mode |= PM_FORCE_PET;
+                       else mode |= PM_NO_PET;
+
+                       if (summon_specific((pet ? -1 : 0), py, px, ((p_ptr->lev * 3) / 2), SUMMON_HOUND, mode))
                        {
-                               if (drain_life(dir, 50))
-                               hp_player(50);
-                       }
-                       o_ptr->timeout = 400;
-                       break;
-               }
 
-               case ACT_BO_MISS_2:
-               {
+                               if (pet)
 #ifdef JP
-                       msg_print("ËâË¡¤Î¥È¥²¤¬¸½¤ì¤¿...");
+                                       msg_print("¥Ï¥¦¥ó¥É¤¬¤¢¤Ê¤¿¤Î²¼ËͤȤ·¤Æ½Ð¸½¤·¤¿¡£");
 #else
-                       msg_print("It grows magical spikes...");
+                               msg_print("A group of hounds appear as your servant.");
 #endif
 
-                       if (!get_aim_dir(&dir)) return FALSE;
-                       fire_bolt(GF_ARROW, dir, 150);
-                       o_ptr->timeout = rand_int(90) + 90;
-                       break;
-               }
-
-               case ACT_BA_FIRE_2:
-               {
+                               else
 #ifdef JP
-                       msg_print("¿¼ÀÖ¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
+                                       msg_print("¥Ï¥¦¥ó¥É¤Ï¤¢¤Ê¤¿¤Ë²ç¤ò¸þ¤±¤Æ¤¤¤ë¡ª");
 #else
-                       msg_print("It glows deep red...");
+                                       msg_print("A group of hounds appear as your enemy!");
 #endif
 
-                       if (!get_aim_dir(&dir)) return FALSE;
-                       fire_ball(GF_FIRE, dir, 120, 3);
-                       o_ptr->timeout = rand_int(225) + 225;
+                       }
+
                        break;
                }
 
-               case ACT_BA_COLD_3:
+               case ACT_SUMMON_DAWN:
                {
 #ifdef JP
-                       msg_print("ÌÀ¤ë¤¯Çò¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
+                       msg_print("¶Ç¤Î»ÕÃĤò¾¤´­¤·¤¿¡£");
 #else
-                       msg_print("It glows bright white...");
+                       msg_print("You summon the Legion of the Dawn.");
 #endif
-
-                       if (!get_aim_dir(&dir)) return FALSE;
-                       fire_ball(GF_COLD, dir, 200, 3);
-                       o_ptr->timeout = rand_int(325) + 325;
+                       (void)summon_specific(-1, py, px, dun_level, SUMMON_DAWN, (PM_ALLOW_GROUP | PM_FORCE_PET));
                        break;
                }
 
-               case ACT_BA_ELEC_3:
+               case ACT_SUMMON_OCTOPUS:
                {
+                       u32b mode = PM_ALLOW_GROUP;
+                       bool pet = !one_in_(5);
+                       if (pet) mode |= PM_FORCE_PET;
+
+                       if (summon_named_creature(0, py, px, MON_JIZOTAKO, mode))
+                       {
+                               if (pet)
 #ifdef JP
-                       msg_print("¿¼ÀÄ¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
+                                       msg_print("Âý¤¬¤¢¤Ê¤¿¤Î²¼ËͤȤ·¤Æ½Ð¸½¤·¤¿¡£");
 #else
-                       msg_print("It glows deep blue...");
+                                       msg_print("A group of octopuses appear as your servant.");
 #endif
+                               else
+#ifdef JP
+                                       msg_print("Âý¤Ï¤¢¤Ê¤¿¤òâˤó¤Ç¤¤¤ë¡ª");
+#else
+                                       msg_print("A group of octopuses appear as your enemy!");
+#endif
+                       }
 
-                       if (!get_aim_dir(&dir)) return FALSE;
-                       fire_ball(GF_ELEC, dir, 250, 3);
-                       o_ptr->timeout = rand_int(425) + 425;
                        break;
                }
 
-               case ACT_WHIRLWIND:
-               {
-                       {
-                               int y = 0, x = 0;
-                               cave_type       *c_ptr;
-                               monster_type    *m_ptr;
-
-                               for (dir = 0; dir <= 9; dir++)
-                               {
-                                       y = py + ddy[dir];
-                                       x = px + ddx[dir];
-                                       c_ptr = &cave[y][x];
-
-                                       /* Get the monster */
-                                       m_ptr = &m_list[c_ptr->m_idx];
+               /* Activate for healing */
 
-                                       /* Hack -- attack monsters */
-                                       if (c_ptr->m_idx && (m_ptr->ml || cave_floor_bold(y, x)))
-                                               py_attack(y, x, 0);
-                               }
-                       }
-                       o_ptr->timeout = 250;
+               case ACT_CHOIR_SINGS:
+               {
+#ifdef JP
+                       msg_print("Å·¹ñ¤Î²Î¤¬Ê¹¤³¤¨¤ë...");
+#else
+                       msg_print("A heavenly choir sings...");
+#endif
+                       (void)set_poisoned(0);
+                       (void)set_cut(0);
+                       (void)set_stun(0);
+                       (void)set_confused(0);
+                       (void)set_blind(0);
+                       (void)set_afraid(0);
+                       (void)set_hero(randint1(25) + 25, FALSE);
+                       (void)hp_player(777);
                        break;
                }
 
-               case ACT_VAMPIRE_2:
+               case ACT_CURE_LW:
                {
-                       if (!get_aim_dir(&dir)) return FALSE;
-                       for (dummy = 0; dummy < 3; dummy++)
-                       {
-                               if (drain_life(dir, 100))
-                               hp_player(100);
-                       }
-
-                       o_ptr->timeout = 400;
+                       (void)set_afraid(0);
+                       (void)hp_player(30);
                        break;
                }
 
-
-               case ACT_CALL_CHAOS:
+               case ACT_CURE_MW:
                {
 #ifdef JP
-                       msg_print("ÍÍ¡¹¤Ê¿§¤Î²Ð²Ö¤òȯ¤·¤Æ¤¤¤ë...");
+                       msg_print("¿¼»ç¿§¤Î¸÷¤òȯ¤·¤Æ¤¤¤ë...");
 #else
-                       msg_print("It glows in scintillating colours...");
+                       msg_print("It radiates deep purple...");
 #endif
-
-                       call_chaos();
-                       o_ptr->timeout = 350;
+                       hp_player(damroll(4, 8));
+                       (void)set_cut((p_ptr->cut / 2) - 50);
                        break;
                }
 
-               case ACT_ROCKET:
+               case ACT_CURE_POISON:
                {
-                       if (!get_aim_dir(&dir)) return FALSE;
 #ifdef JP
-                       msg_print("¥í¥±¥Ã¥È¤òȯ¼Í¤·¤¿¡ª");
+                       msg_print("¿¼ÀÄ¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
 #else
-                       msg_print("You launch a rocket!");
+                       msg_print("It glows deep blue...");
 #endif
-
-                       fire_ball(GF_ROCKET, dir, 120 + plev, 2);
-                       o_ptr->timeout = 400;
+                       (void)set_afraid(0);
+                       (void)set_poisoned(0);
                        break;
                }
 
-               case ACT_DISP_EVIL:
+               case ACT_REST_LIFE:
                {
 #ifdef JP
-                       msg_print("¿ÀÀ»¤ÊÊ·°Ïµ¤¤¬½¼Ëþ¤·¤¿...");
+                       msg_print("¿¼¹È¤Ëµ±¤¤¤Æ¤¤¤ë...");
 #else
-                       msg_print("It floods the area with goodness...");
+                       msg_print("It glows a deep red...");
 #endif
-
-                       dispel_evil(p_ptr->lev * 5);
-                       o_ptr->timeout = rand_int(300) + 300;
+                       restore_level();
                        break;
                }
 
-               case ACT_DISP_GOOD:
+               case ACT_REST_ALL:
                {
 #ifdef JP
-                       msg_print("¼Ù°­¤ÊÊ·°Ïµ¤¤¬½¼Ëþ¤·¤¿...");
+                       msg_print("Ç»Îп§¤Ëµ±¤¤¤Æ¤¤¤ë...");
 #else
-                       msg_print("It floods the area with evil...");
+                       msg_print("It glows a deep green...");
 #endif
-
-                       dispel_good(p_ptr->lev * 5);
-                       o_ptr->timeout = rand_int(300) + 300;
+                       (void)do_res_stat(A_STR);
+                       (void)do_res_stat(A_INT);
+                       (void)do_res_stat(A_WIS);
+                       (void)do_res_stat(A_DEX);
+                       (void)do_res_stat(A_CON);
+                       (void)do_res_stat(A_CHR);
+                       (void)restore_level();
                        break;
                }
 
-               case ACT_BA_MISS_3:
+               case ACT_CURE_700:
                {
-                       if (!get_aim_dir(&dir)) return FALSE;
 #ifdef JP
-                       msg_print("¤¢¤Ê¤¿¤Ï¥¨¥ì¥á¥ó¥È¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
+                       msg_print("¿¼ÀÄ¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
+                       msg_print("ÂÎÆâ¤ËÃȤ«¤¤¸ÝÆ°¤¬´¶¤¸¤é¤ì¤ë...");
 #else
-                       msg_print("You breathe the elements.");
+                       msg_print("It glows deep blue...");
+                       msg_print("You feel a warm tingling inside...");
 #endif
-
-                       fire_ball(GF_MISSILE, dir, 300, 4);
-                       o_ptr->timeout = 500;
+                       (void)hp_player(700);
+                       (void)set_cut(0);
                        break;
                }
 
-               /* Activate for other offensive action */
-
-               case ACT_CONFUSE:
+               case ACT_CURE_1000:
                {
 #ifdef JP
-                       msg_print("ÍÍ¡¹¤Ê¿§¤Î²Ð²Ö¤òȯ¤·¤Æ¤¤¤ë...");
+                       msg_print("Çò¤¯ÌÀ¤ë¤¯µ±¤¤¤Æ¤¤¤ë...");
+                       msg_print("¤Ò¤¸¤ç¤¦¤Ëµ¤Ê¬¤¬¤è¤¤...");
 #else
-                       msg_print("It glows in scintillating colours...");
+                       msg_print("It glows a bright white...");
+                       msg_print("You feel much better...");
 #endif
-
-                       if (!get_aim_dir(&dir)) return FALSE;
-                       confuse_monster(dir, 20);
-                       o_ptr->timeout = 15;
+                       (void)hp_player(1000);
+                       (void)set_cut(0);
                        break;
                }
 
-               case ACT_SLEEP:
+               case ACT_CURING:
                {
 #ifdef JP
-                       msg_print("¿¼ÀÄ¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
+                       msg_format("%s¤ÎÍ¥¤·¤µ¤ËÌþ¤µ¤ì¤ë...", name);
 #else
-                       msg_print("It glows deep blue...");
+                       msg_format("the %s cures you affectionately ...", name);
 #endif
+                       (void)set_poisoned(0);
+                       (void)set_confused(0);
+                       (void)set_blind(0);
+                       (void)set_stun(0);
+                       (void)set_cut(0);
+                       (void)set_image(0);
 
-                       sleep_monsters_touch();
-                       o_ptr->timeout = 55;
                        break;
                }
 
-               case ACT_QUAKE:
+               case ACT_CURE_MANA_FULL:
                {
-                       earthquake(py, px, 10);
-                       o_ptr->timeout = 50;
+#ifdef JP
+                       msg_format("%s¤¬ÀÄÇò¤¯¸÷¤Ã¤¿¡¥¡¥¡¥", name);
+#else
+                       msg_format("The %s glows pale...", name);
+#endif
+                       if (p_ptr->pclass == CLASS_MAGIC_EATER)
+                       {
+                               int i;
+                               for (i = 0; i < EATER_EXT*2; i++)
+                               {
+                                       p_ptr->magic_num1[i] += (p_ptr->magic_num2[i] < 10) ? EATER_CHARGE * 3 : p_ptr->magic_num2[i]*EATER_CHARGE/3;
+                                       if (p_ptr->magic_num1[i] > p_ptr->magic_num2[i]*EATER_CHARGE) p_ptr->magic_num1[i] = p_ptr->magic_num2[i]*EATER_CHARGE;
+                               }
+                               for (; i < EATER_EXT*3; i++)
+                               {
+                                       int k_idx = lookup_kind(TV_ROD, i-EATER_EXT*2);
+                                       p_ptr->magic_num1[i] -= ((p_ptr->magic_num2[i] < 10) ? EATER_ROD_CHARGE*3 : p_ptr->magic_num2[i]*EATER_ROD_CHARGE/3)*k_info[k_idx].pval;
+                                       if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;
+                               }
+#ifdef JP
+                               msg_print("Ƭ¤¬¥Ï¥Ã¥­¥ê¤È¤·¤¿¡£");
+#else
+                               msg_print("You feel your head clear.");
+#endif
+                               p_ptr->window |= (PW_PLAYER);
+                       }
+                       else if (p_ptr->csp < p_ptr->msp)
+                       {
+                               p_ptr->csp = p_ptr->msp;
+                               p_ptr->csp_frac = 0;
+#ifdef JP
+                               msg_print("Ƭ¤¬¥Ï¥Ã¥­¥ê¤È¤·¤¿¡£");
+#else
+                               msg_print("You feel your head clear.");
+#endif
+                               p_ptr->redraw |= (PR_MANA);
+                               p_ptr->window |= (PW_PLAYER);
+                               p_ptr->window |= (PW_SPELL);
+                       }
                        break;
                }
 
-               case ACT_TERROR:
-               {
-                       turn_monsters(40 + p_ptr->lev);
-                       o_ptr->timeout = 3 * (p_ptr->lev + 10);
-                       break;
-               }
+               /* Activate for timed effect */
 
-               case ACT_TELE_AWAY:
+               case ACT_ESP:
                {
-                       if (!get_aim_dir(&dir)) return FALSE;
-                       (void)fire_beam(GF_AWAY_ALL, dir, plev);
-                       o_ptr->timeout = 200;
+                       (void)set_tim_esp(randint1(30) + 25, FALSE);
                        break;
                }
 
-               case ACT_BANISH_EVIL:
+               case ACT_BERSERK:
                {
-                       if (banish_evil(100))
-                       {
-#ifdef JP
-                               msg_print("¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤ÎÎϤ¬¼Ù°­¤òÂǤÁÅݤ·¤¿¡ª");
-#else
-                               msg_print("The power of the artifact banishes evil!");
-#endif
-
-                       }
-                       o_ptr->timeout = 250 + randint(250);
+                       (void)set_afraid(0);
+                       (void)set_shero(randint1(25) + 25, FALSE);
+                       /* (void)set_afraid(0);
+                       (void)set_hero(randint1(50) + 50, FALSE);
+                       (void)set_blessed(randint1(50) + 50, FALSE);
+                       o_ptr->timeout = 100 + randint1(100); */
                        break;
                }
 
-               case ACT_GENOCIDE:
+               case ACT_PROT_EVIL:
                {
 #ifdef JP
-                       msg_print("¿¼ÀÄ¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
+                       msg_format("%s¤«¤é±Ô¤¤²»¤¬Î®¤ì½Ð¤¿...", name);
 #else
-                       msg_print("It glows deep blue...");
+                       msg_format("The %s lets out a shrill wail...", name);
 #endif
-
-                       (void)symbol_genocide(200, TRUE);
-                       o_ptr->timeout = 500;
+                       k = 3 * p_ptr->lev;
+                       (void)set_protevil(randint1(25) + k, FALSE);
                        break;
                }
 
-               case ACT_MASS_GENO:
+               case ACT_RESIST_ALL:
                {
 #ifdef JP
-                       msg_print("¤Ò¤É¤¯±Ô¤¤²»¤¬Î®¤ì½Ð¤¿...");
+                       msg_print("ÍÍ¡¹¤Ê¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
 #else
-                       msg_print("It lets out a long, shrill note...");
+                       msg_print("It glows many colours...");
 #endif
-
-                       (void)mass_genocide(200, TRUE);
-                       o_ptr->timeout = 1000;
+                       (void)set_oppose_acid(randint1(40) + 40, FALSE);
+                       (void)set_oppose_elec(randint1(40) + 40, FALSE);
+                       (void)set_oppose_fire(randint1(40) + 40, FALSE);
+                       (void)set_oppose_cold(randint1(40) + 40, FALSE);
+                       (void)set_oppose_pois(randint1(40) + 40, FALSE);
                        break;
                }
 
-               /* Activate for summoning / charming */
-
-               case ACT_CHARM_ANIMAL:
+               case ACT_SPEED:
                {
-                       if (!get_aim_dir(&dir)) return FALSE;
-                       (void)charm_animal(dir, plev);
-                       o_ptr->timeout = 300;
+#ifdef JP
+                       msg_print("ÌÀ¤ë¤¯Îп§¤Ëµ±¤¤¤Æ¤¤¤ë...");
+#else
+                       msg_print("It glows bright green...");
+#endif
+                       (void)set_fast(randint1(20) + 20, FALSE);
                        break;
                }
 
-               case ACT_CHARM_UNDEAD:
+               case ACT_XTRA_SPEED:
                {
-                       if (!get_aim_dir(&dir)) return FALSE;
-                       (void)control_one_undead(dir, plev);
-                       o_ptr->timeout = 333;
+#ifdef JP
+                       msg_print("ÌÀ¤ë¤¯µ±¤¤¤Æ¤¤¤ë...");
+#else
+                       msg_print("It glows brightly...");
+#endif
+                       (void)set_fast(randint1(75) + 75, FALSE);
                        break;
                }
 
-               case ACT_CHARM_OTHER:
+               case ACT_WRAITH:
                {
-                       if (!get_aim_dir(&dir)) return FALSE;
-                       (void)charm_monster(dir, plev);
-                       o_ptr->timeout = 400;
+                       set_wraith_form(randint1(plev / 2) + (plev / 2), FALSE);
                        break;
                }
 
-               case ACT_CHARM_ANIMALS:
+               case ACT_INVULN:
                {
-                       (void)charm_animals(plev * 2);
-                       o_ptr->timeout = 500;
+                       (void)set_invuln(randint1(8) + 8, FALSE);
                        break;
                }
 
-               case ACT_CHARM_OTHERS:
+               case ACT_HELO:
                {
-                       charm_monsters(plev * 2);
-                       o_ptr->timeout = 750;
+                       (void)set_afraid(0);
+                       set_hero(randint1(25)+25, FALSE);
+                       hp_player(10);
                        break;
                }
 
-               case ACT_SUMMON_ANIMAL:
+               case ACT_HELO_SPEED:
                {
-                       (void)summon_specific(-1, py, px, plev, SUMMON_ANIMAL_RANGER, TRUE, TRUE, TRUE, FALSE, FALSE);
-                       o_ptr->timeout = 200 + randint(300);
+                       (void)set_fast(randint1(50) + 50, FALSE);
+                       hp_player(10);
+                       set_afraid(0);
+                       set_hero(randint1(50) + 50, FALSE);
                        break;
                }
 
-               case ACT_SUMMON_PHANTOM:
+               case ACT_RESIST_ACID:
                {
 #ifdef JP
-                       msg_print("¸¸Îî¤ò¾¤´­¤·¤¿¡£");
+                       msg_format("%s¤¬¹õ¤¯µ±¤¤¤¿...", name);
 #else
-                       msg_print("You summon a phantasmal servant.");
+                       msg_format("The %s grows black.", name);
 #endif
-
-                       (void)summon_specific(-1, py, px, dun_level, SUMMON_PHANTOM, TRUE, TRUE, TRUE, FALSE, FALSE);
-                       o_ptr->timeout = 200 + randint(200);
+                       if ((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_ACID))
+                       {
+                               if (!get_aim_dir(&dir)) return FALSE;
+                               fire_ball(GF_ACID, dir, 100, 2);
+                       }
+                       (void)set_oppose_acid(randint1(20) + 20, FALSE);
                        break;
                }
 
-               case ACT_SUMMON_ELEMENTAL:
+               case ACT_RESIST_FIRE:
                {
-                       bool pet = (randint(3) == 1);
-                       bool group = !(pet && (plev < 50));
-
-                       if (summon_specific((pet ? -1 : 0), py, px, ((plev * 3) / 2), SUMMON_ELEMENTAL, group, FALSE, pet, FALSE, (bool)(!pet)))
-                       {
 #ifdef JP
-                               msg_print("¥¨¥ì¥á¥ó¥¿¥ë¤¬¸½¤ì¤¿...");
+                       msg_format("%s¤¬ÀÖ¤¯µ±¤¤¤¿...", name);
 #else
-                               msg_print("An elemental materializes...");
+                       msg_format("The %s grows red.", name);
 #endif
+                       if ((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_FLAMES))
+                       {
+                               if (!get_aim_dir(&dir)) return FALSE;
+                               fire_ball(GF_FIRE, dir, 100, 2);
+                       }
+                       (void)set_oppose_fire(randint1(20) + 20, FALSE);
+                       break;
+               }
 
-
-                               if (pet)
+               case ACT_RESIST_COLD:
+               {
 #ifdef JP
-                                       msg_print("¤¢¤Ê¤¿¤ËÉþ½¾¤·¤Æ¤¤¤ë¤è¤¦¤À¡£");
+                       msg_format("%s¤¬Çò¤¯µ±¤¤¤¿...", name);
 #else
-                                       msg_print("It seems obedient to you.");
+                       msg_format("The %s grows white.", name);
 #endif
+                       if ((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_ICE))
+                       {
+                               if (!get_aim_dir(&dir)) return FALSE;
+                               fire_ball(GF_COLD, dir, 100, 2);
+                       }
+                       (void)set_oppose_cold(randint1(20) + 20, FALSE);
+                       break;
+               }
 
-                               else
+               case ACT_RESIST_ELEC:
+               {
 #ifdef JP
-                                       msg_print("¤½¤ì¤ò¥³¥ó¥È¥í¡¼¥ë¤Ç¤­¤Ê¤«¤Ã¤¿¡ª");
+                       msg_format("%s¤¬ÀĤ¯µ±¤¤¤¿...", name);
 #else
-                                       msg_print("You fail to control it!");
+                       msg_format("The %s grows blue.", name);
 #endif
-
+                       if ((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_ELEC))
+                       {
+                               if (!get_aim_dir(&dir)) return FALSE;
+                               fire_ball(GF_ELEC, dir, 100, 2);
                        }
-
-                       o_ptr->timeout = 750;
+                       (void)set_oppose_elec(randint1(20) + 20, FALSE);
                        break;
                }
 
-               case ACT_SUMMON_DEMON:
+               case ACT_RESIST_POIS:
                {
-                       bool pet = (randint(3) == 1);
-                       bool group = !(pet && (plev < 50));
-
-                       if (summon_specific((pet ? -1 : 0), py, px, ((plev * 3) / 2), SUMMON_DEMON, group, FALSE, pet, FALSE, (bool)(!pet)))
-                       {
 #ifdef JP
-                               msg_print("ⲫ¤Î°­½­¤¬½¼Ëþ¤·¤¿¡£");
+                       msg_format("%s¤¬ÎФ˵±¤¤¤¿...", name);
 #else
-                               msg_print("The area fills with a stench of sulphur and brimstone.");
+                       msg_format("The %s grows green.", name);
 #endif
+                       (void)set_oppose_pois(randint1(20) + 20, FALSE);
+                       break;
+               }
 
-                               if (pet)
+               /* Activate for general purpose effect (detection etc.) */
+
+               case ACT_LIGHT:
+               {
 #ifdef JP
-                                       msg_print("¡Ö¤´ÍѤǤ´¤¶¤¤¤Þ¤¹¤«¡¢¤´¼ç¿ÍÍÍ¡×");
+                       msg_format("%s¤«¤éÀ¡¤ó¤À¸÷¤¬¤¢¤Õ¤ì½Ð¤¿...", name);
 #else
-                                       msg_print("'What is thy bidding... Master?'");
+                       msg_format("The %s wells with clear light...", name);
 #endif
+                       lite_area(damroll(2, 15), 3);
+                       break;
+               }
 
-                               else
+               case ACT_MAP_LIGHT:
+               {
 #ifdef JP
-                                       msg_print("¡ÖNON SERVIAM! Wretch! ¤ªÁ°¤Îº²¤òĺ¤¯¤¾¡ª¡×");
+                       msg_print("âÁ¤·¤¯µ±¤¤¤¿...");
 #else
-                                       msg_print("'NON SERVIAM! Wretch! I shall feast on thy mortal soul!'");
+                       msg_print("It shines brightly...");
 #endif
-
-                       }
-
-                       o_ptr->timeout = 666 + randint(333);
+                       map_area(DETECT_RAD_MAP);
+                       lite_area(damroll(2, 15), 3);
                        break;
                }
 
-               case ACT_SUMMON_UNDEAD:
+               case ACT_DETECT_ALL:
                {
-                       bool pet = (randint(3) == 1);
-                       bool group;
-                       bool unique_okay;
-                       int type;
-
-                       type = (plev > 47 ? SUMMON_HI_UNDEAD : SUMMON_UNDEAD);
-                       if (pet)
-                       {
-                               group = (((plev > 24) && (randint(3) == 1)) ? TRUE : FALSE);
-                               unique_okay = FALSE;
-                       }
-                       else
-                       {
-                               group = TRUE;
-                               unique_okay = TRUE;
-                       }
-
-                       if (summon_specific((pet ? -1 : 0), py, px, ((plev * 3) / 2), type,
-                                           group, FALSE, pet, unique_okay, (bool)(!pet)))
-                       {
 #ifdef JP
-                               msg_print("Î䤿¤¤É÷¤¬¤¢¤Ê¤¿¤Î¼þ¤ê¤Ë¿á¤­»Ï¤á¤¿¡£¤½¤ì¤ÏÉåÇÔ½­¤ò±¿¤ó¤Ç¤¤¤ë...");
+                       msg_print("Çò¤¯ÌÀ¤ë¤¯µ±¤¤¤Æ¤¤¤ë...");
+                       msg_print("¿´¤Ë¥¤¥á¡¼¥¸¤¬É⤫¤ó¤Ç¤­¤¿...");
 #else
-                               msg_print("Cold winds begin to blow around you, carrying with them the stench of decay...");
+                       msg_print("It glows bright white...");
+                       msg_print("An image forms in your mind...");
 #endif
+                       detect_all(DETECT_RAD_DEFAULT);
+                       break;
+               }
 
-                               if (pet)
+               case ACT_DETECT_XTRA:
+               {
 #ifdef JP
-                                       msg_print("¸Å¤¨¤Î»à¤»¤ë¼Ô¶¦¤¬¤¢¤Ê¤¿¤Ë»Å¤¨¤ë¤¿¤áÅÚ¤«¤éᴤä¿¡ª");
+                       msg_print("ÌÀ¤ë¤¯µ±¤¤¤Æ¤¤¤ë...");
 #else
-                                       msg_print("Ancient, long-dead forms arise from the ground to serve you!");
+                       msg_print("It glows brightly...");
 #endif
+                       detect_all(DETECT_RAD_DEFAULT);
+                       probing();
+                       identify_fully(FALSE);
+                       break;
+               }
 
-                               else
+               case ACT_ID_FULL:
+               {
 #ifdef JP
-                                       msg_print("»à¼Ô¤¬á´¤Ã¤¿¡£Ì²¤ê¤ò˸¤²¤ë¤¢¤Ê¤¿¤òȳ¤¹¤ë¤¿¤á¤Ë¡ª");
+                       msg_print("²«¿§¤¯µ±¤¤¤Æ¤¤¤ë...");
 #else
-                                       msg_print("'The dead arise... to punish you for disturbing them!'");
+                       msg_print("It glows yellow...");
 #endif
-
-                       }
-
-                       o_ptr->timeout = 666 + randint(333);
+                       identify_fully(FALSE);
                        break;
                }
 
-               /* Activate for healing */
-
-               case ACT_CURE_LW:
+               case ACT_ID_PLAIN:
                {
-                       (void)set_afraid(0);
-                       (void)hp_player(30);
-                       o_ptr->timeout = 10;
+                       if (!ident_spell(FALSE)) return FALSE;
                        break;
                }
 
-               case ACT_CURE_MW:
+               case ACT_RUNE_EXPLO:
                {
 #ifdef JP
-                       msg_print("¿¼»ç¿§¤Î¸÷¤òȯ¤·¤Æ¤¤¤ë...");
+                       msg_print("ÌÀ¤ë¤¤ÀÖ¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
 #else
-                       msg_print("It radiates deep purple...");
+                       msg_print("It glows bright red...");
 #endif
-
-                       hp_player(damroll(4, 8));
-                       (void)set_cut((p_ptr->cut / 2) - 50);
-                       o_ptr->timeout = rand_int(3) + 3;
+                       explosive_rune();
                        break;
                }
 
-               case ACT_CURE_POISON:
+               case ACT_RUNE_PROT:
                {
 #ifdef JP
-                       msg_print("¿¼ÀÄ¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
+                       msg_print("¥Ö¥ë¡¼¤ËÌÀ¤ë¤¯µ±¤¤¤Æ¤¤¤ë...");
 #else
-                       msg_print("It glows deep blue...");
+                       msg_print("It glows light blue...");
 #endif
+                       warding_glyph();
+                       break;
+               }
 
-                       (void)set_afraid(0);
-                       (void)set_poisoned(0);
-                       o_ptr->timeout = 5;
+               case ACT_SATIATE:
+               {
+                       (void)set_food(PY_FOOD_MAX - 1);
                        break;
                }
 
-               case ACT_REST_LIFE:
+               case ACT_DEST_DOOR:
                {
 #ifdef JP
-                       msg_print("¿¼¹È¤Ëµ±¤¤¤Æ¤¤¤ë...");
+                       msg_print("ÌÀ¤ë¤¤ÀÖ¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
 #else
-                       msg_print("It glows a deep red...");
+                       msg_print("It glows bright red...");
 #endif
-
-                       restore_level();
-                       o_ptr->timeout = 450;
+                       destroy_doors_touch();
                        break;
                }
 
-               case ACT_REST_ALL:
+               case ACT_STONE_MUD:
                {
 #ifdef JP
-                       msg_print("Ç»Îп§¤Ëµ±¤¤¤Æ¤¤¤ë...");
+                       msg_print("¸ÝÆ°¤·¤Æ¤¤¤ë...");
 #else
-                       msg_print("It glows a deep green...");
+                       msg_print("It pulsates...");
 #endif
+                       if (!get_aim_dir(&dir)) return FALSE;
+                       wall_to_mud(dir, 20 + randint1(30));
+                       break;
+               }
 
-                       (void)do_res_stat(A_STR);
-                       (void)do_res_stat(A_INT);
-                       (void)do_res_stat(A_WIS);
-                       (void)do_res_stat(A_DEX);
-                       (void)do_res_stat(A_CON);
-                       (void)do_res_stat(A_CHR);
-                       (void)restore_level();
-                       o_ptr->timeout = 750;
+               case ACT_RECHARGE:
+               {
+                       recharge(130);
                        break;
                }
 
-               case ACT_CURE_700:
+               case ACT_ALCHEMY:
                {
 #ifdef JP
-                       msg_print("¿¼ÀÄ¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
+                       msg_print("ÌÀ¤ë¤¤²«¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
 #else
-                       msg_print("It glows deep blue...");
+                       msg_print("It glows bright yellow...");
 #endif
+                       (void)alchemy();
+                       break;
+               }
 
+               case ACT_DIM_DOOR:
+               {
 #ifdef JP
-                       msg_print("ÂÎÆâ¤ËÃȤ«¤¤¸ÝÆ°¤¬´¶¤¸¤é¤ì¤ë...");
+                       msg_print("¼¡¸µ¤ÎÈ⤬³«¤¤¤¿¡£ÌÜŪÃϤòÁª¤ó¤Ç²¼¤µ¤¤¡£");
 #else
-                       msg_print("You feel a warm tingling inside...");
+                       msg_print("You open a dimensional gate. Choose a destination.");
 #endif
-
-                       (void)hp_player(700);
-                       (void)set_cut(0);
-                       o_ptr->timeout = 250;
+                       if (!dimension_door()) return FALSE;
                        break;
                }
 
-               case ACT_CURE_1000:
+
+               case ACT_TELEPORT:
                {
 #ifdef JP
-                       msg_print("Çò¤¯ÌÀ¤ë¤¯µ±¤¤¤Æ¤¤¤ë...");
+                       msg_print("¼þ¤ê¤Î¶õ´Ö¤¬ÏĤó¤Ç¤¤¤ë...");
 #else
-                       msg_print("It glows a bright white...");
+                       msg_print("It twists space around you...");
 #endif
+                       teleport_player(100, 0L);
+                       break;
+               }
 
+               case ACT_RECALL:
+               {
 #ifdef JP
-                       msg_print("¤Ò¤¸¤ç¤¦¤Ëµ¤Ê¬¤¬¤è¤¤...");
+                       msg_print("¤ä¤ï¤é¤«¤ÊÇò¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
 #else
-                       msg_print("You feel much better...");
+                       msg_print("It glows soft white...");
 #endif
-
-                       (void)hp_player(1000);
-                       (void)set_cut(0);
-                       o_ptr->timeout = 888;
+                       if (!word_of_recall()) return FALSE;
                        break;
                }
 
-               /* Activate for timed effect */
-
-               case ACT_ESP:
+               case ACT_JUDGE:
                {
-                       (void)set_tim_esp(randint(30) + 25, FALSE);
-                       o_ptr->timeout = 200;
-                       break;
-               }
+#ifdef JP
+                       msg_format("%s¤ÏÀÖ¤¯ÌÀ¤ë¤¯¸÷¤Ã¤¿¡ª", name);
+#else
+                       msg_format("The %s flashes bright red!", name);
+#endif
+                       chg_virtue(V_KNOWLEDGE, 1);
+                       chg_virtue(V_ENLIGHTEN, 1);
+                       wiz_lite(FALSE);
+#ifdef JP
+                       msg_format("%s¤Ï¤¢¤Ê¤¿¤ÎÂÎÎϤòÃ¥¤Ã¤¿...", name);
+                       take_hit(DAMAGE_LOSELIFE, damroll(3,8), "¿³È½¤ÎÊõÀÐ", -1);
+#else
+                       msg_format("The %s drains your vitality...", name);
+                       take_hit(DAMAGE_LOSELIFE, damroll(3, 8), "the Jewel of Judgement", -1);
+#endif
+                       (void)detect_traps(DETECT_RAD_DEFAULT, TRUE);
+                       (void)detect_doors(DETECT_RAD_DEFAULT);
+                       (void)detect_stairs(DETECT_RAD_DEFAULT);
+#ifdef JP
+                       if (get_check("µ¢´Ô¤ÎÎϤò»È¤¤¤Þ¤¹¤«¡©"))
+#else
+                       if (get_check("Activate recall? "))
+#endif
+                       {
+                               (void)word_of_recall();
+                       }
 
-               case ACT_BERSERK:
-               {
-                       (void)set_hero(randint(50) + 50, FALSE);
-                       (void)set_blessed(randint(50) + 50, FALSE);
-                       o_ptr->timeout = 100 + randint(100);
                        break;
                }
 
-               case ACT_PROT_EVIL:
+               case ACT_TELEKINESIS:
                {
+                       if (!get_aim_dir(&dir)) return FALSE;
 #ifdef JP
-                       msg_print("±Ô¤¤²»¤¬Î®¤ì½Ð¤¿...");
+                       msg_format("%s¤ò¿­¤Ð¤·¤¿¡£", name);
 #else
-                       msg_print("It lets out a shrill wail...");
+                       msg_format("You stretched your %s.", name);
 #endif
-
-                       k = 3 * p_ptr->lev;
-                       (void)set_protevil(randint(25) + k, FALSE);
-                       o_ptr->timeout = rand_int(225) + 225;
+                       fetch(dir, 500, TRUE);
                        break;
                }
 
-               case ACT_RESIST_ALL:
+               case ACT_DETECT_UNIQUE:
                {
+                       int i;
+                       monster_type *m_ptr;
+                       monster_race *r_ptr;
 #ifdef JP
-                       msg_print("ÍÍ¡¹¤Ê¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
+                       msg_print("´ñ̯¤Ê¾ì½ê¤¬Æ¬¤ÎÃæ¤ËÉ⤫¤ó¤À¡¥¡¥¡¥");
 #else
-                       msg_print("It glows many colours...");
+                       msg_print("Some strange places show up in your mind. And you see ...");
 #endif
+                       /* Process the monsters (backwards) */
+                       for (i = m_max - 1; i >= 1; i--)
+                       {
+                               /* Access the monster */
+                               m_ptr = &m_list[i];
 
-                       (void)set_oppose_acid(randint(40) + 40, FALSE);
-                       (void)set_oppose_elec(randint(40) + 40, FALSE);
-                       (void)set_oppose_fire(randint(40) + 40, FALSE);
-                       (void)set_oppose_cold(randint(40) + 40, FALSE);
-                       (void)set_oppose_pois(randint(40) + 40, FALSE);
-                       o_ptr->timeout = 200;
-                       break;
-               }
+                               /* Ignore "dead" monsters */
+                               if (!m_ptr->r_idx) continue;
 
-               case ACT_SPEED:
-               {
+                               r_ptr = &r_info[m_ptr->r_idx];
+
+                               if(r_ptr->flags1 & RF1_UNIQUE)
+                               {
 #ifdef JP
-                       msg_print("ÌÀ¤ë¤¯Îп§¤Ëµ±¤¤¤Æ¤¤¤ë...");
+                                       msg_format("%s¡¥ ",r_name + r_ptr->name);
 #else
-                       msg_print("It glows bright green...");
+                                       msg_format("%s. ",r_name + r_ptr->name);
 #endif
-
-                       (void)set_fast(randint(20) + 20, FALSE);
-                       o_ptr->timeout = 250;
+                               }
+                       }
                        break;
                }
 
-               case ACT_XTRA_SPEED:
+               case ACT_ESCAPE:
                {
+                       switch (randint1(13))
+                       {
+                       case 1: case 2: case 3: case 4: case 5:
+                               teleport_player(10, 0L);
+                               break;
+                       case 6: case 7: case 8: case 9: case 10:
+                               teleport_player(222, 0L);
+                               break;
+                       case 11: case 12:
+                               (void)stair_creation();
+                               break;
+                       default:
 #ifdef JP
-                       msg_print("ÌÀ¤ë¤¯µ±¤¤¤Æ¤¤¤ë...");
+                               if (get_check("¤³¤Î³¬¤òµî¤ê¤Þ¤¹¤«¡©"))
 #else
-                       msg_print("It glows brightly...");
+                               if (get_check("Leave this level? "))
 #endif
+                               {
+                                       if (autosave_l) do_cmd_save_game(TRUE);
 
-                       (void)set_fast(randint(75) + 75, FALSE);
-                       o_ptr->timeout = rand_int(200) + 200;
-                       break;
-               }
-
-               case ACT_WRAITH:
-               {
-                       set_wraith_form(randint(plev / 2) + (plev / 2), FALSE);
-                       o_ptr->timeout = 1000;
+                                       /* Leaving */
+                                       p_ptr->leaving = TRUE;
+                               }
+                       }
                        break;
                }
 
-               case ACT_INVULN:
+               case ACT_DISP_CURSE_XTRA:
                {
-                       (void)set_invuln(randint(8) + 8, FALSE);
-                       o_ptr->timeout = 1000;
+#ifdef JP
+                       msg_format("%s¤¬¿¿¼Â¤ò¾È¤é¤·½Ð¤¹...", name);
+#else
+                       msg_format("The %s exhibits the truth...", name);
+#endif
+                       if (remove_all_curse())
+                       {
+#ifdef JP
+                               msg_print("狼¤Ë¸«¼é¤é¤ì¤Æ¤¤¤ë¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
+#else
+                               msg_print("You feel as if someone is watching over you.");
+#endif
+                       }
+                       (void)probing();
                        break;
                }
 
-               /* Activate for general purpose effect (detection etc.) */
-
-               case ACT_LIGHT:
+               case ACT_BRAND_FIRE_BOLTS:
                {
 #ifdef JP
-                       msg_print("À¡¤ó¤À¸÷¤¬¤¢¤Õ¤ì½Ð¤¿...");
+                       msg_format("%s¤¬¿¼¹È¤Ëµ±¤¤¤¿...", name);
 #else
-                       msg_print("It wells with clear light...");
+                       msg_format("Your %s glows deep red...", name);
 #endif
-
-                       lite_area(damroll(2, 15), 3);
-                       o_ptr->timeout = rand_int(10) + 10;
+                       (void)brand_bolts();
                        break;
                }
 
-               case ACT_MAP_LIGHT:
+               case ACT_RECHARGE_XTRA:
                {
 #ifdef JP
-                       msg_print("âÁ¤·¤¯µ±¤¤¤¿...");
+                       msg_format("%s¤¬Çò¤¯µ±¤¤¤¿¡¥¡¥¡¥", name);
 #else
-                       msg_print("It shines brightly...");
+                       msg_format("The %s gleams with blinding light...", name);
 #endif
-
-                       map_area(DETECT_RAD_MAP);
-                       lite_area(damroll(2, 15), 3);
-                       o_ptr->timeout = rand_int(50) + 50;
+                       if (!recharge(1000)) return FALSE;
                        break;
                }
 
-               case ACT_DETECT_ALL:
+               case ACT_LORE:
                {
 #ifdef JP
-                       msg_print("Çò¤¯ÌÀ¤ë¤¯µ±¤¤¤Æ¤¤¤ë...");
+                       msg_print("ÀФ¬±£¤µ¤ì¤¿ÈëÌ©¤ò¼Ì¤·½Ð¤·¤¿¡¥¡¥¡¥");
 #else
-                       msg_print("It glows bright white...");
+                       msg_print("The stone reveals hidden mysteries...");
 #endif
+                       if (!ident_spell(FALSE)) return FALSE;
+
+                       if (mp_ptr->spell_book)
+                       {
+                               /* Sufficient mana */
+                               if (20 <= p_ptr->csp)
+                               {
+                                       /* Use some mana */
+                                       p_ptr->csp -= 20;
+                               }
+
+                               /* Over-exert the player */
+                               else
+                               {
+                                       int oops = 20 - p_ptr->csp;
 
+                                       /* No mana left */
+                                       p_ptr->csp = 0;
+                                       p_ptr->csp_frac = 0;
+
+                                       /* Message */
 #ifdef JP
-                       msg_print("¿´¤Ë¥¤¥á¡¼¥¸¤¬É⤫¤ó¤Ç¤­¤¿...");
+                                       msg_print("ÀФòÀ©¸æ¤Ç¤­¤Ê¤¤¡ª");
 #else
-                       msg_print("An image forms in your mind...");
+                                       msg_print("You are too weak to control the stone!");
 #endif
+                                       /* Hack -- Bypass free action */
+                                       (void)set_paralyzed(p_ptr->paralyzed +
+                                               randint1(5 * oops + 1));
 
-                       detect_all(DETECT_RAD_DEFAULT);
-                       o_ptr->timeout = rand_int(55) + 55;
-                       break;
-               }
+                                       /* Confusing. */
+                                       (void)set_confused(p_ptr->confused +
+                                               randint1(5 * oops + 1));
+                               }
 
-               case ACT_DETECT_XTRA:
-               {
+                               /* Redraw mana */
+                               p_ptr->redraw |= (PR_MANA);
+                       }
 #ifdef JP
-                       msg_print("ÌÀ¤ë¤¯µ±¤¤¤Æ¤¤¤ë...");
+                       take_hit(DAMAGE_LOSELIFE, damroll(1, 12), "´í¸±¤ÊÈëÌ©", -1);
 #else
-                       msg_print("It glows brightly...");
+                       take_hit(DAMAGE_LOSELIFE, damroll(1, 12), "perilous secrets", -1);
 #endif
+                       /* Confusing. */
+                       if (one_in_(5)) (void)set_confused(p_ptr->confused +
+                               randint1(10));
 
-                       detect_all(DETECT_RAD_DEFAULT);
-                       probing();
-                       identify_fully(FALSE);
-                       o_ptr->timeout = 1000;
+                       /* Exercise a little care... */
+                       if (one_in_(20))
+#ifdef JP
+                               take_hit(DAMAGE_LOSELIFE, damroll(4, 10), "´í¸±¤ÊÈëÌ©", -1);
+#else
+                               take_hit(DAMAGE_LOSELIFE, damroll(4, 10), "perilous secrets", -1);
+#endif
                        break;
                }
 
-               case ACT_ID_FULL:
+               case ACT_SHIKOFUMI:
                {
 #ifdef JP
-                       msg_print("²«¿§¤¯µ±¤¤¤Æ¤¤¤ë...");
+                       msg_print("Î϶¯¤¯»Í¸Ô¤òƧ¤ó¤À¡£");
 #else
-                       msg_print("It glows yellow...");
+                       msg_print("You stamp. (as if you are in a ring.)");
 #endif
-
-                       identify_fully(FALSE);
-                       o_ptr->timeout = 750;
+                       (void)set_afraid(0);
+                       (void)set_hero(randint1(20) + 20, FALSE);
+                       dispel_evil(p_ptr->lev * 3);
                        break;
                }
 
-               case ACT_ID_PLAIN:
+               case ACT_PHASE_DOOR:
                {
-                       if (!ident_spell(FALSE)) return FALSE;
-                       o_ptr->timeout = 10;
+                       teleport_player(10, 0L);
                        break;
                }
 
-               case ACT_RUNE_EXPLO:
+               case ACT_DETECT_ALL_MONS:
                {
-#ifdef JP
-                       msg_print("ÌÀ¤ë¤¤ÀÖ¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
-#else
-                       msg_print("It glows bright red...");
-#endif
-
-                       explosive_rune();
-                       o_ptr->timeout = 200;
+                       (void)detect_monsters_invis(255);
+                       (void)detect_monsters_normal(255);
                        break;
                }
 
-               case ACT_RUNE_PROT:
+               case ACT_ULTIMATE_RESIST:
                {
-#ifdef JP
-                       msg_print("¥Ö¥ë¡¼¤ËÌÀ¤ë¤¯µ±¤¤¤Æ¤¤¤ë...");
-#else
-                       msg_print("It glows light blue...");
-#endif
-
-                       warding_glyph();
-                       o_ptr->timeout = 400;
+                       int v = randint1(25)+25;
+                       (void)set_afraid(0);
+                       (void)set_hero(v, FALSE);
+                       (void)hp_player(10);
+                       (void)set_blessed(v, FALSE);
+                       (void)set_oppose_acid(v, FALSE);
+                       (void)set_oppose_elec(v, FALSE);
+                       (void)set_oppose_fire(v, FALSE);
+                       (void)set_oppose_cold(v, FALSE);
+                       (void)set_oppose_pois(v, FALSE);
+                       (void)set_ultimate_res(v, FALSE);
                        break;
                }
 
-               case ACT_SATIATE:
+
+               /* Unique activation */
+               case ACT_CAST_OFF:
                {
-                       (void)set_food(PY_FOOD_MAX - 1);
-                       o_ptr->timeout = 200;
+                       int inv, o_idx, t;
+                       char o_name[MAX_NLEN];
+                       object_type forge;
+
+                       /* Cast off activated item */
+                       for (inv = INVEN_RARM; inv <= INVEN_FEET; inv++)
+                       {
+                               if (o_ptr == &inventory[inv]) break;
+                       }
+
+                       /* Paranoia */
+                       if (inv > INVEN_FEET) return FALSE;
+
+                       object_copy(&forge, o_ptr);
+                       inven_item_increase(inv, (0 - o_ptr->number));
+                       inven_item_optimize(inv);
+                       o_idx = drop_near(&forge, 0, py, px);
+                       o_ptr = &o_list[o_idx];
+
+                       object_desc(o_name, o_ptr, OD_NAME_ONLY);
+                       msg_format(_("%s¤ò椮¼Î¤Æ¤¿¡£", "You cast off %s."), o_name);
+
+                       /* Get effects */
+                       msg_print(_("¡Ödz¤¨¾å¤¬¤ì²¶¤Î¾®±§Ã衪¡×", "You say, 'Burn up my cosmo!"));
+                       t = 20 + randint1(20);
+                       (void)set_blind(p_ptr->blind + t);
+                       (void)set_afraid(0);
+                       (void)set_tim_esp(p_ptr->tim_esp + t, FALSE);
+                       (void)set_tim_regen(p_ptr->tim_regen + t, FALSE);
+                       (void)set_hero(p_ptr->hero + t, FALSE);
+                       (void)set_blessed(p_ptr->blessed + t, FALSE);
+                       (void)set_fast(p_ptr->fast + t, FALSE);
+                       (void)set_shero(p_ptr->shero + t, FALSE);
+                       if (p_ptr->pclass == CLASS_FORCETRAINER)
+                       {
+                               p_ptr->magic_num1[0] = plev * 5 + 190;
+                               msg_print(_("µ¤¤¬ÇúȯÀ£Á°¤Ë¤Ê¤Ã¤¿¡£", "Your force are immediatly before explosion."));
+                       }
+
                        break;
                }
 
-               case ACT_DEST_DOOR:
+               case ACT_FISHING:
                {
+                       int x, y;
+
+                       if (!get_rep_dir2(&dir)) return FALSE;
+                       y = py+ddy[dir];
+                       x = px+ddx[dir];
+                       tsuri_dir = dir;
+                       if (!cave_have_flag_bold(y, x, FF_WATER))
+                       {
 #ifdef JP
-                       msg_print("ÌÀ¤ë¤¤ÀÖ¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
+                               msg_print("¤½¤³¤Ï¿åÊդǤϤʤ¤¡£");
 #else
-                       msg_print("It glows bright red...");
+                               msg_print("There is no fishing place.");
 #endif
-
-                       destroy_doors_touch();
-                       o_ptr->timeout = 10;
-                       break;
-               }
-
-               case ACT_STONE_MUD:
-               {
+                               return FALSE;
+                       }
+                       else if (cave[y][x].m_idx)
+                       {
+                               char m_name[80];
+                               monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
 #ifdef JP
-                       msg_print("¸ÝÆ°¤·¤Æ¤¤¤ë...");
+                               msg_format("%s¤¬¼ÙËâ¤À¡ª", m_name);
 #else
-                       msg_print("It pulsates...");
+                               msg_format("%^s is stand in your way.", m_name);
 #endif
-
-                       if (!get_aim_dir(&dir)) return FALSE;
-                       wall_to_mud(dir);
-                       o_ptr->timeout = 5;
-                       break;
-               }
-
-               case ACT_RECHARGE:
-               {
-                       recharge(130);
-                       o_ptr->timeout = 70;
+                               energy_use = 0;
+                               return FALSE;
+                       }
+                       set_action(ACTION_FISH);
+                       p_ptr->redraw |= (PR_STATE);
                        break;
                }
 
-               case ACT_ALCHEMY:
+               case ACT_INROU:
                {
+                       int count = 0, i;
+                       monster_type *m_ptr;
+#ifndef JP
+                       cptr kakusan = "";
+#endif
+                       if (summon_named_creature(0, py, px, MON_SUKE, PM_FORCE_PET))
+                       {
 #ifdef JP
-                       msg_print("ÌÀ¤ë¤¤²«¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
+                               msg_print("¡Ø½õ¤µ¤ó¡Ù¤¬¸½¤ì¤¿¡£");
 #else
-                       msg_print("It glows bright yellow...");
+                               msg_print("Suke-san apperars.");
+                               kakusan = "Suke-san";
+#endif
+                               count++;
+                       }
+                       if (summon_named_creature(0, py, px, MON_KAKU, PM_FORCE_PET))
+                       {
+#ifdef JP
+                               msg_print("¡Ø³Ê¤µ¤ó¡Ù¤¬¸½¤ì¤¿¡£");
+#else
+                               msg_print("Kaku-san appears.");
+                               kakusan = "Kaku-san";
 #endif
+                               count++;
+                       }
+                       if (!count)
+                       {
+                               for (i = m_max - 1; i > 0; i--)
+                               {
+                                       m_ptr = &m_list[i];
+                                       if (!m_ptr->r_idx) continue;
+                                       if (!((m_ptr->r_idx == MON_SUKE) || (m_ptr->r_idx == MON_KAKU))) continue;
+                                       if (!los(m_ptr->fy, m_ptr->fx, py, px)) continue;
+                                       if (!projectable(m_ptr->fy, m_ptr->fx, py, px)) continue;
+                                       count++;
+                                       break;
+                               }
+                       }
 
-                       (void)alchemy();
-                       o_ptr->timeout = 500;
+                       if (count)
+                       {
+#ifdef JP
+                               msg_print("¡Ö¼Ô¤É¤â¡¢¤Ò¤«¤¨¤ª¤í¤¦¡ª¡ª¡ª¤³¤Î¤ªÊý¤ò¤É¤Ê¤¿¤È¤³¤³¤í¤¨¤ë¡£¡×");
+#else
+                               msg_format("%^s says 'WHO do you think this person is! Bow your head, down your knees!'", kakusan);
+#endif
+                               sukekaku = TRUE;
+                               stun_monsters(120);
+                               confuse_monsters(120);
+                               turn_monsters(120);
+                               stasis_monsters(120);
+                               sukekaku = FALSE;
+                       }
+                       else
+                       {
+#ifdef JP
+                               msg_print("¤·¤«¤·¡¢²¿¤âµ¯¤­¤Ê¤«¤Ã¤¿¡£");
+#else
+                               msg_print("Nothing happen.");
+#endif
+                       }
                        break;
                }
 
-               case ACT_DIM_DOOR:
+               case ACT_MURAMASA:
                {
+                       /* Only for Muramasa */
+                       if (o_ptr->name1 != ART_MURAMASA) return FALSE;
 #ifdef JP
-                       msg_print("¼¡¸µ¤ÎÈ⤬³«¤¤¤¿¡£ÌÜŪÃϤòÁª¤ó¤Ç²¼¤µ¤¤¡£");
+                       if (get_check("ËÜÅö¤Ë»È¤¤¤Þ¤¹¤«¡©"))
 #else
-                       msg_print("You open a dimensional gate. Choose a destination.");
+                       if (get_check("Are you sure?!"))
 #endif
-
-                       if (!dimension_door()) return FALSE;
-                       o_ptr->timeout = 100;
+                       {
+#ifdef JP
+                               msg_print("¼Àµ¤¬¿Ì¤¨¤¿¡¥¡¥¡¥");
+#else
+                               msg_print("The Muramasa pulsates...");
+#endif
+                               do_inc_stat(A_STR);
+                               if (one_in_(2))
+                               {
+#ifdef JP
+                                       msg_print("¼Àµ¤Ï²õ¤ì¤¿¡ª");
+#else
+                                       msg_print("The Muramasa is destroyed!");
+#endif
+                                       curse_weapon_object(TRUE, o_ptr);
+                               }
+                       }
                        break;
                }
 
-
-               case ACT_TELEPORT:
+               case ACT_BLOODY_MOON:
                {
+                       /* Only for Bloody Moon */
+                       if (o_ptr->name1 != ART_BLOOD) return FALSE;
 #ifdef JP
-                       msg_print("¼þ¤ê¤Î¶õ´Ö¤¬ÏĤó¤Ç¤¤¤ë...");
+                       msg_print("³ù¤¬ÌÀ¤ë¤¯µ±¤¤¤¿...");
 #else
-                       msg_print("It twists space around you...");
+                       msg_print("Your scythe glows brightly!");
 #endif
-
-                       teleport_player(100);
-                       o_ptr->timeout = 45;
+                       get_bloody_moon_flags(o_ptr);
+                       if (p_ptr->prace == RACE_ANDROID) calc_android_exp();
+                       p_ptr->update |= (PU_BONUS | PU_HP);
                        break;
                }
 
-               case ACT_RECALL:
+               case ACT_CRIMSON:
                {
+                       int num = 1;
+                       int i;
+                       int flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
+                       int tx, ty;
+
+                       /* Only for Crimson */
+                       if (o_ptr->name1 != ART_CRIMSON) return FALSE;
+
 #ifdef JP
-                       msg_print("¤ä¤ï¤é¤«¤ÊÇò¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
+                       msg_print("¤»¤Ã¤«¤¯¤À¤«¤é¡Ø¥¯¥ê¥à¥¾¥ó¡Ù¤ò¤Ö¤Ã¤Ñ¤Ê¤¹¤¼¡ª");
 #else
-                       msg_print("It glows soft white...");
+                       msg_print("I'll fire CRIMSON! SEKKAKUDAKARA!");
 #endif
-                       if (!word_of_recall()) return FALSE;
-                       o_ptr->timeout = 200;
+
+                       if (!get_aim_dir(&dir)) return FALSE;
+
+                       /* Use the given direction */
+                       tx = px + 99 * ddx[dir];
+                       ty = py + 99 * ddy[dir];
+
+                       /* Hack -- Use an actual "target" */
+                       if ((dir == 5) && target_okay())
+                       {
+                               tx = target_col;
+                               ty = target_row;
+                       }
+
+                       if (p_ptr->pclass == CLASS_ARCHER)
+                       {
+                               /* Extra shot at level 10 */
+                               if (p_ptr->lev >= 10) num++;
+
+                               /* Extra shot at level 30 */
+                               if (p_ptr->lev >= 30) num++;
+
+                               /* Extra shot at level 45 */
+                               if (p_ptr->lev >= 45) num++;
+                       }
+
+                       for (i = 0; i < num; i++)
+                               project(0, p_ptr->lev/20+1, ty, tx, p_ptr->lev*p_ptr->lev*6/50, GF_ROCKET, flg, -1);
                        break;
                }
 
                default:
                {
 #ifdef JP
-                       msg_format("Unknown activation effect: %d.", o_ptr->xtra2);
+                       msg_format("Unknown activation effect: %d.", act_ptr->index);
 #else
-                       msg_format("Unknown activation effect: %d.", o_ptr->xtra2);
+                       msg_format("Unknown activation effect: %d.", act_ptr->index);
 #endif
+                       return FALSE;
+               }
+       }
 
+       /* Set activation timeout */
+       if (act_ptr->timeout.constant >= 0) {
+               o_ptr->timeout = act_ptr->timeout.constant;
+               if (act_ptr->timeout.dice > 0) {
+                       o_ptr->timeout += randint1(act_ptr->timeout.dice);
+               }
+       } else {
+               /* Activations that have special timeout */
+               switch (act_ptr->index) {
+               case ACT_BR_FIRE:
+                       o_ptr->timeout = ((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_FLAMES)) ? 200 : 250;
+                       break;
+               case ACT_BR_COLD:
+                       o_ptr->timeout = ((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_ICE)) ? 200 : 250;
+                       break;
+               case ACT_TERROR:
+                       o_ptr->timeout = 3 * (p_ptr->lev + 10);
+                       break;
+               case ACT_MURAMASA:
+                       /* Nothing to do */
+                       break;
+               default:
+                       msg_format("Special timeout is not implemented: %d.", act_ptr->index);
                        return FALSE;
                }
        }
@@ -2827,7 +3972,36 @@ bool activate_random_artifact(object_type * o_ptr)
 }
 
 
-void random_artifact_resistance(object_type * o_ptr)
+void get_bloody_moon_flags(object_type *o_ptr)
+{
+       int dummy, i;
+
+       for (i = 0; i < TR_FLAG_SIZE; i++)
+               o_ptr->art_flags[i] = a_info[ART_BLOOD].flags[i];
+
+       dummy = randint1(2) + randint1(2);
+       for (i = 0; i < dummy; i++)
+       {
+               int flag = randint0(26);
+               if (flag >= 20) add_flag(o_ptr->art_flags, TR_KILL_UNDEAD + flag - 20);
+               else if (flag == 19) add_flag(o_ptr->art_flags, TR_KILL_ANIMAL);
+               else if (flag == 18) add_flag(o_ptr->art_flags, TR_SLAY_HUMAN);
+               else add_flag(o_ptr->art_flags, TR_CHAOTIC + flag);
+       }
+
+       dummy = randint1(2);
+       for (i = 0; i < dummy; i++) one_resistance(o_ptr);
+
+       for (i = 0; i < 2; i++)
+       {
+               int tmp = randint0(11);
+               if (tmp < 6) add_flag(o_ptr->art_flags, TR_STR + tmp);
+               else add_flag(o_ptr->art_flags, TR_STEALTH + tmp - 6);
+       }
+}
+
+
+void random_artifact_resistance(object_type * o_ptr, artifact_type *a_ptr)
 {
        bool give_resistance = FALSE, give_power = FALSE;
 
@@ -2840,123 +4014,60 @@ void random_artifact_resistance(object_type * o_ptr)
                }
                else
                {
-                       o_ptr->art_flags3 |=
-                           (TR3_CURSED | TR3_HEAVY_CURSE | TR3_AGGRAVATE | TR3_TY_CURSE);
-                       o_ptr->ident |= IDENT_CURSED;
+                       add_flag(o_ptr->art_flags, TR_AGGRAVATE);
+                       add_flag(o_ptr->art_flags, TR_TY_CURSE);
+                       o_ptr->curse_flags |=
+                           (TRC_CURSED | TRC_HEAVY_CURSE);
+                       o_ptr->curse_flags |= get_curse(2, o_ptr);
                        return;
                }
        }
+
        if (o_ptr->name1 == ART_MURAMASA)
        {
                if (p_ptr->pclass != CLASS_SAMURAI)
                {
-                       o_ptr->art_flags3 |= (TR3_NO_TELE | TR3_NO_MAGIC | TR3_HEAVY_CURSE);
-                       o_ptr->ident |= IDENT_CURSED;
+                       add_flag(o_ptr->art_flags, TR_NO_MAGIC);
+                       o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
                }
        }
 
        if (o_ptr->name1 == ART_XIAOLONG)
        {
                if (p_ptr->pclass == CLASS_MONK)
-                       o_ptr->art_flags1 |= TR1_BLOWS;
+                       add_flag(o_ptr->art_flags, TR_BLOWS);
        }
 
        if (o_ptr->name1 == ART_BLOOD)
        {
-               int dummy, i;
-               dummy = randint(2)+randint(2);
-               for (i = 0; i < dummy; i++)
-                       o_ptr->art_flags1 |= (TR1_CHAOTIC << rand_int(18));
-               dummy = randint(2);
-               for (i = 0; i < dummy; i++)
-                       random_resistance(o_ptr, FALSE, randint(34) + 4);
-               dummy = 2;
-               for (i = 0; i < dummy; i++)
-               {
-                       int tmp = rand_int(11);
-                       if (tmp < 6) o_ptr->art_flags1 |= (TR1_STR << tmp);
-                       else o_ptr->art_flags1 |= (TR1_STEALTH << (tmp - 6));
+               get_bloody_moon_flags(o_ptr);
+       }
+
+       if (o_ptr->name1 == ART_HEAVENLY_MAIDEN)
+       {
+               if (p_ptr->psex != SEX_FEMALE)
+               {
+                       add_flag(o_ptr->art_flags, TR_AGGRAVATE);
                }
        }
 
-       switch (o_ptr->name1)
+       if (a_ptr->gen_flags & (TRG_XTRA_POWER)) give_power = TRUE;
+       if (a_ptr->gen_flags & (TRG_XTRA_H_RES)) give_resistance = TRUE;
+       if (a_ptr->gen_flags & (TRG_XTRA_RES_OR_POWER))
        {
-               case ART_CELEBORN:
-               case ART_ARVEDUI:
-               case ART_CASPANION:
-               case ART_HITHLOMIR:
-               case ART_ROHIRRIM:
-               case ART_CELEGORM:
-               case ART_ANARION:
-               case ART_THRANDUIL:
-               case ART_LUTHIEN:
-               case ART_THROR:
-               case ART_THORIN:
-               case ART_NIMTHANC:
-               case ART_DETHANC:
-               case ART_NARTHANC:
-               case ART_STING:
-               case ART_TURMIL:
-               case ART_THALKETTOTH:
-               case ART_JIZO:
-                       {
-                               /* Give a resistance */
-                               give_resistance = TRUE;
-                       }
-                       break;
-               case ART_MAEDHROS:
-               case ART_GLAMDRING:
-               case ART_ORCRIST:
-               case ART_ANDURIL:
-               case ART_ZARCUTHRA:
-               case ART_GURTHANG:
-               case ART_HARADEKKET:
-               case ART_BRAND:
-               case ART_DAWN:
-               case ART_BUCKLAND:
-               case ART_AZAGHAL:
-                       {
-                               /* Give a resistance OR a power */
-                               if (randint(2) == 1) give_resistance = TRUE;
-                               else give_power = TRUE;
-                       }
-                       break;
-               case ART_NENYA:
-               case ART_VILYA:
-               case ART_BERUTHIEL:
-               case ART_THINGOL:
-               case ART_ULMO:
-               case ART_OLORIN:
-                       {
-                               /* Give a power */
-                               give_power = TRUE;
-                       }
-                       break;
-               case ART_CRIMSON:
-               case ART_POWER:
-               case ART_GONDOR:
-               case ART_AULE:
-                       {
-                               /* Give both */
-                               give_power = TRUE;
-                               give_resistance = TRUE;
-                       }
-                       break;
+               /* Give a resistance OR a power */
+               if (one_in_(2)) give_resistance = TRUE;
+               else give_power = TRUE;
        }
 
        if (give_power)
        {
-               o_ptr->xtra1 = EGO_XTRA_ABILITY;
-
-               /* Randomize the "xtra" power */
-               if (o_ptr->xtra1) o_ptr->xtra2 = randint(256);
+               one_ability(o_ptr);
        }
 
-       artifact_bias = 0;
-
        if (give_resistance)
        {
-               random_resistance(o_ptr, FALSE, randint(22) + 16);
+               one_high_resistance(o_ptr);
        }
 }
 
@@ -2964,7 +4075,7 @@ void random_artifact_resistance(object_type * o_ptr)
 /*
  * Create the artifact of the specified number
  */
-void create_named_art(int a_idx, int y, int x)
+bool create_named_art(int a_idx, int y, int x)
 {
        object_type forge;
        object_type *q_ptr;
@@ -2976,13 +4087,13 @@ void create_named_art(int a_idx, int y, int x)
        q_ptr = &forge;
 
        /* Ignore "empty" artifacts */
-       if (!a_ptr->name) return;
+       if (!a_ptr->name) return FALSE;
 
        /* Acquire the "kind" index */
        i = lookup_kind(a_ptr->tval, a_ptr->sval);
 
        /* Oops */
-       if (!i) return;
+       if (!i) return FALSE;
 
        /* Create the artifact */
        object_prep(q_ptr, i);
@@ -3000,11 +4111,22 @@ void create_named_art(int a_idx, int y, int x)
        q_ptr->to_d = a_ptr->to_d;
        q_ptr->weight = a_ptr->weight;
 
-       /* Hack -- acquire "cursed" flag */
-       if (a_ptr->flags3 & TR3_CURSED) q_ptr->ident |= (IDENT_CURSED);
+       /* Hack -- extract the "cursed" flag */
+       if (a_ptr->gen_flags & TRG_CURSED) q_ptr->curse_flags |= (TRC_CURSED);
+       if (a_ptr->gen_flags & TRG_HEAVY_CURSE) q_ptr->curse_flags |= (TRC_HEAVY_CURSE);
+       if (a_ptr->gen_flags & TRG_PERMA_CURSE) q_ptr->curse_flags |= (TRC_PERMA_CURSE);
+       if (a_ptr->gen_flags & (TRG_RANDOM_CURSE0)) q_ptr->curse_flags |= get_curse(0, q_ptr);
+       if (a_ptr->gen_flags & (TRG_RANDOM_CURSE1)) q_ptr->curse_flags |= get_curse(1, q_ptr);
+       if (a_ptr->gen_flags & (TRG_RANDOM_CURSE2)) q_ptr->curse_flags |= get_curse(2, q_ptr);
+
+       random_artifact_resistance(q_ptr, a_ptr);
 
-       random_artifact_resistance(q_ptr);
+       /*
+        * drop_near()Æâ¤ÇÉáÄ̤θÇÄꥢ¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤¬½Å¤Ê¤é¤Ê¤¤À­¼Á¤Ë°Í¸¤¹¤ë.
+        * ²¾¤Ë2¸Ä°Ê¾å¸ºß²Äǽ¤«¤ÄÁõÈ÷Éʰʳ°¤Î¸ÇÄꥢ¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤¬ºîÀ®¤µ¤ì¤ì¤Ð
+        * ¤³¤Î´Ø¿ô¤ÎÊÖ¤êÃͤϿ®ÍѤǤ­¤Ê¤¯¤Ê¤ë.
+        */
 
        /* Drop the artifact from heaven */
-       (void)drop_near(q_ptr, -1, y, x);
+       return drop_near(q_ptr, -1, y, x) ? TRUE : FALSE;
 }