From 5fc36e4cab1dd5a9158ea49a60d19d80de2029c4 Mon Sep 17 00:00:00 2001 From: Deskull Date: Fri, 7 Sep 2018 20:54:16 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#37353=E3=80=80=E3=83=97=E3=83=AC?= =?utf8?q?=E3=82=A4=E3=83=A4=E3=83=BC=E3=81=AE=E9=A3=9F=E4=BA=8B=E5=87=A6?= =?utf8?q?=E7=90=86=E3=82=92=20cmd-eat.c/h=20=E3=81=AB=E5=88=86=E9=9B=A2?= =?utf8?q?=E3=80=82=20/=20Separate=20player's=20eat=20command=20to=20cmd-e?= =?utf8?q?at.c/h.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Hengband_vcs2015/Hengband/Hengband.vcxproj | 4 + Hengband_vcs2015/Hengband/Hengband.vcxproj.filters | 12 + doxygen/Hengband.doxyfile | 2 +- src/cmd-eat.c | 576 +++++++++++++++++++++ src/cmd-eat.h | 3 + src/cmd6.c | 566 +------------------- src/externs.h | 1 - 7 files changed, 597 insertions(+), 567 deletions(-) create mode 100644 src/cmd-eat.c create mode 100644 src/cmd-eat.h diff --git a/Hengband_vcs2015/Hengband/Hengband.vcxproj b/Hengband_vcs2015/Hengband/Hengband.vcxproj index a5e0eae58..0bae6d860 100644 --- a/Hengband_vcs2015/Hengband/Hengband.vcxproj +++ b/Hengband_vcs2015/Hengband/Hengband.vcxproj @@ -138,6 +138,7 @@ + @@ -181,6 +182,7 @@ + @@ -203,6 +205,7 @@ + @@ -217,6 +220,7 @@ + diff --git a/Hengband_vcs2015/Hengband/Hengband.vcxproj.filters b/Hengband_vcs2015/Hengband/Hengband.vcxproj.filters index 124fc3b6c..eba75ee2d 100644 --- a/Hengband_vcs2015/Hengband/Hengband.vcxproj.filters +++ b/Hengband_vcs2015/Hengband/Hengband.vcxproj.filters @@ -208,6 +208,12 @@ Source + + Source + + + Source + @@ -279,6 +285,12 @@ Header + + Header + + + Header + diff --git a/doxygen/Hengband.doxyfile b/doxygen/Hengband.doxyfile index e91890276..a1943c570 100644 --- a/doxygen/Hengband.doxyfile +++ b/doxygen/Hengband.doxyfile @@ -2077,7 +2077,7 @@ HIDE_UNDOC_RELATIONS = YES # set to NO # The default value is: NO. -HAVE_DOT = NO +HAVE_DOT = YES # The DOT_NUM_THREADS specifies the number of dot invocations doxygen is allowed # to run in parallel. When set to 0 doxygen will base this on the number of diff --git a/src/cmd-eat.c b/src/cmd-eat.c new file mode 100644 index 000000000..565b16140 --- /dev/null +++ b/src/cmd-eat.c @@ -0,0 +1,576 @@ +/*! + * @file cmd-eat.c + * @brief ƒvƒŒƒCƒ„[‚̐HŽ–‚ÉŠÖ‚·‚éƒRƒ}ƒ“ƒhŽÀ‘• + * @date 2014/01/27 + * @details + * cmd6.c‚æ‚蕪—£B + */ + + +#include "angband.h" + +/*! + * @brief H—¿‚ðH‚ׂéƒRƒ}ƒ“ƒh‚̃Tƒuƒ‹[ƒ`ƒ“ + * @param item H‚ׂéƒIƒuƒWƒFƒNƒg‚̏ŠŽ•iID + * @return ‚È‚µ + */ +void do_cmd_eat_food_aux(int item) +{ + int ident, lev; + object_type *o_ptr; + + if (music_singing_any()) stop_singing(); + if (hex_spelling_any()) stop_hex_spell_all(); + + /* 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]; + } + + /* Sound */ + sound(SOUND_EAT); + + /* Take a turn */ + p_ptr->energy_use = 100; + + /* Identity not known yet */ + ident = FALSE; + + /* Object level */ + lev = k_info[o_ptr->k_idx].level; + + if (o_ptr->tval == TV_FOOD) + { + /* Analyze the food */ + switch (o_ptr->sval) + { + case SV_FOOD_POISON: + { + if (!(p_ptr->resist_pois || IS_OPPOSE_POIS())) + { + if (set_poisoned(p_ptr->poisoned + randint0(10) + 10)) + { + ident = TRUE; + } + } + break; + } + + case SV_FOOD_BLINDNESS: + { + if (!p_ptr->resist_blind) + { + if (set_blind(p_ptr->blind + randint0(200) + 200)) + { + ident = TRUE; + } + } + break; + } + + case SV_FOOD_PARANOIA: + { + if (!p_ptr->resist_fear) + { + if (set_afraid(p_ptr->afraid + randint0(10) + 10)) + { + ident = TRUE; + } + } + break; + } + + case SV_FOOD_CONFUSION: + { + if (!p_ptr->resist_conf) + { + if (set_confused(p_ptr->confused + randint0(10) + 10)) + { + ident = TRUE; + } + } + break; + } + + case SV_FOOD_HALLUCINATION: + { + if (!p_ptr->resist_chaos) + { + if (set_image(p_ptr->image + randint0(250) + 250)) + { + ident = TRUE; + } + } + break; + } + + case SV_FOOD_PARALYSIS: + { + if (!p_ptr->free_act) + { + if (set_paralyzed(p_ptr->paralyzed + randint0(10) + 10)) + { + ident = TRUE; + } + } + break; + } + + case SV_FOOD_WEAKNESS: + { + take_hit(DAMAGE_NOESCAPE, damroll(6, 6), _("“Å“ü‚èH—¿", "poisonous food"), -1); + (void)do_dec_stat(A_STR); + ident = TRUE; + break; + } + + case SV_FOOD_SICKNESS: + { + take_hit(DAMAGE_NOESCAPE, damroll(6, 6), _("“Å“ü‚èH—¿", "poisonous food"), -1); + (void)do_dec_stat(A_CON); + ident = TRUE; + break; + } + + case SV_FOOD_STUPIDITY: + { + take_hit(DAMAGE_NOESCAPE, damroll(8, 8), _("“Å“ü‚èH—¿", "poisonous food"), -1); + (void)do_dec_stat(A_INT); + ident = TRUE; + break; + } + + case SV_FOOD_NAIVETY: + { + take_hit(DAMAGE_NOESCAPE, damroll(8, 8), _("“Å“ü‚èH—¿", "poisonous food"), -1); + (void)do_dec_stat(A_WIS); + ident = TRUE; + break; + } + + case SV_FOOD_UNHEALTH: + { + take_hit(DAMAGE_NOESCAPE, damroll(10, 10), _("“Å“ü‚èH—¿", "poisonous food"), -1); + (void)do_dec_stat(A_CON); + ident = TRUE; + break; + } + + case SV_FOOD_DISEASE: + { + take_hit(DAMAGE_NOESCAPE, damroll(10, 10), _("“Å“ü‚èH—¿", "poisonous food"), -1); + (void)do_dec_stat(A_STR); + ident = TRUE; + break; + } + + case SV_FOOD_CURE_POISON: + { + if (set_poisoned(0)) ident = TRUE; + break; + } + + case SV_FOOD_CURE_BLINDNESS: + { + if (set_blind(0)) ident = TRUE; + break; + } + + case SV_FOOD_CURE_PARANOIA: + { + if (set_afraid(0)) ident = TRUE; + break; + } + + case SV_FOOD_CURE_CONFUSION: + { + if (set_confused(0)) ident = TRUE; + break; + } + + case SV_FOOD_CURE_SERIOUS: + { + if (hp_player(damroll(4, 8))) ident = TRUE; + break; + } + + case SV_FOOD_RESTORE_STR: + { + if (do_res_stat(A_STR)) ident = TRUE; + break; + } + + case SV_FOOD_RESTORE_CON: + { + if (do_res_stat(A_CON)) ident = TRUE; + break; + } + + case SV_FOOD_RESTORING: + { + if (do_res_stat(A_STR)) ident = TRUE; + if (do_res_stat(A_INT)) ident = TRUE; + if (do_res_stat(A_WIS)) ident = TRUE; + if (do_res_stat(A_DEX)) ident = TRUE; + if (do_res_stat(A_CON)) ident = TRUE; + if (do_res_stat(A_CHR)) ident = TRUE; + break; + } + + +#ifdef JP + /* ‚»‚ꂼ‚ê‚̐H‚ו¨‚ÌŠ´‘z‚ðƒIƒŠƒWƒiƒ‹‚æ‚è×‚©‚­•\Œ» */ + case SV_FOOD_BISCUIT: + { + msg_print("ŠÃ‚­‚ăTƒNƒTƒN‚µ‚Ä‚Æ‚Ä‚à‚¨‚¢‚µ‚¢B"); + ident = TRUE; + break; + } + + case SV_FOOD_JERKY: + { + msg_print("Ž•‚²‚½‚¦‚ª‚ ‚Á‚Ä‚¨‚¢‚µ‚¢B"); + ident = TRUE; + break; + } + + case SV_FOOD_SLIME_MOLD: + { + msg_print("‚±‚ê‚Í‚È‚ñ‚Æ‚àŒ`—e‚µ‚ª‚½‚¢–¡‚¾B"); + ident = TRUE; + break; + } + + case SV_FOOD_RATION: + { + msg_print("‚±‚ê‚Í‚¨‚¢‚µ‚¢B"); + ident = TRUE; + break; + } +#else + case SV_FOOD_RATION: + case SV_FOOD_BISCUIT: + case SV_FOOD_JERKY: + case SV_FOOD_SLIME_MOLD: + { + msg_print("That tastes good."); + ident = TRUE; + break; + } +#endif + + + case SV_FOOD_WAYBREAD: + { + msg_print(_("‚±‚ê‚͂Ђ¶‚傤‚É”ü–¡‚¾B", "That tastes good.")); + (void)set_poisoned(0); + (void)hp_player(damroll(4, 8)); + ident = TRUE; + break; + } + +#ifdef JP + case SV_FOOD_PINT_OF_ALE: + { + msg_print("‚Ì‚Ç‚²‚µ‘u‚â‚©‚¾B"); + ident = TRUE; + break; + } + + case SV_FOOD_PINT_OF_WINE: + { + msg_print("That tastes good."); + ident = TRUE; + break; + } +#else + case SV_FOOD_PINT_OF_ALE: + case SV_FOOD_PINT_OF_WINE: + { + msg_print("That tastes good."); + ident = TRUE; + break; + } +#endif + + } + } + + /* Combine / Reorder the pack (later) */ + p_ptr->notice |= (PN_COMBINE | PN_REORDER); + + if (!(object_is_aware(o_ptr))) + { + chg_virtue(V_KNOWLEDGE, -1); + chg_virtue(V_PATIENCE, -1); + chg_virtue(V_CHANCE, 1); + } + + /* We have tried it */ + if (o_ptr->tval == TV_FOOD) object_tried(o_ptr); + + /* The player is now aware of the object */ + if (ident && !object_is_aware(o_ptr)) + { + object_aware(o_ptr); + gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev); + } + + /* Window stuff */ + p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER); + + + /* Food can feed the player */ + if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE)) + { + /* Reduced nutritional benefit */ + (void)set_food(p_ptr->food + (o_ptr->pval / 10)); + msg_print(_("‚ ‚È‚½‚̂悤‚ÈŽÒ‚É‚Æ‚Á‚ĐH—Æ‚È‚Ç‹Í‚©‚ȉh—{‚É‚µ‚©‚È‚ç‚È‚¢B", + "Mere victuals hold scant sustenance for a being such as yourself.")); + + if (p_ptr->food < PY_FOOD_ALERT) /* Hungry */ + msg_print(_("‚ ‚È‚½‚Ì‹Q‚¦‚͐V‘N‚ÈŒŒ‚É‚æ‚Á‚Ä‚Ì‚Ý–ž‚½‚³‚ê‚éI", + "Your hunger can only be satisfied with fresh blood!")); + } + else if ((prace_is_(RACE_SKELETON) || + prace_is_(RACE_GOLEM) || + prace_is_(RACE_ZOMBIE) || + prace_is_(RACE_SPECTRE)) && + (o_ptr->tval == TV_STAFF || o_ptr->tval == TV_WAND)) + { + cptr staff; + + if (o_ptr->tval == TV_STAFF && + (item < 0) && (o_ptr->number > 1)) + { + msg_print(_("‚Ü‚¸‚͏ñ‚ðE‚í‚È‚¯‚ê‚΁B", "You must first pick up the staffs.")); + return; + } + staff = (o_ptr->tval == TV_STAFF) ? _("ñ", "staff") : _("–‚–@–_", "wand"); + + /* "Eat" charges */ + if (o_ptr->pval == 0) + { + msg_format(_("‚±‚Ì%s‚É‚Í‚à‚¤–‚—Í‚ªŽc‚Á‚Ä‚¢‚È‚¢B", "The %s has no charges left."), staff); + o_ptr->ident |= (IDENT_EMPTY); + + /* Combine / Reorder the pack (later) */ + p_ptr->notice |= (PN_COMBINE | PN_REORDER); + p_ptr->window |= (PW_INVEN); + + return; + } + msg_format(_("‚ ‚È‚½‚Í%s‚Ì–‚—Í‚ðƒGƒlƒ‹ƒM[Œ¹‚Æ‚µ‚Ä‹zŽû‚µ‚½B", "You absorb mana of the %s as your energy."), staff); + + /* Use a single charge */ + o_ptr->pval--; + + /* Eat a charge */ + set_food(p_ptr->food + 5000); + + /* XXX Hack -- unstack if necessary */ + if (o_ptr->tval == TV_STAFF && + (item >= 0) && (o_ptr->number > 1)) + { + object_type forge; + object_type *q_ptr; + + /* Get local object */ + q_ptr = &forge; + + /* Obtain a local object */ + object_copy(q_ptr, o_ptr); + + /* Modify quantity */ + q_ptr->number = 1; + + /* Restore the charges */ + o_ptr->pval++; + + /* Unstack the used item */ + o_ptr->number--; + p_ptr->total_weight -= q_ptr->weight; + item = inven_carry(q_ptr); + + /* Message */ + msg_format(_("ñ‚ð‚Ü‚Æ‚ß‚È‚¨‚µ‚½B", "You unstack your staff.")); + } + + /* Describe charges in the pack */ + if (item >= 0) + { + inven_item_charges(item); + } + + /* Describe charges on the floor */ + else + { + floor_item_charges(0 - item); + } + + /* Window stuff */ + p_ptr->window |= (PW_INVEN | PW_EQUIP); + + /* Don't eat a staff/wand itself */ + return; + } + else if ((prace_is_(RACE_DEMON) || + (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)) && + (o_ptr->tval == TV_CORPSE && o_ptr->sval == SV_CORPSE && + my_strchr("pht", r_info[o_ptr->pval].d_char))) + { + /* Drain vitality of humanoids */ + char o_name[MAX_NLEN]; + object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY)); + msg_format(_("%s‚Í”R‚¦ã‚èŠD‚É‚È‚Á‚½B¸—Í‚ð‹zŽû‚µ‚½‹C‚ª‚·‚éB", "%^s is burnt to ashes. You absorb its vitality!"), o_name); + (void)set_food(PY_FOOD_MAX - 1); + } + else if (prace_is_(RACE_SKELETON)) + { +#if 0 + if (o_ptr->tval == TV_SKELETON || + (o_ptr->tval == TV_CORPSE && o_ptr->sval == SV_SKELETON)) + { + msg_print(_("‚ ‚È‚½‚͍œ‚ÅŽ©•ª‚Ì‘Ì‚ð•â‚Á‚½B", "Your body absorbs the bone.")); + set_food(p_ptr->food + 5000); + } + else +#endif + + if (!((o_ptr->sval == SV_FOOD_WAYBREAD) || + (o_ptr->sval < SV_FOOD_BISCUIT))) + { + object_type forge; + object_type *q_ptr = &forge; + + msg_print(_("H‚ו¨‚ªƒAƒS‚ð‘f’ʂ肵‚Ä—Ž‚¿‚½I", "The food falls through your jaws!")); + + /* Create the item */ + object_prep(q_ptr, lookup_kind(o_ptr->tval, o_ptr->sval)); + + /* Drop the object from heaven */ + (void)drop_near(q_ptr, -1, p_ptr->y, p_ptr->x); + } + else + { + msg_print(_("H‚ו¨‚ªƒAƒS‚ð‘f’ʂ肵‚Ä—Ž‚¿AÁ‚¦‚½I", "The food falls through your jaws and vanishes!")); + } + } + else if (prace_is_(RACE_GOLEM) || + prace_is_(RACE_ZOMBIE) || + prace_is_(RACE_ENT) || + prace_is_(RACE_DEMON) || + prace_is_(RACE_ANDROID) || + prace_is_(RACE_SPECTRE) || + (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_NONLIVING)) + { + msg_print(_("¶ŽÒ‚̐H•¨‚Í‚ ‚È‚½‚É‚Æ‚Á‚Ä‚Ù‚Æ‚ñ‚ljh—{‚É‚È‚ç‚È‚¢B", "The food of mortals is poor sustenance for you.")); + set_food(p_ptr->food + ((o_ptr->pval) / 20)); + } + else if (o_ptr->tval == TV_FOOD && o_ptr->sval == SV_FOOD_WAYBREAD) + { + /* Waybread is always fully satisfying. */ + set_food(MAX(p_ptr->food, PY_FOOD_MAX - 1)); + } + else + { + /* Food can feed the player */ + (void)set_food(p_ptr->food + o_ptr->pval); + } + + /* Destroy a food in the pack */ + if (item >= 0) + { + inven_item_increase(item, -1); + inven_item_describe(item); + inven_item_optimize(item); + } + + /* Destroy a food on the floor */ + else + { + floor_item_increase(0 - item, -1); + floor_item_describe(0 - item); + floor_item_optimize(0 - item); + } +} + + +/*! + * @brief ƒIƒuƒWƒFƒNƒg‚ðƒvƒŒƒCƒ„[‚ªH‚ׂ邱‚Æ‚ª‚Å‚«‚é‚©‚ð”»’è‚·‚é / + * Hook to determine if an object is eatable + * @param o_ptr ”»’肵‚½‚¢ƒIƒuƒWƒFƒNƒg‚̍\‘¢‘ÌŽQÆƒ|ƒCƒ“ƒ^ + * @return H‚ׂ邱‚Æ‚ª‰Â”\‚È‚ç‚ÎTRUE‚ð•Ô‚· + */ +static bool item_tester_hook_eatable(object_type *o_ptr) +{ + if (o_ptr->tval == TV_FOOD) return TRUE; + +#if 0 + if (prace_is_(RACE_SKELETON)) + { + if (o_ptr->tval == TV_SKELETON || + (o_ptr->tval == TV_CORPSE && o_ptr->sval == SV_SKELETON)) + return TRUE; + } + else +#endif + + if (prace_is_(RACE_SKELETON) || + prace_is_(RACE_GOLEM) || + prace_is_(RACE_ZOMBIE) || + prace_is_(RACE_SPECTRE)) + { + if (o_ptr->tval == TV_STAFF || o_ptr->tval == TV_WAND) + return TRUE; + } + else if (prace_is_(RACE_DEMON) || + (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)) + { + if (o_ptr->tval == TV_CORPSE && + o_ptr->sval == SV_CORPSE && + my_strchr("pht", r_info[o_ptr->pval].d_char)) + return TRUE; + } + + /* Assume not */ + return (FALSE); +} + + +/*! + * @brief H—¿‚ðH‚ׂéƒRƒ}ƒ“ƒh‚̃ƒCƒ“ƒ‹[ƒ`ƒ“ / + * Eat some food (from the pack or floor) + * @return ‚È‚µ + */ +void do_cmd_eat_food(void) +{ + OBJECT_IDX item; + cptr q, s; + + + if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN)) + { + set_action(ACTION_NONE); + } + + /* Restrict choices to food */ + item_tester_hook = item_tester_hook_eatable; + + /* Get an item */ + q = _("‚Ç‚ê‚ðH‚ׂ܂·‚©? ", "Eat which item? "); + s = _("H‚ו¨‚ª‚È‚¢B", "You have nothing to eat."); + + if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return; + + /* Eat the object */ + do_cmd_eat_food_aux(item); +} + diff --git a/src/cmd-eat.h b/src/cmd-eat.h new file mode 100644 index 000000000..6037960c5 --- /dev/null +++ b/src/cmd-eat.h @@ -0,0 +1,3 @@ + +extern void do_cmd_eat_food(void); +extern void do_cmd_eat_food_aux(int item); diff --git a/src/cmd6.c b/src/cmd6.c index 42e656c7c..c0441d811 100644 --- a/src/cmd6.c +++ b/src/cmd6.c @@ -54,573 +54,9 @@ #include "angband.h" #include "selfinfo.h" +#include "cmd-eat.h" -/*! - * @brief 食料を食べるコマンドのサブルーチン - * @param item 食べるオブジェクトの所持品ID - * @return なし - */ -static void do_cmd_eat_food_aux(int item) -{ - int ident, lev; - object_type *o_ptr; - - if (music_singing_any()) stop_singing(); - if (hex_spelling_any()) stop_hex_spell_all(); - - /* 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]; - } - - /* Sound */ - sound(SOUND_EAT); - - /* Take a turn */ - p_ptr->energy_use = 100; - - /* Identity not known yet */ - ident = FALSE; - - /* Object level */ - lev = k_info[o_ptr->k_idx].level; - - if (o_ptr->tval == TV_FOOD) - { - /* Analyze the food */ - switch (o_ptr->sval) - { - case SV_FOOD_POISON: - { - if (!(p_ptr->resist_pois || IS_OPPOSE_POIS())) - { - if (set_poisoned(p_ptr->poisoned + randint0(10) + 10)) - { - ident = TRUE; - } - } - break; - } - - case SV_FOOD_BLINDNESS: - { - if (!p_ptr->resist_blind) - { - if (set_blind(p_ptr->blind + randint0(200) + 200)) - { - ident = TRUE; - } - } - break; - } - - case SV_FOOD_PARANOIA: - { - if (!p_ptr->resist_fear) - { - if (set_afraid(p_ptr->afraid + randint0(10) + 10)) - { - ident = TRUE; - } - } - break; - } - - case SV_FOOD_CONFUSION: - { - if (!p_ptr->resist_conf) - { - if (set_confused(p_ptr->confused + randint0(10) + 10)) - { - ident = TRUE; - } - } - break; - } - - case SV_FOOD_HALLUCINATION: - { - if (!p_ptr->resist_chaos) - { - if (set_image(p_ptr->image + randint0(250) + 250)) - { - ident = TRUE; - } - } - break; - } - - case SV_FOOD_PARALYSIS: - { - if (!p_ptr->free_act) - { - if (set_paralyzed(p_ptr->paralyzed + randint0(10) + 10)) - { - ident = TRUE; - } - } - break; - } - - case SV_FOOD_WEAKNESS: - { - take_hit(DAMAGE_NOESCAPE, damroll(6, 6), _("毒入り食料", "poisonous food"), -1); - (void)do_dec_stat(A_STR); - ident = TRUE; - break; - } - - case SV_FOOD_SICKNESS: - { - take_hit(DAMAGE_NOESCAPE, damroll(6, 6), _("毒入り食料", "poisonous food"), -1); - (void)do_dec_stat(A_CON); - ident = TRUE; - break; - } - - case SV_FOOD_STUPIDITY: - { - take_hit(DAMAGE_NOESCAPE, damroll(8, 8), _("毒入り食料", "poisonous food"), -1); - (void)do_dec_stat(A_INT); - ident = TRUE; - break; - } - - case SV_FOOD_NAIVETY: - { - take_hit(DAMAGE_NOESCAPE, damroll(8, 8), _("毒入り食料", "poisonous food"), -1); - (void)do_dec_stat(A_WIS); - ident = TRUE; - break; - } - - case SV_FOOD_UNHEALTH: - { - take_hit(DAMAGE_NOESCAPE, damroll(10, 10), _("毒入り食料", "poisonous food"), -1); - (void)do_dec_stat(A_CON); - ident = TRUE; - break; - } - - case SV_FOOD_DISEASE: - { - take_hit(DAMAGE_NOESCAPE, damroll(10, 10), _("毒入り食料", "poisonous food"), -1); - (void)do_dec_stat(A_STR); - ident = TRUE; - break; - } - - case SV_FOOD_CURE_POISON: - { - if (set_poisoned(0)) ident = TRUE; - break; - } - - case SV_FOOD_CURE_BLINDNESS: - { - if (set_blind(0)) ident = TRUE; - break; - } - - case SV_FOOD_CURE_PARANOIA: - { - if (set_afraid(0)) ident = TRUE; - break; - } - - case SV_FOOD_CURE_CONFUSION: - { - if (set_confused(0)) ident = TRUE; - break; - } - - case SV_FOOD_CURE_SERIOUS: - { - if (hp_player(damroll(4, 8))) ident = TRUE; - break; - } - - case SV_FOOD_RESTORE_STR: - { - if (do_res_stat(A_STR)) ident = TRUE; - break; - } - - case SV_FOOD_RESTORE_CON: - { - if (do_res_stat(A_CON)) ident = TRUE; - break; - } - - case SV_FOOD_RESTORING: - { - if (do_res_stat(A_STR)) ident = TRUE; - if (do_res_stat(A_INT)) ident = TRUE; - if (do_res_stat(A_WIS)) ident = TRUE; - if (do_res_stat(A_DEX)) ident = TRUE; - if (do_res_stat(A_CON)) ident = TRUE; - if (do_res_stat(A_CHR)) ident = TRUE; - break; - } - - -#ifdef JP - /* それぞれの食べ物の感想をオリジナルより細かく表現 */ - case SV_FOOD_BISCUIT: - { - msg_print("甘くてサクサクしてとてもおいしい。"); - ident = TRUE; - break; - } - - case SV_FOOD_JERKY: - { - msg_print("歯ごたえがあっておいしい。"); - ident = TRUE; - break; - } - - case SV_FOOD_SLIME_MOLD: - { - msg_print("これはなんとも形容しがたい味だ。"); - ident = TRUE; - break; - } - - case SV_FOOD_RATION: - { - msg_print("これはおいしい。"); - ident = TRUE; - break; - } -#else - case SV_FOOD_RATION: - case SV_FOOD_BISCUIT: - case SV_FOOD_JERKY: - case SV_FOOD_SLIME_MOLD: - { - msg_print("That tastes good."); - ident = TRUE; - break; - } -#endif - - - case SV_FOOD_WAYBREAD: - { - msg_print(_("これはひじょうに美味だ。", "That tastes good.")); - (void)set_poisoned(0); - (void)hp_player(damroll(4, 8)); - ident = TRUE; - break; - } - -#ifdef JP - case SV_FOOD_PINT_OF_ALE: - { - msg_print("のどごし爽やかだ。"); - ident = TRUE; - break; - } - - case SV_FOOD_PINT_OF_WINE: - { - msg_print("That tastes good."); - ident = TRUE; - break; - } -#else - case SV_FOOD_PINT_OF_ALE: - case SV_FOOD_PINT_OF_WINE: - { - msg_print("That tastes good."); - ident = TRUE; - break; - } -#endif - - } - } - - /* Combine / Reorder the pack (later) */ - p_ptr->notice |= (PN_COMBINE | PN_REORDER); - - if (!(object_is_aware(o_ptr))) - { - chg_virtue(V_KNOWLEDGE, -1); - chg_virtue(V_PATIENCE, -1); - chg_virtue(V_CHANCE, 1); - } - - /* We have tried it */ - if (o_ptr->tval == TV_FOOD) object_tried(o_ptr); - - /* The player is now aware of the object */ - if (ident && !object_is_aware(o_ptr)) - { - object_aware(o_ptr); - gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev); - } - - /* Window stuff */ - p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER); - - - /* Food can feed the player */ - if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE)) - { - /* Reduced nutritional benefit */ - (void)set_food(p_ptr->food + (o_ptr->pval / 10)); - msg_print(_("あなたのような者にとって食糧など僅かな栄養にしかならない。", - "Mere victuals hold scant sustenance for a being such as yourself.")); - - if (p_ptr->food < PY_FOOD_ALERT) /* Hungry */ - msg_print(_("あなたの飢えは新鮮な血によってのみ満たされる!", - "Your hunger can only be satisfied with fresh blood!")); - } - else if ((prace_is_(RACE_SKELETON) || - prace_is_(RACE_GOLEM) || - prace_is_(RACE_ZOMBIE) || - prace_is_(RACE_SPECTRE)) && - (o_ptr->tval == TV_STAFF || o_ptr->tval == TV_WAND)) - { - cptr staff; - - if (o_ptr->tval == TV_STAFF && - (item < 0) && (o_ptr->number > 1)) - { - msg_print(_("まずは杖を拾わなければ。", "You must first pick up the staffs.")); - return; - } - staff = (o_ptr->tval == TV_STAFF) ? _("杖", "staff") : _("魔法棒", "wand"); - - /* "Eat" charges */ - if (o_ptr->pval == 0) - { - msg_format(_("この%sにはもう魔力が残っていない。", "The %s has no charges left."), staff); - o_ptr->ident |= (IDENT_EMPTY); - - /* Combine / Reorder the pack (later) */ - p_ptr->notice |= (PN_COMBINE | PN_REORDER); - p_ptr->window |= (PW_INVEN); - - return; - } - msg_format(_("あなたは%sの魔力をエネルギー源として吸収した。", "You absorb mana of the %s as your energy."), staff); - - /* Use a single charge */ - o_ptr->pval--; - - /* Eat a charge */ - set_food(p_ptr->food + 5000); - - /* XXX Hack -- unstack if necessary */ - if (o_ptr->tval == TV_STAFF && - (item >= 0) && (o_ptr->number > 1)) - { - object_type forge; - object_type *q_ptr; - - /* Get local object */ - q_ptr = &forge; - - /* Obtain a local object */ - object_copy(q_ptr, o_ptr); - - /* Modify quantity */ - q_ptr->number = 1; - - /* Restore the charges */ - o_ptr->pval++; - - /* Unstack the used item */ - o_ptr->number--; - p_ptr->total_weight -= q_ptr->weight; - item = inven_carry(q_ptr); - - /* Message */ - msg_format(_("杖をまとめなおした。", "You unstack your staff.")); - } - - /* Describe charges in the pack */ - if (item >= 0) - { - inven_item_charges(item); - } - - /* Describe charges on the floor */ - else - { - floor_item_charges(0 - item); - } - - /* Window stuff */ - p_ptr->window |= (PW_INVEN | PW_EQUIP); - - /* Don't eat a staff/wand itself */ - return; - } - else if ((prace_is_(RACE_DEMON) || - (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)) && - (o_ptr->tval == TV_CORPSE && o_ptr->sval == SV_CORPSE && - my_strchr("pht", r_info[o_ptr->pval].d_char))) - { - /* Drain vitality of humanoids */ - char o_name[MAX_NLEN]; - object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY)); - msg_format(_("%sは燃え上り灰になった。精力を吸収した気がする。", "%^s is burnt to ashes. You absorb its vitality!"), o_name); - (void)set_food(PY_FOOD_MAX - 1); - } - else if (prace_is_(RACE_SKELETON)) - { -#if 0 - if (o_ptr->tval == TV_SKELETON || - (o_ptr->tval == TV_CORPSE && o_ptr->sval == SV_SKELETON)) - { - msg_print(_("あなたは骨で自分の体を補った。", "Your body absorbs the bone.")); - set_food(p_ptr->food + 5000); - } - else -#endif - - if (!((o_ptr->sval == SV_FOOD_WAYBREAD) || - (o_ptr->sval < SV_FOOD_BISCUIT))) - { - object_type forge; - object_type *q_ptr = &forge; - - msg_print(_("食べ物がアゴを素通りして落ちた!", "The food falls through your jaws!")); - - /* Create the item */ - object_prep(q_ptr, lookup_kind(o_ptr->tval, o_ptr->sval)); - - /* Drop the object from heaven */ - (void)drop_near(q_ptr, -1, p_ptr->y, p_ptr->x); - } - else - { - msg_print(_("食べ物がアゴを素通りして落ち、消えた!", "The food falls through your jaws and vanishes!")); - } - } - else if (prace_is_(RACE_GOLEM) || - prace_is_(RACE_ZOMBIE) || - prace_is_(RACE_ENT) || - prace_is_(RACE_DEMON) || - prace_is_(RACE_ANDROID) || - prace_is_(RACE_SPECTRE) || - (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_NONLIVING)) - { - msg_print(_("生者の食物はあなたにとってほとんど栄養にならない。", "The food of mortals is poor sustenance for you.")); - set_food(p_ptr->food + ((o_ptr->pval) / 20)); - } - else if (o_ptr->tval == TV_FOOD && o_ptr->sval == SV_FOOD_WAYBREAD) - { - /* Waybread is always fully satisfying. */ - set_food(MAX(p_ptr->food, PY_FOOD_MAX - 1)); - } - else - { - /* Food can feed the player */ - (void)set_food(p_ptr->food + o_ptr->pval); - } - - /* Destroy a food in the pack */ - if (item >= 0) - { - inven_item_increase(item, -1); - inven_item_describe(item); - inven_item_optimize(item); - } - - /* Destroy a food on the floor */ - else - { - floor_item_increase(0 - item, -1); - floor_item_describe(0 - item); - floor_item_optimize(0 - item); - } -} - - -/*! - * @brief オブジェクトをプレイヤーが食べることができるかを判定する / - * Hook to determine if an object is eatable - * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ - * @return 食べることが可能ならばTRUEを返す - */ -static bool item_tester_hook_eatable(object_type *o_ptr) -{ - if (o_ptr->tval==TV_FOOD) return TRUE; - -#if 0 - if (prace_is_(RACE_SKELETON)) - { - if (o_ptr->tval == TV_SKELETON || - (o_ptr->tval == TV_CORPSE && o_ptr->sval == SV_SKELETON)) - return TRUE; - } - else -#endif - - if (prace_is_(RACE_SKELETON) || - prace_is_(RACE_GOLEM) || - prace_is_(RACE_ZOMBIE) || - prace_is_(RACE_SPECTRE)) - { - if (o_ptr->tval == TV_STAFF || o_ptr->tval == TV_WAND) - return TRUE; - } - else if (prace_is_(RACE_DEMON) || - (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)) - { - if (o_ptr->tval == TV_CORPSE && - o_ptr->sval == SV_CORPSE && - my_strchr("pht", r_info[o_ptr->pval].d_char)) - return TRUE; - } - - /* Assume not */ - return (FALSE); -} - - -/*! - * @brief 食料を食べるコマンドのメインルーチン / - * Eat some food (from the pack or floor) - * @return なし - */ -void do_cmd_eat_food(void) -{ - OBJECT_IDX item; - cptr q, s; - - - if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN)) - { - set_action(ACTION_NONE); - } - - /* Restrict choices to food */ - item_tester_hook = item_tester_hook_eatable; - - /* Get an item */ - q = _("どれを食べますか? ", "Eat which item? "); - s = _("食べ物がない。", "You have nothing to eat."); - - if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return; - - /* Eat the object */ - do_cmd_eat_food_aux(item); -} - /*! * @brief 薬を飲むコマンドのサブルーチン / diff --git a/src/externs.h b/src/externs.h index a5a139f78..edc933677 100644 --- a/src/externs.h +++ b/src/externs.h @@ -804,7 +804,6 @@ extern void do_cmd_pet_dismiss(void); extern void do_cmd_pet(void); /* cmd6.c */ -extern void do_cmd_eat_food(void); extern void do_cmd_quaff_potion(void); extern void do_cmd_read_scroll(void); extern void do_cmd_aim_wand(void); -- 2.11.0