OSDN Git Service

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