OSDN Git Service

[WIP] [Refactor] #39963 Separated spells2.h from spells1.h
[hengband/hengband.git] / src / realm / realm-hex.c
1 /*!
2  * @file hex.c
3  * @brief 呪術の処理実装 / Hex code
4  * @date 2014/01/14
5  * @author
6  * 2014 Deskull rearranged comment for Doxygen.\n
7  * @details
8  * magic_num1\n
9  * 0: Flag bits of spelling spells\n
10  * 1: Flag bits of despelled spells\n
11  * 2: Revange damage\n
12  * magic_num2\n
13  * 0: Number of spelling spells\n
14  * 1: Type of revenge\n
15  * 2: Turn count for revenge\n
16  */
17
18 #include "angband.h"
19 #include "util.h"
20
21 #include "effect/effect-characteristics.h"
22 #include "cmd-spell.h"
23 #include "cmd-quaff.h"
24 #include "object-flavor.h"
25 #include "object-hook.h"
26 #include "object-curse.h"
27 #include "spells-status.h"
28 #include "spell/technic-info-table.h"
29 #include "player-status.h"
30 #include "player-effects.h"
31 #include "player-skill.h"
32 #include "player-inventory.h"
33 #include "realm/realm-hex.h"
34 #include "grid.h"
35 #include "monsterrace.h"
36 #include "targeting.h"
37 #include "realm/realm-song.h"
38 #include "view/display-main-window.h"
39 #include "world.h"
40 #include "realm/realm-hex.h"
41 #include "spell/spells-execution.h"
42 #include "spell/spells-type.h"
43 #include "spell/process-effect.h"
44 #include "spell/spells2.h"
45
46 #define MAX_KEEP 4 /*!<呪術の最大詠唱数 */
47
48 /*!
49  * @brief プレイヤーが詠唱中の全呪術を停止する
50  * @return なし
51  */
52 bool stop_hex_spell_all(player_type *caster_ptr)
53 {
54         SPELL_IDX i;
55
56         for (i = 0; i < 32; i++)
57         {
58                 if (hex_spelling(caster_ptr, i)) exe_spell(caster_ptr, REALM_HEX, i, SPELL_STOP);
59         }
60
61         CASTING_HEX_FLAGS(caster_ptr) = 0;
62         CASTING_HEX_NUM(caster_ptr) = 0;
63
64         if (caster_ptr->action == ACTION_SPELL) set_action(caster_ptr, ACTION_NONE);
65
66         caster_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
67         caster_ptr->redraw |= (PR_EXTRA | PR_HP | PR_MANA);
68
69         return TRUE;
70 }
71
72 /*!
73  * @brief プレイヤーが詠唱中の呪術から一つを選んで停止する
74  * @return なし
75  */
76 bool stop_hex_spell(player_type *caster_ptr)
77 {
78         int spell;
79         char choice = 0;
80         char out_val[160];
81         bool flag = FALSE;
82         TERM_LEN y = 1;
83         TERM_LEN x = 20;
84         int sp[MAX_KEEP];
85
86         if (!hex_spelling_any(caster_ptr))
87         {
88                 msg_print(_("呪文を詠唱していません。", "You are casting no spell."));
89                 return FALSE;
90         }
91
92         /* Stop all spells */
93         else if ((CASTING_HEX_NUM(caster_ptr) == 1) || (caster_ptr->lev < 35))
94         {
95                 return stop_hex_spell_all(caster_ptr);
96         }
97         else
98         {
99                 strnfmt(out_val, 78, _("どの呪文の詠唱を中断しますか?(呪文 %c-%c, 'l'全て, ESC)", "Which spell do you stop casting? (Spell %c-%c, 'l' to all, ESC)"),
100                         I2A(0), I2A(CASTING_HEX_NUM(caster_ptr) - 1));
101
102                 screen_save();
103
104                 while (!flag)
105                 {
106                         int n = 0;
107                         Term_erase(x, y, 255);
108                         prt(_("     名前", "     Name"), y, x + 5);
109                         for (spell = 0; spell < 32; spell++)
110                         {
111                                 if (hex_spelling(caster_ptr, spell))
112                                 {
113                                         Term_erase(x, y + n + 1, 255);
114                                         put_str(format("%c)  %s", I2A(n), exe_spell(caster_ptr, REALM_HEX, spell, SPELL_NAME)), y + n + 1, x + 2);
115                                         sp[n++] = spell;
116                                 }
117                         }
118
119                         if (!get_com(out_val, &choice, TRUE)) break;
120                         if (isupper(choice)) choice = (char)tolower(choice);
121
122                         if (choice == 'l')      /* All */
123                         {
124                                 screen_load();
125                                 return stop_hex_spell_all(caster_ptr);
126                         }
127                         if ((choice < I2A(0)) || (choice > I2A(CASTING_HEX_NUM(caster_ptr) - 1))) continue;
128                         flag = TRUE;
129                 }
130         }
131
132         screen_load();
133
134         if (flag)
135         {
136                 int n = sp[A2I(choice)];
137
138                 exe_spell(caster_ptr, REALM_HEX, n, SPELL_STOP);
139                 CASTING_HEX_FLAGS(caster_ptr) &= ~(1L << n);
140                 CASTING_HEX_NUM(caster_ptr)--;
141         }
142
143         caster_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
144         caster_ptr->redraw |= (PR_EXTRA | PR_HP | PR_MANA);
145
146         return flag;
147 }
148
149
150 /*!
151  * @brief 一定時間毎に呪術で消費するMPを処理する /
152  * Upkeeping hex spells Called from dungeon.c
153  * @return なし
154  */
155 void check_hex(player_type *caster_ptr)
156 {
157         int spell;
158         MANA_POINT need_mana;
159         u32b need_mana_frac;
160         bool res = FALSE;
161
162         /* Spells spelled by player */
163         if (caster_ptr->realm1 != REALM_HEX) return;
164         if (!CASTING_HEX_FLAGS(caster_ptr) && !caster_ptr->magic_num1[1]) return;
165
166         if (caster_ptr->magic_num1[1])
167         {
168                 caster_ptr->magic_num1[0] = caster_ptr->magic_num1[1];
169                 caster_ptr->magic_num1[1] = 0;
170                 res = TRUE;
171         }
172
173         /* Stop all spells when anti-magic ability is given */
174         if (caster_ptr->anti_magic)
175         {
176                 stop_hex_spell_all(caster_ptr);
177                 return;
178         }
179
180         need_mana = 0;
181         for (spell = 0; spell < 32; spell++)
182         {
183                 if (hex_spelling(caster_ptr, spell))
184                 {
185                         const magic_type *s_ptr;
186                         s_ptr = &technic_info[REALM_HEX - MIN_TECHNIC][spell];
187                         need_mana += mod_need_mana(caster_ptr, s_ptr->smana, spell, REALM_HEX);
188                 }
189         }
190
191         /* Culcurates final mana cost */
192         need_mana_frac = 0;
193         s64b_div(&need_mana, &need_mana_frac, 0, 3); /* Divide by 3 */
194         need_mana += (CASTING_HEX_NUM(caster_ptr) - 1);
195
196         /* Not enough mana */
197         if (s64b_cmp(caster_ptr->csp, caster_ptr->csp_frac, need_mana, need_mana_frac) < 0)
198         {
199                 stop_hex_spell_all(caster_ptr);
200                 return;
201         }
202
203         /* Enough mana */
204         else
205         {
206                 s64b_sub(&(caster_ptr->csp), &(caster_ptr->csp_frac), need_mana, need_mana_frac);
207
208                 caster_ptr->redraw |= PR_MANA;
209                 if (res)
210                 {
211                         msg_print(_("詠唱を再開した。", "You restart casting."));
212
213                         caster_ptr->action = ACTION_SPELL;
214
215                         caster_ptr->update |= (PU_BONUS | PU_HP);
216                         caster_ptr->redraw |= (PR_MAP | PR_STATUS | PR_STATE);
217                         caster_ptr->update |= (PU_MONSTERS);
218                         caster_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
219                 }
220         }
221
222         /* Gain experiences of spelling spells */
223         for (spell = 0; spell < 32; spell++)
224         {
225                 const magic_type *s_ptr;
226
227                 if (!hex_spelling(caster_ptr, spell)) continue;
228
229                 s_ptr = &technic_info[REALM_HEX - MIN_TECHNIC][spell];
230
231                 if (caster_ptr->spell_exp[spell] < SPELL_EXP_BEGINNER)
232                         caster_ptr->spell_exp[spell] += 5;
233                 else if(caster_ptr->spell_exp[spell] < SPELL_EXP_SKILLED)
234                 { if (one_in_(2) && (caster_ptr->current_floor_ptr->dun_level > 4) && ((caster_ptr->current_floor_ptr->dun_level + 10) > caster_ptr->lev)) caster_ptr->spell_exp[spell] += 1; }
235                 else if(caster_ptr->spell_exp[spell] < SPELL_EXP_EXPERT)
236                 { if (one_in_(5) && ((caster_ptr->current_floor_ptr->dun_level + 5) > caster_ptr->lev) && ((caster_ptr->current_floor_ptr->dun_level + 5) > s_ptr->slevel)) caster_ptr->spell_exp[spell] += 1; }
237                 else if(caster_ptr->spell_exp[spell] < SPELL_EXP_MASTER)
238                 { if (one_in_(5) && ((caster_ptr->current_floor_ptr->dun_level + 5) > caster_ptr->lev) && (caster_ptr->current_floor_ptr->dun_level > s_ptr->slevel)) caster_ptr->spell_exp[spell] += 1; }
239         }
240
241         /* Do any effects of continual spells */
242         for (spell = 0; spell < 32; spell++)
243         {
244                 if (hex_spelling(caster_ptr, spell))
245                 {
246                         exe_spell(caster_ptr, REALM_HEX, spell, SPELL_CONT);
247                 }
248         }
249 }
250
251 /*!
252  * @brief プレイヤーの呪術詠唱枠がすでに最大かどうかを返す
253  * @return すでに全枠を利用しているならTRUEを返す
254  */
255 bool hex_spell_fully(player_type *caster_ptr)
256 {
257         int k_max = 0;
258         k_max = (caster_ptr->lev / 15) + 1;
259         k_max = MIN(k_max, MAX_KEEP);
260         if (CASTING_HEX_NUM(caster_ptr) < k_max) return FALSE;
261         return TRUE;
262 }
263
264 /*!
265  * @brief 一定ゲームターン毎に復讐処理の残り期間の判定を行う
266  * @return なし
267  */
268 void revenge_spell(player_type *caster_ptr)
269 {
270         if (caster_ptr->realm1 != REALM_HEX) return;
271         if (HEX_REVENGE_TURN(caster_ptr) <= 0) return;
272
273         switch(HEX_REVENGE_TYPE(caster_ptr))
274         {
275                 case 1: exe_spell(caster_ptr, REALM_HEX, HEX_PATIENCE, SPELL_CONT); break;
276                 case 2: exe_spell(caster_ptr, REALM_HEX, HEX_REVENGE, SPELL_CONT); break;
277         }
278 }
279
280 /*!
281  * @brief 復讐ダメージの追加を行う
282  * @param dam 蓄積されるダメージ量
283  * @return なし
284  */
285 void revenge_store(player_type *caster_ptr, HIT_POINT dam)
286 {
287         if (caster_ptr->realm1 != REALM_HEX) return;
288         if (HEX_REVENGE_TURN(caster_ptr) <= 0) return;
289
290         HEX_REVENGE_POWER(caster_ptr) += dam;
291 }
292
293 /*!
294  * @brief 反テレポート結界の判定
295  * @param m_idx 判定の対象となるモンスターID
296  * @return 反テレポートの効果が適用されるならTRUEを返す
297  */
298 bool teleport_barrier(player_type *caster_ptr, MONSTER_IDX m_idx)
299 {
300         monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[m_idx];
301         monster_race *r_ptr = &r_info[m_ptr->r_idx];
302
303         if (!hex_spelling(caster_ptr, HEX_ANTI_TELE)) return FALSE;
304         if ((caster_ptr->lev * 3 / 2) < randint1(r_ptr->level)) return FALSE;
305
306         return TRUE;
307 }
308
309 /*!
310  * @brief 反魔法結界の判定
311  * @param m_idx 判定の対象となるモンスターID
312  * @return 反魔法の効果が適用されるならTRUEを返す
313  */
314 bool magic_barrier(player_type *target_ptr, MONSTER_IDX m_idx)
315 {
316         monster_type *m_ptr = &target_ptr->current_floor_ptr->m_list[m_idx];
317         monster_race *r_ptr = &r_info[m_ptr->r_idx];
318
319         if (!hex_spelling(target_ptr, HEX_ANTI_MAGIC)) return FALSE;
320         if ((target_ptr->lev * 3 / 2) < randint1(r_ptr->level)) return FALSE;
321
322         return TRUE;
323 }
324
325 /*!
326  * @brief 反増殖結界の判定
327  * @param m_idx 判定の対象となるモンスターID
328  * @return 反増殖の効果が適用されるならTRUEを返す
329  */
330 bool multiply_barrier(player_type *caster_ptr, MONSTER_IDX m_idx)
331 {
332         monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[m_idx];
333         monster_race *r_ptr = &r_info[m_ptr->r_idx];
334
335         if (!hex_spelling(caster_ptr, HEX_ANTI_MULTI)) return FALSE;
336         if ((caster_ptr->lev * 3 / 2) < randint1(r_ptr->level)) return FALSE;
337
338         return TRUE;
339 }
340
341 /*!
342 * @brief 呪術領域魔法の各処理を行う
343 * @param spell 魔法ID
344 * @param mode 処理内容 (SPELL_NAME / SPELL_DESC / SPELL_INFO / SPELL_CAST / SPELL_CONT / SPELL_STOP)
345 * @return SPELL_NAME / SPELL_DESC / SPELL_INFO 時には文字列ポインタを返す。SPELL_CAST / SPELL_CONT / SPELL_STOP 時はNULL文字列を返す。
346 */
347 concptr do_hex_spell(player_type *caster_ptr, SPELL_IDX spell, spell_type mode)
348 {
349         bool name = (mode == SPELL_NAME) ? TRUE : FALSE;
350         bool desc = (mode == SPELL_DESC) ? TRUE : FALSE;
351         bool info = (mode == SPELL_INFO) ? TRUE : FALSE;
352         bool cast = (mode == SPELL_CAST) ? TRUE : FALSE;
353         bool cont = (mode == SPELL_CONT) ? TRUE : FALSE;
354         bool stop = (mode == SPELL_STOP) ? TRUE : FALSE;
355
356         bool add = TRUE;
357
358         PLAYER_LEVEL plev = caster_ptr->lev;
359         HIT_POINT power;
360
361         switch (spell)
362         {
363                 /*** 1st book (0-7) ***/
364         case 0:
365                 if (name) return _("邪なる祝福", "Evily blessing");
366                 if (desc) return _("祝福により攻撃精度と防御力が上がる。", "Attempts to increase +to_hit of a weapon and AC");
367                 if (cast)
368                 {
369                         if (!caster_ptr->blessed)
370                         {
371                                 msg_print(_("高潔な気分になった!", "You feel righteous!"));
372                         }
373                 }
374                 if (stop)
375                 {
376                         if (!caster_ptr->blessed)
377                         {
378                                 msg_print(_("高潔な気分が消え失せた。", "The prayer has expired."));
379                         }
380                 }
381                 break;
382
383         case 1:
384                 if (name) return _("軽傷の治癒", "Cure light wounds");
385                 if (desc) return _("HPや傷を少し回復させる。", "Heals cuts and HP a little.");
386                 if (info) return info_heal(1, 10, 0);
387                 if (cast)
388                 {
389                         msg_print(_("気分が良くなってくる。", "You feel a little better."));
390                 }
391                 if (cast || cont) (void)cure_light_wounds(caster_ptr, 1, 10);
392                 break;
393
394         case 2:
395                 if (name) return _("悪魔のオーラ", "Demonic aura");
396                 if (desc) return _("炎のオーラを身にまとい、回復速度が速くなる。", "Gives fire aura and regeneration.");
397                 if (cast)
398                 {
399                         msg_print(_("体が炎のオーラで覆われた。", "You are enveloped by a fiery aura!"));
400                 }
401                 if (stop)
402                 {
403                         msg_print(_("炎のオーラが消え去った。", "The fiery aura disappeared."));
404                 }
405                 break;
406
407         case 3:
408                 if (name) return _("悪臭霧", "Stinking mist");
409                 if (desc) return _("視界内のモンスターに微弱量の毒のダメージを与える。", "Deals a little poison damage to all monsters in your sight.");
410                 power = plev / 2 + 5;
411                 if (info) return info_damage(1, power, 0);
412                 if (cast || cont)
413                 {
414                         project_all_los(caster_ptr, GF_POIS, randint1(power));
415                 }
416                 break;
417
418         case 4:
419                 if (name) return _("腕力強化", "Extra might");
420                 if (desc) return _("術者の腕力を上昇させる。", "Attempts to increase your strength.");
421                 if (cast)
422                 {
423                         msg_print(_("何だか力が湧いて来る。", "You feel stronger."));
424                 }
425                 break;
426
427         case 5:
428                 if (name) return _("武器呪縛", "Curse weapon");
429                 if (desc) return _("装備している武器を呪う。", "Curses your weapon.");
430                 if (cast)
431                 {
432                         OBJECT_IDX item;
433                         concptr q, s;
434                         GAME_TEXT o_name[MAX_NLEN];
435                         object_type *o_ptr;
436                         u32b f[TR_FLAG_SIZE];
437
438                         item_tester_hook = item_tester_hook_weapon_except_bow;
439                         q = _("どれを呪いますか?", "Which weapon do you curse?");
440                         s = _("武器を装備していない。", "You're not wielding a weapon.");
441
442                         o_ptr = choose_object(caster_ptr, &item, q, s, (USE_EQUIP), 0);
443                         if (!o_ptr) return FALSE;
444
445                         object_desc(caster_ptr, o_name, o_ptr, OD_NAME_ONLY);
446                         object_flags(o_ptr, f);
447
448                         if (!get_check(format(_("本当に %s を呪いますか?", "Do you curse %s, really?"), o_name))) return FALSE;
449
450                         if (!one_in_(3) &&
451                                 (object_is_artifact(o_ptr) || have_flag(f, TR_BLESSED)))
452                         {
453                                 msg_format(_("%s は呪いを跳ね返した。", "%s resists the effect."), o_name);
454                                 if (one_in_(3))
455                                 {
456                                         if (o_ptr->to_d > 0)
457                                         {
458                                                 o_ptr->to_d -= randint1(3) % 2;
459                                                 if (o_ptr->to_d < 0) o_ptr->to_d = 0;
460                                         }
461                                         if (o_ptr->to_h > 0)
462                                         {
463                                                 o_ptr->to_h -= randint1(3) % 2;
464                                                 if (o_ptr->to_h < 0) o_ptr->to_h = 0;
465                                         }
466                                         if (o_ptr->to_a > 0)
467                                         {
468                                                 o_ptr->to_a -= randint1(3) % 2;
469                                                 if (o_ptr->to_a < 0) o_ptr->to_a = 0;
470                                         }
471                                         msg_format(_("%s は劣化してしまった。", "Your %s was disenchanted!"), o_name);
472                                 }
473                         }
474                         else
475                         {
476                                 int curse_rank = 0;
477                                 msg_format(_("恐怖の暗黒オーラがあなたの%sを包み込んだ!", "A terrible black aura blasts your %s!"), o_name);
478                                 o_ptr->curse_flags |= (TRC_CURSED);
479
480                                 if (object_is_artifact(o_ptr) || object_is_ego(o_ptr))
481                                 {
482
483                                         if (one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
484                                         if (one_in_(666))
485                                         {
486                                                 o_ptr->curse_flags |= (TRC_TY_CURSE);
487                                                 if (one_in_(666)) o_ptr->curse_flags |= (TRC_PERMA_CURSE);
488
489                                                 add_flag(o_ptr->art_flags, TR_AGGRAVATE);
490                                                 add_flag(o_ptr->art_flags, TR_VORPAL);
491                                                 add_flag(o_ptr->art_flags, TR_VAMPIRIC);
492                                                 msg_print(_("血だ!血だ!血だ!", "Blood, Blood, Blood!"));
493                                                 curse_rank = 2;
494                                         }
495                                 }
496
497                                 o_ptr->curse_flags |= get_curse(curse_rank, o_ptr);
498                         }
499
500                         caster_ptr->update |= (PU_BONUS);
501                         add = FALSE;
502                 }
503                 break;
504
505         case 6:
506                 if (name) return _("邪悪感知", "Evil detection");
507                 if (desc) return _("周囲の邪悪なモンスターを感知する。", "Detects evil monsters.");
508                 if (info) return info_range(MAX_SIGHT);
509                 if (cast)
510                 {
511                         msg_print(_("邪悪な生物の存在を感じ取ろうとした。", "You sense the presence of evil creatures."));
512                 }
513                 break;
514
515         case 7:
516                 if (name) return _("我慢", "Patience");
517                 if (desc) return _("数ターン攻撃を耐えた後、受けたダメージを地獄の業火として周囲に放出する。",
518                 "Bursts hell fire strongly after enduring damage for a few turns.");
519                 power = MIN(200, (HEX_REVENGE_POWER(caster_ptr) * 2));
520                 if (info) return info_damage(0, 0, power);
521                 if (cast)
522                 {
523                         int a = 3 - (caster_ptr->pspeed - 100) / 10;
524                         MAGIC_NUM2 r = 3 + randint1(3) + MAX(0, MIN(3, a));
525
526                         if (HEX_REVENGE_TURN(caster_ptr) > 0)
527                         {
528                                 msg_print(_("すでに我慢をしている。", "You are already biding your time for vengeance."));
529                                 return NULL;
530                         }
531
532                         HEX_REVENGE_TYPE(caster_ptr) = 1;
533                         HEX_REVENGE_TURN(caster_ptr) = r;
534                         HEX_REVENGE_POWER(caster_ptr) = 0;
535                         msg_print(_("じっと耐えることにした。", "You decide to endure damage for future retribution."));
536                         add = FALSE;
537                 }
538                 if (cont)
539                 {
540                         POSITION rad = 2 + (power / 50);
541
542                         HEX_REVENGE_TURN(caster_ptr)--;
543
544                         if ((HEX_REVENGE_TURN(caster_ptr) <= 0) || (power >= 200))
545                         {
546                                 msg_print(_("我慢が解かれた!", "My patience is at an end!"));
547                                 if (power)
548                                 {
549                                         project(caster_ptr, 0, rad, caster_ptr->y, caster_ptr->x, power, GF_HELL_FIRE,
550                                                 (PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL), -1);
551                                 }
552                                 if (current_world_ptr->wizard)
553                                 {
554                                         msg_format(_("%d点のダメージを返した。", "You return %d damage."), power);
555                                 }
556
557                                 /* Reset */
558                                 HEX_REVENGE_TYPE(caster_ptr) = 0;
559                                 HEX_REVENGE_TURN(caster_ptr) = 0;
560                                 HEX_REVENGE_POWER(caster_ptr) = 0;
561                         }
562                 }
563                 break;
564
565                 /*** 2nd book (8-15) ***/
566         case 8:
567                 if (name) return _("氷の鎧", "Armor of ice");
568                 if (desc) return _("氷のオーラを身にまとい、防御力が上昇する。", "Surrounds you with an icy aura and gives a bonus to AC.");
569                 if (cast)
570                 {
571                         msg_print(_("体が氷の鎧で覆われた。", "You are enveloped by icy armor!"));
572                 }
573                 if (stop)
574                 {
575                         msg_print(_("氷の鎧が消え去った。", "The icy armor disappeared."));
576                 }
577                 break;
578
579         case 9:
580                 if (name) return _("重傷の治癒", "Cure serious wounds");
581                 if (desc) return _("体力や傷を多少回復させる。", "Heals cuts and HP.");
582                 if (info) return info_heal(2, 10, 0);
583                 if (cast)
584                 {
585                         msg_print(_("気分が良くなってくる。", "You feel better."));
586                 }
587                 if (cast || cont) (void)cure_serious_wounds(caster_ptr, 2, 10);
588                 break;
589
590         case 10:
591                 if (name) return _("薬品吸入", "Inhale potion");
592                 if (desc) return _("呪文詠唱を中止することなく、薬の効果を得ることができる。", "Quaffs a potion without canceling spell casting.");
593                 if (cast)
594                 {
595                         CASTING_HEX_FLAGS(caster_ptr) |= (1L << HEX_INHAIL);
596                         do_cmd_quaff_potion(caster_ptr);
597                         CASTING_HEX_FLAGS(caster_ptr) &= ~(1L << HEX_INHAIL);
598                         add = FALSE;
599                 }
600                 break;
601
602         case 11:
603                 if (name) return _("衰弱の霧", "Hypodynamic mist");
604                 if (desc) return _("視界内のモンスターに微弱量の衰弱属性のダメージを与える。",
605                         "Deals a little life-draining damage to all monsters in your sight.");
606                 power = (plev / 2) + 5;
607                 if (info) return info_damage(1, power, 0);
608                 if (cast || cont)
609                 {
610                         project_all_los(caster_ptr, GF_HYPODYNAMIA, randint1(power));
611                 }
612                 break;
613
614         case 12:
615                 if (name) return _("魔剣化", "Swords to runeswords");
616                 if (desc) return _("武器の攻撃力を上げる。切れ味を得、呪いに応じて与えるダメージが上昇し、善良なモンスターに対するダメージが2倍になる。",
617                         "Gives vorpal ability to your weapon. Increases damage from your weapon acccording to curse of your weapon.");
618                 if (cast)
619                 {
620 #ifdef JP
621                         msg_print("あなたの武器が黒く輝いた。");
622 #else
623                         if (!empty_hands(caster_ptr, FALSE))
624                                 msg_print("Your weapons glow bright black.");
625                         else
626                                 msg_print("Your weapon glows bright black.");
627 #endif
628                 }
629                 if (stop)
630                 {
631 #ifdef JP
632                         msg_print("武器の輝きが消え去った。");
633 #else
634                         msg_format("Your weapon%s.", (empty_hands(caster_ptr, FALSE)) ? " no longer glows" : "s no longer glow");
635 #endif
636                 }
637                 break;
638
639         case 13:
640                 if (name) return _("混乱の手", "Touch of confusion");
641                 if (desc) return _("攻撃した際モンスターを混乱させる。", "Confuses a monster when you attack.");
642                 if (cast)
643                 {
644                         msg_print(_("あなたの手が赤く輝き始めた。", "Your hands glow bright red."));
645                 }
646                 if (stop)
647                 {
648                         msg_print(_("手の輝きがなくなった。", "Your hands no longer glow."));
649                 }
650                 break;
651
652         case 14:
653                 if (name) return _("肉体強化", "Building up");
654                 if (desc) return _("術者の腕力、器用さ、耐久力を上昇させる。攻撃回数の上限を 1 増加させる。",
655                         "Attempts to increases your strength, dexterity and constitusion.");
656                 if (cast)
657                 {
658                         msg_print(_("身体が強くなった気がした。", "You feel your body is more developed now."));
659                 }
660                 break;
661
662         case 15:
663                 if (name) return _("反テレポート結界", "Anti teleport barrier");
664                 if (desc) return _("視界内のモンスターのテレポートを阻害するバリアを張る。", "Obstructs all teleportations by monsters in your sight.");
665                 power = plev * 3 / 2;
666                 if (info) return info_power(power);
667                 if (cast)
668                 {
669                         msg_print(_("テレポートを防ぐ呪いをかけた。", "You feel anyone can not teleport except you."));
670                 }
671                 break;
672
673                 /*** 3rd book (16-23) ***/
674         case 16:
675                 if (name) return _("衝撃のクローク", "Cloak of shock");
676                 if (desc) return _("電気のオーラを身にまとい、動きが速くなる。", "Gives lightning aura and a bonus to speed.");
677                 if (cast)
678                 {
679                         msg_print(_("体が稲妻のオーラで覆われた。", "You are enveloped by an electrical aura!"));
680                 }
681                 if (stop)
682                 {
683                         msg_print(_("稲妻のオーラが消え去った。", "The electrical aura disappeared."));
684                 }
685                 break;
686
687         case 17:
688                 if (name) return _("致命傷の治癒", "Cure critical wounds");
689                 if (desc) return _("体力や傷を回復させる。", "Heals cuts and HP greatly.");
690                 if (info) return info_heal(4, 10, 0);
691                 if (cast)
692                 {
693                         msg_print(_("気分が良くなってくる。", "You feel much better."));
694                 }
695                 if (cast || cont) (void)cure_critical_wounds(caster_ptr, damroll(4, 10));
696                 break;
697
698         case 18:
699                 if (name) return _("呪力封入", "Recharging");
700                 if (desc) return _("魔法の道具に魔力を再充填する。", "Recharges a magic device.");
701                 power = plev * 2;
702                 if (info) return info_power(power);
703                 if (cast)
704                 {
705                         if (!recharge(caster_ptr, power)) return NULL;
706                         add = FALSE;
707                 }
708                 break;
709
710         case 19:
711                 if (name) return _("死者復活", "Animate Dead");
712                 if (desc) return _("死体を蘇らせてペットにする。", "Raises corpses and skeletons from dead.");
713                 if (cast)
714                 {
715                         msg_print(_("死者への呼びかけを始めた。", "You start to call the dead.!"));
716                 }
717                 if (cast || cont)
718                 {
719                         animate_dead(caster_ptr, 0, caster_ptr->y, caster_ptr->x);
720                 }
721                 break;
722
723         case 20:
724                 if (name) return _("防具呪縛", "Curse armor");
725                 if (desc) return _("装備している防具に呪いをかける。", "Curse a piece of armour that you wielding.");
726                 if (cast)
727                 {
728                         OBJECT_IDX item;
729                         concptr q, s;
730                         GAME_TEXT o_name[MAX_NLEN];
731                         object_type *o_ptr;
732                         u32b f[TR_FLAG_SIZE];
733
734                         item_tester_hook = object_is_armour;
735                         q = _("どれを呪いますか?", "Which piece of armour do you curse?");
736                         s = _("防具を装備していない。", "You're not wearing any armor.");
737
738                         o_ptr = choose_object(caster_ptr, &item, q, s, (USE_EQUIP), 0);
739                         if (!o_ptr) return FALSE;
740
741                         o_ptr = &caster_ptr->inventory_list[item];
742                         object_desc(caster_ptr, o_name, o_ptr, OD_NAME_ONLY);
743                         object_flags(o_ptr, f);
744
745                         if (!get_check(format(_("本当に %s を呪いますか?", "Do you curse %s, really?"), o_name))) return FALSE;
746
747                         if (!one_in_(3) &&
748                                 (object_is_artifact(o_ptr) || have_flag(f, TR_BLESSED)))
749                         {
750                                 msg_format(_("%s は呪いを跳ね返した。", "%s resists the effect."), o_name);
751                                 if (one_in_(3))
752                                 {
753                                         if (o_ptr->to_d > 0)
754                                         {
755                                                 o_ptr->to_d -= randint1(3) % 2;
756                                                 if (o_ptr->to_d < 0) o_ptr->to_d = 0;
757                                         }
758                                         if (o_ptr->to_h > 0)
759                                         {
760                                                 o_ptr->to_h -= randint1(3) % 2;
761                                                 if (o_ptr->to_h < 0) o_ptr->to_h = 0;
762                                         }
763                                         if (o_ptr->to_a > 0)
764                                         {
765                                                 o_ptr->to_a -= randint1(3) % 2;
766                                                 if (o_ptr->to_a < 0) o_ptr->to_a = 0;
767                                         }
768                                         msg_format(_("%s は劣化してしまった。", "Your %s was disenchanted!"), o_name);
769                                 }
770                         }
771                         else
772                         {
773                                 int curse_rank = 0;
774                                 msg_format(_("恐怖の暗黒オーラがあなたの%sを包み込んだ!", "A terrible black aura blasts your %s!"), o_name);
775                                 o_ptr->curse_flags |= (TRC_CURSED);
776
777                                 if (object_is_artifact(o_ptr) || object_is_ego(o_ptr))
778                                 {
779
780                                         if (one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
781                                         if (one_in_(666))
782                                         {
783                                                 o_ptr->curse_flags |= (TRC_TY_CURSE);
784                                                 if (one_in_(666)) o_ptr->curse_flags |= (TRC_PERMA_CURSE);
785
786                                                 add_flag(o_ptr->art_flags, TR_AGGRAVATE);
787                                                 add_flag(o_ptr->art_flags, TR_RES_POIS);
788                                                 add_flag(o_ptr->art_flags, TR_RES_DARK);
789                                                 add_flag(o_ptr->art_flags, TR_RES_NETHER);
790                                                 msg_print(_("血だ!血だ!血だ!", "Blood, Blood, Blood!"));
791                                                 curse_rank = 2;
792                                         }
793                                 }
794
795                                 o_ptr->curse_flags |= get_curse(curse_rank, o_ptr);
796                         }
797
798                         caster_ptr->update |= (PU_BONUS);
799                         add = FALSE;
800                 }
801                 break;
802
803         case 21:
804                 if (name) return _("影のクローク", "Cloak of shadow");
805                 if (desc) return _("影のオーラを身にまとい、敵に影のダメージを与える。", "Gives aura of shadow.");
806                 if (cast)
807                 {
808                         object_type *o_ptr = &caster_ptr->inventory_list[INVEN_OUTER];
809
810                         if (!o_ptr->k_idx)
811                         {
812                                 msg_print(_("クロークを身につけていない!", "You are not wearing a cloak."));
813                                 return NULL;
814                         }
815                         else if (!object_is_cursed(o_ptr))
816                         {
817                                 msg_print(_("クロークは呪われていない!", "Your cloak is not cursed."));
818                                 return NULL;
819                         }
820                         else
821                         {
822                                 msg_print(_("影のオーラを身にまとった。", "You are enveloped by a shadowy aura!"));
823                         }
824                 }
825                 if (cont)
826                 {
827                         object_type *o_ptr = &caster_ptr->inventory_list[INVEN_OUTER];
828
829                         if ((!o_ptr->k_idx) || (!object_is_cursed(o_ptr)))
830                         {
831                                 exe_spell(caster_ptr, REALM_HEX, spell, SPELL_STOP);
832                                 CASTING_HEX_FLAGS(caster_ptr) &= ~(1L << spell);
833                                 CASTING_HEX_NUM(caster_ptr)--;
834                                 if (!SINGING_SONG_ID(caster_ptr)) set_action(caster_ptr, ACTION_NONE);
835                         }
836                 }
837                 if (stop)
838                 {
839                         msg_print(_("影のオーラが消え去った。", "The shadowy aura disappeared."));
840                 }
841                 break;
842
843         case 22:
844                 if (name) return _("苦痛を魔力に", "Pain to mana");
845                 if (desc) return _("視界内のモンスターに精神ダメージ与え、魔力を吸い取る。", "Deals psychic damage to all monsters in sight and drains some mana.");
846                 power = plev * 3 / 2;
847                 if (info) return info_damage(1, power, 0);
848                 if (cast || cont)
849                 {
850                         project_all_los(caster_ptr, GF_PSI_DRAIN, randint1(power));
851                 }
852                 break;
853
854         case 23:
855                 if (name) return _("目には目を", "Eye for an eye");
856                 if (desc) return _("打撃や魔法で受けたダメージを、攻撃元のモンスターにも与える。", "Returns same damage which you got to the monster which damaged you.");
857                 if (cast)
858                 {
859                         msg_print(_("復讐したい欲望にかられた。", "You feel very vengeful."));
860                 }
861                 break;
862
863                 /*** 4th book (24-31) ***/
864         case 24:
865                 if (name) return _("反増殖結界", "Anti multiply barrier");
866                 if (desc) return _("その階の増殖するモンスターの増殖を阻止する。", "Obstructs all multiplying by monsters in entire floor.");
867                 if (cast)
868                 {
869                         msg_print(_("増殖を阻止する呪いをかけた。", "You feel anyone can not already multiply."));
870                 }
871                 break;
872
873         case 25:
874                 if (name) return _("全復活", "Restoration");
875                 if (desc) return _("経験値を徐々に復活し、減少した能力値を回復させる。", "Restores experience and status.");
876                 if (cast)
877                 {
878                         msg_print(_("体が元の活力を取り戻し始めた。", "You feel your lost status starting to return."));
879                 }
880                 if (cast || cont)
881                 {
882                         bool flag = FALSE;
883                         int d = (caster_ptr->max_exp - caster_ptr->exp);
884                         int r = (caster_ptr->exp / 20);
885                         int i;
886
887                         if (d > 0)
888                         {
889                                 if (d < r)
890                                         caster_ptr->exp = caster_ptr->max_exp;
891                                 else
892                                         caster_ptr->exp += r;
893
894                                 /* Check the experience */
895                                 check_experience(caster_ptr);
896
897                                 flag = TRUE;
898                         }
899                         for (i = A_STR; i < A_MAX; i++)
900                         {
901                                 if (caster_ptr->stat_cur[i] < caster_ptr->stat_max[i])
902                                 {
903                                         if (caster_ptr->stat_cur[i] < 18)
904                                                 caster_ptr->stat_cur[i]++;
905                                         else
906                                                 caster_ptr->stat_cur[i] += 10;
907
908                                         if (caster_ptr->stat_cur[i] > caster_ptr->stat_max[i])
909                                                 caster_ptr->stat_cur[i] = caster_ptr->stat_max[i];
910                                         caster_ptr->update |= (PU_BONUS);
911
912                                         flag = TRUE;
913                                 }
914                         }
915
916                         if (!flag)
917                         {
918                                 msg_format(_("%sの呪文の詠唱をやめた。", "Finish casting '%^s'."), exe_spell(caster_ptr, REALM_HEX, HEX_RESTORE, SPELL_NAME));
919                                 CASTING_HEX_FLAGS(caster_ptr) &= ~(1L << HEX_RESTORE);
920                                 if (cont) CASTING_HEX_NUM(caster_ptr)--;
921                                 if (CASTING_HEX_NUM(caster_ptr)) caster_ptr->action = ACTION_NONE;
922
923                                 caster_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
924                                 caster_ptr->redraw |= (PR_EXTRA);
925
926                                 return "";
927                         }
928                 }
929                 break;
930
931         case 26:
932                 if (name) return _("呪力吸収", "Drain curse power");
933                 if (desc) return _("呪われた武器の呪いを吸収して魔力を回復する。", "Drains curse on your weapon and heals SP a little.");
934                 if (cast)
935                 {
936                         OBJECT_IDX item;
937                         concptr s, q;
938                         u32b f[TR_FLAG_SIZE];
939                         object_type *o_ptr;
940
941                         item_tester_hook = item_tester_hook_cursed;
942                         q = _("どの装備品から吸収しますか?", "Which cursed equipment do you drain mana from?");
943                         s = _("呪われたアイテムを装備していない。", "You have no cursed equipment.");
944
945                         o_ptr = choose_object(caster_ptr, &item, q, s, (USE_EQUIP), 0);
946                         if (!o_ptr) return FALSE;
947
948                         object_flags(o_ptr, f);
949
950                         caster_ptr->csp += (caster_ptr->lev / 5) + randint1(caster_ptr->lev / 5);
951                         if (have_flag(f, TR_TY_CURSE) || (o_ptr->curse_flags & TRC_TY_CURSE)) caster_ptr->csp += randint1(5);
952                         if (caster_ptr->csp > caster_ptr->msp) caster_ptr->csp = caster_ptr->msp;
953
954                         if (o_ptr->curse_flags & TRC_PERMA_CURSE)
955                         {
956                                 /* Nothing */
957                         }
958                         else if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
959                         {
960                                 if (one_in_(7))
961                                 {
962                                         msg_print(_("呪いを全て吸い取った。", "A heavy curse vanished."));
963                                         o_ptr->curse_flags = 0L;
964                                 }
965                         }
966                         else if ((o_ptr->curse_flags & (TRC_CURSED)) && one_in_(3))
967                         {
968                                 msg_print(_("呪いを全て吸い取った。", "A curse vanished."));
969                                 o_ptr->curse_flags = 0L;
970                         }
971
972                         add = FALSE;
973                 }
974                 break;
975
976         case 27:
977                 if (name) return _("吸血の刃", "Swords to vampires");
978                 if (desc) return _("吸血属性で攻撃する。", "Gives vampiric ability to your weapon.");
979                 if (cast)
980                 {
981 #ifdef JP
982                         msg_print("あなたの武器が血を欲している。");
983 #else
984                         if (!empty_hands(caster_ptr, FALSE))
985                                 msg_print("Your weapons want more blood now.");
986                         else
987                                 msg_print("Your weapon wants more blood now.");
988 #endif
989                 }
990                 if (stop)
991                 {
992 #ifdef JP
993                         msg_print("武器の渇望が消え去った。");
994 #else
995                         msg_format("Your weapon%s less thirsty now.", (empty_hands(caster_ptr, FALSE)) ? " is" : "s are");
996 #endif
997                 }
998                 break;
999
1000         case 28:
1001                 if (name) return _("朦朧の言葉", "Word of stun");
1002                 if (desc) return _("視界内のモンスターを朦朧とさせる。", "Stuns all monsters in your sight.");
1003                 power = plev * 4;
1004                 if (info) return info_power(power);
1005                 if (cast || cont)
1006                 {
1007                         stun_monsters(caster_ptr, power);
1008                 }
1009                 break;
1010
1011         case 29:
1012                 if (name) return _("影移動", "Moving into shadow");
1013                 if (desc) return _("モンスターの隣のマスに瞬間移動する。", "Teleports you close to a monster.");
1014                 if (cast)
1015                 {
1016                         int i, dir;
1017                         POSITION y, x;
1018                         bool flag;
1019
1020                         for (i = 0; i < 3; i++)
1021                         {
1022                                 if (!tgt_pt(caster_ptr, &x, &y)) return FALSE;
1023
1024                                 flag = FALSE;
1025
1026                                 for (dir = 0; dir < 8; dir++)
1027                                 {
1028                                         int dy = y + ddy_ddd[dir];
1029                                         int dx = x + ddx_ddd[dir];
1030                                         if (dir == 5) continue;
1031                                         if (caster_ptr->current_floor_ptr->grid_array[dy][dx].m_idx) flag = TRUE;
1032                                 }
1033
1034                                 if (!is_cave_empty_bold(caster_ptr, y, x) || (caster_ptr->current_floor_ptr->grid_array[y][x].info & CAVE_ICKY) ||
1035                                         (distance(y, x, caster_ptr->y, caster_ptr->x) > plev + 2))
1036                                 {
1037                                         msg_print(_("そこには移動できない。", "Can not teleport to there."));
1038                                         continue;
1039                                 }
1040                                 break;
1041                         }
1042
1043                         if (flag && randint0(plev * plev / 2))
1044                         {
1045                                 teleport_player_to(caster_ptr, y, x, TELEPORT_SPONTANEOUS);
1046                         }
1047                         else
1048                         {
1049                                 msg_print(_("おっと!", "Oops!"));
1050                                 teleport_player(caster_ptr, 30, TELEPORT_SPONTANEOUS);
1051                         }
1052
1053                         add = FALSE;
1054                 }
1055                 break;
1056
1057         case 30:
1058                 if (name) return _("反魔法結界", "Anti magic barrier");
1059                 if (desc) return _("視界内のモンスターの魔法を阻害するバリアを張る。", "Obstructs all magic spells of monsters in your sight.");
1060                 power = plev * 3 / 2;
1061                 if (info) return info_power(power);
1062                 if (cast)
1063                 {
1064                         msg_print(_("魔法を防ぐ呪いをかけた。", "You feel anyone can not cast spells except you."));
1065                 }
1066                 break;
1067
1068         case 31:
1069                 if (name) return _("復讐の宣告", "Revenge sentence");
1070                 if (desc) return _("数ターン後にそれまで受けたダメージに応じた威力の地獄の劫火の弾を放つ。",
1071                         "Fires a ball of hell fire to try avenging damage from a few turns.");
1072                 power = HEX_REVENGE_POWER(caster_ptr);
1073                 if (info) return info_damage(0, 0, power);
1074                 if (cast)
1075                 {
1076                         MAGIC_NUM2 r;
1077                         int a = 3 - (caster_ptr->pspeed - 100) / 10;
1078                         r = 1 + randint1(2) + MAX(0, MIN(3, a));
1079
1080                         if (HEX_REVENGE_TURN(caster_ptr) > 0)
1081                         {
1082                                 msg_print(_("すでに復讐は宣告済みだ。", "You've already declared your revenge."));
1083                                 return NULL;
1084                         }
1085
1086                         HEX_REVENGE_TYPE(caster_ptr) = 2;
1087                         HEX_REVENGE_TURN(caster_ptr) = r;
1088                         msg_format(_("あなたは復讐を宣告した。あと %d ターン。", "You declare your revenge. %d turns left."), r);
1089                         add = FALSE;
1090                 }
1091                 if (cont)
1092                 {
1093                         HEX_REVENGE_TURN(caster_ptr)--;
1094
1095                         if (HEX_REVENGE_TURN(caster_ptr) <= 0)
1096                         {
1097                                 DIRECTION dir;
1098
1099                                 if (power)
1100                                 {
1101                                         command_dir = 0;
1102
1103                                         do
1104                                         {
1105                                                 msg_print(_("復讐の時だ!", "Time for revenge!"));
1106                                         } while (!get_aim_dir(caster_ptr, &dir));
1107
1108                                         fire_ball(caster_ptr, GF_HELL_FIRE, dir, power, 1);
1109
1110                                         if (current_world_ptr->wizard)
1111                                         {
1112                                                 msg_format(_("%d点のダメージを返した。", "You return %d damage."), power);
1113                                         }
1114                                 }
1115                                 else
1116                                 {
1117                                         msg_print(_("復讐する気が失せた。", "You are not in the mood for revenge."));
1118                                 }
1119                                 HEX_REVENGE_POWER(caster_ptr) = 0;
1120                         }
1121                 }
1122                 break;
1123         }
1124
1125         /* start casting */
1126         if ((cast) && (add))
1127         {
1128                 /* add spell */
1129                 CASTING_HEX_FLAGS(caster_ptr) |= 1L << (spell);
1130                 CASTING_HEX_NUM(caster_ptr)++;
1131
1132                 if (caster_ptr->action != ACTION_SPELL) set_action(caster_ptr, ACTION_SPELL);
1133         }
1134
1135         if (!info)
1136         {
1137                 caster_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
1138                 caster_ptr->redraw |= (PR_EXTRA | PR_HP | PR_MANA);
1139         }
1140
1141         return "";
1142 }
1143
1144 bool hex_spelling(player_type *caster_ptr, int hex)
1145 {
1146         return (caster_ptr->realm1 == REALM_HEX) && (caster_ptr->magic_num1[0] & (1L << (hex)));
1147 }