OSDN Git Service

[Refactor] #37353 グローバル変数 dungeon_type を他の慣例に従い dungeon_idx に改名。 / Rename dungeon_typ...
[hengband/hengband.git] / src / cmd-quaff.c
index 638df4c..5a4d695 100644 (file)
@@ -9,6 +9,10 @@
 #include "angband.h"\r
 #include "selfinfo.h"\r
 #include "object-hook.h"\r
+#include "mutation.h"\r
+#include "avatar.h"\r
+#include "spells-status.h"\r
+#include "realm-hex.h"\r
 \r
 /*!\r
  * @brief 薬を飲むコマンドのサブルーチン /\r
  * @param item 飲む薬オブジェクトの所持品ID\r
  * @return なし\r
  */\r
-void do_cmd_quaff_potion_aux(int item)\r
+void do_cmd_quaff_potion_aux(INVENTORY_IDX item)\r
 {\r
-       int         ident, lev;\r
+       bool ident;\r
+       DEPTH lev;\r
        object_type *o_ptr;\r
        object_type forge;\r
        object_type *q_ptr;\r
 \r
 \r
-       /* Take a turn */\r
-       p_ptr->energy_use = 100;\r
-\r
-       if (world_player)\r
+       if (p_ptr->timewalk)\r
        {\r
                if (flush_failure) flush();\r
                msg_print(_("瓶から水が流れ出てこない!", "The potion doesn't flow out from a bottle."));\r
@@ -53,8 +55,6 @@ void do_cmd_quaff_potion_aux(int item)
        {\r
                o_ptr = &o_list[0 - item];\r
        }\r
-\r
-       /* Get local object */\r
        q_ptr = &forge;\r
 \r
        /* Obtain a local object */\r
@@ -79,7 +79,6 @@ void do_cmd_quaff_potion_aux(int item)
                floor_item_optimize(0 - item);\r
        }\r
 \r
-       /* Sound */\r
        sound(SOUND_QUAFF);\r
 \r
 \r
@@ -156,37 +155,8 @@ void do_cmd_quaff_potion_aux(int item)
                        }\r
                        break;\r
 \r
-               case SV_POTION_CONFUSION: /* Booze */\r
-                       if (p_ptr->pclass != CLASS_MONK) chg_virtue(V_HARMONY, -1);\r
-                       else if (!p_ptr->resist_conf) p_ptr->special_attack |= ATTACK_SUIKEN;\r
-                       if (!p_ptr->resist_conf)\r
-                       {\r
-                               if (set_confused(randint0(20) + 15))\r
-                               {\r
-                                       ident = TRUE;\r
-                               }\r
-                       }\r
-\r
-                       if (!p_ptr->resist_chaos)\r
-                       {\r
-                               if (one_in_(2))\r
-                               {\r
-                                       if (set_image(p_ptr->image + randint0(150) + 150))\r
-                                       {\r
-                                               ident = TRUE;\r
-                                       }\r
-                               }\r
-                               if (one_in_(13) && (p_ptr->pclass != CLASS_MONK))\r
-                               {\r
-                                       ident = TRUE;\r
-                                       if (one_in_(3)) lose_all_info();\r
-                                       else wiz_dark();\r
-                                       (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);\r
-                                       wiz_dark();\r
-                                       msg_print(_("知らない場所で目が醒めた。頭痛がする。", "You wake up somewhere with a sore head..."));\r
-                                       msg_print(_("何も思い出せない。どうやってここへ来たのかも分からない!", "You can't remember a thing, or how you got here!"));\r
-                               }\r
-                       }\r
+               case SV_POTION_BOOZE:\r
+                       ident = booze(p_ptr);\r
                        break;\r
 \r
                case SV_POTION_SLEEP:\r
@@ -257,12 +227,7 @@ void do_cmd_quaff_potion_aux(int item)
                        break;\r
 \r
                case SV_POTION_DETONATIONS:\r
-                       msg_print(_("体の中で激しい爆発が起きた!", "Massive explosions rupture your body!"));\r
-                       take_hit(DAMAGE_NOESCAPE, damroll(50, 20), _("爆発の薬", "a potion of Detonation"), -1);\r
-\r
-                       (void)set_stun(p_ptr->stun + 75);\r
-                       (void)set_cut(p_ptr->cut + 5000);\r
-                       ident = TRUE;\r
+                       ident = detonation(p_ptr);\r
                        break;\r
 \r
                case SV_POTION_DEATH:\r
