3 * @brief プレイヤーのアイテムに関するコマンドの実装2 / Spell/Prayer commands
7 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
8 * This software may be copied and distributed for educational, research,
9 * and not for profit purposes provided that this copyright and statement
10 * are included in all such copies. Other copyrights may also apply.
11 * 2014 Deskull rearranged comment for Doxygen.\n
15 * This file includes code for eating food, drinking potions,
16 * reading scrolls, aiming wands, using staffs, zapping rods,
17 * and activating artifacts.
19 * In all cases, if the player becomes "aware" of the item's use
20 * by testing it, mark it as "aware" and reward some experience
21 * based on the object's level, always rounding up. If the player
22 * remains "unaware", mark that object "kind" as "tried".
24 * This code now correctly handles the unstacking of wands, staffs,
25 * and rods. Note the overly paranoid warning about potential pack
26 * overflow, which allows the player to use and drop a stacked item.
28 * In all "unstacking" scenarios, the "used" object is "carried" as if
29 * the player had just picked it up. In particular, this means that if
30 * the use of an item induces pack overflow, that item will be dropped.
32 * For simplicity, these routines induce a full "pack reorganization"
33 * which not only combines similar items, but also reorganizes various
34 * items to obey the current "sorting" method. This may require about
35 * 400 item comparisons, but only occasionally.
37 * There may be a BIG problem with any "effect" that can cause "changes"
38 * to the inventory. For example, a "scroll of recharging" can cause
39 * a wand/staff to "disappear", moving the inventory up. Luckily, the
40 * scrolls all appear BEFORE the staffs/wands, so this is not a problem.
41 * But, for example, a "staff of recharging" could cause MAJOR problems.
42 * In such a case, it will be best to either (1) "postpone" the effect
43 * until the end of the function, or (2) "change" the effect, say, into
44 * giving a staff "negative" charges, or "turning a staff into a stick".
45 * It seems as though a "rod of recharging" might in fact cause problems.
46 * The basic problem is that the act of recharging (and destroying) an
47 * item causes the inducer of that action to "move", causing "o_ptr" to
48 * no longer point at the correct item, with horrifying results.
50 * Note that food/potions/scrolls no longer use bit-flags for effects,
51 * but instead use the "sval" (which is also used to sort the objects).
57 #include "cmd-activate.h"
59 #include "cmd-quaff.h"
61 #include "cmd-usestaff.h"
62 #include "cmd-zapwand.h"
68 * @param sval オブジェクトのsval
69 * @param dir 発動目標の方向ID
70 * @param use_charge チャージを消費したかどうかを返す参照ポインタ
71 * @param powerful 強力発動上の処理ならばTRUE
72 * @param magic 魔道具術上の処理ならばTRUE
73 * @return 発動により効果内容が確定したならばTRUEを返す
75 static int rod_effect(OBJECT_SUBTYPE_VALUE sval, int dir, bool *use_charge, bool powerful, bool magic)
78 int lev = powerful ? p_ptr->lev * 2 : p_ptr->lev;
79 int detect_rad = powerful ? DETECT_RAD_DEFAULT * 3 / 2 : DETECT_RAD_DEFAULT;
80 int rad = powerful ? 3 : 2;
88 case SV_ROD_DETECT_TRAP:
90 if (detect_traps(detect_rad, (bool)(dir ? FALSE : TRUE))) ident = TRUE;
94 case SV_ROD_DETECT_DOOR:
96 if (detect_doors(detect_rad)) ident = TRUE;
97 if (detect_stairs(detect_rad)) ident = TRUE;
101 case SV_ROD_IDENTIFY:
104 if (!identify_fully(FALSE)) *use_charge = FALSE;
106 if (!ident_spell(FALSE)) *use_charge = FALSE;
114 if (!word_of_recall()) *use_charge = FALSE;
119 case SV_ROD_ILLUMINATION:
121 if (lite_area(damroll(2, 8), (powerful ? 4 : 2))) ident = TRUE;
127 map_area(powerful ? DETECT_RAD_MAP * 3 / 2 : DETECT_RAD_MAP);
132 case SV_ROD_DETECTION:
134 detect_all(detect_rad);
148 if (set_blind(0)) ident = TRUE;
149 if (set_poisoned(0)) ident = TRUE;
150 if (set_confused(0)) ident = TRUE;
151 if (set_stun(0)) ident = TRUE;
152 if (set_cut(0)) ident = TRUE;
153 if (set_image(0)) ident = TRUE;
154 if (set_shero(0,TRUE)) ident = TRUE;
160 if (hp_player(powerful ? 750 : 500)) ident = TRUE;
161 if (set_stun(0)) ident = TRUE;
162 if (set_cut(0)) ident = TRUE;
163 if (set_shero(0,TRUE)) ident = TRUE;
167 case SV_ROD_RESTORATION:
169 if (restore_level()) ident = TRUE;
170 if (do_res_stat(A_STR)) ident = TRUE;
171 if (do_res_stat(A_INT)) ident = TRUE;
172 if (do_res_stat(A_WIS)) ident = TRUE;
173 if (do_res_stat(A_DEX)) ident = TRUE;
174 if (do_res_stat(A_CON)) ident = TRUE;
175 if (do_res_stat(A_CHR)) ident = TRUE;
181 if (set_fast(randint1(30) + (powerful ? 30 : 15), FALSE)) ident = TRUE;
185 case SV_ROD_PESTICIDE:
187 if (dispel_monsters(powerful ? 8 : 4)) ident = TRUE;
191 case SV_ROD_TELEPORT_AWAY:
193 int distance = MAX_SIGHT * (powerful ? 8 : 5);
194 if (teleport_monster(dir, distance)) ident = TRUE;
198 case SV_ROD_DISARMING:
200 if (disarm_trap(dir)) ident = TRUE;
201 if (powerful && disarm_traps_touch()) ident = TRUE;
207 HIT_POINT dam = damroll((powerful ? 12 : 6), 8);
208 msg_print(_("青く輝く光線が放たれた。", "A line of blue shimmering light appears."));
209 (void)lite_line(dir, dam);
214 case SV_ROD_SLEEP_MONSTER:
216 if (sleep_monster(dir, lev)) ident = TRUE;
220 case SV_ROD_SLOW_MONSTER:
222 if (slow_monster(dir, lev)) ident = TRUE;
226 case SV_ROD_HYPODYNAMIA:
228 if (hypodynamic_bolt(dir, 70 + 3 * lev / 2)) ident = TRUE;
232 case SV_ROD_POLYMORPH:
234 if (poly_monster(dir, lev)) ident = TRUE;
238 case SV_ROD_ACID_BOLT:
240 fire_bolt_or_beam(10, GF_ACID, dir, damroll(6 + lev / 7, 8));
245 case SV_ROD_ELEC_BOLT:
247 fire_bolt_or_beam(10, GF_ELEC, dir, damroll(4 + lev / 9, 8));
252 case SV_ROD_FIRE_BOLT:
254 fire_bolt_or_beam(10, GF_FIRE, dir, damroll(7 + lev / 6, 8));
259 case SV_ROD_COLD_BOLT:
261 fire_bolt_or_beam(10, GF_COLD, dir, damroll(5 + lev / 8, 8));
266 case SV_ROD_ACID_BALL:
268 fire_ball(GF_ACID, dir, 60 + lev, rad);
273 case SV_ROD_ELEC_BALL:
275 fire_ball(GF_ELEC, dir, 40 + lev, rad);
280 case SV_ROD_FIRE_BALL:
282 fire_ball(GF_FIRE, dir, 70 + lev, rad);
287 case SV_ROD_COLD_BALL:
289 fire_ball(GF_COLD, dir, 50 + lev, rad);
301 case SV_ROD_STONE_TO_MUD:
303 HIT_POINT dam = powerful ? 40 + randint1(60) : 20 + randint1(30);
304 if (wall_to_mud(dir, dam)) ident = TRUE;
308 case SV_ROD_AGGRAVATE:
310 aggravate_monsters(0);
319 * @brief 魔法棒を使うコマンドのサブルーチン /
320 * Activate (zap) a Rod
321 * @param item 使うオブジェクトの所持品ID
325 * Unstack fully charged rods as needed.
326 * Hack -- rods of perception/genocide can be "cancelled"
327 * All rods can be cancelled at the "Direction?" prompt
328 * pvals are defined for each rod in k_info. -LM-
331 static void do_cmd_zap_rod_aux(int item)
333 int ident, chance, lev, fail;
338 /* Hack -- let perception get aborted */
339 bool use_charge = TRUE;
343 /* Get the item (in the pack) */
346 o_ptr = &inventory[item];
349 /* Get the item (on the floor) */
352 o_ptr = &o_list[0 - item];
356 /* Mega-Hack -- refuse to zap a pile from the ground */
357 if ((item < 0) && (o_ptr->number > 1))
359 msg_print(_("まずはロッドを拾わなければ。", "You must first pick up the rods."));
364 /* Get a direction (unless KNOWN not to need it) */
365 if (((o_ptr->sval >= SV_ROD_MIN_DIRECTION) && (o_ptr->sval != SV_ROD_HAVOC) && (o_ptr->sval != SV_ROD_AGGRAVATE) && (o_ptr->sval != SV_ROD_PESTICIDE)) ||
366 !object_is_aware(o_ptr))
368 /* Get a direction, allow cancel */
369 if (!get_aim_dir(&dir)) return;
374 p_ptr->energy_use = 100;
376 /* Extract the item level */
377 lev = k_info[o_ptr->k_idx].level;
379 /* Base chance of success */
380 chance = p_ptr->skill_dev;
382 /* Confusion hurts skill */
383 if (p_ptr->confused) chance = chance / 2;
386 if (chance > fail) fail -= (chance - fail)*2;
387 else chance -= (fail - chance)*2;
388 if (fail < USE_DEVICE) fail = USE_DEVICE;
389 if (chance < USE_DEVICE) chance = USE_DEVICE;
393 if (flush_failure) flush();
394 msg_print(_("止まった時の中ではうまく働かないようだ。", "Nothing happen. Maybe this rod is freezing too."));
399 if (p_ptr->pclass == CLASS_BERSERKER) success = FALSE;
400 else if (chance > fail)
402 if (randint0(chance*2) < fail) success = FALSE;
407 if (randint0(fail*2) < chance) success = TRUE;
408 else success = FALSE;
414 if (flush_failure) flush();
415 msg_print(_("うまくロッドを使えなかった。", "You failed to use the rod properly."));
420 k_ptr = &k_info[o_ptr->k_idx];
422 /* A single rod is still charging */
423 if ((o_ptr->number == 1) && (o_ptr->timeout))
425 if (flush_failure) flush();
426 msg_print(_("このロッドはまだ魔力を充填している最中だ。", "The rod is still charging."));
429 /* A stack of rods lacks enough energy. */
430 else if ((o_ptr->number > 1) && (o_ptr->timeout > k_ptr->pval * (o_ptr->number - 1)))
432 if (flush_failure) flush();
433 msg_print(_("そのロッドはまだ充填中です。", "The rods are all still charging."));
440 ident = rod_effect(o_ptr->sval, dir, &use_charge, FALSE, FALSE);
442 /* Increase the timeout by the rod kind's pval. -LM- */
443 if (use_charge) o_ptr->timeout += k_ptr->pval;
445 /* Combine / Reorder the pack (later) */
446 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
448 if (!(object_is_aware(o_ptr)))
450 chg_virtue(V_PATIENCE, -1);
451 chg_virtue(V_CHANCE, 1);
452 chg_virtue(V_KNOWLEDGE, -1);
455 /* Tried the object */
458 /* Successfully determined the object function */
459 if (ident && !object_is_aware(o_ptr))
462 gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev);
466 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
470 * @brief ロッドを使うコマンドのメインルーチン /
473 void do_cmd_zap_rod(void)
478 if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
480 set_action(ACTION_NONE);
483 /* Restrict choices to rods */
484 item_tester_tval = TV_ROD;
487 q = _("どのロッドを振りますか? ", "Zap which rod? ");
488 s = _("使えるロッドがない。", "You have no rod to zap.");
490 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
493 do_cmd_zap_rod_aux(item);
497 * @brief 『一つの指輪』の効果処理 /
498 * Hack -- activate the ring of power
502 void ring_of_power(int dir)
504 /* Pick a random effect */
505 switch (randint1(10))
511 msg_print(_("あなたは悪性のオーラに包み込まれた。", "You are surrounded by a malignant aura."));
514 /* Decrease all stats (permanently) */
515 (void)dec_stat(A_STR, 50, TRUE);
516 (void)dec_stat(A_INT, 50, TRUE);
517 (void)dec_stat(A_WIS, 50, TRUE);
518 (void)dec_stat(A_DEX, 50, TRUE);
519 (void)dec_stat(A_CON, 50, TRUE);
520 (void)dec_stat(A_CHR, 50, TRUE);
522 /* Lose some experience (permanently) */
523 p_ptr->exp -= (p_ptr->exp / 4);
524 p_ptr->max_exp -= (p_ptr->exp / 4);
533 msg_print(_("あなたは強力なオーラに包み込まれた。", "You are surrounded by a powerful aura."));
535 /* Dispel monsters */
536 dispel_monsters(1000);
546 fire_ball(GF_MANA, dir, 600, 3);
557 fire_bolt(GF_MANA, dir, 500);
565 * @brief オブジェクトをプレイヤーが簡易使用コマンドで利用できるかを判定する /
566 * Hook to determine if an object is useable
567 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
568 * @return 利用可能ならばTRUEを返す
570 static bool item_tester_hook_use(object_type *o_ptr)
572 u32b flgs[TR_FLAG_SIZE];
575 if (o_ptr->tval == p_ptr->tval_ammo)
597 if (!object_is_known(o_ptr)) return (FALSE);
599 /* HACK - only items from the equipment can be activated */
600 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
602 if (&inventory[i] == o_ptr)
604 /* Extract the flags */
605 object_flags(o_ptr, flgs);
607 /* Check activation flag */
608 if (have_flag(flgs, TR_ACTIVATE)) return (TRUE);
620 * @brief アイテムを汎用的に「使う」コマンドのメインルーチン /
624 * XXX - Add actions for other item types
626 void do_cmd_use(void)
632 if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
634 set_action(ACTION_NONE);
637 item_tester_no_ryoute = TRUE;
638 /* Prepare the hook */
639 item_tester_hook = item_tester_hook_use;
642 q = _("どれを使いますか?", "Use which item? ");
643 s = _("使えるものがありません。", "You have nothing to use.");
645 if (!get_item(&item, q, s, (USE_INVEN | USE_EQUIP | USE_FLOOR))) return;
647 /* Get the item (in the pack) */
650 o_ptr = &inventory[item];
652 /* Get the item (on the floor) */
655 o_ptr = &o_list[0 - item];
670 do_cmd_eat_food_aux(item);
677 do_cmd_aim_wand_aux(item);
684 do_cmd_use_staff_aux(item);
691 do_cmd_zap_rod_aux(item);
698 do_cmd_quaff_potion_aux(item);
705 /* Check some conditions */
708 msg_print(_("目が見えない。", "You can't see anything."));
713 msg_print(_("明かりがないので、暗くて読めない。", "You have no light to read by."));
718 msg_print(_("混乱していて読めない!", "You are too confused!"));
722 do_cmd_read_scroll_aux(item, TRUE);
731 do_cmd_fire_aux(item, &inventory[INVEN_BOW]);
735 /* Activate an artifact */
738 do_cmd_activate_aux(item);
745 * @brief 魔道具術師の取り込んだ魔力一覧から選択/閲覧する /
746 * @param only_browse 閲覧するだけならばTRUE
747 * @return 選択した魔力のID、キャンセルならば-1を返す
749 static OBJECT_SUBTYPE_VALUE select_magic_eater(bool only_browse)
751 OBJECT_SUBTYPE_VALUE ext = 0;
753 bool flag, request_list;
754 OBJECT_TYPE_VALUE tval = 0;
756 OBJECT_SUBTYPE_VALUE i = 0;
759 int menu_line = (use_menu ? 1 : 0);
763 if (repeat_pull(&sn))
765 /* Verify the spell */
766 if (sn >= EATER_EXT*2 && !(p_ptr->magic_num1[sn] > k_info[lookup_kind(TV_ROD, sn-EATER_EXT*2)].pval * (p_ptr->magic_num2[sn] - 1) * EATER_ROD_CHARGE))
768 else if (sn < EATER_EXT*2 && !(p_ptr->magic_num1[sn] < EATER_CHARGE))
772 #endif /* ALLOW_REPEAT */
774 for (i = 0; i < 108; i++)
776 if (p_ptr->magic_num2[i]) break;
780 msg_print(_("魔法を覚えていない!", "You don't have any magic!"));
791 prt(format(" %s 杖", (menu_line == 1) ? "》" : " "), 2, 14);
792 prt(format(" %s 魔法棒", (menu_line == 2) ? "》" : " "), 3, 14);
793 prt(format(" %s ロッド", (menu_line == 3) ? "》" : " "), 4, 14);
795 prt(format(" %s staff", (menu_line == 1) ? "> " : " "), 2, 14);
796 prt(format(" %s wand", (menu_line == 2) ? "> " : " "), 3, 14);
797 prt(format(" %s rod", (menu_line == 3) ? "> " : " "), 4, 14);
800 if (only_browse) prt(_("どの種類の魔法を見ますか?", "Which type of magic do you browse?"), 0, 0);
801 else prt(_("どの種類の魔法を使いますか?", "Which type of magic do you use?"), 0, 0);
824 ext = (menu_line-1)*EATER_EXT;
825 if (menu_line == 1) tval = TV_STAFF;
826 else if (menu_line == 2) tval = TV_WAND;
830 if (menu_line > 3) menu_line -= 3;
838 if (!get_com(_("[A] 杖, [B] 魔法棒, [C] ロッド:", "[A] staff, [B] wand, [C] rod:"), &choice, TRUE))
842 if (choice == 'A' || choice == 'a')
848 if (choice == 'B' || choice == 'b')
854 if (choice == 'C' || choice == 'c')
862 for (i = ext; i < ext + EATER_EXT; i++)
864 if (p_ptr->magic_num2[i])
866 if (use_menu) menu_line = i-ext+1;
870 if (i == ext+EATER_EXT)
872 msg_print(_("その種類の魔法は覚えていない!", "You don't have that type of magic!"));
876 /* Nothing chosen yet */
880 if (only_browse) strnfmt(out_val, 78, _("('*'で一覧, ESCで中断) どの魔力を見ますか?",
881 "(*=List, ESC=exit) Browse which power? "));
882 else strnfmt(out_val, 78, _("('*'で一覧, ESCで中断) どの魔力を使いますか?",
883 "(*=List, ESC=exit) Use which power? "));
885 /* Save the screen */
888 request_list = always_show_list;
890 /* Get a spell from the user */
894 if (request_list || use_menu)
897 OBJECT_SUBTYPE_VALUE ctr;
907 for (y = 1; y < 20; y++)
912 /* Print header(s) */
914 prt(format(" %s 失率 %s 失率", (tval == TV_ROD ? " 状態 " : "使用回数"), (tval == TV_ROD ? " 状態 " : "使用回数")), y++, x);
916 prt(format(" %s Fail %s Fail", (tval == TV_ROD ? " Stat " : " Charges"), (tval == TV_ROD ? " Stat " : " Charges")), y++, x);
920 for (ctr = 0; ctr < EATER_EXT; ctr++)
922 if (!p_ptr->magic_num2[ctr+ext]) continue;
924 k_idx = lookup_kind(tval, ctr);
928 if (ctr == (menu_line-1))
929 strcpy(dummy, _("》", "> "));
933 /* letter/number for power selection */
940 letter = '0' + ctr - 26;
941 sprintf(dummy, "%c)",letter);
943 x1 = ((ctr < EATER_EXT/2) ? x : x + 40);
944 y1 = ((ctr < EATER_EXT/2) ? y + ctr : y + ctr - EATER_EXT/2);
945 level = (tval == TV_ROD ? k_info[k_idx].level * 5 / 6 - 5 : k_info[k_idx].level);
946 chance = level * 4 / 5 + 20;
947 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
949 if (p_ptr->lev > level)
951 chance -= 3 * (p_ptr->lev - level);
953 chance = mod_spell_chance_1(chance);
954 chance = MAX(chance, adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]]);
955 /* Stunning makes spells harder */
956 if (p_ptr->stun > 50) chance += 25;
957 else if (p_ptr->stun) chance += 15;
959 if (chance > 95) chance = 95;
961 chance = mod_spell_chance_2(chance);
969 strcat(dummy, format(
970 _(" %-22.22s 充填:%2d/%2d%3d%%", " %-22.22s (%2d/%2d) %3d%%"),
971 k_name + k_info[k_idx].name,
972 p_ptr->magic_num1[ctr+ext] ?
973 (p_ptr->magic_num1[ctr+ext] - 1) / (EATER_ROD_CHARGE * k_info[k_idx].pval) +1 : 0,
974 p_ptr->magic_num2[ctr+ext], chance));
975 if (p_ptr->magic_num1[ctr+ext] > k_info[k_idx].pval * (p_ptr->magic_num2[ctr+ext]-1) * EATER_ROD_CHARGE) col = TERM_RED;
979 strcat(dummy, format(" %-22.22s %2d/%2d %3d%%", k_name + k_info[k_idx].name, (s16b)(p_ptr->magic_num1[ctr+ext]/EATER_CHARGE), p_ptr->magic_num2[ctr+ext], chance));
980 if (p_ptr->magic_num1[ctr+ext] < EATER_CHARGE) col = TERM_RED;
985 c_prt(col, dummy, y1, x1);
989 if (!get_com(out_val, &choice, FALSE)) break;
991 if (use_menu && choice != ' ')
1007 menu_line += EATER_EXT - 1;
1008 if (menu_line > EATER_EXT) menu_line -= EATER_EXT;
1009 } while(!p_ptr->magic_num2[menu_line+ext-1]);
1020 if (menu_line > EATER_EXT) menu_line -= EATER_EXT;
1021 } while(!p_ptr->magic_num2[menu_line+ext-1]);
1032 bool reverse = FALSE;
1033 if ((choice == '4') || (choice == 'h') || (choice == 'H')) reverse = TRUE;
1034 if (menu_line > EATER_EXT/2)
1036 menu_line -= EATER_EXT/2;
1039 else menu_line+=EATER_EXT/2;
1040 while(!p_ptr->magic_num2[menu_line+ext-1])
1045 if (menu_line < 2) reverse = FALSE;
1050 if (menu_line > EATER_EXT-1) reverse = TRUE;
1067 /* Request redraw */
1068 if (use_menu && ask) continue;
1070 /* Request redraw */
1071 if (!use_menu && ((choice == ' ') || (choice == '*') || (choice == '?')))
1077 request_list = FALSE;
1079 /* Restore the screen */
1084 request_list = TRUE;
1092 if (isalpha(choice))
1095 ask = (isupper(choice));
1098 if (ask) choice = (char)tolower(choice);
1100 /* Extract request */
1101 i = (islower(choice) ? A2I(choice) : -1);
1105 ask = FALSE; /* Can't uppercase digits */
1107 i = choice - '0' + 26;
1111 /* Totally Illegal */
1112 if ((i < 0) || (i > EATER_EXT) || !p_ptr->magic_num2[i+ext])
1126 (void) strnfmt(tmp_val, 78, _("%sを使いますか? ", "Use %s?"), k_name + k_info[lookup_kind(tval ,i)].name);
1128 /* Belay that order */
1129 if (!get_check(tmp_val)) continue;
1133 if (p_ptr->magic_num1[ext+i] > k_info[lookup_kind(tval, i)].pval * (p_ptr->magic_num2[ext+i] - 1) * EATER_ROD_CHARGE)
1135 msg_print(_("その魔法はまだ充填している最中だ。", "The magic are still charging."));
1137 if (use_menu) ask = TRUE;
1143 if (p_ptr->magic_num1[ext+i] < EATER_CHARGE)
1145 msg_print(_("その魔法は使用回数が切れている。", "The magic has no charges left."));
1147 if (use_menu) ask = TRUE;
1159 /* Clear lines, position cursor (really should use strlen here) */
1160 Term_erase(7, 23, 255);
1161 Term_erase(7, 22, 255);
1162 Term_erase(7, 21, 255);
1163 Term_erase(7, 20, 255);
1165 roff_to_buf(k_text + k_info[lookup_kind(tval, i)].text, 62, temp, sizeof(temp));
1166 for (j = 0, line = 21; temp[j]; j += 1 + strlen(&temp[j]))
1168 prt(&temp[j], line, 10);
1179 /* Restore the screen */
1182 if (!flag) return -1;
1186 #endif /* ALLOW_REPEAT */
1192 * @brief 取り込んだ魔力を利用するコマンドのメインルーチン /
1193 * Use eaten rod, wand or staff
1194 * @param only_browse 閲覧するだけならばTRUE
1195 * @param powerful 強力発動中の処理ならばTRUE
1196 * @return 実際にコマンドを実行したならばTRUEを返す。
1198 bool do_cmd_magic_eater(bool only_browse, bool powerful)
1200 OBJECT_SUBTYPE_VALUE item;
1204 OBJECT_TYPE_VALUE tval;
1205 OBJECT_SUBTYPE_VALUE sval;
1206 bool use_charge = TRUE;
1208 /* Not when confused */
1209 if (!only_browse && p_ptr->confused)
1211 msg_print(_("混乱していて唱えられない!", "You are too confused!"));
1215 item = select_magic_eater(only_browse);
1218 p_ptr->energy_use = 0;
1221 if (item >= EATER_EXT*2) {tval = TV_ROD;sval = item - EATER_EXT*2;}
1222 else if (item >= EATER_EXT) {tval = TV_WAND;sval = item - EATER_EXT;}
1223 else {tval = TV_STAFF; sval = item;}
1224 k_idx = lookup_kind(tval, sval);
1226 level = (tval == TV_ROD ? k_info[k_idx].level * 5 / 6 - 5 : k_info[k_idx].level);
1227 chance = level * 4 / 5 + 20;
1228 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
1230 if (p_ptr->lev > level)
1232 chance -= 3 * (p_ptr->lev - level);
1234 chance = mod_spell_chance_1(chance);
1235 chance = MAX(chance, adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]]);
1236 /* Stunning makes spells harder */
1237 if (p_ptr->stun > 50) chance += 25;
1238 else if (p_ptr->stun) chance += 15;
1240 if (chance > 95) chance = 95;
1242 chance = mod_spell_chance_2(chance);
1244 if (randint0(100) < chance)
1246 if (flush_failure) flush();
1248 msg_print(_("呪文をうまく唱えられなかった!", "You failed to get the magic off!"));
1250 if (randint1(100) >= chance)
1251 chg_virtue(V_CHANCE,-1);
1252 p_ptr->energy_use = 100;
1262 if ((sval >= SV_ROD_MIN_DIRECTION) && (sval != SV_ROD_HAVOC) && (sval != SV_ROD_AGGRAVATE) && (sval != SV_ROD_PESTICIDE))
1263 if (!get_aim_dir(&dir)) return FALSE;
1264 rod_effect(sval, dir, &use_charge, powerful, TRUE);
1265 if (!use_charge) return FALSE;
1267 else if (tval == TV_WAND)
1269 if (!get_aim_dir(&dir)) return FALSE;
1270 wand_effect(sval, dir, powerful, TRUE);
1274 staff_effect(sval, &use_charge, powerful, TRUE, TRUE);
1275 if (!use_charge) return FALSE;
1277 if (randint1(100) < chance)
1278 chg_virtue(V_CHANCE,1);
1280 p_ptr->energy_use = 100;
1281 if (tval == TV_ROD) p_ptr->magic_num1[item] += k_info[k_idx].pval * EATER_ROD_CHARGE;
1282 else p_ptr->magic_num1[item] -= EATER_CHARGE;