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/floor-object.h"
20 #include "game-option/disturbance-options.h"
21 #include "game-option/text-display-options.h"
22 #include "hpmp/hp-mp-processor.h"
23 #include "inventory/inventory-slot-types.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-ability-mask.h"
32 #include "monster-race/race-flags-resistance.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 "monster/monster-util.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 using Mat = MonsterAbilityType;
91 (RF_ABILITY_BALL_MASK |
92 RF_ABILITY_BOLT_MASK |
95 { Mat::MIND_BLAST, Mat::BRAIN_SMASH, Mat::CAUSE_1, Mat::CAUSE_2, Mat::CAUSE_3, Mat::CAUSE_4 });
96 if (flags.has(power)) {
97 return format(" %s%d", KWD_DAM, (int)dam);
100 case MonsterAbilityType::DRAIN_MANA:
101 return format(" %sd%d+%d", KWD_HEAL, plev * 3, plev);
102 case MonsterAbilityType::HASTE:
103 return format(" %sd%d+%d", KWD_DURATION, 20 + plev, plev);
104 case MonsterAbilityType::HEAL:
105 return format(" %s%d", KWD_HEAL, plev * 6);
106 case MonsterAbilityType::INVULNER:
107 return format(" %sd7+7", KWD_DURATION);
108 case MonsterAbilityType::BLINK:
109 return format(" %s10", KWD_SPHERE);
110 case MonsterAbilityType::TPORT:
111 return format(" %s%d", KWD_SPHERE, plev * 5);
112 case MonsterAbilityType::RAISE_DEAD:
113 return format(" %s5", KWD_SPHERE);
115 return std::string();
120 * @brief どのものまねを発動するか選択する処理 /
121 * Allow user to choose a imitation.
122 * @param sn 実行したものまねのIDを返す参照ポインタ(キャンセルなどの場合-1を返す)
123 * @param baigaesi TRUEならば倍返し上の処理として行う
124 * @return 処理を実行したらTRUE、キャンセルした場合FALSEを返す。
126 * If a valid spell is chosen, saves it in '*sn' and returns TRUE
127 * If the user hits escape, returns FALSE, and set '*sn' to -1
128 * If there are no legal choices, returns FALSE, and sets '*sn' to -2
130 * The "prompt" should be "cast", "recite", or "study"
131 * The "known" should be TRUE for cast/pray, FALSE for study
133 * nb: This function has a (trivial) display bug which will be obvious
134 * when you run it. It's probably easy to fix but I haven't tried,
137 static int get_mane_power(PlayerType *player_ptr, int *sn, bool baigaesi)
143 PERCENTAGE minfail = 0;
144 PLAYER_LEVEL plev = player_ptr->lev;
145 PERCENTAGE chance = 0;
146 concptr p = _("能力", "power");
151 /* Assume cancelled */
157 auto mane_data = PlayerClass(player_ptr).get_specific_data<mane_data_type>();
159 num = mane_data->mane_list.size();
161 /* Build a prompt (accept all spells) */
162 constexpr auto fmt = _("(%c-%c, '*'で一覧, ESC) どの%sをまねますか?", "(%c-%c, *=List, ESC=exit) Use which %s? ");
163 const auto prompt = format(fmt, I2A(0), I2A(num - 1), p);
165 char choice = always_show_list ? ESCAPE : '\1';
167 if (choice == ESCAPE) {
170 const auto new_choice = input_command(prompt, true);
175 choice = *new_choice;
179 if ((choice == ' ') || (choice == '*') || (choice == '?')) {
185 /* Display a list of spells */
187 put_str(_("名前", "Name"), y, x + 5);
188 put_str(_("失率 効果", "Fail Info"), y, x + 36);
190 /* Dump the spells */
191 for (i = 0; i < num; i++) {
192 const auto &mane = mane_data->mane_list[i];
193 /* Access the spell */
194 spell = monster_powers.at(mane.spell);
196 chance = spell.manefail;
198 /* Reduce failure rate by "effective" level adjustment */
199 if (plev > spell.level) {
200 chance -= 3 * (plev - spell.level);
203 /* Reduce failure rate by INT/WIS adjustment */
204 chance -= 3 * (adj_mag_stat[player_ptr->stat_index[spell.use_stat]] + adj_mag_stat[player_ptr->stat_index[A_DEX]] - 2) / 2;
207 chance = chance * (baigaesi ? mane.damage * 2 : mane.damage) / spell.manedam;
210 chance += player_ptr->to_m_chance;
212 if (player_ptr->inventory_list[INVEN_NECK].is_specific_artifact(FixedArtifactId::GOGO_PENDANT)) {
216 /* Extract the minimum failure rate */
217 minfail = adj_mag_fail[player_ptr->stat_index[spell.use_stat]];
219 /* Minimum failure rate */
220 if (chance < minfail) {
224 auto player_stun = player_ptr->effects()->stun();
225 chance += player_stun->get_magic_chance_penalty();
231 const auto comment = mane_info(player_ptr, mane.spell, (baigaesi ? mane.damage * 2 : mane.damage));
233 /* Dump the spell --(-- */
234 prt(format(" %c) %-30s %3d%%%s", I2A(i), spell.name, chance, comment.data()), y + i + 1, x);
237 /* Clear the bottom line */
238 prt("", y + i + 1, x);
252 /* Extract request */
255 /* Totally Illegal */
256 if ((i < 0) || (i >= num)) {
261 /* Save the spell index */
262 spell = monster_powers.at(mane_data->mane_list[i].spell);
271 RedrawingFlagsUpdater::get_instance().set_flag(SubWindowRedrawingFlag::SPELL);
272 handle_stuff(player_ptr);
274 /* Abort if needed */
279 /* Save the choice */
282 damage = (baigaesi ? mane_data->mane_list[i].damage * 2 : mane_data->mane_list[i].damage);
290 * do_cmd_cast calls this function if the player's class is 'imitator'.
291 * @param player_ptr プレイヤーへの参照ポインタ
292 * @param spell 発動するモンスター攻撃のID
293 * @return 処理を実行したらTRUE、キャンセルした場合FALSEを返す。
295 static bool use_mane(PlayerType *player_ptr, MonsterAbilityType spell)
298 PLAYER_LEVEL plev = player_ptr->lev;
299 BIT_FLAGS mode = (PM_ALLOW_GROUP | PM_FORCE_PET);
300 BIT_FLAGS u_mode = 0L;
302 if (randint1(50 + plev) < plev / 10) {
303 u_mode = PM_ALLOW_UNIQUE;
308 case MonsterAbilityType::SHRIEK:
309 msg_print(_("かん高い金切り声をあげた。", "You make a high pitched shriek."));
310 aggravate_monsters(player_ptr, 0);
313 case MonsterAbilityType::XXX1:
316 case MonsterAbilityType::DISPEL: {
317 if (!target_set(player_ptr, TARGET_KILL)) {
321 const Pos2D pos(target_row, target_col);
322 const auto &grid = player_ptr->current_floor_ptr->get_grid(pos);
323 const auto m_idx = grid.m_idx;
324 auto should_dispel = m_idx == 0;
325 should_dispel &= grid.has_los();
326 should_dispel &= projectable(player_ptr, player_ptr->y, player_ptr->x, target_row, target_col);
327 if (!should_dispel) {
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::BA_METEOR:
699 if (!get_aim_dir(player_ptr, &dir)) {
702 msg_print(_("メテオスウォームの呪文を念じた。", "You cast a meteor swarm."));
705 fire_ball(player_ptr, AttributeType::METEOR, dir, damage, 4);
707 case MonsterAbilityType::DRAIN_MANA:
708 if (!get_aim_dir(player_ptr, &dir)) {
711 fire_ball_hide(player_ptr, AttributeType::DRAIN_MANA, dir, randint1(plev * 3) + plev, 0);
713 case MonsterAbilityType::MIND_BLAST:
714 if (!get_aim_dir(player_ptr, &dir)) {
717 fire_ball_hide(player_ptr, AttributeType::MIND_BLAST, dir, damage, 0);
719 case MonsterAbilityType::BRAIN_SMASH:
720 if (!get_aim_dir(player_ptr, &dir)) {
723 fire_ball_hide(player_ptr, AttributeType::BRAIN_SMASH, dir, damage, 0);
725 case MonsterAbilityType::CAUSE_1:
726 if (!get_aim_dir(player_ptr, &dir)) {
729 fire_ball_hide(player_ptr, AttributeType::CAUSE_1, dir, damage, 0);
731 case MonsterAbilityType::CAUSE_2:
732 if (!get_aim_dir(player_ptr, &dir)) {
735 fire_ball_hide(player_ptr, AttributeType::CAUSE_2, dir, damage, 0);
737 case MonsterAbilityType::CAUSE_3:
738 if (!get_aim_dir(player_ptr, &dir)) {
741 fire_ball_hide(player_ptr, AttributeType::CAUSE_3, dir, damage, 0);
743 case MonsterAbilityType::CAUSE_4:
744 if (!get_aim_dir(player_ptr, &dir)) {
747 fire_ball_hide(player_ptr, AttributeType::CAUSE_4, dir, damage, 0);
749 case MonsterAbilityType::BO_ACID:
750 if (!get_aim_dir(player_ptr, &dir)) {
753 msg_print(_("アシッド・ボルトの呪文を唱えた。", "You cast an acid bolt."));
756 fire_bolt(player_ptr, AttributeType::ACID, dir, damage);
758 case MonsterAbilityType::BO_ELEC:
759 if (!get_aim_dir(player_ptr, &dir)) {
762 msg_print(_("サンダー・ボルトの呪文を唱えた。", "You cast a lightning bolt."));
765 fire_bolt(player_ptr, AttributeType::ELEC, dir, damage);
767 case MonsterAbilityType::BO_FIRE:
768 if (!get_aim_dir(player_ptr, &dir)) {
771 msg_print(_("ファイア・ボルトの呪文を唱えた。", "You cast a fire bolt."));
774 fire_bolt(player_ptr, AttributeType::FIRE, dir, damage);
776 case MonsterAbilityType::BO_COLD:
777 if (!get_aim_dir(player_ptr, &dir)) {
780 msg_print(_("アイス・ボルトの呪文を唱えた。", "You cast a frost bolt."));
783 fire_bolt(player_ptr, AttributeType::COLD, dir, damage);
785 case MonsterAbilityType::BA_LITE:
786 if (!get_aim_dir(player_ptr, &dir)) {
789 msg_print(_("スターバーストの呪文を念じた。", "You invoke a starburst."));
792 fire_ball(player_ptr, AttributeType::LITE, dir, damage, 4);
794 case MonsterAbilityType::BO_NETH:
795 if (!get_aim_dir(player_ptr, &dir)) {
798 msg_print(_("地獄の矢の呪文を唱えた。", "You cast a nether bolt."));
801 fire_bolt(player_ptr, AttributeType::NETHER, dir, damage);
803 case MonsterAbilityType::BO_WATE:
804 if (!get_aim_dir(player_ptr, &dir)) {
807 msg_print(_("ウォーター・ボルトの呪文を唱えた。", "You cast a water bolt."));
810 fire_bolt(player_ptr, AttributeType::WATER, dir, damage);
812 case MonsterAbilityType::BO_MANA:
813 if (!get_aim_dir(player_ptr, &dir)) {
816 msg_print(_("魔力の矢の呪文を唱えた。", "You cast a mana bolt."));
819 fire_bolt(player_ptr, AttributeType::MANA, dir, damage);
821 case MonsterAbilityType::BO_PLAS:
822 if (!get_aim_dir(player_ptr, &dir)) {
825 msg_print(_("プラズマ・ボルトの呪文を唱えた。", "You cast a plasma bolt."));
828 fire_bolt(player_ptr, AttributeType::PLASMA, dir, damage);
830 case MonsterAbilityType::BO_ICEE:
831 if (!get_aim_dir(player_ptr, &dir)) {
834 msg_print(_("極寒の矢の呪文を唱えた。", "You cast a ice bolt."));
837 fire_bolt(player_ptr, AttributeType::ICE, dir, damage);
839 case MonsterAbilityType::BO_VOID:
840 if (!get_aim_dir(player_ptr, &dir)) {
843 msg_print(_("虚無の矢の呪文を唱えた。", "You cast a void bolt."));
846 fire_bolt(player_ptr, AttributeType::VOID_MAGIC, dir, damage);
848 case MonsterAbilityType::BO_ABYSS:
849 if (!get_aim_dir(player_ptr, &dir)) {
852 msg_print(_("深淵の矢の呪文を唱えた。", "You cast a abyss bolt."));
855 fire_bolt(player_ptr, AttributeType::ABYSS, dir, damage);
857 case MonsterAbilityType::BO_METEOR:
858 if (!get_aim_dir(player_ptr, &dir)) {
861 msg_print(_("メテオストライクの呪文を唱えた。", "You cast a meteor strike."));
864 fire_bolt(player_ptr, AttributeType::METEOR, dir, damage);
866 case MonsterAbilityType::BO_LITE:
867 if (!get_aim_dir(player_ptr, &dir)) {
870 msg_print(_("スターライトアローの呪文を唱えた。", "You cast a starlight arrow."));
873 fire_bolt(player_ptr, AttributeType::LITE, dir, damage);
875 case MonsterAbilityType::MISSILE:
876 if (!get_aim_dir(player_ptr, &dir)) {
879 msg_print(_("マジック・ミサイルの呪文を唱えた。", "You cast a magic missile."));
882 fire_bolt(player_ptr, AttributeType::MISSILE, dir, damage);
884 case MonsterAbilityType::SCARE:
885 if (!get_aim_dir(player_ptr, &dir)) {
888 msg_print(_("恐ろしげな幻覚を作り出した。", "You cast a fearful illusion."));
891 fear_monster(player_ptr, dir, plev + 10);
893 case MonsterAbilityType::BLIND:
894 if (!get_aim_dir(player_ptr, &dir)) {
897 confuse_monster(player_ptr, dir, plev * 2);
899 case MonsterAbilityType::CONF:
900 if (!get_aim_dir(player_ptr, &dir)) {
903 msg_print(_("誘惑的な幻覚をつくり出した。", "You cast a mesmerizing illusion."));
906 confuse_monster(player_ptr, dir, plev * 2);
908 case MonsterAbilityType::SLOW:
909 if (!get_aim_dir(player_ptr, &dir)) {
912 slow_monster(player_ptr, dir, plev);
914 case MonsterAbilityType::HOLD:
915 if (!get_aim_dir(player_ptr, &dir)) {
918 sleep_monster(player_ptr, dir, plev);
920 case MonsterAbilityType::HASTE:
921 (void)set_acceleration(player_ptr, randint1(20 + plev) + plev, false);
923 case MonsterAbilityType::HAND_DOOM: {
924 if (!get_aim_dir(player_ptr, &dir)) {
927 msg_print(_("<破滅の手>を放った!", "You invoke the Hand of Doom!"));
930 fire_ball_hide(player_ptr, AttributeType::HAND_DOOM, dir, 200, 0);
933 case MonsterAbilityType::HEAL: {
934 msg_print(_("自分の傷に念を集中した。", "You concentrate on your wounds!"));
935 (void)hp_player(player_ptr, plev * 6);
936 BadStatusSetter bss(player_ptr);
937 (void)bss.set_stun(0);
938 (void)bss.set_cut(0);
941 case MonsterAbilityType::INVULNER:
942 msg_print(_("無傷の球の呪文を唱えた。", "You cast a Globe of Invulnerability."));
943 (void)set_invuln(player_ptr, randint1(7) + 7, false);
945 case MonsterAbilityType::BLINK:
946 teleport_player(player_ptr, 10, TELEPORT_SPONTANEOUS);
948 case MonsterAbilityType::TPORT:
949 teleport_player(player_ptr, plev * 5, TELEPORT_SPONTANEOUS);
951 case MonsterAbilityType::WORLD:
952 (void)time_walk(player_ptr);
954 case MonsterAbilityType::SPECIAL:
956 case MonsterAbilityType::TELE_TO: {
957 if (!target_set(player_ptr, TARGET_KILL)) {
961 const auto &floor = *player_ptr->current_floor_ptr;
962 const Pos2D pos(target_row, target_col);
963 const auto &grid_target = floor.get_grid(pos);
964 auto should_teleport = !is_monster(grid_target.m_idx);
965 should_teleport &= grid_target.has_los();
966 should_teleport &= projectable(player_ptr, player_ptr->y, player_ptr->x, target_row, target_col);
967 if (!should_teleport) {
971 const auto &monster = floor.m_list[grid_target.m_idx];
972 auto &monrace = monster.get_monrace();
973 const auto m_name = monster_desc(player_ptr, &monster, 0);
974 if (monrace.resistance_flags.has(MonsterResistanceType::RESIST_TELEPORT)) {
975 if (monrace.kind_flags.has(MonsterKindType::UNIQUE) || monrace.resistance_flags.has(MonsterResistanceType::RESIST_ALL)) {
976 if (is_original_ap_and_seen(player_ptr, &monster)) {
977 monrace.r_resistance_flags.set(MonsterResistanceType::RESIST_TELEPORT);
979 msg_format(_("%sには効果がなかった!", "%s is unaffected!"), m_name.data());
982 } else if (monrace.level > randint1(100)) {
983 if (is_original_ap_and_seen(player_ptr, &monster)) {
984 monrace.r_resistance_flags.set(MonsterResistanceType::RESIST_TELEPORT);
986 msg_format(_("%sには耐性がある!", "%s resists!"), m_name.data());
991 msg_format(_("%sを引き戻した。", "You command %s to return."), m_name.data());
993 teleport_monster_to(player_ptr, grid_target.m_idx, player_ptr->y, player_ptr->x, 100, TELEPORT_PASSIVE);
996 case MonsterAbilityType::TELE_AWAY:
997 if (!get_aim_dir(player_ptr, &dir)) {
1001 (void)fire_beam(player_ptr, AttributeType::AWAY_ALL, dir, plev);
1004 case MonsterAbilityType::TELE_LEVEL:
1005 return teleport_level_other(player_ptr);
1008 case MonsterAbilityType::PSY_SPEAR:
1009 if (!get_aim_dir(player_ptr, &dir)) {
1012 msg_print(_("光の剣を放った。", "You throw a psycho-spear."));
1014 (void)fire_beam(player_ptr, AttributeType::PSY_SPEAR, dir, damage);
1017 case MonsterAbilityType::DARKNESS:
1018 msg_print(_("暗闇の中で手を振った。", "You gesture in shadow."));
1019 (void)unlite_area(player_ptr, 10, 3);
1022 case MonsterAbilityType::TRAPS:
1023 if (!target_set(player_ptr, TARGET_KILL)) {
1026 msg_print(_("呪文を唱えて邪悪に微笑んだ。", "You cast a spell and cackle evilly."));
1027 trap_creation(player_ptr, target_row, target_col);
1029 case MonsterAbilityType::FORGET:
1030 msg_print(_("しかし何も起きなかった。", "Nothing happens."));
1032 case MonsterAbilityType::RAISE_DEAD:
1033 msg_print(_("死者復活の呪文を唱えた。", "You animate the dead."));
1034 (void)animate_dead(player_ptr, 0, player_ptr->y, player_ptr->x);
1036 case MonsterAbilityType::S_KIN: {
1038 if (!target_set(player_ptr, TARGET_KILL)) {
1042 msg_print(_("援軍を召喚した。", "You summon minions."));
1043 for (k = 0; k < 4; k++) {
1044 (void)summon_kin_player(player_ptr, plev, target_row, target_col, (PM_FORCE_PET | PM_ALLOW_GROUP));
1048 case MonsterAbilityType::S_CYBER: {
1050 int max_cyber = (player_ptr->current_floor_ptr->dun_level / 50) + randint1(3);
1051 if (!target_set(player_ptr, TARGET_KILL)) {
1054 msg_print(_("サイバーデーモンを召喚した!", "You summon Cyberdemons!"));
1055 if (max_cyber > 4) {
1058 for (k = 0; k < max_cyber; k++) {
1059 summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_CYBER, mode);
1063 case MonsterAbilityType::S_MONSTER: {
1065 if (!target_set(player_ptr, TARGET_KILL)) {
1068 msg_print(_("仲間を召喚した。", "You summon help."));
1069 for (k = 0; k < 1; k++) {
1070 summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_NONE, (mode | u_mode));
1074 case MonsterAbilityType::S_MONSTERS: {
1076 if (!target_set(player_ptr, TARGET_KILL)) {
1079 msg_print(_("モンスターを召喚した!", "You summon monsters!"));
1080 for (k = 0; k < 6; k++) {
1081 summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_NONE, (mode | u_mode));
1085 case MonsterAbilityType::S_ANT: {
1087 if (!target_set(player_ptr, TARGET_KILL)) {
1090 msg_print(_("アリを召喚した。", "You summon ants."));
1091 for (k = 0; k < 6; k++) {
1092 summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_ANT, mode);
1096 case MonsterAbilityType::S_SPIDER: {
1098 if (!target_set(player_ptr, TARGET_KILL)) {
1101 msg_print(_("蜘蛛を召喚した。", "You summon spiders."));
1102 for (k = 0; k < 6; k++) {
1103 summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_SPIDER, mode);
1107 case MonsterAbilityType::S_HOUND: {
1109 if (!target_set(player_ptr, TARGET_KILL)) {
1112 msg_print(_("ハウンドを召喚した。", "You summon hounds."));
1113 for (k = 0; k < 4; k++) {
1114 summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_HOUND, mode);
1118 case MonsterAbilityType::S_HYDRA: {
1120 if (!target_set(player_ptr, TARGET_KILL)) {
1123 msg_print(_("ヒドラを召喚した。", "You summon hydras."));
1124 for (k = 0; k < 4; k++) {
1125 summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_HYDRA, mode);
1129 case MonsterAbilityType::S_ANGEL: {
1131 if (!target_set(player_ptr, TARGET_KILL)) {
1134 msg_print(_("天使を召喚した!", "You summon an angel!"));
1135 for (k = 0; k < 1; k++) {
1136 summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_ANGEL, mode);
1140 case MonsterAbilityType::S_DEMON: {
1142 if (!target_set(player_ptr, TARGET_KILL)) {
1145 msg_print(_("混沌の宮廷から悪魔を召喚した!", "You summon a demon from the Courts of Chaos!"));
1146 for (k = 0; k < 1; k++) {
1147 summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_DEMON, (mode | u_mode));
1151 case MonsterAbilityType::S_UNDEAD: {
1153 if (!target_set(player_ptr, TARGET_KILL)) {
1156 msg_print(_("アンデッドの強敵を召喚した!", "You summon an undead adversary!"));
1157 for (k = 0; k < 1; k++) {
1158 summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_UNDEAD, (mode | u_mode));
1162 case MonsterAbilityType::S_DRAGON: {
1164 if (!target_set(player_ptr, TARGET_KILL)) {
1167 msg_print(_("ドラゴンを召喚した!", "You summon a dragon!"));
1168 for (k = 0; k < 1; k++) {
1169 summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_DRAGON, (mode | u_mode));
1173 case MonsterAbilityType::S_HI_UNDEAD: {
1175 if (!target_set(player_ptr, TARGET_KILL)) {
1178 msg_print(_("強力なアンデッドを召喚した!", "You summon greater undead!"));
1179 for (k = 0; k < 6; k++) {
1180 summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_HI_UNDEAD, (mode | u_mode));
1184 case MonsterAbilityType::S_HI_DRAGON: {
1186 if (!target_set(player_ptr, TARGET_KILL)) {
1189 msg_print(_("古代ドラゴンを召喚した!", "You summon ancient dragons!"));
1190 for (k = 0; k < 4; k++) {
1191 summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_HI_DRAGON, (mode | u_mode));
1195 case MonsterAbilityType::S_AMBERITES: {
1197 if (!target_set(player_ptr, TARGET_KILL)) {
1200 msg_print(_("アンバーの王族を召喚した!", "You summon Lords of Amber!"));
1201 for (k = 0; k < 4; k++) {
1202 summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_AMBERITES, (mode | PM_ALLOW_UNIQUE));
1206 case MonsterAbilityType::S_UNIQUE: {
1208 if (!target_set(player_ptr, TARGET_KILL)) {
1211 msg_print(_("特別な強敵を召喚した!", "You summon special opponents!"));
1212 for (k = 0; k < 4; k++) {
1213 if (summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_UNIQUE, (mode | PM_ALLOW_UNIQUE))) {
1217 for (k = count; k < 4; k++) {
1218 summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_HI_UNDEAD, (mode | u_mode));
1222 case MonsterAbilityType::S_DEAD_UNIQUE: {
1224 if (!target_set(player_ptr, TARGET_KILL)) {
1227 msg_print(_("特別な強敵を蘇生した!", "You summon special dead opponents!"));
1228 for (auto k = 0; k < 4; k++) {
1229 if (summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_DEAD_UNIQUE, (mode | PM_ALLOW_UNIQUE | PM_CLONE))) {
1243 * @brief ものまねコマンドのメインルーチン /
1244 * do_cmd_cast calls this function if the player's class is 'imitator'.
1245 * @param baigaesi TRUEならば倍返し上の処理として行う
1246 * @return 処理を実行したらTRUE、キャンセルした場合FALSEを返す。
1248 * If a valid spell is chosen, saves it in '*sn' and returns TRUE
1249 * If the user hits escape, returns FALSE, and set '*sn' to -1
1250 * If there are no legal choices, returns FALSE, and sets '*sn' to -2
1252 * The "prompt" should be "cast", "recite", or "study"
1253 * The "known" should be TRUE for cast/pray, FALSE for study
1255 * nb: This function has a (trivial) display bug which will be obvious
1256 * when you run it. It's probably easy to fix but I haven't tried,
1259 bool do_cmd_mane(PlayerType *player_ptr, bool baigaesi)
1263 PERCENTAGE minfail = 0;
1264 PLAYER_LEVEL plev = player_ptr->lev;
1265 monster_power spell;
1268 if (cmd_limit_confused(player_ptr)) {
1272 auto mane_data = PlayerClass(player_ptr).get_specific_data<mane_data_type>();
1274 if (mane_data->mane_list.empty()) {
1275 msg_print(_("まねられるものが何もない!", "You don't remember any action!"));
1279 if (!get_mane_power(player_ptr, &n, baigaesi)) {
1283 spell = monster_powers.at(mane_data->mane_list[n].spell);
1285 /* Spell failure chance */
1286 chance = spell.manefail;
1288 /* Reduce failure rate by "effective" level adjustment */
1289 if (plev > spell.level) {
1290 chance -= 3 * (plev - spell.level);
1293 /* Reduce failure rate by 1 stat and DEX adjustment */
1294 chance -= 3 * (adj_mag_stat[player_ptr->stat_index[spell.use_stat]] + adj_mag_stat[player_ptr->stat_index[A_DEX]] - 2) / 2;
1296 if (spell.manedam) {
1297 chance = chance * damage / spell.manedam;
1300 chance += player_ptr->to_m_chance;
1302 /* Extract the minimum failure rate */
1303 minfail = adj_mag_fail[player_ptr->stat_index[spell.use_stat]];
1305 /* Minimum failure rate */
1306 if (chance < minfail) {
1310 auto player_stun = player_ptr->effects()->stun();
1311 chance += player_stun->get_magic_chance_penalty();
1317 if (randint0(100) < chance) {
1318 if (flush_failure) {
1321 msg_print(_("ものまねに失敗した!", "You failed to concentrate hard enough!"));
1325 cast = use_mane(player_ptr, mane_data->mane_list[n].spell);
1331 mane_data->mane_list.erase(std::next(mane_data->mane_list.begin(), n));
1332 PlayerEnergy(player_ptr).set_player_turn_energy(100);
1333 auto &rfu = RedrawingFlagsUpdater::get_instance();
1334 rfu.set_flag(MainWindowRedrawingFlag::IMITATION);
1335 static constexpr auto flags = {
1336 SubWindowRedrawingFlag::PLAYER,
1337 SubWindowRedrawingFlag::SPELL,
1339 rfu.set_flags(flags);