OSDN Git Service

[Refactor] #38997 アイテム増減処理の大半を vary_item() に統合. / Unify some item increase and decrea...
[hengband/hengband.git] / src / spells-object.c
1 
2 #include "angband.h"
3 #include "util.h"
4
5 #include "cmd-basic.h"
6 #include "artifact.h"
7 #include "floor.h"
8 #include "grid.h"
9 #include "spells.h"
10 #include "spells-object.h"
11 #include "object-boost.h"
12 #include "object-hook.h"
13 #include "object-flavor.h"
14 #include "object-ego.h"
15 #include "player-damage.h"
16 #include "player-status.h"
17 #include "avatar.h"
18 #include "player-effects.h"
19 #include "player-class.h"
20 #include "player-inventory.h"
21 #include "objectkind.h"
22 #include "autopick.h"
23 #include "targeting.h"
24 #include "view-mainwindow.h"
25
26
27 typedef struct
28 {
29         OBJECT_TYPE_VALUE tval;
30         OBJECT_SUBTYPE_VALUE sval;
31         PERCENTAGE prob;
32         byte flag;
33 } amuse_type;
34
35
36 /*!
37  * @brief 装備強化処理の失敗率定数(千分率) /
38  * Used by the "enchant" function (chance of failure)
39  * (modified for Zangband, we need better stuff there...) -- TY
40  * @return なし
41  */
42 static int enchant_table[16] =
43 {
44         0, 10,  50, 100, 200,
45         300, 400, 500, 650, 800,
46         950, 987, 993, 995, 998,
47         1000
48 };
49
50
51 /*
52  * Scatter some "amusing" objects near the player
53  */
54
55 #define AMS_NOTHING   0x00 /* No restriction */
56 #define AMS_NO_UNIQUE 0x01 /* Don't make the amusing object of uniques */
57 #define AMS_FIXED_ART 0x02 /* Make a fixed artifact based on the amusing object */
58 #define AMS_MULTIPLE  0x04 /* Drop 1-3 objects for one type */
59 #define AMS_PILE      0x08 /* Drop 1-99 pile objects for one type */
60
61 static amuse_type amuse_info[] =
62 {
63         { TV_BOTTLE, SV_ANY, 5, AMS_NOTHING },
64         { TV_JUNK, SV_ANY, 3, AMS_MULTIPLE },
65         { TV_SPIKE, SV_ANY, 10, AMS_PILE },
66         { TV_STATUE, SV_ANY, 15, AMS_NOTHING },
67         { TV_CORPSE, SV_ANY, 15, AMS_NO_UNIQUE },
68         { TV_SKELETON, SV_ANY, 10, AMS_NO_UNIQUE },
69         { TV_FIGURINE, SV_ANY, 10, AMS_NO_UNIQUE },
70         { TV_PARCHMENT, SV_ANY, 1, AMS_NOTHING },
71         { TV_POLEARM, SV_TSURIZAO, 3, AMS_NOTHING }, //Fishing Pole of Taikobo
72         { TV_SWORD, SV_BROKEN_DAGGER, 3, AMS_FIXED_ART }, //Broken Dagger of Magician
73         { TV_SWORD, SV_BROKEN_DAGGER, 10, AMS_NOTHING },
74         { TV_SWORD, SV_BROKEN_SWORD, 5, AMS_NOTHING },
75         { TV_SCROLL, SV_SCROLL_AMUSEMENT, 10, AMS_NOTHING },
76
77         { 0, 0, 0 }
78 };
79
80 /*!
81  * @brief「弾/矢の製造」処理 / do_cmd_cast calls this function if the player's class is 'archer'.
82  * Hook to determine if an object is contertible in an arrow/bolt
83  * @return 製造を実際に行ったらTRUE、キャンセルしたらFALSEを返す
84  */
85 bool create_ammo(player_type *creature_ptr)
86 {
87         int ext = 0;
88         char ch;
89
90         object_type     forge;
91         object_type *q_ptr;
92
93         char com[80];
94         GAME_TEXT o_name[MAX_NLEN];
95
96         q_ptr = &forge;
97
98         if (creature_ptr->lev >= 20)
99                 sprintf(com, _("[S]弾, [A]矢, [B]クロスボウの矢 :", "Create [S]hots, Create [A]rrow or Create [B]olt ?"));
100         else if (creature_ptr->lev >= 10)
101                 sprintf(com, _("[S]弾, [A]矢:", "Create [S]hots or Create [A]rrow ?"));
102         else
103                 sprintf(com, _("[S]弾:", "Create [S]hots ?"));
104
105         if (cmd_limit_confused(creature_ptr)) return FALSE;
106         if (cmd_limit_blind(creature_ptr)) return FALSE;
107
108         while (TRUE)
109         {
110                 if (!get_com(com, &ch, TRUE))
111                 {
112                         return FALSE;
113                 }
114                 if (ch == 'S' || ch == 's')
115                 {
116                         ext = 1;
117                         break;
118                 }
119                 if ((ch == 'A' || ch == 'a') && (creature_ptr->lev >= 10))
120                 {
121                         ext = 2;
122                         break;
123                 }
124                 if ((ch == 'B' || ch == 'b') && (creature_ptr->lev >= 20))
125                 {
126                         ext = 3;
127                         break;
128                 }
129         }
130
131         /**********Create shots*********/
132         if (ext == 1)
133         {
134                 POSITION x, y;
135                 DIRECTION dir;
136                 grid_type *g_ptr;
137
138                 if (!get_rep_dir(&dir, FALSE)) return FALSE;
139                 y = creature_ptr->y + ddy[dir];
140                 x = creature_ptr->x + ddx[dir];
141                 g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
142
143                 if (!have_flag(f_info[get_feat_mimic(g_ptr)].flags, FF_CAN_DIG))
144                 {
145                         msg_print(_("そこには岩石がない。", "You need pile of rubble."));
146                         return FALSE;
147                 }
148                 else if (!cave_have_flag_grid(g_ptr, FF_CAN_DIG) || !cave_have_flag_grid(g_ptr, FF_HURT_ROCK))
149                 {
150                         msg_print(_("硬すぎて崩せなかった。", "You failed to make ammo."));
151                 }
152                 else
153                 {
154                         s16b slot;
155                         q_ptr = &forge;
156
157                         /* Hack -- Give the player some small firestones */
158                         object_prep(q_ptr, lookup_kind(TV_SHOT, (OBJECT_SUBTYPE_VALUE)m_bonus(1, creature_ptr->lev) + 1));
159                         q_ptr->number = (byte)rand_range(15, 30);
160                         object_aware(q_ptr);
161                         object_known(q_ptr);
162                         apply_magic(q_ptr, creature_ptr->lev, AM_NO_FIXED_ART);
163                         q_ptr->discount = 99;
164
165                         slot = inven_carry(q_ptr);
166
167                         object_desc(o_name, q_ptr, 0);
168                         msg_format(_("%sを作った。", "You make some ammo."), o_name);
169
170                         /* Auto-inscription */
171                         if (slot >= 0) autopick_alter_item(slot, FALSE);
172
173                         /* Destroy the wall */
174                         cave_alter_feat(y, x, FF_HURT_ROCK);
175
176                         creature_ptr->update |= (PU_FLOW);
177                 }
178         }
179         /**********Create arrows*********/
180         else if (ext == 2)
181         {
182                 OBJECT_IDX item;
183                 concptr q, s;
184                 s16b slot;
185
186                 item_tester_hook = item_tester_hook_convertible;
187
188                 q = _("どのアイテムから作りますか? ", "Convert which item? ");
189                 s = _("材料を持っていない。", "You have no item to convert.");
190                 q_ptr = choose_object(creature_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), 0);
191                 if (!q_ptr) return FALSE;
192
193                 q_ptr = &forge;
194
195                 /* Hack -- Give the player some small firestones */
196                 object_prep(q_ptr, lookup_kind(TV_ARROW, (OBJECT_SUBTYPE_VALUE)m_bonus(1, creature_ptr->lev) + 1));
197                 q_ptr->number = (byte)rand_range(5, 10);
198                 object_aware(q_ptr);
199                 object_known(q_ptr);
200                 apply_magic(q_ptr, creature_ptr->lev, AM_NO_FIXED_ART);
201
202                 q_ptr->discount = 99;
203
204                 object_desc(o_name, q_ptr, 0);
205                 msg_format(_("%sを作った。", "You make some ammo."), o_name);
206
207                 vary_item(item, -1);
208                 slot = inven_carry(q_ptr);
209
210                 /* Auto-inscription */
211                 if (slot >= 0) autopick_alter_item(slot, FALSE);
212         }
213         /**********Create bolts*********/
214         else if (ext == 3)
215         {
216                 OBJECT_IDX item;
217                 concptr q, s;
218                 s16b slot;
219
220                 item_tester_hook = item_tester_hook_convertible;
221
222                 q = _("どのアイテムから作りますか? ", "Convert which item? ");
223                 s = _("材料を持っていない。", "You have no item to convert.");
224
225                 q_ptr = choose_object(creature_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), 0);
226                 if (!q_ptr) return FALSE;
227
228                 q_ptr = &forge;
229
230                 /* Hack -- Give the player some small firestones */
231                 object_prep(q_ptr, lookup_kind(TV_BOLT, (OBJECT_SUBTYPE_VALUE)m_bonus(1, creature_ptr->lev) + 1));
232                 q_ptr->number = (byte)rand_range(4, 8);
233                 object_aware(q_ptr);
234                 object_known(q_ptr);
235                 apply_magic(q_ptr, creature_ptr->lev, AM_NO_FIXED_ART);
236
237                 q_ptr->discount = 99;
238
239                 object_desc(o_name, q_ptr, 0);
240                 msg_format(_("%sを作った。", "You make some ammo."), o_name);
241
242                 vary_item(item, -1);
243
244                 slot = inven_carry(q_ptr);
245
246                 /* Auto-inscription */
247                 if (slot >= 0) autopick_alter_item(slot, FALSE);
248         }
249         return TRUE;
250 }
251
252 /*!
253  * @brief 魔道具術師の魔力取り込み処理
254  * @param user_ptr アイテムを取り込むクリーチャー
255  * @return 取り込みを実行したらTRUE、キャンセルしたらFALSEを返す
256  */
257 bool import_magic_device(player_type *user_ptr)
258 {
259         OBJECT_IDX item;
260         PARAMETER_VALUE pval;
261         int ext = 0;
262         concptr q, s;
263         object_type *o_ptr;
264         GAME_TEXT o_name[MAX_NLEN];
265
266         /* Only accept legal items */
267         item_tester_hook = item_tester_hook_recharge;
268
269         q = _("どのアイテムの魔力を取り込みますか? ", "Gain power of which item? ");
270         s = _("魔力を取り込めるアイテムがない。", "You have nothing to gain power.");
271
272         o_ptr = choose_object(user_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), 0);
273         if (!o_ptr) return (FALSE);
274
275         if (o_ptr->tval == TV_STAFF && o_ptr->sval == SV_STAFF_NOTHING)
276         {
277                 msg_print(_("この杖には発動の為の能力は何も備わっていないようだ。", "This staff doesn't have any magical ability."));
278                 return FALSE;
279         }
280
281         if (!object_is_known(o_ptr))
282         {
283                 msg_print(_("鑑定されていないと取り込めない。", "You need to identify before absorbing."));
284                 return FALSE;
285         }
286
287         if (o_ptr->timeout)
288         {
289                 msg_print(_("充填中のアイテムは取り込めない。", "This item is still charging."));
290                 return FALSE;
291         }
292
293         pval = o_ptr->pval;
294         if (o_ptr->tval == TV_ROD)
295                 ext = 72;
296         else if (o_ptr->tval == TV_WAND)
297                 ext = 36;
298
299         if (o_ptr->tval == TV_ROD)
300         {
301                 user_ptr->magic_num2[o_ptr->sval + ext] += (MAGIC_NUM2)o_ptr->number;
302                 if (user_ptr->magic_num2[o_ptr->sval + ext] > 99) user_ptr->magic_num2[o_ptr->sval + ext] = 99;
303         }
304         else
305         {
306                 int num;
307                 for (num = o_ptr->number; num; num--)
308                 {
309                         int gain_num = pval;
310                         if (o_ptr->tval == TV_WAND) gain_num = (pval + num - 1) / num;
311                         if (user_ptr->magic_num2[o_ptr->sval + ext])
312                         {
313                                 gain_num *= 256;
314                                 gain_num = (gain_num / 3 + randint0(gain_num / 3)) / 256;
315                                 if (gain_num < 1) gain_num = 1;
316                         }
317                         user_ptr->magic_num2[o_ptr->sval + ext] += (MAGIC_NUM2)gain_num;
318                         if (user_ptr->magic_num2[o_ptr->sval + ext] > 99) user_ptr->magic_num2[o_ptr->sval + ext] = 99;
319                         user_ptr->magic_num1[o_ptr->sval + ext] += pval * 0x10000;
320                         if (user_ptr->magic_num1[o_ptr->sval + ext] > 99 * 0x10000) user_ptr->magic_num1[o_ptr->sval + ext] = 99 * 0x10000;
321                         if (user_ptr->magic_num1[o_ptr->sval + ext] > user_ptr->magic_num2[o_ptr->sval + ext] * 0x10000) user_ptr->magic_num1[o_ptr->sval + ext] = user_ptr->magic_num2[o_ptr->sval + ext] * 0x10000;
322                         if (o_ptr->tval == TV_WAND) pval -= (pval + num - 1) / num;
323                 }
324         }
325
326         object_desc(o_name, o_ptr, 0);
327         msg_format(_("%sの魔力を取り込んだ。", "You absorb magic of %s."), o_name);
328
329         vary_item(item, -999);
330         take_turn(user_ptr, 100);
331         return TRUE;
332 }
333
334 /*!
335  * @brief 誰得ドロップを行う。
336  * @param y1 配置したいフロアのY座標
337  * @param x1 配置したいフロアのX座標
338  * @param num 誰得の処理回数
339  * @param known TRUEならばオブジェクトが必ず*鑑定*済になる
340  * @return なし
341  */
342 void amusement(POSITION y1, POSITION x1, int num, bool known)
343 {
344         object_type *i_ptr;
345         object_type object_type_body;
346         int n, t = 0;
347
348         for (n = 0; amuse_info[n].tval != 0; n++)
349         {
350                 t += amuse_info[n].prob;
351         }
352
353         /* Acquirement */
354         while (num)
355         {
356                 int i;
357                 KIND_OBJECT_IDX k_idx;
358                 ARTIFACT_IDX a_idx = 0;
359                 int r = randint0(t);
360                 bool insta_art, fixed_art;
361
362                 for (i = 0; ; i++)
363                 {
364                         r -= amuse_info[i].prob;
365                         if (r <= 0) break;
366                 }
367                 i_ptr = &object_type_body;
368                 object_wipe(i_ptr);
369                 k_idx = lookup_kind(amuse_info[i].tval, amuse_info[i].sval);
370
371                 /* Paranoia - reroll if nothing */
372                 if (!k_idx) continue;
373
374                 /* Search an artifact index if need */
375                 insta_art = (k_info[k_idx].gen_flags & TRG_INSTA_ART);
376                 fixed_art = (amuse_info[i].flag & AMS_FIXED_ART);
377
378                 if (insta_art || fixed_art)
379                 {
380                         for (a_idx = 1; a_idx < max_a_idx; a_idx++)
381                         {
382                                 if (insta_art && !(a_info[a_idx].gen_flags & TRG_INSTA_ART)) continue;
383                                 if (a_info[a_idx].tval != k_info[k_idx].tval) continue;
384                                 if (a_info[a_idx].sval != k_info[k_idx].sval) continue;
385                                 if (a_info[a_idx].cur_num > 0) continue;
386                                 break;
387                         }
388
389                         if (a_idx >= max_a_idx) continue;
390                 }
391
392                 /* Make an object (if possible) */
393                 object_prep(i_ptr, k_idx);
394                 if (a_idx) i_ptr->name1 = a_idx;
395                 apply_magic(i_ptr, 1, AM_NO_FIXED_ART);
396
397                 if (amuse_info[i].flag & AMS_NO_UNIQUE)
398                 {
399                         if (r_info[i_ptr->pval].flags1 & RF1_UNIQUE) continue;
400                 }
401
402                 if (amuse_info[i].flag & AMS_MULTIPLE) i_ptr->number = randint1(3);
403                 if (amuse_info[i].flag & AMS_PILE) i_ptr->number = randint1(99);
404
405                 if (known)
406                 {
407                         object_aware(i_ptr);
408                         object_known(i_ptr);
409                 }
410
411                 /* Paranoia - reroll if nothing */
412                 if (!(i_ptr->k_idx)) continue;
413
414                 (void)drop_near(i_ptr, -1, y1, x1);
415
416                 num--;
417         }
418 }
419
420
421
422 /*!
423  * @brief 獲得ドロップを行う。
424  * Scatter some "great" objects near the player
425  * @param y1 配置したいフロアのY座標
426  * @param x1 配置したいフロアのX座標
427  * @param num 獲得の処理回数
428  * @param great TRUEならば必ず高級品以上を落とす
429  * @param special TRUEならば必ず特別品を落とす
430  * @param known TRUEならばオブジェクトが必ず*鑑定*済になる
431  * @return なし
432  */
433 void acquirement(POSITION y1, POSITION x1, int num, bool great, bool special, bool known)
434 {
435         object_type *i_ptr;
436         object_type object_type_body;
437         BIT_FLAGS mode = AM_GOOD | (great || special ? AM_GREAT : 0L) | (special ? AM_SPECIAL : 0L);
438
439         /* Acquirement */
440         while (num--)
441         {
442                 i_ptr = &object_type_body;
443                 object_wipe(i_ptr);
444
445                 /* Make a good (or great) object (if possible) */
446                 if (!make_object(i_ptr, mode)) continue;
447
448                 if (known)
449                 {
450                         object_aware(i_ptr);
451                         object_known(i_ptr);
452                 }
453
454                 (void)drop_near(i_ptr, -1, y1, x1);
455         }
456 }
457
458 void acquire_chaos_weapon(player_type *creature_ptr)
459 {
460         object_type forge;
461         object_type *q_ptr = &forge;
462         OBJECT_TYPE_VALUE dummy = TV_SWORD;
463         OBJECT_SUBTYPE_VALUE dummy2;
464         switch (randint1(creature_ptr->lev))
465         {
466         case 0: case 1:
467                 dummy2 = SV_DAGGER;
468                 break;
469         case 2: case 3:
470                 dummy2 = SV_MAIN_GAUCHE;
471                 break;
472         case 4:
473                 dummy2 = SV_TANTO;
474                 break;
475         case 5: case 6:
476                 dummy2 = SV_RAPIER;
477                 break;
478         case 7: case 8:
479                 dummy2 = SV_SMALL_SWORD;
480                 break;
481         case 9: case 10:
482                 dummy2 = SV_BASILLARD;
483                 break;
484         case 11: case 12: case 13:
485                 dummy2 = SV_SHORT_SWORD;
486                 break;
487         case 14: case 15:
488                 dummy2 = SV_SABRE;
489                 break;
490         case 16: case 17:
491                 dummy2 = SV_CUTLASS;
492                 break;
493         case 18:
494                 dummy2 = SV_WAKIZASHI;
495                 break;
496         case 19:
497                 dummy2 = SV_KHOPESH;
498                 break;
499         case 20:
500                 dummy2 = SV_TULWAR;
501                 break;
502         case 21:
503                 dummy2 = SV_BROAD_SWORD;
504                 break;
505         case 22: case 23:
506                 dummy2 = SV_LONG_SWORD;
507                 break;
508         case 24: case 25:
509                 dummy2 = SV_SCIMITAR;
510                 break;
511         case 26:
512                 dummy2 = SV_NINJATO;
513                 break;
514         case 27:
515                 dummy2 = SV_KATANA;
516                 break;
517         case 28: case 29:
518                 dummy2 = SV_BASTARD_SWORD;
519                 break;
520         case 30:
521                 dummy2 = SV_GREAT_SCIMITAR;
522                 break;
523         case 31:
524                 dummy2 = SV_CLAYMORE;
525                 break;
526         case 32:
527                 dummy2 = SV_ESPADON;
528                 break;
529         case 33:
530                 dummy2 = SV_TWO_HANDED_SWORD;
531                 break;
532         case 34:
533                 dummy2 = SV_FLAMBERGE;
534                 break;
535         case 35:
536                 dummy2 = SV_NO_DACHI;
537                 break;
538         case 36:
539                 dummy2 = SV_EXECUTIONERS_SWORD;
540                 break;
541         case 37:
542                 dummy2 = SV_ZWEIHANDER;
543                 break;
544         case 38:
545                 dummy2 = SV_HAYABUSA;
546                 break;
547         default:
548                 dummy2 = SV_BLADE_OF_CHAOS;
549         }
550
551         object_prep(q_ptr, lookup_kind(dummy, dummy2));
552         q_ptr->to_h = 3 + randint1(creature_ptr->current_floor_ptr->dun_level) % 10;
553         q_ptr->to_d = 3 + randint1(creature_ptr->current_floor_ptr->dun_level) % 10;
554         one_resistance(q_ptr);
555         q_ptr->name2 = EGO_CHAOTIC;
556         (void)drop_near(q_ptr, -1, creature_ptr->y, creature_ptr->x);
557 }
558
559
560 /*!
561  * @brief 防具呪縛処理 /
562  * Curse the players armor
563  * @return 実際に呪縛されたらTRUEを返す
564  */
565 bool curse_armor(player_type *owner_ptr)
566 {
567         int i;
568         object_type *o_ptr;
569
570         GAME_TEXT o_name[MAX_NLEN];
571
572         /* Curse the body armor */
573         o_ptr = &owner_ptr->inventory_list[INVEN_BODY];
574
575         /* Nothing to curse */
576         if (!o_ptr->k_idx) return (FALSE);
577
578         object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
579
580         /* Attempt a saving throw for artifacts */
581         if (object_is_artifact(o_ptr) && (randint0(100) < 50))
582         {
583                 /* Cool */
584 #ifdef JP
585                 msg_format("%sが%sを包み込もうとしたが、%sはそれを跳ね返した!",
586                         "恐怖の暗黒オーラ", "防具", o_name);
587 #else
588                 msg_format("A %s tries to %s, but your %s resists the effects!",
589                         "terrible black aura", "surround your armor", o_name);
590 #endif
591
592         }
593
594         /* not artifact or failed save... */
595         else
596         {
597                 msg_format(_("恐怖の暗黒オーラがあなたの%sを包み込んだ!", "A terrible black aura blasts your %s!"), o_name);
598                 chg_virtue(owner_ptr, V_ENCHANT, -5);
599
600                 /* Blast the armor */
601                 o_ptr->name1 = 0;
602                 o_ptr->name2 = EGO_BLASTED;
603                 o_ptr->to_a = 0 - randint1(5) - randint1(5);
604                 o_ptr->to_h = 0;
605                 o_ptr->to_d = 0;
606                 o_ptr->ac = 0;
607                 o_ptr->dd = 0;
608                 o_ptr->ds = 0;
609
610                 for (i = 0; i < TR_FLAG_SIZE; i++)
611                         o_ptr->art_flags[i] = 0;
612
613                 /* Curse it */
614                 o_ptr->curse_flags = TRC_CURSED;
615
616                 /* Break it */
617                 o_ptr->ident |= (IDENT_BROKEN);
618                 owner_ptr->update |= (PU_BONUS | PU_MANA);
619                 owner_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
620         }
621
622         return (TRUE);
623 }
624
625 /*!
626  * @brief 武器呪縛処理 /
627  * Curse the players weapon
628  * @param owner_ptr 所持者の参照ポインタ
629  * @param force 無条件に呪縛を行うならばTRUE
630  * @param o_ptr 呪縛する武器のアイテム情報参照ポインタ
631  * @return 実際に呪縛されたらTRUEを返す
632  */
633 bool curse_weapon_object(player_type *owner_ptr, bool force, object_type *o_ptr)
634 {
635         int i;
636         GAME_TEXT o_name[MAX_NLEN];
637
638         /* Nothing to curse */
639         if (!o_ptr->k_idx) return (FALSE);
640         object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
641
642         /* Attempt a saving throw */
643         if (object_is_artifact(o_ptr) && (randint0(100) < 50) && !force)
644         {
645                 /* Cool */
646 #ifdef JP
647                 msg_format("%sが%sを包み込もうとしたが、%sはそれを跳ね返した!",
648                         "恐怖の暗黒オーラ", "武器", o_name);
649 #else
650                 msg_format("A %s tries to %s, but your %s resists the effects!",
651                         "terrible black aura", "surround your weapon", o_name);
652 #endif
653         }
654
655         /* not artifact or failed save... */
656         else
657         {
658                 if (!force) msg_format(_("恐怖の暗黒オーラがあなたの%sを包み込んだ!", "A terrible black aura blasts your %s!"), o_name);
659                 chg_virtue(owner_ptr, V_ENCHANT, -5);
660
661                 /* Shatter the weapon */
662                 o_ptr->name1 = 0;
663                 o_ptr->name2 = EGO_SHATTERED;
664                 o_ptr->to_h = 0 - randint1(5) - randint1(5);
665                 o_ptr->to_d = 0 - randint1(5) - randint1(5);
666                 o_ptr->to_a = 0;
667                 o_ptr->ac = 0;
668                 o_ptr->dd = 0;
669                 o_ptr->ds = 0;
670
671                 for (i = 0; i < TR_FLAG_SIZE; i++)
672                         o_ptr->art_flags[i] = 0;
673
674                 /* Curse it */
675                 o_ptr->curse_flags = TRC_CURSED;
676
677                 /* Break it */
678                 o_ptr->ident |= (IDENT_BROKEN);
679                 owner_ptr->update |= (PU_BONUS | PU_MANA);
680                 owner_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
681         }
682
683         return (TRUE);
684 }
685
686 /*!
687  * @brief 武器呪縛処理のメインルーチン /
688  * Curse the players weapon
689  * @param force 無条件に呪縛を行うならばTRUE
690  * @param slot 呪縛する武器の装備スロット
691  * @return 実際に呪縛されたらTRUEを返す
692  */
693 bool curse_weapon(bool force, int slot)
694 {
695         return curse_weapon_object(p_ptr, force, &p_ptr->inventory_list[slot]);
696 }
697
698
699 /*!
700  * @brief 防具の錆止め防止処理
701  * @return ターン消費を要する処理を行ったならばTRUEを返す
702  */
703 bool rustproof(void)
704 {
705         OBJECT_IDX item;
706         object_type *o_ptr;
707         GAME_TEXT o_name[MAX_NLEN];
708         concptr q, s;
709
710         /* Select a piece of armour */
711         item_tester_hook = object_is_armour;
712
713         q = _("どの防具に錆止めをしますか?", "Rustproof which piece of armour? ");
714         s = _("錆止めできるものがありません。", "You have nothing to rustproof.");
715
716         o_ptr = choose_object(p_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
717         if (!o_ptr) return FALSE;
718
719         object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
720
721         add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
722
723         if ((o_ptr->to_a < 0) && !object_is_cursed(o_ptr))
724         {
725 #ifdef JP
726                 msg_format("%sは新品同様になった!", o_name);
727 #else
728                 msg_format("%s %s look%s as good as new!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
729 #endif
730
731                 o_ptr->to_a = 0;
732         }
733
734 #ifdef JP
735         msg_format("%sは腐食しなくなった。", o_name);
736 #else
737         msg_format("%s %s %s now protected against corrosion.", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "are" : "is"));
738 #endif
739
740         calc_android_exp(p_ptr);
741         return TRUE;
742 }
743
744 /*!
745  * @brief ボルトのエゴ化処理(火炎エゴのみ) /
746  * Enchant some bolts
747  * @return 常にTRUEを返す
748  */
749 bool brand_bolts(void)
750 {
751         int i;
752
753         /* Use the first acceptable bolts */
754         for (i = 0; i < INVEN_PACK; i++)
755         {
756                 object_type *o_ptr = &p_ptr->inventory_list[i];
757
758                 /* Skip non-bolts */
759                 if (o_ptr->tval != TV_BOLT) continue;
760
761                 /* Skip artifacts and ego-items */
762                 if (object_is_artifact(o_ptr) || object_is_ego(o_ptr))
763                         continue;
764
765                 /* Skip cursed/broken items */
766                 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) continue;
767
768                 /* Randomize */
769                 if (randint0(100) < 75) continue;
770
771                 msg_print(_("クロスボウの矢が炎のオーラに包まれた!", "Your bolts are covered in a fiery aura!"));
772
773                 /* Ego-item */
774                 o_ptr->name2 = EGO_FLAME;
775                 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
776                 return (TRUE);
777         }
778
779         if (flush_failure) flush();
780
781         /* Fail */
782         msg_print(_("炎で強化するのに失敗した。", "The fiery enchantment failed."));
783
784         return (TRUE);
785 }
786
787
788 bool perilous_secrets(player_type *user_ptr)
789 {
790         if (!ident_spell(user_ptr, FALSE)) return FALSE;
791
792         if (mp_ptr->spell_book)
793         {
794                 /* Sufficient mana */
795                 if (20 <= user_ptr->csp)
796                 {
797                         /* Use some mana */
798                         user_ptr->csp -= 20;
799                 }
800
801                 /* Over-exert the player */
802                 else
803                 {
804                         int oops = 20 - user_ptr->csp;
805
806                         /* No mana left */
807                         user_ptr->csp = 0;
808                         user_ptr->csp_frac = 0;
809
810                         msg_print(_("石を制御できない!", "You are too weak to control the stone!"));
811                         /* Hack -- Bypass free action */
812                         (void)set_paralyzed(user_ptr, user_ptr->paralyzed + randint1(5 * oops + 1));
813
814                         /* Confusing. */
815                         (void)set_confused(user_ptr, user_ptr->confused + randint1(5 * oops + 1));
816                 }
817                 user_ptr->redraw |= (PR_MANA);
818         }
819         take_hit(user_ptr, DAMAGE_LOSELIFE, damroll(1, 12), _("危険な秘密", "perilous secrets"), -1);
820         /* Confusing. */
821         if (one_in_(5)) (void)set_confused(user_ptr, user_ptr->confused + randint1(10));
822
823         /* Exercise a little care... */
824         if (one_in_(20)) take_hit(user_ptr, DAMAGE_LOSELIFE, damroll(4, 10), _("危険な秘密", "perilous secrets"), -1);
825         return TRUE;
826
827 }
828
829 /*!
830  * @brief 固定アーティファクト『ブラッディムーン』の特性を変更する。
831  * @details スレイ2d2種、及びone_resistance()による耐性1d2種、pval2種を得る。
832  * @param o_ptr 対象のオブジェクト構造体(ブラッディムーン)のポインタ
833  * @return なし
834  */
835 void get_bloody_moon_flags(object_type *o_ptr)
836 {
837         int dummy, i;
838
839         for (i = 0; i < TR_FLAG_SIZE; i++)
840                 o_ptr->art_flags[i] = a_info[ART_BLOOD].flags[i];
841
842         dummy = randint1(2) + randint1(2);
843         for (i = 0; i < dummy; i++)
844         {
845                 int flag = randint0(26);
846                 if (flag >= 20) add_flag(o_ptr->art_flags, TR_KILL_UNDEAD + flag - 20);
847                 else if (flag == 19) add_flag(o_ptr->art_flags, TR_KILL_ANIMAL);
848                 else if (flag == 18) add_flag(o_ptr->art_flags, TR_SLAY_HUMAN);
849                 else add_flag(o_ptr->art_flags, TR_CHAOTIC + flag);
850         }
851
852         dummy = randint1(2);
853         for (i = 0; i < dummy; i++) one_resistance(o_ptr);
854
855         for (i = 0; i < 2; i++)
856         {
857                 int tmp = randint0(11);
858                 if (tmp < A_MAX) add_flag(o_ptr->art_flags, TR_STR + tmp);
859                 else add_flag(o_ptr->art_flags, TR_STEALTH + tmp - 6);
860         }
861 }
862
863 /*!
864  * @brief 寿命つき光源の燃素追加処理 /
865  * Charge a lite (torch or latern)
866  * @return なし
867  */
868 void phlogiston(player_type *caster_ptr)
869 {
870         GAME_TURN max_flog = 0;
871         object_type * o_ptr = &caster_ptr->inventory_list[INVEN_LITE];
872
873         /* It's a lamp */
874         if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_LANTERN))
875         {
876                 max_flog = FUEL_LAMP;
877         }
878
879         /* It's a torch */
880         else if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
881         {
882                 max_flog = FUEL_TORCH;
883         }
884
885         /* No torch to refill */
886         else
887         {
888                 msg_print(_("燃素を消費するアイテムを装備していません。", "You are not wielding anything which uses phlogiston."));
889                 return;
890         }
891
892         if (o_ptr->xtra4 >= max_flog)
893         {
894                 msg_print(_("このアイテムにはこれ以上燃素を補充できません。", "No more phlogiston can be put in this item."));
895                 return;
896         }
897
898         /* Refuel */
899         o_ptr->xtra4 += (XTRA16)(max_flog / 2);
900         msg_print(_("照明用アイテムに燃素を補充した。", "You add phlogiston to your light item."));
901
902         if (o_ptr->xtra4 >= max_flog)
903         {
904                 o_ptr->xtra4 = (XTRA16)max_flog;
905                 msg_print(_("照明用アイテムは満タンになった。", "Your light item is full."));
906         }
907
908         caster_ptr->update |= (PU_TORCH);
909 }
910
911 /*!
912  * @brief 武器の祝福処理 /
913  * Bless a weapon
914  * @return ターン消費を要する処理を行ったならばTRUEを返す
915  */
916 bool bless_weapon(void)
917 {
918         OBJECT_IDX item;
919         object_type *o_ptr;
920         BIT_FLAGS flgs[TR_FLAG_SIZE];
921         GAME_TEXT o_name[MAX_NLEN];
922         concptr q, s;
923
924         /* Bless only weapons */
925         item_tester_hook = object_is_weapon;
926
927         q = _("どのアイテムを祝福しますか?", "Bless which weapon? ");
928         s = _("祝福できる武器がありません。", "You have weapon to bless.");
929
930         o_ptr = choose_object(p_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
931         if (!o_ptr) return FALSE;
932
933         object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
934         object_flags(o_ptr, flgs);
935
936         if (object_is_cursed(o_ptr))
937         {
938                 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) ||
939                         have_flag(flgs, TR_ADD_L_CURSE) ||
940                         have_flag(flgs, TR_ADD_H_CURSE) ||
941                         (o_ptr->curse_flags & TRC_PERMA_CURSE))
942                 {
943 #ifdef JP
944                         msg_format("%sを覆う黒いオーラは祝福を跳ね返した!", o_name);
945 #else
946                         msg_format("The black aura on %s %s disrupts the blessing!", ((item >= 0) ? "your" : "the"), o_name);
947 #endif
948
949                         return TRUE;
950                 }
951
952 #ifdef JP
953                 msg_format("%s から邪悪なオーラが消えた。", o_name);
954 #else
955                 msg_format("A malignant aura leaves %s %s.", ((item >= 0) ? "your" : "the"), o_name);
956 #endif
957
958
959                 o_ptr->curse_flags = 0L;
960
961                 o_ptr->ident |= (IDENT_SENSE);
962                 o_ptr->feeling = FEEL_NONE;
963
964                 /* Recalculate the bonuses */
965                 p_ptr->update |= (PU_BONUS);
966                 p_ptr->window |= (PW_EQUIP);
967         }
968
969         /*
970          * Next, we try to bless it. Artifacts have a 1/3 chance of
971          * being blessed, otherwise, the operation simply disenchants
972          * them, godly power negating the magic. Ok, the explanation
973          * is silly, but otherwise priests would always bless every
974          * artifact weapon they find. Ego weapons and normal weapons
975          * can be blessed automatically.
976          */
977         if (have_flag(flgs, TR_BLESSED))
978         {
979 #ifdef JP
980                 msg_format("%s は既に祝福されている。", o_name);
981 #else
982                 msg_format("%s %s %s blessed already.",
983                         ((item >= 0) ? "Your" : "The"), o_name,
984                         ((o_ptr->number > 1) ? "were" : "was"));
985 #endif
986
987                 return TRUE;
988         }
989
990         if (!(object_is_artifact(o_ptr) || object_is_ego(o_ptr)) || one_in_(3))
991         {
992 #ifdef JP
993                 msg_format("%sは輝いた!", o_name);
994 #else
995                 msg_format("%s %s shine%s!",
996                         ((item >= 0) ? "Your" : "The"), o_name,
997                         ((o_ptr->number > 1) ? "" : "s"));
998 #endif
999
1000                 add_flag(o_ptr->art_flags, TR_BLESSED);
1001                 o_ptr->discount = 99;
1002         }
1003         else
1004         {
1005                 bool dis_happened = FALSE;
1006                 msg_print(_("その武器は祝福を嫌っている!", "The weapon resists your blessing!"));
1007
1008                 /* Disenchant tohit */
1009                 if (o_ptr->to_h > 0)
1010                 {
1011                         o_ptr->to_h--;
1012                         dis_happened = TRUE;
1013                 }
1014
1015                 if ((o_ptr->to_h > 5) && (randint0(100) < 33)) o_ptr->to_h--;
1016
1017                 /* Disenchant todam */
1018                 if (o_ptr->to_d > 0)
1019                 {
1020                         o_ptr->to_d--;
1021                         dis_happened = TRUE;
1022                 }
1023
1024                 if ((o_ptr->to_d > 5) && (randint0(100) < 33)) o_ptr->to_d--;
1025
1026                 /* Disenchant toac */
1027                 if (o_ptr->to_a > 0)
1028                 {
1029                         o_ptr->to_a--;
1030                         dis_happened = TRUE;
1031                 }
1032
1033                 if ((o_ptr->to_a > 5) && (randint0(100) < 33)) o_ptr->to_a--;
1034
1035                 if (dis_happened)
1036                 {
1037                         msg_print(_("周囲が凡庸な雰囲気で満ちた...", "There is a static feeling in the air..."));
1038
1039 #ifdef JP
1040                         msg_format("%s は劣化した!", o_name);
1041 #else
1042                         msg_format("%s %s %s disenchanted!", ((item >= 0) ? "Your" : "The"), o_name,
1043                                 ((o_ptr->number > 1) ? "were" : "was"));
1044 #endif
1045
1046                 }
1047         }
1048
1049         p_ptr->update |= (PU_BONUS);
1050         p_ptr->window |= (PW_EQUIP | PW_PLAYER);
1051         calc_android_exp(p_ptr);
1052
1053         return TRUE;
1054 }
1055
1056
1057 /*!
1058  * @brief 盾磨き処理 /
1059  * pulish shield
1060  * @return ターン消費を要する処理を行ったならばTRUEを返す
1061  */
1062 bool pulish_shield(void)
1063 {
1064         OBJECT_IDX item;
1065         object_type *o_ptr;
1066         BIT_FLAGS flgs[TR_FLAG_SIZE];
1067         GAME_TEXT o_name[MAX_NLEN];
1068         concptr            q, s;
1069
1070         /* Assume enchant weapon */
1071         item_tester_tval = TV_SHIELD;
1072
1073         q = _("どの盾を磨きますか?", "Pulish which weapon? ");
1074         s = _("磨く盾がありません。", "You have weapon to pulish.");
1075
1076         o_ptr = choose_object(p_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
1077         if (!o_ptr) return FALSE;
1078
1079         object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1080         object_flags(o_ptr, flgs);
1081
1082         if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
1083                 !object_is_cursed(o_ptr) && (o_ptr->sval != SV_MIRROR_SHIELD))
1084         {
1085 #ifdef JP
1086                 msg_format("%sは輝いた!", o_name);
1087 #else
1088                 msg_format("%s %s shine%s!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
1089 #endif
1090                 o_ptr->name2 = EGO_REFLECTION;
1091                 enchant(o_ptr, randint0(3) + 4, ENCH_TOAC);
1092
1093                 o_ptr->discount = 99;
1094                 chg_virtue(p_ptr, V_ENCHANT, 2);
1095
1096                 return TRUE;
1097         }
1098         else
1099         {
1100                 if (flush_failure) flush();
1101
1102                 msg_print(_("失敗した。", "Failed."));
1103                 chg_virtue(p_ptr, V_ENCHANT, -2);
1104         }
1105         calc_android_exp(p_ptr);
1106
1107         return FALSE;
1108 }
1109
1110 /*!
1111  * @brief 呪いの打ち破り処理 /
1112  * Break the curse of an item
1113  * @param o_ptr 呪い装備情報の参照ポインタ
1114  * @return なし
1115  */
1116 static void break_curse(object_type *o_ptr)
1117 {
1118         if (object_is_cursed(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
1119         {
1120                 msg_print(_("かけられていた呪いが打ち破られた!", "The curse is broken!"));
1121
1122                 o_ptr->curse_flags = 0L;
1123                 o_ptr->ident |= (IDENT_SENSE);
1124                 o_ptr->feeling = FEEL_NONE;
1125         }
1126 }
1127
1128 /*!
1129  * @brief 装備修正強化処理 /
1130  * Enchants a plus onto an item. -RAK-
1131  * @param o_ptr 強化するアイテムの参照ポインタ
1132  * @param n 強化基本量
1133  * @param eflag 強化オプション(命中/ダメージ/AC)
1134  * @return 強化に成功した場合TRUEを返す
1135  * @details
1136  * <pre>
1137  * Revamped!  Now takes item pointer, number of times to try enchanting,
1138  * and a flag of what to try enchanting.  Artifacts resist enchantment
1139  * some of the time, and successful enchantment to at least +0 might
1140  * break a curse on the item. -CFT-
1141  *
1142  * Note that an item can technically be enchanted all the way to +15 if
1143  * you wait a very, very, long time.  Going from +9 to +10 only works
1144  * about 5% of the time, and from +10 to +11 only about 1% of the time.
1145  *
1146  * Note that this function can now be used on "piles" of items, and
1147  * the larger the pile, the lower the chance of success.
1148  * </pre>
1149  */
1150 bool enchant(object_type *o_ptr, int n, int eflag)
1151 {
1152         int     i, chance, prob;
1153         bool    res = FALSE;
1154         bool    a = object_is_artifact(o_ptr);
1155         bool    force = (eflag & ENCH_FORCE);
1156
1157         /* Large piles resist enchantment */
1158         prob = o_ptr->number * 100;
1159
1160         /* Missiles are easy to enchant */
1161         if ((o_ptr->tval == TV_BOLT) ||
1162                 (o_ptr->tval == TV_ARROW) ||
1163                 (o_ptr->tval == TV_SHOT))
1164         {
1165                 prob = prob / 20;
1166         }
1167
1168         /* Try "n" times */
1169         for (i = 0; i < n; i++)
1170         {
1171                 /* Hack -- Roll for pile resistance */
1172                 if (!force && randint0(prob) >= 100) continue;
1173
1174                 /* Enchant to hit */
1175                 if (eflag & ENCH_TOHIT)
1176                 {
1177                         if (o_ptr->to_h < 0) chance = 0;
1178                         else if (o_ptr->to_h > 15) chance = 1000;
1179                         else chance = enchant_table[o_ptr->to_h];
1180
1181                         if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
1182                         {
1183                                 o_ptr->to_h++;
1184                                 res = TRUE;
1185
1186                                 /* only when you get it above -1 -CFT */
1187                                 if (o_ptr->to_h >= 0)
1188                                         break_curse(o_ptr);
1189                         }
1190                 }
1191
1192                 /* Enchant to damage */
1193                 if (eflag & ENCH_TODAM)
1194                 {
1195                         if (o_ptr->to_d < 0) chance = 0;
1196                         else if (o_ptr->to_d > 15) chance = 1000;
1197                         else chance = enchant_table[o_ptr->to_d];
1198
1199                         if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
1200                         {
1201                                 o_ptr->to_d++;
1202                                 res = TRUE;
1203
1204                                 /* only when you get it above -1 -CFT */
1205                                 if (o_ptr->to_d >= 0)
1206                                         break_curse(o_ptr);
1207                         }
1208                 }
1209
1210                 /* Enchant to armor class */
1211                 if (eflag & ENCH_TOAC)
1212                 {
1213                         if (o_ptr->to_a < 0) chance = 0;
1214                         else if (o_ptr->to_a > 15) chance = 1000;
1215                         else chance = enchant_table[o_ptr->to_a];
1216
1217                         if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
1218                         {
1219                                 o_ptr->to_a++;
1220                                 res = TRUE;
1221
1222                                 /* only when you get it above -1 -CFT */
1223                                 if (o_ptr->to_a >= 0)
1224                                         break_curse(o_ptr);
1225                         }
1226                 }
1227         }
1228
1229         /* Failure */
1230         if (!res) return (FALSE);
1231         p_ptr->update |= (PU_BONUS | PU_COMBINE | PU_REORDER);
1232         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
1233
1234         calc_android_exp(p_ptr);
1235
1236         /* Success */
1237         return (TRUE);
1238 }
1239
1240
1241 /*!
1242  * @brief 装備修正強化処理のメインルーチン /
1243  * Enchant an item (in the p_ptr->inventory_list or on the floor)
1244  * @param num_hit 命中修正量
1245  * @param num_dam ダメージ修正量
1246  * @param num_ac AC修正量
1247  * @return 強化に成功した場合TRUEを返す
1248  * @details
1249  * Note that "num_ac" requires armour, else weapon
1250  * Returns TRUE if attempted, FALSE if cancelled
1251  */
1252 bool enchant_spell(HIT_PROB num_hit, HIT_POINT num_dam, ARMOUR_CLASS num_ac)
1253 {
1254         OBJECT_IDX item;
1255         bool        okay = FALSE;
1256         object_type *o_ptr;
1257         GAME_TEXT o_name[MAX_NLEN];
1258         concptr        q, s;
1259
1260         /* Assume enchant weapon */
1261         item_tester_hook = object_allow_enchant_weapon;
1262
1263         /* Enchant armor if requested */
1264         if (num_ac) item_tester_hook = object_is_armour;
1265
1266         q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
1267         s = _("強化できるアイテムがない。", "You have nothing to enchant.");
1268
1269         o_ptr = choose_object(p_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
1270         if (!o_ptr) return (FALSE);
1271
1272         object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1273 #ifdef JP
1274         msg_format("%s は明るく輝いた!", o_name);
1275 #else
1276         msg_format("%s %s glow%s brightly!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
1277 #endif
1278
1279         /* Enchant */
1280         if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
1281         if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
1282         if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
1283
1284         /* Failure */
1285         if (!okay)
1286         {
1287                 if (flush_failure) flush();
1288                 msg_print(_("強化に失敗した。", "The enchantment failed."));
1289                 if (one_in_(3)) chg_virtue(p_ptr, V_ENCHANT, -1);
1290         }
1291         else
1292                 chg_virtue(p_ptr, V_ENCHANT, 1);
1293
1294         calc_android_exp(p_ptr);
1295
1296         /* Something happened */
1297         return (TRUE);
1298 }
1299
1300
1301
1302 /*!
1303  * @brief 武器へのエゴ付加処理 /
1304  * Brand the current weapon
1305  * @param brand_type エゴ化ID(e_info.txtとは連動していない)
1306  * @return なし
1307  */
1308 void brand_weapon(player_type *caster_ptr, int brand_type)
1309 {
1310         OBJECT_IDX item;
1311         object_type *o_ptr;
1312         concptr q, s;
1313
1314         /* Assume enchant weapon */
1315         item_tester_hook = object_allow_enchant_melee_weapon;
1316
1317         q = _("どの武器を強化しますか? ", "Enchant which weapon? ");
1318         s = _("強化できる武器がない。", "You have nothing to enchant.");
1319
1320         o_ptr = choose_object(caster_ptr, &item, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT), 0);
1321         if (!o_ptr) return;
1322
1323         /* you can never modify artifacts / ego-items */
1324         /* you can never modify cursed items */
1325         /* TY: You _can_ modify broken items (if you're silly enough) */
1326         if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
1327                 !object_is_cursed(o_ptr) &&
1328                 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) &&
1329                 !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) &&
1330                 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)))
1331         {
1332                 concptr act = NULL;
1333
1334                 /* Let's get the name before it is changed... */
1335                 GAME_TEXT o_name[MAX_NLEN];
1336                 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1337
1338                 switch (brand_type)
1339                 {
1340                 case 17:
1341                         if (o_ptr->tval == TV_SWORD)
1342                         {
1343                                 act = _("は鋭さを増した!", "becomes very sharp!");
1344
1345                                 o_ptr->name2 = EGO_SHARPNESS;
1346                                 o_ptr->pval = (PARAMETER_VALUE)m_bonus(5, caster_ptr->current_floor_ptr->dun_level) + 1;
1347
1348                                 if ((o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2))
1349                                         o_ptr->pval = 2;
1350                         }
1351                         else
1352                         {
1353                                 act = _("は破壊力を増した!", "seems very powerful.");
1354                                 o_ptr->name2 = EGO_EARTHQUAKES;
1355                                 o_ptr->pval = (PARAMETER_VALUE)m_bonus(3, caster_ptr->current_floor_ptr->dun_level);
1356                         }
1357                         break;
1358                 case 16:
1359                         act = _("は人間の血を求めている!", "seems to be looking for humans!");
1360                         o_ptr->name2 = EGO_KILL_HUMAN;
1361                         break;
1362                 case 15:
1363                         act = _("は電撃に覆われた!", "covered with lightning!");
1364                         o_ptr->name2 = EGO_BRAND_ELEC;
1365                         break;
1366                 case 14:
1367                         act = _("は酸に覆われた!", "coated with acid!");
1368                         o_ptr->name2 = EGO_BRAND_ACID;
1369                         break;
1370                 case 13:
1371                         act = _("は邪悪なる怪物を求めている!", "seems to be looking for evil monsters!");
1372                         o_ptr->name2 = EGO_KILL_EVIL;
1373                         break;
1374                 case 12:
1375                         act = _("は異世界の住人の肉体を求めている!", "seems to be looking for demons!");
1376                         o_ptr->name2 = EGO_KILL_DEMON;
1377                         break;
1378                 case 11:
1379                         act = _("は屍を求めている!", "seems to be looking for undead!");
1380                         o_ptr->name2 = EGO_KILL_UNDEAD;
1381                         break;
1382                 case 10:
1383                         act = _("は動物の血を求めている!", "seems to be looking for animals!");
1384                         o_ptr->name2 = EGO_KILL_ANIMAL;
1385                         break;
1386                 case 9:
1387                         act = _("はドラゴンの血を求めている!", "seems to be looking for dragons!");
1388                         o_ptr->name2 = EGO_KILL_DRAGON;
1389                         break;
1390                 case 8:
1391                         act = _("はトロルの血を求めている!", "seems to be looking for troll!s");
1392                         o_ptr->name2 = EGO_KILL_TROLL;
1393                         break;
1394                 case 7:
1395                         act = _("はオークの血を求めている!", "seems to be looking for orcs!");
1396                         o_ptr->name2 = EGO_KILL_ORC;
1397                         break;
1398                 case 6:
1399                         act = _("は巨人の血を求めている!", "seems to be looking for giants!");
1400                         o_ptr->name2 = EGO_KILL_GIANT;
1401                         break;
1402                 case 5:
1403                         act = _("は非常に不安定になったようだ。", "seems very unstable now.");
1404                         o_ptr->name2 = EGO_TRUMP;
1405                         o_ptr->pval = randint1(2);
1406                         break;
1407                 case 4:
1408                         act = _("は血を求めている!", "thirsts for blood!");
1409                         o_ptr->name2 = EGO_VAMPIRIC;
1410                         break;
1411                 case 3:
1412                         act = _("は毒に覆われた。", "is coated with poison.");
1413                         o_ptr->name2 = EGO_BRAND_POIS;
1414                         break;
1415                 case 2:
1416                         act = _("は純ログルスに飲み込まれた。", "is engulfed in raw Logrus!");
1417                         o_ptr->name2 = EGO_CHAOTIC;
1418                         break;
1419                 case 1:
1420                         act = _("は炎のシールドに覆われた!", "is covered in a fiery shield!");
1421                         o_ptr->name2 = EGO_BRAND_FIRE;
1422                         break;
1423                 default:
1424                         act = _("は深く冷たいブルーに輝いた!", "glows deep, icy blue!");
1425                         o_ptr->name2 = EGO_BRAND_COLD;
1426                         break;
1427                 }
1428
1429                 msg_format(_("あなたの%s%s", "Your %s %s"), o_name, act);
1430                 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
1431
1432                 o_ptr->discount = 99;
1433                 chg_virtue(caster_ptr, V_ENCHANT, 2);
1434         }
1435         else
1436         {
1437                 if (flush_failure) flush();
1438
1439                 msg_print(_("属性付加に失敗した。", "The Branding failed."));
1440                 chg_virtue(caster_ptr, V_ENCHANT, -2);
1441         }
1442         calc_android_exp(caster_ptr);
1443 }