OSDN Git Service

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