OSDN Git Service

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