3 * @brief プレイヤーの食べるコマンド実装
11 #include "main/sound-definitions-table.h"
14 #include "object-flavor.h"
15 #include "object-hook.h"
17 #include "spells-status.h"
18 #include "realm-hex.h"
19 #include "player-status.h"
20 #include "player-effects.h"
21 #include "player-damage.h"
22 #include "player/mimic-info-table.h"
23 #include "player-class.h"
24 #include "player-inventory.h"
26 #include "object/object-kind.h"
27 #include "view/display-main-window.h"
30 * @brief 食料を食べるコマンドのサブルーチン
31 * @param item 食べるオブジェクトの所持品ID
34 void exe_eat_food(player_type *creature_ptr, INVENTORY_IDX item)
39 if (music_singing_any(creature_ptr)) stop_singing(creature_ptr);
40 if (hex_spelling_any(creature_ptr)) stop_hex_spell_all(creature_ptr);
41 o_ptr = REF_ITEM(creature_ptr, creature_ptr->current_floor_ptr, item);
45 take_turn(creature_ptr, 100);
47 /* Identity not known yet */
51 lev = k_info[o_ptr->k_idx].level;
53 if (o_ptr->tval == TV_FOOD)
55 /* Analyze the food */
60 if (!(creature_ptr->resist_pois || is_oppose_pois(creature_ptr)))
62 if (set_poisoned(creature_ptr, creature_ptr->poisoned + randint0(10) + 10))
70 case SV_FOOD_BLINDNESS:
72 if (!creature_ptr->resist_blind)
74 if (set_blind(creature_ptr, creature_ptr->blind + randint0(200) + 200))
82 case SV_FOOD_PARANOIA:
84 if (!creature_ptr->resist_fear)
86 if (set_afraid(creature_ptr, creature_ptr->afraid + randint0(10) + 10))
94 case SV_FOOD_CONFUSION:
96 if (!creature_ptr->resist_conf)
98 if (set_confused(creature_ptr, creature_ptr->confused + randint0(10) + 10))
106 case SV_FOOD_HALLUCINATION:
108 if (!creature_ptr->resist_chaos)
110 if (set_image(creature_ptr, creature_ptr->image + randint0(250) + 250))
118 case SV_FOOD_PARALYSIS:
120 if (!creature_ptr->free_act)
122 if (set_paralyzed(creature_ptr, creature_ptr->paralyzed + randint0(10) + 10))
130 case SV_FOOD_WEAKNESS:
132 take_hit(creature_ptr, DAMAGE_NOESCAPE, damroll(6, 6), _("毒入り食料", "poisonous food"), -1);
133 (void)do_dec_stat(creature_ptr, A_STR);
138 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:
148 take_hit(creature_ptr, DAMAGE_NOESCAPE, damroll(8, 8), _("毒入り食料", "poisonous food"), -1);
149 (void)do_dec_stat(creature_ptr, A_INT);
154 case SV_FOOD_NAIVETY:
156 take_hit(creature_ptr, DAMAGE_NOESCAPE, damroll(8, 8), _("毒入り食料", "poisonous food"), -1);
157 (void)do_dec_stat(creature_ptr, A_WIS);
162 case SV_FOOD_UNHEALTH:
164 take_hit(creature_ptr, DAMAGE_NOESCAPE, damroll(10, 10), _("毒入り食料", "poisonous food"), -1);
165 (void)do_dec_stat(creature_ptr, A_CON);
170 case SV_FOOD_DISEASE:
172 take_hit(creature_ptr, DAMAGE_NOESCAPE, damroll(10, 10), _("毒入り食料", "poisonous food"), -1);
173 (void)do_dec_stat(creature_ptr, A_STR);
178 case SV_FOOD_CURE_POISON:
180 if (set_poisoned(creature_ptr, 0)) ident = TRUE;
184 case SV_FOOD_CURE_BLINDNESS:
186 if (set_blind(creature_ptr, 0)) ident = TRUE;
190 case SV_FOOD_CURE_PARANOIA:
192 if (set_afraid(creature_ptr, 0)) ident = TRUE;
196 case SV_FOOD_CURE_CONFUSION:
198 if (set_confused(creature_ptr, 0)) ident = TRUE;
202 case SV_FOOD_CURE_SERIOUS:
204 ident = cure_serious_wounds(creature_ptr, 4, 8);
208 case SV_FOOD_RESTORE_STR:
210 if (do_res_stat(creature_ptr, A_STR)) ident = TRUE;
214 case SV_FOOD_RESTORE_CON:
216 if (do_res_stat(creature_ptr, A_CON)) ident = TRUE;
220 case SV_FOOD_RESTORING:
222 ident = restore_all_status(creature_ptr);
228 /* それぞれの食べ物の感想をオリジナルより細かく表現 */
229 case SV_FOOD_BISCUIT:
231 msg_print("甘くてサクサクしてとてもおいしい。");
238 msg_print("歯ごたえがあっておいしい。");
243 case SV_FOOD_SLIME_MOLD:
245 msg_print("これはなんとも形容しがたい味だ。");
252 msg_print("これはおいしい。");
258 case SV_FOOD_BISCUIT:
260 case SV_FOOD_SLIME_MOLD:
262 msg_print("That tastes good.");
269 case SV_FOOD_WAYBREAD:
271 msg_print(_("これはひじょうに美味だ。", "That tastes good."));
272 (void)set_poisoned(creature_ptr, 0);
273 (void)hp_player(creature_ptr, damroll(4, 8));
278 case SV_FOOD_PINT_OF_ALE:
280 msg_print(_("のどごし爽やかだ。", "That tastes good."));
285 case SV_FOOD_PINT_OF_WINE:
287 msg_print(_("のどごし爽やかだ。", "That tastes good."));
296 * Store what may have to be updated for the inventory (including
297 * autodestroy if set by something else). Then turn off those flags
298 * so that updates triggered by calling gain_exp() or set_food() below
299 * do not rearrange the inventory before the food item is destroyed in
302 BIT_FLAGS inventory_flags = (PU_COMBINE | PU_REORDER | (creature_ptr->update & PU_AUTODESTROY));
303 creature_ptr->update &= ~(PU_COMBINE | PU_REORDER | PU_AUTODESTROY);
305 if (!(object_is_aware(o_ptr)))
307 chg_virtue(creature_ptr, V_KNOWLEDGE, -1);
308 chg_virtue(creature_ptr, V_PATIENCE, -1);
309 chg_virtue(creature_ptr, V_CHANCE, 1);
312 /* We have tried it */
313 if (o_ptr->tval == TV_FOOD) object_tried(o_ptr);
315 /* The player is now aware of the object */
316 if (ident && !object_is_aware(o_ptr))
318 object_aware(creature_ptr, o_ptr);
319 gain_exp(creature_ptr, (lev + (creature_ptr->lev >> 1)) / creature_ptr->lev);
322 creature_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
324 /* Food can feed the player */
325 if (PRACE_IS_(creature_ptr, RACE_VAMPIRE) || (creature_ptr->mimic_form == MIMIC_VAMPIRE))
327 /* Reduced nutritional benefit */
328 (void)set_food(creature_ptr, creature_ptr->food + (o_ptr->pval / 10));
329 msg_print(_("あなたのような者にとって食糧など僅かな栄養にしかならない。",
330 "Mere victuals hold scant sustenance for a being such as yourself."));
332 if (creature_ptr->food < PY_FOOD_ALERT) /* Hungry */
333 msg_print(_("あなたの飢えは新鮮な血によってのみ満たされる!",
334 "Your hunger can only be satisfied with fresh blood!"));
336 else if ((PRACE_IS_(creature_ptr, RACE_SKELETON) ||
337 PRACE_IS_(creature_ptr, RACE_GOLEM) ||
338 PRACE_IS_(creature_ptr, RACE_ZOMBIE) ||
339 PRACE_IS_(creature_ptr, RACE_SPECTRE)) &&
340 (o_ptr->tval == TV_STAFF || o_ptr->tval == TV_WAND))
344 if (o_ptr->tval == TV_STAFF &&
345 (item < 0) && (o_ptr->number > 1))
347 creature_ptr->update |= inventory_flags;
348 msg_print(_("まずは杖を拾わなければ。", "You must first pick up the staffs."));
351 staff = (o_ptr->tval == TV_STAFF) ? _("杖", "staff") : _("魔法棒", "wand");
354 if (o_ptr->pval == 0)
356 msg_format(_("この%sにはもう魔力が残っていない。", "The %s has no charges left."), staff);
357 o_ptr->ident |= (IDENT_EMPTY);
358 creature_ptr->update |= inventory_flags;
359 creature_ptr->window |= (PW_INVEN);
363 msg_format(_("あなたは%sの魔力をエネルギー源として吸収した。", "You absorb mana of the %s as your energy."), staff);
365 /* Use a single charge */
369 set_food(creature_ptr, creature_ptr->food + 5000);
371 /* XXX Hack -- unstack if necessary */
372 if (o_ptr->tval == TV_STAFF &&
373 (item >= 0) && (o_ptr->number > 1))
378 object_copy(q_ptr, o_ptr);
380 /* Modify quantity */
383 /* Restore the charges */
386 /* Unstack the used item */
388 creature_ptr->total_weight -= q_ptr->weight;
389 item = inven_carry(creature_ptr, q_ptr);
391 msg_format(_("杖をまとめなおした。", "You unstack your staff."));
394 /* Describe charges in the pack */
397 inven_item_charges(creature_ptr, item);
400 /* Describe charges on the floor */
403 floor_item_charges(creature_ptr->current_floor_ptr, 0 - item);
406 creature_ptr->window |= (PW_INVEN | PW_EQUIP);
407 creature_ptr->update |= inventory_flags;
409 /* Don't eat a staff/wand itself */
413 if ((PRACE_IS_(creature_ptr, RACE_DEMON) ||
414 (mimic_info[creature_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)) &&
415 (o_ptr->tval == TV_CORPSE && o_ptr->sval == SV_CORPSE &&
416 my_strchr("pht", r_info[o_ptr->pval].d_char)))
418 /* Drain vitality of humanoids */
419 GAME_TEXT o_name[MAX_NLEN];
420 object_desc(creature_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
421 msg_format(_("%sは燃え上り灰になった。精力を吸収した気がする。", "%^s is burnt to ashes. You absorb its vitality!"), o_name);
422 (void)set_food(creature_ptr, PY_FOOD_MAX - 1);
424 else if (PRACE_IS_(creature_ptr, RACE_SKELETON))
426 if (!((o_ptr->sval == SV_FOOD_WAYBREAD) ||
427 (o_ptr->sval < SV_FOOD_BISCUIT)))
430 object_type *q_ptr = &forge;
432 msg_print(_("食べ物がアゴを素通りして落ちた!", "The food falls through your jaws!"));
433 object_prep(q_ptr, lookup_kind(o_ptr->tval, o_ptr->sval));
435 /* Drop the object from heaven */
436 (void)drop_near(creature_ptr, q_ptr, -1, creature_ptr->y, creature_ptr->x);
440 msg_print(_("食べ物がアゴを素通りして落ち、消えた!", "The food falls through your jaws and vanishes!"));
443 else if (PRACE_IS_(creature_ptr, RACE_GOLEM) ||
444 PRACE_IS_(creature_ptr, RACE_ZOMBIE) ||
445 PRACE_IS_(creature_ptr, RACE_ENT) ||
446 PRACE_IS_(creature_ptr, RACE_DEMON) ||
447 PRACE_IS_(creature_ptr, RACE_ANDROID) ||
448 PRACE_IS_(creature_ptr, RACE_SPECTRE) ||
449 (mimic_info[creature_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_NONLIVING))
451 msg_print(_("生者の食物はあなたにとってほとんど栄養にならない。", "The food of mortals is poor sustenance for you."));
452 set_food(creature_ptr, creature_ptr->food + ((o_ptr->pval) / 20));
454 else if (o_ptr->tval == TV_FOOD && o_ptr->sval == SV_FOOD_WAYBREAD)
456 /* Waybread is always fully satisfying. */
457 set_food(creature_ptr, MAX(creature_ptr->food, PY_FOOD_MAX - 1));
461 /* Food can feed the player */
462 (void)set_food(creature_ptr, creature_ptr->food + o_ptr->pval);
465 creature_ptr->update |= inventory_flags;
466 vary_item(creature_ptr, item, -1);
471 * @brief 食料を食べるコマンドのメインルーチン /
472 * Eat some food (from the pack or floor)
475 void do_cmd_eat_food(player_type *creature_ptr)
480 if (creature_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
482 set_action(creature_ptr, ACTION_NONE);
485 item_tester_hook = item_tester_hook_eatable;
487 q = _("どれを食べますか? ", "Eat which item? ");
488 s = _("食べ物がない。", "You have nothing to eat.");
490 if (!choose_object(creature_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), 0)) return;
492 exe_eat_food(creature_ptr, item);