OSDN Git Service

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