OSDN Git Service

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