@@ -329,54 +294,27 @@ void do_cmd_quaff_potion_aux(int item)
                        break;\r
 \r
                case SV_POTION_BESERK_STRENGTH:\r
-                       if (set_afraid(0)) ident = TRUE;\r
-                       if (set_shero(p_ptr->shero + randint1(25) + 25, FALSE)) ident = TRUE;\r
-                       if (hp_player(30)) ident = TRUE;\r
+                       ident = berserk(randint1(25) + 25);\r
                        break;\r
 \r
                case SV_POTION_CURE_LIGHT:\r
-                       if (hp_player(damroll(2, 8))) ident = TRUE;\r
-                       if (set_blind(0)) ident = TRUE;\r
-                       if (set_cut(p_ptr->cut - 10)) ident = TRUE;\r
-                       if (set_shero(0,TRUE)) ident = TRUE;\r
+                       ident = cure_light_wounds(2, 8);\r
                        break;\r
 \r
                case SV_POTION_CURE_SERIOUS:\r
-                       if (hp_player(damroll(4, 8))) ident = TRUE;\r
-                       if (set_blind(0)) ident = TRUE;\r
-                       if (set_confused(0)) ident = TRUE;\r
-                       if (set_cut((p_ptr->cut / 2) - 50)) ident = TRUE;\r
-                       if (set_shero(0,TRUE)) ident = TRUE;\r
+                       ident = cure_serious_wounds(4, 8);\r
                        break;\r
 \r
                case SV_POTION_CURE_CRITICAL:\r
-                       if (hp_player(damroll(6, 8))) ident = TRUE;\r
-                       if (set_blind(0)) ident = TRUE;\r
-                       if (set_confused(0)) ident = TRUE;\r
-                       if (set_poisoned(0)) ident = TRUE;\r
-                       if (set_stun(0)) ident = TRUE;\r
-                       if (set_cut(0)) ident = TRUE;\r
-                       if (set_shero(0,TRUE)) ident = TRUE;\r
+                       ident = cure_critical_wounds(damroll(6, 8));\r
                        break;\r
 \r
                case SV_POTION_HEALING:\r
-                       if (hp_player(300)) ident = TRUE;\r
-                       if (set_blind(0)) ident = TRUE;\r
-                       if (set_confused(0)) ident = TRUE;\r
-                       if (set_poisoned(0)) ident = TRUE;\r
-                       if (set_stun(0)) ident = TRUE;\r
-                       if (set_cut(0)) ident = TRUE;\r
-                       if (set_shero(0,TRUE)) ident = TRUE;\r
+                       ident = cure_critical_wounds(300);\r
                        break;\r
 \r
                case SV_POTION_STAR_HEALING:\r
-                       if (hp_player(1200)) ident = TRUE;\r
-                       if (set_blind(0)) ident = TRUE;\r
-                       if (set_confused(0)) ident = TRUE;\r
-                       if (set_poisoned(0)) ident = TRUE;\r
-                       if (set_stun(0)) ident = TRUE;\r
-                       if (set_cut(0)) ident = TRUE;\r
-                       if (set_shero(0,TRUE)) ident = TRUE;\r
+                       ident = cure_critical_wounds(1200);\r
                        break;\r
 \r
                case SV_POTION_LIFE:\r
@@ -384,36 +322,7 @@ void do_cmd_quaff_potion_aux(int item)
                        break;\r
 \r
                case SV_POTION_RESTORE_MANA:\r
