OSDN Git Service

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