OSDN Git Service

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