2 * @brief プレイヤーの食べるコマンド実装
7 #include "cmd-item/cmd-eat.h"
8 #include "core/hp-mp-processor.h"
9 #include "core/player-update-types.h"
10 #include "core/window-redrawer.h"
11 #include "flavor/flavor-describer.h"
12 #include "flavor/object-flavor-types.h"
13 #include "floor/floor-object.h"
14 #include "inventory/inventory-object.h"
15 #include "main/sound-definitions-table.h"
16 #include "main/sound-of-music.h"
17 #include "monster-race/monster-race.h"
18 #include "object-enchant/special-object-flags.h"
19 #include "object-hook/hook-expendable.h"
20 #include "object/item-tester-hooker.h"
21 #include "object/item-use-flags.h"
22 #include "object/object-generator.h"
23 #include "object/object-info.h"
24 #include "object/object-kind-hook.h"
25 #include "object/object-kind.h"
26 #include "perception/object-perception.h"
27 #include "player/attack-defense-types.h"
28 #include "player-info/avatar.h"
29 #include "player/digestion-processor.h"
30 #include "player/mimic-info-table.h"
31 #include "player/player-class.h"
32 #include "player/player-damage.h"
33 #include "player/player-race-types.h"
34 #include "player/special-defense-types.h"
35 #include "player/player-status-flags.h"
36 #include "spell-realm/spells-hex.h"
37 #include "spell/spells-status.h"
38 #include "status/action-setter.h"
39 #include "status/bad-status-setter.h"
40 #include "status/base-status.h"
41 #include "status/element-resistance.h"
42 #include "status/experience.h"
43 #include "sv-definition/sv-food-types.h"
44 #include "sv-definition/sv-other-types.h"
45 #include "util/string-processor.h"
46 #include "view/display-messages.h"
47 #include "view/object-describer.h"
50 * @brief 食料を食べるコマンドのサブルーチン
51 * @param item 食べるオブジェクトの所持品ID
54 void exe_eat_food(player_type *creature_ptr, INVENTORY_IDX item)
59 if (music_singing_any(creature_ptr))
60 stop_singing(creature_ptr);
61 if (hex_spelling_any(creature_ptr))
62 stop_hex_spell_all(creature_ptr);
63 o_ptr = ref_item(creature_ptr, item);
67 take_turn(creature_ptr, 100);
69 /* Identity not known yet */
73 lev = k_info[o_ptr->k_idx].level;
75 if (o_ptr->tval == TV_FOOD) {
76 /* Analyze the food */
77 switch (o_ptr->sval) {
78 case SV_FOOD_POISON: {
79 if (!(has_resist_pois(creature_ptr) || is_oppose_pois(creature_ptr))) {
80 if (set_poisoned(creature_ptr, creature_ptr->poisoned + randint0(10) + 10)) {
87 case SV_FOOD_BLINDNESS: {
88 if (!creature_ptr->resist_blind) {
89 if (set_blind(creature_ptr, creature_ptr->blind + randint0(200) + 200)) {
96 case SV_FOOD_PARANOIA: {
97 if (!creature_ptr->resist_fear) {
98 if (set_afraid(creature_ptr, creature_ptr->afraid + randint0(10) + 10)) {
105 case SV_FOOD_CONFUSION: {
106 if (!has_resist_conf(creature_ptr)) {
107 if (set_confused(creature_ptr, creature_ptr->confused + randint0(10) + 10)) {
114 case SV_FOOD_HALLUCINATION: {
115 if (!has_resist_chaos(creature_ptr)) {
116 if (set_image(creature_ptr, creature_ptr->image + randint0(250) + 250)) {
123 case SV_FOOD_PARALYSIS: {
124 if (!creature_ptr->free_act) {
125 if (set_paralyzed(creature_ptr, creature_ptr->paralyzed + randint0(10) + 10)) {
132 case SV_FOOD_WEAKNESS: {
133 take_hit(creature_ptr, DAMAGE_NOESCAPE, damroll(6, 6), _("毒入り食料", "poisonous food"), -1);
134 (void)do_dec_stat(creature_ptr, A_STR);
139 case SV_FOOD_SICKNESS: {
140 take_hit(creature_ptr, DAMAGE_NOESCAPE, damroll(6, 6), _("毒入り食料", "poisonous food"), -1);
141 (void)do_dec_stat(creature_ptr, A_CON);
146 case SV_FOOD_STUPIDITY: {
147 take_hit(creature_ptr, DAMAGE_NOESCAPE, damroll(8, 8), _("毒入り食料", "poisonous food"), -1);
148 (void)do_dec_stat(creature_ptr, A_INT);
153 case SV_FOOD_NAIVETY: {
154 take_hit(creature_ptr, DAMAGE_NOESCAPE, damroll(8, 8), _("毒入り食料", "poisonous food"), -1);
155 (void)do_dec_stat(creature_ptr, A_WIS);
160 case SV_FOOD_UNHEALTH: {
161 take_hit(creature_ptr, DAMAGE_NOESCAPE, damroll(10, 10), _("毒入り食料", "poisonous food"), -1);
162 (void)do_dec_stat(creature_ptr, A_CON);
167 case SV_FOOD_DISEASE: {
168 take_hit(creature_ptr, DAMAGE_NOESCAPE, damroll(10, 10), _("毒入り食料", "poisonous food"), -1);
169 (void)do_dec_stat(creature_ptr, A_STR);
174 case SV_FOOD_CURE_POISON: {
175 if (set_poisoned(creature_ptr, 0))
180 case SV_FOOD_CURE_BLINDNESS: {
181 if (set_blind(creature_ptr, 0))
186 case SV_FOOD_CURE_PARANOIA: {
187 if (set_afraid(creature_ptr, 0))
192 case SV_FOOD_CURE_CONFUSION: {
193 if (set_confused(creature_ptr, 0))
198 case SV_FOOD_CURE_SERIOUS: {
199 ident = cure_serious_wounds(creature_ptr, 4, 8);
203 case SV_FOOD_RESTORE_STR: {
204 if (do_res_stat(creature_ptr, A_STR))
209 case SV_FOOD_RESTORE_CON: {
210 if (do_res_stat(creature_ptr, A_CON))
215 case SV_FOOD_RESTORING: {
216 ident = restore_all_status(creature_ptr);
221 /* それぞれの食べ物の感想をオリジナルより細かく表現 */
222 case SV_FOOD_BISCUIT: {
223 msg_print("甘くてサクサクしてとてもおいしい。");
228 case SV_FOOD_JERKY: {
229 msg_print("歯ごたえがあっておいしい。");
234 case SV_FOOD_SLIME_MOLD: {
235 msg_print("これはなんとも形容しがたい味だ。");
240 case SV_FOOD_RATION: {
241 msg_print("これはおいしい。");
247 case SV_FOOD_BISCUIT:
249 case SV_FOOD_SLIME_MOLD: {
250 msg_print("That tastes good.");
256 case SV_FOOD_WAYBREAD: {
257 msg_print(_("これはひじょうに美味だ。", "That tastes good."));
258 (void)set_poisoned(creature_ptr, 0);
259 (void)hp_player(creature_ptr, damroll(4, 8));
264 case SV_FOOD_PINT_OF_ALE: {
265 msg_print(_("のどごし爽やかだ。", "That tastes good."));
270 case SV_FOOD_PINT_OF_WINE: {
271 msg_print(_("のどごし爽やかだ。", "That tastes good."));
279 * Store what may have to be updated for the inventory (including
280 * autodestroy if set by something else). Then turn off those flags
281 * so that updates triggered by calling gain_exp() or set_food() below
282 * do not rearrange the inventory before the food item is destroyed in
285 BIT_FLAGS inventory_flags = (PU_COMBINE | PU_REORDER | (creature_ptr->update & PU_AUTODESTROY));
286 creature_ptr->update &= ~(PU_COMBINE | PU_REORDER | PU_AUTODESTROY);
288 if (!(object_is_aware(o_ptr))) {
289 chg_virtue(creature_ptr, V_KNOWLEDGE, -1);
290 chg_virtue(creature_ptr, V_PATIENCE, -1);
291 chg_virtue(creature_ptr, V_CHANCE, 1);
294 /* We have tried it */
295 if (o_ptr->tval == TV_FOOD)
298 /* The player is now aware of the object */
299 if (ident && !object_is_aware(o_ptr)) {
300 object_aware(creature_ptr, o_ptr);
301 gain_exp(creature_ptr, (lev + (creature_ptr->lev >> 1)) / creature_ptr->lev);
304 creature_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
306 /* Food can feed the player */
307 if (is_specific_player_race(creature_ptr, RACE_VAMPIRE) || (creature_ptr->mimic_form == MIMIC_VAMPIRE)) {
308 /* Reduced nutritional benefit */
309 (void)set_food(creature_ptr, creature_ptr->food + (o_ptr->pval / 10));
310 msg_print(_("あなたのような者にとって食糧など僅かな栄養にしかならない。", "Mere victuals hold scant sustenance for a being such as yourself."));
312 if (creature_ptr->food < PY_FOOD_ALERT) /* Hungry */
313 msg_print(_("あなたの飢えは新鮮な血によってのみ満たされる!", "Your hunger can only be satisfied with fresh blood!"));
314 } else if ((is_specific_player_race(creature_ptr, RACE_SKELETON) || is_specific_player_race(creature_ptr, RACE_GOLEM)
315 || is_specific_player_race(creature_ptr, RACE_ZOMBIE) || is_specific_player_race(creature_ptr, RACE_SPECTRE))
316 && (o_ptr->tval == TV_STAFF || o_ptr->tval == TV_WAND)) {
319 if (o_ptr->tval == TV_STAFF && (item < 0) && (o_ptr->number > 1)) {
320 creature_ptr->update |= inventory_flags;
321 msg_print(_("まずは杖を拾わなければ。", "You must first pick up the staffs."));
324 staff = (o_ptr->tval == TV_STAFF) ? _("杖", "staff") : _("魔法棒", "wand");
327 if (o_ptr->pval == 0) {
328 msg_format(_("この%sにはもう魔力が残っていない。", "The %s has no charges left."), staff);
329 o_ptr->ident |= (IDENT_EMPTY);
330 creature_ptr->update |= inventory_flags;
331 creature_ptr->window |= (PW_INVEN);
335 msg_format(_("あなたは%sの魔力をエネルギー源として吸収した。", "You absorb mana of the %s as your energy."), staff);
337 /* Use a single charge */
341 set_food(creature_ptr, creature_ptr->food + 5000);
343 /* XXX Hack -- unstack if necessary */
344 if (o_ptr->tval == TV_STAFF && (item >= 0) && (o_ptr->number > 1)) {
348 object_copy(q_ptr, o_ptr);
350 /* Modify quantity */
353 /* Restore the charges */
356 /* Unstack the used item */
358 item = store_item_to_inventory(creature_ptr, q_ptr);
360 msg_format(_("杖をまとめなおした。", "You unstack your staff."));
363 /* Describe charges in the pack */
365 inven_item_charges(creature_ptr, item);
368 /* Describe charges on the floor */
370 floor_item_charges(creature_ptr->current_floor_ptr, 0 - item);
373 creature_ptr->window |= (PW_INVEN | PW_EQUIP);
374 creature_ptr->update |= inventory_flags;
376 /* Don't eat a staff/wand itself */
380 if ((is_specific_player_race(creature_ptr, RACE_BALROG) || (mimic_info[creature_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON))
381 && (o_ptr->tval == TV_CORPSE && o_ptr->sval == SV_CORPSE && angband_strchr("pht", r_info[o_ptr->pval].d_char))) {
382 /* Drain vitality of humanoids */
383 GAME_TEXT o_name[MAX_NLEN];
384 describe_flavor(creature_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
385 msg_format(_("%sは燃え上り灰になった。精力を吸収した気がする。", "%^s is burnt to ashes. You absorb its vitality!"), o_name);
386 (void)set_food(creature_ptr, PY_FOOD_MAX - 1);
387 } else if (is_specific_player_race(creature_ptr, RACE_SKELETON)) {
388 if (!((o_ptr->sval == SV_FOOD_WAYBREAD) || (o_ptr->sval < SV_FOOD_BISCUIT))) {
390 object_type *q_ptr = &forge;
392 msg_print(_("食べ物がアゴを素通りして落ちた!", "The food falls through your jaws!"));
393 object_prep(creature_ptr, q_ptr, lookup_kind(o_ptr->tval, o_ptr->sval));
395 /* Drop the object from heaven */
396 (void)drop_near(creature_ptr, q_ptr, -1, creature_ptr->y, creature_ptr->x);
398 msg_print(_("食べ物がアゴを素通りして落ち、消えた!", "The food falls through your jaws and vanishes!"));
400 } else if (is_specific_player_race(creature_ptr, RACE_GOLEM) || is_specific_player_race(creature_ptr, RACE_ZOMBIE)
401 || is_specific_player_race(creature_ptr, RACE_ENT) || is_specific_player_race(creature_ptr, RACE_BALROG)
402 || is_specific_player_race(creature_ptr, RACE_ANDROID) || is_specific_player_race(creature_ptr, RACE_SPECTRE)
403 || (mimic_info[creature_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_NONLIVING)) {
404 msg_print(_("生者の食物はあなたにとってほとんど栄養にならない。", "The food of mortals is poor sustenance for you."));
405 set_food(creature_ptr, creature_ptr->food + ((o_ptr->pval) / 20));
406 } else if (o_ptr->tval == TV_FOOD && o_ptr->sval == SV_FOOD_WAYBREAD) {
407 /* Waybread is always fully satisfying. */
408 set_food(creature_ptr, MAX(creature_ptr->food, PY_FOOD_MAX - 1));
410 /* Food can feed the player */
411 (void)set_food(creature_ptr, creature_ptr->food + o_ptr->pval);
414 creature_ptr->update |= inventory_flags;
415 vary_item(creature_ptr, item, -1);
419 * @brief 食料を食べるコマンドのメインルーチン /
420 * Eat some food (from the pack or floor)
423 void do_cmd_eat_food(player_type *creature_ptr)
428 if (creature_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN)) {
429 set_action(creature_ptr, ACTION_NONE);
432 item_tester_hook = item_tester_hook_eatable;
434 q = _("どれを食べますか? ", "Eat which item? ");
435 s = _("食べ物がない。", "You have nothing to eat.");
437 if (!choose_object(creature_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), 0))
440 exe_eat_food(creature_ptr, item);