OSDN Git Service

[Refactor] #37353 monster-process.h を作成して変数宣言整理。
[hengband/hengband.git] / src / cmd-mane.c
1 /*!
2  * @file mane.c
3  * @brief ものまねの処理実装 / Imitation code
4  * @date 2014/01/14
5  * @author
6  * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke\n
7  * This software may be copied and distributed for educational, research,\n
8  * and not for profit purposes provided that this copyright and statement\n
9  * are included in all such copies.  Other copyrights may also apply.\n
10  * 2014 Deskull rearranged comment for Doxygen.\n
11  */
12
13 #include "angband.h"
14 #include "floor.h"
15 #include "grid.h"
16 #include "spells.h"
17 #include "spells-summon.h"
18 #include "spells-status.h"
19 #include "monster-status.h"
20 #include "monster-spell.h"
21 #include "monster-process.h"
22 #include "cmd-spell.h"
23 #include "player-status.h"
24 #include "cmd-basic.h"
25
26 static int damage;
27
28 /*!
29  * @brief 受け取ったパラメータに応じてものまねの効果情報をまとめたフォーマットを返す
30  * @param p 情報を返す文字列参照ポインタ
31  * @param power ものまねの効力の種類
32  * @param dam ものまねの威力
33  * @return なし
34  */
35 static void mane_info(char *p, int power, HIT_POINT dam)
36 {
37         PLAYER_LEVEL plev = p_ptr->lev;
38
39         strcpy(p, "");
40
41         if ((power > 2 && power < 41) || (power > 41 && power < 59) || (power == 75))
42                 sprintf(p, " %s%d", KWD_DAM, (int)dam);
43         else
44         {
45                 switch (power)
46                 {
47                         case 41:
48                                 sprintf(p, " %sd%d+%d", KWD_HEAL, plev * 3, plev);
49                                 break;
50                         case 64:
51                                 sprintf(p, " %sd%d+%d", KWD_DURATION, 20+plev, plev);
52                                 break;
53                         case 66:
54                                 sprintf(p, " %s%d", KWD_HEAL, plev*6);
55                                 break;
56                         case 67:
57                                 sprintf(p, " %sd7+7", KWD_DURATION);
58                                 break;
59                         case 68:
60                                 sprintf(p, " %s10", KWD_SPHERE);
61                                 break;
62                         case 69:
63                                 sprintf(p, " %s%d", KWD_SPHERE, plev * 5);
64                                 break;
65                         case 79:
66                                 sprintf(p, " %s5", KWD_SPHERE);
67                                 break;
68                         default:
69                                 break;
70                 }
71         }
72 }
73
74
75 /*!
76  * @brief どのものまねを発動するか選択する処理 /
77  * Allow user to choose a imitation.
78  * @param sn 実行したものまねのIDを返す参照ポインタ(キャンセルなどの場合-1を返す)
79  * @param baigaesi TRUEならば倍返し上の処理として行う
80  * @return 処理を実行したらTRUE、キャンセルした場合FALSEを返す。
81  * @details
82  * If a valid spell is chosen, saves it in '*sn' and returns TRUE
83  * If the user hits escape, returns FALSE, and set '*sn' to -1
84  * If there are no legal choices, returns FALSE, and sets '*sn' to -2
85  *
86  * The "prompt" should be "cast", "recite", or "study"
87  * The "known" should be TRUE for cast/pray, FALSE for study
88  *
89  * nb: This function has a (trivial) display bug which will be obvious
90  * when you run it. It's probably easy to fix but I haven't tried,
91  * sorry.
92  */
93 static int get_mane_power(int *sn, bool baigaesi)
94 {
95         int             i = 0;
96         int             num = 0;
97         TERM_LEN y = 1;
98         TERM_LEN x = 18;
99         PERCENTAGE minfail = 0;
100         PLAYER_LEVEL plev = p_ptr->lev;
101         PERCENTAGE chance = 0;
102         int             ask;
103         char            choice;
104         char            out_val[160];
105         char            comment[80];
106         concptr p = _("能力", "power");
107
108         monster_power   spell;
109         bool            flag, redraw;
110
111         /* Assume cancelled */
112         *sn = (-1);
113
114         /* Nothing chosen yet */
115         flag = FALSE;
116
117         /* No redraw yet */
118         redraw = FALSE;
119
120         num = p_ptr->mane_num;
121
122         /* Build a prompt (accept all spells) */
123         (void)strnfmt(out_val, 78,
124                 _("(%c-%c, '*'で一覧, ESC) どの%sをまねますか?", "(%c-%c, *=List, ESC=exit) Use which %s? "),
125                 I2A(0), I2A(num - 1), p);
126
127         choice= always_show_list ? ESCAPE:1 ;
128         while (!flag)
129         {
130                 if(choice==ESCAPE) choice = ' '; 
131                 else if( !get_com(out_val, &choice, TRUE) )break; 
132
133                 /* Request redraw */
134                 if ((choice == ' ') || (choice == '*') || (choice == '?'))
135                 {
136                         /* Show the list */
137                         if (!redraw)
138                         {
139                                 char psi_desc[80];
140                                 redraw = TRUE;
141                                 screen_save();
142
143                                 /* Display a list of spells */
144                                 prt("", y, x);
145                                 put_str(_("名前", "Name"), y, x + 5);
146                                 put_str(_("失率 効果", "Fail Info"), y, x + 36);
147
148
149                                 /* Dump the spells */
150                                 for (i = 0; i < num; i++)
151                                 {
152                                         /* Access the spell */
153                                         spell = monster_powers[p_ptr->mane_spell[i]];
154
155                                         chance = spell.manefail;
156
157                                         /* Reduce failure rate by "effective" level adjustment */
158                                         if (plev > spell.level) chance -= 3 * (plev - spell.level);
159
160                                         /* Reduce failure rate by INT/WIS adjustment */
161                                         chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[spell.use_stat]] + adj_mag_stat[p_ptr->stat_ind[A_DEX]] - 2) / 2;
162
163                                         if (spell.manedam) chance = chance * (baigaesi ? p_ptr->mane_dam[i] * 2 : p_ptr->mane_dam[i]) / spell.manedam;
164
165                                         chance += p_ptr->to_m_chance;
166
167                                         /* Extract the minimum failure rate */
168                                         minfail = adj_mag_fail[p_ptr->stat_ind[spell.use_stat]];
169
170                                         /* Minimum failure rate */
171                                         if (chance < minfail) chance = minfail;
172
173                                         /* Stunning makes spells harder */
174                                         if (p_ptr->stun > 50) chance += 25;
175                                         else if (p_ptr->stun) chance += 15;
176
177                                         /* Always a 5 percent chance of working */
178                                         if (chance > 95) chance = 95;
179
180                                         /* Get info */
181                                         mane_info(comment, p_ptr->mane_spell[i], (baigaesi ? p_ptr->mane_dam[i]*2 : p_ptr->mane_dam[i]));
182
183                                         /* Dump the spell --(-- */
184                                         sprintf(psi_desc, "  %c) %-30s %3d%%%s",
185                                                 I2A(i), spell.name,
186                                                 chance, comment);
187                                         prt(psi_desc, y + i + 1, x);
188                                 }
189
190                                 /* Clear the bottom line */
191                                 prt("", y + i + 1, x);
192                         }
193
194                         /* Hide the list */
195                         else
196                         {
197                                 /* Hide list */
198                                 redraw = FALSE;
199                                 screen_load();
200                         }
201
202                         /* Redo asking */
203                         continue;
204                 }
205
206                 /* Note verify */
207                 ask = isupper(choice);
208
209                 /* Lowercase */
210                 if (ask) choice = (char)tolower(choice);
211
212                 /* Extract request */
213                 i = (islower(choice) ? A2I(choice) : -1);
214
215                 /* Totally Illegal */
216                 if ((i < 0) || (i >= num))
217                 {
218                         bell();
219                         continue;
220                 }
221
222                 /* Save the spell index */
223                 spell = monster_powers[p_ptr->mane_spell[i]];
224
225                 /* Verify it */
226                 if (ask)
227                 {
228                         char tmp_val[160];
229
230                         /* Prompt */
231                         (void) strnfmt(tmp_val, 78, _("%sをまねますか?", "Use %s? "), monster_powers[p_ptr->mane_spell[i]].name);
232
233                         /* Belay that order */
234                         if (!get_check(tmp_val)) continue;
235                 }
236
237                 /* Stop the loop */
238                 flag = TRUE;
239         }
240         if (redraw) screen_load();
241
242         p_ptr->window |= (PW_SPELL);
243         handle_stuff();
244
245         /* Abort if needed */
246         if (!flag) return (FALSE);
247
248         /* Save the choice */
249         (*sn) = i;
250
251         damage = (baigaesi ? p_ptr->mane_dam[i]*2 : p_ptr->mane_dam[i]);
252
253         /* Success */
254         return (TRUE);
255 }
256
257
258 /*!
259  * @brief ものまね処理の発動 /
260  * do_cmd_cast calls this function if the player's class is 'imitator'.
261  * @param spell 発動するモンスター攻撃のID
262  * @return 処理を実行したらTRUE、キャンセルした場合FALSEを返す。
263  */
264 static bool use_mane(int spell)
265 {
266         DIRECTION dir;
267         PLAYER_LEVEL plev = p_ptr->lev;
268         BIT_FLAGS mode = (PM_ALLOW_GROUP | PM_FORCE_PET);
269         BIT_FLAGS u_mode = 0L;
270
271         if (randint1(50+plev) < plev/10) u_mode = PM_ALLOW_UNIQUE;
272
273
274         /* spell code */
275         switch (spell)
276         {
277
278         case MS_SHRIEK:
279                 msg_print(_("かん高い金切り声をあげた。", "You make a high pitched shriek."));
280                 aggravate_monsters(0);
281                 break;
282
283         case MS_XXX1:
284                 break;
285
286         case MS_DISPEL:
287         {
288                 MONSTER_IDX m_idx;
289
290                 if (!target_set(TARGET_KILL)) return FALSE;
291                 m_idx = current_floor_ptr->grid_array[target_row][target_col].m_idx;
292                 if (!m_idx) break;
293                 if (!player_has_los_bold(target_row, target_col)) break;
294                 if (!projectable(p_ptr->y, p_ptr->x, target_row, target_col)) break;
295                 dispel_monster_status(m_idx);
296                 break;
297         }
298
299         case MS_ROCKET:
300                 if (!get_aim_dir(&dir)) return FALSE;
301                 else msg_print(_("ロケットを発射した。", "You fire a rocket."));
302                         fire_rocket(GF_ROCKET, dir, damage, 2);
303                 break;
304
305         case MS_SHOOT:
306                 if (!get_aim_dir(&dir)) return FALSE;
307                 else msg_print(_("矢を放った。", "You fire an arrow."));
308                         fire_bolt(GF_ARROW, dir, damage);
309                 break;
310
311         case MS_XXX2:
312                 break;
313
314         case MS_XXX3:
315                 break;
316
317         case MS_XXX4:
318                 break;
319
320         case MS_BR_ACID:
321                 if (!get_aim_dir(&dir)) return FALSE;
322                 else msg_print(_("酸のブレスを吐いた。", "You breathe acid."));
323                 fire_breath(GF_ACID, dir, damage, (plev > 35 ? 3 : 2));
324                 break;
325
326         case MS_BR_ELEC:
327                 if (!get_aim_dir(&dir)) return FALSE;
328                 else msg_print(_("稲妻のブレスを吐いた。", "You breathe lightning."));
329                 fire_breath(GF_ELEC, dir, damage, (plev > 35 ? 3 : 2));
330                 break;
331
332         case MS_BR_FIRE:
333                 if (!get_aim_dir(&dir)) return FALSE;
334                 else msg_print(_("火炎のブレスを吐いた。", "You breathe fire."));
335                 fire_breath(GF_FIRE, dir, damage, (plev > 35 ? 3 : 2));
336                 break;
337
338         case MS_BR_COLD:
339                 if (!get_aim_dir(&dir)) return FALSE;
340                 else msg_print(_("冷気のブレスを吐いた。", "You breathe frost."));
341                 fire_breath(GF_COLD, dir, damage, (plev > 35 ? 3 : 2));
342                 break;
343
344         case MS_BR_POIS:
345                 if (!get_aim_dir(&dir)) return FALSE;
346                 else msg_print(_("ガスのブレスを吐いた。", "You breathe gas."));
347                 fire_breath(GF_POIS, dir, damage, (plev > 35 ? 3 : 2));
348                 break;
349
350         case MS_BR_NETHER:
351                 if (!get_aim_dir(&dir)) return FALSE;
352                 else msg_print(_("地獄のブレスを吐いた。", "You breathe nether."));
353                 fire_breath(GF_NETHER, dir, damage, (plev > 35 ? 3 : 2));
354                 break;
355
356         case MS_BR_LITE:
357                 if (!get_aim_dir(&dir)) return FALSE;
358                 else msg_print(_("閃光のブレスを吐いた。", "You breathe light."));
359                 fire_breath(GF_LITE, dir, damage, (plev > 35 ? 3 : 2));
360                 break;
361
362         case MS_BR_DARK:
363                 if (!get_aim_dir(&dir)) return FALSE;
364                 else msg_print(_("暗黒のブレスを吐いた。", "You breathe darkness."));
365                 fire_breath(GF_DARK, dir, damage, (plev > 35 ? 3 : 2));
366                 break;
367
368         case MS_BR_CONF:
369                 if (!get_aim_dir(&dir)) return FALSE;
370                 else msg_print(_("混乱のブレスを吐いた。", "You breathe confusion."));
371                 fire_breath(GF_CONFUSION, dir, damage, (plev > 35 ? 3 : 2));
372                 break;
373
374         case MS_BR_SOUND:
375                 if (!get_aim_dir(&dir)) return FALSE;
376                 else msg_print(_("轟音のブレスを吐いた。", "You breathe sound."));
377                 fire_breath(GF_SOUND, dir, damage, (plev > 35 ? 3 : 2));
378                 break;
379
380         case MS_BR_CHAOS:
381                 if (!get_aim_dir(&dir)) return FALSE;
382                 else msg_print(_("カオスのブレスを吐いた。", "You breathe chaos."));
383                 fire_breath(GF_CHAOS, dir, damage, (plev > 35 ? 3 : 2));
384                 break;
385
386         case MS_BR_DISEN:
387                 if (!get_aim_dir(&dir)) return FALSE;
388                 else msg_print(_("劣化のブレスを吐いた。", "You breathe disenchantment."));
389                 fire_breath(GF_DISENCHANT, dir, damage, (plev > 35 ? 3 : 2));
390                 break;
391
392         case MS_BR_NEXUS:
393                 if (!get_aim_dir(&dir)) return FALSE;
394                 else msg_print(_("因果混乱のブレスを吐いた。", "You breathe nexus."));
395                         fire_breath(GF_NEXUS, dir, damage, (plev > 35 ? 3 : 2));
396                 break;
397
398         case MS_BR_TIME:
399                 if (!get_aim_dir(&dir)) return FALSE;
400                 else msg_print(_("時間逆転のブレスを吐いた。", "You breathe time."));
401                 fire_breath(GF_TIME, dir, damage, (plev > 35 ? 3 : 2));
402                 break;
403
404         case MS_BR_INERTIA:
405                 if (!get_aim_dir(&dir)) return FALSE;
406                 else msg_print(_("遅鈍のブレスを吐いた。", "You breathe inertia."));
407                         fire_breath(GF_INERTIAL, dir, damage, (plev > 35 ? 3 : 2));
408                 break;
409
410         case MS_BR_GRAVITY:
411                 if (!get_aim_dir(&dir)) return FALSE;
412                 else msg_print(_("重力のブレスを吐いた。", "You breathe gravity."));         
413                 fire_breath(GF_GRAVITY, dir, damage, (plev > 35 ? 3 : 2));
414                 break;
415
416         case MS_BR_SHARDS:
417                 if (!get_aim_dir(&dir)) return FALSE;
418                 else msg_print(_("破片のブレスを吐いた。", "You breathe shards."));
419                 fire_breath(GF_SHARDS, dir, damage, (plev > 35 ? 3 : 2));
420                 break;
421
422         case MS_BR_PLASMA:
423                 if (!get_aim_dir(&dir)) return FALSE;
424                 else msg_print(_("プラズマのブレスを吐いた。", "You breathe plasma."));
425                 
426                 fire_breath(GF_PLASMA, dir, damage, (plev > 35 ? 3 : 2));
427                 break;
428
429         case MS_BR_FORCE:
430                 if (!get_aim_dir(&dir)) return FALSE;
431                 else msg_print(_("フォースのブレスを吐いた。", "You breathe force."));
432                 
433                 fire_breath(GF_FORCE, dir, damage, (plev > 35 ? 3 : 2));
434                 break;
435
436         case MS_BR_MANA:
437                 if (!get_aim_dir(&dir)) return FALSE;
438                 else msg_print(_("魔力のブレスを吐いた。", "You breathe mana."));
439                 
440                 fire_breath(GF_MANA, dir, damage, (plev > 35 ? 3 : 2));
441                 break;
442
443         case MS_BALL_NUKE:
444                 if (!get_aim_dir(&dir)) return FALSE;
445                 else msg_print(_("放射能球を放った。", "You cast a ball of radiation."));
446                 
447                         fire_ball(GF_NUKE, dir, damage, 2);
448                 break;
449
450         case MS_BR_NUKE:
451                 if (!get_aim_dir(&dir)) return FALSE;
452                 else msg_print(_("放射性廃棄物のブレスを吐いた。", "You breathe toxic waste."));
453                 
454                 fire_breath(GF_NUKE, dir, damage, (plev > 35 ? 3 : 2));
455                 break;
456
457         case MS_BALL_CHAOS:
458                 if (!get_aim_dir(&dir)) return FALSE;
459                 else msg_print(_("純ログルスを放った。", "You invoke a raw Logrus."));
460                 
461                         fire_ball(GF_CHAOS, dir, damage, 4);
462                 break;
463         case MS_BR_DISI:
464                 if (!get_aim_dir(&dir)) return FALSE;
465                 else msg_print(_("分解のブレスを吐いた。", "You breathe disintegration."));
466                 
467                 fire_breath(GF_DISINTEGRATE, dir, damage, (plev > 35 ? 3 : 2));
468                 break;
469         case MS_BALL_ACID:
470                 if (!get_aim_dir(&dir)) return FALSE;
471                 else msg_print(_("アシッド・ボールの呪文を唱えた。", "You cast an acid ball."));
472                 
473                         fire_ball(GF_ACID, dir, damage, 2);
474                 break;
475         case MS_BALL_ELEC:
476                 if (!get_aim_dir(&dir)) return FALSE;
477                 else msg_print(_("サンダー・ボールの呪文を唱えた。", "You cast a lightning ball."));
478                 
479                         fire_ball(GF_ELEC, dir, damage, 2);
480                 break;
481         case MS_BALL_FIRE:
482                 if (!get_aim_dir(&dir)) return FALSE;
483                 else msg_print(_("ファイア・ボールの呪文を唱えた。", "You cast a fire ball."));
484                 
485                         fire_ball(GF_FIRE, dir, damage, 2);
486                 break;
487         case MS_BALL_COLD:
488                 if (!get_aim_dir(&dir)) return FALSE;
489                 else msg_print(_("アイス・ボールの呪文を唱えた。", "You cast a frost ball."));
490                 
491                         fire_ball(GF_COLD, dir, damage, 2);
492                 break;
493         case MS_BALL_POIS:
494                 if (!get_aim_dir(&dir)) return FALSE;
495                 else msg_print(_("悪臭雲の呪文を唱えた。", "You cast a stinking cloud."));
496                 
497                         fire_ball(GF_POIS, dir, damage, 2);
498                 break;
499         case MS_BALL_NETHER:
500                 if (!get_aim_dir(&dir)) return FALSE;
501                 else msg_print(_("地獄球の呪文を唱えた。", "You cast a nether ball."));
502                 
503                         fire_ball(GF_NETHER, dir, damage, 2);
504                 break;
505         case MS_BALL_WATER:
506                 if (!get_aim_dir(&dir)) return FALSE;
507                 else msg_print(_("流れるような身振りをした。", "You gesture fluidly."));
508                 
509                         fire_ball(GF_WATER, dir, damage, 4);
510                 break;
511         case MS_BALL_MANA:
512                 if (!get_aim_dir(&dir)) return FALSE;
513                 else msg_print(_("魔力の嵐の呪文を念じた。", "You invoke a mana storm."));
514                 
515                         fire_ball(GF_MANA, dir, damage, 4);
516                 break;
517         case MS_BALL_DARK:
518                 if (!get_aim_dir(&dir)) return FALSE;
519                 else msg_print(_("暗黒の嵐の呪文を念じた。", "You invoke a darkness storm."));
520                 
521                         fire_ball(GF_DARK, dir, damage, 4);
522                 break;
523         case MS_DRAIN_MANA:
524                 if (!get_aim_dir(&dir)) return FALSE;
525                 fire_ball_hide(GF_DRAIN_MANA, dir, randint1(plev*3)+plev, 0);
526                 break;
527         case MS_MIND_BLAST:
528                 if (!get_aim_dir(&dir)) return FALSE;
529                 fire_ball_hide(GF_MIND_BLAST, dir, damage, 0);
530                 break;
531         case MS_BRAIN_SMASH:
532                 if (!get_aim_dir(&dir)) return FALSE;
533                 fire_ball_hide(GF_BRAIN_SMASH, dir, damage, 0);
534                 break;
535         case MS_CAUSE_1:
536                 if (!get_aim_dir(&dir)) return FALSE;
537                 fire_ball_hide(GF_CAUSE_1, dir, damage, 0);
538                 break;
539         case MS_CAUSE_2:
540                 if (!get_aim_dir(&dir)) return FALSE;
541                 fire_ball_hide(GF_CAUSE_2, dir, damage, 0);
542                 break;
543         case MS_CAUSE_3:
544                 if (!get_aim_dir(&dir)) return FALSE;
545                 fire_ball_hide(GF_CAUSE_3, dir, damage, 0);
546                 break;
547         case MS_CAUSE_4:
548                 if (!get_aim_dir(&dir)) return FALSE;
549                 fire_ball_hide(GF_CAUSE_4, dir, damage, 0);
550                 break;
551         case MS_BOLT_ACID:
552                 if (!get_aim_dir(&dir)) return FALSE;
553                 else msg_print(_("アシッド・ボルトの呪文を唱えた。", "You cast an acid bolt."));
554                 
555                         fire_bolt(GF_ACID, dir, damage);
556                 break;
557         case MS_BOLT_ELEC:
558                 if (!get_aim_dir(&dir)) return FALSE;
559                 else msg_print(_("サンダー・ボルトの呪文を唱えた。", "You cast a lightning bolt."));
560                 
561                         fire_bolt(GF_ELEC, dir, damage);
562                 break;
563         case MS_BOLT_FIRE:
564                 if (!get_aim_dir(&dir)) return FALSE;
565                 else msg_print(_("ファイア・ボルトの呪文を唱えた。", "You cast a fire bolt."));
566                 
567                         fire_bolt(GF_FIRE, dir, damage);
568                 break;
569         case MS_BOLT_COLD:
570                 if (!get_aim_dir(&dir)) return FALSE;
571                 else msg_print(_("アイス・ボルトの呪文を唱えた。", "You cast a frost bolt."));
572                 
573                         fire_bolt(GF_COLD, dir, damage);
574                 break;
575         case MS_STARBURST:
576                 if (!get_aim_dir(&dir)) return FALSE;
577                 else msg_print(_("スターバーストの呪文を念じた。", "You invoke a starburst."));
578                 
579                         fire_ball(GF_LITE, dir, damage, 4);
580                 break;
581         case MS_BOLT_NETHER:
582                 if (!get_aim_dir(&dir)) return FALSE;
583                 else msg_print(_("地獄の矢の呪文を唱えた。", "You cast a nether bolt."));
584                 
585                         fire_bolt(GF_NETHER, dir, damage);
586                 break;
587         case MS_BOLT_WATER:
588                 if (!get_aim_dir(&dir)) return FALSE;
589                 else msg_print(_("ウォーター・ボルトの呪文を唱えた。", "You cast a water bolt."));
590                 
591                         fire_bolt(GF_WATER, dir, damage);
592                 break;
593         case MS_BOLT_MANA:
594                 if (!get_aim_dir(&dir)) return FALSE;
595                 else msg_print(_("魔力の矢の呪文を唱えた。", "You cast a mana bolt."));
596                 
597                         fire_bolt(GF_MANA, dir, damage);
598                 break;
599         case MS_BOLT_PLASMA:
600                 if (!get_aim_dir(&dir)) return FALSE;
601                 else msg_print(_("プラズマ・ボルトの呪文を唱えた。", "You cast a plasma bolt."));
602                 
603                         fire_bolt(GF_PLASMA, dir, damage);
604                 break;
605         case MS_BOLT_ICE:
606                 if (!get_aim_dir(&dir)) return FALSE;
607                 else msg_print(_("極寒の矢の呪文を唱えた。", "You cast a ice bolt."));
608                 
609                         fire_bolt(GF_ICE, dir, damage);
610                 break;
611         case MS_MAGIC_MISSILE:
612                 if (!get_aim_dir(&dir)) return FALSE;
613                 else msg_print(_("マジック・ミサイルの呪文を唱えた。", "You cast a magic missile."));
614                 
615                         fire_bolt(GF_MISSILE, dir, damage);
616                 break;
617         case MS_SCARE:
618                 if (!get_aim_dir(&dir)) return FALSE;
619                 else msg_print(_("恐ろしげな幻覚を作り出した。", "You cast a fearful illusion."));
620                 
621                         fear_monster(dir, plev+10);
622                 break;
623         case MS_BLIND:
624                 if (!get_aim_dir(&dir)) return FALSE;
625                 confuse_monster(dir, plev * 2);
626                 break;
627         case MS_CONF:
628                 if (!get_aim_dir(&dir)) return FALSE;
629                 else msg_print(_("誘惑的な幻覚をつくり出した。", "You cast a mesmerizing illusion."));
630                 
631                         confuse_monster(dir, plev * 2);
632                 break;
633         case MS_SLOW:
634                 if (!get_aim_dir(&dir)) return FALSE;
635                 slow_monster(dir, plev);
636                 break;
637         case MS_SLEEP:
638                 if (!get_aim_dir(&dir)) return FALSE;
639                 sleep_monster(dir, plev);
640                 break;
641         case MS_SPEED:
642                 (void)set_fast(randint1(20 + plev) + plev, FALSE);
643                 break;
644         case MS_HAND_DOOM:
645         {
646                 if (!get_aim_dir(&dir)) return FALSE;
647                 else msg_print(_("<破滅の手>を放った!", "You invoke the Hand of Doom!"));
648
649                 fire_ball_hide(GF_HAND_DOOM, dir, 200, 0);
650                 break;
651         }
652         case MS_HEAL:
653                 msg_print(_("自分の傷に念を集中した。", "You concentrate on your wounds!"));
654                 (void)hp_player(plev*6);
655                 (void)set_stun(0);
656                 (void)set_cut(0);
657                 break;
658         case MS_INVULNER:
659                 msg_print(_("無傷の球の呪文を唱えた。", "You cast a Globe of Invulnerability."));
660                 (void)set_invuln(randint1(7) + 7, FALSE);
661                 break;
662         case MS_BLINK:
663                 teleport_player(10, 0L);
664                 break;
665         case MS_TELEPORT:
666                 teleport_player(plev * 5, 0L);
667                 break;
668         case MS_WORLD:
669                 (void)time_walk(p_ptr);
670                 break;
671         case MS_SPECIAL:
672                 break;
673         case MS_TELE_TO:
674         {
675                 monster_type *m_ptr;
676                 monster_race *r_ptr;
677                 GAME_TEXT m_name[MAX_NLEN];
678
679                 if (!target_set(TARGET_KILL)) return FALSE;
680                 if (!current_floor_ptr->grid_array[target_row][target_col].m_idx) break;
681                 if (!player_has_los_bold(target_row, target_col)) break;
682                 if (!projectable(p_ptr->y, p_ptr->x, target_row, target_col)) break;
683                 m_ptr = &current_floor_ptr->m_list[current_floor_ptr->grid_array[target_row][target_col].m_idx];
684                 r_ptr = &r_info[m_ptr->r_idx];
685                 monster_desc(m_name, m_ptr, 0);
686                 if (r_ptr->flagsr & RFR_RES_TELE)
687                 {
688                         if ((r_ptr->flags1 & (RF1_UNIQUE)) || (r_ptr->flagsr & RFR_RES_ALL))
689                         {
690                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
691                                 msg_format(_("%sには効果がなかった!", "%s is unaffected!"), m_name);
692
693                                 break;
694                         }
695                         else if (r_ptr->level > randint1(100))
696                         {
697                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
698                                 msg_format(_("%sには耐性がある!", "%s resists!"), m_name);
699
700                                 break;
701                         }
702                 }
703                 msg_format(_("%sを引き戻した。", "You command %s to return."), m_name);
704
705                 teleport_monster_to(current_floor_ptr->grid_array[target_row][target_col].m_idx, p_ptr->y, p_ptr->x, 100, TELEPORT_PASSIVE);
706                 break;
707         }
708         case MS_TELE_AWAY:
709                 if (!get_aim_dir(&dir)) return FALSE;
710
711                 (void)fire_beam(GF_AWAY_ALL, dir, plev);
712                 break;
713
714         case MS_TELE_LEVEL:
715                 return teleport_level_other(p_ptr);
716                 break;
717
718         case MS_PSY_SPEAR:
719                 if (!get_aim_dir(&dir)) return FALSE;
720                 else msg_print(_("光の剣を放った。", "You throw a psycho-spear."));
721                 (void)fire_beam(GF_PSY_SPEAR, dir, damage);
722                 break;
723
724         case MS_DARKNESS:
725                 msg_print(_("暗闇の中で手を振った。", "You gesture in shadow."));
726                 (void)unlite_area(10, 3);
727                 break;
728
729         case MS_MAKE_TRAP:
730                 if (!target_set(TARGET_KILL)) return FALSE;
731                 msg_print(_("呪文を唱えて邪悪に微笑んだ。", "You cast a spell and cackles evilly."));
732                 trap_creation(target_row, target_col);
733                 break;
734         case MS_FORGET:
735                 msg_print(_("しかし何も起きなかった。", "Nothing happen."));
736                 break;
737         case MS_RAISE_DEAD:
738                 msg_print(_("死者復活の呪文を唱えた。", "You cast a animate dead."));
739                 (void)animate_dead(0, p_ptr->y, p_ptr->x);
740                 break;
741         case MS_S_KIN:
742         {
743                 int k;
744                 if (!target_set(TARGET_KILL)) return FALSE;
745
746                 msg_print(_("援軍を召喚した。", "You summon minions."));
747                 for (k = 0;k < 4; k++)
748                 {
749                         (void)summon_kin_player(plev, target_row, target_col, (PM_FORCE_PET | PM_ALLOW_GROUP));
750                 }
751                 break;
752         }
753         case MS_S_CYBER:
754         {
755                 int k;
756                 int max_cyber = (current_floor_ptr->dun_level / 50) + randint1(3);
757                 if (!target_set(TARGET_KILL)) return FALSE;
758                 msg_print(_("サイバーデーモンを召喚した!", "You summon Cyberdemons!"));
759                 if (max_cyber > 4) max_cyber = 4;
760                 for (k = 0;k < max_cyber; k++)
761                         summon_specific(-1, target_row, target_col, plev, SUMMON_CYBER, mode, '\0');
762                 break;
763         }
764         case MS_S_MONSTER:
765         {
766                 int k;
767                 if (!target_set(TARGET_KILL)) return FALSE;
768                 msg_print(_("仲間を召喚した。", "You summon help."));
769                 for (k = 0;k < 1; k++)
770                         summon_specific(-1, target_row, target_col, plev, 0, (mode | u_mode), '\0');
771                 break;
772         }
773         case MS_S_MONSTERS:
774         {
775                 int k;
776                 if (!target_set(TARGET_KILL)) return FALSE;
777                 msg_print(_("モンスターを召喚した!", "You summon monsters!"));
778                 for (k = 0; k < 6; k++)
779                         summon_specific(-1, target_row, target_col, plev, 0, (mode | u_mode), '\0');
780                 break;
781         }
782         case MS_S_ANT:
783         {
784                 int k;
785                 if (!target_set(TARGET_KILL)) return FALSE;
786                 msg_print(_("アリを召喚した。", "You summon ants."));
787                 for (k = 0; k < 6; k++)
788                         summon_specific(-1, target_row, target_col, plev, SUMMON_ANT, mode, '\0');
789                 break;
790         }
791         case MS_S_SPIDER:
792         {
793                 int k;
794                 if (!target_set(TARGET_KILL)) return FALSE;
795                 msg_print(_("蜘蛛を召喚した。", "You summon spiders."));
796                 for (k = 0; k < 6; k++)
797                         summon_specific(-1, target_row, target_col, plev, SUMMON_SPIDER, mode, '\0');
798                 break;
799         }
800         case MS_S_HOUND:
801         {
802                 int k;
803                 if (!target_set(TARGET_KILL)) return FALSE;
804                 msg_print(_("ハウンドを召喚した。", "You summon hounds."));
805                 for (k = 0; k < 4; k++)
806                         summon_specific(-1, target_row, target_col, plev, SUMMON_HOUND, mode, '\0');
807                 break;
808         }
809         case MS_S_HYDRA:
810         {
811                 int k;
812                 if (!target_set(TARGET_KILL)) return FALSE;
813                 msg_print(_("ヒドラを召喚した。", "You summon hydras."));
814                 for (k = 0; k < 4; k++)
815                         summon_specific(-1, target_row, target_col, plev, SUMMON_HYDRA, mode, '\0');
816                 break;
817         }
818         case MS_S_ANGEL:
819         {
820                 int k;
821                 if (!target_set(TARGET_KILL)) return FALSE;
822                 msg_print(_("天使を召喚した!", "You summon angel!"));
823                 for (k = 0; k < 1; k++)
824                         summon_specific(-1, target_row, target_col, plev, SUMMON_ANGEL, mode, '\0');
825                 break;
826         }
827         case MS_S_DEMON:
828         {
829                 int k;
830                 if (!target_set(TARGET_KILL)) return FALSE;
831                 msg_print(_("混沌の宮廷から悪魔を召喚した!", "You summon a demon from the Courts of Chaos!"));
832                 for (k = 0; k < 1; k++)
833                         summon_specific(-1, target_row, target_col, plev, SUMMON_DEMON, (mode | u_mode), '\0');
834                 break;
835         }
836         case MS_S_UNDEAD:
837         {
838                 int k;
839                 if (!target_set(TARGET_KILL)) return FALSE;
840                 msg_print(_("アンデッドの強敵を召喚した!", "You summon an undead adversary!"));
841                 for (k = 0; k < 1; k++)
842                         summon_specific(-1, target_row, target_col, plev, SUMMON_UNDEAD, (mode | u_mode), '\0');
843                 break;
844         }
845         case MS_S_DRAGON:
846         {
847                 int k;
848                 if (!target_set(TARGET_KILL)) return FALSE;
849                 msg_print(_("ドラゴンを召喚した!", "You summon dragon!"));
850                 for (k = 0; k < 1; k++)
851                         summon_specific(-1, target_row, target_col, plev, SUMMON_DRAGON, (mode | u_mode), '\0');
852                 break;
853         }
854         case MS_S_HI_UNDEAD:
855         {
856                 int k;
857                 if (!target_set(TARGET_KILL)) return FALSE;
858                 msg_print(_("強力なアンデッドを召喚した!", "You summon greater undead!"));
859                 for (k = 0; k < 6; k++)
860                         summon_specific(-1, target_row, target_col, plev, SUMMON_HI_UNDEAD, (mode | u_mode), '\0');
861                 break;
862         }
863         case MS_S_HI_DRAGON:
864         {
865                 int k;
866                 if (!target_set(TARGET_KILL)) return FALSE;
867                 msg_print(_("古代ドラゴンを召喚した!", "You summon ancient dragons!"));
868                 for (k = 0; k < 4; k++)
869                         summon_specific(-1, target_row, target_col, plev, SUMMON_HI_DRAGON, (mode | u_mode), '\0');
870                 break;
871         }
872         case MS_S_AMBERITE:
873         {
874                 int k;
875                 if (!target_set(TARGET_KILL)) return FALSE;
876                 msg_print(_("アンバーの王族を召喚した!", "You summon Lords of Amber!"));
877                 for (k = 0; k < 4; k++)
878                         summon_specific(-1, target_row, target_col, plev, SUMMON_AMBERITES, (mode | PM_ALLOW_UNIQUE), '\0');
879                 break;
880         }
881         case MS_S_UNIQUE:
882         {
883                 int k, count = 0;
884                 if (!target_set(TARGET_KILL)) return FALSE;
885                 msg_print(_("特別な強敵を召喚した!", "You summon special opponents!"));
886                 for (k = 0;k < 4; k++)
887                         if (summon_specific(-1, target_row, target_col, plev, SUMMON_UNIQUE, (mode | PM_ALLOW_UNIQUE), '\0')) count++;
888                 for (k = count;k < 4; k++)
889                         summon_specific(-1, target_row, target_col, plev, SUMMON_HI_UNDEAD, (mode | u_mode), '\0');
890                 break;
891         }
892         default:
893                 msg_print("hoge?");
894         }
895
896         return TRUE;
897 }
898
899
900 /*!
901  * @brief ものまねコマンドのメインルーチン /
902  * do_cmd_cast calls this function if the player's class is 'imitator'.
903  * @param baigaesi TRUEならば倍返し上の処理として行う
904  * @return 処理を実行したらTRUE、キャンセルした場合FALSEを返す。
905  * @details
906  * If a valid spell is chosen, saves it in '*sn' and returns TRUE
907  * If the user hits escape, returns FALSE, and set '*sn' to -1
908  * If there are no legal choices, returns FALSE, and sets '*sn' to -2
909  *
910  * The "prompt" should be "cast", "recite", or "study"
911  * The "known" should be TRUE for cast/pray, FALSE for study
912  *
913  * nb: This function has a (trivial) display bug which will be obvious
914  * when you run it. It's probably easy to fix but I haven't tried,
915  * sorry.
916  */
917 bool do_cmd_mane(bool baigaesi)
918 {
919         int n = 0, j;
920         PERCENTAGE chance;
921         PERCENTAGE minfail = 0;
922         PLAYER_LEVEL plev = p_ptr->lev;
923         monster_power   spell;
924         bool            cast;
925
926         if (cmd_limit_confused(p_ptr)) return FALSE;
927
928         if (!p_ptr->mane_num)
929         {
930                 msg_print(_("まねられるものが何もない!", "You don't remember any action!"));
931                 return FALSE;
932         }
933
934         if (!get_mane_power(&n, baigaesi)) return FALSE;
935
936         spell = monster_powers[p_ptr->mane_spell[n]];
937
938         /* Spell failure chance */
939         chance = spell.manefail;
940
941         /* Reduce failure rate by "effective" level adjustment */
942         if (plev > spell.level) chance -= 3 * (plev - spell.level);
943
944         /* Reduce failure rate by 1 stat and DEX adjustment */
945         chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[spell.use_stat]] + adj_mag_stat[p_ptr->stat_ind[A_DEX]] - 2) / 2;
946
947         if (spell.manedam) chance = chance * damage / spell.manedam;
948
949         chance += p_ptr->to_m_chance;
950
951         /* Extract the minimum failure rate */
952         minfail = adj_mag_fail[p_ptr->stat_ind[spell.use_stat]];
953
954         /* Minimum failure rate */
955         if (chance < minfail) chance = minfail;
956
957         /* Stunning makes spells harder */
958         if (p_ptr->stun > 50) chance += 25;
959         else if (p_ptr->stun) chance += 15;
960
961         /* Always a 5 percent chance of working */
962         if (chance > 95) chance = 95;
963
964         /* Failed spell */
965         if (randint0(100) < chance)
966         {
967                 if (flush_failure) flush();
968                 msg_print(_("ものまねに失敗した!", "You failed to concentrate hard enough!"));
969                 sound(SOUND_FAIL);
970         }
971         else
972         {
973                 sound(SOUND_ZAP);
974                 cast = use_mane(p_ptr->mane_spell[n]);
975                 if (!cast) return FALSE;
976         }
977
978         p_ptr->mane_num--;
979         for (j = n; j < p_ptr->mane_num;j++)
980         {
981                 p_ptr->mane_spell[j] = p_ptr->mane_spell[j+1];
982                 p_ptr->mane_dam[j] = p_ptr->mane_dam[j+1];
983         }
984
985         take_turn(p_ptr, 100);
986
987         p_ptr->redraw |= (PR_IMITATION);
988         p_ptr->window |= (PW_PLAYER);
989         p_ptr->window |= (PW_SPELL);
990
991         return TRUE;
992 }