OSDN Git Service

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