OSDN Git Service

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