OSDN Git Service

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