OSDN Git Service

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