OSDN Git Service

[Refactor] #38862 Moved view-mainwindow.c/h to display-main-window.c/h
[hengbandforosx/hengbandosx.git] / src / snipe.c
index 4040029..8e9e797 100644 (file)
@@ -7,20 +7,26 @@
  */
 
 #include "angband.h"
+#include "core.h"
+#include "util.h"
+#include "main/sound-definitions-table.h"
+#include "gameterm.h"
+
 #include "player-status.h"
+#include "cmd-basic.h"
+#include "snipe.h"
+#include "monsterrace.h"
+#include "view/display-main-window.h"
 
 #define MAX_SNIPE_POWERS 16
 
-/*! スナイパー技能情報のtypedef */
-typedef struct snipe_power snipe_power;
-
 /*! スナイパー技能情報の構造体 */
-struct snipe_power
+typedef struct snipe_power
 {
        PLAYER_LEVEL min_lev;
        MANA_POINT mana_cost;
        concptr name;
-};
+} snipe_power;
 
 /*! スナイパー技能の解説メッセージ */
 static concptr const snipe_tips[MAX_SNIPE_POWERS] =
@@ -107,16 +113,16 @@ static snipe_power const snipe_powers[MAX_SNIPE_POWERS] =
  * @brief スナイパーの集中度加算
  * @return 常にTRUEを返す
  */
-static bool snipe_concentrate(void)
+static bool snipe_concentrate(player_type *creature_ptr)
 {
-       if ((int)p_ptr->concent < (2 + (p_ptr->lev + 5) / 10)) p_ptr->concent++;
+       if ((int)creature_ptr->concent < (2 + (creature_ptr->lev + 5) / 10)) creature_ptr->concent++;
 
-       msg_format(_("集中した。(集中度 %d)", "You concentrate deeply. (lvl %d)"), p_ptr->concent);
-       reset_concent = FALSE;
+       msg_format(_("集中した。(集中度 %d)", "You concentrate deeply. (lvl %d)"), creature_ptr->concent);
+       creature_ptr->reset_concent = FALSE;
 
-       p_ptr->update |= (PU_BONUS | PU_MONSTERS);
-       p_ptr->redraw |= (PR_STATUS);
-       return (TRUE);
+       creature_ptr->update |= (PU_BONUS | PU_MONSTERS);
+       creature_ptr->redraw |= (PR_STATUS);
+       return TRUE;
 }
 
 /*! 
@@ -124,18 +130,18 @@ static bool snipe_concentrate(void)
  * @param msg TRUEならばメッセージを表示する
  * @return なし
  */
-void reset_concentration(bool msg)
+void reset_concentration(player_type *creature_ptr, bool msg)
 {
        if (msg)
        {
                msg_print(_("集中力が途切れてしまった。", "Stop concentrating."));
        }
 
-       p_ptr->concent = 0;
-       reset_concent = FALSE;
+       creature_ptr->concent = 0;
+       creature_ptr->reset_concent = FALSE;
 
-       p_ptr->update |= (PU_BONUS | PU_MONSTERS);
-       p_ptr->redraw |= (PR_STATUS);
+       creature_ptr->update |= (PU_BONUS | PU_MONSTERS);
+       creature_ptr->redraw |= (PR_STATUS);
 }
 
 /*! 
@@ -143,9 +149,9 @@ void reset_concentration(bool msg)
  * @param tdam 算出中のダメージ
  * @return 集中度修正を加えたダメージ
  */
