OSDN Git Service

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