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 "cmd-action/cmd-spell.h"
14 #include "core/asking-player.h"
15 #include "core/player-redraw-types.h"
16 #include "core/stuff-handler.h"
17 #include "core/window-redrawer.h"
18 #include "floor/cave.h"
19 #include "floor/floor-object.h"
20 #include "game-option/disturbance-options.h"
21 #include "game-option/text-display-options.h"
22 #include "grid/grid.h"
23 #include "hpmp/hp-mp-processor.h"
24 #include "main/sound-definitions-table.h"
25 #include "main/sound-of-music.h"
26 #include "mind/mind-mage.h"
27 #include "monster-floor/monster-summon.h"
28 #include "monster-floor/place-monster-types.h"
29 #include "monster-race/monster-race.h"
30 #include "monster-race/race-ability-flags.h"
31 #include "monster-race/race-flags-resistance.h"
32 #include "monster-race/race-flags1.h"
33 #include "monster/monster-describer.h"
34 #include "monster/monster-info.h"
35 #include "monster/monster-processor.h"
36 #include "monster/monster-status.h"
37 #include "mspell/monster-power-table.h"
38 #include "player-status/player-energy.h"
39 #include "player/player-status-table.h"
40 #include "spell-kind/spells-launcher.h"
41 #include "spell-kind/spells-lite.h"
42 #include "spell-kind/spells-neighbor.h"
43 #include "spell-kind/spells-sight.h"
44 #include "spell-kind/spells-teleport.h"
45 #include "spell-kind/spells-world.h"
46 #include "spell/spell-types.h"
47 #include "spell/spells-status.h"
48 #include "spell/spells-summon.h"
49 #include "spell/summon-types.h"
50 #include "status/bad-status-setter.h"
51 #include "status/body-improvement.h"
52 #include "status/buff-setter.h"
53 #include "system/floor-type-definition.h"
54 #include "system/monster-race-definition.h"
55 #include "system/monster-type-definition.h"
56 #include "system/player-type-definition.h"
57 #include "target/projection-path-calculator.h"
58 #include "target/target-checker.h"
59 #include "target/target-getter.h"
60 #include "target/target-setter.h"
61 #include "target/target-types.h"
62 #include "term/screen-processor.h"
63 #include "util/int-char-converter.h"
64 #include "view/display-messages.h"
69 * @brief 受け取ったパラメータに応じてものまねの効果情報をまとめたフォーマットを返す
70 * @param p 情報を返す文字列参照ポインタ
71 * @param power ものまねの効力の種類
74 static void mane_info(player_type *caster_ptr, char *p, RF_ABILITY power, HIT_POINT dam)
76 PLAYER_LEVEL plev = caster_ptr->lev;
80 const auto power_int = static_cast<int>(power);
82 if ((power_int > 2 && power_int < 41) || (power_int > 41 && power_int < 59) || (power == RF_ABILITY::PSY_SPEAR))
83 sprintf(p, " %s%d", KWD_DAM, (int)dam);
86 case RF_ABILITY::DRAIN_MANA:
87 sprintf(p, " %sd%d+%d", KWD_HEAL, plev * 3, plev);
89 case RF_ABILITY::HASTE:
90 sprintf(p, " %sd%d+%d", KWD_DURATION, 20 + plev, plev);
92 case RF_ABILITY::HEAL:
93 sprintf(p, " %s%d", KWD_HEAL, plev * 6);
95 case RF_ABILITY::INVULNER:
96 sprintf(p, " %sd7+7", KWD_DURATION);
98 case RF_ABILITY::BLINK:
99 sprintf(p, " %s10", KWD_SPHERE);
101 case RF_ABILITY::TPORT:
102 sprintf(p, " %s%d", KWD_SPHERE, plev * 5);
104 case RF_ABILITY::RAISE_DEAD:
105 sprintf(p, " %s5", KWD_SPHERE);
114 * @brief どのものまねを発動するか選択する処理 /
115 * Allow user to choose a imitation.
116 * @param sn 実行したものまねのIDを返す参照ポインタ(キャンセルなどの場合-1を返す)
117 * @param baigaesi TRUEならば倍返し上の処理として行う
118 * @return 処理を実行したらTRUE、キャンセルした場合FALSEを返す。
120 * If a valid spell is chosen, saves it in '*sn' and returns TRUE
121 * If the user hits escape, returns FALSE, and set '*sn' to -1
122 * If there are no legal choices, returns FALSE, and sets '*sn' to -2
124 * The "prompt" should be "cast", "recite", or "study"
125 * The "known" should be TRUE for cast/pray, FALSE for study
127 * nb: This function has a (trivial) display bug which will be obvious
128 * when you run it. It's probably easy to fix but I haven't tried,
131 static int get_mane_power(player_type *caster_ptr, int *sn, bool baigaesi)
137 PERCENTAGE minfail = 0;
138 PLAYER_LEVEL plev = caster_ptr->lev;
139 PERCENTAGE chance = 0;
142 char out_val[MAX_MONSTER_NAME];
144 concptr p = _("能力", "power");
149 /* Assume cancelled */
155 num = caster_ptr->mane_num;
157 /* Build a prompt (accept all spells) */
158 (void)strnfmt(out_val, 78, _("(%c-%c, '*'で一覧, ESC) どの%sをまねますか?", "(%c-%c, *=List, ESC=exit) Use which %s? "), I2A(0), I2A(num - 1), p);
160 choice = always_show_list ? ESCAPE : 1;
162 if (choice == ESCAPE)
164 else if (!get_com(out_val, &choice, TRUE))
168 if ((choice == ' ') || (choice == '*') || (choice == '?')) {
175 /* Display a list of spells */
177 put_str(_("名前", "Name"), y, x + 5);
178 put_str(_("失率 効果", "Fail Info"), y, x + 36);
180 /* Dump the spells */
181 for (i = 0; i < num; i++) {
182 /* Access the spell */
183 spell = monster_powers[static_cast<size_t>(caster_ptr->mane_spell[i])];
185 chance = spell.manefail;
187 /* Reduce failure rate by "effective" level adjustment */
188 if (plev > spell.level)
189 chance -= 3 * (plev - spell.level);
191 /* Reduce failure rate by INT/WIS adjustment */
192 chance -= 3 * (adj_mag_stat[caster_ptr->stat_index[spell.use_stat]] + adj_mag_stat[caster_ptr->stat_index[A_DEX]] - 2) / 2;
195 chance = chance * (baigaesi ? caster_ptr->mane_dam[i] * 2 : caster_ptr->mane_dam[i]) / spell.manedam;
197 chance += caster_ptr->to_m_chance;
199 /* Extract the minimum failure rate */
200 minfail = adj_mag_fail[caster_ptr->stat_index[spell.use_stat]];
202 /* Minimum failure rate */
203 if (chance < minfail)
206 /* Stunning makes spells harder */
207 if (caster_ptr->stun > 50)
209 else if (caster_ptr->stun)
212 /* Always a 5 percent chance of working */
217 mane_info(caster_ptr, comment, caster_ptr->mane_spell[i], (baigaesi ? caster_ptr->mane_dam[i] * 2 : caster_ptr->mane_dam[i]));
219 /* Dump the spell --(-- */
220 sprintf(psi_desc, " %c) %-30s %3d%%%s", I2A(i), spell.name, chance, comment);
221 prt(psi_desc, y + i + 1, x);
224 /* Clear the bottom line */
225 prt("", y + i + 1, x);
240 ask = isupper(choice);
244 choice = (char)tolower(choice);
246 /* Extract request */
247 i = (islower(choice) ? A2I(choice) : -1);
249 /* Totally Illegal */
250 if ((i < 0) || (i >= num)) {
255 /* Save the spell index */
256 spell = monster_powers[static_cast<int>(caster_ptr->mane_spell[i])];
263 (void)strnfmt(tmp_val, 78, _("%sをまねますか?", "Use %s? "), spell.name);
265 /* Belay that order */
266 if (!get_check(tmp_val))
276 caster_ptr->window_flags |= (PW_SPELL);
277 handle_stuff(caster_ptr);
279 /* Abort if needed */
283 /* Save the choice */
286 damage = (baigaesi ? caster_ptr->mane_dam[i] * 2 : caster_ptr->mane_dam[i]);
294 * do_cmd_cast calls this function if the player's class is 'imitator'.
295 * @param caster_ptr プレーヤーへの参照ポインタ
296 * @param spell 発動するモンスター攻撃のID
297 * @return 処理を実行したらTRUE、キャンセルした場合FALSEを返す。
299 static bool use_mane(player_type *caster_ptr, RF_ABILITY spell)
302 PLAYER_LEVEL plev = caster_ptr->lev;
303 BIT_FLAGS mode = (PM_ALLOW_GROUP | PM_FORCE_PET);
304 BIT_FLAGS u_mode = 0L;
306 if (randint1(50 + plev) < plev / 10)
307 u_mode = PM_ALLOW_UNIQUE;
311 case RF_ABILITY::SHRIEK:
312 msg_print(_("かん高い金切り声をあげた。", "You make a high pitched shriek."));
313 aggravate_monsters(caster_ptr, 0);
316 case RF_ABILITY::XXX1:
319 case RF_ABILITY::DISPEL: {
322 if (!target_set(caster_ptr, TARGET_KILL))
324 m_idx = caster_ptr->current_floor_ptr->grid_array[target_row][target_col].m_idx;
327 if (!player_has_los_bold(caster_ptr, target_row, target_col))
329 if (!projectable(caster_ptr, caster_ptr->y, caster_ptr->x, target_row, target_col))
331 dispel_monster_status(caster_ptr, m_idx);
335 case RF_ABILITY::ROCKET:
336 if (!get_aim_dir(caster_ptr, &dir))
339 msg_print(_("ロケットを発射した。", "You fire a rocket."));
340 fire_rocket(caster_ptr, GF_ROCKET, dir, damage, 2);
343 case RF_ABILITY::SHOOT:
344 if (!get_aim_dir(caster_ptr, &dir))
347 msg_print(_("矢を放った。", "You fire an arrow."));
348 fire_bolt(caster_ptr, GF_ARROW, dir, damage);
351 case RF_ABILITY::XXX2:
354 case RF_ABILITY::XXX3:
357 case RF_ABILITY::XXX4:
360 case RF_ABILITY::BR_ACID:
361 if (!get_aim_dir(caster_ptr, &dir))
364 msg_print(_("酸のブレスを吐いた。", "You breathe acid."));
365 fire_breath(caster_ptr, GF_ACID, dir, damage, (plev > 35 ? 3 : 2));
368 case RF_ABILITY::BR_ELEC:
369 if (!get_aim_dir(caster_ptr, &dir))
372 msg_print(_("稲妻のブレスを吐いた。", "You breathe lightning."));
373 fire_breath(caster_ptr, GF_ELEC, dir, damage, (plev > 35 ? 3 : 2));
376 case RF_ABILITY::BR_FIRE:
377 if (!get_aim_dir(caster_ptr, &dir))
380 msg_print(_("火炎のブレスを吐いた。", "You breathe fire."));
381 fire_breath(caster_ptr, GF_FIRE, dir, damage, (plev > 35 ? 3 : 2));
384 case RF_ABILITY::BR_COLD:
385 if (!get_aim_dir(caster_ptr, &dir))
388 msg_print(_("冷気のブレスを吐いた。", "You breathe frost."));
389 fire_breath(caster_ptr, GF_COLD, dir, damage, (plev > 35 ? 3 : 2));
392 case RF_ABILITY::BR_POIS:
393 if (!get_aim_dir(caster_ptr, &dir))
396 msg_print(_("ガスのブレスを吐いた。", "You breathe gas."));
397 fire_breath(caster_ptr, GF_POIS, dir, damage, (plev > 35 ? 3 : 2));
400 case RF_ABILITY::BR_NETH:
401 if (!get_aim_dir(caster_ptr, &dir))
404 msg_print(_("地獄のブレスを吐いた。", "You breathe nether."));
405 fire_breath(caster_ptr, GF_NETHER, dir, damage, (plev > 35 ? 3 : 2));
408 case RF_ABILITY::BR_LITE:
409 if (!get_aim_dir(caster_ptr, &dir))
412 msg_print(_("閃光のブレスを吐いた。", "You breathe light."));
413 fire_breath(caster_ptr, GF_LITE, dir, damage, (plev > 35 ? 3 : 2));
416 case RF_ABILITY::BR_DARK:
417 if (!get_aim_dir(caster_ptr, &dir))
420 msg_print(_("暗黒のブレスを吐いた。", "You breathe darkness."));
421 fire_breath(caster_ptr, GF_DARK, dir, damage, (plev > 35 ? 3 : 2));
424 case RF_ABILITY::BR_CONF:
425 if (!get_aim_dir(caster_ptr, &dir))
428 msg_print(_("混乱のブレスを吐いた。", "You breathe confusion."));
429 fire_breath(caster_ptr, GF_CONFUSION, dir, damage, (plev > 35 ? 3 : 2));
432 case RF_ABILITY::BR_SOUN:
433 if (!get_aim_dir(caster_ptr, &dir))
436 msg_print(_("轟音のブレスを吐いた。", "You breathe sound."));
437 fire_breath(caster_ptr, GF_SOUND, dir, damage, (plev > 35 ? 3 : 2));
440 case RF_ABILITY::BR_CHAO:
441 if (!get_aim_dir(caster_ptr, &dir))
444 msg_print(_("カオスのブレスを吐いた。", "You breathe chaos."));
445 fire_breath(caster_ptr, GF_CHAOS, dir, damage, (plev > 35 ? 3 : 2));
448 case RF_ABILITY::BR_DISE:
449 if (!get_aim_dir(caster_ptr, &dir))
452 msg_print(_("劣化のブレスを吐いた。", "You breathe disenchantment."));
453 fire_breath(caster_ptr, GF_DISENCHANT, dir, damage, (plev > 35 ? 3 : 2));
456 case RF_ABILITY::BR_NEXU:
457 if (!get_aim_dir(caster_ptr, &dir))
460 msg_print(_("因果混乱のブレスを吐いた。", "You breathe nexus."));
461 fire_breath(caster_ptr, GF_NEXUS, dir, damage, (plev > 35 ? 3 : 2));
464 case RF_ABILITY::BR_TIME:
465 if (!get_aim_dir(caster_ptr, &dir))
468 msg_print(_("時間逆転のブレスを吐いた。", "You breathe time."));
469 fire_breath(caster_ptr, GF_TIME, dir, damage, (plev > 35 ? 3 : 2));
472 case RF_ABILITY::BR_INER:
473 if (!get_aim_dir(caster_ptr, &dir))
476 msg_print(_("遅鈍のブレスを吐いた。", "You breathe inertia."));
477 fire_breath(caster_ptr, GF_INERTIAL, dir, damage, (plev > 35 ? 3 : 2));
480 case RF_ABILITY::BR_GRAV:
481 if (!get_aim_dir(caster_ptr, &dir))
484 msg_print(_("重力のブレスを吐いた。", "You breathe gravity."));
485 fire_breath(caster_ptr, GF_GRAVITY, dir, damage, (plev > 35 ? 3 : 2));
488 case RF_ABILITY::BR_SHAR:
489 if (!get_aim_dir(caster_ptr, &dir))
492 msg_print(_("破片のブレスを吐いた。", "You breathe shards."));
493 fire_breath(caster_ptr, GF_SHARDS, dir, damage, (plev > 35 ? 3 : 2));
496 case RF_ABILITY::BR_PLAS:
497 if (!get_aim_dir(caster_ptr, &dir))
500 msg_print(_("プラズマのブレスを吐いた。", "You breathe plasma."));
502 fire_breath(caster_ptr, GF_PLASMA, dir, damage, (plev > 35 ? 3 : 2));
505 case RF_ABILITY::BR_FORC:
506 if (!get_aim_dir(caster_ptr, &dir))
509 msg_print(_("フォースのブレスを吐いた。", "You breathe force."));
511 fire_breath(caster_ptr, GF_FORCE, dir, damage, (plev > 35 ? 3 : 2));
514 case RF_ABILITY::BR_MANA:
515 if (!get_aim_dir(caster_ptr, &dir))
518 msg_print(_("魔力のブレスを吐いた。", "You breathe mana."));
520 fire_breath(caster_ptr, GF_MANA, dir, damage, (plev > 35 ? 3 : 2));
523 case RF_ABILITY::BA_NUKE:
524 if (!get_aim_dir(caster_ptr, &dir))
527 msg_print(_("放射能球を放った。", "You cast a ball of radiation."));
529 fire_ball(caster_ptr, GF_NUKE, dir, damage, 2);
532 case RF_ABILITY::BR_NUKE:
533 if (!get_aim_dir(caster_ptr, &dir))
536 msg_print(_("放射性廃棄物のブレスを吐いた。", "You breathe toxic waste."));
538 fire_breath(caster_ptr, GF_NUKE, dir, damage, (plev > 35 ? 3 : 2));
541 case RF_ABILITY::BA_CHAO:
542 if (!get_aim_dir(caster_ptr, &dir))
545 msg_print(_("純ログルスを放った。", "You invoke a raw Logrus."));
547 fire_ball(caster_ptr, GF_CHAOS, dir, damage, 4);
549 case RF_ABILITY::BR_DISI:
550 if (!get_aim_dir(caster_ptr, &dir))
553 msg_print(_("分解のブレスを吐いた。", "You breathe disintegration."));
555 fire_breath(caster_ptr, GF_DISINTEGRATE, dir, damage, (plev > 35 ? 3 : 2));
557 case RF_ABILITY::BA_ACID:
558 if (!get_aim_dir(caster_ptr, &dir))
561 msg_print(_("アシッド・ボールの呪文を唱えた。", "You cast an acid ball."));
563 fire_ball(caster_ptr, GF_ACID, dir, damage, 2);
565 case RF_ABILITY::BA_ELEC:
566 if (!get_aim_dir(caster_ptr, &dir))
569 msg_print(_("サンダー・ボールの呪文を唱えた。", "You cast a lightning ball."));
571 fire_ball(caster_ptr, GF_ELEC, dir, damage, 2);
573 case RF_ABILITY::BA_FIRE:
574 if (!get_aim_dir(caster_ptr, &dir))
577 msg_print(_("ファイア・ボールの呪文を唱えた。", "You cast a fire ball."));
579 fire_ball(caster_ptr, GF_FIRE, dir, damage, 2);
581 case RF_ABILITY::BA_COLD:
582 if (!get_aim_dir(caster_ptr, &dir))
585 msg_print(_("アイス・ボールの呪文を唱えた。", "You cast a frost ball."));
587 fire_ball(caster_ptr, GF_COLD, dir, damage, 2);
589 case RF_ABILITY::BA_POIS:
590 if (!get_aim_dir(caster_ptr, &dir))
593 msg_print(_("悪臭雲の呪文を唱えた。", "You cast a stinking cloud."));
595 fire_ball(caster_ptr, GF_POIS, dir, damage, 2);
597 case RF_ABILITY::BA_NETH:
598 if (!get_aim_dir(caster_ptr, &dir))
601 msg_print(_("地獄球の呪文を唱えた。", "You cast a nether ball."));
603 fire_ball(caster_ptr, GF_NETHER, dir, damage, 2);
605 case RF_ABILITY::BA_WATE:
606 if (!get_aim_dir(caster_ptr, &dir))
609 msg_print(_("流れるような身振りをした。", "You gesture fluidly."));
611 fire_ball(caster_ptr, GF_WATER, dir, damage, 4);
613 case RF_ABILITY::BA_MANA:
614 if (!get_aim_dir(caster_ptr, &dir))
617 msg_print(_("魔力の嵐の呪文を念じた。", "You invoke a mana storm."));
619 fire_ball(caster_ptr, GF_MANA, dir, damage, 4);
621 case RF_ABILITY::BA_DARK:
622 if (!get_aim_dir(caster_ptr, &dir))
625 msg_print(_("暗黒の嵐の呪文を念じた。", "You invoke a darkness storm."));
627 fire_ball(caster_ptr, GF_DARK, dir, damage, 4);
629 case RF_ABILITY::DRAIN_MANA:
630 if (!get_aim_dir(caster_ptr, &dir))
632 fire_ball_hide(caster_ptr, GF_DRAIN_MANA, dir, randint1(plev * 3) + plev, 0);
634 case RF_ABILITY::MIND_BLAST:
635 if (!get_aim_dir(caster_ptr, &dir))
637 fire_ball_hide(caster_ptr, GF_MIND_BLAST, dir, damage, 0);
639 case RF_ABILITY::BRAIN_SMASH:
640 if (!get_aim_dir(caster_ptr, &dir))
642 fire_ball_hide(caster_ptr, GF_BRAIN_SMASH, dir, damage, 0);
644 case RF_ABILITY::CAUSE_1:
645 if (!get_aim_dir(caster_ptr, &dir))
647 fire_ball_hide(caster_ptr, GF_CAUSE_1, dir, damage, 0);
649 case RF_ABILITY::CAUSE_2:
650 if (!get_aim_dir(caster_ptr, &dir))
652 fire_ball_hide(caster_ptr, GF_CAUSE_2, dir, damage, 0);
654 case RF_ABILITY::CAUSE_3:
655 if (!get_aim_dir(caster_ptr, &dir))
657 fire_ball_hide(caster_ptr, GF_CAUSE_3, dir, damage, 0);
659 case RF_ABILITY::CAUSE_4:
660 if (!get_aim_dir(caster_ptr, &dir))
662 fire_ball_hide(caster_ptr, GF_CAUSE_4, dir, damage, 0);
664 case RF_ABILITY::BO_ACID:
665 if (!get_aim_dir(caster_ptr, &dir))
668 msg_print(_("アシッド・ボルトの呪文を唱えた。", "You cast an acid bolt."));
670 fire_bolt(caster_ptr, GF_ACID, dir, damage);
672 case RF_ABILITY::BO_ELEC:
673 if (!get_aim_dir(caster_ptr, &dir))
676 msg_print(_("サンダー・ボルトの呪文を唱えた。", "You cast a lightning bolt."));
678 fire_bolt(caster_ptr, GF_ELEC, dir, damage);
680 case RF_ABILITY::BO_FIRE:
681 if (!get_aim_dir(caster_ptr, &dir))
684 msg_print(_("ファイア・ボルトの呪文を唱えた。", "You cast a fire bolt."));
686 fire_bolt(caster_ptr, GF_FIRE, dir, damage);
688 case RF_ABILITY::BO_COLD:
689 if (!get_aim_dir(caster_ptr, &dir))
692 msg_print(_("アイス・ボルトの呪文を唱えた。", "You cast a frost bolt."));
694 fire_bolt(caster_ptr, GF_COLD, dir, damage);
696 case RF_ABILITY::BA_LITE:
697 if (!get_aim_dir(caster_ptr, &dir))
700 msg_print(_("スターバーストの呪文を念じた。", "You invoke a starburst."));
702 fire_ball(caster_ptr, GF_LITE, dir, damage, 4);
704 case RF_ABILITY::BO_NETH:
705 if (!get_aim_dir(caster_ptr, &dir))
708 msg_print(_("地獄の矢の呪文を唱えた。", "You cast a nether bolt."));
710 fire_bolt(caster_ptr, GF_NETHER, dir, damage);
712 case RF_ABILITY::BO_WATE:
713 if (!get_aim_dir(caster_ptr, &dir))
716 msg_print(_("ウォーター・ボルトの呪文を唱えた。", "You cast a water bolt."));
718 fire_bolt(caster_ptr, GF_WATER, dir, damage);
720 case RF_ABILITY::BO_MANA:
721 if (!get_aim_dir(caster_ptr, &dir))
724 msg_print(_("魔力の矢の呪文を唱えた。", "You cast a mana bolt."));
726 fire_bolt(caster_ptr, GF_MANA, dir, damage);
728 case RF_ABILITY::BO_PLAS:
729 if (!get_aim_dir(caster_ptr, &dir))
732 msg_print(_("プラズマ・ボルトの呪文を唱えた。", "You cast a plasma bolt."));
734 fire_bolt(caster_ptr, GF_PLASMA, dir, damage);
736 case RF_ABILITY::BO_ICEE:
737 if (!get_aim_dir(caster_ptr, &dir))
740 msg_print(_("極寒の矢の呪文を唱えた。", "You cast a ice bolt."));
742 fire_bolt(caster_ptr, GF_ICE, dir, damage);
744 case RF_ABILITY::MISSILE:
745 if (!get_aim_dir(caster_ptr, &dir))
748 msg_print(_("マジック・ミサイルの呪文を唱えた。", "You cast a magic missile."));
750 fire_bolt(caster_ptr, GF_MISSILE, dir, damage);
752 case RF_ABILITY::SCARE:
753 if (!get_aim_dir(caster_ptr, &dir))
756 msg_print(_("恐ろしげな幻覚を作り出した。", "You cast a fearful illusion."));
758 fear_monster(caster_ptr, dir, plev + 10);
760 case RF_ABILITY::BLIND:
761 if (!get_aim_dir(caster_ptr, &dir))
763 confuse_monster(caster_ptr, dir, plev * 2);
765 case RF_ABILITY::CONF:
766 if (!get_aim_dir(caster_ptr, &dir))
769 msg_print(_("誘惑的な幻覚をつくり出した。", "You cast a mesmerizing illusion."));
771 confuse_monster(caster_ptr, dir, plev * 2);
773 case RF_ABILITY::SLOW:
774 if (!get_aim_dir(caster_ptr, &dir))
776 slow_monster(caster_ptr, dir, plev);
778 case RF_ABILITY::HOLD:
779 if (!get_aim_dir(caster_ptr, &dir))
781 sleep_monster(caster_ptr, dir, plev);
783 case RF_ABILITY::HASTE:
784 (void)set_fast(caster_ptr, randint1(20 + plev) + plev, FALSE);
786 case RF_ABILITY::HAND_DOOM: {
787 if (!get_aim_dir(caster_ptr, &dir))
790 msg_print(_("<破滅の手>を放った!", "You invoke the Hand of Doom!"));
792 fire_ball_hide(caster_ptr, GF_HAND_DOOM, dir, 200, 0);
795 case RF_ABILITY::HEAL:
796 msg_print(_("自分の傷に念を集中した。", "You concentrate on your wounds!"));
797 (void)hp_player(caster_ptr, plev * 6);
798 (void)set_stun(caster_ptr, 0);
799 (void)set_cut(caster_ptr, 0);
801 case RF_ABILITY::INVULNER:
802 msg_print(_("無傷の球の呪文を唱えた。", "You cast a Globe of Invulnerability."));
803 (void)set_invuln(caster_ptr, randint1(7) + 7, FALSE);
805 case RF_ABILITY::BLINK:
806 teleport_player(caster_ptr, 10, TELEPORT_SPONTANEOUS);
808 case RF_ABILITY::TPORT:
809 teleport_player(caster_ptr, plev * 5, TELEPORT_SPONTANEOUS);
811 case RF_ABILITY::WORLD:
812 (void)time_walk(caster_ptr);
814 case RF_ABILITY::SPECIAL:
816 case RF_ABILITY::TELE_TO: {
819 GAME_TEXT m_name[MAX_NLEN];
821 if (!target_set(caster_ptr, TARGET_KILL))
823 if (!caster_ptr->current_floor_ptr->grid_array[target_row][target_col].m_idx)
825 if (!player_has_los_bold(caster_ptr, target_row, target_col))
827 if (!projectable(caster_ptr, caster_ptr->y, caster_ptr->x, target_row, target_col))
829 m_ptr = &caster_ptr->current_floor_ptr->m_list[caster_ptr->current_floor_ptr->grid_array[target_row][target_col].m_idx];
830 r_ptr = &r_info[m_ptr->r_idx];
831 monster_desc(caster_ptr, m_name, m_ptr, 0);
832 if (r_ptr->flagsr & RFR_RES_TELE) {
833 if ((r_ptr->flags1 & (RF1_UNIQUE)) || (r_ptr->flagsr & RFR_RES_ALL)) {
834 if (is_original_ap_and_seen(caster_ptr, m_ptr))
835 r_ptr->r_flagsr |= RFR_RES_TELE;
836 msg_format(_("%sには効果がなかった!", "%s is unaffected!"), m_name);
839 } else if (r_ptr->level > randint1(100)) {
840 if (is_original_ap_and_seen(caster_ptr, m_ptr))
841 r_ptr->r_flagsr |= RFR_RES_TELE;
842 msg_format(_("%sには耐性がある!", "%s resists!"), m_name);
847 msg_format(_("%sを引き戻した。", "You command %s to return."), m_name);
850 caster_ptr, caster_ptr->current_floor_ptr->grid_array[target_row][target_col].m_idx, caster_ptr->y, caster_ptr->x, 100, TELEPORT_PASSIVE);
853 case RF_ABILITY::TELE_AWAY:
854 if (!get_aim_dir(caster_ptr, &dir))
857 (void)fire_beam(caster_ptr, GF_AWAY_ALL, dir, plev);
860 case RF_ABILITY::TELE_LEVEL:
861 return teleport_level_other(caster_ptr);
864 case RF_ABILITY::PSY_SPEAR:
865 if (!get_aim_dir(caster_ptr, &dir))
868 msg_print(_("光の剣を放った。", "You throw a psycho-spear."));
869 (void)fire_beam(caster_ptr, GF_PSY_SPEAR, dir, damage);
872 case RF_ABILITY::DARKNESS:
873 msg_print(_("暗闇の中で手を振った。", "You gesture in shadow."));
874 (void)unlite_area(caster_ptr, 10, 3);
877 case RF_ABILITY::TRAPS:
878 if (!target_set(caster_ptr, TARGET_KILL))
880 msg_print(_("呪文を唱えて邪悪に微笑んだ。", "You cast a spell and cackle evilly."));
881 trap_creation(caster_ptr, target_row, target_col);
883 case RF_ABILITY::FORGET:
884 msg_print(_("しかし何も起きなかった。", "Nothing happens."));
886 case RF_ABILITY::RAISE_DEAD:
887 msg_print(_("死者復活の呪文を唱えた。", "You animate the dead."));
888 (void)animate_dead(caster_ptr, 0, caster_ptr->y, caster_ptr->x);
890 case RF_ABILITY::S_KIN: {
892 if (!target_set(caster_ptr, TARGET_KILL))
895 msg_print(_("援軍を召喚した。", "You summon minions."));
896 for (k = 0; k < 4; k++) {
897 (void)summon_kin_player(caster_ptr, plev, target_row, target_col, (PM_FORCE_PET | PM_ALLOW_GROUP));
901 case RF_ABILITY::S_CYBER: {
903 int max_cyber = (caster_ptr->current_floor_ptr->dun_level / 50) + randint1(3);
904 if (!target_set(caster_ptr, TARGET_KILL))
906 msg_print(_("サイバーデーモンを召喚した!", "You summon Cyberdemons!"));
909 for (k = 0; k < max_cyber; k++)
910 summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_CYBER, mode);
913 case RF_ABILITY::S_MONSTER: {
915 if (!target_set(caster_ptr, TARGET_KILL))
917 msg_print(_("仲間を召喚した。", "You summon help."));
918 for (k = 0; k < 1; k++)
919 summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_NONE, (mode | u_mode));
922 case RF_ABILITY::S_MONSTERS: {
924 if (!target_set(caster_ptr, TARGET_KILL))
926 msg_print(_("モンスターを召喚した!", "You summon monsters!"));
927 for (k = 0; k < 6; k++)
928 summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_NONE, (mode | u_mode));
931 case RF_ABILITY::S_ANT: {
933 if (!target_set(caster_ptr, TARGET_KILL))
935 msg_print(_("アリを召喚した。", "You summon ants."));
936 for (k = 0; k < 6; k++)
937 summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_ANT, mode);
940 case RF_ABILITY::S_SPIDER: {
942 if (!target_set(caster_ptr, TARGET_KILL))
944 msg_print(_("蜘蛛を召喚した。", "You summon spiders."));
945 for (k = 0; k < 6; k++)
946 summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_SPIDER, mode);
949 case RF_ABILITY::S_HOUND: {
951 if (!target_set(caster_ptr, TARGET_KILL))
953 msg_print(_("ハウンドを召喚した。", "You summon hounds."));
954 for (k = 0; k < 4; k++)
955 summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_HOUND, mode);
958 case RF_ABILITY::S_HYDRA: {
960 if (!target_set(caster_ptr, TARGET_KILL))
962 msg_print(_("ヒドラを召喚した。", "You summon hydras."));
963 for (k = 0; k < 4; k++)
964 summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_HYDRA, mode);
967 case RF_ABILITY::S_ANGEL: {
969 if (!target_set(caster_ptr, TARGET_KILL))
971 msg_print(_("天使を召喚した!", "You summon an angel!"));
972 for (k = 0; k < 1; k++)
973 summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_ANGEL, mode);
976 case RF_ABILITY::S_DEMON: {
978 if (!target_set(caster_ptr, TARGET_KILL))
980 msg_print(_("混沌の宮廷から悪魔を召喚した!", "You summon a demon from the Courts of Chaos!"));
981 for (k = 0; k < 1; k++)
982 summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_DEMON, (mode | u_mode));
985 case RF_ABILITY::S_UNDEAD: {
987 if (!target_set(caster_ptr, TARGET_KILL))
989 msg_print(_("アンデッドの強敵を召喚した!", "You summon an undead adversary!"));
990 for (k = 0; k < 1; k++)
991 summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_UNDEAD, (mode | u_mode));
994 case RF_ABILITY::S_DRAGON: {
996 if (!target_set(caster_ptr, TARGET_KILL))
998 msg_print(_("ドラゴンを召喚した!", "You summon a dragon!"));
999 for (k = 0; k < 1; k++)
1000 summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_DRAGON, (mode | u_mode));
1003 case RF_ABILITY::S_HI_UNDEAD: {
1005 if (!target_set(caster_ptr, TARGET_KILL))
1007 msg_print(_("強力なアンデッドを召喚した!", "You summon greater undead!"));
1008 for (k = 0; k < 6; k++)
1009 summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_HI_UNDEAD, (mode | u_mode));
1012 case RF_ABILITY::S_HI_DRAGON: {
1014 if (!target_set(caster_ptr, TARGET_KILL))
1016 msg_print(_("古代ドラゴンを召喚した!", "You summon ancient dragons!"));
1017 for (k = 0; k < 4; k++)
1018 summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_HI_DRAGON, (mode | u_mode));
1021 case RF_ABILITY::S_AMBERITES: {
1023 if (!target_set(caster_ptr, TARGET_KILL))
1025 msg_print(_("アンバーの王族を召喚した!", "You summon Lords of Amber!"));
1026 for (k = 0; k < 4; k++)
1027 summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_AMBERITES, (mode | PM_ALLOW_UNIQUE));
1030 case RF_ABILITY::S_UNIQUE: {
1032 if (!target_set(caster_ptr, TARGET_KILL))
1034 msg_print(_("特別な強敵を召喚した!", "You summon special opponents!"));
1035 for (k = 0; k < 4; k++)
1036 if (summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_UNIQUE, (mode | PM_ALLOW_UNIQUE)))
1038 for (k = count; k < 4; k++)
1039 summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_HI_UNDEAD, (mode | u_mode));
1050 * @brief ものまねコマンドのメインルーチン /
1051 * do_cmd_cast calls this function if the player's class is 'imitator'.
1052 * @param baigaesi TRUEならば倍返し上の処理として行う
1053 * @return 処理を実行したらTRUE、キャンセルした場合FALSEを返す。
1055 * If a valid spell is chosen, saves it in '*sn' and returns TRUE
1056 * If the user hits escape, returns FALSE, and set '*sn' to -1
1057 * If there are no legal choices, returns FALSE, and sets '*sn' to -2
1059 * The "prompt" should be "cast", "recite", or "study"
1060 * The "known" should be TRUE for cast/pray, FALSE for study
1062 * nb: This function has a (trivial) display bug which will be obvious
1063 * when you run it. It's probably easy to fix but I haven't tried,
1066 bool do_cmd_mane(player_type *creature_ptr, bool baigaesi)
1070 PERCENTAGE minfail = 0;
1071 PLAYER_LEVEL plev = creature_ptr->lev;
1072 monster_power spell;
1075 if (cmd_limit_confused(creature_ptr))
1078 if (!creature_ptr->mane_num) {
1079 msg_print(_("まねられるものが何もない!", "You don't remember any action!"));
1083 if (!get_mane_power(creature_ptr, &n, baigaesi))
1086 spell = monster_powers[static_cast<int>(creature_ptr->mane_spell[n])];
1088 /* Spell failure chance */
1089 chance = spell.manefail;
1091 /* Reduce failure rate by "effective" level adjustment */
1092 if (plev > spell.level)
1093 chance -= 3 * (plev - spell.level);
1095 /* Reduce failure rate by 1 stat and DEX adjustment */
1096 chance -= 3 * (adj_mag_stat[creature_ptr->stat_index[spell.use_stat]] + adj_mag_stat[creature_ptr->stat_index[A_DEX]] - 2) / 2;
1099 chance = chance * damage / spell.manedam;
1101 chance += creature_ptr->to_m_chance;
1103 /* Extract the minimum failure rate */
1104 minfail = adj_mag_fail[creature_ptr->stat_index[spell.use_stat]];
1106 /* Minimum failure rate */
1107 if (chance < minfail)
1110 /* Stunning makes spells harder */
1111 if (creature_ptr->stun > 50)
1113 else if (creature_ptr->stun)
1116 /* Always a 5 percent chance of working */
1121 if (randint0(100) < chance) {
1124 msg_print(_("ものまねに失敗した!", "You failed to concentrate hard enough!"));
1128 cast = use_mane(creature_ptr, creature_ptr->mane_spell[n]);
1133 creature_ptr->mane_num--;
1134 for (j = n; j < creature_ptr->mane_num; j++) {
1135 creature_ptr->mane_spell[j] = creature_ptr->mane_spell[j + 1];
1136 creature_ptr->mane_dam[j] = creature_ptr->mane_dam[j + 1];
1139 PlayerEnergy(creature_ptr).set_player_turn_energy(100);
1141 creature_ptr->redraw |= (PR_IMITATION);
1142 creature_ptr->window_flags |= (PW_PLAYER);
1143 creature_ptr->window_flags |= (PW_SPELL);