OSDN Git Service

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