OSDN Git Service

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