OSDN Git Service

combined head-ego.
[hengband/hengband.git] / src / mspells3.c
index 789d36f..8c64a1b 100644 (file)
@@ -1,20 +1,20 @@
 /* File: mspells3.c */
 
-/* Purpose: Mane code */
-
 /*
- * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
+ * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
  *
- * This software may be copied and distributed for educational, research, and
- * not for profit purposes provided that this copyright and statement are
- * included in all such copies.
+ * This software may be copied and distributed for educational, research,
+ * and not for profit purposes provided that this copyright and statement
+ * are included in all such copies.  Other copyrights may also apply.
  */
 
+/* Purpose: Imitation code */
+
 #include "angband.h"
 
 #define pseudo_plev() (((p_ptr->lev + 40) * (p_ptr->lev + 40) - 1550) / 130)
 
-void learned_info(char *p, int power)
+static void learned_info(char *p, int power)
 {
        int plev = pseudo_plev();
        int hp = p_ptr->chp;
@@ -37,6 +37,9 @@ void learned_info(char *p, int power)
        {
                case MS_SHRIEK:
                case MS_XXX1:
+               case MS_XXX2:
+               case MS_XXX3:
+               case MS_XXX4:
                case MS_SCARE:
                case MS_BLIND:
                case MS_CONF:
@@ -78,18 +81,17 @@ void learned_info(char *p, int power)
                case MS_ROCKET:
                        sprintf(p, " %s%d", s_dam, hp/4);
                        break;
-               case MS_ARROW_1:
-                       sprintf(p, " %s2d5", s_dam);
-                       break;
-               case MS_ARROW_2:
-                       sprintf(p, " %s3d6", s_dam);
-                       break;
-               case MS_ARROW_3:
-                       sprintf(p, " %s5d6", s_dam);
-                       break;
-               case MS_ARROW_4:
-                       sprintf(p, " %s7d6", s_dam);
+               case MS_SHOOT:
+               {
+                       object_type *o_ptr = NULL;
+                       if (buki_motteruka(INVEN_RARM)) o_ptr = &inventory[INVEN_RARM];
+                       else if (buki_motteruka(INVEN_LARM)) o_ptr = &inventory[INVEN_LARM];
+                       else
+                               sprintf(p, " %s1", s_dam);
+                       if (o_ptr)
+                               sprintf(p, " %s%dd%d+%d", s_dam, o_ptr->dd, o_ptr->ds, o_ptr->to_d);
                        break;
+               }
                case MS_BR_ACID:
                case MS_BR_ELEC:
                case MS_BR_FIRE:
@@ -383,36 +385,7 @@ cptr            p = "
        }
        }
 
-       if (mode == 1)
-       {
-               f4 = ((RF4_BOLT_MASK | RF4_BEAM_MASK) & ~(RF4_ROCKET));
-               f5 = RF5_BOLT_MASK | RF5_BEAM_MASK;
-               f6 = RF6_BOLT_MASK | RF6_BEAM_MASK;
-       }
-       else if (mode == 2)
-       {
-               f4 = (RF4_BALL_MASK & ~(RF4_BREATH_MASK));
-               f5 = (RF5_BALL_MASK & ~(RF5_BREATH_MASK));
-               f6 = (RF6_BALL_MASK & ~(RF6_BREATH_MASK));
-       }
-       else if (mode == 3)
-       {
-               f4 = RF4_BREATH_MASK;
-               f5 = RF5_BREATH_MASK;
-               f6 = RF6_BREATH_MASK;
-       }
-       else if (mode == 4)
-       {
-               f4 = RF4_SUMMON_MASK;
-               f5 = RF5_SUMMON_MASK;
-               f6 = RF6_SUMMON_MASK;
-       }
-       else if (mode == 5)
-       {
-               f4 = ~(RF4_BOLT_MASK | RF4_BEAM_MASK | RF4_BALL_MASK | RF4_SUMMON_MASK | RF4_INDIRECT_MASK | RF4_RIDING_MASK);
-               f5 = ~(RF5_BOLT_MASK | RF5_BEAM_MASK | RF5_BALL_MASK | RF5_SUMMON_MASK | RF5_INDIRECT_MASK | RF5_RIDING_MASK);
-               f6 = (~(RF6_BOLT_MASK | RF6_BEAM_MASK | RF6_BALL_MASK | RF6_SUMMON_MASK | RF6_INDIRECT_MASK | RF6_RIDING_MASK)) | (RF6_TRAPS | RF6_DARKNESS);
-       }
+       set_rf_masks(&f4, &f5, &f6, mode);
 
        for (i = 0, num = 0; i < 32; i++)
        {
@@ -445,21 +418,21 @@ cptr            p = "
        }
 
        /* Build a prompt (accept all spells) */