-int boost_concentration_damage(int tdam)
+int boost_concentration_damage(player_type *creature_ptr, int tdam)
 {
-       tdam *= (10 + p_ptr->concent);
+       tdam *= (10 + creature_ptr->concent);
        tdam /= 10;
 
        return (tdam);
@@ -155,14 +161,14 @@ int boost_concentration_damage(int tdam)
  * @brief スナイパーの技能リストを表示する
  * @return なし
  */
-void display_snipe_list(void)
+void display_snipe_list(player_type *sniper_ptr)
 {
        int i;
        TERM_LEN y = 1;
        TERM_LEN x = 1;
-       PLAYER_LEVEL plev = p_ptr->lev;
-       snipe_power     spell;
-       char            psi_desc[80];
+       PLAYER_LEVEL plev = sniper_ptr->lev;
+       snipe_power spell;
+       char psi_desc[80];
 
        /* Display a list of spells */
        prt("", y, x);
@@ -174,7 +180,7 @@ void display_snipe_list(void)
                /* Access the available spell */
                spell = snipe_powers[i];
                if (spell.min_lev > plev) continue;
-               if (spell.mana_cost > (int)p_ptr->concent) continue;
+               if (spell.mana_cost > (int)sniper_ptr->concent) continue;
 
                sprintf(psi_desc, "  %c) %-30s%2d %4d",
                        I2A(i), spell.name, spell.min_lev, spell.mana_cost);
@@ -203,19 +209,19 @@ void display_snipe_list(void)
  * when you run it. It's probably easy to fix but I haven't tried,\n
  * sorry.\n
  */
-static int get_snipe_power(COMMAND_CODE *sn, bool only_browse)
+static int get_snipe_power(player_type *sniper_ptr, COMMAND_CODE *sn, bool only_browse)
 {
        COMMAND_CODE i;
-       int             num = 0;
+       int num = 0;
        TERM_LEN y = 1;
        TERM_LEN x = 20;
-       PLAYER_LEVEL plev = p_ptr->lev;
-       int             ask;
-       char            choice;
-       char            out_val[160];
-       concptr            p = _("射撃術", "power");
-       snipe_power     spell;
-       bool            flag, redraw;
+       PLAYER_LEVEL plev = sniper_ptr->lev;
+       int ask;
+       char choice;
+       char out_val[160];
+       concptr p = _("射撃術", "power");
+       snipe_power spell;
+       bool flag, redraw;
 
        repeat_push(*sn);
 
@@ -227,23 +233,20 @@ static int get_snipe_power(COMMAND_CODE *sn, bool only_browse)
        if (repeat_pull(sn))
        {
                /* Verify the spell */
-               if ((snipe_powers[*sn].min_lev <= plev) && (snipe_powers[*sn].mana_cost <= (int)p_ptr->concent))
+               if ((snipe_powers[*sn].min_lev <= plev) && (snipe_powers[*sn].mana_cost <= (int)sniper_ptr->concent))
                {
                        /* Success */
-                       return (TRUE);
+                       return TRUE;
                }
        }
 
-       /* Nothing chosen yet */
        flag = FALSE;
-
-       /* No redraw yet */
        redraw = FALSE;
 
        for (i = 0; i < MAX_SNIPE_POWERS; i++)
        {
                if ((snipe_powers[i].min_lev <= plev) &&
-                       ((only_browse) || (snipe_powers[i].mana_cost <= (int)p_ptr->concent)))
+                       ((only_browse) || (snipe_powers[i].mana_cost <= (int)sniper_ptr->concent)))
                {
                        num = i;
                }
@@ -292,7 +295,7 @@ static int get_snipe_power(COMMAND_CODE *sn, bool only_browse)
                                        /* Access the spell */
                                        spell = snipe_powers[i];
                                        if (spell.min_lev > plev) continue;
-                                       if (!only_browse && (spell.mana_cost > (int)p_ptr->concent)) continue;
+                                       if (!only_browse && (spell.mana_cost > (int)sniper_ptr->concent)) continue;
 
                                        /* Dump the spell --(-- */
                                        if (only_browse)
@@ -330,7 +333,7 @@ static int get_snipe_power(COMMAND_CODE *sn, bool only_browse)
 
                /* Totally Illegal */
                if ((i < 0) || (i > num) || 
-                       (!only_browse &&(snipe_powers[i].mana_cost > (int)p_ptr->concent)))
+                       (!only_browse &&(snipe_powers[i].mana_cost > (int)sniper_ptr->concent)))
                {
                        bell();
                        continue;
@@ -356,11 +359,11 @@ static int get_snipe_power(COMMAND_CODE *sn, bool only_browse)
        }
        if (redraw && !only_browse) screen_load();
 
-       p_ptr->window |= (PW_SPELL);
-       handle_stuff();
+       sniper_ptr->window |= (PW_SPELL);
+       handle_stuff(sniper_ptr);
 
        /* Abort if needed */
-       if (!flag) return (FALSE);
+       if (!flag) return FALSE;
 
        /* Save the choice */
        (*sn) = i;
@@ -368,9 +371,10 @@ static int get_snipe_power(COMMAND_CODE *sn, bool only_browse)
        repeat_push(*sn);
 
        /* Success */
-       return (TRUE);
+       return TRUE;
 }
 
+
 /*!
  * @brief スナイバー技能のスレイ倍率計算を行う /
  * Calcurate magnification of snipe technics
@@ -378,7 +382,7 @@ static int get_snipe_power(COMMAND_CODE *sn, bool only_browse)
  * @param m_ptr 目標となるモンスターの構造体参照ポインタ
  * @return スレイの倍率(/10倍)
  */
-MULTIPLY tot_dam_aux_snipe(MULTIPLY mult, monster_type *m_ptr, SPELL_IDX snipe_type)
+MULTIPLY tot_dam_aux_snipe(player_type *sniper_ptr, MULTIPLY mult, monster_type *m_ptr, SPELL_IDX snipe_type)
 {
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
        bool seen = is_seen(m_ptr);
@@ -388,7 +392,7 @@ MULTIPLY tot_dam_aux_snipe(MULTIPLY mult, monster_type *m_ptr, SPELL_IDX snipe_t
        case SP_LITE:
                if (r_ptr->flags3 & (RF3_HURT_LITE))
                {
-                       MULTIPLY n = 20 + p_ptr->concent;
+                       MULTIPLY n = 20 + sniper_ptr->concent;
                        if (seen) r_ptr->r_flags3 |= (RF3_HURT_LITE);
                        if (mult < n) mult = n;
                }
@@ -400,7 +404,7 @@ MULTIPLY tot_dam_aux_snipe(MULTIPLY mult, monster_type *m_ptr, SPELL_IDX snipe_t
                }
                else
                {
-                       MULTIPLY n = 15 + (p_ptr->concent * 3);
+                       MULTIPLY n = 15 + (sniper_ptr->concent * 3);
                        if (mult < n) mult = n;
                }
                break;
@@ -411,7 +415,7 @@ MULTIPLY tot_dam_aux_snipe(MULTIPLY mult, monster_type *m_ptr, SPELL_IDX snipe_t
                }
                else
                {
-                       MULTIPLY n = 15 + (p_ptr->concent * 3);
+                       MULTIPLY n = 15 + (sniper_ptr->concent * 3);
                        if (mult < n) mult = n;
                }
                break;
@@ -422,20 +426,20 @@ MULTIPLY tot_dam_aux_snipe(MULTIPLY mult, monster_type *m_ptr, SPELL_IDX snipe_t
                }
                else
                {
-                       MULTIPLY n = 18 + (p_ptr->concent * 4);
+                       MULTIPLY n = 18 + (sniper_ptr->concent * 4);
                        if (mult < n) mult = n;
                }
                break;
        case SP_KILL_WALL:
                if (r_ptr->flags3 & RF3_HURT_ROCK)
                {
-                       MULTIPLY n = 15 + (p_ptr->concent * 2);
+                       MULTIPLY n = 15 + (sniper_ptr->concent * 2);
                        if (seen) r_ptr->r_flags3 |= RF3_HURT_ROCK;
                        if (mult < n) mult = n;
                }
                else if (r_ptr->flags3 & RF3_NONLIVING)
                {
-                       MULTIPLY n = 15 + (p_ptr->concent * 2);
+                       MULTIPLY n = 15 + (sniper_ptr->concent * 2);
                        if (seen) r_ptr->r_flags3 |= RF3_NONLIVING;
                        if (mult < n) mult = n;
                }
@@ -443,7 +447,7 @@ MULTIPLY tot_dam_aux_snipe(MULTIPLY mult, monster_type *m_ptr, SPELL_IDX snipe_t
        case SP_EVILNESS:
                if (r_ptr->flags3 & RF3_GOOD)
                {
-                       MULTIPLY n = 15 + (p_ptr->concent * 4);
+                       MULTIPLY n = 15 + (sniper_ptr->concent * 4);
                        if (seen) r_ptr->r_flags3 |= RF3_GOOD;
                        if (mult < n) mult = n;
                }
@@ -451,11 +455,11 @@ MULTIPLY tot_dam_aux_snipe(MULTIPLY mult, monster_type *m_ptr, SPELL_IDX snipe_t
        case SP_HOLYNESS:
                if (r_ptr->flags3 & RF3_EVIL)
                {
-                       MULTIPLY n = 12 + (p_ptr->concent * 3);
+                       MULTIPLY n = 12 + (sniper_ptr->concent * 3);
                        if (seen) r_ptr->r_flags3 |= RF3_EVIL;
                        if (r_ptr->flags3 & (RF3_HURT_LITE))
                        {
-                               n += (p_ptr->concent * 3);
+                               n += (sniper_ptr->concent * 3);
                                if (seen) r_ptr->r_flags3 |= (RF3_HURT_LITE);
                        }
                        if (mult < n) mult = n;
@@ -476,24 +480,24 @@ MULTIPLY tot_dam_aux_snipe(MULTIPLY mult, monster_type *m_ptr, SPELL_IDX snipe_t
  * @param spell 発動する特殊技能のID
  * @return 処理を実行したらTRUE、キャンセルした場合FALSEを返す。
  */
-static bool cast_sniper_spell(int spell)
+static bool cast_sniper_spell(player_type *sniper_ptr, int spell)
 {
-       object_type *o_ptr = &inventory[INVEN_BOW];
+       object_type *o_ptr = &sniper_ptr->inventory_list[INVEN_BOW];
        SPELL_IDX snipe_type = SP_NONE;
 
        if (o_ptr->tval != TV_BOW)
        {
                msg_print(_("弓を装備していない!", "You wield no bow!"));
-               return (FALSE);
+               return FALSE;
        }
 
        /* spell code */
        switch (spell)
        {
        case 0: /* Concentration */
-               if (!snipe_concentrate()) return (FALSE);
-               take_turn(p_ptr, 100);
-               return (TRUE);
+               if (!snipe_concentrate(sniper_ptr)) return FALSE;
+               take_turn(sniper_ptr, 100);
+               return TRUE;
        case 1: snipe_type = SP_LITE; break;
        case 2: snipe_type = SP_AWAY; break;
        case 3: snipe_type = SP_KILL_TRAP; break;
@@ -514,43 +518,40 @@ static bool cast_sniper_spell(int spell)
        }
 
        command_cmd = 'f';
-       do_cmd_fire(snipe_type);
+       do_cmd_fire(sniper_ptr, snipe_type);
 
-       return (is_fired);
+       return (sniper_ptr->is_fired);
 }
 
 /*!
  * @brief スナイパー技能コマンドのメインルーチン /
  * @return なし
  */
-void do_cmd_snipe(void)
+void do_cmd_snipe(player_type *sniper_ptr)
 {
        COMMAND_CODE n = 0;
-       bool            cast;
+       bool cast;
 
-       if(cmd_limit_confused(p_ptr)) return;
-       if(cmd_limit_image(p_ptr)) return;
-       if(cmd_limit_stun(p_ptr)) return;
+       if(cmd_limit_confused(sniper_ptr)) return;
+       if(cmd_limit_image(sniper_ptr)) return;
+       if(cmd_limit_stun(sniper_ptr)) return;
 
-       if (!get_snipe_power(&n, FALSE)) return;
+       if (!get_snipe_power(sniper_ptr, &n, FALSE)) return;
 
        sound(SOUND_SHOOT);
-
-       /* Cast the spell */
-       cast = cast_sniper_spell(n);
+       cast = cast_sniper_spell(sniper_ptr, n);
 
        if (!cast) return;
-       p_ptr->redraw |= (PR_HP | PR_MANA);
-
-       p_ptr->window |= (PW_PLAYER);
-       p_ptr->window |= (PW_SPELL);
+       sniper_ptr->redraw |= (PR_HP | PR_MANA);
+       sniper_ptr->window |= (PW_PLAYER);
+       sniper_ptr->window |= (PW_SPELL);
 }
 
 /*!
  * @brief スナイパー技能コマンドの表示 /
  * @return なし
  */
-void do_cmd_snipe_browse(void)
+void do_cmd_snipe_browse(player_type *sniper_ptr)
 {
        COMMAND_CODE n = 0;
        int j, line;
@@ -558,9 +559,9 @@ void do_cmd_snipe_browse(void)
 
        screen_save();
 
-       while(1)
+       while (TRUE)
        {
-               if (!get_snipe_power(&n, TRUE))
+               if (!get_snipe_power(sniper_ptr, &n, TRUE))
                {
                        screen_load();
                        return;