OSDN Git Service

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