OSDN Git Service

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