OSDN Git Service

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