OSDN Git Service

Extend features of tiling. (separation of Cell size and Tile size / add offset position.)
[hengband/hengband.git] / src / mspells3.c
index c1864a0..671f664 100644 (file)
@@ -1,19 +1,25 @@
-/* File: mspells3.c */
-
-/*
- * 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.  Other copyrights may also apply.
+/*!
+ * @file mspells3.c
+ * @brief ÀÄËâË¡¤Î½èÍý¼ÂÁõ / Blue magic
+ * @date 2014/01/15
+ * @author
+ * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke\n
+ * This software may be copied and distributed for educational, research,\n
+ * and not for profit purposes provided that this copyright and statement\n
+ * are included in all such copies.  Other copyrights may also apply.\n
+ * 2014 Deskull rearranged comment for Doxygen.\n
  */
 
-/* Purpose: Mane code */
-
 #include "angband.h"
 
-#define pseudo_plev() (((p_ptr->lev + 40) * (p_ptr->lev + 40) - 1550) / 130)
+#define pseudo_plev() (((p_ptr->lev + 40) * (p_ptr->lev + 40) - 1550) / 130) /*!< ¥â¥ó¥¹¥¿¡¼ËâË¡¤ò¥×¥ì¥¤¥ä¡¼¤¬»ÈÍѤ¹¤ë¾ì¹ç¤Î´¹»»¥ì¥Ù¥ë */
 
+/*!
+ * @brief ¼õ¤±¼è¤Ã¤¿¥â¥ó¥¹¥¿¡¼ËâË¡¤ÎID¤Ë±þ¤¸¤ÆÀÄËâË¡¤Î¸ú²Ì¾ðÊó¤ò¤Þ¤È¤á¤¿¥Õ¥©¡¼¥Þ¥Ã¥È¤òÊÖ¤¹
+ * @param p ¾ðÊó¤òÊÖ¤¹Ê¸»úÎ󻲾ȥݥ¤¥ó¥¿
+ * @param power ¥â¥ó¥¹¥¿¡¼ËâË¡¤ÎID
+ * @return ¤Ê¤·
+ */
 static void learned_info(char *p, int power)
 {
        int plev = pseudo_plev();
@@ -235,19 +241,22 @@ static void learned_info(char *p, int power)
 }
 
 
-/*
+/*!
+ * @brief »ÈÍѲÄǽ¤ÊÀÄËâË¡¤òÁªÂò¤¹¤ë /
  * Allow user to choose a imitation.
- *
- * If a valid spell is chosen, saves it in '*sn' and returns TRUE
- * If the user hits escape, returns FALSE, and set '*sn' to -1
- * If there are no legal choices, returns FALSE, and sets '*sn' to -2
- *
- * The "prompt" should be "cast", "recite", or "study"
- * The "known" should be TRUE for cast/pray, FALSE for study
- *
- * nb: This function has a (trivial) display bug which will be obvious
- * when you run it. It's probably easy to fix but I haven't tried,
- * sorry.
+ * @param sn ÁªÂò¤·¤¿¥â¥ó¥¹¥¿¡¼¹¶·âID¡¢¥­¥ã¥ó¥»¥ë¤Î¾ì¹ç-1¡¢ÉÔÀµ¤ÊÁªÂò¤Î¾ì¹ç-2¤òÊÖ¤¹
+ * @return È¯Æ°²Äǽ¤ÊËâË¡¤òÁªÂò¤·¤¿¾ì¹çTRUE¡¢¥­¥ã¥ó¥»¥ë½èÍý¤«ÉÔÀµ¤ÊÁªÂò¤¬¹Ô¤ï¤ì¤¿¾ì¹çFALSE¤òÊÖ¤¹¡£
+ * @details
+ * If a valid spell is chosen, saves it in '*sn' and returns TRUE\n
+ * If the user hits escape, returns FALSE, and set '*sn' to -1\n
+ * If there are no legal choices, returns FALSE, and sets '*sn' to -2\n
+ *\n
+ * The "prompt" should be "cast", "recite", or "study"\n
+ * The "known" should be TRUE for cast/pray, FALSE for study\n
+ *\n
+ * nb: This function has a (trivial) display bug which will be obvious\n
+ * when you run it. It's probably easy to fix but I haven't tried,\n
+ * sorry.\n
  */
 static int get_learned_power(int *sn)
 {
@@ -418,13 +427,13 @@ 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();
 
@@ -544,15 +553,10 @@ put_str("MP 
                                        if (plev > spell.level) chance -= 3 * (plev - spell.level);
                                        else chance += (spell.level - plev);
 
-                                       chance += p_ptr->to_m_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);
 
                                        need_mana = mod_need_mana(monster_powers[spellnum[i]].smana, 0, REALM_NONE);
 
@@ -575,9 +579,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]);
@@ -647,7 +649,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
@@ -665,14 +667,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);
@@ -691,9 +689,12 @@ put_str("MP 
 }
 
 
