2 * @brief ものまねの処理実装 / Imitation code
5 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke\n
6 * This software may be copied and distributed for educational, research,\n
7 * and not for profit purposes provided that this copyright and statement\n
8 * are included in all such copies. Other copyrights may also apply.\n
9 * 2014 Deskull rearranged comment for Doxygen.\n
12 #include "action/action-limited.h"
13 #include "artifact/fixed-art-types.h"
14 #include "cmd-action/cmd-spell.h"
15 #include "core/asking-player.h"
16 #include "core/player-redraw-types.h"
17 #include "core/stuff-handler.h"
18 #include "core/window-redrawer.h"
19 #include "floor/cave.h"
20 #include "floor/floor-object.h"
21 #include "game-option/disturbance-options.h"
22 #include "game-option/text-display-options.h"
23 #include "grid/grid.h"
24 #include "hpmp/hp-mp-processor.h"
25 #include "inventory/inventory-slot-types.h"
26 #include "main/sound-definitions-table.h"
27 #include "main/sound-of-music.h"
28 #include "mind/mind-mage.h"
29 #include "monster-floor/monster-summon.h"
30 #include "monster-floor/place-monster-types.h"
31 #include "monster-race/monster-race.h"
32 #include "monster-race/race-ability-flags.h"
33 #include "monster-race/race-flags-resistance.h"
34 #include "monster-race/race-flags1.h"
35 #include "monster/monster-describer.h"
36 #include "monster/monster-info.h"
37 #include "monster/monster-processor.h"
38 #include "monster/monster-status.h"
39 #include "mspell/monster-power-table.h"
40 #include "player-status/player-energy.h"
41 #include "player/player-status-table.h"
42 #include "spell-kind/spells-launcher.h"
43 #include "spell-kind/spells-lite.h"
44 #include "spell-kind/spells-neighbor.h"
45 #include "spell-kind/spells-sight.h"
46 #include "spell-kind/spells-teleport.h"
47 #include "spell-kind/spells-world.h"
48 #include "spell/spell-types.h"
49 #include "spell/spells-status.h"
50 #include "spell/spells-summon.h"
51 #include "spell/summon-types.h"
52 #include "status/bad-status-setter.h"
53 #include "status/body-improvement.h"
54 #include "status/buff-setter.h"
55 #include "system/floor-type-definition.h"
56 #include "system/monster-race-definition.h"
57 #include "system/monster-type-definition.h"
58 #include "system/object-type-definition.h"
59 #include "system/player-type-definition.h"
60 #include "target/projection-path-calculator.h"
61 #include "target/target-checker.h"
62 #include "target/target-getter.h"
63 #include "target/target-setter.h"
64 #include "target/target-types.h"
65 #include "term/screen-processor.h"
66 #include "util/int-char-converter.h"
67 #include "view/display-messages.h"
72 * @brief 受け取ったパラメータに応じてものまねの効果情報をまとめたフォーマットを返す
73 * @param p 情報を返す文字列参照ポインタ
74 * @param power ものまねの効力の種類
77 static void mane_info(player_type *caster_ptr, char *p, RF_ABILITY power, HIT_POINT dam)
79 PLAYER_LEVEL plev = caster_ptr->lev;
83 const auto power_int = static_cast<int>(power);
85 if ((power_int > 2 && power_int < 41) || (power_int > 41 && power_int < 59) || (power == RF_ABILITY::PSY_SPEAR))
86 sprintf(p, " %s%d", KWD_DAM, (int)dam);
89 case RF_ABILITY::DRAIN_MANA:
90 sprintf(p, " %sd%d+%d", KWD_HEAL, plev * 3, plev);
92 case RF_ABILITY::HASTE:
93 sprintf(p, " %sd%d+%d", KWD_DURATION, 20 + plev, plev);
95 case RF_ABILITY::HEAL:
96 sprintf(p, " %s%d", KWD_HEAL, plev * 6);
98 case RF_ABILITY::INVULNER:
99 sprintf(p, " %sd7+7", KWD_DURATION);
101 case RF_ABILITY::BLINK:
102 sprintf(p, " %s10", KWD_SPHERE);
104 case RF_ABILITY::TPORT:
105 sprintf(p, " %s%d", KWD_SPHERE, plev * 5);
107 case RF_ABILITY::RAISE_DEAD:
108 sprintf(p, " %s5", KWD_SPHERE);
117 * @brief どのものまねを発動するか選択する処理 /
118 * Allow user to choose a imitation.
119 * @param sn 実行したものまねのIDを返す参照ポインタ(キャンセルなどの場合-1を返す)
120 * @param baigaesi TRUEならば倍返し上の処理として行う
121 * @return 処理を実行したらTRUE、キャンセルした場合FALSEを返す。
123 * If a valid spell is chosen, saves it in '*sn' and returns TRUE
124 * If the user hits escape, returns FALSE, and set '*sn' to -1
125 * If there are no legal choices, returns FALSE, and sets '*sn' to -2
127 * The "prompt" should be "cast", "recite", or "study"
128 * The "known" should be TRUE for cast/pray, FALSE for study
130 * nb: This function has a (trivial) display bug which will be obvious
131 * when you run it. It's probably easy to fix but I haven't tried,
134 static int get_mane_power(player_type *caster_ptr, int *sn, bool baigaesi)
140 PERCENTAGE minfail = 0;
141 PLAYER_LEVEL plev = caster_ptr->lev;
142 PERCENTAGE chance = 0;
145 char out_val[MAX_MONSTER_NAME];
147 concptr p = _("能力", "power");
152 /* Assume cancelled */
158 num = caster_ptr->mane_num;
160 /* Build a prompt (accept all spells) */
161 (void)strnfmt(out_val, 78, _("(%c-%c, '*'で一覧, ESC) どの%sをまねますか?", "(%c-%c, *=List, ESC=exit) Use which %s? "), I2A(0), I2A(num - 1), p);
163 choice = always_show_list ? ESCAPE : 1;
165 if (choice == ESCAPE)
167 else if (!get_com(out_val, &choice, TRUE))
171 if ((choice == ' ') || (choice == '*') || (choice == '?')) {
178 /* Display a list of spells */
180 put_str(_("名前", "Name"), y, x + 5);
181 put_str(_("失率 効果", "Fail Info"), y, x + 36);
183 /* Dump the spells */
184 for (i = 0; i < num; i++) {
185 /* Access the spell */
186 spell = monster_powers[static_cast<size_t>(caster_ptr->mane_spell[i])];
188 chance = spell.manefail;
190 /* Reduce failure rate by "effective" level adjustment */
191 if (plev > spell.level)
192 chance -= 3 * (plev - spell.level);
194 /* Reduce failure rate by INT/WIS adjustment */
195 chance -= 3 * (adj_mag_stat[caster_ptr->stat_index[spell.use_stat]] + adj_mag_stat[caster_ptr->stat_index[A_DEX]] - 2) / 2;
198 chance = chance * (baigaesi ? caster_ptr->mane_dam[i] * 2 : caster_ptr->mane_dam[i]) / spell.manedam;
200 chance += caster_ptr->to_m_chance;
202 if (caster_ptr->inventory_list[INVEN_NECK].name1 == ART_GOGO_PENDANT) {
206 /* Extract the minimum failure rate */
207 minfail = adj_mag_fail[caster_ptr->stat_index[spell.use_stat]];
209 /* Minimum failure rate */
210 if (chance < minfail)
213 /* Stunning makes spells harder */
214 if (caster_ptr->stun > 50)
216 else if (caster_ptr->stun)
219 /* Always a 5 percent chance of working */
224 mane_info(caster_ptr, comment, caster_ptr->mane_spell[i], (baigaesi ? caster_ptr->mane_dam[i] * 2 : caster_ptr->mane_dam[i]));
226 /* Dump the spell --(-- */
227 sprintf(psi_desc, " %c) %-30s %3d%%%s", I2A(i), spell.name, chance, comment);
228 prt(psi_desc, y + i + 1, x);
231 /* Clear the bottom line */
232 prt("", y + i + 1, x);
247 ask = isupper(choice);
251 choice = (char)tolower(choice);
253 /* Extract request */
254 i = (islower(choice) ? A2I(choice) : -1);
256 /* Totally Illegal */
257 if ((i < 0) || (i >= num)) {
262 /* Save the spell index */
263 spell = monster_powers[static_cast<int>(caster_ptr->mane_spell[i])];
270 (void)strnfmt(tmp_val, 78, _("%sをまねますか?", "Use %s? "), spell.name);
272 /* Belay that order */
273 if (!get_check(tmp_val))
283 caster_ptr->window_flags |= (PW_SPELL);
284 handle_stuff(caster_ptr);
286 /* Abort if needed */
290 /* Save the choice */
293 damage = (baigaesi ? caster_ptr->mane_dam[i] * 2 : caster_ptr->mane_dam[i]);
301 * do_cmd_cast calls this function if the player's class is 'imitator'.
302 * @param caster_ptr プレーヤーへの参照ポインタ
303 * @param spell 発動するモンスター攻撃のID
304 * @return 処理を実行したらTRUE、キャンセルした場合FALSEを返す。
306 static bool use_mane(player_type *caster_ptr, RF_ABILITY spell)
309 PLAYER_LEVEL plev = caster_ptr->lev;
310 BIT_FLAGS mode = (PM_ALLOW_GROUP | PM_FORCE_PET);
311 BIT_FLAGS u_mode = 0L;
313 if (randint1(50 + plev) < plev / 10)
314 u_mode = PM_ALLOW_UNIQUE;
318 case RF_ABILITY::SHRIEK:
319 msg_print(_("かん高い金切り声をあげた。", "You make a high pitched shriek."));
320 aggravate_monsters(caster_ptr, 0);
323 case RF_ABILITY::XXX1:
326 case RF_ABILITY::DISPEL: {
329 if (!target_set(caster_ptr, TARGET_KILL))
331 m_idx = caster_ptr->current_floor_ptr->grid_array[target_row][target_col].m_idx;
334 if (!player_has_los_bold(caster_ptr, target_row, target_col))
336 if (!projectable(caster_ptr, caster_ptr->y, caster_ptr->x, target_row, target_col))
338 dispel_monster_status(caster_ptr, m_idx);
342 case RF_ABILITY::ROCKET:
343 if (!get_aim_dir(caster_ptr, &dir))
346 msg_print(_("ロケットを発射した。", "You fire a rocket."));
347 fire_rocket(caster_ptr, GF_ROCKET, dir, damage, 2);
350 case RF_ABILITY::SHOOT:
351 if (!get_aim_dir(caster_ptr, &dir))
354 msg_print(_("矢を放った。", "You fire an arrow."));
355 fire_bolt(caster_ptr, GF_ARROW, dir, damage);
358 case RF_ABILITY::XXX2:
361 case RF_ABILITY::XXX3:
364 case RF_ABILITY::XXX4:
367 case RF_ABILITY::BR_ACID:
368 if (!get_aim_dir(caster_ptr, &dir))
371 msg_print(_("酸のブレスを吐いた。", "You breathe acid."));
372 fire_breath(caster_ptr, GF_ACID, dir, damage, (plev > 35 ? 3 : 2));
375 case RF_ABILITY::BR_ELEC:
376 if (!get_aim_dir(caster_ptr, &dir))
379 msg_print(_("稲妻のブレスを吐いた。", "You breathe lightning."));
380 fire_breath(caster_ptr, GF_ELEC, dir, damage, (plev > 35 ? 3 : 2));
383 case RF_ABILITY::BR_FIRE:
384 if (!get_aim_dir(caster_ptr, &dir))
387 msg_print(_("火炎のブレスを吐いた。", "You breathe fire."));
388 fire_breath(caster_ptr, GF_FIRE, dir, damage, (plev > 35 ? 3 : 2));
391 case RF_ABILITY::BR_COLD:
392 if (!get_aim_dir(caster_ptr, &dir))
395 msg_print(_("冷気のブレスを吐いた。", "You breathe frost."));
396 fire_breath(caster_ptr, GF_COLD, dir, damage, (plev > 35 ? 3 : 2));
399 case RF_ABILITY::BR_POIS:
400 if (!get_aim_dir(caster_ptr, &dir))
403 msg_print(_("ガスのブレスを吐いた。", "You breathe gas."));
404 fire_breath(caster_ptr, GF_POIS, dir, damage, (plev > 35 ? 3 : 2));
407 case RF_ABILITY::BR_NETH:
408 if (!get_aim_dir(caster_ptr, &dir))
411 msg_print(_("地獄のブレスを吐いた。", "You breathe nether."));
412 fire_breath(caster_ptr, GF_NETHER, dir, damage, (plev > 35 ? 3 : 2));
415 case RF_ABILITY::BR_LITE:
416 if (!get_aim_dir(caster_ptr, &dir))
419 msg_print(_("閃光のブレスを吐いた。", "You breathe light."));
420 fire_breath(caster_ptr, GF_LITE, dir, damage, (plev > 35 ? 3 : 2));
423 case RF_ABILITY::BR_DARK:
424 if (!get_aim_dir(caster_ptr, &dir))
427 msg_print(_("暗黒のブレスを吐いた。", "You breathe darkness."));
428 fire_breath(caster_ptr, GF_DARK, dir, damage, (plev > 35 ? 3 : 2));
431 case RF_ABILITY::BR_CONF:
432 if (!get_aim_dir(caster_ptr, &dir))
435 msg_print(_("混乱のブレスを吐いた。", "You breathe confusion."));
436 fire_breath(caster_ptr, GF_CONFUSION, dir, damage, (plev > 35 ? 3 : 2));
439 case RF_ABILITY::BR_SOUN:
440 if (!get_aim_dir(caster_ptr, &dir))
443 msg_print(_("轟音のブレスを吐いた。", "You breathe sound."));
444 fire_breath(caster_ptr, GF_SOUND, dir, damage, (plev > 35 ? 3 : 2));
447 case RF_ABILITY::BR_CHAO:
448 if (!get_aim_dir(caster_ptr, &dir))
451 msg_print(_("カオスのブレスを吐いた。", "You breathe chaos."));
452 fire_breath(caster_ptr, GF_CHAOS, dir, damage, (plev > 35 ? 3 : 2));
455 case RF_ABILITY::BR_DISE:
456 if (!get_aim_dir(caster_ptr, &dir))
459 msg_print(_("劣化のブレスを吐いた。", "You breathe disenchantment."));
460 fire_breath(caster_ptr, GF_DISENCHANT, dir, damage, (plev > 35 ? 3 : 2));
463 case RF_ABILITY::BR_NEXU:
464 if (!get_aim_dir(caster_ptr, &dir))
467 msg_print(_("因果混乱のブレスを吐いた。", "You breathe nexus."));
468 fire_breath(caster_ptr, GF_NEXUS, dir, damage, (plev > 35 ? 3 : 2));
471 case RF_ABILITY::BR_TIME:
472 if (!get_aim_dir(caster_ptr, &dir))
475 msg_print(_("時間逆転のブレスを吐いた。", "You breathe time."));
476 fire_breath(caster_ptr, GF_TIME, dir, damage, (plev > 35 ? 3 : 2));
479 case RF_ABILITY::BR_INER:
480 if (!get_aim_dir(caster_ptr, &dir))
483 msg_print(_("遅鈍のブレスを吐いた。", "You breathe inertia."));
484 fire_breath(caster_ptr, GF_INERTIAL, dir, damage, (plev > 35 ? 3 : 2));
487 case RF_ABILITY::BR_GRAV:
488 if (!get_aim_dir(caster_ptr, &dir))
491 msg_print(_("重力のブレスを吐いた。", "You breathe gravity."));
492 fire_breath(caster_ptr, GF_GRAVITY, dir, damage, (plev > 35 ? 3 : 2));
495 case RF_ABILITY::BR_SHAR:
496 if (!get_aim_dir(caster_ptr, &dir))
499 msg_print(_("破片のブレスを吐いた。", "You breathe shards."));
500 fire_breath(caster_ptr, GF_SHARDS, dir, damage, (plev > 35 ? 3 : 2));
503 case RF_ABILITY::BR_PLAS:
504 if (!get_aim_dir(caster_ptr, &dir))
507 msg_print(_("プラズマのブレスを吐いた。", "You breathe plasma."));
509 fire_breath(caster_ptr, GF_PLASMA, dir, damage, (plev > 35 ? 3 : 2));
512 case RF_ABILITY::BR_FORC:
513 if (!get_aim_dir(caster_ptr, &dir))
516 msg_print(_("フォースのブレスを吐いた。", "You breathe force."));
518 fire_breath(caster_ptr, GF_FORCE, dir, damage, (plev > 35 ? 3 : 2));
521 case RF_ABILITY::BR_MANA:
522 if (!get_aim_dir(caster_ptr, &dir))
525 msg_print(_("魔力のブレスを吐いた。", "You breathe mana."));
527 fire_breath(caster_ptr, GF_MANA, dir, damage, (plev > 35 ? 3 : 2));
530 case RF_ABILITY::BA_NUKE:
531 if (!get_aim_dir(caster_ptr, &dir))
534 msg_print(_("放射能球を放った。", "You cast a ball of radiation."));
536 fire_ball(caster_ptr, GF_NUKE, dir, damage, 2);
539 case RF_ABILITY::BR_NUKE:
540 if (!get_aim_dir(caster_ptr, &dir))
543 msg_print(_("放射性廃棄物のブレスを吐いた。", "You breathe toxic waste."));
545 fire_breath(caster_ptr, GF_NUKE, dir, damage, (plev > 35 ? 3 : 2));
548 case RF_ABILITY::BA_CHAO:
549 if (!get_aim_dir(caster_ptr, &dir))
552 msg_print(_("純ログルスを放った。", "You invoke a raw Logrus."));
554 fire_ball(caster_ptr, GF_CHAOS, dir, damage, 4);
556 case RF_ABILITY::BR_DISI:
557 if (!get_aim_dir(caster_ptr, &dir))
560 msg_print(_("分解のブレスを吐いた。", "You breathe disintegration."));
562 fire_breath(caster_ptr, GF_DISINTEGRATE, dir, damage, (plev > 35 ? 3 : 2));
564 case RF_ABILITY::BA_ACID:
565 if (!get_aim_dir(caster_ptr, &dir))
568 msg_print(_("アシッド・ボールの呪文を唱えた。", "You cast an acid ball."));
570 fire_ball(caster_ptr, GF_ACID, dir, damage, 2);
572 case RF_ABILITY::BA_ELEC:
573 if (!get_aim_dir(caster_ptr, &dir))
576 msg_print(_("サンダー・ボールの呪文を唱えた。", "You cast a lightning ball."));
578 fire_ball(caster_ptr, GF_ELEC, dir, damage, 2);
580 case RF_ABILITY::BA_FIRE:
581 if (!get_aim_dir(caster_ptr, &dir))
584 msg_print(_("ファイア・ボールの呪文を唱えた。", "You cast a fire ball."));
586 fire_ball(caster_ptr, GF_FIRE, dir, damage, 2);
588 case RF_ABILITY::BA_COLD:
589 if (!get_aim_dir(caster_ptr, &dir))
592 msg_print(_("アイス・ボールの呪文を唱えた。", "You cast a frost ball."));
594 fire_ball(caster_ptr, GF_COLD, dir, damage, 2);
596 case RF_ABILITY::BA_POIS:
597 if (!get_aim_dir(caster_ptr, &dir))
600 msg_print(_("悪臭雲の呪文を唱えた。", "You cast a stinking cloud."));
602 fire_ball(caster_ptr, GF_POIS, dir, damage, 2);
604 case RF_ABILITY::BA_NETH:
605 if (!get_aim_dir(caster_ptr, &dir))
608 msg_print(_("地獄球の呪文を唱えた。", "You cast a nether ball."));
610 fire_ball(caster_ptr, GF_NETHER, dir, damage, 2);
612 case RF_ABILITY::BA_WATE:
613 if (!get_aim_dir(caster_ptr, &dir))
616 msg_print(_("流れるような身振りをした。", "You gesture fluidly."));
618 fire_ball(caster_ptr, GF_WATER, dir, damage, 4);
620 case RF_ABILITY::BA_MANA:
621 if (!get_aim_dir(caster_ptr, &dir))
624 msg_print(_("魔力の嵐の呪文を念じた。", "You invoke a mana storm."));
626 fire_ball(caster_ptr, GF_MANA, dir, damage, 4);
628 case RF_ABILITY::BA_DARK:
629 if (!get_aim_dir(caster_ptr, &dir))
632 msg_print(_("暗黒の嵐の呪文を念じた。", "You invoke a darkness storm."));
634 fire_ball(caster_ptr, GF_DARK, dir, damage, 4);
636 case RF_ABILITY::DRAIN_MANA:
637 if (!get_aim_dir(caster_ptr, &dir))
639 fire_ball_hide(caster_ptr, GF_DRAIN_MANA, dir, randint1(plev * 3) + plev, 0);
641 case RF_ABILITY::MIND_BLAST:
642 if (!get_aim_dir(caster_ptr, &dir))
644 fire_ball_hide(caster_ptr, GF_MIND_BLAST, dir, damage, 0);
646 case RF_ABILITY::BRAIN_SMASH:
647 if (!get_aim_dir(caster_ptr, &dir))
649 fire_ball_hide(caster_ptr, GF_BRAIN_SMASH, dir, damage, 0);
651 case RF_ABILITY::CAUSE_1:
652 if (!get_aim_dir(caster_ptr, &dir))
654 fire_ball_hide(caster_ptr, GF_CAUSE_1, dir, damage, 0);
656 case RF_ABILITY::CAUSE_2:
657 if (!get_aim_dir(caster_ptr, &dir))
659 fire_ball_hide(caster_ptr, GF_CAUSE_2, dir, damage, 0);
661 case RF_ABILITY::CAUSE_3:
662 if (!get_aim_dir(caster_ptr, &dir))
664 fire_ball_hide(caster_ptr, GF_CAUSE_3, dir, damage, 0);
666 case RF_ABILITY::CAUSE_4:
667 if (!get_aim_dir(caster_ptr, &dir))
669 fire_ball_hide(caster_ptr, GF_CAUSE_4, dir, damage, 0);
671 case RF_ABILITY::BO_ACID:
672 if (!get_aim_dir(caster_ptr, &dir))
675 msg_print(_("アシッド・ボルトの呪文を唱えた。", "You cast an acid bolt."));
677 fire_bolt(caster_ptr, GF_ACID, dir, damage);
679 case RF_ABILITY::BO_ELEC:
680 if (!get_aim_dir(caster_ptr, &dir))
683 msg_print(_("サンダー・ボルトの呪文を唱えた。", "You cast a lightning bolt."));
685 fire_bolt(caster_ptr, GF_ELEC, dir, damage);
687 case RF_ABILITY::BO_FIRE:
688 if (!get_aim_dir(caster_ptr, &dir))
691 msg_print(_("ファイア・ボルトの呪文を唱えた。", "You cast a fire bolt."));
693 fire_bolt(caster_ptr, GF_FIRE, dir, damage);
695 case RF_ABILITY::BO_COLD:
696 if (!get_aim_dir(caster_ptr, &dir))
699 msg_print(_("アイス・ボルトの呪文を唱えた。", "You cast a frost bolt."));
701 fire_bolt(caster_ptr, GF_COLD, dir, damage);
703 case RF_ABILITY::BA_LITE:
704 if (!get_aim_dir(caster_ptr, &dir))
707 msg_print(_("スターバーストの呪文を念じた。", "You invoke a starburst."));
709 fire_ball(caster_ptr, GF_LITE, dir, damage, 4);
711 case RF_ABILITY::BO_NETH:
712 if (!get_aim_dir(caster_ptr, &dir))
715 msg_print(_("地獄の矢の呪文を唱えた。", "You cast a nether bolt."));
717 fire_bolt(caster_ptr, GF_NETHER, dir, damage);
719 case RF_ABILITY::BO_WATE:
720 if (!get_aim_dir(caster_ptr, &dir))
723 msg_print(_("ウォーター・ボルトの呪文を唱えた。", "You cast a water bolt."));
725 fire_bolt(caster_ptr, GF_WATER, dir, damage);
727 case RF_ABILITY::BO_MANA:
728 if (!get_aim_dir(caster_ptr, &dir))
731 msg_print(_("魔力の矢の呪文を唱えた。", "You cast a mana bolt."));
733 fire_bolt(caster_ptr, GF_MANA, dir, damage);
735 case RF_ABILITY::BO_PLAS:
736 if (!get_aim_dir(caster_ptr, &dir))
739 msg_print(_("プラズマ・ボルトの呪文を唱えた。", "You cast a plasma bolt."));
741 fire_bolt(caster_ptr, GF_PLASMA, dir, damage);
743 case RF_ABILITY::BO_ICEE:
744 if (!get_aim_dir(caster_ptr, &dir))
747 msg_print(_("極寒の矢の呪文を唱えた。", "You cast a ice bolt."));
749 fire_bolt(caster_ptr, GF_ICE, dir, damage);
751 case RF_ABILITY::MISSILE:
752 if (!get_aim_dir(caster_ptr, &dir))
755 msg_print(_("マジック・ミサイルの呪文を唱えた。", "You cast a magic missile."));
757 fire_bolt(caster_ptr, GF_MISSILE, dir, damage);
759 case RF_ABILITY::SCARE:
760 if (!get_aim_dir(caster_ptr, &dir))
763 msg_print(_("恐ろしげな幻覚を作り出した。", "You cast a fearful illusion."));
765 fear_monster(caster_ptr, dir, plev + 10);
767 case RF_ABILITY::BLIND:
768 if (!get_aim_dir(caster_ptr, &dir))
770 confuse_monster(caster_ptr, dir, plev * 2);
772 case RF_ABILITY::CONF:
773 if (!get_aim_dir(caster_ptr, &dir))
776 msg_print(_("誘惑的な幻覚をつくり出した。", "You cast a mesmerizing illusion."));
778 confuse_monster(caster_ptr, dir, plev * 2);
780 case RF_ABILITY::SLOW:
781 if (!get_aim_dir(caster_ptr, &dir))
783 slow_monster(caster_ptr, dir, plev);
785 case RF_ABILITY::HOLD:
786 if (!get_aim_dir(caster_ptr, &dir))
788 sleep_monster(caster_ptr, dir, plev);
790 case RF_ABILITY::HASTE:
791 (void)set_fast(caster_ptr, randint1(20 + plev) + plev, FALSE);
793 case RF_ABILITY::HAND_DOOM: {
794 if (!get_aim_dir(caster_ptr, &dir))
797 msg_print(_("<破滅の手>を放った!", "You invoke the Hand of Doom!"));
799 fire_ball_hide(caster_ptr, GF_HAND_DOOM, dir, 200, 0);
802 case RF_ABILITY::HEAL:
803 msg_print(_("自分の傷に念を集中した。", "You concentrate on your wounds!"));
804 (void)hp_player(caster_ptr, plev * 6);
805 (void)set_stun(caster_ptr, 0);
806 (void)set_cut(caster_ptr, 0);
808 case RF_ABILITY::INVULNER:
809 msg_print(_("無傷の球の呪文を唱えた。", "You cast a Globe of Invulnerability."));
810 (void)set_invuln(caster_ptr, randint1(7) + 7, FALSE);
812 case RF_ABILITY::BLINK:
813 teleport_player(caster_ptr, 10, TELEPORT_SPONTANEOUS);
815 case RF_ABILITY::TPORT:
816 teleport_player(caster_ptr, plev * 5, TELEPORT_SPONTANEOUS);
818 case RF_ABILITY::WORLD:
819 (void)time_walk(caster_ptr);
821 case RF_ABILITY::SPECIAL:
823 case RF_ABILITY::TELE_TO: {
826 GAME_TEXT m_name[MAX_NLEN];
828 if (!target_set(caster_ptr, TARGET_KILL))
830 if (!caster_ptr->current_floor_ptr->grid_array[target_row][target_col].m_idx)
832 if (!player_has_los_bold(caster_ptr, target_row, target_col))
834 if (!projectable(caster_ptr, caster_ptr->y, caster_ptr->x, target_row, target_col))
836 m_ptr = &caster_ptr->current_floor_ptr->m_list[caster_ptr->current_floor_ptr->grid_array[target_row][target_col].m_idx];
837 r_ptr = &r_info[m_ptr->r_idx];
838 monster_desc(caster_ptr, m_name, m_ptr, 0);
839 if (r_ptr->flagsr & RFR_RES_TELE) {
840 if ((r_ptr->flags1 & (RF1_UNIQUE)) || (r_ptr->flagsr & RFR_RES_ALL)) {
841 if (is_original_ap_and_seen(caster_ptr, m_ptr))
842 r_ptr->r_flagsr |= RFR_RES_TELE;
843 msg_format(_("%sには効果がなかった!", "%s is unaffected!"), m_name);
846 } else if (r_ptr->level > randint1(100)) {
847 if (is_original_ap_and_seen(caster_ptr, m_ptr))
848 r_ptr->r_flagsr |= RFR_RES_TELE;
849 msg_format(_("%sには耐性がある!", "%s resists!"), m_name);
854 msg_format(_("%sを引き戻した。", "You command %s to return."), m_name);
857 caster_ptr, caster_ptr->current_floor_ptr->grid_array[target_row][target_col].m_idx, caster_ptr->y, caster_ptr->x, 100, TELEPORT_PASSIVE);
860 case RF_ABILITY::TELE_AWAY:
861 if (!get_aim_dir(caster_ptr, &dir))
864 (void)fire_beam(caster_ptr, GF_AWAY_ALL, dir, plev);
867 case RF_ABILITY::TELE_LEVEL:
868 return teleport_level_other(caster_ptr);
871 case RF_ABILITY::PSY_SPEAR:
872 if (!get_aim_dir(caster_ptr, &dir))
875 msg_print(_("光の剣を放った。", "You throw a psycho-spear."));
876 (void)fire_beam(caster_ptr, GF_PSY_SPEAR, dir, damage);
879 case RF_ABILITY::DARKNESS:
880 msg_print(_("暗闇の中で手を振った。", "You gesture in shadow."));
881 (void)unlite_area(caster_ptr, 10, 3);
884 case RF_ABILITY::TRAPS:
885 if (!target_set(caster_ptr, TARGET_KILL))
887 msg_print(_("呪文を唱えて邪悪に微笑んだ。", "You cast a spell and cackle evilly."));
888 trap_creation(caster_ptr, target_row, target_col);
890 case RF_ABILITY::FORGET:
891 msg_print(_("しかし何も起きなかった。", "Nothing happens."));
893 case RF_ABILITY::RAISE_DEAD:
894 msg_print(_("死者復活の呪文を唱えた。", "You animate the dead."));
895 (void)animate_dead(caster_ptr, 0, caster_ptr->y, caster_ptr->x);
897 case RF_ABILITY::S_KIN: {
899 if (!target_set(caster_ptr, TARGET_KILL))
902 msg_print(_("援軍を召喚した。", "You summon minions."));
903 for (k = 0; k < 4; k++) {
904 (void)summon_kin_player(caster_ptr, plev, target_row, target_col, (PM_FORCE_PET | PM_ALLOW_GROUP));
908 case RF_ABILITY::S_CYBER: {
910 int max_cyber = (caster_ptr->current_floor_ptr->dun_level / 50) + randint1(3);
911 if (!target_set(caster_ptr, TARGET_KILL))
913 msg_print(_("サイバーデーモンを召喚した!", "You summon Cyberdemons!"));
916 for (k = 0; k < max_cyber; k++)
917 summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_CYBER, mode);
920 case RF_ABILITY::S_MONSTER: {
922 if (!target_set(caster_ptr, TARGET_KILL))
924 msg_print(_("仲間を召喚した。", "You summon help."));
925 for (k = 0; k < 1; k++)
926 summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_NONE, (mode | u_mode));
929 case RF_ABILITY::S_MONSTERS: {
931 if (!target_set(caster_ptr, TARGET_KILL))
933 msg_print(_("モンスターを召喚した!", "You summon monsters!"));
934 for (k = 0; k < 6; k++)
935 summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_NONE, (mode | u_mode));
938 case RF_ABILITY::S_ANT: {
940 if (!target_set(caster_ptr, TARGET_KILL))
942 msg_print(_("アリを召喚した。", "You summon ants."));
943 for (k = 0; k < 6; k++)
944 summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_ANT, mode);
947 case RF_ABILITY::S_SPIDER: {
949 if (!target_set(caster_ptr, TARGET_KILL))
951 msg_print(_("蜘蛛を召喚した。", "You summon spiders."));
952 for (k = 0; k < 6; k++)
953 summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_SPIDER, mode);
956 case RF_ABILITY::S_HOUND: {
958 if (!target_set(caster_ptr, TARGET_KILL))
960 msg_print(_("ハウンドを召喚した。", "You summon hounds."));
961 for (k = 0; k < 4; k++)
962 summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_HOUND, mode);
965 case RF_ABILITY::S_HYDRA: {
967 if (!target_set(caster_ptr, TARGET_KILL))
969 msg_print(_("ヒドラを召喚した。", "You summon hydras."));
970 for (k = 0; k < 4; k++)
971 summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_HYDRA, mode);
974 case RF_ABILITY::S_ANGEL: {
976 if (!target_set(caster_ptr, TARGET_KILL))
978 msg_print(_("天使を召喚した!", "You summon an angel!"));
979 for (k = 0; k < 1; k++)
980 summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_ANGEL, mode);
983 case RF_ABILITY::S_DEMON: {
985 if (!target_set(caster_ptr, TARGET_KILL))
987 msg_print(_("混沌の宮廷から悪魔を召喚した!", "You summon a demon from the Courts of Chaos!"));
988 for (k = 0; k < 1; k++)
989 summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_DEMON, (mode | u_mode));
992 case RF_ABILITY::S_UNDEAD: {
994 if (!target_set(caster_ptr, TARGET_KILL))
996 msg_print(_("アンデッドの強敵を召喚した!", "You summon an undead adversary!"));
997 for (k = 0; k < 1; k++)
998 summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_UNDEAD, (mode | u_mode));
1001 case RF_ABILITY::S_DRAGON: {
1003 if (!target_set(caster_ptr, TARGET_KILL))
1005 msg_print(_("ドラゴンを召喚した!", "You summon a dragon!"));
1006 for (k = 0; k < 1; k++)
1007 summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_DRAGON, (mode | u_mode));
1010 case RF_ABILITY::S_HI_UNDEAD: {
1012 if (!target_set(caster_ptr, TARGET_KILL))
1014 msg_print(_("強力なアンデッドを召喚した!", "You summon greater undead!"));
1015 for (k = 0; k < 6; k++)
1016 summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_HI_UNDEAD, (mode | u_mode));
1019 case RF_ABILITY::S_HI_DRAGON: {
1021 if (!target_set(caster_ptr, TARGET_KILL))
1023 msg_print(_("古代ドラゴンを召喚した!", "You summon ancient dragons!"));
1024 for (k = 0; k < 4; k++)
1025 summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_HI_DRAGON, (mode | u_mode));
1028 case RF_ABILITY::S_AMBERITES: {
1030 if (!target_set(caster_ptr, TARGET_KILL))
1032 msg_print(_("アンバーの王族を召喚した!", "You summon Lords of Amber!"));
1033 for (k = 0; k < 4; k++)
1034 summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_AMBERITES, (mode | PM_ALLOW_UNIQUE));
1037 case RF_ABILITY::S_UNIQUE: {
1039 if (!target_set(caster_ptr, TARGET_KILL))
1041 msg_print(_("特別な強敵を召喚した!", "You summon special opponents!"));
1042 for (k = 0; k < 4; k++)
1043 if (summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_UNIQUE, (mode | PM_ALLOW_UNIQUE)))
1045 for (k = count; k < 4; k++)
1046 summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_HI_UNDEAD, (mode | u_mode));
1057 * @brief ものまねコマンドのメインルーチン /
1058 * do_cmd_cast calls this function if the player's class is 'imitator'.
1059 * @param baigaesi TRUEならば倍返し上の処理として行う
1060 * @return 処理を実行したらTRUE、キャンセルした場合FALSEを返す。
1062 * If a valid spell is chosen, saves it in '*sn' and returns TRUE
1063 * If the user hits escape, returns FALSE, and set '*sn' to -1
1064 * If there are no legal choices, returns FALSE, and sets '*sn' to -2
1066 * The "prompt" should be "cast", "recite", or "study"
1067 * The "known" should be TRUE for cast/pray, FALSE for study
1069 * nb: This function has a (trivial) display bug which will be obvious
1070 * when you run it. It's probably easy to fix but I haven't tried,
1073 bool do_cmd_mane(player_type *creature_ptr, bool baigaesi)
1077 PERCENTAGE minfail = 0;
1078 PLAYER_LEVEL plev = creature_ptr->lev;
1079 monster_power spell;
1082 if (cmd_limit_confused(creature_ptr))
1085 if (!creature_ptr->mane_num) {
1086 msg_print(_("まねられるものが何もない!", "You don't remember any action!"));
1090 if (!get_mane_power(creature_ptr, &n, baigaesi))
1093 spell = monster_powers[static_cast<int>(creature_ptr->mane_spell[n])];
1095 /* Spell failure chance */
1096 chance = spell.manefail;
1098 /* Reduce failure rate by "effective" level adjustment */
1099 if (plev > spell.level)
1100 chance -= 3 * (plev - spell.level);
1102 /* Reduce failure rate by 1 stat and DEX adjustment */
1103 chance -= 3 * (adj_mag_stat[creature_ptr->stat_index[spell.use_stat]] + adj_mag_stat[creature_ptr->stat_index[A_DEX]] - 2) / 2;
1106 chance = chance * damage / spell.manedam;
1108 chance += creature_ptr->to_m_chance;
1110 /* Extract the minimum failure rate */
1111 minfail = adj_mag_fail[creature_ptr->stat_index[spell.use_stat]];
1113 /* Minimum failure rate */
1114 if (chance < minfail)
1117 /* Stunning makes spells harder */
1118 if (creature_ptr->stun > 50)
1120 else if (creature_ptr->stun)
1123 /* Always a 5 percent chance of working */
1128 if (randint0(100) < chance) {
1131 msg_print(_("ものまねに失敗した!", "You failed to concentrate hard enough!"));
1135 cast = use_mane(creature_ptr, creature_ptr->mane_spell[n]);
1140 creature_ptr->mane_num--;
1141 for (j = n; j < creature_ptr->mane_num; j++) {
1142 creature_ptr->mane_spell[j] = creature_ptr->mane_spell[j + 1];
1143 creature_ptr->mane_dam[j] = creature_ptr->mane_dam[j + 1];
1146 PlayerEnergy(creature_ptr).set_player_turn_energy(100);
1148 creature_ptr->redraw |= (PR_IMITATION);
1149 creature_ptr->window_flags |= (PW_PLAYER);
1150 creature_ptr->window_flags |= (PW_SPELL);