OSDN Git Service

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