OSDN Git Service

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