OSDN Git Service

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