OSDN Git Service

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