OSDN Git Service

[Refactor] #37353 targeting.h を作成して 宣言を移動.
[hengband/hengband.git] / src / spells-object.c
1 
2 #include "angband.h"
3 #include "util.h"
4
5 #include "artifact.h"
6 #include "floor.h"
7 #include "grid.h"
8 #include "spells.h"
9 #include "spells-object.h"
10 #include "object-boost.h"
11 #include "object-hook.h"
12 #include "object-flavor.h"
13 #include "player-status.h"
14 #include "avatar.h"
15 #include "player-effects.h"
16 #include "player-class.h"
17 #include "objectkind.h"
18 #include "autopick.h"
19 #include "targeting.h"
20
21
22 typedef struct
23 {
24         OBJECT_TYPE_VALUE tval;
25         OBJECT_SUBTYPE_VALUE sval;
26         PERCENTAGE prob;
27         byte flag;
28 } amuse_type;
29
30 /*
31  * Scatter some "amusing" objects near the player
32  */
33
34 #define AMS_NOTHING   0x00 /* No restriction */
35 #define AMS_NO_UNIQUE 0x01 /* Don't make the amusing object of uniques */
36 #define AMS_FIXED_ART 0x02 /* Make a fixed artifact based on the amusing object */
37 #define AMS_MULTIPLE  0x04 /* Drop 1-3 objects for one type */
38 #define AMS_PILE      0x08 /* Drop 1-99 pile objects for one type */
39
40 static amuse_type amuse_info[] =
41 {
42         { TV_BOTTLE, SV_ANY, 5, AMS_NOTHING },
43         { TV_JUNK, SV_ANY, 3, AMS_MULTIPLE },
44         { TV_SPIKE, SV_ANY, 10, AMS_PILE },
45         { TV_STATUE, SV_ANY, 15, AMS_NOTHING },
46         { TV_CORPSE, SV_ANY, 15, AMS_NO_UNIQUE },
47         { TV_SKELETON, SV_ANY, 10, AMS_NO_UNIQUE },
48         { TV_FIGURINE, SV_ANY, 10, AMS_NO_UNIQUE },
49         { TV_PARCHMENT, SV_ANY, 1, AMS_NOTHING },
50         { TV_POLEARM, SV_TSURIZAO, 3, AMS_NOTHING }, //Fishing Pole of Taikobo
51         { TV_SWORD, SV_BROKEN_DAGGER, 3, AMS_FIXED_ART }, //Broken Dagger of Magician
52         { TV_SWORD, SV_BROKEN_DAGGER, 10, AMS_NOTHING },
53         { TV_SWORD, SV_BROKEN_SWORD, 5, AMS_NOTHING },
54         { TV_SCROLL, SV_SCROLL_AMUSEMENT, 10, AMS_NOTHING },
55
56         { 0, 0, 0 }
57 };
58
59 /*!
60  * @brief「弾/矢の製造」処理 / do_cmd_cast calls this function if the player's class is 'archer'.
61  * Hook to determine if an object is contertible in an arrow/bolt
62  * @return 製造を実際に行ったらTRUE、キャンセルしたらFALSEを返す
63  */
64 bool create_ammo(void)
65 {
66         int ext = 0;
67         char ch;
68
69         object_type     forge;
70         object_type *q_ptr;
71
72         char com[80];
73         GAME_TEXT o_name[MAX_NLEN];
74
75         q_ptr = &forge;
76
77         if (p_ptr->lev >= 20)
78                 sprintf(com, _("[S]弾, [A]矢, [B]クロスボウの矢 :", "Create [S]hots, Create [A]rrow or Create [B]olt ?"));
79         else if (p_ptr->lev >= 10)
80                 sprintf(com, _("[S]弾, [A]矢:", "Create [S]hots or Create [A]rrow ?"));
81         else
82                 sprintf(com, _("[S]弾:", "Create [S]hots ?"));
83
84         if (p_ptr->confused)
85         {
86                 msg_print(_("混乱してる!", "You are too confused!"));
87                 return FALSE;
88         }
89
90         if (p_ptr->blind)
91         {
92                 msg_print(_("目が見えない!", "You are blind!"));
93                 return FALSE;
94         }
95
96         while (TRUE)
97         {
98                 if (!get_com(com, &ch, TRUE))
99                 {
100                         return FALSE;
101                 }
102                 if (ch == 'S' || ch == 's')
103                 {
104                         ext = 1;
105                         break;
106                 }
107                 if ((ch == 'A' || ch == 'a') && (p_ptr->lev >= 10))
108                 {
109                         ext = 2;
110                         break;
111                 }
112                 if ((ch == 'B' || ch == 'b') && (p_ptr->lev >= 20))
113                 {
114                         ext = 3;
115                         break;
116                 }
117         }
118
119         /**********Create shots*********/
120         if (ext == 1)
121         {
122                 POSITION x, y;
123                 DIRECTION dir;
124                 grid_type *g_ptr;
125
126                 if (!get_rep_dir(&dir, FALSE)) return FALSE;
127                 y = p_ptr->y + ddy[dir];
128                 x = p_ptr->x + ddx[dir];
129                 g_ptr = &current_floor_ptr->grid_array[y][x];
130
131                 if (!have_flag(f_info[get_feat_mimic(g_ptr)].flags, FF_CAN_DIG))
132                 {
133                         msg_print(_("そこには岩石がない。", "You need pile of rubble."));
134                         return FALSE;
135                 }
136                 else if (!cave_have_flag_grid(g_ptr, FF_CAN_DIG) || !cave_have_flag_grid(g_ptr, FF_HURT_ROCK))
137                 {
138                         msg_print(_("硬すぎて崩せなかった。", "You failed to make ammo."));
139                 }
140                 else
141                 {
142                         s16b slot;
143                         q_ptr = &forge;
144
145                         /* Hack -- Give the player some small firestones */
146                         object_prep(q_ptr, lookup_kind(TV_SHOT, (OBJECT_SUBTYPE_VALUE)m_bonus(1, p_ptr->lev) + 1));
147                         q_ptr->number = (byte)rand_range(15, 30);
148                         object_aware(q_ptr);
149                         object_known(q_ptr);
150                         apply_magic(q_ptr, p_ptr->lev, AM_NO_FIXED_ART);
151                         q_ptr->discount = 99;
152
153                         slot = inven_carry(q_ptr);
154
155                         object_desc(o_name, q_ptr, 0);
156                         msg_format(_("%sを作った。", "You make some ammo."), o_name);
157
158                         /* Auto-inscription */
159                         if (slot >= 0) autopick_alter_item(slot, FALSE);
160
161                         /* Destroy the wall */
162                         cave_alter_feat(y, x, FF_HURT_ROCK);
163
164                         p_ptr->update |= (PU_FLOW);
165                 }
166         }
167         /**********Create arrows*********/
168         else if (ext == 2)
169         {
170                 OBJECT_IDX item;
171                 concptr q, s;
172                 s16b slot;
173
174                 item_tester_hook = item_tester_hook_convertible;
175
176                 q = _("どのアイテムから作りますか? ", "Convert which item? ");
177                 s = _("材料を持っていない。", "You have no item to convert.");
178                 q_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
179                 if (!q_ptr) return FALSE;
180
181                 q_ptr = &forge;
182
183                 /* Hack -- Give the player some small firestones */
184                 object_prep(q_ptr, lookup_kind(TV_ARROW, (OBJECT_SUBTYPE_VALUE)m_bonus(1, p_ptr->lev) + 1));
185                 q_ptr->number = (byte)rand_range(5, 10);
186                 object_aware(q_ptr);
187                 object_known(q_ptr);
188                 apply_magic(q_ptr, p_ptr->lev, AM_NO_FIXED_ART);
189
190                 q_ptr->discount = 99;
191
192                 object_desc(o_name, q_ptr, 0);
193                 msg_format(_("%sを作った。", "You make some ammo."), o_name);
194
195                 if (item >= 0)
196                 {
197                         inven_item_increase(item, -1);
198                         inven_item_describe(item);
199                         inven_item_optimize(item);
200                 }
201                 else
202                 {
203                         floor_item_increase(0 - item, -1);
204                         floor_item_describe(0 - item);
205                         floor_item_optimize(0 - item);
206                 }
207
208                 slot = inven_carry(q_ptr);
209
210                 /* Auto-inscription */
211                 if (slot >= 0) autopick_alter_item(slot, FALSE);
212         }
213         /**********Create bolts*********/
214         else if (ext == 3)
215         {
216                 OBJECT_IDX item;
217                 concptr q, s;
218                 s16b slot;
219
220                 item_tester_hook = item_tester_hook_convertible;
221
222                 q = _("どのアイテムから作りますか? ", "Convert which item? ");
223                 s = _("材料を持っていない。", "You have no item to convert.");
224
225                 q_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
226                 if (!q_ptr) return FALSE;
227
228                 q_ptr = &forge;
229
230                 /* Hack -- Give the player some small firestones */
231                 object_prep(q_ptr, lookup_kind(TV_BOLT, (OBJECT_SUBTYPE_VALUE)m_bonus(1, p_ptr->lev) + 1));
232                 q_ptr->number = (byte)rand_range(4, 8);
233                 object_aware(q_ptr);
234                 object_known(q_ptr);
235                 apply_magic(q_ptr, p_ptr->lev, AM_NO_FIXED_ART);
236
237                 q_ptr->discount = 99;
238
239                 object_desc(o_name, q_ptr, 0);
240                 msg_format(_("%sを作った。", "You make some ammo."), o_name);
241
242                 if (item >= 0)
243                 {
244                         inven_item_increase(item, -1);
245                         inven_item_describe(item);
246                         inven_item_optimize(item);
247                 }
248                 else
249                 {
250                         floor_item_increase(0 - item, -1);
251                         floor_item_describe(0 - item);
252                         floor_item_optimize(0 - item);
253                 }
254
255                 slot = inven_carry(q_ptr);
256
257                 /* Auto-inscription */
258                 if (slot >= 0) autopick_alter_item(slot, FALSE);
259         }
260         return TRUE;
261 }
262
263 /*!
264  * @brief 魔道具術師の魔力取り込み処理
265  * @return 取り込みを実行したらTRUE、キャンセルしたらFALSEを返す
266  */
267 bool import_magic_device(void)
268 {
269         OBJECT_IDX item;
270         PARAMETER_VALUE pval;
271         int ext = 0;
272         concptr q, s;
273         object_type *o_ptr;
274         GAME_TEXT o_name[MAX_NLEN];
275
276         /* Only accept legal items */
277         item_tester_hook = item_tester_hook_recharge;
278
279         q = _("どのアイテムの魔力を取り込みますか? ", "Gain power of which item? ");
280         s = _("魔力を取り込めるアイテムがない。", "You have nothing to gain power.");
281
282         o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
283         if (!o_ptr) return (FALSE);
284
285         if (o_ptr->tval == TV_STAFF && o_ptr->sval == SV_STAFF_NOTHING)
286         {
287                 msg_print(_("この杖には発動の為の能力は何も備わっていないようだ。", "This staff doesn't have any magical ability."));
288                 return FALSE;
289         }
290
291         if (!object_is_known(o_ptr))
292         {
293                 msg_print(_("鑑定されていないと取り込めない。", "You need to identify before absorbing."));
294                 return FALSE;
295         }
296
297         if (o_ptr->timeout)
298         {
299                 msg_print(_("充填中のアイテムは取り込めない。", "This item is still charging."));
300                 return FALSE;
301         }
302
303         pval = o_ptr->pval;
304         if (o_ptr->tval == TV_ROD)
305                 ext = 72;
306         else if (o_ptr->tval == TV_WAND)
307                 ext = 36;
308
309         if (o_ptr->tval == TV_ROD)
310         {
311                 p_ptr->magic_num2[o_ptr->sval + ext] += (MAGIC_NUM2)o_ptr->number;
312                 if (p_ptr->magic_num2[o_ptr->sval + ext] > 99) p_ptr->magic_num2[o_ptr->sval + ext] = 99;
313         }
314         else
315         {
316                 int num;
317                 for (num = o_ptr->number; num; num--)
318                 {
319                         int gain_num = pval;
320                         if (o_ptr->tval == TV_WAND) gain_num = (pval + num - 1) / num;
321                         if (p_ptr->magic_num2[o_ptr->sval + ext])
322                         {
323                                 gain_num *= 256;
324                                 gain_num = (gain_num / 3 + randint0(gain_num / 3)) / 256;
325                                 if (gain_num < 1) gain_num = 1;
326                         }
327                         p_ptr->magic_num2[o_ptr->sval + ext] += (MAGIC_NUM2)gain_num;
328                         if (p_ptr->magic_num2[o_ptr->sval + ext] > 99) p_ptr->magic_num2[o_ptr->sval + ext] = 99;
329                         p_ptr->magic_num1[o_ptr->sval + ext] += pval * 0x10000;
330                         if (p_ptr->magic_num1[o_ptr->sval + ext] > 99 * 0x10000) p_ptr->magic_num1[o_ptr->sval + ext] = 99 * 0x10000;
331                         if (p_ptr->magic_num1[o_ptr->sval + ext] > p_ptr->magic_num2[o_ptr->sval + ext] * 0x10000) p_ptr->magic_num1[o_ptr->sval + ext] = p_ptr->magic_num2[o_ptr->sval + ext] * 0x10000;
332                         if (o_ptr->tval == TV_WAND) pval -= (pval + num - 1) / num;
333                 }
334         }
335
336         object_desc(o_name, o_ptr, 0);
337         msg_format(_("%sの魔力を取り込んだ。", "You absorb magic of %s."), o_name);
338
339         /* Eliminate the item (from the pack) */
340         if (item >= 0)
341         {
342                 inven_item_increase(item, -999);
343                 inven_item_describe(item);
344                 inven_item_optimize(item);
345         }
346
347         /* Eliminate the item (from the floor) */
348         else
349         {
350                 floor_item_increase(0 - item, -999);
351                 floor_item_describe(0 - item);
352                 floor_item_optimize(0 - item);
353         }
354         take_turn(p_ptr, 100);
355         return TRUE;
356 }
357
358 /*!
359  * @brief 誰得ドロップを行う。
360  * @param y1 配置したいフロアのY座標
361  * @param x1 配置したいフロアのX座標
362  * @param num 誰得の処理回数
363  * @param known TRUEならばオブジェクトが必ず*鑑定*済になる
364  * @return なし
365  */
366 void amusement(POSITION y1, POSITION x1, int num, bool known)
367 {
368         object_type *i_ptr;
369         object_type object_type_body;
370         int n, t = 0;
371
372         for (n = 0; amuse_info[n].tval != 0; n++)
373         {
374                 t += amuse_info[n].prob;
375         }
376
377         /* Acquirement */
378         while (num)
379         {
380                 int i;
381                 KIND_OBJECT_IDX k_idx;
382                 ARTIFACT_IDX a_idx = 0;
383                 int r = randint0(t);
384                 bool insta_art, fixed_art;
385
386                 for (i = 0; ; i++)
387                 {
388                         r -= amuse_info[i].prob;
389                         if (r <= 0) break;
390                 }
391                 i_ptr = &object_type_body;
392                 object_wipe(i_ptr);
393                 k_idx = lookup_kind(amuse_info[i].tval, amuse_info[i].sval);
394
395                 /* Paranoia - reroll if nothing */
396                 if (!k_idx) continue;
397
398                 /* Search an artifact index if need */
399                 insta_art = (k_info[k_idx].gen_flags & TRG_INSTA_ART);
400                 fixed_art = (amuse_info[i].flag & AMS_FIXED_ART);
401
402                 if (insta_art || fixed_art)
403                 {
404                         for (a_idx = 1; a_idx < max_a_idx; a_idx++)
405                         {
406                                 if (insta_art && !(a_info[a_idx].gen_flags & TRG_INSTA_ART)) continue;
407                                 if (a_info[a_idx].tval != k_info[k_idx].tval) continue;
408                                 if (a_info[a_idx].sval != k_info[k_idx].sval) continue;
409                                 if (a_info[a_idx].cur_num > 0) continue;
410                                 break;
411                         }
412
413                         if (a_idx >= max_a_idx) continue;
414                 }
415
416                 /* Make an object (if possible) */
417                 object_prep(i_ptr, k_idx);
418                 if (a_idx) i_ptr->name1 = a_idx;
419                 apply_magic(i_ptr, 1, AM_NO_FIXED_ART);
420
421                 if (amuse_info[i].flag & AMS_NO_UNIQUE)
422                 {
423                         if (r_info[i_ptr->pval].flags1 & RF1_UNIQUE) continue;
424                 }
425
426                 if (amuse_info[i].flag & AMS_MULTIPLE) i_ptr->number = randint1(3);
427                 if (amuse_info[i].flag & AMS_PILE) i_ptr->number = randint1(99);
428
429                 if (known)
430                 {
431                         object_aware(i_ptr);
432                         object_known(i_ptr);
433                 }
434
435                 /* Paranoia - reroll if nothing */
436                 if (!(i_ptr->k_idx)) continue;
437
438                 (void)drop_near(i_ptr, -1, y1, x1);
439
440                 num--;
441         }
442 }
443
444
445
446 /*!
447  * @brief 獲得ドロップを行う。
448  * Scatter some "great" objects near the player
449  * @param y1 配置したいフロアのY座標
450  * @param x1 配置したいフロアのX座標
451  * @param num 獲得の処理回数
452  * @param great TRUEならば必ず高級品以上を落とす
453  * @param special TRUEならば必ず特別品を落とす
454  * @param known TRUEならばオブジェクトが必ず*鑑定*済になる
455  * @return なし
456  */
457 void acquirement(POSITION y1, POSITION x1, int num, bool great, bool special, bool known)
458 {
459         object_type *i_ptr;
460         object_type object_type_body;
461         BIT_FLAGS mode = AM_GOOD | (great || special ? AM_GREAT : 0L) | (special ? AM_SPECIAL : 0L);
462
463         /* Acquirement */
464         while (num--)
465         {
466                 i_ptr = &object_type_body;
467                 object_wipe(i_ptr);
468
469                 /* Make a good (or great) object (if possible) */
470                 if (!make_object(i_ptr, mode)) continue;
471
472                 if (known)
473                 {
474                         object_aware(i_ptr);
475                         object_known(i_ptr);
476                 }
477
478                 (void)drop_near(i_ptr, -1, y1, x1);
479         }
480 }
481
482 void acquire_chaos_weapon(player_type *creature_ptr)
483 {
484         object_type forge;
485         object_type *q_ptr = &forge;
486         OBJECT_TYPE_VALUE dummy = TV_SWORD;
487         OBJECT_SUBTYPE_VALUE dummy2;
488         switch (randint1(creature_ptr->lev))
489         {
490         case 0: case 1:
491                 dummy2 = SV_DAGGER;
492                 break;
493         case 2: case 3:
494                 dummy2 = SV_MAIN_GAUCHE;
495                 break;
496         case 4:
497                 dummy2 = SV_TANTO;
498                 break;
499         case 5: case 6:
500                 dummy2 = SV_RAPIER;
501                 break;
502         case 7: case 8:
503                 dummy2 = SV_SMALL_SWORD;
504                 break;
505         case 9: case 10:
506                 dummy2 = SV_BASILLARD;
507                 break;
508         case 11: case 12: case 13:
509                 dummy2 = SV_SHORT_SWORD;
510                 break;
511         case 14: case 15:
512                 dummy2 = SV_SABRE;
513                 break;
514         case 16: case 17:
515                 dummy2 = SV_CUTLASS;
516                 break;
517         case 18:
518                 dummy2 = SV_WAKIZASHI;
519                 break;
520         case 19:
521                 dummy2 = SV_KHOPESH;
522                 break;
523         case 20:
524                 dummy2 = SV_TULWAR;
525                 break;
526         case 21:
527                 dummy2 = SV_BROAD_SWORD;
528                 break;
529         case 22: case 23:
530                 dummy2 = SV_LONG_SWORD;
531                 break;
532         case 24: case 25:
533                 dummy2 = SV_SCIMITAR;
534                 break;
535         case 26:
536                 dummy2 = SV_NINJATO;
537                 break;
538         case 27:
539                 dummy2 = SV_KATANA;
540                 break;
541         case 28: case 29:
542                 dummy2 = SV_BASTARD_SWORD;
543                 break;
544         case 30:
545                 dummy2 = SV_GREAT_SCIMITAR;
546                 break;
547         case 31:
548                 dummy2 = SV_CLAYMORE;
549                 break;
550         case 32:
551                 dummy2 = SV_ESPADON;
552                 break;
553         case 33:
554                 dummy2 = SV_TWO_HANDED_SWORD;
555                 break;
556         case 34:
557                 dummy2 = SV_FLAMBERGE;
558                 break;
559         case 35:
560                 dummy2 = SV_NO_DACHI;
561                 break;
562         case 36:
563                 dummy2 = SV_EXECUTIONERS_SWORD;
564                 break;
565         case 37:
566                 dummy2 = SV_ZWEIHANDER;
567                 break;
568         case 38:
569                 dummy2 = SV_HAYABUSA;
570                 break;
571         default:
572                 dummy2 = SV_BLADE_OF_CHAOS;
573         }
574
575         object_prep(q_ptr, lookup_kind(dummy, dummy2));
576         q_ptr->to_h = 3 + randint1(current_floor_ptr->dun_level) % 10;
577         q_ptr->to_d = 3 + randint1(current_floor_ptr->dun_level) % 10;
578         one_resistance(q_ptr);
579         q_ptr->name2 = EGO_CHAOTIC;
580         (void)drop_near(q_ptr, -1, creature_ptr->y, creature_ptr->x);
581 }
582
583
584 /*!
585  * @brief 防具呪縛処理 /
586  * Curse the players armor
587  * @return 実際に呪縛されたらTRUEを返す
588  */
589 bool curse_armor(void)
590 {
591         int i;
592         object_type *o_ptr;
593
594         GAME_TEXT o_name[MAX_NLEN];
595
596         /* Curse the body armor */
597         o_ptr = &p_ptr->inventory_list[INVEN_BODY];
598
599         /* Nothing to curse */
600         if (!o_ptr->k_idx) return (FALSE);
601
602         object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
603
604         /* Attempt a saving throw for artifacts */
605         if (object_is_artifact(o_ptr) && (randint0(100) < 50))
606         {
607                 /* Cool */
608 #ifdef JP
609                 msg_format("%sが%sを包み込もうとしたが、%sはそれを跳ね返した!",
610                         "恐怖の暗黒オーラ", "防具", o_name);
611 #else
612                 msg_format("A %s tries to %s, but your %s resists the effects!",
613                         "terrible black aura", "surround your armor", o_name);
614 #endif
615
616         }
617
618         /* not artifact or failed save... */
619         else
620         {
621                 msg_format(_("恐怖の暗黒オーラがあなたの%sを包み込んだ!", "A terrible black aura blasts your %s!"), o_name);
622                 chg_virtue(V_ENCHANT, -5);
623
624                 /* Blast the armor */
625                 o_ptr->name1 = 0;
626                 o_ptr->name2 = EGO_BLASTED;
627                 o_ptr->to_a = 0 - randint1(5) - randint1(5);
628                 o_ptr->to_h = 0;
629                 o_ptr->to_d = 0;
630                 o_ptr->ac = 0;
631                 o_ptr->dd = 0;
632                 o_ptr->ds = 0;
633
634                 for (i = 0; i < TR_FLAG_SIZE; i++)
635                         o_ptr->art_flags[i] = 0;
636
637                 /* Curse it */
638                 o_ptr->curse_flags = TRC_CURSED;
639
640                 /* Break it */
641                 o_ptr->ident |= (IDENT_BROKEN);
642                 p_ptr->update |= (PU_BONUS | PU_MANA);
643                 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
644         }
645
646         return (TRUE);
647 }
648
649 /*!
650  * @brief 武器呪縛処理 /
651  * Curse the players weapon
652  * @param force 無条件に呪縛を行うならばTRUE
653  * @param o_ptr 呪縛する武器のアイテム情報参照ポインタ
654  * @return 実際に呪縛されたらTRUEを返す
655  */
656 bool curse_weapon_object(bool force, object_type *o_ptr)
657 {
658         int i;
659         GAME_TEXT o_name[MAX_NLEN];
660
661         /* Nothing to curse */
662         if (!o_ptr->k_idx) return (FALSE);
663         object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
664
665         /* Attempt a saving throw */
666         if (object_is_artifact(o_ptr) && (randint0(100) < 50) && !force)
667         {
668                 /* Cool */
669 #ifdef JP
670                 msg_format("%sが%sを包み込もうとしたが、%sはそれを跳ね返した!",
671                         "恐怖の暗黒オーラ", "武器", o_name);
672 #else
673                 msg_format("A %s tries to %s, but your %s resists the effects!",
674                         "terrible black aura", "surround your weapon", o_name);
675 #endif
676         }
677
678         /* not artifact or failed save... */
679         else
680         {
681                 if (!force) msg_format(_("恐怖の暗黒オーラがあなたの%sを包み込んだ!", "A terrible black aura blasts your %s!"), o_name);
682                 chg_virtue(V_ENCHANT, -5);
683
684                 /* Shatter the weapon */
685                 o_ptr->name1 = 0;
686                 o_ptr->name2 = EGO_SHATTERED;
687                 o_ptr->to_h = 0 - randint1(5) - randint1(5);
688                 o_ptr->to_d = 0 - randint1(5) - randint1(5);
689                 o_ptr->to_a = 0;
690                 o_ptr->ac = 0;
691                 o_ptr->dd = 0;
692                 o_ptr->ds = 0;
693
694                 for (i = 0; i < TR_FLAG_SIZE; i++)
695                         o_ptr->art_flags[i] = 0;
696
697                 /* Curse it */
698                 o_ptr->curse_flags = TRC_CURSED;
699
700                 /* Break it */
701                 o_ptr->ident |= (IDENT_BROKEN);
702                 p_ptr->update |= (PU_BONUS | PU_MANA);
703                 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
704         }
705
706         return (TRUE);
707 }
708
709 /*!
710  * @brief 武器呪縛処理のメインルーチン /
711  * Curse the players weapon
712  * @param force 無条件に呪縛を行うならばTRUE
713  * @param slot 呪縛する武器の装備スロット
714  * @return 実際に呪縛されたらTRUEを返す
715  */
716 bool curse_weapon(bool force, int slot)
717 {
718         return curse_weapon_object(force, &p_ptr->inventory_list[slot]);
719 }
720
721
722 /*!
723  * @brief 防具の錆止め防止処理
724  * @return ターン消費を要する処理を行ったならばTRUEを返す
725  */
726 bool rustproof(void)
727 {
728         OBJECT_IDX item;
729         object_type *o_ptr;
730         GAME_TEXT o_name[MAX_NLEN];
731         concptr q, s;
732
733         /* Select a piece of armour */
734         item_tester_hook = object_is_armour;
735
736         q = _("どの防具に錆止めをしますか?", "Rustproof which piece of armour? ");
737         s = _("錆止めできるものがありません。", "You have nothing to rustproof.");
738
739         o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
740         if (!o_ptr) return FALSE;
741
742         object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
743
744         add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
745
746         if ((o_ptr->to_a < 0) && !object_is_cursed(o_ptr))
747         {
748 #ifdef JP
749                 msg_format("%sは新品同様になった!", o_name);
750 #else
751                 msg_format("%s %s look%s as good as new!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
752 #endif
753
754                 o_ptr->to_a = 0;
755         }
756
757 #ifdef JP
758         msg_format("%sは腐食しなくなった。", o_name);
759 #else
760         msg_format("%s %s %s now protected against corrosion.", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "are" : "is"));
761 #endif
762
763         calc_android_exp();
764         return TRUE;
765 }
766
767 /*!
768  * @brief ボルトのエゴ化処理(火炎エゴのみ) /
769  * Enchant some bolts
770  * @return 常にTRUEを返す
771  */
772 bool brand_bolts(void)
773 {
774         int i;
775
776         /* Use the first acceptable bolts */
777         for (i = 0; i < INVEN_PACK; i++)
778         {
779                 object_type *o_ptr = &p_ptr->inventory_list[i];
780
781                 /* Skip non-bolts */
782                 if (o_ptr->tval != TV_BOLT) continue;
783
784                 /* Skip artifacts and ego-items */
785                 if (object_is_artifact(o_ptr) || object_is_ego(o_ptr))
786                         continue;
787
788                 /* Skip cursed/broken items */
789                 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) continue;
790
791                 /* Randomize */
792                 if (randint0(100) < 75) continue;
793
794                 msg_print(_("クロスボウの矢が炎のオーラに包まれた!", "Your bolts are covered in a fiery aura!"));
795
796                 /* Ego-item */
797                 o_ptr->name2 = EGO_FLAME;
798                 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
799                 return (TRUE);
800         }
801
802         if (flush_failure) flush();
803
804         /* Fail */
805         msg_print(_("炎で強化するのに失敗した。", "The fiery enchantment failed."));
806
807         return (TRUE);
808 }
809
810
811 bool perilous_secrets(player_type *creature_ptr)
812 {
813         if (!ident_spell(FALSE)) return FALSE;
814
815         if (mp_ptr->spell_book)
816         {
817                 /* Sufficient mana */
818                 if (20 <= creature_ptr->csp)
819                 {
820                         /* Use some mana */
821                         creature_ptr->csp -= 20;
822                 }
823
824                 /* Over-exert the player */
825                 else
826                 {
827                         int oops = 20 - creature_ptr->csp;
828
829                         /* No mana left */
830                         creature_ptr->csp = 0;
831                         creature_ptr->csp_frac = 0;
832
833                         msg_print(_("石を制御できない!", "You are too weak to control the stone!"));
834                         /* Hack -- Bypass free action */
835                         (void)set_paralyzed(creature_ptr->paralyzed + randint1(5 * oops + 1));
836
837                         /* Confusing. */
838                         (void)set_confused(creature_ptr->confused + randint1(5 * oops + 1));
839                 }
840                 creature_ptr->redraw |= (PR_MANA);
841         }
842         take_hit(DAMAGE_LOSELIFE, damroll(1, 12), _("危険な秘密", "perilous secrets"), -1);
843         /* Confusing. */
844         if (one_in_(5)) (void)set_confused(creature_ptr->confused + randint1(10));
845
846         /* Exercise a little care... */
847         if (one_in_(20)) take_hit(DAMAGE_LOSELIFE, damroll(4, 10), _("危険な秘密", "perilous secrets"), -1);
848         return TRUE;
849
850 }
851
852 /*!
853  * @brief 固定アーティファクト『ブラッディムーン』の特性を変更する。
854  * @details スレイ2d2種、及びone_resistance()による耐性1d2種、pval2種を得る。
855  * @param o_ptr 対象のオブジェクト構造体(ブラッディムーン)のポインタ
856  * @return なし
857  */
858 void get_bloody_moon_flags(object_type *o_ptr)
859 {
860         int dummy, i;
861
862         for (i = 0; i < TR_FLAG_SIZE; i++)
863                 o_ptr->art_flags[i] = a_info[ART_BLOOD].flags[i];
864
865         dummy = randint1(2) + randint1(2);
866         for (i = 0; i < dummy; i++)
867         {
868                 int flag = randint0(26);
869                 if (flag >= 20) add_flag(o_ptr->art_flags, TR_KILL_UNDEAD + flag - 20);
870                 else if (flag == 19) add_flag(o_ptr->art_flags, TR_KILL_ANIMAL);
871                 else if (flag == 18) add_flag(o_ptr->art_flags, TR_SLAY_HUMAN);
872                 else add_flag(o_ptr->art_flags, TR_CHAOTIC + flag);
873         }
874
875         dummy = randint1(2);
876         for (i = 0; i < dummy; i++) one_resistance(o_ptr);
877
878         for (i = 0; i < 2; i++)
879         {
880                 int tmp = randint0(11);
881                 if (tmp < A_MAX) add_flag(o_ptr->art_flags, TR_STR + tmp);
882                 else add_flag(o_ptr->art_flags, TR_STEALTH + tmp - 6);
883         }
884 }
885
886 /*!
887  * @brief 寿命つき光源の燃素追加処理 /
888  * Charge a lite (torch or latern)
889  * @return なし
890  */
891 void phlogiston(void)
892 {
893         GAME_TURN max_flog = 0;
894         object_type * o_ptr = &p_ptr->inventory_list[INVEN_LITE];
895
896         /* It's a lamp */
897         if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_LANTERN))
898         {
899                 max_flog = FUEL_LAMP;
900         }
901
902         /* It's a torch */
903         else if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
904         {
905                 max_flog = FUEL_TORCH;
906         }
907
908         /* No torch to refill */
909         else
910         {
911                 msg_print(_("燃素を消費するアイテムを装備していません。", "You are not wielding anything which uses phlogiston."));
912                 return;
913         }
914
915         if (o_ptr->xtra4 >= max_flog)
916         {
917                 msg_print(_("このアイテムにはこれ以上燃素を補充できません。", "No more phlogiston can be put in this item."));
918                 return;
919         }
920
921         /* Refuel */
922         o_ptr->xtra4 += (XTRA16)(max_flog / 2);
923         msg_print(_("照明用アイテムに燃素を補充した。", "You add phlogiston to your light item."));
924
925         if (o_ptr->xtra4 >= max_flog)
926         {
927                 o_ptr->xtra4 = (XTRA16)max_flog;
928                 msg_print(_("照明用アイテムは満タンになった。", "Your light item is full."));
929         }
930
931         p_ptr->update |= (PU_TORCH);
932 }
933
934 /*!
935  * @brief 武器の祝福処理 /
936  * Bless a weapon
937  * @return ターン消費を要する処理を行ったならばTRUEを返す
938  */
939 bool bless_weapon(void)
940 {
941         OBJECT_IDX item;
942         object_type *o_ptr;
943         BIT_FLAGS flgs[TR_FLAG_SIZE];
944         GAME_TEXT o_name[MAX_NLEN];
945         concptr q, s;
946
947         /* Bless only weapons */
948         item_tester_hook = object_is_weapon;
949
950         q = _("どのアイテムを祝福しますか?", "Bless which weapon? ");
951         s = _("祝福できる武器がありません。", "You have weapon to bless.");
952
953         o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
954         if (!o_ptr) return FALSE;
955
956         object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
957         object_flags(o_ptr, flgs);
958
959         if (object_is_cursed(o_ptr))
960         {
961                 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) ||
962                         have_flag(flgs, TR_ADD_L_CURSE) ||
963                         have_flag(flgs, TR_ADD_H_CURSE) ||
964                         (o_ptr->curse_flags & TRC_PERMA_CURSE))
965                 {
966 #ifdef JP
967                         msg_format("%sを覆う黒いオーラは祝福を跳ね返した!", o_name);
968 #else
969                         msg_format("The black aura on %s %s disrupts the blessing!", ((item >= 0) ? "your" : "the"), o_name);
970 #endif
971
972                         return TRUE;
973                 }
974
975 #ifdef JP
976                 msg_format("%s から邪悪なオーラが消えた。", o_name);
977 #else
978                 msg_format("A malignant aura leaves %s %s.", ((item >= 0) ? "your" : "the"), o_name);
979 #endif
980
981
982                 o_ptr->curse_flags = 0L;
983
984                 o_ptr->ident |= (IDENT_SENSE);
985                 o_ptr->feeling = FEEL_NONE;
986
987                 /* Recalculate the bonuses */
988                 p_ptr->update |= (PU_BONUS);
989                 p_ptr->window |= (PW_EQUIP);
990         }
991
992         /*
993          * Next, we try to bless it. Artifacts have a 1/3 chance of
994          * being blessed, otherwise, the operation simply disenchants
995          * them, godly power negating the magic. Ok, the explanation
996          * is silly, but otherwise priests would always bless every
997          * artifact weapon they find. Ego weapons and normal weapons
998          * can be blessed automatically.
999          */
1000         if (have_flag(flgs, TR_BLESSED))
1001         {
1002 #ifdef JP
1003                 msg_format("%s は既に祝福されている。", o_name);
1004 #else
1005                 msg_format("%s %s %s blessed already.",
1006                         ((item >= 0) ? "Your" : "The"), o_name,
1007                         ((o_ptr->number > 1) ? "were" : "was"));
1008 #endif
1009
1010                 return TRUE;
1011         }
1012
1013         if (!(object_is_artifact(o_ptr) || object_is_ego(o_ptr)) || one_in_(3))
1014         {
1015 #ifdef JP
1016                 msg_format("%sは輝いた!", o_name);
1017 #else
1018                 msg_format("%s %s shine%s!",
1019                         ((item >= 0) ? "Your" : "The"), o_name,
1020                         ((o_ptr->number > 1) ? "" : "s"));
1021 #endif
1022
1023                 add_flag(o_ptr->art_flags, TR_BLESSED);
1024                 o_ptr->discount = 99;
1025         }
1026         else
1027         {
1028                 bool dis_happened = FALSE;
1029                 msg_print(_("その武器は祝福を嫌っている!", "The weapon resists your blessing!"));
1030
1031                 /* Disenchant tohit */
1032                 if (o_ptr->to_h > 0)
1033                 {
1034                         o_ptr->to_h--;
1035                         dis_happened = TRUE;
1036                 }
1037
1038                 if ((o_ptr->to_h > 5) && (randint0(100) < 33)) o_ptr->to_h--;
1039
1040                 /* Disenchant todam */
1041                 if (o_ptr->to_d > 0)
1042                 {
1043                         o_ptr->to_d--;
1044                         dis_happened = TRUE;
1045                 }
1046
1047                 if ((o_ptr->to_d > 5) && (randint0(100) < 33)) o_ptr->to_d--;
1048
1049                 /* Disenchant toac */
1050                 if (o_ptr->to_a > 0)
1051                 {
1052                         o_ptr->to_a--;
1053                         dis_happened = TRUE;
1054                 }
1055
1056                 if ((o_ptr->to_a > 5) && (randint0(100) < 33)) o_ptr->to_a--;
1057
1058                 if (dis_happened)
1059                 {
1060                         msg_print(_("周囲が凡庸な雰囲気で満ちた...", "There is a static feeling in the air..."));
1061
1062 #ifdef JP
1063                         msg_format("%s は劣化した!", o_name);
1064 #else
1065                         msg_format("%s %s %s disenchanted!", ((item >= 0) ? "Your" : "The"), o_name,
1066                                 ((o_ptr->number > 1) ? "were" : "was"));
1067 #endif
1068
1069                 }
1070         }
1071
1072         p_ptr->update |= (PU_BONUS);
1073         p_ptr->window |= (PW_EQUIP | PW_PLAYER);
1074         calc_android_exp();
1075
1076         return TRUE;
1077 }
1078
1079
1080 /*!
1081  * @brief 盾磨き処理 /
1082  * pulish shield
1083  * @return ターン消費を要する処理を行ったならばTRUEを返す
1084  */
1085 bool pulish_shield(void)
1086 {
1087         OBJECT_IDX item;
1088         object_type *o_ptr;
1089         BIT_FLAGS flgs[TR_FLAG_SIZE];
1090         GAME_TEXT o_name[MAX_NLEN];
1091         concptr            q, s;
1092
1093         /* Assume enchant weapon */
1094         item_tester_tval = TV_SHIELD;
1095
1096         q = _("どの盾を磨きますか?", "Pulish which weapon? ");
1097         s = _("磨く盾がありません。", "You have weapon to pulish.");
1098
1099         o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
1100         if (!o_ptr) return FALSE;
1101
1102         object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1103         object_flags(o_ptr, flgs);
1104
1105         if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
1106                 !object_is_cursed(o_ptr) && (o_ptr->sval != SV_MIRROR_SHIELD))
1107         {
1108 #ifdef JP
1109                 msg_format("%sは輝いた!", o_name);
1110 #else
1111                 msg_format("%s %s shine%s!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
1112 #endif
1113                 o_ptr->name2 = EGO_REFLECTION;
1114                 enchant(o_ptr, randint0(3) + 4, ENCH_TOAC);
1115
1116                 o_ptr->discount = 99;
1117                 chg_virtue(V_ENCHANT, 2);
1118
1119                 return TRUE;
1120         }
1121         else
1122         {
1123                 if (flush_failure) flush();
1124
1125                 msg_print(_("失敗した。", "Failed."));
1126                 chg_virtue(V_ENCHANT, -2);
1127         }
1128         calc_android_exp();
1129
1130         return FALSE;
1131 }