OSDN Git Service

[Refactor] #37353 メッセージ整理。 / Refactor messages.
[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         PLAYER_LEVEL plev = p_ptr->lev;
27         cptr s_dam = _("損傷:", "dam ");
28         cptr s_dur = _("期間:", "dur ");
29         cptr s_range = _("範囲:", "range ");
30         cptr s_heal = _("回復:", "heal ");
31
32         strcpy(p, "");
33
34         if ((power > 2 && power < 41) || (power > 41 && power < 59) || (power == 75))
35                 sprintf(p, " %s%d", s_dam, (int)dam);
36         else
37         {
38                 switch (power)
39                 {
40                         case 41:
41                                 sprintf(p, " %sd%d+%d", s_heal, plev * 3, plev);
42                                 break;
43                         case 64:
44                                 sprintf(p, " %sd%d+%d", s_dur, 20+plev, plev);
45                                 break;
46                         case 66:
47                                 sprintf(p, " %s%d", s_heal, plev*6);
48                                 break;
49                         case 67:
50                                 sprintf(p, " %sd7+7", s_dur);
51                                 break;
52                         case 68:
53                                 sprintf(p, " %s10", s_range);
54                                 break;
55                         case 69:
56                                 sprintf(p, " %s%d", s_range, plev * 5);
57                                 break;
58                         case 79:
59                                 sprintf(p, " %s5", s_range);
60                                 break;
61                         default:
62                                 break;
63                 }
64         }
65 }
66
67
68 /*!
69  * @brief どのものまねを発動するか選択する処理 /
70  * Allow user to choose a imitation.
71  * @param sn 実行したものまねのIDを返す参照ポインタ(キャンセルなどの場合-1を返す)
72  * @param baigaesi TRUEならば倍返し上の処理として行う
73  * @return 処理を実行したらTRUE、キャンセルした場合FALSEを返す。
74  * @details
75  * If a valid spell is chosen, saves it in '*sn' and returns TRUE
76  * If the user hits escape, returns FALSE, and set '*sn' to -1
77  * If there are no legal choices, returns FALSE, and sets '*sn' to -2
78  *
79  * The "prompt" should be "cast", "recite", or "study"
80  * The "known" should be TRUE for cast/pray, FALSE for study
81  *
82  * nb: This function has a (trivial) display bug which will be obvious
83  * when you run it. It's probably easy to fix but I haven't tried,
84  * sorry.
85  */
86 static int get_mane_power(int *sn, bool baigaesi)
87 {
88         int             i = 0;
89         int             num = 0;
90         TERM_LEN y = 1;
91         TERM_LEN x = 18;
92         int             minfail = 0;
93         PLAYER_LEVEL plev = p_ptr->lev;
94         int             chance = 0;
95         int             ask;
96         char            choice;
97         char            out_val[160];
98         char            comment[80];
99         cptr            p = _("能力", "power");
100
101         monster_power   spell;
102         bool            flag, redraw;
103
104         /* Assume cancelled */
105         *sn = (-1);
106
107         /* Nothing chosen yet */
108         flag = FALSE;
109
110         /* No redraw yet */
111         redraw = FALSE;
112
113         num = p_ptr->mane_num;
114
115         /* Build a prompt (accept all spells) */
116         (void)strnfmt(out_val, 78, 
117                       _("(%c-%c, '*'で一覧, ESC) どの%sをまねますか?", "(%c-%c, *=List, ESC=exit) Use which %s? "),
118                       I2A(0), I2A(num - 1), p);
119
120         /* Get a spell from the user */
121
122         choice= always_show_list ? ESCAPE:1 ;
123         while (!flag)
124         {
125                 if(choice==ESCAPE) choice = ' '; 
126                 else if( !get_com(out_val, &choice, TRUE) )break; 
127
128                 /* Request redraw */
129                 if ((choice == ' ') || (choice == '*') || (choice == '?'))
130                 {
131                         /* Show the list */
132                         if (!redraw)
133                         {
134                                 char psi_desc[80];
135
136                                 /* Show list */
137                                 redraw = TRUE;
138                                 screen_save();
139
140                                 /* Display a list of spells */
141                                 prt("", y, x);
142                                 put_str(_("名前", "Name"), y, x + 5);
143                                 put_str(_("失率 効果", "Fail Info"), y, x + 36);
144
145
146                                 /* Dump the spells */
147                                 for (i = 0; i < num; i++)
148                                 {
149                                         /* Access the spell */
150                                         spell = monster_powers[p_ptr->mane_spell[i]];
151
152                                         chance = spell.manefail;
153
154                                         /* Reduce failure rate by "effective" level adjustment */
155                                         if (plev > spell.level) chance -= 3 * (plev - spell.level);
156
157                                         /* Reduce failure rate by INT/WIS adjustment */
158                                         chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[spell.use_stat]] + adj_mag_stat[p_ptr->stat_ind[A_DEX]] - 2) / 2;
159
160                                         if (spell.manedam) chance = chance * (baigaesi ? p_ptr->mane_dam[i] * 2 : p_ptr->mane_dam[i]) / spell.manedam;
161
162                                         chance += p_ptr->to_m_chance;
163
164                                         /* Extract the minimum failure rate */
165                                         minfail = adj_mag_fail[p_ptr->stat_ind[spell.use_stat]];
166
167                                         /* Minimum failure rate */
168                                         if (chance < minfail) chance = minfail;
169
170                                         /* Stunning makes spells harder */
171                                         if (p_ptr->stun > 50) chance += 25;
172                                         else if (p_ptr->stun) chance += 15;
173
174                                         /* Always a 5 percent chance of working */
175                                         if (chance > 95) chance = 95;
176
177                                         /* Get info */
178                                         mane_info(comment, p_ptr->mane_spell[i], (baigaesi ? p_ptr->mane_dam[i]*2 : p_ptr->mane_dam[i]));
179
180                                         /* Dump the spell --(-- */
181                                         sprintf(psi_desc, "  %c) %-30s %3d%%%s",
182                                                 I2A(i), spell.name,
183                                                 chance, comment);
184                                         prt(psi_desc, y + i + 1, x);
185                                 }
186
187                                 /* Clear the bottom line */
188                                 prt("", y + i + 1, x);
189                         }
190
191                         /* Hide the list */
192                         else
193                         {
194                                 /* Hide list */
195                                 redraw = FALSE;
196
197                                 /* Restore the screen */
198                                 screen_load();
199                         }
200
201                         /* Redo asking */
202                         continue;
203                 }
204
205                 /* Note verify */
206                 ask = isupper(choice);
207
208                 /* Lowercase */
209                 if (ask) choice = (char)tolower(choice);
210
211                 /* Extract request */
212                 i = (islower(choice) ? A2I(choice) : -1);
213
214                 /* Totally Illegal */
215                 if ((i < 0) || (i >= num))
216                 {
217                         bell();
218                         continue;
219                 }
220
221                 /* Save the spell index */
222                 spell = monster_powers[p_ptr->mane_spell[i]];
223
224                 /* Verify it */
225                 if (ask)
226                 {
227                         char tmp_val[160];
228
229                         /* Prompt */
230                         (void) strnfmt(tmp_val, 78, _("%sをまねますか?", "Use %s? "), monster_powers[p_ptr->mane_spell[i]].name);
231
232                         /* Belay that order */
233                         if (!get_check(tmp_val)) continue;
234                 }
235
236                 /* Stop the loop */
237                 flag = TRUE;
238         }
239
240         /* Restore the screen */
241         if (redraw) screen_load();
242
243         p_ptr->window |= (PW_SPELL);
244         handle_stuff();
245
246         /* Abort if needed */
247         if (!flag) return (FALSE);
248
249         /* Save the choice */
250         (*sn) = i;
251
252         damage = (baigaesi ? p_ptr->mane_dam[i]*2 : p_ptr->mane_dam[i]);
253
254         /* Success */
255         return (TRUE);
256 }
257
258
259 /*!
260  * @brief ものまね処理の発動 /
261  * do_cmd_cast calls this function if the player's class is 'imitator'.
262  * @param spell 発動するモンスター攻撃のID
263  * @return 処理を実行したらTRUE、キャンセルした場合FALSEを返す。
264  */
265 static bool use_mane(int spell)
266 {
267         DIRECTION dir;
268         PLAYER_LEVEL plev = p_ptr->lev;
269         BIT_FLAGS mode = (PM_ALLOW_GROUP | PM_FORCE_PET);
270         BIT_FLAGS u_mode = 0L;
271
272         if (randint1(50+plev) < plev/10) u_mode = PM_ALLOW_UNIQUE;
273
274
275         /* spell code */
276         switch (spell)
277         {
278
279         case MS_SHRIEK:
280                 msg_print(_("かん高い金切り声をあげた。", "You make a high pitched shriek."));
281                 aggravate_monsters(0);
282                 break;
283
284         case MS_XXX1:
285                 break;
286
287         case MS_DISPEL:
288         {
289                 MONSTER_IDX m_idx;
290
291                 if (!target_set(TARGET_KILL)) return FALSE;
292                 m_idx = cave[target_row][target_col].m_idx;
293                 if (!m_idx) break;
294                 if (!player_has_los_bold(target_row, target_col)) break;
295                 if (!projectable(p_ptr->y, p_ptr->x, target_row, target_col)) break;
296                 dispel_monster_status(m_idx);
297                 break;
298         }
299
300         case MS_ROCKET:
301                 if (!get_aim_dir(&dir)) return FALSE;
302                 else msg_print(_("ロケットを発射した。", "You fire a rocket."));
303                         fire_rocket(GF_ROCKET, dir, damage, 2);
304                 break;
305
306         case MS_SHOOT:
307                 if (!get_aim_dir(&dir)) return FALSE;
308                 else msg_print(_("矢を放った。", "You fire an arrow."));
309                         fire_bolt(GF_ARROW, dir, damage);
310                 break;
311
312         case MS_XXX2:
313                 break;
314
315         case MS_XXX3:
316                 break;
317
318         case MS_XXX4:
319                 break;
320
321         case MS_BR_ACID:
322                 if (!get_aim_dir(&dir)) return FALSE;
323                 else msg_print(_("酸のブレスを吐いた。", "You breathe acid."));
324                 fire_breath(GF_ACID, dir, damage, (plev > 35 ? 3 : 2));
325                 break;
326
327         case MS_BR_ELEC:
328                 if (!get_aim_dir(&dir)) return FALSE;
329                 else msg_print(_("稲妻のブレスを吐いた。", "You breathe lightning."));
330                 fire_breath(GF_ELEC, dir, damage, (plev > 35 ? 3 : 2));
331                 break;
332
333         case MS_BR_FIRE:
334                 if (!get_aim_dir(&dir)) return FALSE;
335                 else msg_print(_("火炎のブレスを吐いた。", "You breathe fire."));
336                 fire_breath(GF_FIRE, dir, damage, (plev > 35 ? 3 : 2));
337                 break;
338
339         case MS_BR_COLD:
340                 if (!get_aim_dir(&dir)) return FALSE;
341                 else msg_print(_("冷気のブレスを吐いた。", "You breathe frost."));
342                 fire_breath(GF_COLD, dir, damage, (plev > 35 ? 3 : 2));
343                 break;
344
345         case MS_BR_POIS:
346                 if (!get_aim_dir(&dir)) return FALSE;
347                 else msg_print(_("ガスのブレスを吐いた。", "You breathe gas."));
348                 fire_breath(GF_POIS, dir, damage, (plev > 35 ? 3 : 2));
349                 break;
350
351         case MS_BR_NETHER:
352                 if (!get_aim_dir(&dir)) return FALSE;
353                 else msg_print(_("地獄のブレスを吐いた。", "You breathe nether."));
354                 fire_breath(GF_NETHER, dir, damage, (plev > 35 ? 3 : 2));
355                 break;
356
357         case MS_BR_LITE:
358                 if (!get_aim_dir(&dir)) return FALSE;
359                 else msg_print(_("閃光のブレスを吐いた。", "You breathe light."));
360                 fire_breath(GF_LITE, dir, damage, (plev > 35 ? 3 : 2));
361                 break;
362
363         case MS_BR_DARK:
364                 if (!get_aim_dir(&dir)) return FALSE;
365                 else msg_print(_("暗黒のブレスを吐いた。", "You breathe darkness."));
366                 fire_breath(GF_DARK, dir, damage, (plev > 35 ? 3 : 2));
367                 break;
368
369         case MS_BR_CONF:
370                 if (!get_aim_dir(&dir)) return FALSE;
371                 else msg_print(_("混乱のブレスを吐いた。", "You breathe confusion."));
372                 fire_breath(GF_CONFUSION, dir, damage, (plev > 35 ? 3 : 2));
373                 break;
374
375         case MS_BR_SOUND:
376                 if (!get_aim_dir(&dir)) return FALSE;
377                 else msg_print(_("轟音のブレスを吐いた。", "You breathe sound."));
378                 fire_breath(GF_SOUND, dir, damage, (plev > 35 ? 3 : 2));
379                 break;
380
381         case MS_BR_CHAOS:
382                 if (!get_aim_dir(&dir)) return FALSE;
383                 else msg_print(_("カオスのブレスを吐いた。", "You breathe chaos."));
384                 fire_breath(GF_CHAOS, dir, damage, (plev > 35 ? 3 : 2));
385                 break;
386
387         case MS_BR_DISEN:
388                 if (!get_aim_dir(&dir)) return FALSE;
389                 else msg_print(_("劣化のブレスを吐いた。", "You breathe disenchantment."));
390                 fire_breath(GF_DISENCHANT, dir, damage, (plev > 35 ? 3 : 2));
391                 break;
392
393         case MS_BR_NEXUS:
394                 if (!get_aim_dir(&dir)) return FALSE;
395                 else msg_print(_("因果混乱のブレスを吐いた。", "You breathe nexus."));
396                         fire_breath(GF_NEXUS, dir, damage, (plev > 35 ? 3 : 2));
397                 break;
398
399         case MS_BR_TIME:
400                 if (!get_aim_dir(&dir)) return FALSE;
401                 else msg_print(_("時間逆転のブレスを吐いた。", "You breathe time."));
402                 fire_breath(GF_TIME, dir, damage, (plev > 35 ? 3 : 2));
403                 break;
404
405         case MS_BR_INERTIA:
406                 if (!get_aim_dir(&dir)) return FALSE;
407                 else msg_print(_("遅鈍のブレスを吐いた。", "You breathe inertia."));
408                         fire_breath(GF_INERTIAL, dir, damage, (plev > 35 ? 3 : 2));
409                 break;
410
411         case MS_BR_GRAVITY:
412                 if (!get_aim_dir(&dir)) return FALSE;
413                 else msg_print(_("重力のブレスを吐いた。", "You breathe gravity."));         
414                 fire_breath(GF_GRAVITY, dir, damage, (plev > 35 ? 3 : 2));
415                 break;
416
417         case MS_BR_SHARDS:
418                 if (!get_aim_dir(&dir)) return FALSE;
419                 else msg_print(_("破片のブレスを吐いた。", "You breathe shards."));
420                 fire_breath(GF_SHARDS, dir, damage, (plev > 35 ? 3 : 2));
421                 break;
422
423         case MS_BR_PLASMA:
424                 if (!get_aim_dir(&dir)) return FALSE;
425                 else msg_print(_("プラズマのブレスを吐いた。", "You breathe plasma."));
426                 
427                 fire_breath(GF_PLASMA, dir, damage, (plev > 35 ? 3 : 2));
428                 break;
429
430         case MS_BR_FORCE:
431                 if (!get_aim_dir(&dir)) return FALSE;
432                 else msg_print(_("フォースのブレスを吐いた。", "You breathe force."));
433                 
434                 fire_breath(GF_FORCE, dir, damage, (plev > 35 ? 3 : 2));
435                 break;
436
437         case MS_BR_MANA:
438                 if (!get_aim_dir(&dir)) return FALSE;
439                 else msg_print(_("魔力のブレスを吐いた。", "You breathe mana."));
440                 
441                 fire_breath(GF_MANA, dir, damage, (plev > 35 ? 3 : 2));
442                 break;
443
444         case MS_BALL_NUKE:
445                 if (!get_aim_dir(&dir)) return FALSE;
446                 else msg_print(_("放射能球を放った。", "You cast a ball of radiation."));
447                 
448                         fire_ball(GF_NUKE, dir, damage, 2);
449                 break;
450
451         case MS_BR_NUKE:
452                 if (!get_aim_dir(&dir)) return FALSE;
453                 else msg_print(_("放射性廃棄物のブレスを吐いた。", "You breathe toxic waste."));
454                 
455                 fire_breath(GF_NUKE, dir, damage, (plev > 35 ? 3 : 2));
456                 break;
457
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_breath(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                 p_ptr->redraw |= (PR_MAP);
683                 p_ptr->update |= (PU_MONSTERS);
684
685                 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
686
687                 handle_stuff();
688                 break;
689         case MS_SPECIAL:
690                 break;
691         case MS_TELE_TO:
692         {
693                 monster_type *m_ptr;
694                 monster_race *r_ptr;
695                 char m_name[80];
696
697                 if (!target_set(TARGET_KILL)) return FALSE;
698                 if (!cave[target_row][target_col].m_idx) break;
699                 if (!player_has_los_bold(target_row, target_col)) break;
700                 if (!projectable(p_ptr->y, p_ptr->x, target_row, target_col)) break;
701                 m_ptr = &m_list[cave[target_row][target_col].m_idx];
702                 r_ptr = &r_info[m_ptr->r_idx];
703                 monster_desc(m_name, m_ptr, 0);
704                 if (r_ptr->flagsr & RFR_RES_TELE)
705                 {
706                         if ((r_ptr->flags1 & (RF1_UNIQUE)) || (r_ptr->flagsr & RFR_RES_ALL))
707                         {
708                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
709                                 msg_format(_("%sには効果がなかった!", "%s is unaffected!"), m_name);
710
711                                 break;
712                         }
713                         else if (r_ptr->level > randint1(100))
714                         {
715                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
716                                 msg_format(_("%sには耐性がある!", "%s resists!"), m_name);
717
718                                 break;
719                         }
720                 }
721                 msg_format(_("%sを引き戻した。", "You command %s to return."), m_name);
722
723                 teleport_monster_to(cave[target_row][target_col].m_idx, p_ptr->y, p_ptr->x, 100, TELEPORT_PASSIVE);
724                 break;
725         }
726         case MS_TELE_AWAY:
727                 if (!get_aim_dir(&dir)) return FALSE;
728
729                 (void)fire_beam(GF_AWAY_ALL, dir, plev);
730                 break;
731         case MS_TELE_LEVEL:
732         {
733                 IDX target_m_idx;
734                 monster_type *m_ptr;
735                 monster_race *r_ptr;
736                 char m_name[80];
737
738                 if (!target_set(TARGET_KILL)) return FALSE;
739                 target_m_idx = cave[target_row][target_col].m_idx;
740                 if (!target_m_idx) break;
741                 if (!player_has_los_bold(target_row, target_col)) break;
742                 if (!projectable(p_ptr->y, p_ptr->x, target_row, target_col)) break;
743                 m_ptr = &m_list[target_m_idx];
744                 r_ptr = &r_info[m_ptr->r_idx];
745                 monster_desc(m_name, m_ptr, 0);
746                 msg_format(_("%^sの足を指さした。", "You gesture at %^s's feet."), m_name);
747
748                 if ((r_ptr->flagsr & (RFR_EFF_RES_NEXU_MASK | RFR_RES_TELE)) ||
749                         (r_ptr->flags1 & RF1_QUESTOR) || (r_ptr->level + randint1(50) > plev + randint1(60)))
750                 {
751                         msg_print(_("しかし効果がなかった!", "%^s is unaffected!"));
752                 }
753                 else teleport_level(target_m_idx);
754                 break;
755         }
756
757         case MS_PSY_SPEAR:
758                 if (!get_aim_dir(&dir)) return FALSE;
759                 else msg_print(_("光の剣を放った。", "You throw a psycho-spear."));
760                 (void)fire_beam(GF_PSY_SPEAR, dir, damage);
761                 break;
762
763         case MS_DARKNESS:
764                 msg_print(_("暗闇の中で手を振った。", "You gesture in shadow."));
765                 (void)unlite_area(10, 3);
766                 break;
767
768         case MS_MAKE_TRAP:
769                 if (!target_set(TARGET_KILL)) return FALSE;
770                 msg_print(_("呪文を唱えて邪悪に微笑んだ。", "You cast a spell and cackles evilly."));
771                 trap_creation(target_row, target_col);
772                 break;
773         case MS_FORGET:
774                 msg_print(_("しかし何も起きなかった。", "Nothing happen."));
775                 break;
776         case MS_RAISE_DEAD:
777                 msg_print(_("死者復活の呪文を唱えた。", "You cast a animate dead."));
778                 (void)animate_dead(0, p_ptr->y, p_ptr->x);
779                 break;
780         case MS_S_KIN:
781         {
782                 int k;
783                 if (!target_set(TARGET_KILL)) return FALSE;
784
785                 msg_print(_("援軍を召喚した。", "You summon minions."));
786                 for (k = 0;k < 4; k++)
787                 {
788                         (void)summon_kin_player(plev, target_row, target_col, (PM_FORCE_PET | PM_ALLOW_GROUP));
789                 }
790                 break;
791         }
792         case MS_S_CYBER:
793         {
794                 int k;
795                 int max_cyber = (dun_level / 50) + randint1(3);
796                 if (!target_set(TARGET_KILL)) return FALSE;
797                 msg_print(_("サイバーデーモンを召喚した!", "You summon Cyberdemons!"));
798                 if (max_cyber > 4) max_cyber = 4;
799                 for (k = 0;k < max_cyber; k++)
800                         summon_specific(-1, target_row, target_col, plev, SUMMON_CYBER, mode);
801                 break;
802         }
803         case MS_S_MONSTER:
804         {
805                 int k;
806                 if (!target_set(TARGET_KILL)) return FALSE;
807                 msg_print(_("仲間を召喚した。", "You summon help."));
808                 for (k = 0;k < 1; k++)
809                         summon_specific(-1, target_row, target_col, plev, 0, (mode | u_mode));
810                 break;
811         }
812         case MS_S_MONSTERS:
813         {
814                 int k;
815                 if (!target_set(TARGET_KILL)) return FALSE;
816                 msg_print(_("モンスターを召喚した!", "You summon monsters!"));
817                 for (k = 0;k < 6; k++)
818                         summon_specific(-1, target_row, target_col, plev, 0, (mode | u_mode));
819                 break;
820         }
821         case MS_S_ANT:
822         {
823                 int k;
824                 if (!target_set(TARGET_KILL)) return FALSE;
825                 msg_print(_("アリを召喚した。", "You summon ants."));
826                 for (k = 0;k < 6; k++)
827                         summon_specific(-1, target_row, target_col, plev, SUMMON_ANT, mode);
828                 break;
829         }
830         case MS_S_SPIDER:
831         {
832                 int k;
833                 if (!target_set(TARGET_KILL)) return FALSE;
834                 msg_print(_("蜘蛛を召喚した。", "You summon spiders."));
835                 for (k = 0;k < 6; k++)
836                         summon_specific(-1, target_row, target_col, plev, SUMMON_SPIDER, mode);
837                 break;
838         }
839         case MS_S_HOUND:
840         {
841                 int k;
842                 if (!target_set(TARGET_KILL)) return FALSE;
843                 msg_print(_("ハウンドを召喚した。", "You summon hounds."));
844                 for (k = 0;k < 4; k++)
845                         summon_specific(-1, target_row, target_col, plev, SUMMON_HOUND, mode);
846                 break;
847         }
848         case MS_S_HYDRA:
849         {
850                 int k;
851                 if (!target_set(TARGET_KILL)) return FALSE;
852                 msg_print(_("ヒドラを召喚した。", "You summon hydras."));
853                 for (k = 0;k < 4; k++)
854                         summon_specific(-1, target_row, target_col, plev, SUMMON_HYDRA, mode);
855                 break;
856         }
857         case MS_S_ANGEL:
858         {
859                 int k;
860                 if (!target_set(TARGET_KILL)) return FALSE;
861                 msg_print(_("天使を召喚した!", "You summon angel!"));
862                 for (k = 0;k < 1; k++)
863                         summon_specific(-1, target_row, target_col, plev, SUMMON_ANGEL, mode);
864                 break;
865         }
866         case MS_S_DEMON:
867         {
868                 int k;
869                 if (!target_set(TARGET_KILL)) return FALSE;
870                 msg_print(_("混沌の宮廷から悪魔を召喚した!", "You summon a demon from the Courts of Chaos!"));
871                 for (k = 0;k < 1; k++)
872                         summon_specific(-1, target_row, target_col, plev, SUMMON_DEMON, (mode | u_mode));
873                 break;
874         }
875         case MS_S_UNDEAD:
876         {
877                 int k;
878                 if (!target_set(TARGET_KILL)) return FALSE;
879                 msg_print(_("アンデッドの強敵を召喚した!", "You summon an undead adversary!"));
880                 for (k = 0;k < 1; k++)
881                         summon_specific(-1, target_row, target_col, plev, SUMMON_UNDEAD, (mode | u_mode));
882                 break;
883         }
884         case MS_S_DRAGON:
885         {
886                 int k;
887                 if (!target_set(TARGET_KILL)) return FALSE;
888                 msg_print(_("ドラゴンを召喚した!", "You summon dragon!"));
889                 for (k = 0;k < 1; k++)
890                         summon_specific(-1, target_row, target_col, plev, SUMMON_DRAGON, (mode | u_mode));
891                 break;
892         }
893         case MS_S_HI_UNDEAD:
894         {
895                 int k;
896                 if (!target_set(TARGET_KILL)) return FALSE;
897                 msg_print(_("強力なアンデッドを召喚した!", "You summon greater undead!"));
898                 for (k = 0;k < 6; k++)
899                         summon_specific(-1, target_row, target_col, plev, SUMMON_HI_UNDEAD, (mode | u_mode));
900                 break;
901         }
902         case MS_S_HI_DRAGON:
903         {
904                 int k;
905                 if (!target_set(TARGET_KILL)) return FALSE;
906                 msg_print(_("古代ドラゴンを召喚した!", "You summon ancient dragons!"));
907                 for (k = 0;k < 4; k++)
908                         summon_specific(-1, target_row, target_col, plev, SUMMON_HI_DRAGON, (mode | u_mode));
909                 break;
910         }
911         case MS_S_AMBERITE:
912         {
913                 int k;
914                 if (!target_set(TARGET_KILL)) return FALSE;
915                 msg_print(_("アンバーの王族を召喚した!", "You summon Lords of Amber!"));
916                 for (k = 0;k < 4; k++)
917                         summon_specific(-1, target_row, target_col, plev, SUMMON_AMBERITES, (mode | PM_ALLOW_UNIQUE));
918                 break;
919         }
920         case MS_S_UNIQUE:
921         {
922                 int k, count = 0;
923                 if (!target_set(TARGET_KILL)) return FALSE;
924                 msg_print(_("特別な強敵を召喚した!", "You summon special opponents!"));
925                 for (k = 0;k < 4; k++)
926                         if (summon_specific(-1, target_row, target_col, plev, SUMMON_UNIQUE, (mode | PM_ALLOW_UNIQUE))) count++;
927                 for (k = count;k < 4; k++)
928                         summon_specific(-1, target_row, target_col, plev, SUMMON_HI_UNDEAD, (mode | u_mode));
929                 break;
930         }
931         default:
932                 msg_print("hoge?");
933         }
934
935         return TRUE;
936 }
937
938
939 /*!
940  * @brief ものまねコマンドのメインルーチン /
941  * do_cmd_cast calls this function if the player's class is 'imitator'.
942  * @param baigaesi TRUEならば倍返し上の処理として行う
943  * @return 処理を実行したらTRUE、キャンセルした場合FALSEを返す。
944  * @details
945  * If a valid spell is chosen, saves it in '*sn' and returns TRUE
946  * If the user hits escape, returns FALSE, and set '*sn' to -1
947  * If there are no legal choices, returns FALSE, and sets '*sn' to -2
948  *
949  * The "prompt" should be "cast", "recite", or "study"
950  * The "known" should be TRUE for cast/pray, FALSE for study
951  *
952  * nb: This function has a (trivial) display bug which will be obvious
953  * when you run it. It's probably easy to fix but I haven't tried,
954  * sorry.
955  */
956 bool do_cmd_mane(bool baigaesi)
957 {
958         int             n = 0, j;
959         int             chance;
960         int             minfail = 0;
961         PLAYER_LEVEL plev = p_ptr->lev;
962         monster_power   spell;
963         bool            cast;
964
965
966         /* not if confused */
967         if (p_ptr->confused)
968         {
969                 msg_print(_("混乱していて集中できない!", "You are too confused!"));
970                 return TRUE;
971         }
972
973         if (!p_ptr->mane_num)
974         {
975                 msg_print(_("まねられるものが何もない!", "You don't remember any action!"));
976                 return FALSE;
977         }
978
979         /* get power */
980         if (!get_mane_power(&n, baigaesi)) return FALSE;
981
982         spell = monster_powers[p_ptr->mane_spell[n]];
983
984         /* Spell failure chance */
985         chance = spell.manefail;
986
987         /* Reduce failure rate by "effective" level adjustment */
988         if (plev > spell.level) chance -= 3 * (plev - spell.level);
989
990         /* Reduce failure rate by 1 stat and DEX adjustment */
991         chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[spell.use_stat]] + adj_mag_stat[p_ptr->stat_ind[A_DEX]] - 2) / 2;
992
993         if (spell.manedam) chance = chance * damage / spell.manedam;
994
995         chance += p_ptr->to_m_chance;
996
997         /* Extract the minimum failure rate */
998         minfail = adj_mag_fail[p_ptr->stat_ind[spell.use_stat]];
999
1000         /* Minimum failure rate */
1001         if (chance < minfail) chance = minfail;
1002
1003         /* Stunning makes spells harder */
1004         if (p_ptr->stun > 50) chance += 25;
1005         else if (p_ptr->stun) chance += 15;
1006
1007         /* Always a 5 percent chance of working */
1008         if (chance > 95) chance = 95;
1009
1010         /* Failed spell */
1011         if (randint0(100) < chance)
1012         {
1013                 if (flush_failure) flush();
1014                 msg_print(_("ものまねに失敗した!", "You failed to concentrate hard enough!"));
1015                 sound(SOUND_FAIL);
1016         }
1017         else
1018         {
1019                 sound(SOUND_ZAP);
1020
1021                 /* Cast the spell */
1022                 cast = use_mane(p_ptr->mane_spell[n]);
1023
1024                 if (!cast) return FALSE;
1025         }
1026
1027         p_ptr->mane_num--;
1028         for (j = n; j < p_ptr->mane_num;j++)
1029         {
1030                 p_ptr->mane_spell[j] = p_ptr->mane_spell[j+1];
1031                 p_ptr->mane_dam[j] = p_ptr->mane_dam[j+1];
1032         }
1033
1034         p_ptr->energy_use = 100;
1035
1036         p_ptr->redraw |= (PR_IMITATION);
1037         p_ptr->window |= (PW_PLAYER);
1038         p_ptr->window |= (PW_SPELL);
1039
1040         return TRUE;
1041 }