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/player-redraw-types.h"
18 #include "core/stuff-handler.h"
19 #include "core/window-redrawer.h"
20 #include "floor/cave.h"
21 #include "floor/floor-object.h"
22 #include "game-option/disturbance-options.h"
23 #include "game-option/text-display-options.h"
24 #include "hpmp/hp-mp-processor.h"
25 #include "inventory/inventory-slot-types.h"
26 #include "main/sound-definitions-table.h"
27 #include "main/sound-of-music.h"
28 #include "mind/mind-mage.h"
29 #include "monster-floor/monster-summon.h"
30 #include "monster-floor/place-monster-types.h"
31 #include "monster-race/monster-race.h"
32 #include "monster-race/race-ability-flags.h"
33 #include "monster-race/race-flags-resistance.h"
34 #include "monster-race/race-flags1.h"
35 #include "monster/monster-describer.h"
36 #include "monster/monster-info.h"
37 #include "monster/monster-processor.h"
38 #include "monster/monster-status.h"
39 #include "mspell/monster-power-table.h"
40 #include "player-base/player-class.h"
41 #include "player-info/mane-data-type.h"
42 #include "player-status/player-energy.h"
43 #include "player/player-status-table.h"
44 #include "spell-kind/spells-launcher.h"
45 #include "spell-kind/spells-lite.h"
46 #include "spell-kind/spells-neighbor.h"
47 #include "spell-kind/spells-sight.h"
48 #include "spell-kind/spells-teleport.h"
49 #include "spell-kind/spells-world.h"
50 #include "spell/spells-status.h"
51 #include "spell/spells-summon.h"
52 #include "spell/summon-types.h"
53 #include "status/bad-status-setter.h"
54 #include "status/body-improvement.h"
55 #include "status/buff-setter.h"
56 #include "system/floor-type-definition.h"
57 #include "system/grid-type-definition.h"
58 #include "system/item-entity.h"
59 #include "system/monster-race-info.h"
60 #include "system/monster-type-definition.h"
61 #include "system/player-type-definition.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 "timed-effect/player-stun.h"
69 #include "timed-effect/timed-effects.h"
70 #include "util/enum-converter.h"
71 #include "util/int-char-converter.h"
72 #include "view/display-messages.h"
79 * @brief 受け取ったパラメータに応じてものまねの効果情報をまとめたフォーマットを返す
80 * @param p 情報を返す文字列参照ポインタ
81 * @param power ものまねの効力の種類
84 static void mane_info(PlayerType *player_ptr, char *p, MonsterAbilityType power, int dam)
86 PLAYER_LEVEL plev = player_ptr->lev;
90 const auto power_int = enum2i(power);
92 if ((power_int > 2 && power_int < 41) || (power_int > 41 && power_int < 59) || (power == MonsterAbilityType::PSY_SPEAR) || (power == MonsterAbilityType::BO_VOID) || (power == MonsterAbilityType::BO_ABYSS) || (power == MonsterAbilityType::BA_VOID) || (power == MonsterAbilityType::BA_ABYSS) || (power == MonsterAbilityType::BR_VOID) || (power == MonsterAbilityType::BR_ABYSS)) {
93 sprintf(p, " %s%d", KWD_DAM, (int)dam);
96 case MonsterAbilityType::DRAIN_MANA:
97 sprintf(p, " %sd%d+%d", KWD_HEAL, plev * 3, plev);
99 case MonsterAbilityType::HASTE:
100 sprintf(p, " %sd%d+%d", KWD_DURATION, 20 + plev, plev);
102 case MonsterAbilityType::HEAL:
103 sprintf(p, " %s%d", KWD_HEAL, plev * 6);
105 case MonsterAbilityType::INVULNER:
106 sprintf(p, " %sd7+7", KWD_DURATION);
108 case MonsterAbilityType::BLINK:
109 sprintf(p, " %s10", KWD_SPHERE);
111 case MonsterAbilityType::TPORT:
112 sprintf(p, " %s%d", KWD_SPHERE, plev * 5);
114 case MonsterAbilityType::RAISE_DEAD:
115 sprintf(p, " %s5", KWD_SPHERE);
124 * @brief どのものまねを発動するか選択する処理 /
125 * Allow user to choose a imitation.
126 * @param sn 実行したものまねのIDを返す参照ポインタ(キャンセルなどの場合-1を返す)
127 * @param baigaesi TRUEならば倍返し上の処理として行う
128 * @return 処理を実行したらTRUE、キャンセルした場合FALSEを返す。
130 * If a valid spell is chosen, saves it in '*sn' and returns TRUE
131 * If the user hits escape, returns FALSE, and set '*sn' to -1
132 * If there are no legal choices, returns FALSE, and sets '*sn' to -2
134 * The "prompt" should be "cast", "recite", or "study"
135 * The "known" should be TRUE for cast/pray, FALSE for study
137 * nb: This function has a (trivial) display bug which will be obvious
138 * when you run it. It's probably easy to fix but I haven't tried,
141 static int get_mane_power(PlayerType *player_ptr, int *sn, bool baigaesi)
147 PERCENTAGE minfail = 0;
148 PLAYER_LEVEL plev = player_ptr->lev;
149 PERCENTAGE chance = 0;
151 char out_val[MAX_MONSTER_NAME];
153 concptr p = _("能力", "power");
158 /* Assume cancelled */
164 auto mane_data = PlayerClass(player_ptr).get_specific_data<mane_data_type>();
166 num = mane_data->mane_list.size();
168 /* Build a prompt (accept all spells) */
169 (void)strnfmt(out_val, 78, _("(%c-%c, '*'で一覧, ESC) どの%sをまねますか?", "(%c-%c, *=List, ESC=exit) Use which %s? "), I2A(0), I2A(num - 1), p);
171 choice = always_show_list ? ESCAPE : 1;
173 if (choice == ESCAPE) {
175 } else if (!get_com(out_val, &choice, true)) {
180 if ((choice == ' ') || (choice == '*') || (choice == '?')) {
187 /* Display a list of spells */
189 put_str(_("名前", "Name"), y, x + 5);
190 put_str(_("失率 効果", "Fail Info"), y, x + 36);
192 /* Dump the spells */
193 for (i = 0; i < num; i++) {
194 const auto &mane = mane_data->mane_list[i];
195 /* Access the spell */
196 spell = monster_powers.at(mane.spell);
198 chance = spell.manefail;
200 /* Reduce failure rate by "effective" level adjustment */
201 if (plev > spell.level) {
202 chance -= 3 * (plev - spell.level);
205 /* Reduce failure rate by INT/WIS adjustment */
206 chance -= 3 * (adj_mag_stat[player_ptr->stat_index[spell.use_stat]] + adj_mag_stat[player_ptr->stat_index[A_DEX]] - 2) / 2;
209 chance = chance * (baigaesi ? mane.damage * 2 : mane.damage) / spell.manedam;
212 chance += player_ptr->to_m_chance;
214 if (player_ptr->inventory_list[INVEN_NECK].is_specific_artifact(FixedArtifactId::GOGO_PENDANT)) {
218 /* Extract the minimum failure rate */
219 minfail = adj_mag_fail[player_ptr->stat_index[spell.use_stat]];
221 /* Minimum failure rate */
222 if (chance < minfail) {
226 auto player_stun = player_ptr->effects()->stun();
227 chance += player_stun->get_magic_chance_penalty();
233 mane_info(player_ptr, comment, mane.spell, (baigaesi ? mane.damage * 2 : mane.damage));
235 /* Dump the spell --(-- */
236 sprintf(psi_desc, " %c) %-30s %3d%%%s", I2A(i), spell.name, chance, comment);
237 prt(psi_desc, y + i + 1, x);
240 /* Clear the bottom line */
241 prt("", y + i + 1, x);
255 /* Extract request */
258 /* Totally Illegal */
259 if ((i < 0) || (i >= num)) {
264 /* Save the spell index */
265 spell = monster_powers.at(mane_data->mane_list[i].spell);
274 player_ptr->window_flags |= (PW_SPELL);
275 handle_stuff(player_ptr);
277 /* Abort if needed */
282 /* Save the choice */
285 damage = (baigaesi ? mane_data->mane_list[i].damage * 2 : mane_data->mane_list[i].damage);
293 * do_cmd_cast calls this function if the player's class is 'imitator'.
294 * @param player_ptr プレイヤーへの参照ポインタ
295 * @param spell 発動するモンスター攻撃のID
296 * @return 処理を実行したらTRUE、キャンセルした場合FALSEを返す。
298 static bool use_mane(PlayerType *player_ptr, MonsterAbilityType spell)
301 PLAYER_LEVEL plev = player_ptr->lev;
302 BIT_FLAGS mode = (PM_ALLOW_GROUP | PM_FORCE_PET);
303 BIT_FLAGS u_mode = 0L;
305 if (randint1(50 + plev) < plev / 10) {
306 u_mode = PM_ALLOW_UNIQUE;
311 case MonsterAbilityType::SHRIEK:
312 msg_print(_("かん高い金切り声をあげた。", "You make a high pitched shriek."));
313 aggravate_monsters(player_ptr, 0);
316 case MonsterAbilityType::XXX1:
319 case MonsterAbilityType::DISPEL: {
322 if (!target_set(player_ptr, TARGET_KILL)) {
325 m_idx = player_ptr->current_floor_ptr->grid_array[target_row][target_col].m_idx;
329 if (!player_has_los_bold(player_ptr, target_row, target_col)) {
332 if (!projectable(player_ptr, player_ptr->y, player_ptr->x, target_row, target_col)) {
335 dispel_monster_status(player_ptr, m_idx);
339 case MonsterAbilityType::ROCKET:
340 if (!get_aim_dir(player_ptr, &dir)) {
343 msg_print(_("ロケットを発射した。", "You fire a rocket."));
345 fire_rocket(player_ptr, AttributeType::ROCKET, dir, damage, 2);
348 case MonsterAbilityType::SHOOT:
349 if (!get_aim_dir(player_ptr, &dir)) {
352 msg_print(_("矢を放った。", "You fire an arrow."));
354 fire_bolt(player_ptr, AttributeType::MONSTER_SHOOT, dir, damage);
357 case MonsterAbilityType::XXX2:
360 case MonsterAbilityType::XXX3:
363 case MonsterAbilityType::XXX4:
366 case MonsterAbilityType::BR_ACID:
367 if (!get_aim_dir(player_ptr, &dir)) {
370 msg_print(_("酸のブレスを吐いた。", "You breathe acid."));
372 fire_breath(player_ptr, AttributeType::ACID, dir, damage, (plev > 35 ? 3 : 2));
375 case MonsterAbilityType::BR_ELEC:
376 if (!get_aim_dir(player_ptr, &dir)) {
379 msg_print(_("稲妻のブレスを吐いた。", "You breathe lightning."));
381 fire_breath(player_ptr, AttributeType::ELEC, dir, damage, (plev > 35 ? 3 : 2));
384 case MonsterAbilityType::BR_FIRE:
385 if (!get_aim_dir(player_ptr, &dir)) {
388 msg_print(_("火炎のブレスを吐いた。", "You breathe fire."));
390 fire_breath(player_ptr, AttributeType::FIRE, dir, damage, (plev > 35 ? 3 : 2));
393 case MonsterAbilityType::BR_COLD:
394 if (!get_aim_dir(player_ptr, &dir)) {
397 msg_print(_("冷気のブレスを吐いた。", "You breathe frost."));
399 fire_breath(player_ptr, AttributeType::COLD, dir, damage, (plev > 35 ? 3 : 2));
402 case MonsterAbilityType::BR_POIS:
403 if (!get_aim_dir(player_ptr, &dir)) {
406 msg_print(_("ガスのブレスを吐いた。", "You breathe gas."));
408 fire_breath(player_ptr, AttributeType::POIS, dir, damage, (plev > 35 ? 3 : 2));
411 case MonsterAbilityType::BR_NETH:
412 if (!get_aim_dir(player_ptr, &dir)) {
415 msg_print(_("地獄のブレスを吐いた。", "You breathe nether."));
417 fire_breath(player_ptr, AttributeType::NETHER, dir, damage, (plev > 35 ? 3 : 2));
420 case MonsterAbilityType::BR_LITE:
421 if (!get_aim_dir(player_ptr, &dir)) {
424 msg_print(_("閃光のブレスを吐いた。", "You breathe light."));
426 fire_breath(player_ptr, AttributeType::LITE, dir, damage, (plev > 35 ? 3 : 2));
429 case MonsterAbilityType::BR_DARK:
430 if (!get_aim_dir(player_ptr, &dir)) {
433 msg_print(_("暗黒のブレスを吐いた。", "You breathe darkness."));
435 fire_breath(player_ptr, AttributeType::DARK, dir, damage, (plev > 35 ? 3 : 2));
438 case MonsterAbilityType::BR_CONF:
439 if (!get_aim_dir(player_ptr, &dir)) {
442 msg_print(_("混乱のブレスを吐いた。", "You breathe confusion."));
444 fire_breath(player_ptr, AttributeType::CONFUSION, dir, damage, (plev > 35 ? 3 : 2));
447 case MonsterAbilityType::BR_SOUN:
448 if (!get_aim_dir(player_ptr, &dir)) {
451 msg_print(_("轟音のブレスを吐いた。", "You breathe sound."));
453 fire_breath(player_ptr, AttributeType::SOUND, dir, damage, (plev > 35 ? 3 : 2));
456 case MonsterAbilityType::BR_CHAO:
457 if (!get_aim_dir(player_ptr, &dir)) {
460 msg_print(_("カオスのブレスを吐いた。", "You breathe chaos."));
462 fire_breath(player_ptr, AttributeType::CHAOS, dir, damage, (plev > 35 ? 3 : 2));
465 case MonsterAbilityType::BR_DISE:
466 if (!get_aim_dir(player_ptr, &dir)) {
469 msg_print(_("劣化のブレスを吐いた。", "You breathe disenchantment."));
471 fire_breath(player_ptr, AttributeType::DISENCHANT, dir, damage, (plev > 35 ? 3 : 2));
474 case MonsterAbilityType::BR_NEXU:
475 if (!get_aim_dir(player_ptr, &dir)) {
478 msg_print(_("因果混乱のブレスを吐いた。", "You breathe nexus."));
480 fire_breath(player_ptr, AttributeType::NEXUS, dir, damage, (plev > 35 ? 3 : 2));
483 case MonsterAbilityType::BR_TIME:
484 if (!get_aim_dir(player_ptr, &dir)) {
487 msg_print(_("時間逆転のブレスを吐いた。", "You breathe time."));
489 fire_breath(player_ptr, AttributeType::TIME, dir, damage, (plev > 35 ? 3 : 2));
492 case MonsterAbilityType::BR_INER:
493 if (!get_aim_dir(player_ptr, &dir)) {
496 msg_print(_("遅鈍のブレスを吐いた。", "You breathe inertia."));
498 fire_breath(player_ptr, AttributeType::INERTIAL, dir, damage, (plev > 35 ? 3 : 2));
501 case MonsterAbilityType::BR_GRAV:
502 if (!get_aim_dir(player_ptr, &dir)) {
505 msg_print(_("重力のブレスを吐いた。", "You breathe gravity."));
507 fire_breath(player_ptr, AttributeType::GRAVITY, dir, damage, (plev > 35 ? 3 : 2));
510 case MonsterAbilityType::BR_SHAR:
511 if (!get_aim_dir(player_ptr, &dir)) {
514 msg_print(_("破片のブレスを吐いた。", "You breathe shards."));
516 fire_breath(player_ptr, AttributeType::SHARDS, dir, damage, (plev > 35 ? 3 : 2));
519 case MonsterAbilityType::BR_PLAS:
520 if (!get_aim_dir(player_ptr, &dir)) {
523 msg_print(_("プラズマのブレスを吐いた。", "You breathe plasma."));
525 fire_breath(player_ptr, AttributeType::PLASMA, dir, damage, (plev > 35 ? 3 : 2));
528 case MonsterAbilityType::BR_FORC:
529 if (!get_aim_dir(player_ptr, &dir)) {
532 msg_print(_("フォースのブレスを吐いた。", "You breathe force."));
534 fire_breath(player_ptr, AttributeType::FORCE, dir, damage, (plev > 35 ? 3 : 2));
537 case MonsterAbilityType::BR_MANA:
538 if (!get_aim_dir(player_ptr, &dir)) {
541 msg_print(_("魔力のブレスを吐いた。", "You breathe mana."));
543 fire_breath(player_ptr, AttributeType::MANA, dir, damage, (plev > 35 ? 3 : 2));
546 case MonsterAbilityType::BA_NUKE:
547 if (!get_aim_dir(player_ptr, &dir)) {
550 msg_print(_("放射能球を放った。", "You cast a ball of radiation."));
552 fire_ball(player_ptr, AttributeType::NUKE, dir, damage, 2);
555 case MonsterAbilityType::BR_NUKE:
556 if (!get_aim_dir(player_ptr, &dir)) {
559 msg_print(_("放射性廃棄物のブレスを吐いた。", "You breathe toxic waste."));
562 fire_breath(player_ptr, AttributeType::NUKE, dir, damage, (plev > 35 ? 3 : 2));
565 case MonsterAbilityType::BA_CHAO:
566 if (!get_aim_dir(player_ptr, &dir)) {
569 msg_print(_("純ログルスを放った。", "You invoke a raw Logrus."));
572 fire_ball(player_ptr, AttributeType::CHAOS, dir, damage, 4);
574 case MonsterAbilityType::BR_DISI:
575 if (!get_aim_dir(player_ptr, &dir)) {
578 msg_print(_("分解のブレスを吐いた。", "You breathe disintegration."));
581 fire_breath(player_ptr, AttributeType::DISINTEGRATE, dir, damage, (plev > 35 ? 3 : 2));
583 case MonsterAbilityType::BR_VOID:
584 if (!get_aim_dir(player_ptr, &dir)) {
587 msg_print(_("虚無のブレスを吐いた。", "You breathe void."));
590 fire_breath(player_ptr, AttributeType::VOID_MAGIC, dir, damage, (plev > 35 ? 3 : 2));
593 case MonsterAbilityType::BR_ABYSS:
594 if (!get_aim_dir(player_ptr, &dir)) {
597 msg_print(_("深淵のブレスを吐いた。", "You breathe abyss."));
600 fire_breath(player_ptr, AttributeType::ABYSS, dir, damage, (plev > 35 ? 3 : 2));
603 case MonsterAbilityType::BA_ACID:
604 if (!get_aim_dir(player_ptr, &dir)) {
607 msg_print(_("アシッド・ボールの呪文を唱えた。", "You cast an acid ball."));
610 fire_ball(player_ptr, AttributeType::ACID, dir, damage, 2);
612 case MonsterAbilityType::BA_ELEC:
613 if (!get_aim_dir(player_ptr, &dir)) {
616 msg_print(_("サンダー・ボールの呪文を唱えた。", "You cast a lightning ball."));
619 fire_ball(player_ptr, AttributeType::ELEC, dir, damage, 2);
621 case MonsterAbilityType::BA_FIRE:
622 if (!get_aim_dir(player_ptr, &dir)) {
625 msg_print(_("ファイア・ボールの呪文を唱えた。", "You cast a fire ball."));
628 fire_ball(player_ptr, AttributeType::FIRE, dir, damage, 2);
630 case MonsterAbilityType::BA_COLD:
631 if (!get_aim_dir(player_ptr, &dir)) {
634 msg_print(_("アイス・ボールの呪文を唱えた。", "You cast a frost ball."));
637 fire_ball(player_ptr, AttributeType::COLD, dir, damage, 2);
639 case MonsterAbilityType::BA_POIS:
640 if (!get_aim_dir(player_ptr, &dir)) {
643 msg_print(_("悪臭雲の呪文を唱えた。", "You cast a stinking cloud."));
646 fire_ball(player_ptr, AttributeType::POIS, dir, damage, 2);
648 case MonsterAbilityType::BA_NETH:
649 if (!get_aim_dir(player_ptr, &dir)) {
652 msg_print(_("地獄球の呪文を唱えた。", "You cast a nether ball."));
655 fire_ball(player_ptr, AttributeType::NETHER, dir, damage, 2);
657 case MonsterAbilityType::BA_WATE:
658 if (!get_aim_dir(player_ptr, &dir)) {
661 msg_print(_("流れるような身振りをした。", "You gesture fluidly."));
664 fire_ball(player_ptr, AttributeType::WATER, dir, damage, 4);
666 case MonsterAbilityType::BA_MANA:
667 if (!get_aim_dir(player_ptr, &dir)) {
670 msg_print(_("魔力の嵐の呪文を念じた。", "You invoke a mana storm."));
673 fire_ball(player_ptr, AttributeType::MANA, dir, damage, 4);
675 case MonsterAbilityType::BA_DARK:
676 if (!get_aim_dir(player_ptr, &dir)) {
679 msg_print(_("暗黒の嵐の呪文を念じた。", "You invoke a darkness storm."));
682 fire_ball(player_ptr, AttributeType::DARK, dir, damage, 4);
684 case MonsterAbilityType::BA_VOID:
685 if (!get_aim_dir(player_ptr, &dir)) {
688 msg_print(_("虚無の嵐の呪文を念じた。", "You cast a void ball."));
691 fire_ball(player_ptr, AttributeType::VOID_MAGIC, dir, damage, 4);
693 case MonsterAbilityType::BA_ABYSS:
694 if (!get_aim_dir(player_ptr, &dir)) {
697 msg_print(_("深淵の嵐の呪文を念じた。", "You cast a abyss ball."));
700 fire_ball(player_ptr, AttributeType::ABYSS, dir, damage, 4);
702 case MonsterAbilityType::DRAIN_MANA:
703 if (!get_aim_dir(player_ptr, &dir)) {
706 fire_ball_hide(player_ptr, AttributeType::DRAIN_MANA, dir, randint1(plev * 3) + plev, 0);
708 case MonsterAbilityType::MIND_BLAST:
709 if (!get_aim_dir(player_ptr, &dir)) {
712 fire_ball_hide(player_ptr, AttributeType::MIND_BLAST, dir, damage, 0);
714 case MonsterAbilityType::BRAIN_SMASH:
715 if (!get_aim_dir(player_ptr, &dir)) {
718 fire_ball_hide(player_ptr, AttributeType::BRAIN_SMASH, dir, damage, 0);
720 case MonsterAbilityType::CAUSE_1:
721 if (!get_aim_dir(player_ptr, &dir)) {
724 fire_ball_hide(player_ptr, AttributeType::CAUSE_1, dir, damage, 0);
726 case MonsterAbilityType::CAUSE_2:
727 if (!get_aim_dir(player_ptr, &dir)) {
730 fire_ball_hide(player_ptr, AttributeType::CAUSE_2, dir, damage, 0);
732 case MonsterAbilityType::CAUSE_3:
733 if (!get_aim_dir(player_ptr, &dir)) {
736 fire_ball_hide(player_ptr, AttributeType::CAUSE_3, dir, damage, 0);
738 case MonsterAbilityType::CAUSE_4:
739 if (!get_aim_dir(player_ptr, &dir)) {
742 fire_ball_hide(player_ptr, AttributeType::CAUSE_4, dir, damage, 0);
744 case MonsterAbilityType::BO_ACID:
745 if (!get_aim_dir(player_ptr, &dir)) {
748 msg_print(_("アシッド・ボルトの呪文を唱えた。", "You cast an acid bolt."));
751 fire_bolt(player_ptr, AttributeType::ACID, dir, damage);
753 case MonsterAbilityType::BO_ELEC:
754 if (!get_aim_dir(player_ptr, &dir)) {
757 msg_print(_("サンダー・ボルトの呪文を唱えた。", "You cast a lightning bolt."));
760 fire_bolt(player_ptr, AttributeType::ELEC, dir, damage);
762 case MonsterAbilityType::BO_FIRE:
763 if (!get_aim_dir(player_ptr, &dir)) {
766 msg_print(_("ファイア・ボルトの呪文を唱えた。", "You cast a fire bolt."));
769 fire_bolt(player_ptr, AttributeType::FIRE, dir, damage);
771 case MonsterAbilityType::BO_COLD:
772 if (!get_aim_dir(player_ptr, &dir)) {
775 msg_print(_("アイス・ボルトの呪文を唱えた。", "You cast a frost bolt."));
778 fire_bolt(player_ptr, AttributeType::COLD, dir, damage);
780 case MonsterAbilityType::BA_LITE:
781 if (!get_aim_dir(player_ptr, &dir)) {
784 msg_print(_("スターバーストの呪文を念じた。", "You invoke a starburst."));
787 fire_ball(player_ptr, AttributeType::LITE, dir, damage, 4);
789 case MonsterAbilityType::BO_NETH:
790 if (!get_aim_dir(player_ptr, &dir)) {
793 msg_print(_("地獄の矢の呪文を唱えた。", "You cast a nether bolt."));
796 fire_bolt(player_ptr, AttributeType::NETHER, dir, damage);
798 case MonsterAbilityType::BO_WATE:
799 if (!get_aim_dir(player_ptr, &dir)) {
802 msg_print(_("ウォーター・ボルトの呪文を唱えた。", "You cast a water bolt."));
805 fire_bolt(player_ptr, AttributeType::WATER, dir, damage);
807 case MonsterAbilityType::BO_MANA:
808 if (!get_aim_dir(player_ptr, &dir)) {
811 msg_print(_("魔力の矢の呪文を唱えた。", "You cast a mana bolt."));
814 fire_bolt(player_ptr, AttributeType::MANA, dir, damage);
816 case MonsterAbilityType::BO_PLAS:
817 if (!get_aim_dir(player_ptr, &dir)) {
820 msg_print(_("プラズマ・ボルトの呪文を唱えた。", "You cast a plasma bolt."));
823 fire_bolt(player_ptr, AttributeType::PLASMA, dir, damage);
825 case MonsterAbilityType::BO_ICEE:
826 if (!get_aim_dir(player_ptr, &dir)) {
829 msg_print(_("極寒の矢の呪文を唱えた。", "You cast a ice bolt."));
832 fire_bolt(player_ptr, AttributeType::ICE, dir, damage);
834 case MonsterAbilityType::BO_VOID:
835 if (!get_aim_dir(player_ptr, &dir)) {
838 msg_print(_("虚無の矢の呪文を唱えた。", "You cast a void bolt."));
841 fire_bolt(player_ptr, AttributeType::VOID_MAGIC, dir, damage);
843 case MonsterAbilityType::BO_ABYSS:
844 if (!get_aim_dir(player_ptr, &dir)) {
847 msg_print(_("深淵の矢の呪文を唱えた。", "You cast a abyss bolt."));
850 fire_bolt(player_ptr, AttributeType::ABYSS, dir, damage);
852 case MonsterAbilityType::MISSILE:
853 if (!get_aim_dir(player_ptr, &dir)) {
856 msg_print(_("マジック・ミサイルの呪文を唱えた。", "You cast a magic missile."));
859 fire_bolt(player_ptr, AttributeType::MISSILE, dir, damage);
861 case MonsterAbilityType::SCARE:
862 if (!get_aim_dir(player_ptr, &dir)) {
865 msg_print(_("恐ろしげな幻覚を作り出した。", "You cast a fearful illusion."));
868 fear_monster(player_ptr, dir, plev + 10);
870 case MonsterAbilityType::BLIND:
871 if (!get_aim_dir(player_ptr, &dir)) {
874 confuse_monster(player_ptr, dir, plev * 2);
876 case MonsterAbilityType::CONF:
877 if (!get_aim_dir(player_ptr, &dir)) {
880 msg_print(_("誘惑的な幻覚をつくり出した。", "You cast a mesmerizing illusion."));
883 confuse_monster(player_ptr, dir, plev * 2);
885 case MonsterAbilityType::SLOW:
886 if (!get_aim_dir(player_ptr, &dir)) {
889 slow_monster(player_ptr, dir, plev);
891 case MonsterAbilityType::HOLD:
892 if (!get_aim_dir(player_ptr, &dir)) {
895 sleep_monster(player_ptr, dir, plev);
897 case MonsterAbilityType::HASTE:
898 (void)set_acceleration(player_ptr, randint1(20 + plev) + plev, false);
900 case MonsterAbilityType::HAND_DOOM: {
901 if (!get_aim_dir(player_ptr, &dir)) {
904 msg_print(_("<破滅の手>を放った!", "You invoke the Hand of Doom!"));
907 fire_ball_hide(player_ptr, AttributeType::HAND_DOOM, dir, 200, 0);
910 case MonsterAbilityType::HEAL: {
911 msg_print(_("自分の傷に念を集中した。", "You concentrate on your wounds!"));
912 (void)hp_player(player_ptr, plev * 6);
913 BadStatusSetter bss(player_ptr);
914 (void)bss.set_stun(0);
915 (void)bss.set_cut(0);
918 case MonsterAbilityType::INVULNER:
919 msg_print(_("無傷の球の呪文を唱えた。", "You cast a Globe of Invulnerability."));
920 (void)set_invuln(player_ptr, randint1(7) + 7, false);
922 case MonsterAbilityType::BLINK:
923 teleport_player(player_ptr, 10, TELEPORT_SPONTANEOUS);
925 case MonsterAbilityType::TPORT:
926 teleport_player(player_ptr, plev * 5, TELEPORT_SPONTANEOUS);
928 case MonsterAbilityType::WORLD:
929 (void)time_walk(player_ptr);
931 case MonsterAbilityType::SPECIAL:
933 case MonsterAbilityType::TELE_TO: {
934 MonsterEntity *m_ptr;
935 MonsterRaceInfo *r_ptr;
936 GAME_TEXT m_name[MAX_NLEN];
938 if (!target_set(player_ptr, TARGET_KILL)) {
941 if (!player_ptr->current_floor_ptr->grid_array[target_row][target_col].m_idx) {
944 if (!player_has_los_bold(player_ptr, target_row, target_col)) {
947 if (!projectable(player_ptr, player_ptr->y, player_ptr->x, target_row, target_col)) {
950 m_ptr = &player_ptr->current_floor_ptr->m_list[player_ptr->current_floor_ptr->grid_array[target_row][target_col].m_idx];
951 r_ptr = &monraces_info[m_ptr->r_idx];
952 monster_desc(player_ptr, m_name, m_ptr, 0);
953 if (r_ptr->resistance_flags.has(MonsterResistanceType::RESIST_TELEPORT)) {
954 if (r_ptr->kind_flags.has(MonsterKindType::UNIQUE) || r_ptr->resistance_flags.has(MonsterResistanceType::RESIST_ALL)) {
955 if (is_original_ap_and_seen(player_ptr, m_ptr)) {
956 r_ptr->r_resistance_flags.set(MonsterResistanceType::RESIST_TELEPORT);
958 msg_format(_("%sには効果がなかった!", "%s is unaffected!"), m_name);
961 } else if (r_ptr->level > randint1(100)) {
962 if (is_original_ap_and_seen(player_ptr, m_ptr)) {
963 r_ptr->r_resistance_flags.set(MonsterResistanceType::RESIST_TELEPORT);
965 msg_format(_("%sには耐性がある!", "%s resists!"), m_name);
970 msg_format(_("%sを引き戻した。", "You command %s to return."), m_name);
973 player_ptr, player_ptr->current_floor_ptr->grid_array[target_row][target_col].m_idx, player_ptr->y, player_ptr->x, 100, TELEPORT_PASSIVE);
976 case MonsterAbilityType::TELE_AWAY:
977 if (!get_aim_dir(player_ptr, &dir)) {
981 (void)fire_beam(player_ptr, AttributeType::AWAY_ALL, dir, plev);
984 case MonsterAbilityType::TELE_LEVEL:
985 return teleport_level_other(player_ptr);
988 case MonsterAbilityType::PSY_SPEAR:
989 if (!get_aim_dir(player_ptr, &dir)) {
992 msg_print(_("光の剣を放った。", "You throw a psycho-spear."));
994 (void)fire_beam(player_ptr, AttributeType::PSY_SPEAR, dir, damage);
997 case MonsterAbilityType::DARKNESS:
998 msg_print(_("暗闇の中で手を振った。", "You gesture in shadow."));
999 (void)unlite_area(player_ptr, 10, 3);
1002 case MonsterAbilityType::TRAPS:
1003 if (!target_set(player_ptr, TARGET_KILL)) {
1006 msg_print(_("呪文を唱えて邪悪に微笑んだ。", "You cast a spell and cackle evilly."));
1007 trap_creation(player_ptr, target_row, target_col);
1009 case MonsterAbilityType::FORGET:
1010 msg_print(_("しかし何も起きなかった。", "Nothing happens."));
1012 case MonsterAbilityType::RAISE_DEAD:
1013 msg_print(_("死者復活の呪文を唱えた。", "You animate the dead."));
1014 (void)animate_dead(player_ptr, 0, player_ptr->y, player_ptr->x);
1016 case MonsterAbilityType::S_KIN: {
1018 if (!target_set(player_ptr, TARGET_KILL)) {
1022 msg_print(_("援軍を召喚した。", "You summon minions."));
1023 for (k = 0; k < 4; k++) {
1024 (void)summon_kin_player(player_ptr, plev, target_row, target_col, (PM_FORCE_PET | PM_ALLOW_GROUP));
1028 case MonsterAbilityType::S_CYBER: {
1030 int max_cyber = (player_ptr->current_floor_ptr->dun_level / 50) + randint1(3);
1031 if (!target_set(player_ptr, TARGET_KILL)) {
1034 msg_print(_("サイバーデーモンを召喚した!", "You summon Cyberdemons!"));
1035 if (max_cyber > 4) {
1038 for (k = 0; k < max_cyber; k++) {
1039 summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_CYBER, mode);
1043 case MonsterAbilityType::S_MONSTER: {
1045 if (!target_set(player_ptr, TARGET_KILL)) {
1048 msg_print(_("仲間を召喚した。", "You summon help."));
1049 for (k = 0; k < 1; k++) {
1050 summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_NONE, (mode | u_mode));
1054 case MonsterAbilityType::S_MONSTERS: {
1056 if (!target_set(player_ptr, TARGET_KILL)) {
1059 msg_print(_("モンスターを召喚した!", "You summon monsters!"));
1060 for (k = 0; k < 6; k++) {
1061 summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_NONE, (mode | u_mode));
1065 case MonsterAbilityType::S_ANT: {
1067 if (!target_set(player_ptr, TARGET_KILL)) {
1070 msg_print(_("アリを召喚した。", "You summon ants."));
1071 for (k = 0; k < 6; k++) {
1072 summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_ANT, mode);
1076 case MonsterAbilityType::S_SPIDER: {
1078 if (!target_set(player_ptr, TARGET_KILL)) {
1081 msg_print(_("蜘蛛を召喚した。", "You summon spiders."));
1082 for (k = 0; k < 6; k++) {
1083 summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_SPIDER, mode);
1087 case MonsterAbilityType::S_HOUND: {
1089 if (!target_set(player_ptr, TARGET_KILL)) {
1092 msg_print(_("ハウンドを召喚した。", "You summon hounds."));
1093 for (k = 0; k < 4; k++) {
1094 summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_HOUND, mode);
1098 case MonsterAbilityType::S_HYDRA: {
1100 if (!target_set(player_ptr, TARGET_KILL)) {
1103 msg_print(_("ヒドラを召喚した。", "You summon hydras."));
1104 for (k = 0; k < 4; k++) {
1105 summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_HYDRA, mode);
1109 case MonsterAbilityType::S_ANGEL: {
1111 if (!target_set(player_ptr, TARGET_KILL)) {
1114 msg_print(_("天使を召喚した!", "You summon an angel!"));
1115 for (k = 0; k < 1; k++) {
1116 summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_ANGEL, mode);
1120 case MonsterAbilityType::S_DEMON: {
1122 if (!target_set(player_ptr, TARGET_KILL)) {
1125 msg_print(_("混沌の宮廷から悪魔を召喚した!", "You summon a demon from the Courts of Chaos!"));
1126 for (k = 0; k < 1; k++) {
1127 summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_DEMON, (mode | u_mode));
1131 case MonsterAbilityType::S_UNDEAD: {
1133 if (!target_set(player_ptr, TARGET_KILL)) {
1136 msg_print(_("アンデッドの強敵を召喚した!", "You summon an undead adversary!"));
1137 for (k = 0; k < 1; k++) {
1138 summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_UNDEAD, (mode | u_mode));
1142 case MonsterAbilityType::S_DRAGON: {
1144 if (!target_set(player_ptr, TARGET_KILL)) {
1147 msg_print(_("ドラゴンを召喚した!", "You summon a dragon!"));
1148 for (k = 0; k < 1; k++) {
1149 summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_DRAGON, (mode | u_mode));
1153 case MonsterAbilityType::S_HI_UNDEAD: {
1155 if (!target_set(player_ptr, TARGET_KILL)) {
1158 msg_print(_("強力なアンデッドを召喚した!", "You summon greater undead!"));
1159 for (k = 0; k < 6; k++) {
1160 summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_HI_UNDEAD, (mode | u_mode));
1164 case MonsterAbilityType::S_HI_DRAGON: {
1166 if (!target_set(player_ptr, TARGET_KILL)) {
1169 msg_print(_("古代ドラゴンを召喚した!", "You summon ancient dragons!"));
1170 for (k = 0; k < 4; k++) {
1171 summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_HI_DRAGON, (mode | u_mode));
1175 case MonsterAbilityType::S_AMBERITES: {
1177 if (!target_set(player_ptr, TARGET_KILL)) {
1180 msg_print(_("アンバーの王族を召喚した!", "You summon Lords of Amber!"));
1181 for (k = 0; k < 4; k++) {
1182 summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_AMBERITES, (mode | PM_ALLOW_UNIQUE));
1186 case MonsterAbilityType::S_UNIQUE: {
1188 if (!target_set(player_ptr, TARGET_KILL)) {
1191 msg_print(_("特別な強敵を召喚した!", "You summon special opponents!"));
1192 for (k = 0; k < 4; k++) {
1193 if (summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_UNIQUE, (mode | PM_ALLOW_UNIQUE))) {
1197 for (k = count; k < 4; k++) {
1198 summon_specific(player_ptr, -1, target_row, target_col, plev, SUMMON_HI_UNDEAD, (mode | u_mode));
1210 * @brief ものまねコマンドのメインルーチン /
1211 * do_cmd_cast calls this function if the player's class is 'imitator'.
1212 * @param baigaesi TRUEならば倍返し上の処理として行う
1213 * @return 処理を実行したらTRUE、キャンセルした場合FALSEを返す。
1215 * If a valid spell is chosen, saves it in '*sn' and returns TRUE
1216 * If the user hits escape, returns FALSE, and set '*sn' to -1
1217 * If there are no legal choices, returns FALSE, and sets '*sn' to -2
1219 * The "prompt" should be "cast", "recite", or "study"
1220 * The "known" should be TRUE for cast/pray, FALSE for study
1222 * nb: This function has a (trivial) display bug which will be obvious
1223 * when you run it. It's probably easy to fix but I haven't tried,
1226 bool do_cmd_mane(PlayerType *player_ptr, bool baigaesi)
1230 PERCENTAGE minfail = 0;
1231 PLAYER_LEVEL plev = player_ptr->lev;
1232 monster_power spell;
1235 if (cmd_limit_confused(player_ptr)) {
1239 auto mane_data = PlayerClass(player_ptr).get_specific_data<mane_data_type>();
1241 if (mane_data->mane_list.empty()) {
1242 msg_print(_("まねられるものが何もない!", "You don't remember any action!"));
1246 if (!get_mane_power(player_ptr, &n, baigaesi)) {
1250 spell = monster_powers.at(mane_data->mane_list[n].spell);
1252 /* Spell failure chance */
1253 chance = spell.manefail;
1255 /* Reduce failure rate by "effective" level adjustment */
1256 if (plev > spell.level) {
1257 chance -= 3 * (plev - spell.level);
1260 /* Reduce failure rate by 1 stat and DEX adjustment */
1261 chance -= 3 * (adj_mag_stat[player_ptr->stat_index[spell.use_stat]] + adj_mag_stat[player_ptr->stat_index[A_DEX]] - 2) / 2;
1263 if (spell.manedam) {
1264 chance = chance * damage / spell.manedam;
1267 chance += player_ptr->to_m_chance;
1269 /* Extract the minimum failure rate */
1270 minfail = adj_mag_fail[player_ptr->stat_index[spell.use_stat]];
1272 /* Minimum failure rate */
1273 if (chance < minfail) {
1277 auto player_stun = player_ptr->effects()->stun();
1278 chance += player_stun->get_magic_chance_penalty();
1284 if (randint0(100) < chance) {
1285 if (flush_failure) {
1288 msg_print(_("ものまねに失敗した!", "You failed to concentrate hard enough!"));
1292 cast = use_mane(player_ptr, mane_data->mane_list[n].spell);
1298 mane_data->mane_list.erase(std::next(mane_data->mane_list.begin(), n));
1300 PlayerEnergy(player_ptr).set_player_turn_energy(100);
1302 player_ptr->redraw |= (PR_IMITATION);
1303 player_ptr->window_flags |= (PW_PLAYER);
1304 player_ptr->window_flags |= (PW_SPELL);