OSDN Git Service

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