OSDN Git Service

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