OSDN Git Service

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