OSDN Git Service

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