OSDN Git Service

[Refactor] #37353 VARTUE_LARGE, VARTUE_SMALL を avatar.h へ移動.
[hengband/hengband.git] / src / realm-hex.c
index 340e78d..720e97d 100644 (file)
  */
 
 #include "angband.h"
+#include "util.h"
+
+#include "floor.h"
 #include "cmd-spell.h"
 #include "cmd-quaff.h"
+#include "object-flavor.h"
 #include "object-hook.h"
+#include "object-curse.h"
+#include "spells-status.h"
+#include "spells.h"
+#include "player-status.h"
+#include "player-effects.h"
+#include "player-skill.h"
+#include "realm-hex.h"
+#include "grid.h"
+#include "monsterrace.h"
+#include "targeting.h"
+#include "realm-song.h"
+#include "view-mainwindow.h"
 
 #define MAX_KEEP 4 /*!<呪術の最大詠唱数 */
 
@@ -28,7 +44,7 @@
  */
 bool stop_hex_spell_all(void)
 {
-       int i;
+       SPELL_IDX i;
 
        for (i = 0; i < 32; i++)
        {
@@ -38,10 +54,8 @@ bool stop_hex_spell_all(void)
        CASTING_HEX_FLAGS(p_ptr) = 0;
        CASTING_HEX_NUM(p_ptr) = 0;
 
-       /* Print message */
        if (p_ptr->action == ACTION_SPELL) set_action(ACTION_NONE);
 
-       /* Redraw status */
        p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
        p_ptr->redraw |= (PR_EXTRA | PR_HP | PR_MANA);
 
@@ -55,11 +69,11 @@ bool stop_hex_spell_all(void)
 bool stop_hex_spell(void)
 {
        int spell;
-       char choice;
+       char choice = 0;
        char out_val[160];
        bool flag = FALSE;
-       TERM_POSITION y = 1;
-       TERM_POSITION x = 20;
+       TERM_LEN y = 1;
+       TERM_LEN x = 20;
        int sp[MAX_KEEP];
 
        if (!hex_spelling_any())
@@ -75,13 +89,8 @@ bool stop_hex_spell(void)
        }
        else
        {
-#ifdef JP
-               strnfmt(out_val, 78, "どの呪文の詠唱を中断しますか?(呪文 %c-%c, 'l'全て, ESC)",
+               strnfmt(out_val, 78, _("どの呪文の詠唱を中断しますか?(呪文 %c-%c, 'l'全て, ESC)", "Which spell do you stop casting? (Spell %c-%c, 'l' to all, ESC)"),
                        I2A(0), I2A(CASTING_HEX_NUM(p_ptr) - 1));
-#else
-               strnfmt(out_val, 78, "Which spell do you stop casting? (Spell %c-%c, 'l' to all, ESC)",
-                       I2A(0), I2A(CASTING_HEX_NUM(p_ptr) - 1));
-#endif
 
                screen_save();
 
@@ -89,7 +98,7 @@ bool stop_hex_spell(void)
                {
                        int n = 0;
                        Term_erase(x, y, 255);
-                       prt("     名前", y, x + 5);
+                       prt(_("     名前", "     Name"), y, x + 5);
                        for (spell = 0; spell < 32; spell++)
                        {
                                if (hex_spelling(spell))
@@ -124,7 +133,6 @@ bool stop_hex_spell(void)
                CASTING_HEX_NUM(p_ptr)--;
        }
 
-       /* Redraw status */
        p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
        p_ptr->redraw |= (PR_EXTRA | PR_HP | PR_MANA);
 
@@ -140,7 +148,7 @@ bool stop_hex_spell(void)
 void check_hex(void)
 {
        int spell;
-       s32b need_mana;
+       MANA_POINT need_mana;
        u32b need_mana_frac;
        bool res = FALSE;
 
@@ -173,13 +181,11 @@ void check_hex(void)
                }
        }
 
-
        /* Culcurates final mana cost */
        need_mana_frac = 0;
        s64b_div(&need_mana, &need_mana_frac, 0, 3); /* Divide by 3 */
        need_mana += (CASTING_HEX_NUM(p_ptr) - 1);
 
-
        /* Not enough mana */
        if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, need_mana, need_mana_frac) < 0)
        {
@@ -195,23 +201,13 @@ void check_hex(void)
                p_ptr->redraw |= PR_MANA;
                if (res)
                {
-#ifdef JP
-                       msg_print("詠唱を再開した。");
-#else
-                       msg_print("You restart spelling.");
-#endif
+                       msg_print(_("詠唱を再開した。", "You restart spelling."));
+
                        p_ptr->action = ACTION_SPELL;
 
-                       /* Recalculate bonuses */
                        p_ptr->update |= (PU_BONUS | PU_HP);
-
-                       /* Redraw map and status bar */
                        p_ptr->redraw |= (PR_MAP | PR_STATUS | PR_STATE);
-
-                       /* Update monsters */
                        p_ptr->update |= (PU_MONSTERS);
-
-                       /* Window stuff */
                        p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
                }
        }
@@ -228,11 +224,11 @@ void check_hex(void)
                if (p_ptr->spell_exp[spell] < SPELL_EXP_BEGINNER)
                        p_ptr->spell_exp[spell] += 5;
                else if(p_ptr->spell_exp[spell] < SPELL_EXP_SKILLED)
-               { if (one_in_(2) && (dun_level > 4) && ((dun_level + 10) > p_ptr->lev)) p_ptr->spell_exp[spell] += 1; }
+               { if (one_in_(2) && (current_floor_ptr->dun_level > 4) && ((current_floor_ptr->dun_level + 10) > p_ptr->lev)) p_ptr->spell_exp[spell] += 1; }
                else if(p_ptr->spell_exp[spell] < SPELL_EXP_EXPERT)
-               { if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && ((dun_level + 5) > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
+               { if (one_in_(5) && ((current_floor_ptr->dun_level + 5) > p_ptr->lev) && ((current_floor_ptr->dun_level + 5) > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
                else if(p_ptr->spell_exp[spell] < SPELL_EXP_MASTER)
-               { if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && (dun_level > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
+               { if (one_in_(5) && ((current_floor_ptr->dun_level + 5) > p_ptr->lev) && (current_floor_ptr->dun_level > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
        }
 
        /* Do any effects of continual spells */
@@ -252,14 +248,9 @@ void check_hex(void)
 bool hex_spell_fully(void)
 {
        int k_max = 0;
-
        k_max = (p_ptr->lev / 15) + 1;
-
-       /* Paranoia */
        k_max = MIN(k_max, MAX_KEEP);
-
        if (CASTING_HEX_NUM(p_ptr) < k_max) return FALSE;
-
        return TRUE;
 }
 
@@ -299,7 +290,7 @@ void revenge_store(HIT_POINT dam)
  */
 bool teleport_barrier(MONSTER_IDX m_idx)
 {
-       monster_type *m_ptr = &m_list[m_idx];
+       monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
        if (!hex_spelling(HEX_ANTI_TELE)) return FALSE;
@@ -315,7 +306,7 @@ bool teleport_barrier(MONSTER_IDX m_idx)
  */
 bool magic_barrier(MONSTER_IDX m_idx)
 {
-       monster_type *m_ptr = &m_list[m_idx];
+       monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
        if (!hex_spelling(HEX_ANTI_MAGIC)) return FALSE;
@@ -331,7 +322,7 @@ bool magic_barrier(MONSTER_IDX m_idx)
  */
 bool multiply_barrier(MONSTER_IDX m_idx)
 {
-       monster_type *m_ptr = &m_list[m_idx];
+       monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
        if (!hex_spelling(HEX_ANTI_MULTI)) return FALSE;
@@ -346,7 +337,7 @@ bool multiply_barrier(MONSTER_IDX m_idx)
 * @param mode 処理内容 (SPELL_NAME / SPELL_DESC / SPELL_INFO / SPELL_CAST / SPELL_CONT / SPELL_STOP)
 * @return SPELL_NAME / SPELL_DESC / SPELL_INFO 時には文字列ポインタを返す。SPELL_CAST / SPELL_CONT / SPELL_STOP 時はNULL文字列を返す。
 */
-cptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
+concptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
 {
        bool name = (mode == SPELL_NAME) ? TRUE : FALSE;
        bool desc = (mode == SPELL_DESC) ? TRUE : FALSE;
@@ -413,7 +404,7 @@ cptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
                if (info) return info_damage(1, power, 0);
                if (cast || cont)
                {
-                       project_hack(GF_POIS, randint1(power));
+                       project_all_los(GF_POIS, randint1(power));
                }
                break;
 
@@ -432,8 +423,8 @@ cptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
                if (cast)
                {
                        OBJECT_IDX item;
-                       cptr q, s;
-                       char o_name[MAX_NLEN];
+                       concptr q, s;
+                       GAME_TEXT o_name[MAX_NLEN];
                        object_type *o_ptr;
                        u32b f[TR_FLAG_SIZE];
 
@@ -441,9 +432,9 @@ cptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
                        q = _("どれを呪いますか?", "Which weapon do you curse?");
                        s = _("武器を装備していない。", "You wield no weapons.");
 
-                       if (!get_item(&item, q, s, (USE_EQUIP))) return FALSE;
+                       o_ptr = choose_object(&item, q, s, (USE_EQUIP));
+                       if (!o_ptr) return FALSE;
 
-                       o_ptr = &inventory[item];
                        object_desc(o_name, o_ptr, OD_NAME_ONLY);
                        object_flags(o_ptr, f);
 
@@ -539,7 +530,7 @@ cptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
                }
                if (cont)
                {
-                       int rad = 2 + (power / 50);
+                       POSITION rad = 2 + (power / 50);
 
                        HEX_REVENGE_TURN(p_ptr)--;
 
@@ -609,7 +600,7 @@ cptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
                if (info) return info_damage(1, power, 0);
                if (cast || cont)
                {
-                       project_hack(GF_HYPODYNAMIA, randint1(power));
+                       project_all_los(GF_HYPODYNAMIA, randint1(power));
                }
                break;
 
@@ -728,8 +719,8 @@ cptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
                if (cast)
                {
                        OBJECT_IDX item;
-                       cptr q, s;
-                       char o_name[MAX_NLEN];
+                       concptr q, s;
+                       GAME_TEXT o_name[MAX_NLEN];
                        object_type *o_ptr;
                        u32b f[TR_FLAG_SIZE];
 
@@ -737,9 +728,10 @@ cptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
                        q = _("どれを呪いますか?", "Which piece of armour do you curse?");
                        s = _("防具を装備していない。", "You wield no piece of armours.");
 
-                       if (!get_item(&item, q, s, (USE_EQUIP))) return FALSE;
+                       o_ptr = choose_object(&item, q, s, (USE_EQUIP));
+                       if (!o_ptr) return FALSE;
 
-                       o_ptr = &inventory[item];
+                       o_ptr = &p_ptr->inventory_list[item];
                        object_desc(o_name, o_ptr, OD_NAME_ONLY);
                        object_flags(o_ptr, f);
 
@@ -806,7 +798,7 @@ cptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
                if (desc) return _("影のオーラを身にまとい、敵に影のダメージを与える。", "Gives aura of shadow.");
                if (cast)
                {
-                       object_type *o_ptr = &inventory[INVEN_OUTER];
+                       object_type *o_ptr = &p_ptr->inventory_list[INVEN_OUTER];
 
                        if (!o_ptr->k_idx)
                        {
@@ -825,7 +817,7 @@ cptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
                }
                if (cont)
                {
-                       object_type *o_ptr = &inventory[INVEN_OUTER];
+                       object_type *o_ptr = &p_ptr->inventory_list[INVEN_OUTER];
 
                        if ((!o_ptr->k_idx) || (!object_is_cursed(o_ptr)))
                        {
@@ -848,7 +840,7 @@ cptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
                if (info) return info_damage(1, power, 0);
                if (cast || cont)
                {
-                       project_hack(GF_PSI_DRAIN, randint1(power));
+                       project_all_los(GF_PSI_DRAIN, randint1(power));
                }
                break;
 
@@ -897,7 +889,7 @@ cptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
 
                                flag = TRUE;
                        }
-                       for (i = A_STR; i < 6; i++)
+                       for (i = A_STR; i < A_MAX; i++)
                        {
                                if (p_ptr->stat_cur[i] < p_ptr->stat_max[i])
                                {
@@ -908,8 +900,6 @@ cptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
 
                                        if (p_ptr->stat_cur[i] > p_ptr->stat_max[i])
                                                p_ptr->stat_cur[i] = p_ptr->stat_max[i];
-
-                                       /* Recalculate bonuses */
                                        p_ptr->update |= (PU_BONUS);
 
                                        flag = TRUE;
@@ -923,7 +913,6 @@ cptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
                                if (cont) CASTING_HEX_NUM(p_ptr)--;
                                if (CASTING_HEX_NUM(p_ptr)) p_ptr->action = ACTION_NONE;
 
-                               /* Redraw status */
                                p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
                                p_ptr->redraw |= (PR_EXTRA);
 
@@ -938,7 +927,7 @@ cptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
                if (cast)
                {
                        OBJECT_IDX item;
-                       cptr s, q;
+                       concptr s, q;
                        u32b f[TR_FLAG_SIZE];
                        object_type *o_ptr;
 
@@ -946,9 +935,9 @@ cptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
                        q = _("どの装備品から吸収しますか?", "Which cursed equipment do you drain mana from?");
                        s = _("呪われたアイテムを装備していない。", "You have no cursed equipment.");
 
-                       if (!get_item(&item, q, s, (USE_EQUIP))) return FALSE;
+                       o_ptr = choose_object(&item, q, s, (USE_EQUIP));
+                       if (!o_ptr) return FALSE;
 
-                       o_ptr = &inventory[item];
                        object_flags(o_ptr, f);
 
                        p_ptr->csp += (p_ptr->lev / 5) + randint1(p_ptr->lev / 5);
@@ -1032,10 +1021,10 @@ cptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
                                        int dy = y + ddy_ddd[dir];
                                        int dx = x + ddx_ddd[dir];
                                        if (dir == 5) continue;
-                                       if (cave[dy][dx].m_idx) flag = TRUE;
+                                       if (current_floor_ptr->grid_array[dy][dx].m_idx) flag = TRUE;
                                }
 
-                               if (!cave_empty_bold(y, x) || (cave[y][x].info & CAVE_ICKY) ||
+                               if (!cave_empty_bold(y, x) || (current_floor_ptr->grid_array[y][x].info & CAVE_ICKY) ||
                                        (distance(y, x, p_ptr->y, p_ptr->x) > plev + 2))
                                {
                                        msg_print(_("そこには移動できない。", "Can not teleport to there."));
@@ -1098,7 +1087,7 @@ cptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
 
                        if (HEX_REVENGE_TURN(p_ptr) <= 0)
                        {
-                               int dir;
+                               DIRECTION dir;
 
                                if (power)
                                {
@@ -1136,7 +1125,6 @@ cptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
                if (p_ptr->action != ACTION_SPELL) set_action(ACTION_SPELL);
        }
 
-       /* Redraw status */
        if (!info)
        {
                p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);