OSDN Git Service

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