OSDN Git Service

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