3 * @brief プレイヤーの読むコマンド実装
12 #include "object-flavor.h"
13 #include "object-hook.h"
16 #include "player-status.h"
17 #include "player-damage.h"
18 #include "player-class.h"
19 #include "player-effects.h"
21 #include "realm-hex.h"
24 #include "spells-object.h"
25 #include "spells-floor.h"
26 #include "spells-summon.h"
27 #include "spells-status.h"
29 #include "cmd-basic.h"
32 #include "objectkind.h"
33 #include "realm-song.h"
34 #include "view-mainwindow.h"
37 * @brief 巻物を読むコマンドのサブルーチン
38 * Read a scroll (from the pack or floor).
39 * @param item 読むオブジェクトの所持品ID
40 * @param known 判明済ならばTRUE
44 * Certain scrolls can be "aborted" without losing the scroll. These
45 * include scrolls with no effects but recharge or identify, which are
46 * cancelled before use. XXX Reading them still takes a current_world_ptr->game_turn, though.
49 void exe_read(INVENTORY_IDX item, bool known)
51 int k, used_up, ident, lev;
55 /* Get the item (in the pack) */
58 o_ptr = &p_ptr->inventory_list[item];
61 /* Get the item (on the floor) */
64 o_ptr = ¤t_floor_ptr->o_list[0 - item];
67 take_turn(p_ptr, 100);
68 if (cmd_limit_time_walk(p_ptr)) return;
70 if (p_ptr->pclass == CLASS_BERSERKER)
72 msg_print(_("巻物なんて読めない。", "You cannot read."));
76 if (music_singing_any()) stop_singing(p_ptr);
79 if (hex_spelling_any() && ((p_ptr->lev < 35) || hex_spell_fully())) stop_hex_spell_all();
81 /* Not identified yet */
85 lev = k_info[o_ptr->k_idx].level;
87 /* Assume the scroll will get used up */
90 if (o_ptr->tval == TV_SCROLL)
92 /* Analyze the scroll */
95 case SV_SCROLL_DARKNESS:
97 if (!(p_ptr->resist_blind) && !(p_ptr->resist_dark))
99 (void)set_blind(p_ptr, p_ptr->blind + 3 + randint1(5));
101 if (unlite_area(10, 3)) ident = TRUE;
105 case SV_SCROLL_AGGRAVATE_MONSTER:
107 msg_print(_("カン高くうなる様な音が辺りを覆った。", "There is a high pitched humming noise."));
108 aggravate_monsters(0);
113 case SV_SCROLL_CURSE_ARMOR:
115 if (curse_armor()) ident = TRUE;
119 case SV_SCROLL_CURSE_WEAPON:
122 if (has_melee_weapon(INVEN_RARM))
125 if (has_melee_weapon(INVEN_LARM) && one_in_(2)) k = INVEN_LARM;
127 else if (has_melee_weapon(INVEN_LARM)) k = INVEN_LARM;
128 if (k && curse_weapon(FALSE, k)) ident = TRUE;
132 case SV_SCROLL_SUMMON_MONSTER:
134 for (k = 0; k < randint1(3); k++)
136 if (summon_specific(0, p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
144 case SV_SCROLL_SUMMON_UNDEAD:
146 for (k = 0; k < randint1(3); k++)
148 if (summon_specific(0, p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, SUMMON_UNDEAD, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
156 case SV_SCROLL_SUMMON_PET:
158 if (summon_specific(-1, p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, 0, (PM_ALLOW_GROUP | PM_FORCE_PET)))
165 case SV_SCROLL_SUMMON_KIN:
167 if (summon_kin_player(p_ptr->lev, p_ptr->y, p_ptr->x, (PM_FORCE_PET | PM_ALLOW_GROUP)))
174 case SV_SCROLL_TRAP_CREATION:
176 if (trap_creation(p_ptr->y, p_ptr->x)) ident = TRUE;
180 case SV_SCROLL_PHASE_DOOR:
182 teleport_player(10, 0L);
187 case SV_SCROLL_TELEPORT:
189 teleport_player(100, 0L);
194 case SV_SCROLL_TELEPORT_LEVEL:
196 (void)teleport_level(0);
201 case SV_SCROLL_WORD_OF_RECALL:
203 if (!recall_player(p_ptr, randint0(21) + 15)) used_up = FALSE;
208 case SV_SCROLL_IDENTIFY:
210 if (!ident_spell(FALSE)) used_up = FALSE;
215 case SV_SCROLL_STAR_IDENTIFY:
217 if (!identify_fully(FALSE)) used_up = FALSE;
222 case SV_SCROLL_REMOVE_CURSE:
231 case SV_SCROLL_STAR_REMOVE_CURSE:
233 if (remove_all_curse())
240 case SV_SCROLL_ENCHANT_ARMOR:
243 if (!enchant_spell(0, 0, 1)) used_up = FALSE;
247 case SV_SCROLL_ENCHANT_WEAPON_TO_HIT:
249 if (!enchant_spell(1, 0, 0)) used_up = FALSE;
254 case SV_SCROLL_ENCHANT_WEAPON_TO_DAM:
256 if (!enchant_spell(0, 1, 0)) used_up = FALSE;
261 case SV_SCROLL_STAR_ENCHANT_ARMOR:
263 if (!enchant_spell(0, 0, randint1(3) + 2)) used_up = FALSE;
268 case SV_SCROLL_STAR_ENCHANT_WEAPON:
270 if (!enchant_spell(randint1(3), randint1(3), 0)) used_up = FALSE;
275 case SV_SCROLL_RECHARGING:
277 if (!recharge(130)) used_up = FALSE;
282 case SV_SCROLL_MUNDANITY:
285 if (!mundane_spell(FALSE)) used_up = FALSE;
289 case SV_SCROLL_LIGHT:
291 if (lite_area(damroll(2, 8), 2)) ident = TRUE;
295 case SV_SCROLL_MAPPING:
297 map_area(DETECT_RAD_MAP);
302 case SV_SCROLL_DETECT_GOLD:
304 if (detect_treasure(DETECT_RAD_DEFAULT)) ident = TRUE;
305 if (detect_objects_gold(DETECT_RAD_DEFAULT)) ident = TRUE;
309 case SV_SCROLL_DETECT_ITEM:
311 if (detect_objects_normal(DETECT_RAD_DEFAULT)) ident = TRUE;
315 case SV_SCROLL_DETECT_TRAP:
317 if (detect_traps(DETECT_RAD_DEFAULT, known)) ident = TRUE;
321 case SV_SCROLL_DETECT_DOOR:
323 if (detect_doors(DETECT_RAD_DEFAULT)) ident = TRUE;
324 if (detect_stairs(DETECT_RAD_DEFAULT)) ident = TRUE;
328 case SV_SCROLL_DETECT_INVIS:
330 if (detect_monsters_invis(DETECT_RAD_DEFAULT)) ident = TRUE;
334 case SV_SCROLL_SATISFY_HUNGER:
336 if (set_food(p_ptr, PY_FOOD_MAX - 1)) ident = TRUE;
340 case SV_SCROLL_BLESSING:
342 if (set_blessed(p_ptr, p_ptr->blessed + randint1(12) + 6, FALSE)) ident = TRUE;
346 case SV_SCROLL_HOLY_CHANT:
348 if (set_blessed(p_ptr, p_ptr->blessed + randint1(24) + 12, FALSE)) ident = TRUE;
352 case SV_SCROLL_HOLY_PRAYER:
354 if (set_blessed(p_ptr, p_ptr->blessed + randint1(48) + 24, FALSE)) ident = TRUE;
358 case SV_SCROLL_MONSTER_CONFUSION:
360 if (!(p_ptr->special_attack & ATTACK_CONFUSE))
362 msg_print(_("手が輝き始めた。", "Your hands begin to glow."));
363 p_ptr->special_attack |= ATTACK_CONFUSE;
364 p_ptr->redraw |= (PR_STATUS);
370 case SV_SCROLL_PROTECTION_FROM_EVIL:
373 if (set_protevil(p_ptr, p_ptr->protevil + randint1(25) + k, FALSE)) ident = TRUE;
377 case SV_SCROLL_RUNE_OF_PROTECTION:
384 case SV_SCROLL_TRAP_DOOR_DESTRUCTION:
386 if (destroy_doors_touch()) ident = TRUE;
390 case SV_SCROLL_STAR_DESTRUCTION:
392 if (destroy_area(p_ptr->y, p_ptr->x, 13 + randint0(5), FALSE))
395 msg_print(_("ダンジョンが揺れた...", "The dungeon trembles..."));
400 case SV_SCROLL_DISPEL_UNDEAD:
402 if (dispel_undead(80)) ident = TRUE;
406 case SV_SCROLL_SPELL:
408 if ((p_ptr->pclass == CLASS_WARRIOR) ||
409 (p_ptr->pclass == CLASS_IMITATOR) ||
410 (p_ptr->pclass == CLASS_MINDCRAFTER) ||
411 (p_ptr->pclass == CLASS_SORCERER) ||
412 (p_ptr->pclass == CLASS_ARCHER) ||
413 (p_ptr->pclass == CLASS_MAGIC_EATER) ||
414 (p_ptr->pclass == CLASS_RED_MAGE) ||
415 (p_ptr->pclass == CLASS_SAMURAI) ||
416 (p_ptr->pclass == CLASS_BLUE_MAGE) ||
417 (p_ptr->pclass == CLASS_CAVALRY) ||
418 (p_ptr->pclass == CLASS_BERSERKER) ||
419 (p_ptr->pclass == CLASS_SMITH) ||
420 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
421 (p_ptr->pclass == CLASS_NINJA) ||
422 (p_ptr->pclass == CLASS_SNIPER)) break;
424 p_ptr->update |= (PU_SPELLS);
429 case SV_SCROLL_GENOCIDE:
431 (void)symbol_genocide(300, TRUE);
436 case SV_SCROLL_MASS_GENOCIDE:
438 (void)mass_genocide(300, TRUE);
443 case SV_SCROLL_ACQUIREMENT:
445 acquirement(p_ptr->y, p_ptr->x, 1, TRUE, FALSE, FALSE);
450 case SV_SCROLL_STAR_ACQUIREMENT:
452 acquirement(p_ptr->y, p_ptr->x, randint1(2) + 1, TRUE, FALSE, FALSE);
457 /* New Hengband scrolls */
460 fire_ball(GF_FIRE, 0, 666, 4);
461 /* Note: "Double" damage since it is centered on the player ... */
462 if (!(IS_OPPOSE_FIRE() || p_ptr->resist_fire || p_ptr->immune_fire))
463 take_hit(DAMAGE_NOESCAPE, 50+randint1(50), _("炎の巻物", "a Scroll of Fire"), -1);
472 fire_ball(GF_ICE, 0, 777, 4);
473 if (!(IS_OPPOSE_COLD() || p_ptr->resist_cold || p_ptr->immune_cold))
474 take_hit(DAMAGE_NOESCAPE, 100+randint1(100), _("氷の巻物", "a Scroll of Ice"), -1);
480 case SV_SCROLL_CHAOS:
482 fire_ball(GF_CHAOS, 0, 1000, 4);
483 if (!p_ptr->resist_chaos)
484 take_hit(DAMAGE_NOESCAPE, 111+randint1(111), _("ログルスの巻物", "a Scroll of Logrus"), -1);
490 case SV_SCROLL_RUMOR:
492 msg_print(_("巻物にはメッセージが書かれている:", "There is message on the scroll. It says:"));
496 msg_print(_("巻物は煙を立てて消え去った!", "The scroll disappears in a puff of smoke!"));
502 case SV_SCROLL_ARTIFACT:
505 if (!artifact_scroll()) used_up = FALSE;
509 case SV_SCROLL_RESET_RECALL:
512 if (!reset_recall()) used_up = FALSE;
516 case SV_SCROLL_AMUSEMENT:
519 amusement(p_ptr->y, p_ptr->x, 1, FALSE);
523 case SV_SCROLL_STAR_AMUSEMENT:
526 amusement(p_ptr->y, p_ptr->x, randint1(2) + 1, FALSE);
531 else if (o_ptr->name1 == ART_GHB)
533 msg_print(_("私は苦労して『グレーター・ヘル=ビースト』を倒した。", "I had a very hard time to kill the Greater hell-beast, "));
534 msg_print(_("しかし手に入ったのはこのきたないTシャツだけだった。", "but all I got was this lousy t-shirt!"));
537 else if (o_ptr->name1 == ART_POWER)
539 msg_print(_("「一つの指輪は全てを統べ、", "'One Ring to rule them all, "));
541 msg_print(_("一つの指輪は全てを見つけ、", "One Ring to find them, "));
543 msg_print(_("一つの指輪は全てを捕らえて", "One Ring to bring them all "));
545 msg_print(_("暗闇の中に繋ぎとめる。」", "and in the darkness bind them.'"));
548 else if (o_ptr->tval==TV_PARCHMENT)
551 GAME_TEXT o_name[MAX_NLEN];
555 q=format("book-%d_jp.txt",o_ptr->sval);
557 /* Display object description */
558 object_desc(o_name, o_ptr, OD_NAME_ONLY);
559 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, q);
561 /* Peruse the help file */
562 (void)show_file(TRUE, buf, o_name, 0, 0);
568 p_ptr->update |= (PU_COMBINE | PU_REORDER);
570 if (!(object_is_aware(o_ptr)))
572 chg_virtue(V_PATIENCE, -1);
573 chg_virtue(V_CHANCE, 1);
574 chg_virtue(V_KNOWLEDGE, -1);
577 /* The item was tried */
580 /* An identification was made */
581 if (ident && !object_is_aware(o_ptr))
584 gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev);
587 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
590 /* Hack -- allow certain scrolls to be "preserved" */
598 /* Destroy a scroll in the pack */
601 inven_item_increase(item, -1);
602 inven_item_describe(item);
603 inven_item_optimize(item);
606 /* Destroy a scroll on the floor */
609 floor_item_increase(0 - item, -1);
610 floor_item_describe(0 - item);
611 floor_item_optimize(0 - item);
616 * @brief 読むコマンドのメインルーチン /
617 * Eat some food (from the pack or floor)
620 void do_cmd_read_scroll(void)
626 if (p_ptr->wild_mode)
631 if (cmd_limit_arena(p_ptr)) return;
633 if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
635 set_action(ACTION_NONE);
638 if (cmd_limit_blind(p_ptr)) return;
639 if (cmd_limit_confused(p_ptr)) return;
641 /* Restrict choices to scrolls */
642 item_tester_hook = item_tester_hook_readable;
644 q = _("どの巻物を読みますか? ", "Read which scroll? ");
645 s = _("読める巻物がない。", "You have no scrolls to read.");
647 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR), 0);
650 /* Read the scroll */
651 exe_read(item, object_is_aware(o_ptr));