OSDN Git Service

[Refactor] #40577 Moved player_has_los_bold() from floor.h to cave.c/h
[hengband/hengband.git] / src / mind / mind-switcher.c
1 /*!
2  * @file mind.c
3  * @brief 各職業の特殊技能実装 / Special magics
4  * @date 2014/01/15
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  * 2005 henkma \n
11  * 2014 Deskull rearranged comment for Doxygen.\n
12  * @details
13  * mind.cとあるが実際には超能力者、練気術師、狂戦士、鏡使い、忍者までの
14  * 特殊技能を揃えて実装している。
15  */
16
17 #include "mind/mind-switcher.h"
18 #include "action/action-limited.h"
19 #include "action/movement-execution.h"
20 #include "cmd-action/cmd-attack.h"
21 #include "cmd-action/cmd-spell.h"
22 #include "cmd-item/cmd-throw.h"
23 #include "core/asking-player.h"
24 #include "core/hp-mp-processor.h"
25 #include "core/player-redraw-types.h"
26 #include "core/player-update-types.h"
27 #include "core/stuff-handler.h"
28 #include "core/window-redrawer.h"
29 #include "effect/effect-characteristics.h"
30 #include "effect/spells-effect-util.h"
31 #include "floor/cave.h"
32 #include "floor/floor.h"
33 #include "game-option/disturbance-options.h"
34 #include "game-option/input-options.h"
35 #include "game-option/text-display-options.h"
36 #include "grid/feature.h"
37 #include "grid/grid.h"
38 #include "inventory/inventory-slot-types.h"
39 #include "io/command-repeater.h"
40 #include "io/input-key-acceptor.h"
41 #include "io/input-key-requester.h"
42 #include "io/targeting.h"
43 #include "main/sound-definitions-table.h"
44 #include "main/sound-of-music.h"
45 #include "mind/mind-force-trainer.h"
46 #include "mind/mind-magic-resistance.h"
47 #include "mind/mind-mindcrafter.h"
48 #include "mind/mind-mirror-master.h"
49 #include "mind/mind-ninja.h"
50 #include "mind/mind-warrior.h"
51 #include "monster-floor/monster-summon.h"
52 #include "monster/monster-status.h"
53 #include "monster-floor/place-monster-types.h"
54 #include "player-attack/player-attack.h"
55 #include "player/avatar.h"
56 #include "player/player-class.h"
57 #include "player/player-damage.h"
58 #include "player/player-move.h"
59 #include "player/special-defense-types.h"
60 #include "spell/process-effect.h"
61 #include "spell-kind/earthquake.h"
62 #include "spell-kind/spells-detection.h"
63 #include "spell-kind/spells-fetcher.h"
64 #include "spell-kind/spells-floor.h"
65 #include "spell-kind/spells-grid.h"
66 #include "spell-kind/spells-launcher.h"
67 #include "spell-kind/spells-lite.h"
68 #include "spell-kind/spells-perception.h"
69 #include "spell-kind/spells-sight.h"
70 #include "spell-kind/spells-world.h"
71 #include "spell/spells-status.h"
72 #include "spell/spells-summon.h"
73 #include "spell-kind/spells-teleport.h"
74 #include "spell-kind/spells-world.h"
75 #include "spell/spell-types.h"
76 #include "status/bad-status-setter.h"
77 #include "status/base-status.h"
78 #include "status/body-improvement.h"
79 #include "status/buff-setter.h"
80 #include "status/element-resistance.h"
81 #include "status/sight-setter.h"
82 #include "status/temporary-resistance.h"
83 #include "system/floor-type-definition.h"
84 #include "term/screen-processor.h"
85 #include "util/buffer-shaper.h"
86 #include "util/int-char-converter.h"
87 #include "view/display-messages.h"
88
89 /*! 特殊技能の一覧テーブル */
90 mind_power const mind_powers[5] =
91 {
92   {
93     {
94       /* Level gained,  cost,  %fail,  name */
95 #ifdef JP
96       { 1,   1,  15, "霊視"},
97       { 2,   1,  20, "神経攻撃"},
98       { 3,   2,  25, "次元の瞬き"},
99       { 7,   6,  35, "虚空の幻影"},
100       { 9,   7,  50, "精神支配"},
101       { 11,  7,  30, "念動衝撃弾"},
102       { 13, 12,  50, "鎧化"},
103       { 15, 12,  60, "サイコメトリー"},
104       { 18, 10,  45, "精神波動"},
105       { 23, 15,  50, "アドレナリン・ドーピング"},
106       { 26, 28,  60, "テレキネシス"},
107       { 28, 10,  40, "サイキック・ドレイン"},
108       { 35, 35,  75, "光の剣"},
109       { 45,150,  85, "完全な世界"},
110       { 99,  0,   0, ""},
111       { 99,  0,   0, ""},
112       { 99,  0,   0, ""},
113       { 99,  0,   0, ""},
114       { 99,  0,   0, ""},
115       { 99,  0,   0, ""},
116       { 99,  0,   0, ""},
117 #else
118       { 1,   1,  15, "Precognition"},
119       { 2,   1,  20, "Neural Blast"},
120       { 3,   2,  25, "Minor Displacement"},
121       { 7,   6,  35, "Major Displacement"},
122       { 9,   7,  50, "Domination"},
123       { 11,  7,  30, "Pulverise"},
124       { 13, 12,  50, "Character Armour"},
125       { 15, 12,  60, "Psychometry" },
126       { 18, 10,  45, "Mind Wave" },
127       { 23, 15,  50, "Adrenaline Channeling"},
128       { 26, 28,  60, "Telekinesis"},
129       { 28, 10,  40, "Psychic Drain"},
130       { 35, 35,  75, "Psycho-Spear"},
131       { 45,150,  85, "The World"},
132       { 99,  0,   0, ""},
133       { 99,  0,   0, ""},
134       { 99,  0,   0, ""},
135       { 99,  0,   0, ""},
136       { 99,  0,   0, ""},
137       { 99,  0,   0, ""},
138       { 99,  0,   0, ""},
139 #endif
140       
141     }
142   },
143   
144   {
145     {
146       /* Level gained,  cost,  %fail,  name */
147 #ifdef JP
148       { 1,   1,  15, "小龍"},
149       { 3,   3,  30, "閃光"},
150       { 5,   6,  35, "舞空術"},
151       { 8,   5,  40, "カメハメ波"},
152       { 10,  7,  45, "対魔法防御"},
153       { 13,  5,  60, "練気"},
154       { 17, 17,  50, "纏闘気"},
155       { 20, 20,  50, "衝波"},
156       { 23, 18,  55, "彗龍"},
157       { 25, 30,  70, "いてつく波動"},
158       { 28, 26,  50, "幻霊召喚"},
159       { 32, 35,  65, "煉獄火炎"},
160       { 38, 42,  75, "超カメハメ波"},
161       { 44, 50,  80, "光速移動"},
162       { 99,  0,   0, ""},
163       { 99,  0,   0, ""},
164       { 99,  0,   0, ""},
165       { 99,  0,   0, ""},
166       { 99,  0,   0, ""},
167       { 99,  0,   0, ""},
168       { 99,  0,   0, ""},
169 #else
170       { 1,   1,  15, "Small Force Ball"},
171       { 3,   3,  30, "Flash Light"},
172       { 5,   6,  35, "Flying Technique"},
173       { 8,   5,  40, "Kamehameha"},
174       { 10,  7,  45, "Magic Resistance"},
175       { 13,  5,  60, "Improve Force"},
176       { 17, 17,  50, "Aura of Force"},
177       { 20, 20,  50, "Shock Power"},
178       { 23, 18,  55, "Large Force Ball"},
179       { 25, 30,  70, "Dispel Magic"},
180       { 28, 26,  50, "Summon Ghost"},
181       { 32, 35,  65, "Exploding Frame"},
182       { 38, 42,  75, "Super Kamehameha"},
183       { 44, 50,  80, "Light Speed"},
184       { 99,  0,   0, ""},
185       { 99,  0,   0, ""},
186       { 99,  0,   0, ""},
187       { 99,  0,   0, ""},
188       { 99,  0,   0, ""},
189       { 99,  0,   0, ""},
190       { 99,  0,   0, ""},
191 #endif
192       
193     }
194   },
195   
196   {
197     {
198       /* Level gained,  cost,  %fail,  name */
199 #ifdef JP
200       {  8,  5,  40, "殺気感知"},
201       { 15, 20,   0, "突撃"},
202       { 20, 15,   0, "トラップ粉砕"},
203       { 25, 20,  60, "地震"},
204       { 30, 80,  75, "皆殺し"},
205       { 99,  0,   0, ""},
206       { 99,  0,   0, ""},
207       { 99,  0,   0, ""},
208       { 99,  0,   0, ""},
209       { 99,  0,   0, ""},
210       { 99,  0,   0, ""},
211       { 99,  0,   0, ""},
212       { 99,  0,   0, ""},
213       { 99,  0,   0, ""},
214       { 99,  0,   0, ""},
215       { 99,  0,   0, ""},
216       { 99,  0,   0, ""},
217       { 99,  0,   0, ""},
218       { 99,  0,   0, ""},
219       { 99,  0,   0, ""},
220       { 99,  0,   0, ""},
221 #else
222       {  8,  5,  40, "Detect Atmosphere of Menace"},
223       { 15, 20,   0, "Charge"},
224       { 20, 15,   0, "Smash a Trap"},
225       { 25, 20,  60, "Quake"},
226       { 30, 80,  75, "Massacre"},
227       { 99,  0,   0, ""},
228       { 99,  0,   0, ""},
229       { 99,  0,   0, ""},
230       { 99,  0,   0, ""},
231       { 99,  0,   0, ""},
232       { 99,  0,   0, ""},
233       { 99,  0,   0, ""},
234       { 99,  0,   0, ""},
235       { 99,  0,   0, ""},
236       { 99,  0,   0, ""},
237       { 99,  0,   0, ""},
238       { 99,  0,   0, ""},
239       { 99,  0,   0, ""},
240       { 99,  0,   0, ""},
241       { 99,  0,   0, ""},
242       { 99,  0,   0, ""},
243 #endif
244       
245     }
246   },
247
248   {
249     {
250       /* Level gained,  cost,  %fail,  name */
251 #ifdef JP
252       { 1,   1,  15, "真見の鏡"},
253       { 1,   2,  40, "鏡生成"},
254       { 2,   2,  20, "光のしずく"},
255       { 3,   2,  20, "歪んだ鏡"},
256       { 5,   3,  35, "閃光鏡"},
257       { 6,   5,  35, "彷える鏡"},
258
259       { 10,  5,  30, "微塵隠れ"},
260       { 12, 12,  30, "追放の鏡"},
261       { 15, 15,  30, "鏡砕き"},
262       { 19, 13,  30, "催眠鏡"},
263       { 23, 18,  50, "シーカーレイ"},
264
265       { 25, 20,  40, "鏡の封印"},
266       { 27, 30,  60, "水鏡の盾"},
267       { 29, 30,  60, "スーパーレイ"},
268       { 31, 35,  60, "幻惑の光"},
269       { 33, 50,  80, "鏡の国"},
270
271       { 36, 30,  80, "鏡抜け"},
272       { 38, 40,  70, "帰還の鏡"},
273       { 40, 50,  55, "影分身"},
274       { 43, 55,  70, "封魔結界"},
275       { 46, 70,  75, "ラフノールの鏡"},
276 #else
277       { 1,   1,  15, "Mirror of Seeing"},
278       { 1,   2,  40, "Making a Mirror"},
279       { 2,   2,  20, "Drip of Light"},
280       { 3,   2,  20, "Warped Mirror"},
281       { 5,   3,  35, "Mirror of Light"},
282       { 6,   5,  35, "Mirror of Wandering"},
283
284       { 10,  5,  30, "Robe of Dust"},
285       { 12, 12,  30, "Banishing Mirror"},
286       { 15, 15,  30, "Mirror Clashing"},
287       { 19, 13,  30, "Mirror Sleeping"},
288       { 23, 18,  50, "Seeker Ray"},
289
290       { 25, 20,  40, "Seal of Mirror"},
291       { 27, 30,  60, "Shield of Water"},
292       { 29, 30,  60, "Super Ray"},
293       { 31, 35,  60, "Illusion Light"},
294       { 33, 50,  80, "Mirror Shift"},
295
296       { 36, 30,  80, "Mirror Tunnel"},
297       { 38, 40,  70, "Mirror of Recall"},
298       { 40, 50,  55, "Multi-Shadow"},
299       { 43, 55,  70, "Binding Field"},
300       { 46, 70,  75, "Mirror of Ruffnor"},
301 #endif
302       
303     }
304   },
305   
306   {
307     {
308       /* Level gained,  cost,  %fail,  name */
309 #ifdef JP
310       {  1,  1,  20, "暗闇生成"},
311       {  2,  2,  25, "周辺調査"},
312       {  3,  3,  25, "葉隠れ"},
313       {  5,  3,  30, "変わり身"},
314       {  7,  8,  35, "高飛び"},
315       {  8, 10,  35, "一撃離脱"},
316       { 10, 10,  40, "金縛り"},
317       { 12, 12,  70, "古の口伝"},
318       { 15, 10,  50, "浮雲"},
319       { 17, 12,  45, "火遁"},
320       { 18, 20,  40, "入身"},
321       { 20,  5,  50, "八方手裏剣"},
322       { 22, 15,  55, "鎖鎌"},
323       { 25, 32,  60, "煙玉"},
324       { 28, 32,  60, "転身"},
325       { 30, 30,  70, "爆発の紋章"},
326       { 32, 40,  40, "土遁"},
327       { 34, 35,  50, "霧隠れ"},
328       { 38, 40,  60, "煉獄火炎"},
329       { 41, 50,  55, "分身"},
330       { 99,  0,   0, ""},
331 #else
332       {  1,  1,  20, "Create Darkness"},
333       {  2,  2,  25, "Detect Near"},
334       {  3,  3,  25, "Hide in Leafs"},
335       {  5,  3,  30, "Kawarimi"},
336       {  7,  8,  35, "Absconding"},
337       {  8, 10,  35, "Hit and Away"},
338       { 10, 10,  40, "Bind Monster"},
339       { 12, 12,  70, "Ancient Knowledge"},
340       { 15, 10,  50, "Floating"},
341       { 17, 12,  45, "Hide in Flame"},
342       { 18, 20,  40, "Nyusin"},
343       { 20,  5,  50, "Syuriken Spreading"},
344       { 22, 15,  55, "Chain Hook"},
345       { 25, 32,  60, "Smoke Ball"},
346       { 28, 32,  60, "Swap Position"},
347       { 30, 30,  70, "Glyph of Explosion"},
348       { 32, 40,  40, "Hide in Mud"},
349       { 34, 35,  50, "Hide in Mist"},
350       { 38, 40,  60, "Rengoku-Kaen"},
351       { 41, 50,  55, "Bunshin"},
352       { 99,  0,   0, ""},
353 #endif
354       
355     }
356   },
357 };
358
359 /*! 特殊能力の解説文字列 */
360 static concptr const mind_tips[5][MAX_MIND_POWERS] =
361 {
362 #ifdef JP
363 {
364         "近くの全ての見えるモンスターを感知する。レベル5で罠/扉、15で透明なモンスター、30で財宝とアイテムを感知できるようになる。レベル20で周辺の地形を感知し、45でその階全体を永久に照らし、ダンジョン内のすべてのアイテムを感知する。レベル25で一定時間テレパシーを得る。",
365         "精神攻撃のビームまたは球を放つ。",
366         "近距離のテレポートをする。",
367         "遠距離のテレポートをする。",
368         "レベル30未満で、モンスターを朦朧か混乱か恐怖させる球を放つ。レベル30以上で視界内の全てのモンスターを魅了する。抵抗されると無効。",
369         "テレキネシスの球を放つ。",
370         "一定時間、ACを上昇させる。レベルが上がると、酸、炎、冷気、電撃、毒の耐性も得られる。",
371         "レベル25未満で、アイテムの雰囲気を知る。レベル25以上で、アイテムを鑑定する。",
372         "レベル25未満で、自分を中心とした精神攻撃の球を発生させる。レベル25以上で、視界内の全てのモンスターに対して精神攻撃を行う。",
373         "恐怖と朦朧から回復し、ヒーロー気分かつ加速状態でなければHPが少し回復する。さらに、一定時間ヒーロー気分になり、加速する。",
374         "アイテムを自分の足元へ移動させる。",
375         "精神攻撃の球を放つ。モンスターに命中すると、0~1.5ターン消費する。抵抗されなければ、MPが回復する。",
376         "無傷球をも切り裂く純粋なエネルギーのビームを放つ。",
377         "時を止める。全MPを消費し、消費したMPに応じて長く時を止めていられる。",
378         "",
379         "",
380         "",
381         "",
382         "",
383         "",
384         "",
385 },
386 {
387         "ごく小さい気の球を放つ。",
388         "光源が照らしている範囲か部屋全体を永久に明るくする。",
389         "一定時間、空中に浮けるようになる。",
390         "射程の短い気のビームを放つ。",
391         "一定時間、魔法防御能力を上昇させる。",
392         "気を練る。気を練ると術の威力は上がり、持続時間は長くなる。練った気は時間とともに拡散する。練りすぎると暴走する危険がある。",
393         "一定時間、攻撃してきた全てのモンスターを傷つけるオーラを纏う。",
394         "隣りのモンスターに対して気をぶつけ、吹きとばす。",
395         "大きな気の球を放つ。",
396         "モンスター1体にかかった魔法を解除する。",
397         "1体の幽霊を召喚する。",
398         "自分を中心とした超巨大な炎の球を発生させる。",
399         "射程の長い、強力な気のビームを放つ。",
400         "しばらくの間、非常に速く動くことができる。",
401         "",
402         "",
403         "",
404         "",
405         "",
406         "",
407         "",
408 },
409 {
410         "近くの思考することができるモンスターを感知する。",
411         "攻撃した後、反対側に抜ける。",
412         "トラップにかかるが、そのトラップを破壊する。",
413         "周囲のダンジョンを揺らし、壁と床をランダムに入れ変える。",
414         "全方向に向かって攻撃する。",
415         "",
416         "",
417         "",
418         "",
419         "",
420         "",
421         "",
422         "",
423         "",
424         "",
425         "",
426         "",
427         "",
428         "",
429         "",
430         "",
431 },
432 {
433         "近くの全てのモンスターを感知する。レベル15で透明なモンスターを感知する。レベル25で一定時間テレパシーを得る。レベル35で周辺の地形を感知する。全ての効果は、鏡の上でないとレベル4だけ余計に必要になる。",
434         "自分のいる床の上に鏡を生成する。",
435         "閃光の矢を放つ。レベル10以上では鏡の上で使うとビームになる。",
436         "近距離のテレポートをする。",
437         "自分の周囲や、 自分のいる部屋全体を明るくする。",
438         "遠距離のテレポートをする。",
439         "一定時間、鏡のオーラが付く。攻撃を受けると破片のダメージで反撃し、さらに鏡の上にいた場合近距離のテレポートをする。",
440         "モンスターをテレポートさせるビームを放つ。抵抗されると無効。",
441         "破片の球を放つ。",
442         "全ての鏡の周りに眠りの球を発生させる。",
443         "ターゲットに向かって魔力のビームを放つ。鏡に命中すると、その鏡を破壊し、別の鏡に向かって反射する。",
444         "鏡の上のモンスターを消し去る。",
445         "一定時間、ACを上昇させる。レベル32で反射が付く。レベル40で魔法防御が上がる。",
446         "ターゲットに向かって強力な魔力のビームを放つ。鏡に命中すると、その鏡を破壊し、8方向に魔力のビームを発生させる。",
447         "視界内のモンスターを減速させ、朦朧とさせ、混乱させ、恐怖させ、麻痺させる。鏡の上で使うと威力が高い。",
448         "フロアを作り変える。鏡の上でしか使えない。",
449         "短距離内の指定した場所にテレポートする。",
450         "地上にいるときはダンジョンの最深階へ、ダンジョンにいるときは地上へと移動する。",
451         "全ての攻撃が、1/2の確率で無効になる。",
452         "視界内の2つの鏡とプレイヤーを頂点とする三角形の領域に、魔力の結界を発生させる。",
453         "一定時間、ダメージを受けなくなるバリアを張る。切れた瞬間に少しターンを消費するので注意。",
454 },
455 {
456         "半径3以内かその部屋を暗くする。",
457         "近くの全ての見えるモンスターを感知する。レベル5で罠/扉/階段、レベル15でアイテムを感知できるようになる。レベル45でその階全体の地形と全てのアイテムを感知する。",
458         "近距離のテレポートをする。",
459         "攻撃を受けた瞬間にテレポートをするようになる。失敗するとその攻撃のダメージを受ける。テレポートに失敗することもある。",
460         "遠距離のテレポートをする。",
461         "攻撃してすぐにテレポートする。",
462         "敵1体の動きを封じる。ユニークモンスター相手の場合又は抵抗された場合には無効。",
463         "アイテムを識別する。",
464         "一定時間、浮遊能力を得る。",
465         "自分を中心とした火の球を発生させ、テレポートする。さらに、一定時間炎に対する耐性を得る。装備による耐性に累積する。",
466         "素早く相手に近寄り攻撃する。",
467         "ランダムな方向に8回くさびを投げる。",
468         "敵を1体自分の近くに引き寄せる。",
469         "ダメージのない混乱の球を放つ。",
470         "1体のモンスターと位置を交換する。",
471         "自分のいる床の上に、モンスターが通ると爆発してダメージを与えるルーンを描く。",
472         "一定時間、半物質化し壁を通り抜けられるようになる。さらに、一定時間酸への耐性を得る。装備による耐性に累積する。",
473         "自分を中心とした超巨大な毒、衰弱、混乱の球を発生させ、テレポートする。",
474         "ランダムな方向に何回か炎か地獄かプラズマのビームを放つ。",
475         "全ての攻撃が、1/2の確率で無効になる。",
476         "",
477 },
478 #else
479 {
480         "Detects visible monsters in your vicinity. Detects traps and doors at level 5, invisible monsters at level 15, and items at level 30. Gives telepathy at level 25. Magically maps the surroundings at level 20. Lights and reveals the whole level at level 45.",
481         "Fires a beam or ball which inflicts PSI damage.",
482         "Teleports you a short distance.",
483         "Teleports you a long distance.",
484         "Stuns, confuses or scares a monster. Or attempts to charm all monsters in sight at level 30.",
485         "Fires a ball which hurts monsters with telekinesis.",
486         "Gives stone skin and some resistance to elements for a while. As your level increases, more resistances are given.",
487         "Gives feeling of an item. Or identifies an item at level 25.",
488         "Generates a ball centered on you which inflicts PSI damage on a monster or, at level 25 and higher, inflicts PSI damage on all monsters.",
489         "Removes fear and being stunned. Gives heroism and speed. Heals HP a little unless you already have heroism and a temporary speed boost.",
490         "Pulls a distant item close to you.",
491         "Fires a ball which damages. When not resisted, you gain SP. You will be occupied for 0 to 1.5 turns after casting as your mind recovers.",
492         "Fires a beam of pure energy which penetrates invulnerability barriers.",
493         "Stops time. Consumes all of your SP. The more SP consumed, the longer the duration of the spell.",
494         "",
495         "",
496         "",
497         "",
498         "",
499         "",
500         "",
501 },
502 {
503         "Fires a very small energy ball.",
504         "Lights up nearby area and the inside of a room permanently.",
505         "Gives levitation a while.",
506         "Fires a short energy beam.",
507         "Gives magic resistance for a while.",
508         "Increases your spirit energy temporarily. More spirit energy will boost the effect or duration of your force abilities. Too much spirit energy can result in an explosion.",
509         "Envelops you with a temporary aura that damages any monster which hits you in melee.",
510         "Damages an adjacent monster and blows it away.",
511         "Fires a large energy ball.",
512         "Dispels all magics which are affecting a monster.",
513         "Summons ghosts.",
514         "Generates a huge ball of flame centered on you.",
515         "Fires a long, powerful energy beam.",
516         "Gives extremely fast speed.",
517         "",
518         "",
519         "",
520         "",
521         "",
522         "",
523         "",
524 },
525 {
526         "Detects all monsters except the mindless in your vicinity.",
527         "In one action, attacks a monster with your weapons normally and then moves to the space beyond the monster if that space is not blocked.",
528         "Sets off a trap, then destroys that trap.",
529         "Shakes dungeon structure, and results in random swapping of floors and walls.",
530         "Attacks all adjacent monsters.",
531         "",
532         "",
533         "",
534         "",
535         "",
536         "",
537         "",
538         "",
539         "",
540         "",
541         "",
542         "",
543         "",
544         "",
545         "",
546         "",
547 },
548 {
549         "Detects visible monsters in your vicinity. Detects invisible monsters at level 15. Gives telepathy at level 25. Magically maps the surroundings at level 35. All of the effects need 4 more levels unless on a mirror.",
550         "Makes a mirror under you.",
551         "Fires bolt of light. At level ten or higher, the bolt will be a beam of light if you are on a mirror.",
552         "Teleports you a short distance.",
553         "Lights up nearby area and the inside of a room permanently.",
554         "Teleports you a long distance.",
555         "Gives a temporary aura of mirror shards. The aura damages any monster that hits you in melee. If you are on a mirror, the aura will teleport you a short distance if a monster hits you in melee.",
556         "Teleports all monsters on the line away unless resisted.",
557         "Fires a ball of shards.",
558         "Causes any mirror to lull to sleep monsters close to the mirror.",
559         "Fires a beam of mana. If the beam hits a mirror, it breaks that mirror and bounces toward another mirror.",
560         "Eliminates a monster on a mirror from current dungeon level.",
561         "Gives a bonus to AC. Gives reflection at level 32. Gives magic resistance at level 40.",
562         "Fires a powerful beam of mana. If the beam hits a mirror, it breaks that mirror and fires 8 beams of mana to 8 different directions from that point.",
563         "Attempts to slow, stun, confuse, scare, freeze all monsters in sight. Gets more power on a mirror.",
564         "Recreates current dungeon level. Can only be used on a mirror.",
565         "Teleports you to a given location.",
566         "Recalls player from dungeon to town or from town to the deepest level of dungeon.",
567         "Completely protects you from any attacks at one in two chance.",
568         "Generates a magical triangle which damages all monsters in the area. The vertices of the triangle are you and two mirrors in sight.",
569         "Generates a barrier which completely protects you from almost all damage. Takes a few of your turns when the barrier breaks or duration time is exceeded.",
570 },
571
572 {
573         "Darkens nearby area and inside of a room.",
574         "Detects visible monsters in your vicinity. Detects traps, doors and stairs at level 5. Detects items at level 15. Lights and reveals the whole level at level 45.",
575         "Teleports you a short distance.",
576         "Teleports you as you receive an attack. Might be able to teleport just before receiving damage at higher levels.",
577         "Teleports you a long distance.",
578         "Attacks an adjacent monster and teleports you away immediately after the attack.",
579         "Attempts to freeze a monster.",
580         "Identifies an item.",
581         "Gives levitation for a while.",
582         "Generates a fire ball and immediately teleports you away. Gives resistance to fire for a while. This resistance can be added to that from equipment for more powerful resistance.",
583         "Steps close to a monster and attacks at a time.",
584         "Shoots 8 iron Spikes in 8 random directions.",
585         "Teleports a monster to a place adjacent to you.",
586         "Releases a confusion ball which doesn't inflict any damage.",
587         "Causes you and a targeted monster to exchange positions.",
588         "Sets a glyph under you. The glyph will explode when a monster moves on it.",
589         "Makes you ethereal for a period of time. While ethereal, you can pass through walls and are resistant to acid. The resistance can be added to that from equipment for more powerful resistance.",
590         "Generates huge balls of poison, drain life and confusion. Then immediately teleports you away.",
591         "Fires some number of beams of fire, nether or plasma in random directions.",
592         "Creates shadows of yourself which gives you the ability to completely evade any attacks at one in two chance for a while.",
593         "",
594 },
595 #endif
596 };
597
598 /*!
599  * @brief 特殊技能の効果情報をまとめたフォーマットを返す
600  * @param p 情報を返す文字列参照ポインタ
601  * @param use_mind 職業毎の特殊技能ID
602  * @param power モンスター魔法のID
603  * @return なし
604  */
605 void mindcraft_info(player_type *caster_ptr, char *p, int use_mind, int power)
606 {
607         PLAYER_LEVEL plev = caster_ptr->lev;
608
609         strcpy(p, "");
610
611         switch (use_mind)
612         {
613         case MIND_MINDCRAFTER:
614                 switch (power)
615                 {
616                 case 0:  break;
617                 case 1:  sprintf(p, " %s%dd%d", KWD_DAM, 3 + ((plev - 1) / 4), 3 + plev/15); break;
618                 case 2:  sprintf(p, " %s10", KWD_SPHERE); break;
619                 case 3:  sprintf(p, " %s%d", KWD_SPHERE, plev * 5);  break;
620                 case 4:  break;
621                 case 5: sprintf(p, " %s%dd8", KWD_DAM, 8 + ((plev - 5) / 4));  break;
622                 case 6:  sprintf(p, " %s%d", KWD_DURATION, plev);  break;
623                 case 7:  break;
624                 case 8:  sprintf(p, (plev < 25 ? " %s%d" : " %sd%d"), KWD_DAM, (plev < 25 ? plev * 3 / 2 : plev * ((plev - 5) / 10 + 1))); break;
625                 case 9:  sprintf(p, " %s10+d%d", KWD_DURATION, plev * 3 / 2);  break;
626 #ifdef JP
627                 case 10: sprintf(p, " 最大重量:%d.%dkg", lbtokg1(plev * 15),lbtokg2(plev * 15));  break;
628 #else
629                 case 10: sprintf(p, " max wgt %d", plev * 15);  break;
630 #endif
631                 case 11: sprintf(p, " %s%dd6", KWD_DAM, plev / 2);  break;
632                 case 12: sprintf(p, " %sd%d+%d", KWD_DAM, plev * 3, plev * 3); break;
633                 case 13: sprintf(p, _(" 行動:%ld回", " %ld acts."), (long int)(caster_ptr->csp + 100-caster_ptr->energy_need - 50)/100); break;
634                 }
635                 break;
636         case MIND_KI:
637         {
638                 int boost = get_current_ki(caster_ptr);
639
640                 if (heavy_armor(caster_ptr)) boost /= 2;
641
642                 switch (power)
643                 {
644                 case 0:  sprintf(p, " %s%dd4", KWD_DAM, 3 + ((plev - 1) / 5) + boost / 12); break;
645                 case 1:  break;
646                 case 2:  sprintf(p, " %s%d+d30", KWD_DURATION, 30 + boost / 5); break;
647                 case 3:  sprintf(p, " %s%dd5", KWD_DAM, 5 + ((plev - 1) / 5) + boost / 10); break;
648                 case 4:  sprintf(p, " %s%d+d20", KWD_DURATION, 20 + boost / 5); break;
649                 case 5:  break;
650                 case 6:  sprintf(p, " %s%d+d%d", KWD_DURATION, 15 + boost / 7, plev / 2); break;
651                 case 7:  sprintf(p, " %s%dd8", KWD_DAM, 8 + ((plev - 5) / 4) + boost / 12); break;
652                 case 8:  sprintf(p, " %s10d6+%d", KWD_DAM, plev * 3 / 2 + boost * 3 / 5); break;
653                 case 9:  break;
654                 case 10: sprintf(p, _(" 最大%d体", " max %d"), 1+boost/100); break;
655                 case 11: sprintf(p, " %s%d", KWD_DAM, 100 + plev + boost); break;
656                 case 12: sprintf(p, " %s%dd15", KWD_DAM, 10 + plev / 2 + boost * 3 / 10); break;
657                 case 13: sprintf(p, _(" 行動:%d+d16回", " %d+d16 acts"), 16+boost/20); break;
658                 }
659                 break;
660         }
661         case MIND_MIRROR_MASTER:
662         {
663                 switch (power)
664                 {
665                 case 0:  break;
666                 case 1:  break;
667                 case 2:  sprintf(p, " %s%dd4", KWD_DAM,  3 + ((plev - 1) / 5) ); break;
668                 case 3:  sprintf(p, " %s10", KWD_SPHERE); break;
669                 case 4:  break;
670                 case 5:  sprintf(p, " %s%d", KWD_SPHERE, plev *5); break;
671                 case 6:  sprintf(p, " %s20+d20", KWD_DURATION);  break;
672                 case 7:  break;
673                 case 8:  sprintf(p, " %s%dd8", KWD_DAM, 8+((plev -5)/4) ); break;
674                 case 9:  break;
675                 case 10: sprintf(p, " %s%dd8", KWD_DAM, 11+(plev-5)/4 ); break;
676                 case 11: break;
677                 case 12: sprintf(p, " %s20+d20", KWD_DURATION);  break;
678                 case 13: sprintf(p, " %s150+d%d", KWD_DAM, plev*2 ); break;
679                 case 14: break;
680                 case 15: break;
681                 case 16: sprintf(p, " %s%d", KWD_SPHERE, plev/2 +10); break;
682                 case 17: break;
683                 case 18: sprintf(p, " %s6+d6", KWD_DURATION);  break;
684                 case 19: sprintf(p, " %s%d", KWD_DAM, plev*11+5 ); break;
685                 case 20: sprintf(p, " %s4+d4", KWD_DURATION);  break;
686                 }
687                 break;
688         }
689         case MIND_NINJUTSU:
690         {
691                 switch (power)
692                 {
693                 case 0:  break;
694                 case 1:  break;
695                 case 2:  sprintf(p, " %s10", KWD_SPHERE); break;
696                 case 3:  break;
697                 case 4:  sprintf(p, " %s%d", KWD_SPHERE , plev *5); break;
698                 case 5:  sprintf(p, " %s30", KWD_SPHERE); break;
699                 case 6:  break;
700                 case 7:  break;
701                 case 8:  sprintf(p, " %s20+d20", KWD_DURATION);  break;
702                 case 9:  sprintf(p, " %s%d", KWD_DAM, (50+plev)/2 ); break;
703                 case 10: break;
704                 case 11: break;
705                 case 12: break;
706                 case 13: break;
707                 case 14: break;
708                 case 15: break;
709                 case 16: sprintf(p, " %s%d+d%d", KWD_DURATION, plev/2, plev/2);  break;
710                 case 17: sprintf(p, " %s%d*3", KWD_DAM, (75+plev*2/3)/2 ); break;
711                 case 18: sprintf(p, " %s%dd10", KWD_DAM, 6+plev/8 ); break;
712                 case 19: sprintf(p, " %s6+d6", KWD_DURATION);  break;
713                 }
714                 break;
715         }
716         }
717 }
718
719 /*!
720  * @brief 使用可能な特殊技能を選択する /
721  * Allow user to choose a mindcrafter power.
722  * @param sn 選択した特殊技能ID、キャンセルの場合-1、不正な選択の場合-2を返す
723  * @param only_browse 一覧を見るだけの場合TRUEを返す
724  * @return 発動可能な魔法を選択した場合TRUE、キャンセル処理か不正な選択が行われた場合FALSEを返す。
725  * @details
726  * If a valid spell is chosen, saves it in '*sn' and returns TRUE\n
727  * If the user hits escape, returns FALSE, and set '*sn' to -1\n
728  * If there are no legal choices, returns FALSE, and sets '*sn' to -2\n
729  *\n
730  * The "prompt" should be "cast", "recite", or "study"\n
731  * The "known" should be TRUE for cast/pray, FALSE for study\n
732  *\n
733  * nb: This function has a (trivial) display bug which will be obvious\n
734  * when you run it. It's probably easy to fix but I haven't tried,\n
735  * sorry.\n
736  */
737 static bool get_mind_power(player_type *caster_ptr, SPELL_IDX *sn, bool only_browse)
738 {
739         SPELL_IDX i;
740         int             num = 0;
741         TERM_LEN y = 1;
742         TERM_LEN x = 10;
743         PERCENTAGE minfail = 0;
744         PLAYER_LEVEL plev = caster_ptr->lev;
745         PERCENTAGE chance = 0;
746         int             ask = TRUE;
747         char            choice;
748         char            out_val[160];
749         char            comment[80];
750         concptr            p;
751         COMMAND_CODE code;
752         mind_type       spell;
753         const mind_power      *mind_ptr;
754         bool            flag, redraw;
755         int             use_mind;
756         int menu_line = (use_menu ? 1 : 0);
757
758         switch (caster_ptr->pclass)
759         {
760         case CLASS_MINDCRAFTER:
761         {
762                 use_mind = MIND_MINDCRAFTER;
763                 p = _("超能力", "mindcraft");
764                 break;
765         }
766         case CLASS_FORCETRAINER:
767         {
768                 use_mind = MIND_KI;
769                 p = _("練気術", "Force");
770                 break;
771         }
772         case CLASS_BERSERKER:
773         {
774                 use_mind = MIND_BERSERKER;
775                 p = _("技", "brutal power");
776                 break;
777         }
778         case CLASS_MIRROR_MASTER:
779         {
780                 use_mind = MIND_MIRROR_MASTER;
781                 p = _("鏡魔法", "magic");
782                 break;
783         }
784         case CLASS_NINJA:
785         {
786                 use_mind = MIND_NINJUTSU;
787                 p = _("忍術", "ninjutsu");
788                 break;
789         }
790         default:
791         {
792                 use_mind = 0;
793                 p = _("超能力", "mindcraft");
794                 break;
795         }
796         }
797         mind_ptr = &mind_powers[use_mind];
798
799         /* Assume cancelled */
800         *sn = (-1);
801
802         /* Get the spell, if available */
803
804         if (repeat_pull(&code))
805         {
806                 *sn = (SPELL_IDX)code;
807                 /* Hack -- If requested INVEN_FORCE(1111), pull again */
808                 if (*sn == INVEN_FORCE) repeat_pull(&code);
809                 *sn = (SPELL_IDX)code;
810
811                 /* Verify the spell */
812                 if (mind_ptr->info[*sn].min_lev <= plev)
813                 {
814                         /* Success */
815                         return TRUE;
816                 }
817         }
818
819         flag = FALSE;
820         redraw = FALSE;
821
822         for (i = 0; i < MAX_MIND_POWERS; i++)
823         {
824                 if (mind_ptr->info[i].min_lev <= plev)
825                 {
826                         num++;
827                 }
828         }
829
830         /* Build a prompt (accept all spells) */
831         if (only_browse)
832         {
833                 (void)strnfmt(out_val, 78,
834                         _("(%^s %c-%c, '*'で一覧, ESC) どの%sについて知りますか?", "(%^ss %c-%c, *=List, ESC=exit) Use which %s? "),
835                         p, I2A(0), I2A(num - 1), p);
836         }
837         else
838         {
839                 (void)strnfmt(out_val, 78,
840                         _("(%^s %c-%c, '*'で一覧, ESC) どの%sを使いますか?", "(%^ss %c-%c, *=List, ESC=exit) Use which %s? "),
841                         p, I2A(0), I2A(num - 1), p);
842         }
843
844         if (use_menu && !only_browse) screen_save();
845
846         choice = (always_show_list || use_menu) ? ESCAPE : 1;
847
848         while (!flag)
849         {
850                 if(choice==ESCAPE) choice = ' '; 
851                 else if( !get_com(out_val, &choice, TRUE) )break;
852
853                 if (use_menu && choice != ' ')
854                 {
855                         switch(choice)
856                         {
857                                 case '0':
858                                 {
859                                         if (!only_browse) screen_load();
860                                         return FALSE;
861                                 }
862
863                                 case '8':
864                                 case 'k':
865                                 case 'K':
866                                 {
867                                         menu_line += (num - 1);
868                                         break;
869                                 }
870
871                                 case '2':
872                                 case 'j':
873                                 case 'J':
874                                 {
875                                         menu_line++;
876                                         break;
877                                 }
878
879                                 case 'x':
880                                 case 'X':
881                                 case '\r':
882                                 case '\n':
883                                 {
884                                         i = menu_line - 1;
885                                         ask = FALSE;
886                                         break;
887                                 }
888                         }
889                         if (menu_line > num) menu_line -= num;
890                 }
891                 /* Request redraw */
892                 if ((choice == ' ') || (choice == '*') || (choice == '?') || (use_menu && ask))
893                 {
894                         /* Show the list */
895                         if (!redraw || use_menu)
896                         {
897                                 char psi_desc[80];
898                                 bool has_weapon[2];
899                                 redraw = TRUE;
900                                 if (!only_browse && !use_menu) screen_save();
901
902                                 /* Display a list of spells */
903                                 prt("", y, x);
904                                 put_str(_("名前", "Name"), y, x + 5);
905
906                                 put_str(format(_("Lv   %s   失率 効果", "Lv   %s   Fail Info"),
907                                         ((use_mind == MIND_BERSERKER) || (use_mind == MIND_NINJUTSU)) ? "HP" : "MP"), y, x + 35);
908
909                                 has_weapon[0] = has_melee_weapon(caster_ptr, INVEN_RARM);
910                                 has_weapon[1] = has_melee_weapon(caster_ptr, INVEN_LARM);
911
912                                 /* Dump the spells */
913                                 for (i = 0; i < MAX_MIND_POWERS; i++)
914                                 {
915                                         int mana_cost;
916
917                                         /* Access the spell */
918                                         spell = mind_ptr->info[i];
919
920                                         if (spell.min_lev > plev)   break;
921
922                                         chance = spell.fail;
923
924                                         mana_cost = spell.mana_cost;
925                                         if (chance)
926                                         {
927
928                                                 /* Reduce failure rate by "effective" level adjustment */
929                                                 chance -= 3 * (plev - spell.min_lev);
930
931                                                 /* Reduce failure rate by INT/WIS adjustment */
932                                                 chance -= 3 * (adj_mag_stat[caster_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
933
934                                                 if (use_mind == MIND_KI)
935                                                 {
936                                                         if (heavy_armor(caster_ptr)) chance += 20;
937                                                         if (caster_ptr->icky_wield[0]) chance += 20;
938                                                         else if (has_weapon[0]) chance += 10;
939                                                         if (caster_ptr->icky_wield[1]) chance += 20;
940                                                         else if (has_weapon[1]) chance += 10;
941                                                         if (i == 5)
942                                                         {
943                                                                 int j;
944                                                                 for (j = 0; j < get_current_ki(caster_ptr) / 50; j++)
945                                                                         mana_cost += (j+1) * 3 / 2;
946                                                         }
947                                                 }
948
949                                                 /* Not enough mana to cast */
950                                                 if ((use_mind != MIND_BERSERKER) && (use_mind != MIND_NINJUTSU) && (mana_cost > caster_ptr->csp))
951                                                 {
952                                                         chance += 5 * (mana_cost - caster_ptr->csp);
953                                                 }
954
955                                                 chance += caster_ptr->to_m_chance;
956
957                                                 /* Extract the minimum failure rate */
958                                                 minfail = adj_mag_fail[caster_ptr->stat_ind[mp_ptr->spell_stat]];
959
960                                                 /* Minimum failure rate */
961                                                 if (chance < minfail) chance = minfail;
962
963                                                 /* Stunning makes spells harder */
964                                                 if (caster_ptr->stun > 50) chance += 25;
965                                                 else if (caster_ptr->stun) chance += 15;
966
967                                                 if (use_mind == MIND_KI)
968                                                 {
969                                                         if (heavy_armor(caster_ptr)) chance += 5;
970                                                         if (caster_ptr->icky_wield[0]) chance += 5;
971                                                         if (caster_ptr->icky_wield[1]) chance += 5;
972                                                 }
973                                                 /* Always a 5 percent chance of working */
974                                                 if (chance > 95) chance = 95;
975                                         }
976
977                                         /* Get info */
978                                         mindcraft_info(caster_ptr, comment, use_mind, i);
979
980                                         if (use_menu)
981                                         {
982                                                 if (i == (menu_line-1)) strcpy(psi_desc, _("  》 ", "  >  "));
983                                                 else strcpy(psi_desc, "     ");
984                                         }
985                                         else
986                                                 sprintf(psi_desc, "  %c) ", I2A(i));
987                                         /* Dump the spell --(-- */
988                                         strcat(psi_desc,
989                                                format("%-30s%2d %4d%s %3d%%%s",
990                                                       spell.name, spell.min_lev, mana_cost,
991                                                       (((use_mind == MIND_MINDCRAFTER) && (i == 13)) ? _("~", "~ ") : "  "),
992                                                       chance, comment));
993                                         prt(psi_desc, y + i + 1, x);
994                                 }
995
996                                 /* Clear the bottom line */
997                                 prt("", y + i + 1, x);
998                         }
999
1000                         /* Hide the list */
1001                         else if (!only_browse)
1002                         {
1003                                 /* Hide list */
1004                                 redraw = FALSE;
1005                                 screen_load();
1006                         }
1007
1008                         /* Redo asking */
1009                         continue;
1010                 }
1011
1012                 if (!use_menu)
1013                 {
1014                         /* Note verify */
1015                         ask = isupper(choice);
1016
1017                         /* Lowercase */
1018                         if (ask) choice = (char)tolower(choice);
1019
1020                         /* Extract request */
1021                         i = (islower(choice) ? A2I(choice) : -1);
1022                 }
1023
1024                 /* Totally Illegal */
1025                 if ((i < 0) || (i >= num))
1026                 {
1027                         bell();
1028                         continue;
1029                 }
1030
1031                 /* Save the spell index */
1032                 spell = mind_ptr->info[i];
1033
1034                 /* Verify it */
1035                 if (ask)
1036                 {
1037                         char tmp_val[160];
1038
1039                         /* Prompt */
1040                         (void) strnfmt(tmp_val, 78, _("%sを使いますか?", "Use %s? "), spell.name);
1041
1042                         /* Belay that order */
1043                         if (!get_check(tmp_val)) continue;
1044                 }
1045
1046                 /* Stop the loop */
1047                 flag = TRUE;
1048         }
1049         if (redraw && !only_browse) screen_load();
1050
1051         caster_ptr->window |= (PW_SPELL);
1052         handle_stuff(caster_ptr);
1053
1054         /* Abort if needed */
1055         if (!flag) return FALSE;
1056
1057         /* Save the choice */
1058         (*sn) = i;
1059
1060         repeat_push((COMMAND_CODE)i);
1061
1062         /* Success */
1063         return TRUE;
1064 }
1065
1066 /*!
1067  * @brief 超能力の発動 /
1068  * do_cmd_cast calls this function if the player's class is 'mindcrafter'.
1069  * @param spell 発動する特殊技能のID
1070  * @return 処理を実行したらTRUE、キャンセルした場合FALSEを返す。
1071  */
1072 static bool cast_mindcrafter_spell(player_type *caster_ptr, int spell)
1073 {
1074         int b = 0;
1075         DIRECTION dir;
1076         TIME_EFFECT t;
1077         PLAYER_LEVEL plev = caster_ptr->lev;
1078
1079         /* spell code */
1080         switch (spell)
1081         {
1082         case 0:   /* Precog */
1083                 if (plev > 44)
1084                 {
1085                         chg_virtue(caster_ptr, V_KNOWLEDGE, 1);
1086                         chg_virtue(caster_ptr, V_ENLIGHTEN, 1);
1087                         wiz_lite(caster_ptr, FALSE);
1088                 }
1089                 else if (plev > 19)
1090                         map_area(caster_ptr, DETECT_RAD_MAP);
1091
1092                 if (plev < 30)
1093                 {
1094                         b = detect_monsters_normal(caster_ptr, DETECT_RAD_DEFAULT);
1095                         if (plev > 14) b |= detect_monsters_invis(caster_ptr, DETECT_RAD_DEFAULT);
1096                         if (plev > 4)  {
1097                                 b |= detect_traps(caster_ptr, DETECT_RAD_DEFAULT, TRUE);
1098                                 b |= detect_doors(caster_ptr, DETECT_RAD_DEFAULT);
1099                         }
1100                 }
1101                 else
1102                 {
1103                         b = detect_all(caster_ptr, DETECT_RAD_DEFAULT);
1104                 }
1105
1106                 if ((plev > 24) && (plev < 40))
1107                         set_tim_esp(caster_ptr, (TIME_EFFECT)plev, FALSE);
1108
1109                 if (!b) msg_print(_("安全な気がする。", "You feel safe."));
1110
1111                 break;
1112         case 1:
1113                 /* Mindblast */
1114                 if (!get_aim_dir(caster_ptr, &dir)) return FALSE;
1115
1116                 if (randint1(100) < plev * 2)
1117                         fire_beam(caster_ptr, GF_PSI, dir, damroll(3 + ((plev - 1) / 4), (3 + plev / 15)));
1118                 else
1119                         fire_ball(caster_ptr, GF_PSI, dir, damroll(3 + ((plev - 1) / 4), (3 + plev / 15)), 0);
1120                 break;
1121         case 2:
1122                 /* Minor displace */
1123                 teleport_player(caster_ptr, 10, TELEPORT_SPONTANEOUS);
1124                 break;
1125         case 3:
1126                 /* Major displace */
1127                 teleport_player(caster_ptr, plev * 5, TELEPORT_SPONTANEOUS);
1128                 break;
1129         case 4:
1130                 /* Domination */
1131                 if (plev < 30)
1132                 {
1133                         if (!get_aim_dir(caster_ptr, &dir)) return FALSE;
1134
1135                         fire_ball(caster_ptr, GF_DOMINATION, dir, plev, 0);
1136                 }
1137                 else
1138                 {
1139                         charm_monsters(caster_ptr, plev * 2);
1140                 }
1141                 break;
1142         case 5:
1143                 /* Fist of Force  ---  not 'true' TK  */
1144                 if (!get_aim_dir(caster_ptr, &dir)) return FALSE;
1145
1146                 fire_ball(caster_ptr, GF_TELEKINESIS, dir, damroll(8 + ((plev - 5) / 4), 8),
1147                         (plev > 20 ? (plev - 20) / 8 + 1 : 0));
1148                 break;
1149         case 6:
1150                 /* Character Armour */
1151                 set_shield(caster_ptr, (TIME_EFFECT)plev, FALSE);
1152                 if (plev > 14) set_oppose_acid(caster_ptr, (TIME_EFFECT)plev, FALSE);
1153                 if (plev > 19) set_oppose_fire(caster_ptr, (TIME_EFFECT)plev, FALSE);
1154                 if (plev > 24) set_oppose_cold(caster_ptr, (TIME_EFFECT)plev, FALSE);
1155                 if (plev > 29) set_oppose_elec(caster_ptr, (TIME_EFFECT)plev, FALSE);
1156                 if (plev > 34) set_oppose_pois(caster_ptr, (TIME_EFFECT)plev, FALSE);
1157                 break;
1158         case 7:
1159                 /* Psychometry */
1160                 if (plev < 25)
1161                         return psychometry(caster_ptr);
1162                 else
1163                         return ident_spell(caster_ptr, FALSE, 0);
1164         case 8:
1165                 /* Mindwave */
1166                 msg_print(_("精神を捻じ曲げる波動を発生させた!", "Mind-warping forces emanate from your brain!"));
1167
1168                 if (plev < 25)
1169                         project(caster_ptr, 0, 2 + plev / 10, caster_ptr->y, caster_ptr->x,
1170                         (plev * 3), GF_PSI, PROJECT_KILL, -1);
1171                 else
1172                         (void)mindblast_monsters(caster_ptr, randint1(plev * ((plev - 5) / 10 + 1)));
1173                 break;
1174         case 9:
1175                 /* Adrenaline */
1176                 set_afraid(caster_ptr, 0);
1177                 set_stun(caster_ptr, 0);
1178
1179                 /*
1180                  * Only heal when Adrenalin Channeling is not active. We check
1181                  * that by checking if the player isn't fast and 'heroed' atm.
1182                  */
1183                 if (!is_fast(caster_ptr) || !is_hero(caster_ptr))
1184                 {
1185                         hp_player(caster_ptr, plev);
1186                 }
1187
1188                 t = 10 + randint1((plev * 3) / 2);
1189                 set_hero(caster_ptr, t, FALSE);
1190                 /* Haste */
1191                 (void)set_fast(caster_ptr, t, FALSE);
1192                 break;
1193         case 10:
1194                 /* Telekinesis */
1195                 if (!get_aim_dir(caster_ptr, &dir)) return FALSE;
1196
1197                 fetch_item(caster_ptr, dir, plev * 15, FALSE);
1198
1199                 break;
1200         case 11:
1201                 /* Psychic Drain */
1202                 if (!get_aim_dir(caster_ptr, &dir)) return FALSE;
1203
1204                 b = damroll(plev / 2, 6);
1205
1206                 /* This is always a radius-0 ball now */
1207                 if (fire_ball(caster_ptr, GF_PSI_DRAIN, dir, b, 0))
1208                         caster_ptr->energy_need += randint1(150);
1209                 break;
1210         case 12:
1211                 /* psycho-spear */
1212                 if (!get_aim_dir(caster_ptr, &dir)) return FALSE;
1213
1214                 fire_beam(caster_ptr, GF_PSY_SPEAR, dir, randint1(plev*3)+plev*3);
1215                 break;
1216         case 13:
1217         {
1218                 time_walk(caster_ptr);
1219                 break;
1220         }
1221         default:
1222                 msg_print(_("なに?", "Zap?"));
1223         }
1224
1225         return TRUE;
1226 }
1227
1228 /*!
1229  * @brief 練気術の発動 /
1230  * do_cmd_cast calls this function if the player's class is 'ForceTrainer'.
1231  * @param spell 発動する特殊技能のID
1232  * @return 処理を実行したらTRUE、キャンセルした場合FALSEを返す。
1233  */
1234 static bool cast_force_spell(player_type *caster_ptr, int spell)
1235 {
1236         DIRECTION dir;
1237         PLAYER_LEVEL plev = caster_ptr->lev;
1238         int boost = get_current_ki(caster_ptr);
1239
1240         if (heavy_armor(caster_ptr)) boost /= 2;
1241
1242         /* spell code */
1243         switch (spell)
1244         {
1245         case 0:
1246                 if (!get_aim_dir(caster_ptr, &dir)) return FALSE;
1247                 fire_ball(caster_ptr, GF_MISSILE, dir, damroll(3 + ((plev - 1) / 5) + boost / 12, 4), 0);
1248                 break;
1249         case 1:
1250                 (void)lite_area(caster_ptr, damroll(2, (plev / 2)), (plev / 10) + 1);
1251                 break;
1252         case 2:
1253                 set_tim_levitation(caster_ptr, randint1(30) + 30 + boost / 5, FALSE);
1254                 break;
1255         case 3:
1256                 project_length = plev / 8 + 3;
1257                 if (!get_aim_dir(caster_ptr, &dir)) return FALSE;
1258
1259                 fire_beam(caster_ptr, GF_MISSILE, dir, damroll(5 + ((plev - 1) / 5) + boost / 10, 5));
1260                 break;
1261         case 4:
1262                 set_resist_magic(caster_ptr, randint1(20) + 20 + boost / 5, FALSE);
1263                 break;
1264         case 5:
1265                 msg_print(_("気を練った。", "You improved the Force."));
1266                 set_current_ki(caster_ptr, FALSE, 70 + plev);
1267                 caster_ptr->update |= (PU_BONUS);
1268                 if (randint1(get_current_ki(caster_ptr)) > (plev * 4 + 120))
1269                 {
1270                         msg_print(_("気が暴走した!", "The Force exploded!"));
1271                         fire_ball(caster_ptr, GF_MANA, 0, get_current_ki(caster_ptr) / 2, 10);
1272                         take_hit(caster_ptr, DAMAGE_LOSELIFE, caster_ptr->magic_num1[0] / 2, _("気の暴走", "Explosion of the Force"), -1);
1273                 }
1274                 else return TRUE;
1275                 break;
1276         case 6:
1277                 set_tim_sh_force(caster_ptr, randint1(plev / 2) + 15 + boost / 7, FALSE);
1278                 break;
1279         case 7:
1280                 return shock_power(caster_ptr);
1281                 break;
1282         case 8:
1283                 if (!get_aim_dir(caster_ptr, &dir)) return FALSE;
1284                 fire_ball(caster_ptr, GF_MISSILE, dir, damroll(10, 6) + plev * 3 / 2 + boost * 3 / 5, (plev < 30) ? 2 : 3);
1285                 break;
1286         case 9:
1287         {
1288                 MONSTER_IDX m_idx;
1289
1290                 if (!target_set(caster_ptr, TARGET_KILL)) return FALSE;
1291                 m_idx = caster_ptr->current_floor_ptr->grid_array[target_row][target_col].m_idx;
1292                 if (!m_idx) break;
1293                 if (!player_has_los_bold(caster_ptr, target_row, target_col)) break;
1294                 if (!projectable(caster_ptr, caster_ptr->y, caster_ptr->x, target_row, target_col)) break;
1295                 dispel_monster_status(caster_ptr, m_idx);
1296                 break;
1297         }
1298         case 10:
1299         {
1300                 int i;
1301                 bool success = FALSE;
1302
1303                 for (i = 0; i < 1 + boost/100; i++)
1304                         if (summon_specific(caster_ptr, -1, caster_ptr->y, caster_ptr->x, plev, SUMMON_PHANTOM, PM_FORCE_PET))
1305                                 success = TRUE;
1306                 if (success)
1307                 {
1308                         msg_print(_("御用でございますが、御主人様?", "'Your wish, master?'"));
1309                 }
1310                 else
1311                 {
1312                         msg_print(_("何も現れなかった。", "Nothing happen."));
1313                 }
1314                 break;
1315         }
1316         case 11:
1317                 fire_ball(caster_ptr, GF_FIRE, 0, 200 + (2 * plev) + boost * 2, 10);
1318                 break;
1319         case 12:
1320                 if (!get_aim_dir(caster_ptr, &dir)) return FALSE;
1321
1322                 fire_beam(caster_ptr, GF_MANA, dir, damroll(10 + (plev / 2) + boost * 3 / 10, 15));
1323                 break;
1324         case 13:
1325                 set_lightspeed(caster_ptr, randint1(16) + 16 + boost / 20, FALSE);
1326                 break;
1327         default:
1328                 msg_print(_("なに?", "Zap?"));
1329         }
1330
1331         set_current_ki(caster_ptr, TRUE, 0);
1332         caster_ptr->update |= (PU_BONUS);
1333
1334         return TRUE;
1335 }
1336
1337
1338 /*!
1339  * @brief 現在フロアに存在している鏡の数を数える / calculate mirrors
1340  * @return 鏡の枚数
1341  */
1342 static int number_of_mirrors(floor_type *floor_ptr)
1343 {
1344         int val = 0;
1345         for (POSITION x = 0; x < floor_ptr->width; x++) {
1346                 for (POSITION y = 0; y < floor_ptr->height; y++) {
1347                         if (is_mirror_grid(&floor_ptr->grid_array[y][x])) val++;
1348                 }
1349         }
1350
1351         return val;
1352 }
1353
1354
1355 /*!
1356  * @brief 鏡魔法の発動 /
1357  * do_cmd_cast calls this function if the player's class is 'Mirror magic'.
1358  * @param spell 発動する特殊技能のID
1359  * @return 処理を実行したらTRUE、キャンセルした場合FALSEを返す。
1360  */
1361 static bool cast_mirror_spell(player_type *caster_ptr, int spell)
1362 {
1363         DIRECTION dir;
1364         PLAYER_LEVEL plev = caster_ptr->lev;
1365         int tmp;
1366         TIME_EFFECT t;
1367         POSITION x, y;
1368
1369         /* spell code */
1370         switch (spell)
1371         {
1372                 /* mirror of seeing */
1373         case 0:
1374                 tmp = is_mirror_grid(&caster_ptr->current_floor_ptr->grid_array[caster_ptr->y][caster_ptr->x]) ? 4 : 0;
1375                 if (plev + tmp > 4)detect_monsters_normal(caster_ptr, DETECT_RAD_DEFAULT);
1376                 if (plev + tmp > 18)detect_monsters_invis(caster_ptr, DETECT_RAD_DEFAULT);
1377                 if (plev + tmp > 28)set_tim_esp(caster_ptr, (TIME_EFFECT)plev, FALSE);
1378                 if (plev + tmp > 38)map_area(caster_ptr, DETECT_RAD_MAP);
1379                 if (tmp == 0 && plev < 5) {
1380                         msg_print(_("鏡がなくて集中できなかった!", "You need a mirror to concentrate!"));
1381                 }
1382                 break;
1383                 /* drip of light */
1384         case 1:
1385                 if (number_of_mirrors(caster_ptr->current_floor_ptr) < 4 + plev / 10) {
1386                         place_mirror(caster_ptr);
1387                 }
1388                 else {
1389                         msg_format(_("これ以上鏡は制御できない!", "There are too many mirrors to control!"));
1390                 }
1391                 break;
1392         case 2:
1393                 if (!get_aim_dir(caster_ptr, &dir)) return FALSE;
1394                 if (plev > 9 && is_mirror_grid(&caster_ptr->current_floor_ptr->grid_array[caster_ptr->y][caster_ptr->x])) {
1395                         fire_beam(caster_ptr, GF_LITE, dir, damroll(3 + ((plev - 1) / 5), 4));
1396                 }
1397                 else {
1398                         fire_bolt(caster_ptr, GF_LITE, dir, damroll(3 + ((plev - 1) / 5), 4));
1399                 }
1400                 break;
1401                 /* warped mirror */
1402         case 3:
1403                 teleport_player(caster_ptr, 10, TELEPORT_SPONTANEOUS);
1404                 break;
1405                 /* mirror of light */
1406         case 4:
1407                 (void)lite_area(caster_ptr, damroll(2, (plev / 2)), (plev / 10) + 1);
1408                 break;
1409                 /* mirror of wandering */
1410         case 5:
1411                 teleport_player(caster_ptr, plev * 5, TELEPORT_SPONTANEOUS);
1412                 break;
1413                 /* robe of dust */
1414         case 6:
1415                 set_dustrobe(caster_ptr, 20 + randint1(20), FALSE);
1416                 break;
1417                 /* banishing mirror */
1418         case 7:
1419                 if (!get_aim_dir(caster_ptr, &dir)) return FALSE;
1420                 (void)fire_beam(caster_ptr, GF_AWAY_ALL, dir, plev);
1421                 break;
1422                 /* mirror clashing */
1423         case 8:
1424                 if (!get_aim_dir(caster_ptr, &dir)) return FALSE;
1425                 fire_ball(caster_ptr, GF_SHARDS, dir, damroll(8 + ((plev - 5) / 4), 8),
1426                         (plev > 20 ? (plev - 20) / 8 + 1 : 0));
1427                 break;
1428                 /* mirror sleeping */
1429         case 9:
1430                 for (x = 0; x < caster_ptr->current_floor_ptr->width; x++) {
1431                         for (y = 0; y < caster_ptr->current_floor_ptr->height; y++) {
1432                                 if (is_mirror_grid(&caster_ptr->current_floor_ptr->grid_array[y][x])) {
1433                                         project(caster_ptr, 0, 2, y, x, (HIT_POINT)plev, GF_OLD_SLEEP, (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP | PROJECT_NO_HANGEKI), -1);
1434                                 }
1435                         }
1436                 }
1437                 break;
1438                 /* seeker ray */
1439         case 10:
1440                 if (!get_aim_dir(caster_ptr, &dir)) return FALSE;
1441                 fire_beam(caster_ptr, GF_SEEKER, dir, damroll(11 + (plev - 5) / 4, 8));
1442                 break;
1443                 /* seal of mirror */
1444         case 11:
1445                 seal_of_mirror(caster_ptr, plev * 4 + 100);
1446                 break;
1447                 /* shield of water */
1448         case 12:
1449                 t = 20 + randint1(20);
1450                 set_shield(caster_ptr, t, FALSE);
1451                 if (plev > 31)set_tim_reflect(caster_ptr, t, FALSE);
1452                 if (plev > 39)set_resist_magic(caster_ptr, t, FALSE);
1453                 break;
1454                 /* super ray */
1455         case 13:
1456                 if (!get_aim_dir(caster_ptr, &dir)) return FALSE;
1457                 fire_beam(caster_ptr, GF_SUPER_RAY, dir, 150 + randint1(2 * plev));
1458                 break;
1459                 /* illusion light */
1460         case 14:
1461                 tmp = is_mirror_grid(&caster_ptr->current_floor_ptr->grid_array[caster_ptr->y][caster_ptr->x]) ? 4 : 3;
1462                 slow_monsters(caster_ptr, plev);
1463                 stun_monsters(caster_ptr, plev*tmp);
1464                 confuse_monsters(caster_ptr, plev*tmp);
1465                 turn_monsters(caster_ptr, plev*tmp);
1466                 stun_monsters(caster_ptr, plev*tmp);
1467                 stasis_monsters(caster_ptr, plev*tmp);
1468                 break;
1469                 /* mirror shift */
1470         case 15:
1471                 if (!is_mirror_grid(&caster_ptr->current_floor_ptr->grid_array[caster_ptr->y][caster_ptr->x])) {
1472                         msg_print(_("鏡の国の場所がわからない!", "You cannot find out where the mirror is!"));
1473                         break;
1474                 }
1475                 reserve_alter_reality(caster_ptr);
1476                 break;
1477                 /* mirror tunnel */
1478         case 16:
1479                 msg_print(_("鏡の世界を通り抜け…  ", "You try to enter the mirror..."));
1480                 return mirror_tunnel(caster_ptr);
1481
1482                 /* mirror of recall */
1483         case 17:
1484                 return recall_player(caster_ptr, randint0(21) + 15);
1485                 /* multi-shadow */
1486         case 18:
1487                 set_multishadow(caster_ptr, 6 + randint1(6), FALSE);
1488                 break;
1489                 /* binding field */
1490         case 19:
1491                 if (!binding_field(caster_ptr, plev * 11 + 5))msg_print(_("適当な鏡を選べなかった!", "You were not able to choose suitable mirrors!"));
1492                 break;
1493                 /* mirror of Ruffnor */
1494         case 20:
1495                 (void)set_invuln(caster_ptr, randint1(4) + 4, FALSE);
1496                 break;
1497         default:
1498                 msg_print(_("なに?", "Zap?"));
1499
1500         }
1501         caster_ptr->magic_num1[0] = 0;
1502
1503         return TRUE;
1504 }
1505
1506 /*!
1507  * @brief 怒りの発動 /
1508  * do_cmd_cast calls this function if the player's class is 'berserker'.
1509  * @param spell 発動する特殊技能のID
1510  * @return 処理を実行したらTRUE、キャンセルした場合FALSEを返す。
1511  */
1512 static bool cast_berserk_spell(player_type *caster_ptr, int spell)
1513 {
1514         POSITION y, x;
1515         DIRECTION dir;
1516
1517         /* spell code */
1518         switch (spell)
1519         {
1520         case 0:
1521                 detect_monsters_mind(caster_ptr, DETECT_RAD_DEFAULT);
1522                 break;
1523         case 1:
1524         {
1525                 if (caster_ptr->riding)
1526                 {
1527                         msg_print(_("乗馬中には無理だ。", "You cannot do it when riding."));
1528                         return FALSE;
1529                 }
1530
1531                 if (!get_direction(caster_ptr, &dir, FALSE, FALSE)) return FALSE;
1532
1533                 if (dir == 5) return FALSE;
1534                 y = caster_ptr->y + ddy[dir];
1535                 x = caster_ptr->x + ddx[dir];
1536
1537                 if (!caster_ptr->current_floor_ptr->grid_array[y][x].m_idx)
1538                 {
1539                         msg_print(_("その方向にはモンスターはいません。", "There is no monster."));
1540                         return FALSE;
1541                 }
1542
1543                 do_cmd_attack(caster_ptr, y, x, 0);
1544
1545                 if (!player_can_enter(caster_ptr, caster_ptr->current_floor_ptr->grid_array[y][x].feat, 0) || is_trap(caster_ptr, caster_ptr->current_floor_ptr->grid_array[y][x].feat))
1546                         break;
1547
1548                 y += ddy[dir];
1549                 x += ddx[dir];
1550
1551                 if (player_can_enter(caster_ptr, caster_ptr->current_floor_ptr->grid_array[y][x].feat, 0) && !is_trap(caster_ptr, caster_ptr->current_floor_ptr->grid_array[y][x].feat) && !caster_ptr->current_floor_ptr->grid_array[y][x].m_idx)
1552                 {
1553                         msg_print(NULL);
1554                         (void)move_player_effect(caster_ptr, y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
1555                 }
1556                 break;
1557         }
1558         case 2:
1559         {
1560                 if (!get_direction(caster_ptr, &dir, FALSE, FALSE)) return FALSE;
1561                 y = caster_ptr->y + ddy[dir];
1562                 x = caster_ptr->x + ddx[dir];
1563                 exe_movement(caster_ptr, dir, easy_disarm, TRUE);
1564                 break;
1565         }
1566         case 3:
1567                 earthquake(caster_ptr, caster_ptr->y, caster_ptr->x, 8+randint0(5), 0);
1568                 break;
1569         case 4:
1570                 massacre(caster_ptr);
1571                 break;
1572         default:
1573                 msg_print(_("なに?", "Zap?"));
1574
1575         }
1576         return TRUE;
1577 }
1578
1579 /*!
1580  * @brief 忍術の発動 /
1581  * do_cmd_cast calls this function if the player's class is 'ninja'.
1582  * @param caster_ptr プレーヤーへの参照ポインタ
1583  * @param spell 発動する特殊技能のID
1584  * @return 処理を実行したらTRUE、キャンセルした場合FALSEを返す。
1585  */
1586 static bool cast_ninja_spell(player_type *caster_ptr, int spell)
1587 {
1588         POSITION x = 0, y = 0;
1589         DIRECTION dir;
1590         PLAYER_LEVEL plev = caster_ptr->lev;
1591
1592         switch (spell)
1593         {
1594         case 0:
1595                 (void)unlite_area(caster_ptr, 0, 3);
1596                 break;
1597         case 1:
1598                 if (plev > 44)
1599                 {
1600                         wiz_lite(caster_ptr, TRUE);
1601                 }
1602                 detect_monsters_normal(caster_ptr, DETECT_RAD_DEFAULT);
1603                 if (plev > 4)
1604                 {
1605                         detect_traps(caster_ptr, DETECT_RAD_DEFAULT, TRUE);
1606                         detect_doors(caster_ptr, DETECT_RAD_DEFAULT);
1607                         detect_stairs(caster_ptr, DETECT_RAD_DEFAULT);
1608                 }
1609                 if (plev > 14)
1610                 {
1611                         detect_objects_normal(caster_ptr, DETECT_RAD_DEFAULT);
1612                 }
1613                 break;
1614         case 2:
1615         {
1616                 teleport_player(caster_ptr, 10, TELEPORT_SPONTANEOUS);
1617                 break;
1618         }
1619         case 3:
1620         {
1621                 if (!(caster_ptr->special_defense & NINJA_KAWARIMI))
1622                 {
1623                         msg_print(_("敵の攻撃に対して敏感になった。", "You are now prepared to evade any attacks."));
1624                         caster_ptr->special_defense |= NINJA_KAWARIMI;
1625                         caster_ptr->redraw |= (PR_STATUS);
1626                 }
1627                 break;
1628         }
1629         case 4:
1630         {
1631                 teleport_player(caster_ptr, caster_ptr->lev * 5, TELEPORT_SPONTANEOUS);
1632                 break;
1633         }
1634         case 5:
1635         {
1636                 if(!hit_and_away(caster_ptr)) return FALSE;
1637                 break;
1638         }
1639         case 6:
1640         {
1641                 if (!get_aim_dir(caster_ptr, &dir)) return FALSE;
1642                 (void)stasis_monster(caster_ptr, dir);
1643                 break;
1644         }
1645         case 7:
1646                 return ident_spell(caster_ptr, FALSE, 0);
1647         case 8:
1648                 set_tim_levitation(caster_ptr, randint1(20) + 20, FALSE);
1649                 break;
1650         case 9:
1651                 fire_ball(caster_ptr, GF_FIRE, 0, 50+plev, plev/10+2);
1652                 teleport_player(caster_ptr, 30, TELEPORT_SPONTANEOUS);
1653                 set_oppose_fire(caster_ptr, (TIME_EFFECT)plev, FALSE);
1654                 break;
1655         case 10:
1656                 return rush_attack(caster_ptr, NULL);
1657         case 11:
1658         {
1659                 int i;
1660                 for (i = 0; i < 8; i++)
1661                 {
1662                         OBJECT_IDX slot;
1663
1664                         for (slot = 0; slot < INVEN_PACK; slot++)
1665                         {
1666                                 if (caster_ptr->inventory_list[slot].tval == TV_SPIKE) break;
1667                         }
1668                         if (slot == INVEN_PACK)
1669                         {
1670                                 if (!i) msg_print(_("くさびを持っていない。", "You have no Iron Spikes."));
1671                                 else msg_print(_("くさびがなくなった。", "You have no more Iron Spikes."));
1672                                 return FALSE;
1673                         }
1674
1675                         /* Gives a multiplier of 2 at first, up to 3 at 40th */
1676                         do_cmd_throw(caster_ptr, 1, FALSE, slot);
1677
1678                         take_turn(caster_ptr, 100);
1679                 }
1680                 break;
1681         }
1682         case 12:
1683                 (void)fetch_monster(caster_ptr);
1684                 break;
1685         case 13:
1686                 if (!get_aim_dir(caster_ptr, &dir)) return FALSE;
1687                 fire_ball(caster_ptr, GF_OLD_CONF, dir, plev*3, 3);
1688                 break;
1689         case 14:
1690                 project_length = -1;
1691                 if (!get_aim_dir(caster_ptr, &dir))
1692                 {
1693                         project_length = 0;
1694                         return FALSE;
1695                 }
1696                 project_length = 0;
1697
1698                 (void)teleport_swap(caster_ptr, dir);
1699                 break;
1700         case 15:
1701                 explosive_rune(caster_ptr, caster_ptr->y, caster_ptr->x);
1702                 break;
1703         case 16:
1704                 (void)set_pass_wall(caster_ptr, randint1(plev/2) + plev/2, FALSE);
1705                 set_oppose_acid(caster_ptr, (TIME_EFFECT)plev, FALSE);
1706                 break;
1707         case 17:
1708                 fire_ball(caster_ptr, GF_POIS, 0, 75+plev*2/3, plev/5+2);
1709                 fire_ball(caster_ptr, GF_HYPODYNAMIA, 0, 75+plev*2/3, plev/5+2);
1710                 fire_ball(caster_ptr, GF_CONFUSION, 0, 75+plev*2/3, plev/5+2);
1711                 teleport_player(caster_ptr, 30, TELEPORT_SPONTANEOUS);
1712                 break;
1713         case 18:
1714         {
1715                 int k;
1716                 int num = damroll(3, 9);
1717
1718                 for (k = 0; k < num; k++)
1719                 {
1720                         EFFECT_ID typ = one_in_(2) ? GF_FIRE : one_in_(3) ? GF_NETHER : GF_PLASMA;
1721                         int attempts = 1000;
1722
1723                         while (attempts--)
1724                         {
1725                                 scatter(caster_ptr, &y, &x, caster_ptr->y, caster_ptr->x, 4, 0);
1726
1727                                 if (!player_bold(caster_ptr, y, x)) break;
1728                         }
1729                         project(caster_ptr, 0, 0, y, x, damroll(6 + plev / 8, 10), typ,
1730                                 (PROJECT_BEAM | PROJECT_THRU | PROJECT_GRID | PROJECT_KILL), -1);
1731                 }
1732                 break;
1733         }
1734         case 19:
1735                 set_multishadow(caster_ptr, 6+randint1(6), FALSE);
1736                 break;
1737         default:
1738                 msg_print(_("なに?", "Zap?"));
1739
1740         }
1741         return TRUE;
1742 }
1743
1744 /*!
1745  * @brief 特殊技能コマンドのメインルーチン /
1746  * @return なし
1747  */
1748 void do_cmd_mind(player_type *caster_ptr)
1749 {
1750         SPELL_IDX n = 0;
1751         int b = 0;
1752         PERCENTAGE chance;
1753         PERCENTAGE minfail = 0;
1754         PLAYER_LEVEL plev = caster_ptr->lev;
1755         int             old_csp = caster_ptr->csp;
1756         mind_type       spell;
1757         bool            cast;
1758         int             use_mind, mana_cost;
1759         concptr            p;
1760         bool            on_mirror = FALSE;
1761
1762         if (cmd_limit_confused(caster_ptr)) return;
1763         if (!get_mind_power(caster_ptr, &n, FALSE)) return;
1764
1765 #ifdef JP
1766         switch(caster_ptr->pclass)
1767         {
1768                 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER; p = "精神";break;
1769                 case CLASS_FORCETRAINER:          use_mind = MIND_KI; p = "気";break;
1770                 case CLASS_BERSERKER:   use_mind = MIND_BERSERKER; p = "怒り";break;
1771                 case CLASS_MIRROR_MASTER:   use_mind = MIND_MIRROR_MASTER; p = "鏡魔法";break;
1772                 case CLASS_NINJA:       use_mind = MIND_NINJUTSU; p = "精神";break;
1773                 default:                use_mind = 0 ;p = "超能力"; break;
1774         }
1775 #else
1776         switch(caster_ptr->pclass)
1777         {
1778                 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER; break;
1779                 case CLASS_FORCETRAINER: use_mind = MIND_KI; break;
1780                 case CLASS_BERSERKER:   use_mind = MIND_BERSERKER; break;
1781                 case CLASS_MIRROR_MASTER:   use_mind = MIND_MIRROR_MASTER; break;
1782                 case CLASS_NINJA:       use_mind = MIND_NINJUTSU; break;
1783                 default:                use_mind = 0; break;
1784         }
1785         p = "skill";
1786 #endif
1787         spell = mind_powers[use_mind].info[n];
1788
1789         /* Spell failure chance */
1790         chance = spell.fail;
1791
1792         mana_cost = spell.mana_cost;
1793         if (use_mind == MIND_KI)
1794         {
1795                 if (heavy_armor(caster_ptr)) chance += 20;
1796                 if (caster_ptr->icky_wield[0]) chance += 20;
1797                 else if (has_melee_weapon(caster_ptr, INVEN_RARM)) chance += 10;
1798                 if (caster_ptr->icky_wield[1]) chance += 20;
1799                 else if (has_melee_weapon(caster_ptr, INVEN_LARM)) chance += 10;
1800                 if (n == 5)
1801                 {
1802                         int j;
1803                         for (j = 0; j < get_current_ki(caster_ptr) / 50; j++)
1804                                 mana_cost += (j+1) * 3 / 2;
1805                 }
1806         }
1807
1808         /* Verify "dangerous" spells */
1809         if ((use_mind == MIND_BERSERKER) || (use_mind == MIND_NINJUTSU))
1810         {
1811                 if (mana_cost > caster_ptr->chp)
1812                 {
1813                         msg_print(_("HPが足りません。", "You do not have enough hp to use this power."));
1814                         return;
1815                 }
1816         }
1817         else if (mana_cost > caster_ptr->csp)
1818         {
1819                 /* Warning */
1820                 msg_print(_("MPが足りません。", "You do not have enough mana to use this power."));
1821
1822                 if (!over_exert) return;
1823
1824                 /* Verify */
1825                 if (!get_check(_("それでも挑戦しますか? ", "Attempt it anyway? "))) return;
1826
1827         }
1828
1829         if (chance)
1830         {
1831                 /* Reduce failure rate by "effective" level adjustment */
1832                 chance -= 3 * (plev - spell.min_lev);
1833
1834                 chance += caster_ptr->to_m_chance;
1835
1836                 /* Reduce failure rate by INT/WIS adjustment */
1837                 chance -= 3 * (adj_mag_stat[caster_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
1838
1839                 /* Not enough mana to cast */
1840                 if ((mana_cost > caster_ptr->csp) && (use_mind != MIND_BERSERKER) && (use_mind != MIND_NINJUTSU))
1841                 {
1842                         chance += 5 * (mana_cost - caster_ptr->csp);
1843                 }
1844
1845                 /* Extract the minimum failure rate */
1846                 minfail = adj_mag_fail[caster_ptr->stat_ind[mp_ptr->spell_stat]];
1847
1848                 /* Minimum failure rate */
1849                 if (chance < minfail) chance = minfail;
1850
1851                 /* Stunning makes spells harder */
1852                 if (caster_ptr->stun > 50) chance += 25;
1853                 else if (caster_ptr->stun) chance += 15;
1854
1855                 if (use_mind == MIND_KI)
1856                 {
1857                         if (heavy_armor(caster_ptr)) chance += 5;
1858                         if (caster_ptr->icky_wield[0]) chance += 5;
1859                         if (caster_ptr->icky_wield[1]) chance += 5;
1860                 }
1861         }
1862
1863         /* Always a 5 percent chance of working */
1864         if (chance > 95) chance = 95;
1865
1866         /* Failed spell */
1867         if (randint0(100) < chance)
1868         {
1869                 if (flush_failure) flush();
1870                 msg_format(_("%sの集中に失敗した!", "You failed to concentrate hard enough for %s!"), p);
1871
1872                 sound(SOUND_FAIL);
1873
1874                 if ((use_mind != MIND_BERSERKER) && (use_mind != MIND_NINJUTSU))
1875                 {
1876                         if ((use_mind == MIND_KI) && (n != 5) && get_current_ki(caster_ptr))
1877                         {
1878                                 msg_print(_("気が散ってしまった...", "Your improved Force has gone away..."));
1879                                 set_current_ki(caster_ptr, TRUE, 0);
1880                         }
1881
1882                         if (randint1(100) < (chance / 2))
1883                         {
1884                                 /* Backfire */
1885                           b = randint1(100);
1886
1887                           if( use_mind == MIND_MINDCRAFTER ){
1888                                 if (b < 5)
1889                                 {
1890                                         msg_print(_("なんてこった!頭の中が真っ白になった!", "Oh, no! Your mind has gone blank!"));
1891                                         lose_all_info(caster_ptr);
1892                                 }
1893                                 else if (b < 15)
1894                                 {
1895                                         msg_print(_("奇妙な光景が目の前で踊っている...", "Weird visions seem to dance before your eyes..."));
1896                                         set_image(caster_ptr, caster_ptr->image + 5 + randint1(10));
1897                                 }
1898                                 else if (b < 45)
1899                                 {
1900                                         msg_print(_("あなたの頭は混乱した!", "Your brain is addled!"));
1901                                         set_confused(caster_ptr, caster_ptr->confused + randint1(8));
1902                                 }
1903                                 else if (b < 90)
1904                                 {
1905                                         set_stun(caster_ptr, caster_ptr->stun + randint1(8));
1906                                 }
1907                                 else
1908                                 {
1909                                         /* Mana storm */
1910                                         msg_format(_("%sの力が制御できない氾流となって解放された!", "Your mind unleashes its power in an uncontrollable storm!"), p);
1911
1912                                         project(caster_ptr, PROJECT_WHO_UNCTRL_POWER, 2 + plev / 10, caster_ptr->y, caster_ptr->x, plev * 2,
1913                                                 GF_MANA, PROJECT_JUMP | PROJECT_KILL | PROJECT_GRID | PROJECT_ITEM, -1);
1914                                         caster_ptr->csp = MAX(0, caster_ptr->csp - plev * MAX(1, plev / 10));
1915                                 }
1916                           }
1917                           if( use_mind == MIND_MIRROR_MASTER ){
1918                                 if (b < 51)
1919                                 {
1920                                   /* Nothing has happen */
1921                                 }
1922                                 else if (b < 81)
1923                                 {
1924                                         msg_print(_("鏡の世界の干渉を受けた!", "Weird visions seem to dance before your eyes..."));
1925                                         teleport_player(caster_ptr, 10, TELEPORT_PASSIVE);
1926                                 }
1927                                 else if (b < 96)
1928                                 {
1929                                         msg_print(_("まわりのものがキラキラ輝いている!", "Your brain is addled!"));
1930                                         set_image(caster_ptr, caster_ptr->image + 5 + randint1(10));
1931                                 }
1932                                 else
1933                                 {
1934                                         /* Mana storm */
1935                                         msg_format(_("%sの力が制御できない氾流となって解放された!", "Your mind unleashes its power in an uncontrollable storm!"), p);
1936
1937                                         project(caster_ptr, PROJECT_WHO_UNCTRL_POWER, 2 + plev / 10, caster_ptr->y, caster_ptr->x, plev * 2,
1938                                                 GF_MANA, PROJECT_JUMP | PROJECT_KILL | PROJECT_GRID | PROJECT_ITEM, -1);
1939                                         caster_ptr->csp = MAX(0, caster_ptr->csp - plev * MAX(1, plev / 10));
1940                                 }
1941                           }
1942                         }
1943                 }
1944         }
1945         else
1946         {
1947                 sound(SOUND_ZAP);
1948
1949                 switch(use_mind)
1950                 {
1951                 case MIND_MINDCRAFTER:
1952                         
1953                         cast = cast_mindcrafter_spell(caster_ptr, n);
1954                         break;
1955                 case MIND_KI:
1956                         
1957                         cast = cast_force_spell(caster_ptr, n);
1958                         break;
1959                 case MIND_BERSERKER:
1960                         
1961                         cast = cast_berserk_spell(caster_ptr, n);
1962                         break;
1963                 case MIND_MIRROR_MASTER:
1964                         
1965                         if(is_mirror_grid(&caster_ptr->current_floor_ptr->grid_array[caster_ptr->y][caster_ptr->x]) )on_mirror = TRUE;
1966                         cast = cast_mirror_spell(caster_ptr, n);
1967                         break;
1968                 case MIND_NINJUTSU:
1969                         
1970                         cast = cast_ninja_spell(caster_ptr, n);
1971                         break;
1972                 default:
1973                         msg_format(_("謎の能力:%d, %d", "Mystery power:%d, %d"),use_mind, n);
1974                         return;
1975                 }
1976
1977                 if (!cast) return;
1978         }
1979
1980
1981         /* teleport from mirror costs small energy */
1982         if(on_mirror && caster_ptr->pclass == CLASS_MIRROR_MASTER)
1983         {
1984           if( n==3 || n==5 || n==7 || n==16 ) take_turn(caster_ptr, 50);
1985         }
1986         else
1987         {
1988                 take_turn(caster_ptr, 100);
1989         }
1990
1991         if ((use_mind == MIND_BERSERKER) || (use_mind == MIND_NINJUTSU))
1992         {
1993                 take_hit(caster_ptr, DAMAGE_USELIFE, mana_cost, _("過度の集中", "concentrating too hard"), -1);
1994                 /* Redraw hp */
1995                 caster_ptr->redraw |= (PR_HP);
1996         }
1997
1998         /* Sufficient mana */
1999         else if (mana_cost <= old_csp)
2000         {
2001                 /* Use some mana */
2002                 caster_ptr->csp -= mana_cost;
2003
2004                 /* Limit */
2005                 if (caster_ptr->csp < 0) caster_ptr->csp = 0;
2006
2007                 if ((use_mind == MIND_MINDCRAFTER) && (n == 13))
2008                 {
2009                         /* No mana left */
2010                         caster_ptr->csp = 0;
2011                         caster_ptr->csp_frac = 0;
2012                 }
2013         }
2014
2015         /* Over-exert the player */
2016         else
2017         {
2018                 int oops = mana_cost - old_csp;
2019
2020                 /* No mana left */
2021                 if ((caster_ptr->csp - mana_cost) < 0) caster_ptr->csp_frac = 0;
2022                 caster_ptr->csp = MAX(0, caster_ptr->csp - mana_cost);
2023
2024                 msg_format(_("%sを集中しすぎて気を失ってしまった!", "You faint from the effort!"),p);
2025
2026                 /* Hack -- Bypass free action */
2027                 (void)set_paralyzed(caster_ptr, caster_ptr->paralyzed + randint1(5 * oops + 1));
2028
2029                 /* Damage WIS (possibly permanently) */
2030                 if (randint0(100) < 50)
2031                 {
2032                         bool perm = (randint0(100) < 25);
2033
2034                         msg_print(_("自分の精神を攻撃してしまった!", "You have damaged your mind!"));
2035
2036                         /* Reduce constitution */
2037                         (void)dec_stat(caster_ptr, A_WIS, 15 + randint1(10), perm);
2038                 }
2039         }
2040         caster_ptr->redraw |= (PR_MANA);
2041         caster_ptr->window |= (PW_PLAYER);
2042         caster_ptr->window |= (PW_SPELL);
2043 }
2044
2045
2046 /*!
2047  * @brief 現在プレイヤーが使用可能な特殊技能の一覧表示 /
2048  * @return なし
2049  */
2050 void do_cmd_mind_browse(player_type *caster_ptr)
2051 {
2052         SPELL_IDX n = 0;
2053         int j, line;
2054         char temp[62*5];
2055         int use_mind = 0;
2056
2057         if (caster_ptr->pclass == CLASS_MINDCRAFTER) use_mind = MIND_MINDCRAFTER;
2058         else if (caster_ptr->pclass == CLASS_FORCETRAINER) use_mind = MIND_KI;
2059         else if (caster_ptr->pclass == CLASS_BERSERKER) use_mind = MIND_BERSERKER;
2060         else if (caster_ptr->pclass == CLASS_NINJA) use_mind = MIND_NINJUTSU;
2061         else if (caster_ptr->pclass == CLASS_MIRROR_MASTER)
2062           use_mind = MIND_MIRROR_MASTER;
2063
2064         screen_save();
2065
2066         while (TRUE)
2067         {
2068                 if (!get_mind_power(caster_ptr, &n, TRUE))
2069                 {
2070                         screen_load();
2071                         return;
2072                 }
2073
2074                 /* Clear lines, position cursor  (really should use strlen here) */
2075                 term_erase(12, 21, 255);
2076                 term_erase(12, 20, 255);
2077                 term_erase(12, 19, 255);
2078                 term_erase(12, 18, 255);
2079                 term_erase(12, 17, 255);
2080                 term_erase(12, 16, 255);
2081
2082                 shape_buffer(mind_tips[use_mind][n], 62, temp, sizeof(temp));
2083                 for(j=0, line = 17;temp[j];j+=(1+strlen(&temp[j])))
2084                 {
2085                         prt(&temp[j], line, 15);
2086                         line++;
2087                 }
2088                 switch (use_mind)
2089                 {
2090                 case MIND_MIRROR_MASTER:
2091                 case MIND_NINJUTSU:
2092                   prt(_("何かキーを押して下さい。", "Hit any key."),0,0);
2093                   (void)inkey();
2094                 }
2095         }
2096 }