OSDN Git Service

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