3 * @brief プレイヤーの読むコマンド実装
12 #include "object-flavor.h"
13 #include "object-hook.h"
16 #include "player-status.h"
17 #include "player-effects.h"
19 #include "realm-hex.h"
22 #include "spells-object.h"
23 #include "spells-floor.h"
24 #include "spells-summon.h"
25 #include "spells-status.h"
27 #include "cmd-basic.h"
30 #include "objectkind.h"
33 * @brief 巻物を読むコマンドのサブルーチン
34 * Read a scroll (from the pack or floor).
35 * @param item 読むオブジェクトの所持品ID
36 * @param known 判明済ならばTRUE
40 * Certain scrolls can be "aborted" without losing the scroll. These
41 * include scrolls with no effects but recharge or identify, which are
42 * cancelled before use. XXX Reading them still takes a current_world_ptr->game_turn, though.
45 void do_cmd_read_scroll_aux(INVENTORY_IDX item, bool known)
47 int k, used_up, ident, lev;
51 /* Get the item (in the pack) */
54 o_ptr = &p_ptr->inventory_list[item];
57 /* Get the item (on the floor) */
60 o_ptr = ¤t_floor_ptr->o_list[0 - item];
63 take_turn(p_ptr, 100);
64 if (cmd_limit_time_walk(p_ptr)) return;
66 if (p_ptr->pclass == CLASS_BERSERKER)
68 msg_print(_("巻物なんて読めない。", "You cannot read."));
72 if (music_singing_any()) stop_singing(p_ptr);
75 if (hex_spelling_any() && ((p_ptr->lev < 35) || hex_spell_fully())) stop_hex_spell_all();
77 /* Not identified yet */
81 lev = k_info[o_ptr->k_idx].level;
83 /* Assume the scroll will get used up */
86 if (o_ptr->tval == TV_SCROLL)
88 /* Analyze the scroll */
91 case SV_SCROLL_DARKNESS:
93 if (!(p_ptr->resist_blind) && !(p_ptr->resist_dark))
95 (void)set_blind(p_ptr->blind + 3 + randint1(5));
97 if (unlite_area(10, 3)) ident = TRUE;
101 case SV_SCROLL_AGGRAVATE_MONSTER:
103 msg_print(_("カン高くうなる様な音が辺りを覆った。", "There is a high pitched humming noise."));
104 aggravate_monsters(0);
109 case SV_SCROLL_CURSE_ARMOR:
111 if (curse_armor()) ident = TRUE;
115 case SV_SCROLL_CURSE_WEAPON:
118 if (has_melee_weapon(INVEN_RARM))
121 if (has_melee_weapon(INVEN_LARM) && one_in_(2)) k = INVEN_LARM;
123 else if (has_melee_weapon(INVEN_LARM)) k = INVEN_LARM;
124 if (k && curse_weapon(FALSE, k)) ident = TRUE;
128 case SV_SCROLL_SUMMON_MONSTER:
130 for (k = 0; k < randint1(3); k++)
132 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), '\0'))
140 case SV_SCROLL_SUMMON_UNDEAD:
142 for (k = 0; k < randint1(3); k++)
144 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), '\0'))
152 case SV_SCROLL_SUMMON_PET:
154 if (summon_specific(-1, p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, 0, (PM_ALLOW_GROUP | PM_FORCE_PET), '\0'))
161 case SV_SCROLL_SUMMON_KIN:
163 if (summon_kin_player(p_ptr->lev, p_ptr->y, p_ptr->x, (PM_FORCE_PET | PM_ALLOW_GROUP)))
170 case SV_SCROLL_TRAP_CREATION:
172 if (trap_creation(p_ptr->y, p_ptr->x)) ident = TRUE;
176 case SV_SCROLL_PHASE_DOOR:
178 teleport_player(10, 0L);
183 case SV_SCROLL_TELEPORT:
185 teleport_player(100, 0L);
190 case SV_SCROLL_TELEPORT_LEVEL:
192 (void)teleport_level(0);
197 case SV_SCROLL_WORD_OF_RECALL:
199 if (!recall_player(p_ptr, randint0(21) + 15)) used_up = FALSE;
204 case SV_SCROLL_IDENTIFY:
206 if (!ident_spell(FALSE)) used_up = FALSE;
211 case SV_SCROLL_STAR_IDENTIFY:
213 if (!identify_fully(FALSE)) used_up = FALSE;
218 case SV_SCROLL_REMOVE_CURSE:
227 case SV_SCROLL_STAR_REMOVE_CURSE:
229 if (remove_all_curse())
236 case SV_SCROLL_ENCHANT_ARMOR:
239 if (!enchant_spell(0, 0, 1)) used_up = FALSE;
243 case SV_SCROLL_ENCHANT_WEAPON_TO_HIT:
245 if (!enchant_spell(1, 0, 0)) used_up = FALSE;
250 case SV_SCROLL_ENCHANT_WEAPON_TO_DAM:
252 if (!enchant_spell(0, 1, 0)) used_up = FALSE;
257 case SV_SCROLL_STAR_ENCHANT_ARMOR:
259 if (!enchant_spell(0, 0, randint1(3) + 2)) used_up = FALSE;
264 case SV_SCROLL_STAR_ENCHANT_WEAPON:
266 if (!enchant_spell(randint1(3), randint1(3), 0)) used_up = FALSE;
271 case SV_SCROLL_RECHARGING:
273 if (!recharge(130)) used_up = FALSE;
278 case SV_SCROLL_MUNDANITY:
281 if (!mundane_spell(FALSE)) used_up = FALSE;
285 case SV_SCROLL_LIGHT:
287 if (lite_area(damroll(2, 8), 2)) ident = TRUE;
291 case SV_SCROLL_MAPPING:
293 map_area(DETECT_RAD_MAP);
298 case SV_SCROLL_DETECT_GOLD:
300 if (detect_treasure(DETECT_RAD_DEFAULT)) ident = TRUE;
301 if (detect_objects_gold(DETECT_RAD_DEFAULT)) ident = TRUE;
305 case SV_SCROLL_DETECT_ITEM:
307 if (detect_objects_normal(DETECT_RAD_DEFAULT)) ident = TRUE;
311 case SV_SCROLL_DETECT_TRAP:
313 if (detect_traps(DETECT_RAD_DEFAULT, known)) ident = TRUE;
317 case SV_SCROLL_DETECT_DOOR:
319 if (detect_doors(DETECT_RAD_DEFAULT)) ident = TRUE;
320 if (detect_stairs(DETECT_RAD_DEFAULT)) ident = TRUE;
324 case SV_SCROLL_DETECT_INVIS:
326 if (detect_monsters_invis(DETECT_RAD_DEFAULT)) ident = TRUE;
330 case SV_SCROLL_SATISFY_HUNGER:
332 if (set_food(PY_FOOD_MAX - 1)) ident = TRUE;
336 case SV_SCROLL_BLESSING:
338 if (set_blessed(p_ptr->blessed + randint1(12) + 6, FALSE)) ident = TRUE;
342 case SV_SCROLL_HOLY_CHANT:
344 if (set_blessed(p_ptr->blessed + randint1(24) + 12, FALSE)) ident = TRUE;
348 case SV_SCROLL_HOLY_PRAYER:
350 if (set_blessed(p_ptr->blessed + randint1(48) + 24, FALSE)) ident = TRUE;
354 case SV_SCROLL_MONSTER_CONFUSION:
356 if (!(p_ptr->special_attack & ATTACK_CONFUSE))
358 msg_print(_("手が輝き始めた。", "Your hands begin to glow."));
359 p_ptr->special_attack |= ATTACK_CONFUSE;
360 p_ptr->redraw |= (PR_STATUS);
366 case SV_SCROLL_PROTECTION_FROM_EVIL:
369 if (set_protevil(p_ptr->protevil + randint1(25) + k, FALSE)) ident = TRUE;
373 case SV_SCROLL_RUNE_OF_PROTECTION:
380 case SV_SCROLL_TRAP_DOOR_DESTRUCTION:
382 if (destroy_doors_touch()) ident = TRUE;
386 case SV_SCROLL_STAR_DESTRUCTION:
388 if (destroy_area(p_ptr->y, p_ptr->x, 13 + randint0(5), FALSE))
391 msg_print(_("ダンジョンが揺れた...", "The dungeon trembles..."));
396 case SV_SCROLL_DISPEL_UNDEAD:
398 if (dispel_undead(80)) ident = TRUE;
402 case SV_SCROLL_SPELL:
404 if ((p_ptr->pclass == CLASS_WARRIOR) ||
405 (p_ptr->pclass == CLASS_IMITATOR) ||
406 (p_ptr->pclass == CLASS_MINDCRAFTER) ||
407 (p_ptr->pclass == CLASS_SORCERER) ||
408 (p_ptr->pclass == CLASS_ARCHER) ||
409 (p_ptr->pclass == CLASS_MAGIC_EATER) ||
410 (p_ptr->pclass == CLASS_RED_MAGE) ||
411 (p_ptr->pclass == CLASS_SAMURAI) ||
412 (p_ptr->pclass == CLASS_BLUE_MAGE) ||
413 (p_ptr->pclass == CLASS_CAVALRY) ||
414 (p_ptr->pclass == CLASS_BERSERKER) ||
415 (p_ptr->pclass == CLASS_SMITH) ||
416 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
417 (p_ptr->pclass == CLASS_NINJA) ||
418 (p_ptr->pclass == CLASS_SNIPER)) break;
420 p_ptr->update |= (PU_SPELLS);
425 case SV_SCROLL_GENOCIDE:
427 (void)symbol_genocide(300, TRUE);
432 case SV_SCROLL_MASS_GENOCIDE:
434 (void)mass_genocide(300, TRUE);
439 case SV_SCROLL_ACQUIREMENT:
441 acquirement(p_ptr->y, p_ptr->x, 1, TRUE, FALSE, FALSE);
446 case SV_SCROLL_STAR_ACQUIREMENT:
448 acquirement(p_ptr->y, p_ptr->x, randint1(2) + 1, TRUE, FALSE, FALSE);
453 /* New Hengband scrolls */
456 fire_ball(GF_FIRE, 0, 666, 4);
457 /* Note: "Double" damage since it is centered on the player ... */
458 if (!(IS_OPPOSE_FIRE() || p_ptr->resist_fire || p_ptr->immune_fire))
459 take_hit(DAMAGE_NOESCAPE, 50+randint1(50), _("炎の巻物", "a Scroll of Fire"), -1);
468 fire_ball(GF_ICE, 0, 777, 4);
469 if (!(IS_OPPOSE_COLD() || p_ptr->resist_cold || p_ptr->immune_cold))
470 take_hit(DAMAGE_NOESCAPE, 100+randint1(100), _("氷の巻物", "a Scroll of Ice"), -1);
476 case SV_SCROLL_CHAOS:
478 fire_ball(GF_CHAOS, 0, 1000, 4);
479 if (!p_ptr->resist_chaos)
480 take_hit(DAMAGE_NOESCAPE, 111+randint1(111), _("ログルスの巻物", "a Scroll of Logrus"), -1);
486 case SV_SCROLL_RUMOR:
488 msg_print(_("巻物にはメッセージが書かれている:", "There is message on the scroll. It says:"));
492 msg_print(_("巻物は煙を立てて消え去った!", "The scroll disappears in a puff of smoke!"));
498 case SV_SCROLL_ARTIFACT:
501 if (!artifact_scroll()) used_up = FALSE;
505 case SV_SCROLL_RESET_RECALL:
508 if (!reset_recall()) used_up = FALSE;
512 case SV_SCROLL_AMUSEMENT:
515 amusement(p_ptr->y, p_ptr->x, 1, FALSE);
519 case SV_SCROLL_STAR_AMUSEMENT:
522 amusement(p_ptr->y, p_ptr->x, randint1(2) + 1, FALSE);
527 else if (o_ptr->name1 == ART_GHB)
529 msg_print(_("私は苦労して『グレーター・ヘル=ビースト』を倒した。", "I had a very hard time to kill the Greater hell-beast, "));
530 msg_print(_("しかし手に入ったのはこのきたないTシャツだけだった。", "but all I got was this lousy t-shirt!"));
533 else if (o_ptr->name1 == ART_POWER)
535 msg_print(_("「一つの指輪は全てを統べ、", "'One Ring to rule them all, "));
537 msg_print(_("一つの指輪は全てを見つけ、", "One Ring to find them, "));
539 msg_print(_("一つの指輪は全てを捕らえて", "One Ring to bring them all "));
541 msg_print(_("暗闇の中に繋ぎとめる。」", "and in the darkness bind them.'"));
544 else if (o_ptr->tval==TV_PARCHMENT)
547 GAME_TEXT o_name[MAX_NLEN];
551 q=format("book-%d_jp.txt",o_ptr->sval);
553 /* Display object description */
554 object_desc(o_name, o_ptr, OD_NAME_ONLY);
556 /* Build the filename */
557 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, q);
559 /* Peruse the help file */
560 (void)show_file(TRUE, buf, o_name, 0, 0);
566 p_ptr->update |= (PU_COMBINE | PU_REORDER);
568 if (!(object_is_aware(o_ptr)))
570 chg_virtue(V_PATIENCE, -1);
571 chg_virtue(V_CHANCE, 1);
572 chg_virtue(V_KNOWLEDGE, -1);
575 /* The item was tried */
578 /* An identification was made */
579 if (ident && !object_is_aware(o_ptr))
582 gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev);
585 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
588 /* Hack -- allow certain scrolls to be "preserved" */
596 /* Destroy a scroll in the pack */
599 inven_item_increase(item, -1);
600 inven_item_describe(item);
601 inven_item_optimize(item);
604 /* Destroy a scroll on the floor */
607 floor_item_increase(0 - item, -1);
608 floor_item_describe(0 - item);
609 floor_item_optimize(0 - item);
614 * @brief 読むコマンドのメインルーチン /
615 * Eat some food (from the pack or floor)
618 void do_cmd_read_scroll(void)
624 if (p_ptr->wild_mode)
629 if (cmd_limit_arena(p_ptr)) return;
631 if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
633 set_action(ACTION_NONE);
636 if (cmd_limit_blind(p_ptr)) return;
637 if (cmd_limit_confused(p_ptr)) return;
639 /* Restrict choices to scrolls */
640 item_tester_hook = item_tester_hook_readable;
642 q = _("どの巻物を読みますか? ", "Read which scroll? ");
643 s = _("読める巻物がない。", "You have no scrolls to read.");
645 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
648 /* Read the scroll */
649 do_cmd_read_scroll_aux(item, object_is_aware(o_ptr));