OSDN Git Service

Merge pull request #820 from iks3/feature-player-race-flags-to-struct
[hengbandforosx/hengbandosx.git] / src / cmd-action / cmd-mane.cpp
1 /*!
2  * @brief ものまねの処理実装 / Imitation code
3  * @date 2014/01/14
4  * @author
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
10  */
11
12 #include "action/action-limited.h"
13 #include "cmd-action/cmd-spell.h"
14 #include "core/asking-player.h"
15 #include "core/hp-mp-processor.h"
16 #include "core/player-redraw-types.h"
17 #include "core/stuff-handler.h"
18 #include "core/window-redrawer.h"
19 #include "floor/cave.h"
20 #include "floor/floor-object.h"
21 #include "game-option/disturbance-options.h"
22 #include "game-option/text-display-options.h"
23 #include "grid/grid.h"
24 #include "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-flags-resistance.h"
31 #include "monster-race/race-flags1.h"
32 #include "monster/monster-describer.h"
33 #include "monster/monster-info.h"
34 #include "monster/monster-processor.h"
35 #include "monster/monster-status.h"
36 #include "mspell/monster-power-table.h"
37 #include "player/player-status-table.h"
38 #include "player/player-status.h"
39 #include "spell-kind/spells-launcher.h"
40 #include "spell-kind/spells-lite.h"
41 #include "spell-kind/spells-neighbor.h"
42 #include "spell-kind/spells-sight.h"
43 #include "spell-kind/spells-teleport.h"
44 #include "spell-kind/spells-world.h"
45 #include "spell/spell-types.h"
46 #include "spell/spells-status.h"
47 #include "spell/spells-summon.h"
48 #include "spell/summon-types.h"
49 #include "status/bad-status-setter.h"
50 #include "status/body-improvement.h"
51 #include "status/buff-setter.h"
52 #include "system/floor-type-definition.h"
53 #include "target/projection-path-calculator.h"
54 #include "target/target-checker.h"
55 #include "target/target-getter.h"
56 #include "target/target-setter.h"
57 #include "target/target-types.h"
58 #include "term/screen-processor.h"
59 #include "util/int-char-converter.h"
60 #include "view/display-messages.h"
61
62 static int damage;
63
64 /*!
65  * @brief 受け取ったパラメータに応じてものまねの効果情報をまとめたフォーマットを返す
66  * @param p 情報を返す文字列参照ポインタ
67  * @param power ものまねの効力の種類
68  * @param dam ものまねの威力
69  * @return なし
70  */
71 static void mane_info(player_type *caster_ptr, char *p, RF_ABILITY power, HIT_POINT dam)
72 {
73     PLAYER_LEVEL plev = caster_ptr->lev;
74
75     strcpy(p, "");
76
77     const auto power_int = static_cast<int>(power);
78
79     if ((power_int > 2 && power_int < 41) || (power_int > 41 && power_int < 59) || (power == RF_ABILITY::PSY_SPEAR))
80         sprintf(p, " %s%d", KWD_DAM, (int)dam);
81     else {
82         switch (power) {
83         case RF_ABILITY::DRAIN_MANA:
84             sprintf(p, " %sd%d+%d", KWD_HEAL, plev * 3, plev);
85             break;
86         case RF_ABILITY::HASTE:
87             sprintf(p, " %sd%d+%d", KWD_DURATION, 20 + plev, plev);
88             break;
89         case RF_ABILITY::HEAL:
90             sprintf(p, " %s%d", KWD_HEAL, plev * 6);
91             break;
92         case RF_ABILITY::INVULNER:
93             sprintf(p, " %sd7+7", KWD_DURATION);
94             break;
95         case RF_ABILITY::BLINK:
96             sprintf(p, " %s10", KWD_SPHERE);
97             break;
98         case RF_ABILITY::TPORT:
99             sprintf(p, " %s%d", KWD_SPHERE, plev * 5);
100             break;
101         case RF_ABILITY::RAISE_DEAD:
102             sprintf(p, " %s5", KWD_SPHERE);
103             break;
104         default:
105             break;
106         }
107     }
108 }
109
110 /*!
111  * @brief どのものまねを発動するか選択する処理 /
112  * Allow user to choose a imitation.
113  * @param sn 実行したものまねのIDを返す参照ポインタ(キャンセルなどの場合-1を返す)
114  * @param baigaesi TRUEならば倍返し上の処理として行う
115  * @return 処理を実行したらTRUE、キャンセルした場合FALSEを返す。
116  * @details
117  * If a valid spell is chosen, saves it in '*sn' and returns TRUE
118  * If the user hits escape, returns FALSE, and set '*sn' to -1
119  * If there are no legal choices, returns FALSE, and sets '*sn' to -2
120  *
121  * The "prompt" should be "cast", "recite", or "study"
122  * The "known" should be TRUE for cast/pray, FALSE for study
123  *
124  * nb: This function has a (trivial) display bug which will be obvious
125  * when you run it. It's probably easy to fix but I haven't tried,
126  * sorry.
127  */
128 static int get_mane_power(player_type *caster_ptr, int *sn, bool baigaesi)
129 {
130     int i = 0;
131     int num = 0;
132     TERM_LEN y = 1;
133     TERM_LEN x = 18;
134     PERCENTAGE minfail = 0;
135     PLAYER_LEVEL plev = caster_ptr->lev;
136     PERCENTAGE chance = 0;
137     int ask;
138     char choice;
139     char out_val[MAX_MONSTER_NAME];
140     char comment[80];
141     concptr p = _("能力", "power");
142
143     monster_power spell;
144     bool flag, redraw;
145
146     /* Assume cancelled */
147     *sn = (-1);
148
149     flag = FALSE;
150     redraw = FALSE;
151
152     num = caster_ptr->mane_num;
153
154     /* Build a prompt (accept all spells) */
155     (void)strnfmt(out_val, 78, _("(%c-%c, '*'で一覧, ESC) どの%sをまねますか?", "(%c-%c, *=List, ESC=exit) Use which %s? "), I2A(0), I2A(num - 1), p);
156
157     choice = always_show_list ? ESCAPE : 1;
158     while (!flag) {
159         if (choice == ESCAPE)
160             choice = ' ';
161         else if (!get_com(out_val, &choice, TRUE))
162             break;
163
164         /* Request redraw */
165         if ((choice == ' ') || (choice == '*') || (choice == '?')) {
166             /* Show the list */
167             if (!redraw) {
168                 char psi_desc[160];
169                 redraw = TRUE;
170                 screen_save();
171
172                 /* Display a list of spells */
173                 prt("", y, x);
174                 put_str(_("名前", "Name"), y, x + 5);
175                 put_str(_("失率 効果", "Fail Info"), y, x + 36);
176
177                 /* Dump the spells */
178                 for (i = 0; i < num; i++) {
179                     /* Access the spell */
180                     spell = monster_powers[static_cast<size_t>(caster_ptr->mane_spell[i])];
181
182                     chance = spell.manefail;
183
184                     /* Reduce failure rate by "effective" level adjustment */
185                     if (plev > spell.level)
186                         chance -= 3 * (plev - spell.level);
187
188                     /* Reduce failure rate by INT/WIS adjustment */
189                     chance -= 3 * (adj_mag_stat[caster_ptr->stat_index[spell.use_stat]] + adj_mag_stat[caster_ptr->stat_index[A_DEX]] - 2) / 2;
190
191                     if (spell.manedam)
192                         chance = chance * (baigaesi ? caster_ptr->mane_dam[i] * 2 : caster_ptr->mane_dam[i]) / spell.manedam;
193
194                     chance += caster_ptr->to_m_chance;
195
196                     /* Extract the minimum failure rate */
197                     minfail = adj_mag_fail[caster_ptr->stat_index[spell.use_stat]];
198
199                     /* Minimum failure rate */
200                     if (chance < minfail)
201                         chance = minfail;
202
203                     /* Stunning makes spells harder */
204                     if (caster_ptr->stun > 50)
205                         chance += 25;
206                     else if (caster_ptr->stun)
207                         chance += 15;
208
209                     /* Always a 5 percent chance of working */
210                     if (chance > 95)
211                         chance = 95;
212
213                     /* Get info */
214                     mane_info(caster_ptr, comment, caster_ptr->mane_spell[i], (baigaesi ? caster_ptr->mane_dam[i] * 2 : caster_ptr->mane_dam[i]));
215
216                     /* Dump the spell --(-- */
217                     sprintf(psi_desc, "  %c) %-30s %3d%%%s", I2A(i), spell.name, chance, comment);
218                     prt(psi_desc, y + i + 1, x);
219                 }
220
221                 /* Clear the bottom line */
222                 prt("", y + i + 1, x);
223             }
224
225             /* Hide the list */
226             else {
227                 /* Hide list */
228                 redraw = FALSE;
229                 screen_load();
230             }
231
232             /* Redo asking */
233             continue;
234         }
235
236         /* Note verify */
237         ask = isupper(choice);
238
239         /* Lowercase */
240         if (ask)
241             choice = (char)tolower(choice);
242
243         /* Extract request */
244         i = (islower(choice) ? A2I(choice) : -1);
245
246         /* Totally Illegal */
247         if ((i < 0) || (i >= num)) {
248             bell();
249             continue;
250         }
251
252         /* Save the spell index */
253         spell = monster_powers[static_cast<int>(caster_ptr->mane_spell[i])];
254
255         /* Verify it */
256         if (ask) {
257             char tmp_val[160];
258
259             /* Prompt */
260             (void)strnfmt(tmp_val, 78, _("%sをまねますか?", "Use %s? "), spell.name);
261
262             /* Belay that order */
263             if (!get_check(tmp_val))
264                 continue;
265         }
266
267         /* Stop the loop */
268         flag = TRUE;
269     }
270     if (redraw)
271         screen_load();
272
273     caster_ptr->window_flags |= (PW_SPELL);
274     handle_stuff(caster_ptr);
275
276     /* Abort if needed */
277     if (!flag)
278         return FALSE;
279
280     /* Save the choice */
281     (*sn) = i;
282
283     damage = (baigaesi ? caster_ptr->mane_dam[i] * 2 : caster_ptr->mane_dam[i]);
284
285     /* Success */
286     return TRUE;
287 }
288
289 /*!
290  * @brief ものまね処理の発動 /
291  * do_cmd_cast calls this function if the player's class is 'imitator'.
292  * @param caster_ptr プレーヤーへの参照ポインタ
293  * @param spell 発動するモンスター攻撃のID
294  * @return 処理を実行したらTRUE、キャンセルした場合FALSEを返す。
295  */
296 static bool use_mane(player_type *caster_ptr, RF_ABILITY spell)
297 {
298     DIRECTION dir;
299     PLAYER_LEVEL plev = caster_ptr->lev;
300     BIT_FLAGS mode = (PM_ALLOW_GROUP | PM_FORCE_PET);
301     BIT_FLAGS u_mode = 0L;
302
303     if (randint1(50 + plev) < plev / 10)
304         u_mode = PM_ALLOW_UNIQUE;
305
306     /* spell code */
307     switch (spell) {
308     case RF_ABILITY::SHRIEK:
309         msg_print(_("かん高い金切り声をあげた。", "You make a high pitched shriek."));
310         aggravate_monsters(caster_ptr, 0);
311         break;
312
313     case RF_ABILITY::XXX1:
314         break;
315
316     case RF_ABILITY::DISPEL: {
317         MONSTER_IDX m_idx;
318
319         if (!target_set(caster_ptr, TARGET_KILL))
320             return FALSE;
321         m_idx = caster_ptr->current_floor_ptr->grid_array[target_row][target_col].m_idx;
322         if (!m_idx)
323             break;
324         if (!player_has_los_bold(caster_ptr, target_row, target_col))
325             break;
326         if (!projectable(caster_ptr, caster_ptr->y, caster_ptr->x, target_row, target_col))
327             break;
328         dispel_monster_status(caster_ptr, m_idx);
329         break;
330     }
331
332     case RF_ABILITY::ROCKET:
333         if (!get_aim_dir(caster_ptr, &dir))
334             return FALSE;
335         else
336             msg_print(_("ロケットを発射した。", "You fire a rocket."));
337         fire_rocket(caster_ptr, GF_ROCKET, dir, damage, 2);
338         break;
339
340     case RF_ABILITY::SHOOT:
341         if (!get_aim_dir(caster_ptr, &dir))
342             return FALSE;
343         else
344             msg_print(_("矢を放った。", "You fire an arrow."));
345         fire_bolt(caster_ptr, GF_ARROW, dir, damage);
346         break;
347
348     case RF_ABILITY::XXX2:
349         break;
350
351     case RF_ABILITY::XXX3:
352         break;
353
354     case RF_ABILITY::XXX4:
355         break;
356
357     case RF_ABILITY::BR_ACID:
358         if (!get_aim_dir(caster_ptr, &dir))
359             return FALSE;
360         else
361             msg_print(_("酸のブレスを吐いた。", "You breathe acid."));
362         fire_breath(caster_ptr, GF_ACID, dir, damage, (plev > 35 ? 3 : 2));
363         break;
364
365     case RF_ABILITY::BR_ELEC:
366         if (!get_aim_dir(caster_ptr, &dir))
367             return FALSE;
368         else
369             msg_print(_("稲妻のブレスを吐いた。", "You breathe lightning."));
370         fire_breath(caster_ptr, GF_ELEC, dir, damage, (plev > 35 ? 3 : 2));
371         break;
372
373     case RF_ABILITY::BR_FIRE:
374         if (!get_aim_dir(caster_ptr, &dir))
375             return FALSE;
376         else
377             msg_print(_("火炎のブレスを吐いた。", "You breathe fire."));
378         fire_breath(caster_ptr, GF_FIRE, dir, damage, (plev > 35 ? 3 : 2));
379         break;
380
381     case RF_ABILITY::BR_COLD:
382         if (!get_aim_dir(caster_ptr, &dir))
383             return FALSE;
384         else
385             msg_print(_("冷気のブレスを吐いた。", "You breathe frost."));
386         fire_breath(caster_ptr, GF_COLD, dir, damage, (plev > 35 ? 3 : 2));
387         break;
388
389     case RF_ABILITY::BR_POIS:
390         if (!get_aim_dir(caster_ptr, &dir))
391             return FALSE;
392         else
393             msg_print(_("ガスのブレスを吐いた。", "You breathe gas."));
394         fire_breath(caster_ptr, GF_POIS, dir, damage, (plev > 35 ? 3 : 2));
395         break;
396
397     case RF_ABILITY::BR_NETH:
398         if (!get_aim_dir(caster_ptr, &dir))
399             return FALSE;
400         else
401             msg_print(_("地獄のブレスを吐いた。", "You breathe nether."));
402         fire_breath(caster_ptr, GF_NETHER, dir, damage, (plev > 35 ? 3 : 2));
403         break;
404
405     case RF_ABILITY::BR_LITE:
406         if (!get_aim_dir(caster_ptr, &dir))
407             return FALSE;
408         else
409             msg_print(_("閃光のブレスを吐いた。", "You breathe light."));
410         fire_breath(caster_ptr, GF_LITE, dir, damage, (plev > 35 ? 3 : 2));
411         break;
412
413     case RF_ABILITY::BR_DARK:
414         if (!get_aim_dir(caster_ptr, &dir))
415             return FALSE;
416         else
417             msg_print(_("暗黒のブレスを吐いた。", "You breathe darkness."));
418         fire_breath(caster_ptr, GF_DARK, dir, damage, (plev > 35 ? 3 : 2));
419         break;
420
421     case RF_ABILITY::BR_CONF:
422         if (!get_aim_dir(caster_ptr, &dir))
423             return FALSE;
424         else
425             msg_print(_("混乱のブレスを吐いた。", "You breathe confusion."));
426         fire_breath(caster_ptr, GF_CONFUSION, dir, damage, (plev > 35 ? 3 : 2));
427         break;
428
429     case RF_ABILITY::BR_SOUN:
430         if (!get_aim_dir(caster_ptr, &dir))
431             return FALSE;
432         else
433             msg_print(_("轟音のブレスを吐いた。", "You breathe sound."));
434         fire_breath(caster_ptr, GF_SOUND, dir, damage, (plev > 35 ? 3 : 2));
435         break;
436
437     case RF_ABILITY::BR_CHAO:
438         if (!get_aim_dir(caster_ptr, &dir))
439             return FALSE;
440         else
441             msg_print(_("カオスのブレスを吐いた。", "You breathe chaos."));
442         fire_breath(caster_ptr, GF_CHAOS, dir, damage, (plev > 35 ? 3 : 2));
443         break;
444
445     case RF_ABILITY::BR_DISE:
446         if (!get_aim_dir(caster_ptr, &dir))
447             return FALSE;
448         else
449             msg_print(_("劣化のブレスを吐いた。", "You breathe disenchantment."));
450         fire_breath(caster_ptr, GF_DISENCHANT, dir, damage, (plev > 35 ? 3 : 2));
451         break;
452
453     case RF_ABILITY::BR_NEXU:
454         if (!get_aim_dir(caster_ptr, &dir))
455             return FALSE;
456         else
457             msg_print(_("因果混乱のブレスを吐いた。", "You breathe nexus."));
458         fire_breath(caster_ptr, GF_NEXUS, dir, damage, (plev > 35 ? 3 : 2));
459         break;
460
461     case RF_ABILITY::BR_TIME:
462         if (!get_aim_dir(caster_ptr, &dir))
463             return FALSE;
464         else
465             msg_print(_("時間逆転のブレスを吐いた。", "You breathe time."));
466         fire_breath(caster_ptr, GF_TIME, dir, damage, (plev > 35 ? 3 : 2));
467         break;
468
469     case RF_ABILITY::BR_INER:
470         if (!get_aim_dir(caster_ptr, &dir))
471             return FALSE;
472         else
473             msg_print(_("遅鈍のブレスを吐いた。", "You breathe inertia."));
474         fire_breath(caster_ptr, GF_INERTIAL, dir, damage, (plev > 35 ? 3 : 2));
475         break;
476
477     case RF_ABILITY::BR_GRAV:
478         if (!get_aim_dir(caster_ptr, &dir))
479             return FALSE;
480         else
481             msg_print(_("重力のブレスを吐いた。", "You breathe gravity."));
482         fire_breath(caster_ptr, GF_GRAVITY, dir, damage, (plev > 35 ? 3 : 2));
483         break;
484
485     case RF_ABILITY::BR_SHAR:
486         if (!get_aim_dir(caster_ptr, &dir))
487             return FALSE;
488         else
489             msg_print(_("破片のブレスを吐いた。", "You breathe shards."));
490         fire_breath(caster_ptr, GF_SHARDS, dir, damage, (plev > 35 ? 3 : 2));
491         break;
492
493     case RF_ABILITY::BR_PLAS:
494         if (!get_aim_dir(caster_ptr, &dir))
495             return FALSE;
496         else
497             msg_print(_("プラズマのブレスを吐いた。", "You breathe plasma."));
498
499         fire_breath(caster_ptr, GF_PLASMA, dir, damage, (plev > 35 ? 3 : 2));
500         break;
501
502     case RF_ABILITY::BR_FORC:
503         if (!get_aim_dir(caster_ptr, &dir))
504             return FALSE;
505         else
506             msg_print(_("フォースのブレスを吐いた。", "You breathe force."));
507
508         fire_breath(caster_ptr, GF_FORCE, dir, damage, (plev > 35 ? 3 : 2));
509         break;
510
511     case RF_ABILITY::BR_MANA:
512         if (!get_aim_dir(caster_ptr, &dir))
513             return FALSE;
514         else
515             msg_print(_("魔力のブレスを吐いた。", "You breathe mana."));
516
517         fire_breath(caster_ptr, GF_MANA, dir, damage, (plev > 35 ? 3 : 2));
518         break;
519
520     case RF_ABILITY::BA_NUKE:
521         if (!get_aim_dir(caster_ptr, &dir))
522             return FALSE;
523         else
524             msg_print(_("放射能球を放った。", "You cast a ball of radiation."));
525
526         fire_ball(caster_ptr, GF_NUKE, dir, damage, 2);
527         break;
528
529     case RF_ABILITY::BR_NUKE:
530         if (!get_aim_dir(caster_ptr, &dir))
531             return FALSE;
532         else
533             msg_print(_("放射性廃棄物のブレスを吐いた。", "You breathe toxic waste."));
534
535         fire_breath(caster_ptr, GF_NUKE, dir, damage, (plev > 35 ? 3 : 2));
536         break;
537
538     case RF_ABILITY::BA_CHAO:
539         if (!get_aim_dir(caster_ptr, &dir))
540             return FALSE;
541         else
542             msg_print(_("純ログルスを放った。", "You invoke a raw Logrus."));
543
544         fire_ball(caster_ptr, GF_CHAOS, dir, damage, 4);
545         break;
546     case RF_ABILITY::BR_DISI:
547         if (!get_aim_dir(caster_ptr, &dir))
548             return FALSE;
549         else
550             msg_print(_("分解のブレスを吐いた。", "You breathe disintegration."));
551
552         fire_breath(caster_ptr, GF_DISINTEGRATE, dir, damage, (plev > 35 ? 3 : 2));
553         break;
554     case RF_ABILITY::BA_ACID:
555         if (!get_aim_dir(caster_ptr, &dir))
556             return FALSE;
557         else
558             msg_print(_("アシッド・ボールの呪文を唱えた。", "You cast an acid ball."));
559
560         fire_ball(caster_ptr, GF_ACID, dir, damage, 2);
561         break;
562     case RF_ABILITY::BA_ELEC:
563         if (!get_aim_dir(caster_ptr, &dir))
564             return FALSE;
565         else
566             msg_print(_("サンダー・ボールの呪文を唱えた。", "You cast a lightning ball."));
567
568         fire_ball(caster_ptr, GF_ELEC, dir, damage, 2);
569         break;
570     case RF_ABILITY::BA_FIRE:
571         if (!get_aim_dir(caster_ptr, &dir))
572             return FALSE;
573         else
574             msg_print(_("ファイア・ボールの呪文を唱えた。", "You cast a fire ball."));
575
576         fire_ball(caster_ptr, GF_FIRE, dir, damage, 2);
577         break;
578     case RF_ABILITY::BA_COLD:
579         if (!get_aim_dir(caster_ptr, &dir))
580             return FALSE;
581         else
582             msg_print(_("アイス・ボールの呪文を唱えた。", "You cast a frost ball."));
583
584         fire_ball(caster_ptr, GF_COLD, dir, damage, 2);
585         break;
586     case RF_ABILITY::BA_POIS:
587         if (!get_aim_dir(caster_ptr, &dir))
588             return FALSE;
589         else
590             msg_print(_("悪臭雲の呪文を唱えた。", "You cast a stinking cloud."));
591
592         fire_ball(caster_ptr, GF_POIS, dir, damage, 2);
593         break;
594     case RF_ABILITY::BA_NETH:
595         if (!get_aim_dir(caster_ptr, &dir))
596             return FALSE;
597         else
598             msg_print(_("地獄球の呪文を唱えた。", "You cast a nether ball."));
599
600         fire_ball(caster_ptr, GF_NETHER, dir, damage, 2);
601         break;
602     case RF_ABILITY::BA_WATE:
603         if (!get_aim_dir(caster_ptr, &dir))
604             return FALSE;
605         else
606             msg_print(_("流れるような身振りをした。", "You gesture fluidly."));
607
608         fire_ball(caster_ptr, GF_WATER, dir, damage, 4);
609         break;
610     case RF_ABILITY::BA_MANA:
611         if (!get_aim_dir(caster_ptr, &dir))
612             return FALSE;
613         else
614             msg_print(_("魔力の嵐の呪文を念じた。", "You invoke a mana storm."));
615
616         fire_ball(caster_ptr, GF_MANA, dir, damage, 4);
617         break;
618     case RF_ABILITY::BA_DARK:
619         if (!get_aim_dir(caster_ptr, &dir))
620             return FALSE;
621         else
622             msg_print(_("暗黒の嵐の呪文を念じた。", "You invoke a darkness storm."));
623
624         fire_ball(caster_ptr, GF_DARK, dir, damage, 4);
625         break;
626     case RF_ABILITY::DRAIN_MANA:
627         if (!get_aim_dir(caster_ptr, &dir))
628             return FALSE;
629         fire_ball_hide(caster_ptr, GF_DRAIN_MANA, dir, randint1(plev * 3) + plev, 0);
630         break;
631     case RF_ABILITY::MIND_BLAST:
632         if (!get_aim_dir(caster_ptr, &dir))
633             return FALSE;
634         fire_ball_hide(caster_ptr, GF_MIND_BLAST, dir, damage, 0);
635         break;
636     case RF_ABILITY::BRAIN_SMASH:
637         if (!get_aim_dir(caster_ptr, &dir))
638             return FALSE;
639         fire_ball_hide(caster_ptr, GF_BRAIN_SMASH, dir, damage, 0);
640         break;
641     case RF_ABILITY::CAUSE_1:
642         if (!get_aim_dir(caster_ptr, &dir))
643             return FALSE;
644         fire_ball_hide(caster_ptr, GF_CAUSE_1, dir, damage, 0);
645         break;
646     case RF_ABILITY::CAUSE_2:
647         if (!get_aim_dir(caster_ptr, &dir))
648             return FALSE;
649         fire_ball_hide(caster_ptr, GF_CAUSE_2, dir, damage, 0);
650         break;
651     case RF_ABILITY::CAUSE_3:
652         if (!get_aim_dir(caster_ptr, &dir))
653             return FALSE;
654         fire_ball_hide(caster_ptr, GF_CAUSE_3, dir, damage, 0);
655         break;
656     case RF_ABILITY::CAUSE_4:
657         if (!get_aim_dir(caster_ptr, &dir))
658             return FALSE;
659         fire_ball_hide(caster_ptr, GF_CAUSE_4, dir, damage, 0);
660         break;
661     case RF_ABILITY::BO_ACID:
662         if (!get_aim_dir(caster_ptr, &dir))
663             return FALSE;
664         else
665             msg_print(_("アシッド・ボルトの呪文を唱えた。", "You cast an acid bolt."));
666
667         fire_bolt(caster_ptr, GF_ACID, dir, damage);
668         break;
669     case RF_ABILITY::BO_ELEC:
670         if (!get_aim_dir(caster_ptr, &dir))
671             return FALSE;
672         else
673             msg_print(_("サンダー・ボルトの呪文を唱えた。", "You cast a lightning bolt."));
674
675         fire_bolt(caster_ptr, GF_ELEC, dir, damage);
676         break;
677     case RF_ABILITY::BO_FIRE:
678         if (!get_aim_dir(caster_ptr, &dir))
679             return FALSE;
680         else
681             msg_print(_("ファイア・ボルトの呪文を唱えた。", "You cast a fire bolt."));
682
683         fire_bolt(caster_ptr, GF_FIRE, dir, damage);
684         break;
685     case RF_ABILITY::BO_COLD:
686         if (!get_aim_dir(caster_ptr, &dir))
687             return FALSE;
688         else
689             msg_print(_("アイス・ボルトの呪文を唱えた。", "You cast a frost bolt."));
690
691         fire_bolt(caster_ptr, GF_COLD, dir, damage);
692         break;
693     case RF_ABILITY::BA_LITE:
694         if (!get_aim_dir(caster_ptr, &dir))
695             return FALSE;
696         else
697             msg_print(_("スターバーストの呪文を念じた。", "You invoke a starburst."));
698
699         fire_ball(caster_ptr, GF_LITE, dir, damage, 4);
700         break;
701     case RF_ABILITY::BO_NETH:
702         if (!get_aim_dir(caster_ptr, &dir))
703             return FALSE;
704         else
705             msg_print(_("地獄の矢の呪文を唱えた。", "You cast a nether bolt."));
706
707         fire_bolt(caster_ptr, GF_NETHER, dir, damage);
708         break;
709     case RF_ABILITY::BO_WATE:
710         if (!get_aim_dir(caster_ptr, &dir))
711             return FALSE;
712         else
713             msg_print(_("ウォーター・ボルトの呪文を唱えた。", "You cast a water bolt."));
714
715         fire_bolt(caster_ptr, GF_WATER, dir, damage);
716         break;
717     case RF_ABILITY::BO_MANA:
718         if (!get_aim_dir(caster_ptr, &dir))
719             return FALSE;
720         else
721             msg_print(_("魔力の矢の呪文を唱えた。", "You cast a mana bolt."));
722
723         fire_bolt(caster_ptr, GF_MANA, dir, damage);
724         break;
725     case RF_ABILITY::BO_PLAS:
726         if (!get_aim_dir(caster_ptr, &dir))
727             return FALSE;
728         else
729             msg_print(_("プラズマ・ボルトの呪文を唱えた。", "You cast a plasma bolt."));
730
731         fire_bolt(caster_ptr, GF_PLASMA, dir, damage);
732         break;
733     case RF_ABILITY::BO_ICEE:
734         if (!get_aim_dir(caster_ptr, &dir))
735             return FALSE;
736         else
737             msg_print(_("極寒の矢の呪文を唱えた。", "You cast a ice bolt."));
738
739         fire_bolt(caster_ptr, GF_ICE, dir, damage);
740         break;
741     case RF_ABILITY::MISSILE:
742         if (!get_aim_dir(caster_ptr, &dir))
743             return FALSE;
744         else
745             msg_print(_("マジック・ミサイルの呪文を唱えた。", "You cast a magic missile."));
746
747         fire_bolt(caster_ptr, GF_MISSILE, dir, damage);
748         break;
749     case RF_ABILITY::SCARE:
750         if (!get_aim_dir(caster_ptr, &dir))
751             return FALSE;
752         else
753             msg_print(_("恐ろしげな幻覚を作り出した。", "You cast a fearful illusion."));
754
755         fear_monster(caster_ptr, dir, plev + 10);
756         break;
757     case RF_ABILITY::BLIND:
758         if (!get_aim_dir(caster_ptr, &dir))
759             return FALSE;
760         confuse_monster(caster_ptr, dir, plev * 2);
761         break;
762     case RF_ABILITY::CONF:
763         if (!get_aim_dir(caster_ptr, &dir))
764             return FALSE;
765         else
766             msg_print(_("誘惑的な幻覚をつくり出した。", "You cast a mesmerizing illusion."));
767
768         confuse_monster(caster_ptr, dir, plev * 2);
769         break;
770     case RF_ABILITY::SLOW:
771         if (!get_aim_dir(caster_ptr, &dir))
772             return FALSE;
773         slow_monster(caster_ptr, dir, plev);
774         break;
775     case RF_ABILITY::HOLD:
776         if (!get_aim_dir(caster_ptr, &dir))
777             return FALSE;
778         sleep_monster(caster_ptr, dir, plev);
779         break;
780     case RF_ABILITY::HASTE:
781         (void)set_fast(caster_ptr, randint1(20 + plev) + plev, FALSE);
782         break;
783     case RF_ABILITY::HAND_DOOM: {
784         if (!get_aim_dir(caster_ptr, &dir))
785             return FALSE;
786         else
787             msg_print(_("<破滅の手>を放った!", "You invoke the Hand of Doom!"));
788
789         fire_ball_hide(caster_ptr, GF_HAND_DOOM, dir, 200, 0);
790         break;
791     }
792     case RF_ABILITY::HEAL:
793         msg_print(_("自分の傷に念を集中した。", "You concentrate on your wounds!"));
794         (void)hp_player(caster_ptr, plev * 6);
795         (void)set_stun(caster_ptr, 0);
796         (void)set_cut(caster_ptr, 0);
797         break;
798     case RF_ABILITY::INVULNER:
799         msg_print(_("無傷の球の呪文を唱えた。", "You cast a Globe of Invulnerability."));
800         (void)set_invuln(caster_ptr, randint1(7) + 7, FALSE);
801         break;
802     case RF_ABILITY::BLINK:
803         teleport_player(caster_ptr, 10, TELEPORT_SPONTANEOUS);
804         break;
805     case RF_ABILITY::TPORT:
806         teleport_player(caster_ptr, plev * 5, TELEPORT_SPONTANEOUS);
807         break;
808     case RF_ABILITY::WORLD:
809         (void)time_walk(caster_ptr);
810         break;
811     case RF_ABILITY::SPECIAL:
812         break;
813     case RF_ABILITY::TELE_TO: {
814         monster_type *m_ptr;
815         monster_race *r_ptr;
816         GAME_TEXT m_name[MAX_NLEN];
817
818         if (!target_set(caster_ptr, TARGET_KILL))
819             return FALSE;
820         if (!caster_ptr->current_floor_ptr->grid_array[target_row][target_col].m_idx)
821             break;
822         if (!player_has_los_bold(caster_ptr, target_row, target_col))
823             break;
824         if (!projectable(caster_ptr, caster_ptr->y, caster_ptr->x, target_row, target_col))
825             break;
826         m_ptr = &caster_ptr->current_floor_ptr->m_list[caster_ptr->current_floor_ptr->grid_array[target_row][target_col].m_idx];
827         r_ptr = &r_info[m_ptr->r_idx];
828         monster_desc(caster_ptr, m_name, m_ptr, 0);
829         if (r_ptr->flagsr & RFR_RES_TELE) {
830             if ((r_ptr->flags1 & (RF1_UNIQUE)) || (r_ptr->flagsr & RFR_RES_ALL)) {
831                 if (is_original_ap_and_seen(caster_ptr, m_ptr))
832                     r_ptr->r_flagsr |= RFR_RES_TELE;
833                 msg_format(_("%sには効果がなかった!", "%s is unaffected!"), m_name);
834
835                 break;
836             } else if (r_ptr->level > randint1(100)) {
837                 if (is_original_ap_and_seen(caster_ptr, m_ptr))
838                     r_ptr->r_flagsr |= RFR_RES_TELE;
839                 msg_format(_("%sには耐性がある!", "%s resists!"), m_name);
840
841                 break;
842             }
843         }
844         msg_format(_("%sを引き戻した。", "You command %s to return."), m_name);
845
846         teleport_monster_to(
847             caster_ptr, caster_ptr->current_floor_ptr->grid_array[target_row][target_col].m_idx, caster_ptr->y, caster_ptr->x, 100, TELEPORT_PASSIVE);
848         break;
849     }
850     case RF_ABILITY::TELE_AWAY:
851         if (!get_aim_dir(caster_ptr, &dir))
852             return FALSE;
853
854         (void)fire_beam(caster_ptr, GF_AWAY_ALL, dir, plev);
855         break;
856
857     case RF_ABILITY::TELE_LEVEL:
858         return teleport_level_other(caster_ptr);
859         break;
860
861     case RF_ABILITY::PSY_SPEAR:
862         if (!get_aim_dir(caster_ptr, &dir))
863             return FALSE;
864         else
865             msg_print(_("光の剣を放った。", "You throw a psycho-spear."));
866         (void)fire_beam(caster_ptr, GF_PSY_SPEAR, dir, damage);
867         break;
868
869     case RF_ABILITY::DARKNESS:
870         msg_print(_("暗闇の中で手を振った。", "You gesture in shadow."));
871         (void)unlite_area(caster_ptr, 10, 3);
872         break;
873
874     case RF_ABILITY::TRAPS:
875         if (!target_set(caster_ptr, TARGET_KILL))
876             return FALSE;
877         msg_print(_("呪文を唱えて邪悪に微笑んだ。", "You cast a spell and cackle evilly."));
878         trap_creation(caster_ptr, target_row, target_col);
879         break;
880     case RF_ABILITY::FORGET:
881         msg_print(_("しかし何も起きなかった。", "Nothing happens."));
882         break;
883     case RF_ABILITY::RAISE_DEAD:
884         msg_print(_("死者復活の呪文を唱えた。", "You animate the dead."));
885         (void)animate_dead(caster_ptr, 0, caster_ptr->y, caster_ptr->x);
886         break;
887     case RF_ABILITY::S_KIN: {
888         int k;
889         if (!target_set(caster_ptr, TARGET_KILL))
890             return FALSE;
891
892         msg_print(_("援軍を召喚した。", "You summon minions."));
893         for (k = 0; k < 4; k++) {
894             (void)summon_kin_player(caster_ptr, plev, target_row, target_col, (PM_FORCE_PET | PM_ALLOW_GROUP));
895         }
896         break;
897     }
898     case RF_ABILITY::S_CYBER: {
899         int k;
900         int max_cyber = (caster_ptr->current_floor_ptr->dun_level / 50) + randint1(3);
901         if (!target_set(caster_ptr, TARGET_KILL))
902             return FALSE;
903         msg_print(_("サイバーデーモンを召喚した!", "You summon Cyberdemons!"));
904         if (max_cyber > 4)
905             max_cyber = 4;
906         for (k = 0; k < max_cyber; k++)
907             summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_CYBER, mode);
908         break;
909     }
910     case RF_ABILITY::S_MONSTER: {
911         int k;
912         if (!target_set(caster_ptr, TARGET_KILL))
913             return FALSE;
914         msg_print(_("仲間を召喚した。", "You summon help."));
915         for (k = 0; k < 1; k++)
916             summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_NONE, (mode | u_mode));
917         break;
918     }
919     case RF_ABILITY::S_MONSTERS: {
920         int k;
921         if (!target_set(caster_ptr, TARGET_KILL))
922             return FALSE;
923         msg_print(_("モンスターを召喚した!", "You summon monsters!"));
924         for (k = 0; k < 6; k++)
925             summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_NONE, (mode | u_mode));
926         break;
927     }
928     case RF_ABILITY::S_ANT: {
929         int k;
930         if (!target_set(caster_ptr, TARGET_KILL))
931             return FALSE;
932         msg_print(_("アリを召喚した。", "You summon ants."));
933         for (k = 0; k < 6; k++)
934             summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_ANT, mode);
935         break;
936     }
937     case RF_ABILITY::S_SPIDER: {
938         int k;
939         if (!target_set(caster_ptr, TARGET_KILL))
940             return FALSE;
941         msg_print(_("蜘蛛を召喚した。", "You summon spiders."));
942         for (k = 0; k < 6; k++)
943             summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_SPIDER, mode);
944         break;
945     }
946     case RF_ABILITY::S_HOUND: {
947         int k;
948         if (!target_set(caster_ptr, TARGET_KILL))
949             return FALSE;
950         msg_print(_("ハウンドを召喚した。", "You summon hounds."));
951         for (k = 0; k < 4; k++)
952             summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_HOUND, mode);
953         break;
954     }
955     case RF_ABILITY::S_HYDRA: {
956         int k;
957         if (!target_set(caster_ptr, TARGET_KILL))
958             return FALSE;
959         msg_print(_("ヒドラを召喚した。", "You summon hydras."));
960         for (k = 0; k < 4; k++)
961             summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_HYDRA, mode);
962         break;
963     }
964     case RF_ABILITY::S_ANGEL: {
965         int k;
966         if (!target_set(caster_ptr, TARGET_KILL))
967             return FALSE;
968         msg_print(_("天使を召喚した!", "You summon an angel!"));
969         for (k = 0; k < 1; k++)
970             summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_ANGEL, mode);
971         break;
972     }
973     case RF_ABILITY::S_DEMON: {
974         int k;
975         if (!target_set(caster_ptr, TARGET_KILL))
976             return FALSE;
977         msg_print(_("混沌の宮廷から悪魔を召喚した!", "You summon a demon from the Courts of Chaos!"));
978         for (k = 0; k < 1; k++)
979             summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_DEMON, (mode | u_mode));
980         break;
981     }
982     case RF_ABILITY::S_UNDEAD: {
983         int k;
984         if (!target_set(caster_ptr, TARGET_KILL))
985             return FALSE;
986         msg_print(_("アンデッドの強敵を召喚した!", "You summon an undead adversary!"));
987         for (k = 0; k < 1; k++)
988             summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_UNDEAD, (mode | u_mode));
989         break;
990     }
991     case RF_ABILITY::S_DRAGON: {
992         int k;
993         if (!target_set(caster_ptr, TARGET_KILL))
994             return FALSE;
995         msg_print(_("ドラゴンを召喚した!", "You summon a dragon!"));
996         for (k = 0; k < 1; k++)
997             summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_DRAGON, (mode | u_mode));
998         break;
999     }
1000     case RF_ABILITY::S_HI_UNDEAD: {
1001         int k;
1002         if (!target_set(caster_ptr, TARGET_KILL))
1003             return FALSE;
1004         msg_print(_("強力なアンデッドを召喚した!", "You summon greater undead!"));
1005         for (k = 0; k < 6; k++)
1006             summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_HI_UNDEAD, (mode | u_mode));
1007         break;
1008     }
1009     case RF_ABILITY::S_HI_DRAGON: {
1010         int k;
1011         if (!target_set(caster_ptr, TARGET_KILL))
1012             return FALSE;
1013         msg_print(_("古代ドラゴンを召喚した!", "You summon ancient dragons!"));
1014         for (k = 0; k < 4; k++)
1015             summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_HI_DRAGON, (mode | u_mode));
1016         break;
1017     }
1018     case RF_ABILITY::S_AMBERITES: {
1019         int k;
1020         if (!target_set(caster_ptr, TARGET_KILL))
1021             return FALSE;
1022         msg_print(_("アンバーの王族を召喚した!", "You summon Lords of Amber!"));
1023         for (k = 0; k < 4; k++)
1024             summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_AMBERITES, (mode | PM_ALLOW_UNIQUE));
1025         break;
1026     }
1027     case RF_ABILITY::S_UNIQUE: {
1028         int k, count = 0;
1029         if (!target_set(caster_ptr, TARGET_KILL))
1030             return FALSE;
1031         msg_print(_("特別な強敵を召喚した!", "You summon special opponents!"));
1032         for (k = 0; k < 4; k++)
1033             if (summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_UNIQUE, (mode | PM_ALLOW_UNIQUE)))
1034                 count++;
1035         for (k = count; k < 4; k++)
1036             summon_specific(caster_ptr, -1, target_row, target_col, plev, SUMMON_HI_UNDEAD, (mode | u_mode));
1037         break;
1038     }
1039     default:
1040         msg_print("hoge?");
1041     }
1042
1043     return TRUE;
1044 }
1045
1046 /*!
1047  * @brief ものまねコマンドのメインルーチン /
1048  * do_cmd_cast calls this function if the player's class is 'imitator'.
1049  * @param baigaesi TRUEならば倍返し上の処理として行う
1050  * @return 処理を実行したらTRUE、キャンセルした場合FALSEを返す。
1051  * @details
1052  * If a valid spell is chosen, saves it in '*sn' and returns TRUE
1053  * If the user hits escape, returns FALSE, and set '*sn' to -1
1054  * If there are no legal choices, returns FALSE, and sets '*sn' to -2
1055  *
1056  * The "prompt" should be "cast", "recite", or "study"
1057  * The "known" should be TRUE for cast/pray, FALSE for study
1058  *
1059  * nb: This function has a (trivial) display bug which will be obvious
1060  * when you run it. It's probably easy to fix but I haven't tried,
1061  * sorry.
1062  */
1063 bool do_cmd_mane(player_type *creature_ptr, bool baigaesi)
1064 {
1065     int n = 0, j;
1066     PERCENTAGE chance;
1067     PERCENTAGE minfail = 0;
1068     PLAYER_LEVEL plev = creature_ptr->lev;
1069     monster_power spell;
1070     bool cast;
1071
1072     if (cmd_limit_confused(creature_ptr))
1073         return FALSE;
1074
1075     if (!creature_ptr->mane_num) {
1076         msg_print(_("まねられるものが何もない!", "You don't remember any action!"));
1077         return FALSE;
1078     }
1079
1080     if (!get_mane_power(creature_ptr, &n, baigaesi))
1081         return FALSE;
1082
1083     spell = monster_powers[static_cast<int>(creature_ptr->mane_spell[n])];
1084
1085     /* Spell failure chance */
1086     chance = spell.manefail;
1087
1088     /* Reduce failure rate by "effective" level adjustment */
1089     if (plev > spell.level)
1090         chance -= 3 * (plev - spell.level);
1091
1092     /* Reduce failure rate by 1 stat and DEX adjustment */
1093     chance -= 3 * (adj_mag_stat[creature_ptr->stat_index[spell.use_stat]] + adj_mag_stat[creature_ptr->stat_index[A_DEX]] - 2) / 2;
1094
1095     if (spell.manedam)
1096         chance = chance * damage / spell.manedam;
1097
1098     chance += creature_ptr->to_m_chance;
1099
1100     /* Extract the minimum failure rate */
1101     minfail = adj_mag_fail[creature_ptr->stat_index[spell.use_stat]];
1102
1103     /* Minimum failure rate */
1104     if (chance < minfail)
1105         chance = minfail;
1106
1107     /* Stunning makes spells harder */
1108     if (creature_ptr->stun > 50)
1109         chance += 25;
1110     else if (creature_ptr->stun)
1111         chance += 15;
1112
1113     /* Always a 5 percent chance of working */
1114     if (chance > 95)
1115         chance = 95;
1116
1117     /* Failed spell */
1118     if (randint0(100) < chance) {
1119         if (flush_failure)
1120             flush();
1121         msg_print(_("ものまねに失敗した!", "You failed to concentrate hard enough!"));
1122         sound(SOUND_FAIL);
1123     } else {
1124         sound(SOUND_ZAP);
1125         cast = use_mane(creature_ptr, creature_ptr->mane_spell[n]);
1126         if (!cast)
1127             return FALSE;
1128     }
1129
1130     creature_ptr->mane_num--;
1131     for (j = n; j < creature_ptr->mane_num; j++) {
1132         creature_ptr->mane_spell[j] = creature_ptr->mane_spell[j + 1];
1133         creature_ptr->mane_dam[j] = creature_ptr->mane_dam[j + 1];
1134     }
1135
1136     take_turn(creature_ptr, 100);
1137
1138     creature_ptr->redraw |= (PR_IMITATION);
1139     creature_ptr->window_flags |= (PW_PLAYER);
1140     creature_ptr->window_flags |= (PW_SPELL);
1141
1142     return TRUE;
1143 }