-/*
- * do_cmd_cast calls this function if the player's class
- * is 'imitator'.
+/*!
+ * @brief ÀÄËâË¡¤Îȯư /
+ * do_cmd_cast calls this function if the player's class is 'blue-mage'.
+ * @param spell È¯Æ°¤¹¤ë¥â¥ó¥¹¥¿¡¼¹¶·â¤ÎID
+ * @param success TRUE¤ÏÀ®¸ù»þ¡¢FALSE¤Ï¼ºÇÔ»þ¤Î½èÍý¤ò¹Ô¤¦
+ * @return ½èÍý¤ò¼Â¹Ô¤·¤¿¤éTRUE¡¢¥­¥ã¥ó¥»¥ë¤·¤¿¾ì¹çFALSE¤òÊÖ¤¹¡£
  */
 static bool cast_learned_spell(int spell, bool success)
 {
@@ -735,45 +736,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_need += ENERGY_NEED();
-               }
-               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:
@@ -1318,11 +1288,11 @@ else msg_print("Ͷ
                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(randint1(20 + plev) + plev, FALSE);
@@ -1358,10 +1328,10 @@ msg_print("̵
                (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;
@@ -1397,6 +1367,7 @@ 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);
@@ -1404,7 +1375,7 @@ msg_print("̵
                {
                        if ((r_ptr->flags1 & (RF1_UNIQUE)) || (r_ptr->flagsr & RFR_RES_ALL))
                        {
-                               if (is_original_ap(m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
+                               if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
 #ifdef JP
                                msg_format("%s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª", m_name);
 #else
@@ -1415,7 +1386,7 @@ msg_print("̵
                        }
                        else if (r_ptr->level > randint1(100))
                        {
-                               if (is_original_ap(m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
+                               if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
 #ifdef JP
                                msg_format("%s¤Ë¤ÏÂÑÀ­¤¬¤¢¤ë¡ª", m_name);
 #else
@@ -1431,7 +1402,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:
@@ -1441,20 +1412,23 @@ 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 gesture at %s's feet.", m_name);
+               msg_format("You gesture at %^s's feet.", m_name);
 #endif
 
                if ((r_ptr->flagsr & (RFR_EFF_RES_NEXU_MASK | RFR_RES_TELE)) ||
@@ -1463,27 +1437,10 @@ msg_format("%s
 #ifdef JP
                        msg_print("¤·¤«¤·¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª");
 #else
-                       msg_format("%s are unaffected!", m_name);
-#endif
-               }
-               else if (!dun_level || one_in_(2))
-               {
-#ifdef JP
-                       msg_format("%s¤Ï¾²¤òÆͤ­ÇˤäÆÄÀ¤ó¤Ç¤¤¤Ã¤¿¡£", m_name);
-#else
-                       msg_format("%s sinks 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 rises up through the ceiling.", m_name);
+                       msg_format("%^s is unaffected!", m_name);
 #endif
-                       delete_monster_idx(cave[target_row][target_col].m_idx);
                }
+               else teleport_level(target_m_idx);
                break;
        }
        case MS_PSY_SPEAR:
@@ -1942,10 +1899,10 @@ msg_print("No one have appeared.");
        return TRUE;
 }
 
-
-/*
- * do_cmd_cast calls this function if the player's class
- * is 'Blue-Mage'.
+/*!
+ * @brief ÀÄËâË¡¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
+ * do_cmd_cast calls this function if the player's class is 'Blue-Mage'.
+ * @return ½èÍý¤ò¼Â¹Ô¤·¤¿¤éTRUE¡¢¥­¥ã¥ó¥»¥ë¤·¤¿¾ì¹çFALSE¤òÊÖ¤¹¡£
  */
 bool do_cmd_cast_learned(void)
 {
@@ -2006,15 +1963,10 @@ if (!get_check("
        if (plev > spell.level) chance -= 3 * (plev - spell.level);
        else chance += (spell.level - plev);
 
-       chance += p_ptr->to_m_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 (need_mana > p_ptr->csp)
@@ -2035,9 +1987,7 @@ 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 (randint0(100) < chance)
@@ -2121,9 +2071,15 @@ msg_print("
        return TRUE;
 }
 
+/*!
+ * @brief ÀÄËâË¡¤Î¥é¡¼¥Ë¥ó¥°È½Äê¤ÈÀ®¸ù¤·¤¿¾ì¹ç¤Î¥é¡¼¥Ë¥ó¥°½èÍý
+ * @param monspell ¥é¡¼¥Ë¥ó¥°¤ò»î¤ß¤ë¥â¥ó¥¹¥¿¡¼¹¶·â¤ÎID
+ * @return ¤Ê¤·
+ */
 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 (randint1(p_ptr->lev + 70) > monster_powers[monspell].level + 40)
@@ -2145,8 +2101,16 @@ void learn_spell(int monspell)
 }
 
 
-/*
+/*!
+ * @brief ¥â¥ó¥¹¥¿¡¼ÆüìǽÎϤΥե饰ÇÛÎ󤫤éÆÃÄê¾ò·ï¤ÎËâË¡¤À¤±¤òÈ´¤­½Ð¤¹½èÍý
  * Extract monster spells mask for the given mode
+ * @param f4 ¥â¥ó¥¹¥¿¡¼ÆüìǽÎϤÎ4ÈÖÌܤΥե饰ÇÛÎó
+ * @param f5 ¥â¥ó¥¹¥¿¡¼ÆüìǽÎϤÎ5ÈÖÌܤΥե饰ÇÛÎó
+ * @param f6 ¥â¥ó¥¹¥¿¡¼ÆüìǽÎϤÎ6ÈÖÌܤΥե饰ÇÛÎó
+ * @param mode È´¤­½Ð¤·¤¿¤¤¾ò·ï
+ * @return ¤Ê¤·
+ */
+/*
  */
 void set_rf_masks(s32b *f4, s32b *f5, s32b *f6, int mode)
 {