OSDN Git Service

[Refactor/WIP] モンスター種族IDをenum class化
[hengbandforosx/hengbandosx.git] / src / spell / spells-object.cpp
1 /*!
2  * @brief アイテムに影響のある魔法の処理
3  * @date 2019/01/22
4  * @author deskull
5  */
6
7 #include "spell/spells-object.h"
8 #include "avatar/avatar.h"
9 #include "core/player-update-types.h"
10 #include "core/window-redrawer.h"
11 #include "flavor/flavor-describer.h"
12 #include "flavor/object-flavor-types.h"
13 #include "floor/floor-object.h"
14 #include "game-option/disturbance-options.h"
15 #include "inventory/inventory-slot-types.h"
16 #include "monster-race/monster-race.h"
17 #include "monster-race/race-flags1.h"
18 #include "object-enchant/apply-magic.h"
19 #include "object-enchant/item-apply-magic.h"
20 #include "object-enchant/item-feeling.h"
21 #include "object-enchant/object-boost.h"
22 #include "object-enchant/object-ego.h"
23 #include "object-enchant/special-object-flags.h"
24 #include "object-enchant/trc-types.h"
25 #include "object-enchant/trg-types.h"
26 #include "object-hook/hook-armor.h"
27 #include "object-hook/hook-weapon.h"
28 #include "object/item-tester-hooker.h"
29 #include "object/item-use-flags.h"
30 #include "object/object-kind-hook.h"
31 #include "object/object-kind.h"
32 #include "perception/object-perception.h"
33 #include "player-info/class-info.h"
34 #include "racial/racial-android.h"
35 #include "sv-definition/sv-other-types.h"
36 #include "sv-definition/sv-scroll-types.h"
37 #include "sv-definition/sv-weapon-types.h"
38 #include "system/artifact-type-definition.h"
39 #include "system/floor-type-definition.h"
40 #include "system/monster-race-definition.h"
41 #include "system/object-type-definition.h"
42 #include "system/player-type-definition.h"
43 #include "term/screen-processor.h"
44 #include "util/bit-flags-calculator.h"
45 #include "view/display-messages.h"
46
47 struct amuse_type {
48     ItemKindType tval;
49     OBJECT_SUBTYPE_VALUE sval;
50     PERCENTAGE prob;
51     byte flag;
52 };
53
54 /*!
55  * @brief 装備強化処理の失敗率定数(千分率) /
56  * Used by the "enchant" function (chance of failure)
57  * (modified for Zangband, we need better stuff there...) -- TY
58  */
59 static int enchant_table[16] = { 0, 10, 50, 100, 200, 300, 400, 500, 650, 800, 950, 987, 993, 995, 998, 1000 };
60
61 /*
62  * Scatter some "amusing" objects near the player
63  */
64
65 #define AMS_NOTHING 0x00 /* No restriction */
66 #define AMS_NO_UNIQUE 0x01 /* Don't make the amusing object of uniques */
67 #define AMS_FIXED_ART 0x02 /* Make a fixed artifact based on the amusing object */
68 #define AMS_MULTIPLE 0x04 /* Drop 1-3 objects for one type */
69 #define AMS_PILE 0x08 /* Drop 1-99 pile objects for one type */
70
71 static amuse_type amuse_info[] = { { ItemKindType::BOTTLE, SV_ANY, 5, AMS_NOTHING }, { ItemKindType::JUNK, SV_ANY, 3, AMS_MULTIPLE }, { ItemKindType::SPIKE, SV_ANY, 10, AMS_PILE }, { ItemKindType::STATUE, SV_ANY, 15, AMS_NOTHING },
72     { ItemKindType::CORPSE, SV_ANY, 15, AMS_NO_UNIQUE }, { ItemKindType::SKELETON, SV_ANY, 10, AMS_NO_UNIQUE }, { ItemKindType::FIGURINE, SV_ANY, 10, AMS_NO_UNIQUE },
73     { ItemKindType::PARCHMENT, SV_ANY, 1, AMS_NOTHING }, { ItemKindType::POLEARM, SV_TSURIZAO, 3, AMS_NOTHING }, // Fishing Pole of Taikobo
74     { ItemKindType::SWORD, SV_BROKEN_DAGGER, 3, AMS_FIXED_ART }, // Broken Dagger of Magician
75     { ItemKindType::SWORD, SV_BROKEN_DAGGER, 10, AMS_NOTHING }, { ItemKindType::SWORD, SV_BROKEN_SWORD, 5, AMS_NOTHING }, { ItemKindType::SCROLL, SV_SCROLL_AMUSEMENT, 10, AMS_NOTHING },
76
77     { ItemKindType::NONE, 0, 0, 0 } };
78
79 /*!
80  * @brief 誰得ドロップを行う。
81  * @param player_ptr プレイヤーへの参照ポインタ
82  * @param y1 配置したいフロアのY座標
83  * @param x1 配置したいフロアのX座標
84  * @param num 誰得の処理回数
85  * @param known TRUEならばオブジェクトが必ず*鑑定*済になる
86  */
87 void amusement(PlayerType *player_ptr, POSITION y1, POSITION x1, int num, bool known)
88 {
89     int t = 0;
90     for (int n = 0; amuse_info[n].tval != ItemKindType::NONE; n++) {
91         t += amuse_info[n].prob;
92     }
93
94     /* Acquirement */
95     ObjectType *i_ptr;
96     ObjectType ObjectType_body;
97     while (num) {
98         int i;
99         KIND_OBJECT_IDX k_idx;
100         ARTIFACT_IDX a_idx = 0;
101         int r = randint0(t);
102         bool insta_art, fixed_art;
103
104         for (i = 0;; i++) {
105             r -= amuse_info[i].prob;
106             if (r <= 0) {
107                 break;
108             }
109         }
110         i_ptr = &ObjectType_body;
111         i_ptr->wipe();
112         k_idx = lookup_kind(amuse_info[i].tval, amuse_info[i].sval);
113
114         /* Paranoia - reroll if nothing */
115         if (!k_idx) {
116             continue;
117         }
118
119         /* Search an artifact index if need */
120         insta_art = k_info[k_idx].gen_flags.has(ItemGenerationTraitType::INSTA_ART);
121         fixed_art = (amuse_info[i].flag & AMS_FIXED_ART);
122
123         if (insta_art || fixed_art) {
124             for (const auto &a_ref : a_info) {
125                 if (a_ref.idx == 0) {
126                     continue;
127                 }
128                 if (insta_art && !a_ref.gen_flags.has(ItemGenerationTraitType::INSTA_ART)) {
129                     continue;
130                 }
131                 if (a_ref.tval != k_info[k_idx].tval) {
132                     continue;
133                 }
134                 if (a_ref.sval != k_info[k_idx].sval) {
135                     continue;
136                 }
137                 if (a_ref.cur_num > 0) {
138                     continue;
139                 }
140
141                 a_idx = a_ref.idx;
142                 break;
143             }
144
145             if (a_idx >= static_cast<ARTIFACT_IDX>(a_info.size())) {
146                 continue;
147             }
148         }
149
150         /* Make an object (if possible) */
151         i_ptr->prep(k_idx);
152         if (a_idx) {
153             i_ptr->fixed_artifact_idx = a_idx;
154         }
155         apply_magic_to_object(player_ptr, i_ptr, 1, AM_NO_FIXED_ART);
156
157         if (amuse_info[i].flag & AMS_NO_UNIQUE) {
158             if (r_info[i2enum<MonsterRaceId>(i_ptr->pval)].kind_flags.has(MonsterKindType::UNIQUE)) {
159                 continue;
160             }
161         }
162
163         if (amuse_info[i].flag & AMS_MULTIPLE) {
164             i_ptr->number = randint1(3);
165         }
166         if (amuse_info[i].flag & AMS_PILE) {
167             i_ptr->number = randint1(99);
168         }
169
170         if (known) {
171             object_aware(player_ptr, i_ptr);
172             object_known(i_ptr);
173         }
174
175         /* Paranoia - reroll if nothing */
176         if (!(i_ptr->k_idx)) {
177             continue;
178         }
179
180         (void)drop_near(player_ptr, i_ptr, -1, y1, x1);
181
182         num--;
183     }
184 }
185
186 /*!
187  * @brief 獲得ドロップを行う。
188  * Scatter some "great" objects near the player
189  * @param player_ptr プレイヤーへの参照ポインタ
190  * @param y1 配置したいフロアのY座標
191  * @param x1 配置したいフロアのX座標
192  * @param num 獲得の処理回数
193  * @param great TRUEならば必ず高級品以上を落とす
194  * @param special TRUEならば必ず特別品を落とす
195  * @param known TRUEならばオブジェクトが必ず*鑑定*済になる
196  */
197 void acquirement(PlayerType *player_ptr, POSITION y1, POSITION x1, int num, bool great, bool special, bool known)
198 {
199     ObjectType *i_ptr;
200     ObjectType ObjectType_body;
201     BIT_FLAGS mode = AM_GOOD | (great || special ? AM_GREAT : AM_NONE) | (special ? AM_SPECIAL : AM_NONE);
202
203     /* Acquirement */
204     while (num--) {
205         i_ptr = &ObjectType_body;
206         i_ptr->wipe();
207
208         /* Make a good (or great) object (if possible) */
209         if (!make_object(player_ptr, i_ptr, mode)) {
210             continue;
211         }
212
213         if (known) {
214             object_aware(player_ptr, i_ptr);
215             object_known(i_ptr);
216         }
217
218         (void)drop_near(player_ptr, i_ptr, -1, y1, x1);
219     }
220 }
221
222 /*!
223  * @brief 防具呪縛処理 /
224  * Curse the players armor
225  * @return 何も持っていない場合を除き、常にTRUEを返す
226  * @todo 元のreturnは間違っているが、修正後の↓文がどれくらい正しいかは要チェック
227  */
228 bool curse_armor(PlayerType *player_ptr)
229 {
230     /* Curse the body armor */
231     ObjectType *o_ptr;
232     o_ptr = &player_ptr->inventory_list[INVEN_BODY];
233
234     if (!o_ptr->k_idx) {
235         return false;
236     }
237
238     GAME_TEXT o_name[MAX_NLEN];
239     describe_flavor(player_ptr, o_name, o_ptr, OD_OMIT_PREFIX);
240
241     /* Attempt a saving throw for artifacts */
242     if (o_ptr->is_artifact() && (randint0(100) < 50)) {
243         /* Cool */
244 #ifdef JP
245         msg_format("%sが%sを包み込もうとしたが、%sはそれを跳ね返した!", "恐怖の暗黒オーラ", "防具", o_name);
246 #else
247         msg_format("A %s tries to %s, but your %s resists the effects!", "terrible black aura", "surround your armor", o_name);
248 #endif
249         return true;
250     }
251
252     /* not artifact or failed save... */
253     msg_format(_("恐怖の暗黒オーラがあなたの%sを包み込んだ!", "A terrible black aura blasts your %s!"), o_name);
254     chg_virtue(player_ptr, V_ENCHANT, -5);
255
256     /* Blast the armor */
257     o_ptr->fixed_artifact_idx = 0;
258     o_ptr->ego_idx = EgoType::BLASTED;
259     o_ptr->to_a = 0 - randint1(5) - randint1(5);
260     o_ptr->to_h = 0;
261     o_ptr->to_d = 0;
262     o_ptr->ac = 0;
263     o_ptr->dd = 0;
264     o_ptr->ds = 0;
265
266     o_ptr->art_flags.clear();
267
268     /* Curse it */
269     o_ptr->curse_flags.set(CurseTraitType::CURSED);
270
271     /* Break it */
272     o_ptr->ident |= (IDENT_BROKEN);
273     player_ptr->update |= (PU_BONUS | PU_MANA);
274     player_ptr->window_flags |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
275     return true;
276 }
277
278 /*!
279  * @brief 武器呪縛処理 /
280  * Curse the players weapon
281  * @param player_ptr 所持者の参照ポインタ
282  * @param force 無条件に呪縛を行うならばTRUE
283  * @param o_ptr 呪縛する武器のアイテム情報参照ポインタ
284  * @return 何も持っていない場合を除き、常にTRUEを返す
285  * @todo 元のreturnは間違っているが、修正後の↓文がどれくらい正しいかは要チェック
286  */
287 bool curse_weapon_object(PlayerType *player_ptr, bool force, ObjectType *o_ptr)
288 {
289     if (!o_ptr->k_idx) {
290         return false;
291     }
292
293     GAME_TEXT o_name[MAX_NLEN];
294     describe_flavor(player_ptr, o_name, o_ptr, OD_OMIT_PREFIX);
295
296     /* Attempt a saving throw */
297     if (o_ptr->is_artifact() && (randint0(100) < 50) && !force) {
298 #ifdef JP
299         msg_format("%sが%sを包み込もうとしたが、%sはそれを跳ね返した!", "恐怖の暗黒オーラ", "武器", o_name);
300 #else
301         msg_format("A %s tries to %s, but your %s resists the effects!", "terrible black aura", "surround your weapon", o_name);
302 #endif
303         return true;
304     }
305
306     /* not artifact or failed save... */
307     if (!force) {
308         msg_format(_("恐怖の暗黒オーラがあなたの%sを包み込んだ!", "A terrible black aura blasts your %s!"), o_name);
309     }
310     chg_virtue(player_ptr, V_ENCHANT, -5);
311
312     /* Shatter the weapon */
313     o_ptr->fixed_artifact_idx = 0;
314     o_ptr->ego_idx = EgoType::SHATTERED;
315     o_ptr->to_h = 0 - randint1(5) - randint1(5);
316     o_ptr->to_d = 0 - randint1(5) - randint1(5);
317     o_ptr->to_a = 0;
318     o_ptr->ac = 0;
319     o_ptr->dd = 0;
320     o_ptr->ds = 0;
321
322     o_ptr->art_flags.clear();
323
324     /* Curse it */
325     o_ptr->curse_flags.set(CurseTraitType::CURSED);
326
327     /* Break it */
328     o_ptr->ident |= (IDENT_BROKEN);
329     player_ptr->update |= (PU_BONUS | PU_MANA);
330     player_ptr->window_flags |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
331     return true;
332 }
333
334 /*!
335  * @brief ボルトのエゴ化処理(火炎エゴのみ) /
336  * Enchant some bolts
337  * @param player_ptr プレイヤーへの参照ポインタ
338  */
339 void brand_bolts(PlayerType *player_ptr)
340 {
341     /* Use the first acceptable bolts */
342     for (int i = 0; i < INVEN_PACK; i++) {
343         auto *o_ptr = &player_ptr->inventory_list[i];
344
345         /* Skip non-bolts */
346         if (o_ptr->tval != ItemKindType::BOLT) {
347             continue;
348         }
349
350         /* Skip artifacts and ego-items */
351         if (o_ptr->is_artifact() || o_ptr->is_ego()) {
352             continue;
353         }
354
355         /* Skip cursed/broken items */
356         if (o_ptr->is_cursed() || o_ptr->is_broken()) {
357             continue;
358         }
359
360         /* Randomize */
361         if (randint0(100) < 75) {
362             continue;
363         }
364
365         msg_print(_("クロスボウの矢が炎のオーラに包まれた!", "Your bolts are covered in a fiery aura!"));
366
367         /* Ego-item */
368         o_ptr->ego_idx = EgoType::FLAME;
369         enchant_equipment(player_ptr, o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
370         return;
371     }
372
373     if (flush_failure) {
374         flush();
375     }
376     msg_print(_("炎で強化するのに失敗した。", "The fiery enchantment failed."));
377 }
378
379 /*!
380  * @brief 呪いの打ち破り処理 /
381  * Break the curse of an item
382  * @param o_ptr 呪い装備情報の参照ポインタ
383  */
384 static void break_curse(ObjectType *o_ptr)
385 {
386     BIT_FLAGS is_curse_broken = o_ptr->is_cursed() && o_ptr->curse_flags.has_not(CurseTraitType::PERMA_CURSE) && o_ptr->curse_flags.has_not(CurseTraitType::HEAVY_CURSE) && (randint0(100) < 25);
387     if (!is_curse_broken) {
388         return;
389     }
390
391     msg_print(_("かけられていた呪いが打ち破られた!", "The curse is broken!"));
392
393     o_ptr->curse_flags.clear();
394     o_ptr->ident |= (IDENT_SENSE);
395     o_ptr->feeling = FEEL_NONE;
396 }
397
398 /*!
399  * @brief 装備修正強化処理 /
400  * Enchants a plus onto an item. -RAK-
401  * @param player_ptr プレイヤーへの参照ポインタ
402  * @param o_ptr 強化するアイテムの参照ポインタ
403  * @param n 強化基本量
404  * @param eflag 強化オプション(命中/ダメージ/AC)
405  * @return 強化に成功した場合TRUEを返す
406  * @details
407  * <pre>
408  * Revamped!  Now takes item pointer, number of times to try enchanting,
409  * and a flag of what to try enchanting.  Artifacts resist enchantment
410  * some of the time, and successful enchantment to at least +0 might
411  * break a curse on the item. -CFT-
412  *
413  * Note that an item can technically be enchanted all the way to +15 if
414  * you wait a very, very, long time.  Going from +9 to +10 only works
415  * about 5% of the time, and from +10 to +11 only about 1% of the time.
416  *
417  * Note that this function can now be used on "piles" of items, and
418  * the larger the pile, the lower the chance of success.
419  * </pre>
420  */
421 bool enchant_equipment(PlayerType *player_ptr, ObjectType *o_ptr, int n, int eflag)
422 {
423     /* Large piles resist enchantment */
424     int prob = o_ptr->number * 100;
425
426     /* Missiles are easy to enchant */
427     if ((o_ptr->tval == ItemKindType::BOLT) || (o_ptr->tval == ItemKindType::ARROW) || (o_ptr->tval == ItemKindType::SHOT)) {
428         prob = prob / 20;
429     }
430
431     /* Try "n" times */
432     int chance;
433     bool res = false;
434     bool a = o_ptr->is_artifact();
435     bool force = (eflag & ENCH_FORCE);
436     for (int i = 0; i < n; i++) {
437         /* Hack -- Roll for pile resistance */
438         if (!force && randint0(prob) >= 100) {
439             continue;
440         }
441
442         /* Enchant to hit */
443         if (eflag & ENCH_TOHIT) {
444             if (o_ptr->to_h < 0) {
445                 chance = 0;
446             } else if (o_ptr->to_h > 15) {
447                 chance = 1000;
448             } else {
449                 chance = enchant_table[o_ptr->to_h];
450             }
451
452             if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50)))) {
453                 o_ptr->to_h++;
454                 res = true;
455
456                 /* only when you get it above -1 -CFT */
457                 if (o_ptr->to_h >= 0) {
458                     break_curse(o_ptr);
459                 }
460             }
461         }
462
463         /* Enchant to damage */
464         if (eflag & ENCH_TODAM) {
465             if (o_ptr->to_d < 0) {
466                 chance = 0;
467             } else if (o_ptr->to_d > 15) {
468                 chance = 1000;
469             } else {
470                 chance = enchant_table[o_ptr->to_d];
471             }
472
473             if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50)))) {
474                 o_ptr->to_d++;
475                 res = true;
476
477                 /* only when you get it above -1 -CFT */
478                 if (o_ptr->to_d >= 0) {
479                     break_curse(o_ptr);
480                 }
481             }
482         }
483
484         /* Enchant to armor class */
485         if (!(eflag & ENCH_TOAC)) {
486             continue;
487         }
488
489         if (o_ptr->to_a < 0) {
490             chance = 0;
491         } else if (o_ptr->to_a > 15) {
492             chance = 1000;
493         } else {
494             chance = enchant_table[o_ptr->to_a];
495         }
496
497         if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50)))) {
498             o_ptr->to_a++;
499             res = true;
500
501             /* only when you get it above -1 -CFT */
502             if (o_ptr->to_a >= 0) {
503                 break_curse(o_ptr);
504             }
505         }
506     }
507
508     /* Failure */
509     if (!res) {
510         return false;
511     }
512     set_bits(player_ptr->update, PU_BONUS | PU_COMBINE | PU_REORDER);
513     set_bits(player_ptr->window_flags, PW_INVEN | PW_EQUIP | PW_PLAYER | PW_FLOOR_ITEM_LIST);
514
515     /* Success */
516     return true;
517 }
518
519 /*!
520  * @brief 装備修正強化処理のメインルーチン /
521  * Enchant an item (in the inventory or on the floor)
522  * @param player_ptr プレイヤーへの参照ポインタ
523  * @param num_hit 命中修正量
524  * @param num_dam ダメージ修正量
525  * @param num_ac AC修正量
526  * @return 強化に成功した場合TRUEを返す
527  * @details
528  * Note that "num_ac" requires armour, else weapon
529  * Returns TRUE if attempted, FALSE if cancelled
530  */
531 bool enchant_spell(PlayerType *player_ptr, HIT_PROB num_hit, int num_dam, ARMOUR_CLASS num_ac)
532 {
533     /* Assume enchant weapon */
534     FuncItemTester item_tester(&ObjectType::allow_enchant_weapon);
535
536     /* Enchant armor if requested */
537     if (num_ac) {
538         item_tester = FuncItemTester(&ObjectType::is_armour);
539     }
540
541     concptr q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
542     concptr s = _("強化できるアイテムがない。", "You have nothing to enchant.");
543
544     OBJECT_IDX item;
545     ObjectType *o_ptr;
546     o_ptr = choose_object(player_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), item_tester);
547     if (!o_ptr) {
548         return false;
549     }
550
551     GAME_TEXT o_name[MAX_NLEN];
552     describe_flavor(player_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
553 #ifdef JP
554     msg_format("%s は明るく輝いた!", o_name);
555 #else
556     msg_format("%s %s glow%s brightly!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
557 #endif
558
559     /* Enchant */
560     bool is_enchant_successful = false;
561     if (enchant_equipment(player_ptr, o_ptr, num_hit, ENCH_TOHIT)) {
562         is_enchant_successful = true;
563     }
564     if (enchant_equipment(player_ptr, o_ptr, num_dam, ENCH_TODAM)) {
565         is_enchant_successful = true;
566     }
567     if (enchant_equipment(player_ptr, o_ptr, num_ac, ENCH_TOAC)) {
568         is_enchant_successful = true;
569     }
570
571     if (!is_enchant_successful) {
572         if (flush_failure) {
573             flush();
574         }
575         msg_print(_("強化に失敗した。", "The enchantment failed."));
576         if (one_in_(3)) {
577             chg_virtue(player_ptr, V_ENCHANT, -1);
578         }
579     } else {
580         chg_virtue(player_ptr, V_ENCHANT, 1);
581     }
582
583     calc_android_exp(player_ptr);
584
585     /* Something happened */
586     return true;
587 }
588
589 /*!
590  * @brief 武器へのエゴ付加処理 /
591  * Brand the current weapon
592  * @param player_ptr プレイヤーへの参照ポインタ
593  * @param brand_type エゴ化ID(e_info.txtとは連動していない)
594  */
595 void brand_weapon(PlayerType *player_ptr, int brand_type)
596 {
597     concptr q = _("どの武器を強化しますか? ", "Enchant which weapon? ");
598     concptr s = _("強化できる武器がない。", "You have nothing to enchant.");
599
600     OBJECT_IDX item;
601     ObjectType *o_ptr;
602     o_ptr = choose_object(player_ptr, &item, q, s, USE_EQUIP | IGNORE_BOTHHAND_SLOT, FuncItemTester(&ObjectType::allow_enchant_melee_weapon));
603     if (!o_ptr) {
604         return;
605     }
606
607     bool is_special_item = o_ptr->k_idx && !o_ptr->is_artifact() && !o_ptr->is_ego() && !o_ptr->is_cursed() && !((o_ptr->tval == ItemKindType::SWORD) && (o_ptr->sval == SV_POISON_NEEDLE)) && !((o_ptr->tval == ItemKindType::POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) && !((o_ptr->tval == ItemKindType::SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE));
608     if (!is_special_item) {
609         if (flush_failure) {
610             flush();
611         }
612
613         msg_print(_("属性付加に失敗した。", "The branding failed."));
614         chg_virtue(player_ptr, V_ENCHANT, -2);
615         calc_android_exp(player_ptr);
616         return;
617     }
618
619     GAME_TEXT o_name[MAX_NLEN];
620     describe_flavor(player_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
621
622     concptr act = nullptr;
623     switch (brand_type) {
624     case 17:
625         if (o_ptr->tval == ItemKindType::SWORD) {
626             act = _("は鋭さを増した!", "becomes very sharp!");
627
628             o_ptr->ego_idx = EgoType::SHARPNESS;
629             o_ptr->pval = (PARAMETER_VALUE)m_bonus(5, player_ptr->current_floor_ptr->dun_level) + 1;
630
631             if ((o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2)) {
632                 o_ptr->pval = 2;
633             }
634         } else {
635             act = _("は破壊力を増した!", "seems very powerful.");
636             o_ptr->ego_idx = EgoType::EARTHQUAKES;
637             o_ptr->pval = (PARAMETER_VALUE)m_bonus(3, player_ptr->current_floor_ptr->dun_level);
638         }
639
640         break;
641     case 16:
642         act = _("は人間の血を求めている!", "seems to be looking for humans!");
643         o_ptr->ego_idx = EgoType::KILL_HUMAN;
644         break;
645     case 15:
646         act = _("は電撃に覆われた!", "covered with lightning!");
647         o_ptr->ego_idx = EgoType::BRAND_ELEC;
648         break;
649     case 14:
650         act = _("は酸に覆われた!", "coated with acid!");
651         o_ptr->ego_idx = EgoType::BRAND_ACID;
652         break;
653     case 13:
654         act = _("は邪悪なる怪物を求めている!", "seems to be looking for evil monsters!");
655         o_ptr->ego_idx = EgoType::KILL_EVIL;
656         break;
657     case 12:
658         act = _("は異世界の住人の肉体を求めている!", "seems to be looking for demons!");
659         o_ptr->ego_idx = EgoType::KILL_DEMON;
660         break;
661     case 11:
662         act = _("は屍を求めている!", "seems to be looking for undead!");
663         o_ptr->ego_idx = EgoType::KILL_UNDEAD;
664         break;
665     case 10:
666         act = _("は動物の血を求めている!", "seems to be looking for animals!");
667         o_ptr->ego_idx = EgoType::KILL_ANIMAL;
668         break;
669     case 9:
670         act = _("はドラゴンの血を求めている!", "seems to be looking for dragons!");
671         o_ptr->ego_idx = EgoType::KILL_DRAGON;
672         break;
673     case 8:
674         act = _("はトロルの血を求めている!", "seems to be looking for troll!s");
675         o_ptr->ego_idx = EgoType::KILL_TROLL;
676         break;
677     case 7:
678         act = _("はオークの血を求めている!", "seems to be looking for orcs!");
679         o_ptr->ego_idx = EgoType::KILL_ORC;
680         break;
681     case 6:
682         act = _("は巨人の血を求めている!", "seems to be looking for giants!");
683         o_ptr->ego_idx = EgoType::KILL_GIANT;
684         break;
685     case 5:
686         act = _("は非常に不安定になったようだ。", "seems very unstable now.");
687         o_ptr->ego_idx = EgoType::TRUMP;
688         o_ptr->pval = randint1(2);
689         break;
690     case 4:
691         act = _("は血を求めている!", "thirsts for blood!");
692         o_ptr->ego_idx = EgoType::VAMPIRIC;
693         break;
694     case 3:
695         act = _("は毒に覆われた。", "is coated with poison.");
696         o_ptr->ego_idx = EgoType::BRAND_POIS;
697         break;
698     case 2:
699         act = _("は純ログルスに飲み込まれた。", "is engulfed in raw Logrus!");
700         o_ptr->ego_idx = EgoType::CHAOTIC;
701         break;
702     case 1:
703         act = _("は炎のシールドに覆われた!", "is covered in a fiery shield!");
704         o_ptr->ego_idx = EgoType::BRAND_FIRE;
705         break;
706     default:
707         act = _("は深く冷たいブルーに輝いた!", "glows deep, icy blue!");
708         o_ptr->ego_idx = EgoType::BRAND_COLD;
709         break;
710     }
711
712     msg_format(_("あなたの%s%s", "Your %s %s"), o_name, act);
713     enchant_equipment(player_ptr, o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
714     o_ptr->discount = 99;
715     chg_virtue(player_ptr, V_ENCHANT, 2);
716     calc_android_exp(player_ptr);
717 }