OSDN Git Service

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