OSDN Git Service

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