OSDN Git Service

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