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 "cmd-action/cmd-mane.h"
13 #include "action/action-limited.h"
14 #include "artifact/fixed-art-types.h"
15 #include "cmd-action/cmd-spell.h"
16 #include "core/asking-player.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 "hpmp/hp-mp-processor.h"
24 #include "inventory/inventory-slot-types.h"
25 #include "main/sound-definitions-table.h"
26 #include "main/sound-of-music.h"
27 #include "mind/mind-mage.h"
28 #include "monster-floor/monster-summon.h"
29 #include "monster-floor/place-monster-types.h"
30 #include "monster-race/monster-race.h"
31 #include "monster-race/race-ability-flags.h"
32 #include "monster-race/race-flags-resistance.h"
33 #include "monster-race/race-flags1.h"
34 #include "monster/monster-describer.h"
35 #include "monster/monster-info.h"
36 #include "monster/monster-processor.h"
37 #include "monster/monster-status.h"
38 #include "mspell/monster-power-table.h"
39 #include "player-base/player-class.h"
40 #include "player-info/mane-data-type.h"
41 #include "player-status/player-energy.h"
42 #include "player/player-status-table.h"
43 #include "spell-kind/spells-launcher.h"
44 #include "spell-kind/spells-lite.h"
45 #include "spell-kind/spells-neighbor.h"
46 #include "spell-kind/spells-sight.h"
47 #include "spell-kind/spells-teleport.h"
48 #include "spell-kind/spells-world.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/grid-type-definition.h"
57 #include "system/item-entity.h"
58 #include "system/monster-entity.h"
59 #include "system/monster-race-info.h"
60 #include "system/player-type-definition.h"
61 #include "system/redrawing-flags-updater.h"
62 #include "target/projection-path-calculator.h"
63 #include "target/target-checker.h"
64 #include "target/target-getter.h"
65 #include "target/target-setter.h"
66 #include "target/target-types.h"
67 #include "term/screen-processor.h"
68 #include "term/z-form.h"
69 #include "timed-effect/player-stun.h"
70 #include "timed-effect/timed-effects.h"
71 #include "util/enum-converter.h"
72 #include "util/int-char-converter.h"
73 #include "view/display-messages.h"
80 * @brief 受け取ったパラメータに応じてものまねの効果情報をまとめたフォーマットを返す
81 * @param power ものまねの効力の種類
83 * @param std::string ものまねの効果を表す文字列
85 static std::string mane_info(PlayerType *player_ptr, MonsterAbilityType power, int dam)
87 PLAYER_LEVEL plev = player_ptr->lev;
89 const auto power_int = enum2i(power);
90 using Mat = MonsterAbilityType;
91 EnumClassFlagGroup<Mat> flags{
92 Mat::PSY_SPEAR, Mat::BO_VOID, Mat::BO_ABYSS, Mat::BA_VOID, Mat::BA_ABYSS, Mat::BR_VOID, Mat::BR_ABYSS
94 if ((power_int > 2 && power_int < 41) || (power_int > 41 && power_int < 59) || flags.has(power)) {
95 return format(" %s%d", KWD_DAM, (int)dam);
98 case MonsterAbilityType::DRAIN_MANA:
99 return format(" %sd%d+%d", KWD_HEAL, plev * 3, plev);
100 case MonsterAbilityType::HASTE:
101 return format(" %sd%d+%d", KWD_DURATION, 20 + plev, plev);
102 case MonsterAbilityType::HEAL:
103 return format(" %s%d", KWD_HEAL, plev * 6);
104 case MonsterAbilityType::INVULNER:
105 return format(" %sd7+7", KWD_DURATION);
106 case MonsterAbilityType::BLINK:
107 return format(" %s10", KWD_SPHERE);
108 case MonsterAbilityType::TPORT:
109 return format(" %s%d", KWD_SPHERE, plev * 5);
110 case MonsterAbilityType::RAISE_DEAD:
111 return format(" %s5", KWD_SPHERE);
113 return std::string();
118 * @brief どのものまねを発動するか選択する処理 /
119 * Allow user to choose a imitation.
120 * @param sn 実行したものまねのIDを返す参照ポインタ(キャンセルなどの場合-1を返す)
121 * @param baigaesi TRUEならば倍返し上の処理として行う
122 * @return 処理を実行したらTRUE、キャンセルした場合FALSEを返す。
124 * If a valid spell is chosen, saves it in '*sn' and returns TRUE
125 * If the user hits escape, returns FALSE, and set '*sn' to -1
126 * If there are no legal choices, returns FALSE, and sets '*sn' to -2
128 * The "prompt" should be "cast", "recite", or "study"
129 * The "known" should be TRUE for cast/pray, FALSE for study
131 * nb: This function has a (trivial) display bug which will be obvious
132 * when you run it. It's probably easy to fix but I haven't tried,
135 static int get_mane_power(PlayerType *player_ptr, int *sn, bool baigaesi)
141 PERCENTAGE minfail = 0;
142 PLAYER_LEVEL plev = player_ptr->lev;
143 PERCENTAGE chance = 0;
145 concptr p = _("能力", "power");
150 /* Assume cancelled */
156 auto mane_data = PlayerClass(player_ptr).get_specific_data<mane_data_type>();
158 num = mane_data->mane_list.size();
160 /* Build a prompt (accept all spells) */
161 constexpr auto fmt = _("(%c-%c, '*'で一覧, ESC) どの%sをまねますか?", "(%c-%c, *=List, ESC=exit) Use which %s? ");
162 const auto prompt = format(fmt, I2A(0), I2A(num - 1), p);
164 choice = always_show_list ? ESCAPE : 1;
166 if (choice == ESCAPE) {
169 const auto new_choice = input_command(prompt, true);
170 if (!new_choice.has_value()) {
174 choice = new_choice.value();
178 if ((choice == ' ') || (choice == '*') || (choice == '?')) {
184 /* Display a list of spells */
186 put_str(_("名前", "Name"), y, x + 5);
187 put_str(_("失率 効果", "Fail Info"), y, x + 36);
189 /* Dump the spells */
190 for (i = 0; i < num; i++) {
191 const auto &mane = mane_data->mane_list[i];
192 /* Access the spell */
193 spell = monster_powers.at(mane.spell);
195 chance = spell.manefail;
197 /* Reduce failure rate by "effective" level adjustment */
198 if (plev > spell.level) {
199 chance -= 3 * (plev - spell.level);
202 /* Reduce failure rate by INT/WIS adjustment */
203 chance -= 3 * (adj_mag_stat[player_ptr->stat_index[spell.use_stat]] + adj_mag_stat[player_ptr->stat_index[A_DEX]] - 2) / 2;
206 chance = chance * (baigaesi ? mane.damage * 2 : mane.damage) / spell.manedam;
209 chance += player_ptr->to_m_chance;
211 if (player_ptr->inventory_list[INVEN_NECK].is_specific_artifact(FixedArtifactId::GOGO_PENDANT)) {
215 /* Extract the minimum failure rate */
216 minfail = adj_mag_fail[player_ptr->stat_index[spell.use_stat]];
218 /* Minimum failure rate */
219 if (chance < minfail) {
223 auto player_stun = player_ptr->effects()->stun();
224 chance += player_stun->get_magic_chance_penalty();
230 const auto comment = mane_info(player_ptr, mane.spell, (baigaesi ? mane.damage * 2 : mane.damage));
232 /* Dump the spell --(-- */
233 prt(format(" %c) %-30s %3d%%%s", I2A(i), spell.name, chance, comment.data()), y + i + 1, x);
236 /* Clear the bottom line */
237 prt("", y + i + 1, x);
251 /* Extract request */
254 /* Totally Illegal */
255 if ((i < 0) || (i >= num)) {
260 /* Save the spell index */
261 spell = monster_powers.at(mane_data->mane_list[i].spell);
270 RedrawingFlagsUpdater::get_instance().set_flag(SubWindowRedrawingFlag::SPELL);
271 handle_stuff(player_ptr);
273 /* Abort if needed */
278 /* Save the choice */
281 damage = (baigaesi ? mane_data->mane_list[i].damage * 2 : mane_data->mane_list[i].damage);
289 * do_cmd_cast calls this function if the player's class is 'imitator'.
290 * @param player_ptr プレイヤーへの参照ポインタ
291 * @param spell 発動するモンスター攻撃のID
292 * @return 処理を実行したらTRUE、キャンセルした場合FALSEを返す。
294 static bool use_mane(PlayerType *player_ptr, MonsterAbilityType spell)
297 PLAYER_LEVEL plev = player_ptr->lev;
298 BIT_FLAGS mode = (PM_ALLOW_GROUP | PM_FORCE_PET);
299 BIT_FLAGS u_mode = 0L;
301 if (randint1(50 + plev) < plev / 10) {
302 u_mode = PM_ALLOW_UNIQUE;
307 case MonsterAbilityType::SHRIEK:
308 msg_print(_("かん高い金切り声をあげた。", "You make a high pitched shriek."));
309 aggravate_monsters(player_ptr, 0);
312 case MonsterAbilityType::XXX1:
315 case MonsterAbilityType::DISPEL: {
318 if (!target_set(player_ptr, TARGET_KILL)) {
321 m_idx = player_ptr->current_floor_ptr->grid_array[target_row][target_col].m_idx;
325 if (!player_has_los_bold(player_ptr, target_row, target_col)) {
328 if (!projectable(player_ptr, player_ptr->y, player_ptr->x, target_row, target_col)) {
331 dispel_monster_status(player_ptr, m_idx);
335 case MonsterAbilityType::ROCKET:
336 if (!get_aim_dir(player_ptr, &dir)) {
339 msg_print(_("ロケットを発射した。", "You fire a rocket."));
341 fire_rocket(player_ptr, AttributeType::ROCKET, dir, damage, 2);
344 case MonsterAbilityType::SHOOT:
345 if (!get_aim_dir(player_ptr, &dir)) {
348 msg_print(_("矢を放った。", "You fire an arrow."));
350 fire_bolt(player_ptr, AttributeType::MONSTER_SHOOT, dir, damage);
353 case MonsterAbilityType::XXX2:
356 case MonsterAbilityType::XXX3:
359 case MonsterAbilityType::XXX4:
362 case MonsterAbilityType::BR_ACID:
363 if (!get_aim_dir(player_ptr, &dir)) {
366 msg_print(_("酸のブレスを吐いた。", "You breathe acid."));
368 fire_breath(player_ptr, AttributeType::ACID, dir, damage, (plev > 35 ? 3 : 2));
371 case MonsterAbilityType::BR_ELEC:
372 if (!get_aim_dir(player_ptr, &dir)) {
375 msg_print(_("稲妻のブレスを吐いた。", "You breathe lightning."));
377 fire_breath(player_ptr, AttributeType::ELEC, dir, damage, (plev > 35 ? 3 : 2));
380 case MonsterAbilityType::BR_FIRE:
381 if (!get_aim_dir(player_ptr, &dir)) {
384 msg_print(_("火炎のブレスを吐いた。", "You breathe fire."));
386 fire_breath(player_ptr, AttributeType::FIRE, dir, damage, (plev > 35 ? 3 : 2));
389 case MonsterAbilityType::BR_COLD:
390 if (!get_aim_dir(player_ptr, &dir)) {
393 msg_print(_("冷気のブレスを吐いた。", "You breathe frost."));
395 fire_breath(player_ptr, AttributeType::COLD, dir, damage, (plev > 35 ? 3 : 2));
398 case MonsterAbilityType::BR_POIS:
399 if (!get_aim_dir(player_ptr, &dir)) {
402 msg_print(_("ガスのブレスを吐いた。", "You breathe gas."));
404 fire_breath(player_ptr, AttributeType::POIS, dir, damage, (plev > 35 ? 3 : 2));
407 case MonsterAbilityType::BR_NETH:
408 if (!get_aim_dir(player_ptr, &dir)) {
411 msg_print(_("地獄のブレスを吐いた。", "You breathe nether."));
413 fire_breath(player_ptr, AttributeType::NETHER, dir, damage, (plev > 35 ? 3 : 2));
416 case MonsterAbilityType::BR_LITE:
417 if (!get_aim_dir(player_ptr, &dir)) {
420 msg_print(_("閃光のブレスを吐いた。", "You breathe light."));
422 fire_breath(player_ptr, AttributeType::LITE, dir, damage, (plev > 35 ? 3 : 2));
425 case MonsterAbilityType::BR_DARK:
426 if (!get_aim_dir(player_ptr, &dir)) {
429 msg_print(_("暗黒のブレスを吐いた。", "You breathe darkness."));
431 fire_breath(player_ptr, AttributeType::DARK, dir, damage, (plev > 35 ? 3 : 2));
434 case MonsterAbilityType::BR_CONF:
435 if (!get_aim_dir(player_ptr, &dir)) {
438 msg_print(_("混乱のブレスを吐いた。", "You breathe confusion."));
440 fire_breath(player_ptr, AttributeType::CONFUSION, dir, damage, (plev > 35 ? 3 : 2));
443 case MonsterAbilityType::BR_SOUN:
444 if (!get_aim_dir(player_ptr, &dir)) {
447 msg_print(_("轟音のブレスを吐いた。", "You breathe sound."));
449 fire_breath(player_ptr, AttributeType::SOUND, dir, damage, (plev > 35 ? 3 : 2));
452 case MonsterAbilityType::BR_CHAO:
453 if (!get_aim_dir(player_ptr, &dir)) {
456 msg_print(_("カオスのブレスを吐いた。", "You breathe chaos."));
458 fire_breath(player_ptr, AttributeType::CHAOS, dir, damage, (plev > 35 ? 3 : 2));
461 case MonsterAbilityType::BR_DISE:
462 if (!get_aim_dir(player_ptr, &dir)) {
465 msg_print(_("劣化のブレスを吐いた。", "You breathe disenchantment."));
467 fire_breath(player_ptr, AttributeType::DISENCHANT, dir, damage, (plev > 35 ? 3 : 2));
470 case MonsterAbilityType::BR_NEXU:
471 if (!get_aim_dir(player_ptr, &dir)) {
474 msg_print(_("因果混乱のブレスを吐いた。", "You breathe nexus."));
476 fire_breath(player_ptr, AttributeType::NEXUS, dir, damage, (plev > 35 ? 3 : 2));
479 case MonsterAbilityType::BR_TIME:
480 if (!get_aim_dir(player_ptr, &dir)) {
483 msg_print(_("時間逆転のブレスを吐いた。", "You breathe time."));
485 fire_breath(player_ptr, AttributeType::TIME, dir, damage, (plev > 35 ? 3 : 2));
488 case MonsterAbilityType::BR_INER:
489 if (!get_aim_dir(player_ptr, &dir)) {
492 msg_print(_("遅鈍のブレスを吐いた。", "You breathe inertia."));
494 fire_breath(player_ptr, AttributeType::INERTIAL, dir, damage, (plev > 35 ? 3 : 2));
497 case MonsterAbilityType::BR_GRAV:
498 if (!get_aim_dir(player_ptr, &dir)) {
501 msg_print(_("重力のブレスを吐いた。", "You breathe gravity."));
503 fire_breath(player_ptr, AttributeType::GRAVITY, dir, damage, (plev > 35 ? 3 : 2));
506 case MonsterAbilityType::BR_SHAR:
507 if (!get_aim_dir(player_ptr, &dir)) {
510 msg_print(_("破片のブレスを吐いた。", "You breathe shards."));
512 fire_breath(player_ptr, AttributeType::SHARDS, dir, damage, (plev > 35 ? 3 : 2));
515 case MonsterAbilityType::BR_PLAS:
516 if (!get_aim_dir(player_ptr, &dir)) {
519 msg_print(_("プラズマのブレスを吐いた。", "You breathe plasma."));
521 fire_breath(player_ptr, AttributeType::PLASMA, dir, damage, (plev > 35 ? 3 : 2));
524 case MonsterAbilityType::BR_FORC:
525 if (!get_aim_dir(player_ptr, &dir)) {
528 msg_print(_("フォースのブレスを吐いた。", "You breathe force."));
530 fire_breath(player_ptr, AttributeType::FORCE, dir, damage, (plev > 35 ? 3 : 2));
533 case MonsterAbilityType::BR_MANA:
534 if (!get_aim_dir(player_ptr, &dir)) {
537 msg_print(_("魔力のブレスを吐いた。", "You breathe mana."));
539 fire_breath(player_ptr, AttributeType::MANA, dir, damage, (plev > 35 ? 3 : 2));
542 case MonsterAbilityType::BA_NUKE:
543 if (!get_aim_dir(player_ptr, &dir)) {
546 msg_print(_("放射能球を放った。", "You cast a ball of radiation."));
548 fire_ball(player_ptr, AttributeType::NUKE, dir, damage, 2);
551 case MonsterAbilityType::BR_NUKE:
552 if (!get_aim_dir(player_ptr, &dir)) {
555 msg_print(_("放射性廃棄物のブレスを吐いた。", "You breathe toxic waste."));
558 fire_breath(player_ptr, AttributeType::NUKE, dir, damage, (plev > 35 ? 3 : 2));
561 case MonsterAbilityType::BA_CHAO:
562 if (!get_aim_dir(player_ptr, &dir)) {
565 msg_print(_("純ログルスを放った。", "You invoke a raw Logrus."));
568 fire_ball(player_ptr, AttributeType::CHAOS, dir, damage, 4);
570 case MonsterAbilityType::BR_DISI:
571 if (!get_aim_dir(player_ptr, &dir)) {
574 msg_print(_("分解のブレスを吐いた。", "You breathe disintegration."));
577 fire_breath(player_ptr, AttributeType::DISINTEGRATE, dir, damage, (plev > 35 ? 3 : 2));
579 case MonsterAbilityType::BR_VOID:
580 if (!get_aim_dir(player_ptr, &dir)) {
583 msg_print(_("虚無のブレスを吐いた。", "You breathe void."));
586 fire_breath(player_ptr, AttributeType::VOID_MAGIC, dir, damage, (plev > 35 ? 3 : 2));
589 case MonsterAbilityType::BR_ABYSS:
590 if (!get_aim_dir(player_ptr, &dir)) {
593 msg_print(_("深淵のブレスを吐いた。", "You breathe abyss."));
596 fire_breath(player_ptr, AttributeType::ABYSS, dir, damage, (plev > 35 ? 3 : 2));
599 case MonsterAbilityType::BA_ACID:
600 if (!get_aim_dir(player_ptr, &dir)) {
603 msg_print(_("アシッド・ボールの呪文を唱えた。", "You cast an acid ball."));
606 fire_ball(player_ptr, AttributeType::ACID, dir, damage, 2);
608 case MonsterAbilityType::BA_ELEC:
609 if (!get_aim_dir(player_ptr, &dir)) {
612 msg_print(_("サンダー・ボールの呪文を唱えた。", "You cast a lightning ball."));
615 fire_ball(player_ptr, AttributeType::ELEC, dir, damage, 2);
617 case MonsterAbilityType::BA_FIRE:
618 if (!get_aim_dir(player_ptr, &dir)) {
621 msg_print(_("ファイア・ボールの呪文を唱えた。", "You cast a fire ball."));
624 fire_ball(player_ptr, AttributeType::FIRE, dir, damage, 2);
626 case MonsterAbilityType::BA_COLD:
627 if (!get_aim_dir(player_ptr, &dir)) {
630 msg_print(_("アイス・ボールの呪文を唱えた。", "You cast a frost ball."));
633 fire_ball(player_ptr, AttributeType::COLD, dir, damage, 2);
635 case MonsterAbilityType::BA_POIS:
636 if (!get_aim_dir(player_ptr, &dir)) {
639 msg_print(_("悪臭雲の呪文を唱えた。", "You cast a stinking cloud."));
642 fire_ball(player_ptr, AttributeType::POIS, dir, damage, 2);
644 case MonsterAbilityType::BA_NETH:
645 if (!get_aim_dir(player_ptr, &dir)) {
648 msg_print(_("地獄球の呪文を唱えた。", "You cast a nether ball."));
651 fire_ball(player_ptr, AttributeType::NETHER, dir, damage, 2);
653 case MonsterAbilityType::BA_WATE:
654 if (!get_aim_dir(player_ptr, &dir)) {
657 msg_print(_("流れるような身振りをした。", "You gesture fluidly."));
660 fire_ball(player_ptr, AttributeType::WATER, dir, damage, 4);
662 case MonsterAbilityType::BA_MANA:
663 if (!get_aim_dir(player_ptr, &dir)) {
666 msg_print(_("魔力の嵐の呪文を念じた。", "You invoke a mana storm."));
669 fire_ball(player_ptr, AttributeType::MANA, dir, damage, 4);
671 case MonsterAbilityType::BA_DARK:
672 if (!get_aim_dir(player_ptr, &dir)) {
675 msg_print(_("暗黒の嵐の呪文を念じた。", "You invoke a darkness storm."));
678 fire_ball(player_ptr, AttributeType::DARK, dir, damage, 4);
680 case MonsterAbilityType::BA_VOID:
681 if (!get_aim_dir(player_ptr, &dir)) {
684 msg_print(_("虚無の嵐の呪文を念じた。", "You cast a void ball."));
687 fire_ball(player_ptr, AttributeType::VOID_MAGIC, dir, damage, 4);
689 case MonsterAbilityType::BA_ABYSS:
690 if (!get_aim_dir(player_ptr, &dir)) {
693 msg_print(_("深淵の嵐の呪文を念じた。", "You cast a abyss ball."));
696 fire_ball(player_ptr, AttributeType::ABYSS, dir, damage, 4);
698 case MonsterAbilityType::DRAIN_MANA:
699 if (!get_aim_dir(player_ptr, &dir)) {
702 fire_ball_hide(player_ptr, AttributeType::DRAIN_MANA, dir, randint1(plev * 3) + plev, 0);
704 case MonsterAbilityType::MIND_BLAST:
705 if (!get_aim_dir(player_ptr, &dir)) {
708 fire_ball_hide(player_ptr, AttributeType::MIND_BLAST, dir, damage, 0);
710 case MonsterAbilityType::BRAIN_SMASH:
711 if (!get_aim_dir(player_ptr, &dir)) {
714 fire_ball_hide(player_ptr, AttributeType::BRAIN_SMASH, dir, damage, 0);
716 case MonsterAbilityType::CAUSE_1:
717 if (!get_aim_dir(player_ptr, &dir)) {
720 fire_ball_hide(player_ptr, AttributeType::CAUSE_1, dir, damage, 0);
722 case MonsterAbilityType::CAUSE_2:
723 if (!get_aim_dir(player_ptr, &dir)) {
726 fire_ball_hide(player_ptr, AttributeType::CAUSE_2, dir, damage, 0);
728 case MonsterAbilityType::CAUSE_3:
729 if (!get_aim_dir(player_ptr, &dir)) {
732 fire_ball_hide(player_ptr, AttributeType::CAUSE_3, dir, damage, 0);
734 case MonsterAbilityType::CAUSE_4:
735 if (!get_aim_dir(player_ptr, &dir)) {
738 fire_ball_hide(player_ptr, AttributeType::CAUSE_4, dir, damage, 0);
740 case MonsterAbilityType::BO_ACID:
741 if (!get_aim_dir(player_ptr, &dir)) {
744 msg_print(_("アシッド・ボルトの呪文を唱えた。", "You cast an acid bolt."));
747 fire_bolt(player_ptr, AttributeType::ACID, dir, damage);
749 case MonsterAbilityType::BO_ELEC:
750 if (!get_aim_dir(player_ptr, &dir)) {
753 msg_print(_("サンダー・ボルトの呪文を唱えた。", "You cast a lightning bolt."));
756 fire_bolt(player_ptr, AttributeType::ELEC, dir, damage);
758 case MonsterAbilityType::BO_FIRE:
759 if (!get_aim_dir(player_ptr, &dir)) {
762 msg_print(_("ファイア・ボルトの呪文を唱えた。", "You cast a fire bolt."));
765 fire_bolt(player_ptr, AttributeType::FIRE, dir, damage);
767 case MonsterAbilityType::BO_COLD:
768 if (!get_aim_dir(player_ptr, &dir)) {
771 msg_print(_("アイス・ボルトの呪文を唱えた。", "You cast a frost bolt."));
774 fire_bolt(player_ptr, AttributeType::COLD, dir, damage);
776 case MonsterAbilityType::BA_LITE:
777 if (!get_aim_dir(player_ptr, &dir)) {
780 msg_print(_("スターバーストの呪文を念じた。", "You invoke a starburst."));
783 fire_ball(player_ptr, AttributeType::LITE, dir, damage, 4);
785 case MonsterAbilityType::BO_NETH:
786 if (!get_aim_dir(player_ptr, &dir)) {
789 msg_print(_("地獄の矢の呪文を唱えた。", "You cast a nether bolt."));
792 fire_bolt(player_ptr, AttributeType::NETHER, dir, damage);
794 case MonsterAbilityType::BO_WATE:
795 if (!get_aim_dir(player_ptr, &dir)) {
798 msg_print(_("ウォーター・ボルトの呪文を唱えた。", "You cast a water bolt."));
801 fire_bolt(player_ptr, AttributeType::WATER, dir, damage);
803 case MonsterAbilityType::BO_MANA:
804 if (!get_aim_dir(player_ptr, &dir)) {
807 msg_print(_("魔力の矢の呪文を唱えた。", "You cast a mana bolt."));
810 fire_bolt(player_ptr, AttributeType::MANA, dir, damage);
812 case MonsterAbilityType::BO_PLAS:
813 if (!get_aim_dir(player_ptr, &dir)) {
816 msg_print(_("プラズマ・ボルトの呪文を唱えた。", "You cast a plasma bolt."));
819 fire_bolt(player_ptr, AttributeType::PLASMA, dir, damage);
821 case MonsterAbilityType::BO_ICEE:
822 if (!get_aim_dir(player_ptr, &dir)) {
825 msg_print(_("極寒の矢の呪文を唱えた。", "You cast a ice bolt."));
828 fire_bolt(player_ptr, AttributeType::ICE, dir, damage);
830 case MonsterAbilityType::BO_VOID:
831 if (!get_aim_dir(player_ptr, &dir)) {
834 msg_print(_("虚無の矢の呪文を唱えた。", "You cast a void bolt."));
837 fire_bolt(player_ptr, AttributeType::VOID_MAGIC, dir, damage);
839 case MonsterAbilityType::BO_ABYSS:
840 if (!get_aim_dir(player_ptr, &dir)) {
843 msg_print(_("深淵の矢の呪文を唱えた。", "You cast a abyss bolt."));
846 fire_bolt(player_ptr, AttributeType::ABYSS, dir, damage);
848 case MonsterAbilityType::MISSILE:
849 if (!get_aim_dir(player_ptr, &dir)) {
852 msg_print(_("マジック・ミサイルの呪文を唱えた。", "You cast a magic missile."));
855 fire_bolt(player_ptr, AttributeType::MISSILE, dir, damage);
857 case MonsterAbilityType::SCARE:
858 if (!get_aim_dir(player_ptr, &dir)) {
861 msg_print(_("恐ろしげな幻覚を作り出した。", "You cast a fearful illusion."));
864 fear_monster(player_ptr, dir, plev + 10);
866 case MonsterAbilityType::BLIND:
867 if (!get_aim_dir(player_ptr, &dir)) {
870 confuse_monster(player_ptr, dir, plev * 2);
872 case MonsterAbilityType::CONF:
873 if (!get_aim_dir(player_ptr, &dir)) {
876 msg_print(_("誘惑的な幻覚をつくり出した。", "You cast a mesmerizing illusion."));
879 confuse_monster(player_ptr, dir, plev * 2);
881 case MonsterAbilityType::SLOW:
882 if (!get_aim_dir(player_ptr, &dir)) {
885 slow_monster(player_ptr, dir, plev);
887 case MonsterAbilityType::HOLD:
888 if (!get_aim_dir(player_ptr, &dir)) {
891 sleep_monster(player_ptr, dir, plev);
893 case MonsterAbilityType::HASTE:
894 (void)set_acceleration(player_ptr, randint1(20 + plev) + plev, false);
896 case MonsterAbilityType::HAND_DOOM: {
897 if (!get_aim_dir(player_ptr, &dir)) {
900 msg_print(_("<破滅の手>を放った!", "You invoke the Hand of Doom!"));
903 fire_ball_hide(player_ptr, AttributeType::HAND_DOOM, dir, 200, 0);
906 case MonsterAbilityType::HEAL: {
907 msg_print(_("自分の傷に念を集中した。", "You concentrate on your wounds!"));
908 (void)hp_player(player_ptr, plev * 6);
909 BadStatusSetter bss(player_ptr);
910 (void)bss.set_stun(0);
911 (void)bss.set_cut(0);
914 case MonsterAbilityType::INVULNER:
915 msg_print(_("無傷の球の呪文を唱えた。", "You cast a Globe of Invulnerability."));
916 (void)set_invuln(player_ptr, randint1(7) + 7, false);
918 case MonsterAbilityType::BLINK:
919 teleport_player(player_ptr, 10, TELEPORT_SPONTANEOUS);
921 case MonsterAbilityType::TPORT:
922 teleport_player(player_ptr, plev * 5, TELEPORT_SPONTANEOUS);
924 case MonsterAbilityType::WORLD:
925 (void)time_walk(player_ptr);
927 case MonsterAbilityType::SPECIAL:
929 case MonsterAbilityType::TELE_TO: {
930 if (!target_set(player_ptr, TARGET_KILL)) {
934 auto *floor_ptr = player_ptr->current_floor_ptr;
935 if (!floor_ptr->grid_array[target_row][target_col].m_idx) {
938 if (!player_has_los_bold(player_ptr, target_row, target_col)) {
941 if (!projectable(player_ptr, player_ptr->y, player_ptr->x, target_row, target_col)) {
945 const auto &grid = floor_ptr->grid_array[target_row][target_col];
946 auto *m_ptr = &floor_ptr->m_list[grid.m_idx];
947 auto *r_ptr = &monraces_info[m_ptr->r_idx];
948 const auto m_name = monster_desc(player_ptr, m_ptr, 0);
949 if (r_ptr->resistance_flags.has(MonsterResistanceType::RESIST_TELEPORT)) {
950 if (r_ptr->kind_flags.has(MonsterKindType::UNIQUE) || r_ptr->resistance_flags.has(MonsterResistanceType::RESIST_ALL)) {
951 if (is_original_ap_and_seen(player_ptr, m_ptr)) {
952 r_ptr->r_resistance_flags.set(MonsterResistanceType::RESIST_TELEPORT);
954 msg_format(_("%sには効果がなかった!", "%s is unaffected!"), m_name.data());
957 } else if (r_ptr->level > randint1(100)) {
958 if (is_original_ap_and_seen(player_ptr, m_ptr)) {
959 r_ptr->r_resistance_flags.set(MonsterResistanceType::RESIST_TELEPORT);
961 msg_format(_("%sには耐性がある!", "%s resists!"), m_name.data());
966 msg_format(_("%sを引き戻した。", "You command %s to return."), m_name.data());
968 teleport_monster_to(player_ptr, grid.m_idx, player_ptr->y, player_ptr->x, 100, TELEPORT_PASSIVE);
971 case MonsterAbilityType::TELE_AWAY:
972 if (!get_aim_dir(player_ptr, &dir)) {
976 (void)fire_beam(player_ptr, AttributeType::AWAY_ALL, dir, plev);
979 case MonsterAbilityType::TELE_LEVEL:
980 return teleport_level_other(player_ptr);
983 case MonsterAbilityType::PSY_SPEAR:
984 if (!get_aim_dir(player_ptr, &dir)) {
987 msg_print(_("光の剣を放った。", "You throw a psycho-spear."));
989 (void)fire_beam(player_ptr, AttributeType::PSY_SPEAR, dir, damage);
992 case MonsterAbilityType::DARKNESS:
993 msg_print(_("暗闇の中で手を振った。", "You gesture in shadow."));
994 (void)unlite_area(player_ptr, 10, 3);
997 case MonsterAbilityType::TRAPS:
998 if (!target_set(player_ptr, TARGET_KILL)) {
1001 msg_print(_("呪文を唱えて邪悪に微笑んだ。", "You cast a spell and cackle evilly."));
1002 trap_creation(player_ptr, target_row, target_col);
1004 case MonsterAbilityType::FORGET:
1005 msg_print(_("しかし何も起きなかった。", "Nothing happens."));
1007 case MonsterAbilityType::RAISE_DEAD:
1008 msg_print(_("死者復活の呪文を唱えた。", "You animate the dead."));
1009 (void)animate_dead(player_ptr, 0, player_ptr->y, player_ptr->x);
1011 case MonsterAbilityType::S_KIN: {
1013 if (!target_set(player_ptr, TARGET_KILL)) {
1017 msg_print(_("援軍を召喚した。", "You summon minions."));
1018 for (k = 0; k < 4; k++) {
1019 (void)summon_kin_player(player_ptr, plev, target_row, target_col, (PM_FORCE_PET | PM_ALLOW_GROUP));
1023 case MonsterAbilityType::S_CYBER: {
1025 int max_cyber = (player_ptr->current_floor_ptr->dun_level / 50) + randint1(3);
1026 if (!target_set(player_ptr, TARGET_KILL)) {
1029 msg_print(_("サイバーデーモンを召喚した!", "You summon Cyberdemons!"));
1030 if (max_cyber > 4) {
1033 for (k = 0; k < max_cyber; k++) {
1034 summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_CYBER, mode);
1038 case MonsterAbilityType::S_MONSTER: {
1040 if (!target_set(player_ptr, TARGET_KILL)) {
1043 msg_print(_("仲間を召喚した。", "You summon help."));
1044 for (k = 0; k < 1; k++) {
1045 summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_NONE, (mode | u_mode));
1049 case MonsterAbilityType::S_MONSTERS: {
1051 if (!target_set(player_ptr, TARGET_KILL)) {
1054 msg_print(_("モンスターを召喚した!", "You summon monsters!"));
1055 for (k = 0; k < 6; k++) {
1056 summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_NONE, (mode | u_mode));
1060 case MonsterAbilityType::S_ANT: {
1062 if (!target_set(player_ptr, TARGET_KILL)) {
1065 msg_print(_("アリを召喚した。", "You summon ants."));
1066 for (k = 0; k < 6; k++) {
1067 summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_ANT, mode);
1071 case MonsterAbilityType::S_SPIDER: {
1073 if (!target_set(player_ptr, TARGET_KILL)) {
1076 msg_print(_("蜘蛛を召喚した。", "You summon spiders."));
1077 for (k = 0; k < 6; k++) {
1078 summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_SPIDER, mode);
1082 case MonsterAbilityType::S_HOUND: {
1084 if (!target_set(player_ptr, TARGET_KILL)) {
1087 msg_print(_("ハウンドを召喚した。", "You summon hounds."));
1088 for (k = 0; k < 4; k++) {
1089 summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_HOUND, mode);
1093 case MonsterAbilityType::S_HYDRA: {
1095 if (!target_set(player_ptr, TARGET_KILL)) {
1098 msg_print(_("ヒドラを召喚した。", "You summon hydras."));
1099 for (k = 0; k < 4; k++) {
1100 summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_HYDRA, mode);
1104 case MonsterAbilityType::S_ANGEL: {
1106 if (!target_set(player_ptr, TARGET_KILL)) {
1109 msg_print(_("天使を召喚した!", "You summon an angel!"));
1110 for (k = 0; k < 1; k++) {
1111 summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_ANGEL, mode);
1115 case MonsterAbilityType::S_DEMON: {
1117 if (!target_set(player_ptr, TARGET_KILL)) {
1120 msg_print(_("混沌の宮廷から悪魔を召喚した!", "You summon a demon from the Courts of Chaos!"));
1121 for (k = 0; k < 1; k++) {
1122 summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_DEMON, (mode | u_mode));
1126 case MonsterAbilityType::S_UNDEAD: {
1128 if (!target_set(player_ptr, TARGET_KILL)) {
1131 msg_print(_("アンデッドの強敵を召喚した!", "You summon an undead adversary!"));
1132 for (k = 0; k < 1; k++) {
1133 summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_UNDEAD, (mode | u_mode));
1137 case MonsterAbilityType::S_DRAGON: {
1139 if (!target_set(player_ptr, TARGET_KILL)) {
1142 msg_print(_("ドラゴンを召喚した!", "You summon a dragon!"));
1143 for (k = 0; k < 1; k++) {
1144 summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_DRAGON, (mode | u_mode));
1148 case MonsterAbilityType::S_HI_UNDEAD: {
1150 if (!target_set(player_ptr, TARGET_KILL)) {
1153 msg_print(_("強力なアンデッドを召喚した!", "You summon greater undead!"));
1154 for (k = 0; k < 6; k++) {
1155 summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_HI_UNDEAD, (mode | u_mode));
1159 case MonsterAbilityType::S_HI_DRAGON: {
1161 if (!target_set(player_ptr, TARGET_KILL)) {
1164 msg_print(_("古代ドラゴンを召喚した!", "You summon ancient dragons!"));
1165 for (k = 0; k < 4; k++) {
1166 summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_HI_DRAGON, (mode | u_mode));
1170 case MonsterAbilityType::S_AMBERITES: {
1172 if (!target_set(player_ptr, TARGET_KILL)) {
1175 msg_print(_("アンバーの王族を召喚した!", "You summon Lords of Amber!"));
1176 for (k = 0; k < 4; k++) {
1177 summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_AMBERITES, (mode | PM_ALLOW_UNIQUE));
1181 case MonsterAbilityType::S_UNIQUE: {
1183 if (!target_set(player_ptr, TARGET_KILL)) {
1186 msg_print(_("特別な強敵を召喚した!", "You summon special opponents!"));
1187 for (k = 0; k < 4; k++) {
1188 if (summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_UNIQUE, (mode | PM_ALLOW_UNIQUE))) {
1192 for (k = count; k < 4; k++) {
1193 summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_HI_UNDEAD, (mode | u_mode));
1205 * @brief ものまねコマンドのメインルーチン /
1206 * do_cmd_cast calls this function if the player's class is 'imitator'.
1207 * @param baigaesi TRUEならば倍返し上の処理として行う
1208 * @return 処理を実行したらTRUE、キャンセルした場合FALSEを返す。
1210 * If a valid spell is chosen, saves it in '*sn' and returns TRUE
1211 * If the user hits escape, returns FALSE, and set '*sn' to -1
1212 * If there are no legal choices, returns FALSE, and sets '*sn' to -2
1214 * The "prompt" should be "cast", "recite", or "study"
1215 * The "known" should be TRUE for cast/pray, FALSE for study
1217 * nb: This function has a (trivial) display bug which will be obvious
1218 * when you run it. It's probably easy to fix but I haven't tried,
1221 bool do_cmd_mane(PlayerType *player_ptr, bool baigaesi)
1225 PERCENTAGE minfail = 0;
1226 PLAYER_LEVEL plev = player_ptr->lev;
1227 monster_power spell;
1230 if (cmd_limit_confused(player_ptr)) {
1234 auto mane_data = PlayerClass(player_ptr).get_specific_data<mane_data_type>();
1236 if (mane_data->mane_list.empty()) {
1237 msg_print(_("まねられるものが何もない!", "You don't remember any action!"));
1241 if (!get_mane_power(player_ptr, &n, baigaesi)) {
1245 spell = monster_powers.at(mane_data->mane_list[n].spell);
1247 /* Spell failure chance */
1248 chance = spell.manefail;
1250 /* Reduce failure rate by "effective" level adjustment */
1251 if (plev > spell.level) {
1252 chance -= 3 * (plev - spell.level);
1255 /* Reduce failure rate by 1 stat and DEX adjustment */
1256 chance -= 3 * (adj_mag_stat[player_ptr->stat_index[spell.use_stat]] + adj_mag_stat[player_ptr->stat_index[A_DEX]] - 2) / 2;
1258 if (spell.manedam) {
1259 chance = chance * damage / spell.manedam;
1262 chance += player_ptr->to_m_chance;
1264 /* Extract the minimum failure rate */
1265 minfail = adj_mag_fail[player_ptr->stat_index[spell.use_stat]];
1267 /* Minimum failure rate */
1268 if (chance < minfail) {
1272 auto player_stun = player_ptr->effects()->stun();
1273 chance += player_stun->get_magic_chance_penalty();
1279 if (randint0(100) < chance) {
1280 if (flush_failure) {
1283 msg_print(_("ものまねに失敗した!", "You failed to concentrate hard enough!"));
1287 cast = use_mane(player_ptr, mane_data->mane_list[n].spell);
1293 mane_data->mane_list.erase(std::next(mane_data->mane_list.begin(), n));
1294 PlayerEnergy(player_ptr).set_player_turn_energy(100);
1295 auto &rfu = RedrawingFlagsUpdater::get_instance();
1296 rfu.set_flag(MainWindowRedrawingFlag::IMITATION);
1297 static constexpr auto flags = {
1298 SubWindowRedrawingFlag::PLAYER,
1299 SubWindowRedrawingFlag::SPELL,
1301 rfu.set_flags(flags);