+       (void)strnfmt(out_val, 78, 
 #ifdef JP
-(void) strnfmt(out_val, 78, "(%c-%c, '*'¤Ç°ìÍ÷, ESC) ¤É¤Î%s¤ò¾§¤¨¤Þ¤¹¤«¡©",
+                     "(%c-%c, '*'¤Ç°ìÍ÷, ESC) ¤É¤Î%s¤ò¾§¤¨¤Þ¤¹¤«¡©",
 #else
-       (void)strnfmt(out_val, 78, "(%c-%c, *=List, ESC=exit) Use which %s? ",
+                     "(%c-%c, *=List, ESC=exit) Use which %s? ",
 #endif
-
-               I2A(0), I2A(num - 1), p);
+                     I2A(0), I2A(num - 1), p);
 
        if (use_menu) screen_save();
 
        /* Get a spell from the user */
 
-        choice= (always_show_list || use_menu) ? ESCAPE:1 ;
-        while (!flag)
-        {
+       choice= (always_show_list || use_menu) ? ESCAPE:1 ;
+       while (!flag)
+       {
                if(choice==ESCAPE) choice = ' '; 
                else if( !get_com(out_val, &choice, TRUE) )break; 
 
@@ -471,7 +444,6 @@ cptr            p = "
                                {
                                        screen_load();
                                        return (FALSE);
-                                       break;
                                }
 
                                case '8':
@@ -558,7 +530,7 @@ put_str("MP 
                                /* Dump the spells */
                                for (i = 0; i < num; i++)
                                {
-                                       int shouhimana;
+                                       int need_mana;
 
                                        prt("", y + i + 1, x);
                                        if (!p_ptr->magic_num2[spellnum[i]]) continue;
@@ -572,28 +544,17 @@ put_str("MP 
                                        if (plev > spell.level) chance -= 3 * (plev - spell.level);
                                        else chance += (spell.level - plev);
 
-                                       if (p_ptr->pseikaku == SEIKAKU_NAMAKE) chance += 10;
-                                       if (p_ptr->pseikaku == SEIKAKU_KIREMONO) chance -= 3;
-                                       if ((p_ptr->pseikaku == SEIKAKU_GAMAN) || (p_ptr->pseikaku == SEIKAKU_CHIKARA)) chance++;
-
                                        /* Reduce failure rate by INT/WIS adjustment */
                                        chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[A_INT]] - 1);
 
-                                       if (p_ptr->heavy_spell) chance += 20;
-                                       if(p_ptr->dec_mana || p_ptr->easy_spell) chance-=4;
-                                       else if (p_ptr->easy_spell) chance-=3;
-                                       else if (p_ptr->dec_mana) chance-=2;
+                                       chance = mod_spell_chance_1(chance);
 
-                                       shouhimana = monster_powers[spellnum[i]].smana;
-                                       if (p_ptr->dec_mana)
-                                       {
-                                               shouhimana = (shouhimana + 1) * 3 / 4;
-                                       }
+                                       need_mana = mod_need_mana(monster_powers[spellnum[i]].smana, 0, REALM_NONE);
 
                                        /* Not enough mana to cast */
-                                       if (shouhimana > p_ptr->csp)
+                                       if (need_mana > p_ptr->csp)
                                        {
-                                               chance += 5 * (shouhimana - p_ptr->csp);
+                                               chance += 5 * (need_mana - p_ptr->csp);
                                        }
 
                                        /* Extract the minimum failure rate */
@@ -609,9 +570,7 @@ put_str("MP 
                                        /* Always a 5 percent chance of working */
                                        if (chance > 95) chance = 95;
 
-                                       if(p_ptr->dec_mana) chance--;
-                                       if (p_ptr->heavy_spell) chance += 5;
-                                       chance = MAX(chance,0);
+                                       chance = mod_spell_chance_2(chance);
 
                                        /* Get info */
                                        learned_info(comment, spellnum[i]);
@@ -629,8 +588,8 @@ put_str("MP 
 
                                        /* Dump the spell --(-- */
                                        strcat(psi_desc, format(" %-26s %3d %3d%%%s",
-                                               spell.name, shouhimana,
-                                               chance, comment));
+                                               spell.name, need_mana,
+                                               chance, comment));
                                        prt(psi_desc, y + i + 1, x);
                                }
 
@@ -681,7 +640,7 @@ put_str("MP 
 
                        /* Prompt */
 #ifdef JP
-(void) strnfmt(tmp_val, 78, "%s¤ÎËâË¡¤ò¾§¤¨¤Þ¤¹¤«¡©", monster_powers[spellnum[i]].name);
+                       (void) strnfmt(tmp_val, 78, "%s¤ÎËâË¡¤ò¾§¤¨¤Þ¤¹¤«¡©", monster_powers[spellnum[i]].name);
 #else
                        (void)strnfmt(tmp_val, 78, "Use %s? ", monster_powers[spellnum[i]].name);
 #endif
@@ -699,14 +658,10 @@ put_str("MP 
        if (redraw) screen_load();
 
        /* Show choices */
-       if (show_choices)
-       {
-               /* Update */
-               p_ptr->window |= (PW_SPELL);
+       p_ptr->window |= (PW_SPELL);
 
-               /* Window stuff */
-               window_stuff();
-       }
+       /* Window stuff */
+       window_stuff();
 
        /* Abort if needed */
        if (!flag) return (FALSE);
@@ -733,15 +688,25 @@ static bool cast_learned_spell(int spell, bool success)
 {
        int             dir;
        int             plev = pseudo_plev();
-       int     summon_lev = p_ptr->lev * 2 / 3 + randint(p_ptr->lev/2);
+       int     summon_lev = p_ptr->lev * 2 / 3 + randint1(p_ptr->lev/2);
        int             hp = p_ptr->chp;
        int             damage = 0;
-       bool    unique_okay = FALSE;
        bool   pet = success;
-       bool   not_pet = (bool)(!pet);
        bool   no_trump = FALSE;
+       u32b p_mode, u_mode = 0L, g_mode;
 
-       if (!success || (randint(50+plev) < plev/10)) unique_okay = TRUE;
+       if (pet)
+       {
+               p_mode = PM_FORCE_PET;
+               g_mode = 0;
+       }
+       else
+       {
+               p_mode = PM_NO_PET;
+               g_mode = PM_ALLOW_GROUP;
+       }
+
+       if (!success || (randint1(50+plev) < plev/10)) u_mode = PM_ALLOW_UNIQUE;
 
        /* spell code */
        switch (spell)
@@ -750,7 +715,7 @@ static bool cast_learned_spell(int spell, bool success)
 #ifdef JP
 msg_print("¤«¤ó¹â¤¤¶âÀÚ¤êÀ¼¤ò¤¢¤²¤¿¡£");
 #else
-               msg_print("You makes a high pitched shriek.");
+               msg_print("You make a high pitched shriek.");
 #endif
 
                aggravate_monsters(0);
@@ -759,45 +724,14 @@ msg_print("
                break;
        case MS_DISPEL:
        {
-               monster_type *m_ptr;
-               char m_name[80];
+               int m_idx;
 
                if (!target_set(TARGET_KILL)) return FALSE;
-               if (!cave[target_row][target_col].m_idx) break;
-               if (!los(py, px, target_row, target_col)) break;
-               m_ptr = &m_list[cave[target_row][target_col].m_idx];
-               monster_desc(m_name, m_ptr, 0);
-               if (m_ptr->invulner)
-               {
-                       m_ptr->invulner = 0;
-#ifdef JP
-msg_format("%s¤Ï¤â¤¦ÌµÅ¨¤Ç¤Ï¤Ê¤¤¡£", m_name);
-#else
-                       msg_format("%^s is no longer invulnerable.", m_name);
-#endif
-                       m_ptr->energy -= 100;
-               }
-               if (m_ptr->fast)
-               {
-                       m_ptr->fast = 0;
-#ifdef JP
-msg_format("%s¤Ï¤â¤¦²Ã®¤µ¤ì¤Æ¤¤¤Ê¤¤¡£", m_name);
-#else
-                       msg_format("%^s is no longer fast.", m_name);
-#endif
-               }
-               if (m_ptr->slow)
-               {
-                       m_ptr->slow = 0;
-#ifdef JP
-msg_format("%s¤Ï¤â¤¦¸ºÂ®¤µ¤ì¤Æ¤¤¤Ê¤¤¡£", m_name);
-#else
-                       msg_format("%^s is no longer slow.", m_name);
-#endif
-               }
-               p_ptr->redraw |= (PR_HEALTH);
-               if (p_ptr->riding == cave[target_row][target_col].m_idx) p_ptr->redraw |= (PR_UHEALTH);
-
+               m_idx = cave[target_row][target_col].m_idx;
+               if (!m_idx) break;
+               if (!player_has_los_bold(target_row, target_col)) break;
+               if (!projectable(py, px, target_row, target_col)) break;
+               dispel_monster_status(m_idx);
                break;
        }
        case MS_ROCKET:
@@ -806,61 +740,48 @@ msg_format("%s
 #ifdef JP
 msg_print("¥í¥±¥Ã¥È¤òȯ¼Í¤·¤¿¡£");
 #else
-                       msg_print("You fires a rocket.");
+                       msg_print("You fire a rocket.");
 #endif
                damage = hp / 4;
                        fire_rocket(GF_ROCKET, dir, damage, 2);
                break;
-       case MS_ARROW_1:
+       case MS_SHOOT:
+       {
+               object_type *o_ptr = NULL;
+
                if (!get_aim_dir(&dir)) return FALSE;
                else
+               {
 #ifdef JP
 msg_print("Ìð¤òÊü¤Ã¤¿¡£");
 #else
-                       msg_print("You fires an arrow.");
+                       msg_print("You fire an arrow.");
 #endif
-               damage = damroll(2, 5);
-               fire_bolt(GF_ARROW, dir, damage);
+                       if (buki_motteruka(INVEN_RARM)) o_ptr = &inventory[INVEN_RARM];
+                       else if (buki_motteruka(INVEN_LARM)) o_ptr = &inventory[INVEN_LARM];
+                       else
+                       damage = 1;
+                       if (o_ptr)
+                       {
+                               damage = damroll(o_ptr->dd, o_ptr->ds)+ o_ptr->to_d;
+                               if (damage < 1) damage = 1;
+                       }
+                       fire_bolt(GF_ARROW, dir, damage);
+               }
                break;
-       case MS_ARROW_2:
-               if (!get_aim_dir(&dir)) return FALSE;
-               else
-#ifdef JP
-msg_print("Ìð¤òÊü¤Ã¤¿¡£");
-#else
-                       msg_print("You fires an arrow.");
-#endif
-               damage = damroll(3, 6);
-               fire_bolt(GF_ARROW, dir, damage);
+       }
+       case MS_XXX2:
                break;
-       case MS_ARROW_3:
-               if (!get_aim_dir(&dir)) return FALSE;
-               else
-#ifdef JP
-msg_print("¥Ü¥ë¥È¤ò·â¤Ã¤¿¡£");
-#else
-                       msg_print("You fires a bolt.");
-#endif
-               damage = damroll(5, 6);
-               fire_bolt(GF_ARROW, dir, damage);
+       case MS_XXX3:
                break;
-       case MS_ARROW_4:
-               if (!get_aim_dir(&dir)) return FALSE;
-               else
-#ifdef JP
-msg_print("¥Ü¥ë¥È¤ò·â¤Ã¤¿¡£");
-#else
-                       msg_print("You fires a bolt.");
-#endif
-               damage = damroll(7, 6);
-               fire_bolt(GF_ARROW, dir, damage);
+       case MS_XXX4:
                break;
        case MS_BR_ACID:
                if (!get_aim_dir(&dir)) return FALSE;
 #ifdef JP
 else msg_print("»À¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
 #else
-                       else msg_print("You breathes acid.");
+                       else msg_print("You breathe acid.");
 #endif
                damage = hp / 3;
                fire_ball(GF_ACID, dir, damage, (plev > 40 ? -3 : -2));
@@ -870,7 +791,7 @@ else msg_print("
 #ifdef JP
 else msg_print("°ðºÊ¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
 #else
-                       else msg_print("You breathes lightning.");
+                       else msg_print("You breathe lightning.");
 #endif
                damage = hp / 3;
                fire_ball(GF_ELEC, dir, damage, (plev > 40 ? -3 : -2));
@@ -880,7 +801,7 @@ else msg_print("
 #ifdef JP
 else msg_print("²Ð±ê¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
 #else
-                       else msg_print("You breathes fire.");
+                       else msg_print("You breathe fire.");
 #endif
                damage = hp / 3;
                fire_ball(GF_FIRE, dir, damage, (plev > 40 ? -3 : -2));
@@ -890,7 +811,7 @@ else msg_print("
 #ifdef JP
 else msg_print("Î䵤¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
 #else
-                       else msg_print("You breathes frost.");
+                       else msg_print("You breathe frost.");
 #endif
                damage = hp / 3;
                fire_ball(GF_COLD, dir, damage, (plev > 40 ? -3 : -2));
@@ -900,7 +821,7 @@ else msg_print("
 #ifdef JP
 else msg_print("¥¬¥¹¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
 #else
-                       else msg_print("You breathes gas.");
+                       else msg_print("You breathe gas.");
 #endif
                damage = hp / 3;
                fire_ball(GF_POIS, dir, damage, (plev > 40 ? -3 : -2));
@@ -910,7 +831,7 @@ else msg_print("
 #ifdef JP
 else msg_print("ÃϹö¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
 #else
-                       else msg_print("You breathes nether.");
+                       else msg_print("You breathe nether.");
 #endif
                damage = hp / 6;
                fire_ball(GF_NETHER, dir, damage, (plev > 40 ? -3 : -2));
@@ -920,7 +841,7 @@ else msg_print("
 #ifdef JP
 else msg_print("Á®¸÷¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
 #else
-                       else msg_print("You breathes light.");
+                       else msg_print("You breathe light.");
 #endif
                damage = hp / 6;
                fire_ball(GF_LITE, dir, damage, (plev > 40 ? -3 : -2));
@@ -930,7 +851,7 @@ else msg_print("
 #ifdef JP
 else msg_print("°Å¹õ¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
 #else
-                       else msg_print("You breathes darkness.");
+                       else msg_print("You breathe darkness.");
 #endif
                damage = hp / 6;
                fire_ball(GF_DARK, dir, damage, (plev > 40 ? -3 : -2));
@@ -940,7 +861,7 @@ else msg_print("
 #ifdef JP
 else msg_print("º®Íð¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
 #else
-                       else msg_print("You breathes confusion.");
+                       else msg_print("You breathe confusion.");
 #endif
                damage = hp / 6;
                fire_ball(GF_CONFUSION, dir, damage, (plev > 40 ? -3 : -2));
@@ -950,7 +871,7 @@ else msg_print("
 #ifdef JP
 else msg_print("¹ì²»¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
 #else
-                       else msg_print("You breathes sound.");
+                       else msg_print("You breathe sound.");
 #endif
                damage = hp / 6;
                fire_ball(GF_SOUND, dir, damage, (plev > 40 ? -3 : -2));
@@ -960,7 +881,7 @@ else msg_print("
 #ifdef JP
 else msg_print("¥«¥ª¥¹¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
 #else
-                       else msg_print("You breathes chaos.");
+                       else msg_print("You breathe chaos.");
 #endif
                damage = hp / 6;
                fire_ball(GF_CHAOS, dir, damage, (plev > 40 ? -3 : -2));
@@ -970,7 +891,7 @@ else msg_print("
 #ifdef JP
 else msg_print("Îô²½¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
 #else
-                       else msg_print("You breathes disenchantment.");
+                       else msg_print("You breathe disenchantment.");
 #endif
                damage = hp / 6;
                fire_ball(GF_DISENCHANT, dir, damage, (plev > 40 ? -3 : -2));
@@ -980,7 +901,7 @@ else msg_print("
 #ifdef JP
 else msg_print("°ø²Ìº®Íð¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
 #else
-                       else msg_print("You breathes nexus.");
+                       else msg_print("You breathe nexus.");
 #endif
                damage = MIN(hp / 3, 250);
                fire_ball(GF_NEXUS, dir, damage, (plev > 40 ? -3 : -2));
@@ -990,7 +911,7 @@ else msg_print("
 #ifdef JP
 else msg_print("»þ´ÖµÕž¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
 #else
-                       else msg_print("You breathes time.");
+                       else msg_print("You breathe time.");
 #endif
                damage = MIN(hp / 3, 150);
                fire_ball(GF_TIME, dir, damage, (plev > 40 ? -3 : -2));
@@ -1000,7 +921,7 @@ else msg_print("
 #ifdef JP
 else msg_print("ÃÙÆߤΥ֥쥹¤òÅǤ¤¤¿¡£");
 #else
-                       else msg_print("You breathes inertia.");
+                       else msg_print("You breathe inertia.");
 #endif
                damage = MIN(hp / 6, 200);
                fire_ball(GF_INERTIA, dir, damage, (plev > 40 ? -3 : -2));
@@ -1010,7 +931,7 @@ else msg_print("
 #ifdef JP
 else msg_print("½ÅÎϤΥ֥쥹¤òÅǤ¤¤¿¡£");
 #else
-                       else msg_print("You breathes gravity.");
+                       else msg_print("You breathe gravity.");
 #endif
                damage = MIN(hp / 3, 200);
                fire_ball(GF_GRAVITY, dir, damage, (plev > 40 ? -3 : -2));
@@ -1020,7 +941,7 @@ else msg_print("
 #ifdef JP
 else msg_print("ÇËÊҤΥ֥쥹¤òÅǤ¤¤¿¡£");
 #else
-                       else msg_print("You breathes shards.");
+                       else msg_print("You breathe shards.");
 #endif
                damage = hp / 6;
                fire_ball(GF_SHARDS, dir, damage, (plev > 40 ? -3 : -2));
@@ -1030,7 +951,7 @@ else msg_print("
 #ifdef JP
 else msg_print("¥×¥é¥º¥Þ¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
 #else
-                       else msg_print("You breathes plasma.");
+                       else msg_print("You breathe plasma.");
 #endif
                damage = MIN(hp / 6, 150);
                fire_ball(GF_PLASMA, dir, damage, (plev > 40 ? -3 : -2));
@@ -1040,7 +961,7 @@ else msg_print("
 #ifdef JP
 else msg_print("¥Õ¥©¡¼¥¹¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
 #else
-                       else msg_print("You breathes force.");
+                       else msg_print("You breathe force.");
 #endif
                damage = MIN(hp / 6, 200);
                fire_ball(GF_FORCE, dir, damage, (plev > 40 ? -3 : -2));
@@ -1050,7 +971,7 @@ else msg_print("
 #ifdef JP
 else msg_print("ËâÎϤΥ֥쥹¤òÅǤ¤¤¿¡£");
 #else
-                       else msg_print("You breathes mana.");
+                       else msg_print("You breathe mana.");
 #endif
                
                damage = MIN(hp / 3, 250);
@@ -1061,7 +982,7 @@ else msg_print("
 #ifdef JP
 else msg_print("Êü¼Íǽµå¤òÊü¤Ã¤¿¡£");
 #else
-                       else msg_print("You casts a ball of radiation.");
+                       else msg_print("You cast a ball of radiation.");
 #endif
                damage = plev * 2 + damroll(10, 6);
                fire_ball(GF_NUKE, dir, damage, 2);
@@ -1071,7 +992,7 @@ else msg_print("
 #ifdef JP
 else msg_print("Êü¼ÍÀ­ÇÑ´þʪ¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
 #else
-                       else msg_print("You breathes toxic waste.");
+                       else msg_print("You breathe toxic waste.");
 #endif
                damage = hp / 3;
                fire_ball(GF_NUKE, dir, damage, (plev > 40 ? -3 : -2));
@@ -1081,7 +1002,7 @@ else msg_print("
 #ifdef JP
 else msg_print("½ã¥í¥°¥ë¥¹¤òÊü¤Ã¤¿¡£");
 #else
-                       else msg_print("You invokes a raw Logrus.");
+                       else msg_print("You invoke a raw Logrus.");
 #endif
                damage = plev * 4 + damroll(10, 10);
                fire_ball(GF_CHAOS, dir, damage, 4);
@@ -1091,7 +1012,7 @@ else msg_print("
 #ifdef JP
 else msg_print("ʬ²ò¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
 #else
-                       else msg_print("You breathes disintegration.");
+                       else msg_print("You breathe disintegration.");
 #endif
                damage = MIN(hp / 6, 150);
                fire_ball(GF_DISINTEGRATE, dir, damage, (plev > 40 ? -3 : -2));
@@ -1101,9 +1022,9 @@ else msg_print("ʬ
 #ifdef JP
 else msg_print("¥¢¥·¥Ã¥É¡¦¥Ü¡¼¥ë¤Î¼öʸ¤ò¾§¤¨¤¿¡£");
 #else
-                       else msg_print("You casts an acid ball.");
+                       else msg_print("You cast an acid ball.");
 #endif
-               damage = randint(plev * 6) + 15;
+               damage = randint1(plev * 6) + 15;
                fire_ball(GF_ACID, dir, damage, 2);
                break;
        case MS_BALL_ELEC:
@@ -1111,9 +1032,9 @@ else msg_print("
 #ifdef JP
 else msg_print("¥µ¥ó¥À¡¼¡¦¥Ü¡¼¥ë¤Î¼öʸ¤ò¾§¤¨¤¿¡£");
 #else
-                       else msg_print("You casts a lightning ball.");
+                       else msg_print("You cast a lightning ball.");
 #endif
-               damage = randint(plev * 3) + 8;
+               damage = randint1(plev * 3) + 8;
                fire_ball(GF_ELEC, dir, damage, 2);
                break;
        case MS_BALL_FIRE:
@@ -1121,9 +1042,9 @@ else msg_print("
 #ifdef JP
 else msg_print("¥Õ¥¡¥¤¥¢¡¦¥Ü¡¼¥ë¤Î¼öʸ¤ò¾§¤¨¤¿¡£");
 #else
-                       else msg_print("You casts a fire ball.");
+                       else msg_print("You cast a fire ball.");
 #endif
-               damage = randint(plev * 7) + 10;
+               damage = randint1(plev * 7) + 10;
                fire_ball(GF_FIRE, dir, damage, 2);
                break;
        case MS_BALL_COLD:
@@ -1131,9 +1052,9 @@ else msg_print("
 #ifdef JP
 else msg_print("¥¢¥¤¥¹¡¦¥Ü¡¼¥ë¤Î¼öʸ¤ò¾§¤¨¤¿¡£");
 #else
-                       else msg_print("You casts a frost ball.");
+                       else msg_print("You cast a frost ball.");
 #endif
-               damage = randint(plev * 3) + 10;
+               damage = randint1(plev * 3) + 10;
                fire_ball(GF_COLD, dir, damage, 2);
                break;
        case MS_BALL_POIS:
@@ -1141,7 +1062,7 @@ else msg_print("
 #ifdef JP
 else msg_print("°­½­±À¤Î¼öʸ¤ò¾§¤¨¤¿¡£");
 #else
-                       else msg_print("You casts a stinking cloud.");
+                       else msg_print("You cast a stinking cloud.");
 #endif
                damage = damroll(12,2);
                fire_ball(GF_POIS, dir, damage, 2);
@@ -1151,7 +1072,7 @@ else msg_print("
 #ifdef JP
 else msg_print("ÃϹöµå¤Î¼öʸ¤ò¾§¤¨¤¿¡£");
 #else
-                       else msg_print("You casts a nether ball.");
+                       else msg_print("You cast a nether ball.");
 #endif
                damage = plev * 2 + 50 + damroll(10, 10);
                fire_ball(GF_NETHER, dir, damage, 2);
@@ -1161,9 +1082,9 @@ else msg_print("
 #ifdef JP
 else msg_print("ή¤ì¤ë¤è¤¦¤Ê¿È¿¶¤ê¤ò¤·¤¿¡£");
 #else
-                       else msg_print("You gestures fluidly.");
+                       else msg_print("You gesture fluidly.");
 #endif
-               damage = randint(plev * 4) + 50;
+               damage = randint1(plev * 4) + 50;
                fire_ball(GF_WATER, dir, damage, 4);
                break;
        case MS_BALL_MANA:
@@ -1171,7 +1092,7 @@ else msg_print("ή
 #ifdef JP
 else msg_print("ËâÎϤÎÍò¤Î¼öʸ¤òÇ°¤¸¤¿¡£");
 #else
-                       else msg_print("You invokes a mana storm.");
+                       else msg_print("You invoke a mana storm.");
 #endif
                damage = plev * 8 + 50 + damroll(10, 10);
                fire_ball(GF_MANA, dir, damage, 4);
@@ -1181,14 +1102,14 @@ else msg_print("
 #ifdef JP
 else msg_print("°Å¹õ¤ÎÍò¤Î¼öʸ¤òÇ°¤¸¤¿¡£");
 #else
-                       else msg_print("You invokes a darkness storm.");
+                       else msg_print("You invoke a darkness storm.");
 #endif
                damage = plev * 8 + 50 + damroll(10, 10);
                fire_ball(GF_DARK, dir, damage, 4);
                break;
        case MS_DRAIN_MANA:
                if (!get_aim_dir(&dir)) return FALSE;
-               fire_ball_hide(GF_DRAIN_MANA, dir, randint(plev)+plev, 0);
+               fire_ball_hide(GF_DRAIN_MANA, dir, randint1(plev)+plev, 0);
                break;
        case MS_MIND_BLAST:
                if (!get_aim_dir(&dir)) return FALSE;
@@ -1225,7 +1146,7 @@ else msg_print("
 #ifdef JP
 else msg_print("¥¢¥·¥Ã¥É¡¦¥Ü¥ë¥È¤Î¼öʸ¤ò¾§¤¨¤¿¡£");
 #else
-                       else msg_print("You casts an acid bolt.");
+                       else msg_print("You cast an acid bolt.");
 #endif
                damage = damroll(7, 8) + plev * 2 / 3;
                fire_bolt(GF_ACID, dir, damage);
@@ -1235,7 +1156,7 @@ else msg_print("
 #ifdef JP
 else msg_print("¥µ¥ó¥À¡¼¡¦¥Ü¥ë¥È¤Î¼öʸ¤ò¾§¤¨¤¿¡£");
 #else
-                       else msg_print("You casts a lightning bolt.");
+                       else msg_print("You cast a lightning bolt.");
 #endif
                damage = damroll(4, 8) + plev * 2 / 3;
                fire_bolt(GF_ELEC, dir, damage);
@@ -1245,7 +1166,7 @@ else msg_print("
 #ifdef JP
 else msg_print("¥Õ¥¡¥¤¥¢¡¦¥Ü¥ë¥È¤Î¼öʸ¤ò¾§¤¨¤¿¡£");
 #else
-                       else msg_print("You casts a fire bolt.");
+                       else msg_print("You cast a fire bolt.");
 #endif
                damage = damroll(9, 8) + plev * 2 / 3;
                fire_bolt(GF_FIRE, dir, damage);
@@ -1255,7 +1176,7 @@ else msg_print("
 #ifdef JP
 else msg_print("¥¢¥¤¥¹¡¦¥Ü¥ë¥È¤Î¼öʸ¤ò¾§¤¨¤¿¡£");
 #else
-                       else msg_print("You casts a frost bolt.");
+                       else msg_print("You cast a frost bolt.");
 #endif
                damage = damroll(6, 8) + plev * 2 / 3;
                fire_bolt(GF_COLD, dir, damage);
@@ -1266,7 +1187,7 @@ else msg_print("
 #ifdef JP
 msg_print("¥¹¥¿¡¼¥Ð¡¼¥¹¥È¤Î¼öʸ¤òÇ°¤¸¤¿¡£");
 #else
-                       msg_print("You invokes a starburst.");
+                       msg_print("You invoke a starburst.");
 #endif
                damage = plev * 8 + 50 + damroll(10, 10);
                fire_ball(GF_LITE, dir, damage, 4);
@@ -1276,7 +1197,7 @@ msg_print("
 #ifdef JP
 else msg_print("ÃϹö¤ÎÌð¤Î¼öʸ¤ò¾§¤¨¤¿¡£");
 #else
-                       else msg_print("You casts a nether bolt.");
+                       else msg_print("You cast a nether bolt.");
 #endif
                damage = 30 + damroll(5, 5) + plev * 8 / 3;
                fire_bolt(GF_NETHER, dir, damage);
@@ -1286,7 +1207,7 @@ else msg_print("
 #ifdef JP
 else msg_print("¥¦¥©¡¼¥¿¡¼¡¦¥Ü¥ë¥È¤Î¼öʸ¤ò¾§¤¨¤¿¡£");
 #else
-                       else msg_print("You casts a water bolt.");
+                       else msg_print("You cast a water bolt.");
 #endif
                damage = damroll(10, 10) + plev * 2;
                fire_bolt(GF_WATER, dir, damage);
@@ -1296,9 +1217,9 @@ else msg_print("
 #ifdef JP
 else msg_print("ËâÎϤÎÌð¤Î¼öʸ¤ò¾§¤¨¤¿¡£");
 #else
-                       else msg_print("You casts a mana bolt.");
+                       else msg_print("You cast a mana bolt.");
 #endif
-               damage = randint(plev * 7) + 50;
+               damage = randint1(plev * 7) + 50;
                fire_bolt(GF_MANA, dir, damage);
                break;
        case MS_BOLT_PLASMA:
@@ -1306,7 +1227,7 @@ else msg_print("
 #ifdef JP
 else msg_print("¥×¥é¥º¥Þ¡¦¥Ü¥ë¥È¤Î¼öʸ¤ò¾§¤¨¤¿¡£");
 #else
-                       else msg_print("You casts a plasma bolt.");
+                       else msg_print("You cast a plasma bolt.");
 #endif
                damage = 10 + damroll(8, 7) + plev * 2;
                fire_bolt(GF_PLASMA, dir, damage);
@@ -1316,7 +1237,7 @@ else msg_print("
 #ifdef JP
 else msg_print("¶Ë´¨¤ÎÌð¤Î¼öʸ¤ò¾§¤¨¤¿¡£");
 #else
-                       else msg_print("You casts a ice bolt.");
+                       else msg_print("You cast a ice bolt.");
 #endif
                damage = damroll(6, 6) + plev * 2;
                fire_bolt(GF_ICE, dir, damage);
@@ -1326,7 +1247,7 @@ else msg_print("
 #ifdef JP
 else msg_print("¥Þ¥¸¥Ã¥¯¡¦¥ß¥µ¥¤¥ë¤Î¼öʸ¤ò¾§¤¨¤¿¡£");
 #else
-                       else msg_print("You casts a magic missile.");
+                       else msg_print("You cast a magic missile.");
 #endif
                damage = damroll(2, 6) + plev * 2 / 3;
                fire_bolt(GF_MISSILE, dir, damage);
@@ -1336,7 +1257,7 @@ else msg_print("
 #ifdef JP
 else msg_print("¶²¤í¤·¤²¤Ê¸¸³Ð¤òºî¤ê½Ð¤·¤¿¡£");
 #else
-                       else msg_print("You casts a fearful illusion.");
+                       else msg_print("You cast a fearful illusion.");
 #endif
                fear_monster(dir, plev+10);
                break;
@@ -1349,20 +1270,20 @@ else msg_print("
 #ifdef JP
 else msg_print("ͶÏÇŪ¤Ê¸¸³Ð¤ò¤Ä¤¯¤ê½Ð¤·¤¿¡£");
 #else
-                       else msg_print("You casts a mesmerizing illusion.");
+                       else msg_print("You cast a mesmerizing illusion.");
 #endif
                confuse_monster(dir, plev * 2);
                break;
        case MS_SLOW:
                if (!get_aim_dir(&dir)) return FALSE;
-               slow_monster(dir);
+               slow_monster(dir, plev);
                break;
        case MS_SLEEP:
                if (!get_aim_dir(&dir)) return FALSE;
-               sleep_monster(dir);
+               sleep_monster(dir, plev);
                break;
        case MS_SPEED:
-               (void)set_fast(randint(20 + plev) + plev, FALSE);
+               (void)set_fast(randint1(20 + plev) + plev, FALSE);
                break;
        case MS_HAND_DOOM:
        {
@@ -1370,7 +1291,7 @@ else msg_print("Ͷ
 #ifdef JP
 else msg_print("<ÇËÌǤμê>¤òÊü¤Ã¤¿¡ª");
 #else
-               else msg_print("You invokes the Hand of Doom!");
+               else msg_print("You invoke the Hand of Doom!");
 #endif
 
                fire_ball_hide(GF_HAND_DOOM, dir, plev * 3, 0);
@@ -1380,7 +1301,7 @@ else msg_print("<
 #ifdef JP
 msg_print("¼«Ê¬¤Î½ý¤ËÇ°¤ò½¸Ã椷¤¿¡£");
 #else
-                       msg_print("You concentrates on your wounds!");
+                       msg_print("You concentrate on your wounds!");
 #endif
                (void)hp_player(plev*4);
                (void)set_stun(0);
@@ -1390,15 +1311,15 @@ msg_print("
 #ifdef JP
 msg_print("̵½ý¤Îµå¤Î¼öʸ¤ò¾§¤¨¤¿¡£");
 #else
-                       msg_print("You casts a Globe of Invulnerability.");
+                       msg_print("You cast a Globe of Invulnerability.");
 #endif
-               (void)set_invuln(randint(4) + 4, FALSE);
+               (void)set_invuln(randint1(4) + 4, FALSE);
                break;
        case MS_BLINK:
-               teleport_player(10);
+               teleport_player(10, 0L);
                break;
        case MS_TELEPORT:
-               teleport_player(plev * 5);
+               teleport_player(plev * 5, 0L);
                break;
        case MS_WORLD:
                world_player = TRUE;
@@ -1409,7 +1330,8 @@ msg_print("̵
 #endif
                msg_print(NULL);
 
-               p_ptr->energy += (randint(200)+1200);
+               /* Hack */
+               p_ptr->energy_need -= 1000 + (100 + randint1(200)+200)*TURNS_PER_TICK/10;
 
                /* Redraw map */
                p_ptr->redraw |= (PR_MAP);
@@ -1433,27 +1355,28 @@ msg_print("̵
                if (!target_set(TARGET_KILL)) return FALSE;
                if (!cave[target_row][target_col].m_idx) break;
                if (!player_has_los_bold(target_row, target_col)) break;
+               if (!projectable(py, px, target_row, target_col)) break;
                m_ptr = &m_list[cave[target_row][target_col].m_idx];
                r_ptr = &r_info[m_ptr->r_idx];
                monster_desc(m_name, m_ptr, 0);
-               if (r_ptr->flags3 & (RF3_RES_TELE))
+               if (r_ptr->flagsr & RFR_RES_TELE)
                {
-                       if ((r_ptr->flags1 & (RF1_UNIQUE)) || (r_ptr->flags3 & (RF3_RES_ALL)))
+                       if ((r_ptr->flags1 & (RF1_UNIQUE)) || (r_ptr->flagsr & RFR_RES_ALL))
                        {
-                               r_ptr->r_flags3 |= RF3_RES_TELE;
+                               if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
 #ifdef JP
-msg_format("%s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª", m_name);
+                               msg_format("%s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª", m_name);
 #else
                                msg_format("%s is unaffected!", m_name);
 #endif
 
                                break;
                        }
-                       else if (r_ptr->level > randint(100))
+                       else if (r_ptr->level > randint1(100))
                        {
-                               r_ptr->r_flags3 |= RF3_RES_TELE;
+                               if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
 #ifdef JP
-msg_format("%s¤Ë¤ÏÂÑÀ­¤¬¤¢¤ë¡ª", m_name);
+                               msg_format("%s¤Ë¤ÏÂÑÀ­¤¬¤¢¤ë¡ª", m_name);
 #else
                                msg_format("%s resists!", m_name);
 #endif
@@ -1467,7 +1390,7 @@ msg_format("%s
                msg_format("You command %s to return.", m_name);
 #endif
 
-               teleport_to_player(cave[target_row][target_col].m_idx, 100);
+               teleport_monster_to(cave[target_row][target_col].m_idx, py, px, 100, TELEPORT_PASSIVE);
                break;
        }
        case MS_TELE_AWAY:
@@ -1477,49 +1400,35 @@ msg_format("%s
                break;
        case MS_TELE_LEVEL:
        {
+               int target_m_idx;
                monster_type *m_ptr;
                monster_race *r_ptr;
                char m_name[80];
 
                if (!target_set(TARGET_KILL)) return FALSE;
-               if (!cave[target_row][target_col].m_idx) break;
-               if (!los(py, px, target_row, target_col)) break;
-               m_ptr = &m_list[cave[target_row][target_col].m_idx];
+               target_m_idx = cave[target_row][target_col].m_idx;
+               if (!target_m_idx) break;
+               if (!player_has_los_bold(target_row, target_col)) break;
+               if (!projectable(py, px, target_row, target_col)) break;
+               m_ptr = &m_list[target_m_idx];
                r_ptr = &r_info[m_ptr->r_idx];
                monster_desc(m_name, m_ptr, 0);
 #ifdef JP
-msg_format("%s¤Î­¤ò»Ø¤µ¤·¤¿¡£", m_name);
+               msg_format("%^s¤Î­¤ò»Ø¤µ¤·¤¿¡£", m_name);
 #else
-                       msg_format("You gestures at %s's feet.", m_name);
+               msg_format("You gesture at %^s's feet.", m_name);
 #endif
 
-               if ((r_ptr->flags3 & RF3_RES_TELE) || (r_ptr->flags1 & RF1_QUESTOR) || (r_ptr->level + randint(50) > plev + randint(60)))
+               if ((r_ptr->flagsr & (RFR_EFF_RES_NEXU_MASK | RFR_RES_TELE)) ||
+                       (r_ptr->flags1 & RF1_QUESTOR) || (r_ptr->level + randint1(50) > plev + randint1(60)))
                {
 #ifdef JP
-msg_print("¤·¤«¤·¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª");
+                       msg_print("¤·¤«¤·¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª");
 #else
-                       msg_format("%s are unaffected!", m_name);
+                       msg_format("%^s is unaffected!", m_name);
 #endif
-
-               }
-               else if (randint(2) == 1)
-               {
-#ifdef JP
-msg_format("%s¤Ï¾²¤òÆͤ­ÇˤäÆÄÀ¤ó¤Ç¤¤¤Ã¤¿¡£", m_name);
-#else
-                       msg_format("%s sink through the floor.", m_name);
-#endif
-                       delete_monster_idx(cave[target_row][target_col].m_idx);
-               }
-               else
-               {
-#ifdef JP
-msg_format("%s¤ÏÅ·°æ¤òÆͤ­ÇˤäÆÃè¤ØÉ⤤¤Æ¤¤¤Ã¤¿¡£",m_name);
-#else
-                       msg_format("%s rise up through the ceiling.", m_name);
-#endif
-                       delete_monster_idx(cave[target_row][target_col].m_idx);
                }
+               else teleport_level(target_m_idx);
                break;
        }
        case MS_PSY_SPEAR:
@@ -1528,16 +1437,16 @@ msg_format("%s
 #ifdef JP
 else msg_print("¸÷¤Î·õ¤òÊü¤Ã¤¿¡£");
 #else
-                       else msg_print("You throws a psycho-spear.");
+                       else msg_print("You throw a psycho-spear.");
 #endif
-               damage = randint(plev * 3) + 100;
+               damage = randint1(plev * 3) + 100;
                (void)fire_beam(GF_PSY_SPEAR, dir, damage);
                break;
        case MS_DARKNESS:
 #ifdef JP
 msg_print("°Å°Ç¤ÎÃæ¤Ç¼ê¤ò¿¶¤Ã¤¿¡£");
 #else
-                       msg_print("You gestures in shadow.");
+                       msg_print("You gesture in shadow.");
 #endif
                (void)unlite_area(10, 3);
                break;
@@ -1546,7 +1455,7 @@ msg_print("
 #ifdef JP
 msg_print("¼öʸ¤ò¾§¤¨¤Æ¼Ù°­¤ËÈù¾Ð¤ó¤À¡£");
 #else
-                       msg_print("You casts a spell and cackles evilly.");
+                       msg_print("You cast a spell and cackle evilly.");
 #endif
                trap_creation(target_row, target_col);
                break;
@@ -1561,7 +1470,7 @@ msg_print("
 #ifdef JP
 msg_print("»à¼ÔÉü³è¤Î¼öʸ¤ò¾§¤¨¤¿¡£");
 #else
-               msg_print("You casts a animate dead.");
+               msg_print("You cast a animate dead.");
 #endif
                (void)animate_dead(0, py, px);
                break;
@@ -1571,17 +1480,17 @@ msg_print("
 #ifdef JP
 msg_print("±ç·³¤ò¾¤´­¤·¤¿¡£");
 #else
-                       msg_print("You summons minions.");
+                       msg_print("You summon minions.");
 #endif
                for (k = 0;k < 1; k++)
                {
-                       if (summon_kin_player(pet, summon_lev, py, px, FALSE))
+                       if (summon_kin_player(summon_lev, py, px, (pet ? PM_FORCE_PET : 0L)))
                        {
                                if (!pet)
 #ifdef JP
-msg_print("¾¤´Ô¤µ¤ì¤¿Ãç´Ö¤ÏÅܤäƤ¤¤ë¡ª");
+msg_print("¾¤´­¤µ¤ì¤¿Ãç´Ö¤ÏÅܤäƤ¤¤ë¡ª");
 #else
-msg_print("Summoned fellows is angry!");
+msg_print("Summoned fellows are angry!");
 #endif
                        }
                        else
@@ -1597,16 +1506,16 @@ msg_print("Summoned fellows is angry!");
 #ifdef JP
 msg_print("¥µ¥¤¥Ð¡¼¥Ç¡¼¥â¥ó¤ò¾¤´­¤·¤¿¡ª");
 #else
-                       msg_print("You summons Cyberdemons!");
+                       msg_print("You summon a Cyberdemon!");
 #endif
                for (k = 0 ;k < 1 ; k++)
-                       if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_CYBER, FALSE, FALSE, pet, FALSE, not_pet))
+                       if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_CYBER, p_mode))
                        {
                                if (!pet)
 #ifdef JP
-msg_print("¾¤´Ô¤µ¤ì¤¿¥µ¥¤¥Ð¡¼¥Ç¡¼¥â¥ó¤ÏÅܤäƤ¤¤ë¡ª");
+msg_print("¾¤´­¤µ¤ì¤¿¥µ¥¤¥Ð¡¼¥Ç¡¼¥â¥ó¤ÏÅܤäƤ¤¤ë¡ª");
 #else
-msg_print("Summoned Cyberdemons are angry!");
+msg_print("The summoned Cyberdemon are angry!");
 #endif
                        }
                        else
@@ -1621,16 +1530,16 @@ msg_print("Summoned Cyberdemons are angry!");
 #ifdef JP
 msg_print("Ãç´Ö¤ò¾¤´­¤·¤¿¡£");
 #else
-                       msg_print("You summons help.");
+                       msg_print("You summon help.");
 #endif
                for (k = 0;k < 1; k++)
-                       if (summon_specific((pet ? -1 : 0), py, px, summon_lev, 0, FALSE, FALSE, pet, FALSE, not_pet))
+                       if (summon_specific((pet ? -1 : 0), py, px, summon_lev, 0, p_mode))
                        {
                                if (!pet)
 #ifdef JP
-msg_print("¾¤´Ô¤µ¤ì¤¿¥â¥ó¥¹¥¿¡¼¤ÏÅܤäƤ¤¤ë¡ª");
+msg_print("¾¤´­¤µ¤ì¤¿¥â¥ó¥¹¥¿¡¼¤ÏÅܤäƤ¤¤ë¡ª");
 #else
-msg_print("Summoned monster is angry!");
+msg_print("The summoned monster is angry!");
 #endif
                        }
                        else
@@ -1645,14 +1554,14 @@ msg_print("Summoned monster is angry!");
 #ifdef JP
 msg_print("¥â¥ó¥¹¥¿¡¼¤ò¾¤´­¤·¤¿¡ª");
 #else
-                       msg_print("You summons monsters!");
+                       msg_print("You summon monsters!");
 #endif
                for (k = 0;k < plev / 15 + 2; k++)
-                       if(summon_specific((pet ? -1 : 0), py, px, summon_lev, 0, FALSE, FALSE, pet, unique_okay, not_pet))
+                       if(summon_specific((pet ? -1 : 0), py, px, summon_lev, 0, (p_mode | u_mode)))
                        {
                                if (!pet)
 #ifdef JP
-msg_print("¾¤´Ô¤µ¤ì¤¿¥â¥ó¥¹¥¿¡¼¤ÏÅܤäƤ¤¤ë¡ª");
+msg_print("¾¤´­¤µ¤ì¤¿¥â¥ó¥¹¥¿¡¼¤ÏÅܤäƤ¤¤ë¡ª");
 #else
 msg_print("Summoned monsters are angry!");
 #endif
@@ -1669,14 +1578,14 @@ msg_print("Summoned monsters are angry!");
 #ifdef JP
 msg_print("¥¢¥ê¤ò¾¤´­¤·¤¿¡£");
 #else
-                       msg_print("You summons ants.");
+                       msg_print("You summon ants.");
 #endif
                for (k = 0;k < 1; k++)
-                       if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_ANT, TRUE, FALSE, pet, FALSE, not_pet))
+                       if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_ANT, (PM_ALLOW_GROUP | p_mode)))
                        {
                                if (!pet)
 #ifdef JP
-msg_print("¾¤´Ô¤µ¤ì¤¿¥¢¥ê¤ÏÅܤäƤ¤¤ë¡ª");
+msg_print("¾¤´­¤µ¤ì¤¿¥¢¥ê¤ÏÅܤäƤ¤¤ë¡ª");
 #else
 msg_print("Summoned ants are angry!");
 #endif
@@ -1693,14 +1602,14 @@ msg_print("Summoned ants are angry!");
 #ifdef JP
 msg_print("ÃØéá¤ò¾¤´­¤·¤¿¡£");
 #else
-                       msg_print("You summons spiders.");
+                       msg_print("You summon spiders.");
 #endif
                for (k = 0;k < 1; k++)
-                       if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_SPIDER, TRUE, FALSE, pet, FALSE, not_pet))
+                       if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_SPIDER, (PM_ALLOW_GROUP | p_mode)))
                        {
                                if (!pet)
 #ifdef JP
-msg_print("¾¤´Ô¤µ¤ì¤¿ÃØéá¤ÏÅܤäƤ¤¤ë¡ª");
+msg_print("¾¤´­¤µ¤ì¤¿ÃØéá¤ÏÅܤäƤ¤¤ë¡ª");
 #else
 msg_print("Summoned spiders are angry!");
 #endif
@@ -1717,14 +1626,14 @@ msg_print("Summoned spiders are angry!");
 #ifdef JP
 msg_print("¥Ï¥¦¥ó¥É¤ò¾¤´­¤·¤¿¡£");
 #else
-                       msg_print("You summons hounds.");
+                       msg_print("You summon hounds.");
 #endif
                for (k = 0;k < 1; k++)
-                       if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_HOUND, TRUE, FALSE, pet, FALSE, not_pet))
+                       if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_HOUND, (PM_ALLOW_GROUP | p_mode)))
                        {
                                if (!pet)
 #ifdef JP
-msg_print("¾¤´Ô¤µ¤ì¤¿¥Ï¥¦¥ó¥É¤ÏÅܤäƤ¤¤ë¡ª");
+msg_print("¾¤´­¤µ¤ì¤¿¥Ï¥¦¥ó¥É¤ÏÅܤäƤ¤¤ë¡ª");
 #else
 msg_print("Summoned hounds are angry!");
 #endif
@@ -1741,14 +1650,14 @@ msg_print("Summoned hounds are angry!");
 #ifdef JP
 msg_print("¥Ò¥É¥é¤ò¾¤´­¤·¤¿¡£");
 #else
-                       msg_print("You summons hydras.");
+                       msg_print("You summon a hydras.");
 #endif
                for (k = 0;k < 1; k++)
-                       if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_HYDRA, not_pet, FALSE, pet, FALSE, not_pet))
+                       if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_HYDRA, (g_mode | p_mode)))
                        {
                                if (!pet)
 #ifdef JP
-msg_print("¾¤´Ô¤µ¤ì¤¿¥Ò¥É¥é¤ÏÅܤäƤ¤¤ë¡ª");
+msg_print("¾¤´­¤µ¤ì¤¿¥Ò¥É¥é¤ÏÅܤäƤ¤¤ë¡ª");
 #else
 msg_print("Summoned hydras are angry!");
 #endif
@@ -1765,16 +1674,16 @@ msg_print("Summoned hydras are angry!");
 #ifdef JP
 msg_print("Å·»È¤ò¾¤´­¤·¤¿¡ª");
 #else
-                       msg_print("You summons angel!");
+                       msg_print("You summon an angel!");
 #endif
                for (k = 0;k < 1; k++)
-                       if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_ANGEL, not_pet, FALSE, pet, FALSE, not_pet))
+                       if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_ANGEL, (g_mode | p_mode)))
                        {
                                if (!pet)
 #ifdef JP
-msg_print("¾¤´Ô¤µ¤ì¤¿Å·»È¤ÏÅܤäƤ¤¤ë¡ª");
+msg_print("¾¤´­¤µ¤ì¤¿Å·»È¤ÏÅܤäƤ¤¤ë¡ª");
 #else
-msg_print("Summoned angel is angry!");
+msg_print("Summoned angels are angry!");
 #endif
                        }
                        else
@@ -1789,16 +1698,16 @@ msg_print("Summoned angel is angry!");
 #ifdef JP
 msg_print("º®Æ٤εÜÄ¤é°­Ëâ¤ò¾¤´­¤·¤¿¡ª");
 #else
-                       msg_print("You summons a demon from the Courts of Chaos!");
+                       msg_print("You summon a demon from the Courts of Chaos!");
 #endif
                for (k = 0;k < 1; k++)
-                       if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_DEMON, not_pet, FALSE, pet, FALSE, not_pet))
+                       if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_DEMON, (g_mode | p_mode)))
                        {
                                if (!pet)
 #ifdef JP
-msg_print("¾¤´Ô¤µ¤ì¤¿¥Ç¡¼¥â¥ó¤ÏÅܤäƤ¤¤ë¡ª");
+msg_print("¾¤´­¤µ¤ì¤¿¥Ç¡¼¥â¥ó¤ÏÅܤäƤ¤¤ë¡ª");
 #else
-msg_print("Summoned demon is angry!");
+msg_print("Summoned demons are angry!");
 #endif
                        }
                        else
@@ -1813,16 +1722,16 @@ msg_print("Summoned demon is angry!");
 #ifdef JP
 msg_print("¥¢¥ó¥Ç¥Ã¥É¤Î¶¯Å¨¤ò¾¤´­¤·¤¿¡ª");
 #else
-                       msg_print("You summons an undead adversary!");
+                       msg_print("You summon an undead adversary!");
 #endif
                for (k = 0;k < 1; k++)
-                       if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_UNDEAD, not_pet, FALSE, pet, FALSE, not_pet))
+                       if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_UNDEAD, (g_mode | p_mode)))
                        {
                                if (!pet)
 #ifdef JP
-msg_print("¾¤´Ô¤µ¤ì¤¿¥¢¥ó¥Ç¥Ã¥É¤ÏÅܤäƤ¤¤ë¡ª");
+msg_print("¾¤´­¤µ¤ì¤¿¥¢¥ó¥Ç¥Ã¥É¤ÏÅܤäƤ¤¤ë¡ª");
 #else
-msg_print("Summoned undead is angry!");
+msg_print("Summoned undeads are angry!");
 #endif
                        }
                        else
@@ -1837,16 +1746,16 @@ msg_print("Summoned undead is angry!");
 #ifdef JP
 msg_print("¥É¥é¥´¥ó¤ò¾¤´­¤·¤¿¡ª");
 #else
-                       msg_print("You summons dragon!");
+                       msg_print("You summon a dragon!");
 #endif
                for (k = 0;k < 1; k++)
-                       if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_DRAGON, not_pet, FALSE, pet, FALSE, not_pet))
+                       if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_DRAGON, (g_mode | p_mode)))
                        {
                                if (!pet)
 #ifdef JP
-msg_print("¾¤´Ô¤µ¤ì¤¿¥É¥é¥´¥ó¤ÏÅܤäƤ¤¤ë¡ª");
+msg_print("¾¤´­¤µ¤ì¤¿¥É¥é¥´¥ó¤ÏÅܤäƤ¤¤ë¡ª");
 #else
-msg_print("Summoned dragon is angry!");
+msg_print("Summoned dragons are angry!");
 #endif
                        }
                        else
@@ -1861,16 +1770,16 @@ msg_print("Summoned dragon is angry!");
 #ifdef JP
 msg_print("¶¯ÎϤʥ¢¥ó¥Ç¥Ã¥É¤ò¾¤´­¤·¤¿¡ª");
 #else
-                       msg_print("You summons greater undead!");
+                       msg_print("You summon a greater undead!");
 #endif
                for (k = 0;k < 1; k++)
-                       if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_HI_UNDEAD, not_pet, FALSE, pet, unique_okay, not_pet))
+                       if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_HI_UNDEAD, (g_mode | p_mode | u_mode)))
                        {
                                if (!pet)
 #ifdef JP
-msg_print("¾¤´Ô¤µ¤ì¤¿¾åµé¥¢¥ó¥Ç¥Ã¥É¤ÏÅܤäƤ¤¤ë¡ª");
+msg_print("¾¤´­¤µ¤ì¤¿¾åµé¥¢¥ó¥Ç¥Ã¥É¤ÏÅܤäƤ¤¤ë¡ª");
 #else
-msg_print("Summoned greater undead is angry!");
+msg_print("Summoned greater undeads are angry!");
 #endif
                        }
                        else
@@ -1885,16 +1794,16 @@ msg_print("Summoned greater undead is angry!");
 #ifdef JP
 msg_print("¸ÅÂå¥É¥é¥´¥ó¤ò¾¤´­¤·¤¿¡ª");
 #else
-                       msg_print("You summons ancient dragons!");
+                       msg_print("You summon an ancient dragon!");
 #endif
                for (k = 0;k < 1; k++)
-                       if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_HI_DRAGON, not_pet, FALSE, pet, unique_okay, not_pet))
+                       if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_HI_DRAGON, (g_mode | p_mode | u_mode)))
                        {
                                if (!pet)
 #ifdef JP
-msg_print("¾¤´Ô¤µ¤ì¤¿¸ÅÂå¥É¥é¥´¥ó¤ÏÅܤäƤ¤¤ë¡ª");
+msg_print("¾¤´­¤µ¤ì¤¿¸ÅÂå¥É¥é¥´¥ó¤ÏÅܤäƤ¤¤ë¡ª");
 #else
-msg_print("Summoned ancient dragon is angry!");
+msg_print("Summoned ancient dragons are angry!");
 #endif
                        }
                        else
@@ -1907,16 +1816,16 @@ msg_print("Summoned ancient dragon is angry!");
        {
                int k;
 #ifdef JP
-msg_print("¥¢¥ó¥Ð¡¼¤Î²¦¤ò¾¤´­¤·¤¿¡ª");
+msg_print("¥¢¥ó¥Ð¡¼¤Î²¦²¤ò¾¤´­¤·¤¿¡ª");
 #else
-                       msg_print("You summons Lords of Amber!");
+                       msg_print("You summon a Lord of Amber!");
 #endif
                for (k = 0;k < 1; k++)
-                       if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_AMBERITES, not_pet, FALSE, pet, unique_okay, not_pet))
+                       if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_AMBERITES, (g_mode | p_mode | u_mode)))
                        {
                                if (!pet)
 #ifdef JP
-msg_print("¾¤´Ô¤µ¤ì¤¿¥¢¥ó¥Ð¡¼¤Î²¦¤ÏÅܤäƤ¤¤ë¡ª");
+msg_print("¾¤´­¤µ¤ì¤¿¥¢¥ó¥Ð¡¼¤Î²¦Â²¤ÏÅܤäƤ¤¤ë¡ª");
 #else
 msg_print("Summoned Lords of Amber are angry!");
 #endif
@@ -1933,28 +1842,28 @@ msg_print("Summoned Lords of Amber are angry!");
 #ifdef JP
 msg_print("ÆÃÊ̤ʶ¯Å¨¤ò¾¤´­¤·¤¿¡ª");
 #else
-                       msg_print("You summons special opponents!");
+                       msg_print("You summon a special opponent!");
 #endif
                for (k = 0;k < 1; k++)
-                       if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_UNIQUE, not_pet, FALSE, pet, TRUE, not_pet))
+                       if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_UNIQUE, (g_mode | p_mode | PM_ALLOW_UNIQUE)))
                        {
                                count++;
                                if (!pet)
 #ifdef JP
-msg_print("¾¤´Ô¤µ¤ì¤¿¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼¤ÏÅܤäƤ¤¤ë¡ª");
+msg_print("¾¤´­¤µ¤ì¤¿¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼¤ÏÅܤäƤ¤¤ë¡ª");
 #else
 msg_print("Summoned special opponents are angry!");
 #endif
                        }
                for (k = count;k < 1; k++)
-                       if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_HI_UNDEAD, not_pet, FALSE, pet, TRUE, not_pet))
+                       if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_HI_UNDEAD, (g_mode | p_mode | PM_ALLOW_UNIQUE)))
                        {
                                count++;
                                if (!pet)
 #ifdef JP
-msg_print("¾¤´Ô¤µ¤ì¤¿¾åµé¥¢¥ó¥Ç¥Ã¥É¤ÏÅܤäƤ¤¤ë¡ª");
+msg_print("¾¤´­¤µ¤ì¤¿¾åµé¥¢¥ó¥Ç¥Ã¥É¤ÏÅܤäƤ¤¤ë¡ª");
 #else
-msg_print("Summoned greater undead are angry!");
+msg_print("Summoned greater undeads are angry!");
 #endif
                        }
                if (!count)
@@ -1991,7 +1900,7 @@ bool do_cmd_cast_learned(void)
        int             plev = p_ptr->lev;
        monster_power   spell;
        bool            cast;
-       int             shouhimana;
+       int             need_mana;
 
 
        /* not if confused */
@@ -2011,15 +1920,10 @@ msg_print("
 
        spell = monster_powers[n];
 
-       shouhimana = spell.smana;
-
-       if (p_ptr->dec_mana)
-       {
-               shouhimana = (shouhimana + 1) * 3 / 4;
-       }
+       need_mana = mod_need_mana(spell.smana, 0, REALM_NONE);
 
        /* Verify "dangerous" spells */
-       if (shouhimana > p_ptr->csp)
+       if (need_mana > p_ptr->csp)
        {
                /* Warning */
 #ifdef JP
@@ -2047,22 +1951,15 @@ if (!get_check("
        if (plev > spell.level) chance -= 3 * (plev - spell.level);
        else chance += (spell.level - plev);
 
-       if (p_ptr->pseikaku == SEIKAKU_NAMAKE) chance += 10;
-       if (p_ptr->pseikaku == SEIKAKU_KIREMONO) chance -= 3;
-       if ((p_ptr->pseikaku == SEIKAKU_GAMAN) || (p_ptr->pseikaku == SEIKAKU_CHIKARA)) chance++;
-
        /* Reduce failure rate by INT/WIS adjustment */
        chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[A_INT]] - 1);
 
-       if (p_ptr->heavy_spell) chance += 20;
-       if(p_ptr->dec_mana && p_ptr->easy_spell) chance-=4;
-       else if (p_ptr->easy_spell) chance-=3;
-       else if (p_ptr->dec_mana) chance-=2;
+       chance = mod_spell_chance_1(chance);
 
        /* Not enough mana to cast */
-       if (shouhimana > p_ptr->csp)
+       if (need_mana > p_ptr->csp)
        {
-               chance += 5 * (shouhimana - p_ptr->csp);
+               chance += 5 * (need_mana - p_ptr->csp);
        }
 
        /* Extract the minimum failure rate */
@@ -2078,12 +1975,10 @@ if (!get_check("
        /* Always a 5 percent chance of working */
        if (chance > 95) chance = 95;
 
-       if(p_ptr->dec_mana) chance--;
-       if (p_ptr->heavy_spell) chance += 5;
-       chance = MAX(chance,0);
+       chance = mod_spell_chance_2(chance);
 
        /* Failed spell */
-       if (rand_int(100) < chance)
+       if (randint0(100) < chance)
        {
                if (flush_failure) flush();
 #ifdef JP
@@ -2109,14 +2004,14 @@ msg_print("
        }
 
        /* Sufficient mana */
-       if (shouhimana <= p_ptr->csp)
+       if (need_mana <= p_ptr->csp)
        {
                /* Use some mana */
-               p_ptr->csp -= shouhimana;
+               p_ptr->csp -= need_mana;
        }
        else
        {
-               int oops = shouhimana;
+               int oops = need_mana;
 
                /* No mana left */
                p_ptr->csp = 0;
@@ -2131,14 +2026,14 @@ msg_print("
 
 
                /* Hack -- Bypass free action */
-               (void)set_paralyzed(p_ptr->paralyzed + randint(5 * oops + 1));
+               (void)set_paralyzed(p_ptr->paralyzed + randint1(5 * oops + 1));
 
                chg_virtue(V_KNOWLEDGE, -10);
 
                /* Damage CON (possibly permanently) */
-               if (rand_int(100) < 50)
+               if (randint0(100) < 50)
                {
-                       bool perm = (rand_int(100) < 25);
+                       bool perm = (randint0(100) < 25);
 
                        /* Message */
 #ifdef JP
@@ -2149,7 +2044,7 @@ msg_print("
 
 
                        /* Reduce constitution */
-                       (void)dec_stat(A_CON, 15 + randint(10), perm);
+                       (void)dec_stat(A_CON, 15 + randint1(10), perm);
                }
        }
 
@@ -2167,9 +2062,10 @@ msg_print("
 void learn_spell(int monspell)
 {
        if (p_ptr->action != ACTION_LEARN) return;
+       if (monspell < 0) return; /* Paranoia */
        if (p_ptr->magic_num2[monspell]) return;
        if (p_ptr->confused || p_ptr->blind || p_ptr->image || p_ptr->stun || p_ptr->paralyzed) return;
-       if (randint(p_ptr->lev + 70) > monster_powers[monspell].level + 40)
+       if (randint1(p_ptr->lev + 70) > monster_powers[monspell].level + 40)
        {
                p_ptr->magic_num2[monspell] = 1;
 #ifdef JP
@@ -2186,3 +2082,45 @@ void learn_spell(int monspell)
                p_ptr->redraw |= (PR_STATE);
        }
 }
+
+
+/*
+ * Extract monster spells mask for the given mode
+ */
+void set_rf_masks(s32b *f4, s32b *f5, s32b *f6, int mode)
+{
+       switch (mode)
+       {
+               case MONSPELL_TYPE_BOLT:
+                       *f4 = ((RF4_BOLT_MASK | RF4_BEAM_MASK) & ~(RF4_ROCKET));
+                       *f5 = RF5_BOLT_MASK | RF5_BEAM_MASK;
+                       *f6 = RF6_BOLT_MASK | RF6_BEAM_MASK;
+                       break;
+
+               case MONSPELL_TYPE_BALL:
+                       *f4 = (RF4_BALL_MASK & ~(RF4_BREATH_MASK));
+                       *f5 = (RF5_BALL_MASK & ~(RF5_BREATH_MASK));
+                       *f6 = (RF6_BALL_MASK & ~(RF6_BREATH_MASK));
+                       break;
+
+               case MONSPELL_TYPE_BREATH:
+                       *f4 = RF4_BREATH_MASK;
+                       *f5 = RF5_BREATH_MASK;
+                       *f6 = RF6_BREATH_MASK;
+                       break;
+
+               case MONSPELL_TYPE_SUMMON:
+                       *f4 = RF4_SUMMON_MASK;
+                       *f5 = RF5_SUMMON_MASK;
+                       *f6 = RF6_SUMMON_MASK;
+                       break;
+
+               case MONSPELL_TYPE_OTHER:
+                       *f4 = RF4_ATTACK_MASK & ~(RF4_BOLT_MASK | RF4_BEAM_MASK | RF4_BALL_MASK | RF4_INDIRECT_MASK);
+                       *f5 = RF5_ATTACK_MASK & ~(RF5_BOLT_MASK | RF5_BEAM_MASK | RF5_BALL_MASK | RF5_INDIRECT_MASK);
+                       *f6 = RF6_ATTACK_MASK & ~(RF6_BOLT_MASK | RF6_BEAM_MASK | RF6_BALL_MASK | RF6_INDIRECT_MASK);
+                       break;
+       }
+
+       return;
+}