OSDN Git Service

[Refactor] #37353 型の置換。 / Type replacement. (BASE_STATUS / A_MAX)
[hengband/hengband.git] / src / hissatsu.c
index e8ebacd..8d76b1a 100644 (file)
@@ -11,6 +11,8 @@
  */
 
 #include "angband.h"
+#include "monsterrace-hook.h"
+#include "player-status.h"
 
 #define TECHNIC_HISSATSU (REALM_HISSATSU - MIN_TECHNIC)
 
@@ -36,28 +38,27 @@ static int get_hissatsu_power(SPELL_IDX *sn)
 {
        SPELL_IDX i;
        int j = 0;
-       int             num = 0;
-       int             y = 1;
-       int             x = 15;
-       int             plev = p_ptr->lev;
-       int             ask = TRUE;
-       char            choice;
-       char            out_val[160];
+       int num = 0;
+       POSITION y = 1;
+       POSITION x = 15;
+       PLAYER_LEVEL plev = p_ptr->lev;
+       int ask = TRUE;
+       char choice;
+       char out_val[160];
        SPELL_IDX sentaku[32];
-       cptr            p = _("必殺剣", "special attack");
-
+       concptr p = _("必殺剣", "special attack");
+       COMMAND_CODE code;
        magic_type spell;
-       bool            flag, redraw;
+       bool flag, redraw;
        int menu_line = (use_menu ? 1 : 0);
 
        /* Assume cancelled */
        *sn = (-1);
 
-#ifdef ALLOW_REPEAT /* TNB */
-
        /* Get the spell, if available */
-       if (repeat_pull(sn))
+       if (repeat_pull(&code))
        {
+               *sn = (SPELL_IDX)code;
                /* Verify the spell */
                if (technic_info[TECHNIC_HISSATSU][*sn].slevel <= plev)
                {
@@ -66,8 +67,6 @@ static int get_hissatsu_power(SPELL_IDX *sn)
                }
        }
 
-#endif /* ALLOW_REPEAT -- TNB */
-
        /* Nothing chosen yet */
        flag = FALSE;
 
@@ -185,8 +184,6 @@ static int get_hissatsu_power(SPELL_IDX *sn)
 
                                /* Show list */
                                redraw = TRUE;
-
-                               /* Save the screen */
                                if (!use_menu) screen_save();
 
                                /* Display a list of spells */
@@ -237,8 +234,6 @@ static int get_hissatsu_power(SPELL_IDX *sn)
                        {
                                /* Hide list */
                                redraw = FALSE;
-
-                               /* Restore the screen */
                                screen_load();
                        }
 
@@ -291,16 +286,10 @@ static int get_hissatsu_power(SPELL_IDX *sn)
                /* Stop the loop */
                flag = TRUE;
        }
-
-       /* Restore the screen */
        if (redraw) screen_load();
 
-       /* Show choices */
        p_ptr->window |= (PW_SPELL);
-
-       /* Window stuff */
-       window_stuff();
-
+       handle_stuff();
 
        /* Abort if needed */
        if (!flag) return (FALSE);
@@ -308,11 +297,7 @@ static int get_hissatsu_power(SPELL_IDX *sn)
        /* Save the choice */
        (*sn) = j;
 
-#ifdef ALLOW_REPEAT /* TNB */
-
-       repeat_push(*sn);
-
-#endif /* ALLOW_REPEAT -- TNB */
+       repeat_push((COMMAND_CODE)j);
 
        /* Success */
        return (TRUE);
@@ -328,14 +313,8 @@ void do_cmd_hissatsu(void)
        SPELL_IDX       n = 0;
        magic_type      spell;
 
-
-       /* not if confused */
-       if (p_ptr->confused)
-       {
-               msg_print(_("混乱していて集中できない!", "You are too confused!"));
-               return;
-       }
-       if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM))
+       if (cmd_limit_confused(p_ptr)) return;
+       if (!has_melee_weapon(INVEN_RARM) && !has_melee_weapon(INVEN_LARM))
        {
                if (flush_failure) flush();
                msg_print(_("武器を持たないと必殺技は使えない!", "You need to wield a weapon!"));
@@ -372,7 +351,6 @@ void do_cmd_hissatsu(void)
        /* Cast the spell */
        if (!do_spell(REALM_HISSATSU, n, SPELL_CAST)) return;
 
-       /* Take a turn */
        p_ptr->energy_use = 100;
 
        /* Use some mana */
@@ -380,11 +358,8 @@ void do_cmd_hissatsu(void)
 
        /* Limit */
        if (p_ptr->csp < 0) p_ptr->csp = 0;
-
-       /* Redraw mana */
        p_ptr->redraw |= (PR_MANA);
 
-       /* Window stuff */
        p_ptr->window |= (PW_PLAYER);
        p_ptr->window |= (PW_SPELL);
 }
@@ -400,7 +375,7 @@ void do_cmd_gain_hissatsu(void)
        int i, j;
 
        object_type *o_ptr;
-       cptr q, s;
+       concptr q, s;
 
        bool gain = FALSE;
 
@@ -415,11 +390,7 @@ void do_cmd_gain_hissatsu(void)
                return;
        }
 
-       if (p_ptr->confused)
-       {
-               msg_print(_("混乱していて読めない!", "You are too confused!"));
-               return;
-       }
+       if (cmd_limit_confused(p_ptr)) return;
 
        if (!(p_ptr->new_spells))
        {
@@ -440,23 +411,11 @@ void do_cmd_gain_hissatsu(void)
 
        item_tester_tval = TV_HISSATSU_BOOK;
 
-       /* Get an item */
        q = _("どの書から学びますか? ", "Study which book? ");
        s = _("読める書がない。", "You have no books that you can read.");
 
-       if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
-
-       /* Get the item (in the pack) */
-       if (item >= 0)
-       {
-               o_ptr = &inventory[item];
-       }
-
-       /* Get the item (on the floor) */
-       else
-       {
-               o_ptr = &o_list[0 - item];
-       }
+       o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
+       if (!o_ptr) return;
 
        for (i = o_ptr->sval * 8; i < o_ptr->sval * 8 + 8; i++)
        {
@@ -479,7 +438,6 @@ void do_cmd_gain_hissatsu(void)
        if (!gain)
                msg_print(_("何も覚えられなかった。", "You were not able to learn any special attacks."));
 
-       /* Take a turn */
        else
                p_ptr->energy_use = 100;
 
@@ -565,7 +523,7 @@ MULTIPLY mult_hissatsu(MULTIPLY mult, BIT_FLAGS *flgs, monster_type *m_ptr, BIT_
        /* Zammaken (Nonliving Evil) */
        if (mode == HISSATSU_ZANMA)
        {
-               if (!monster_living(r_ptr) && (r_ptr->flags3 & RF3_EVIL))
+               if (!monster_living(m_ptr->r_idx) && (r_ptr->flags3 & RF3_EVIL))
                {
                        if (mult < 15) mult = 25;
                        else if (mult < 50) mult = MIN(50, mult+20);
@@ -648,7 +606,7 @@ MULTIPLY mult_hissatsu(MULTIPLY mult, BIT_FLAGS *flgs, monster_type *m_ptr, BIT_
        }
 
        /* Bloody Maelstrom */
-       if ((mode == HISSATSU_SEKIRYUKA) && p_ptr->cut && monster_living(r_ptr))
+       if ((mode == HISSATSU_SEKIRYUKA) && p_ptr->cut && monster_living(m_ptr->r_idx))
        {
                MULTIPLY tmp = MIN(100, MAX(10, p_ptr->cut / 10));
                if (mult < tmp) mult = tmp;