OSDN Git Service

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