-                       if (p_ptr->pclass == CLASS_MAGIC_EATER)\r
-                       {\r
-                               int i;\r
-                               for (i = 0; i < EATER_EXT*2; i++)\r
-                               {\r
-                                       p_ptr->magic_num1[i] += (p_ptr->magic_num2[i] < 10) ? EATER_CHARGE * 3 : p_ptr->magic_num2[i]*EATER_CHARGE/3;\r
-                                       if (p_ptr->magic_num1[i] > p_ptr->magic_num2[i]*EATER_CHARGE) p_ptr->magic_num1[i] = p_ptr->magic_num2[i]*EATER_CHARGE;\r
-                               }\r
-                               for (; i < EATER_EXT*3; i++)\r
-                               {\r
-                                       KIND_OBJECT_IDX k_idx = lookup_kind(TV_ROD, i-EATER_EXT*2);\r
-                                       p_ptr->magic_num1[i] -= ((p_ptr->magic_num2[i] < 10) ? EATER_ROD_CHARGE*3 : p_ptr->magic_num2[i]*EATER_ROD_CHARGE/3)*k_info[k_idx].pval;\r
-                                       if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;\r
-                               }\r
-                               msg_print(_("頭がハッキリとした。", "You feel your head clear."));\r
-                               p_ptr->window |= (PW_PLAYER);\r
-                               ident = TRUE;\r
-                       }\r
-                       else if (p_ptr->csp < p_ptr->msp)\r
-                       {\r
-                               p_ptr->csp = p_ptr->msp;\r
-                               p_ptr->csp_frac = 0;\r
-                               msg_print(_("頭がハッキリとした。", "You feel your head clear."));\r
-\r
-                               p_ptr->redraw |= (PR_MANA);\r
-                               p_ptr->window |= (PW_PLAYER);\r
-                               p_ptr->window |= (PW_SPELL);\r
-                               ident = TRUE;\r
-                       }\r
-                       if (set_shero(0,TRUE)) ident = TRUE;\r
+                       ident = restore_mana(TRUE);\r
                        break;\r
 \r
                case SV_POTION_RESTORE_EXP:\r
@@ -534,13 +443,7 @@ void do_cmd_quaff_potion_aux(int item)
                        break;\r
 \r
                case SV_POTION_CURING:\r
-                       if (hp_player(50)) ident = TRUE;\r
-                       if (set_blind(0)) ident = TRUE;\r
-                       if (set_poisoned(0)) ident = TRUE;\r
-                       if (set_confused(0)) ident = TRUE;\r
-                       if (set_stun(0)) ident = TRUE;\r
-                       if (set_cut(0)) ident = TRUE;\r
-                       if (set_image(0)) ident = TRUE;\r
+                       if (true_healing(50)) ident = TRUE;\r
                        break;\r
 \r
                case SV_POTION_INVULNERABILITY:\r
@@ -549,7 +452,7 @@ void do_cmd_quaff_potion_aux(int item)
                        break;\r
 \r
                case SV_POTION_NEW_LIFE:\r
-                       do_cmd_rerate(FALSE);\r
+                       roll_hitdice(0L);\r
                        get_max_stats();\r
                        p_ptr->update |= PU_BONUS;\r
                        lose_all_mutations();\r
@@ -599,9 +502,7 @@ void do_cmd_quaff_potion_aux(int item)
                msg_print(_("液体の一部はあなたのアゴを素通りして落ちた!", "Some of the fluid falls through your jaws!"));\r
                (void)potion_smash_effect(0, p_ptr->y, p_ptr->x, q_ptr->k_idx);\r
        }\r
-\r
-       /* Combine / Reorder the pack (later) */\r
-       p_ptr->notice |= (PN_COMBINE | PN_REORDER);\r
+       p_ptr->update |= (PU_COMBINE | PU_REORDER);\r
 \r
        if (!(object_is_aware(q_ptr)))\r
        {\r
@@ -620,7 +521,6 @@ void do_cmd_quaff_potion_aux(int item)
                gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev);\r
        }\r
 \r
-       /* Window stuff */\r
        p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);\r
 \r
        /* Potions can feed the player */\r
@@ -684,7 +584,14 @@ void do_cmd_quaff_potion_aux(int item)
 void do_cmd_quaff_potion(void)\r
 {\r
        OBJECT_IDX item;\r
-       cptr q, s;\r
+       concptr q, s;\r
+\r
+       if (p_ptr->wild_mode)\r
+       {\r
+               return;\r
+       }\r
+\r
+       if (cmd_limit_arena(p_ptr)) return;\r
 \r
        if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))\r
        {\r
@@ -694,11 +601,10 @@ void do_cmd_quaff_potion(void)
        /* Restrict choices to potions */\r
        item_tester_hook = item_tester_hook_quaff;\r
 \r
-       /* Get an item */\r
        q = _("どの薬を飲みますか? ", "Quaff which potion? ");\r
        s = _("飲める薬がない。", "You have no potions to quaff.");\r
 \r
-       if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;\r
+       if (!choose_object(&item, q, s, (USE_INVEN | USE_FLOOR))) return;\r
 \r
        /* Quaff the potion */\r
        do_cmd_quaff_potion_aux(item);\r