2 * @brief アイテムに影響のある魔法の処理
7 #include "spell/spells-object.h"
8 #include "action/action-limited.h"
9 #include "autopick/autopick.h"
10 #include "core/asking-player.h"
11 #include "core/player-redraw-types.h"
12 #include "core/player-update-types.h"
13 #include "core/window-redrawer.h"
14 #include "flavor/flavor-describer.h"
15 #include "flavor/object-flavor-types.h"
16 #include "floor/cave.h"
17 #include "floor/floor-object.h"
18 #include "game-option/disturbance-options.h"
19 #include "grid/feature.h"
20 #include "grid/grid.h"
21 #include "inventory/inventory-object.h"
22 #include "inventory/inventory-slot-types.h"
23 #include "inventory/player-inventory.h"
24 #include "monster-race/monster-race.h"
25 #include "monster-race/race-flags1.h"
26 #include "object-enchant/apply-magic.h"
27 #include "object-enchant/item-apply-magic.h"
28 #include "object-enchant/item-feeling.h"
29 #include "object-enchant/object-boost.h"
30 #include "object-enchant/object-ego.h"
31 #include "object-enchant/special-object-flags.h"
32 #include "object-enchant/tr-types.h"
33 #include "object-enchant/trc-types.h"
34 #include "object-enchant/trg-types.h"
35 #include "object-hook/hook-armor.h"
36 #include "object-hook/hook-bow.h"
37 #include "object-hook/hook-checker.h"
38 #include "object-hook/hook-enchant.h"
39 #include "object-hook/hook-magic.h"
40 #include "object-hook/hook-weapon.h"
41 #include "object/item-tester-hooker.h"
42 #include "object/item-use-flags.h"
43 #include "object/object-flags.h"
44 #include "object/object-generator.h"
45 #include "object/object-kind-hook.h"
46 #include "object/object-kind.h"
47 #include "perception/object-perception.h"
48 #include "player-info/avatar.h"
49 #include "player/player-class.h"
50 #include "player/player-damage.h"
51 #include "player/player-status.h"
52 #include "racial/racial-android.h"
53 #include "spell-kind/spells-perception.h"
54 #include "status/bad-status-setter.h"
55 #include "sv-definition/sv-food-types.h"
56 #include "sv-definition/sv-lite-types.h"
57 #include "sv-definition/sv-other-types.h"
58 #include "sv-definition/sv-protector-types.h"
59 #include "sv-definition/sv-scroll-types.h"
60 #include "sv-definition/sv-staff-types.h"
61 #include "sv-definition/sv-weapon-types.h"
62 #include "system/artifact-type-definition.h"
63 #include "system/floor-type-definition.h"
64 #include "system/object-type-definition.h"
65 #include "target/target-getter.h"
66 #include "term/screen-processor.h"
67 #include "util/bit-flags-calculator.h"
68 #include "view/display-messages.h"
72 OBJECT_SUBTYPE_VALUE sval;
78 * @brief 装備強化処理の失敗率定数(千分率) /
79 * Used by the "enchant" function (chance of failure)
80 * (modified for Zangband, we need better stuff there...) -- TY
83 static int enchant_table[16] = { 0, 10, 50, 100, 200, 300, 400, 500, 650, 800, 950, 987, 993, 995, 998, 1000 };
86 * Scatter some "amusing" objects near the player
89 #define AMS_NOTHING 0x00 /* No restriction */
90 #define AMS_NO_UNIQUE 0x01 /* Don't make the amusing object of uniques */
91 #define AMS_FIXED_ART 0x02 /* Make a fixed artifact based on the amusing object */
92 #define AMS_MULTIPLE 0x04 /* Drop 1-3 objects for one type */
93 #define AMS_PILE 0x08 /* Drop 1-99 pile objects for one type */
95 static amuse_type amuse_info[]
96 = { { TV_BOTTLE, SV_ANY, 5, AMS_NOTHING }, { TV_JUNK, SV_ANY, 3, AMS_MULTIPLE }, { TV_SPIKE, SV_ANY, 10, AMS_PILE }, { TV_STATUE, SV_ANY, 15, AMS_NOTHING },
97 { TV_CORPSE, SV_ANY, 15, AMS_NO_UNIQUE }, { TV_SKELETON, SV_ANY, 10, AMS_NO_UNIQUE }, { TV_FIGURINE, SV_ANY, 10, AMS_NO_UNIQUE },
98 { TV_PARCHMENT, SV_ANY, 1, AMS_NOTHING }, { TV_POLEARM, SV_TSURIZAO, 3, AMS_NOTHING }, // Fishing Pole of Taikobo
99 { TV_SWORD, SV_BROKEN_DAGGER, 3, AMS_FIXED_ART }, // Broken Dagger of Magician
100 { TV_SWORD, SV_BROKEN_DAGGER, 10, AMS_NOTHING }, { TV_SWORD, SV_BROKEN_SWORD, 5, AMS_NOTHING }, { TV_SCROLL, SV_SCROLL_AMUSEMENT, 10, AMS_NOTHING },
106 * @param creature_ptr プレーヤーへの参照ポインタ
107 * @param y1 配置したいフロアのY座標
108 * @param x1 配置したいフロアのX座標
110 * @param known TRUEならばオブジェクトが必ず*鑑定*済になる
113 void amusement(player_type *creature_ptr, POSITION y1, POSITION x1, int num, bool known)
116 for (int n = 0; amuse_info[n].tval != 0; n++) {
117 t += amuse_info[n].prob;
122 object_type object_type_body;
125 KIND_OBJECT_IDX k_idx;
126 ARTIFACT_IDX a_idx = 0;
128 bool insta_art, fixed_art;
131 r -= amuse_info[i].prob;
135 i_ptr = &object_type_body;
137 k_idx = lookup_kind(amuse_info[i].tval, amuse_info[i].sval);
139 /* Paranoia - reroll if nothing */
143 /* Search an artifact index if need */
144 insta_art = (k_info[k_idx].gen_flags & TRG_INSTA_ART);
145 fixed_art = (amuse_info[i].flag & AMS_FIXED_ART);
147 if (insta_art || fixed_art) {
148 for (a_idx = 1; a_idx < max_a_idx; a_idx++) {
149 if (insta_art && !(a_info[a_idx].gen_flags & TRG_INSTA_ART))
151 if (a_info[a_idx].tval != k_info[k_idx].tval)
153 if (a_info[a_idx].sval != k_info[k_idx].sval)
155 if (a_info[a_idx].cur_num > 0)
160 if (a_idx >= max_a_idx)
164 /* Make an object (if possible) */
165 object_prep(creature_ptr, i_ptr, k_idx);
167 i_ptr->name1 = a_idx;
168 apply_magic(creature_ptr, i_ptr, 1, AM_NO_FIXED_ART);
170 if (amuse_info[i].flag & AMS_NO_UNIQUE) {
171 if (r_info[i_ptr->pval].flags1 & RF1_UNIQUE)
175 if (amuse_info[i].flag & AMS_MULTIPLE)
176 i_ptr->number = randint1(3);
177 if (amuse_info[i].flag & AMS_PILE)
178 i_ptr->number = randint1(99);
181 object_aware(creature_ptr, i_ptr);
185 /* Paranoia - reroll if nothing */
189 (void)drop_near(creature_ptr, i_ptr, -1, y1, x1);
197 * Scatter some "great" objects near the player
198 * @param caster_ptr プレーヤーへの参照ポインタ
199 * @param y1 配置したいフロアのY座標
200 * @param x1 配置したいフロアのX座標
202 * @param great TRUEならば必ず高級品以上を落とす
203 * @param special TRUEならば必ず特別品を落とす
204 * @param known TRUEならばオブジェクトが必ず*鑑定*済になる
207 void acquirement(player_type *caster_ptr, POSITION y1, POSITION x1, int num, bool great, bool special, bool known)
210 object_type object_type_body;
211 BIT_FLAGS mode = AM_GOOD | (great || special ? AM_GREAT : 0L) | (special ? AM_SPECIAL : 0L);
215 i_ptr = &object_type_body;
218 /* Make a good (or great) object (if possible) */
219 if (!make_object(caster_ptr, i_ptr, mode))
223 object_aware(caster_ptr, i_ptr);
227 (void)drop_near(caster_ptr, i_ptr, -1, y1, x1);
232 * todo 元のreturnは間違っているが、修正後の↓文がどれくらい正しいかは要チェック
234 * Curse the players armor
235 * @return 何も持っていない場合を除き、常にTRUEを返す
237 bool curse_armor(player_type *owner_ptr)
239 /* Curse the body armor */
241 o_ptr = &owner_ptr->inventory_list[INVEN_BODY];
246 GAME_TEXT o_name[MAX_NLEN];
247 describe_flavor(owner_ptr, o_name, o_ptr, OD_OMIT_PREFIX);
249 /* Attempt a saving throw for artifacts */
250 if (object_is_artifact(o_ptr) && (randint0(100) < 50)) {
253 msg_format("%sが%sを包み込もうとしたが、%sはそれを跳ね返した!", "恐怖の暗黒オーラ", "防具", o_name);
255 msg_format("A %s tries to %s, but your %s resists the effects!", "terrible black aura", "surround your armor", o_name);
260 /* not artifact or failed save... */
261 msg_format(_("恐怖の暗黒オーラがあなたの%sを包み込んだ!", "A terrible black aura blasts your %s!"), o_name);
262 chg_virtue(owner_ptr, V_ENCHANT, -5);
264 /* Blast the armor */
266 o_ptr->name2 = EGO_BLASTED;
267 o_ptr->to_a = 0 - randint1(5) - randint1(5);
274 for (int i = 0; i < TR_FLAG_SIZE; i++)
275 o_ptr->art_flags[i] = 0;
278 o_ptr->curse_flags = TRC_CURSED;
281 o_ptr->ident |= (IDENT_BROKEN);
282 owner_ptr->update |= (PU_BONUS | PU_MANA);
283 owner_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
288 * todo 元のreturnは間違っているが、修正後の↓文がどれくらい正しいかは要チェック
290 * Curse the players weapon
291 * @param owner_ptr 所持者の参照ポインタ
292 * @param force 無条件に呪縛を行うならばTRUE
293 * @param o_ptr 呪縛する武器のアイテム情報参照ポインタ
294 * @return 何も持っていない場合を除き、常にTRUEを返す
296 bool curse_weapon_object(player_type *owner_ptr, bool force, object_type *o_ptr)
301 GAME_TEXT o_name[MAX_NLEN];
302 describe_flavor(owner_ptr, o_name, o_ptr, OD_OMIT_PREFIX);
304 /* Attempt a saving throw */
305 if (object_is_artifact(o_ptr) && (randint0(100) < 50) && !force) {
307 msg_format("%sが%sを包み込もうとしたが、%sはそれを跳ね返した!", "恐怖の暗黒オーラ", "武器", o_name);
309 msg_format("A %s tries to %s, but your %s resists the effects!", "terrible black aura", "surround your weapon", o_name);
314 /* not artifact or failed save... */
316 msg_format(_("恐怖の暗黒オーラがあなたの%sを包み込んだ!", "A terrible black aura blasts your %s!"), o_name);
317 chg_virtue(owner_ptr, V_ENCHANT, -5);
319 /* Shatter the weapon */
321 o_ptr->name2 = EGO_SHATTERED;
322 o_ptr->to_h = 0 - randint1(5) - randint1(5);
323 o_ptr->to_d = 0 - randint1(5) - randint1(5);
329 for (int i = 0; i < TR_FLAG_SIZE; i++)
330 o_ptr->art_flags[i] = 0;
333 o_ptr->curse_flags = TRC_CURSED;
336 o_ptr->ident |= (IDENT_BROKEN);
337 owner_ptr->update |= (PU_BONUS | PU_MANA);
338 owner_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
344 * @param caster_ptr 錆止め実行者の参照ポインタ
345 * @return ターン消費を要する処理を行ったならばTRUEを返す
347 bool rustproof(player_type *caster_ptr)
349 /* Select a piece of armour */
350 item_tester_hook = object_is_armour;
352 concptr q = _("どの防具に錆止めをしますか?", "Rustproof which piece of armour? ");
353 concptr s = _("錆止めできるものがありません。", "You have nothing to rustproof.");
357 o_ptr = choose_object(caster_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
361 GAME_TEXT o_name[MAX_NLEN];
362 describe_flavor(caster_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
364 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
366 if ((o_ptr->to_a < 0) && !object_is_cursed(o_ptr)) {
368 msg_format("%sは新品同様になった!", o_name);
370 msg_format("%s %s look%s as good as new!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
377 msg_format("%sは腐食しなくなった。", o_name);
379 msg_format("%s %s %s now protected against corrosion.", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "are" : "is"));
382 calc_android_exp(caster_ptr);
387 * @brief ボルトのエゴ化処理(火炎エゴのみ) /
389 * @param caster_ptr プレーヤーへの参照ポインタ
392 void brand_bolts(player_type *caster_ptr)
394 /* Use the first acceptable bolts */
395 for (int i = 0; i < INVEN_PACK; i++) {
396 object_type *o_ptr = &caster_ptr->inventory_list[i];
399 if (o_ptr->tval != TV_BOLT)
402 /* Skip artifacts and ego-items */
403 if (object_is_artifact(o_ptr) || object_is_ego(o_ptr))
406 /* Skip cursed/broken items */
407 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr))
411 if (randint0(100) < 75)
414 msg_print(_("クロスボウの矢が炎のオーラに包まれた!", "Your bolts are covered in a fiery aura!"));
417 o_ptr->name2 = EGO_FLAME;
418 enchant(caster_ptr, o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
424 msg_print(_("炎で強化するのに失敗した。", "The fiery enchantment failed."));
427 bool perilous_secrets(player_type *user_ptr)
429 if (!ident_spell(user_ptr, FALSE, 0))
432 if (mp_ptr->spell_book) {
433 /* Sufficient mana */
434 if (20 <= user_ptr->csp) {
439 /* Over-exert the player */
441 int oops = 20 - user_ptr->csp;
445 user_ptr->csp_frac = 0;
447 msg_print(_("石を制御できない!", "You are too weak to control the stone!"));
448 /* Hack -- Bypass free action */
449 (void)set_paralyzed(user_ptr, user_ptr->paralyzed + randint1(5 * oops + 1));
452 (void)set_confused(user_ptr, user_ptr->confused + randint1(5 * oops + 1));
455 user_ptr->redraw |= (PR_MANA);
458 take_hit(user_ptr, DAMAGE_LOSELIFE, damroll(1, 12), _("危険な秘密", "perilous secrets"), -1);
461 (void)set_confused(user_ptr, user_ptr->confused + randint1(10));
463 /* Exercise a little care... */
465 take_hit(user_ptr, DAMAGE_LOSELIFE, damroll(4, 10), _("危険な秘密", "perilous secrets"), -1);
470 * @brief 寿命つき光源の燃素追加処理 /
471 * Charge a lite (torch or latern)
474 void phlogiston(player_type *caster_ptr)
476 GAME_TURN max_flog = 0;
477 object_type *o_ptr = &caster_ptr->inventory_list[INVEN_LITE];
480 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_LANTERN)) {
481 max_flog = FUEL_LAMP;
485 else if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH)) {
486 max_flog = FUEL_TORCH;
489 /* No torch to refill */
491 msg_print(_("燃素を消費するアイテムを装備していません。", "You are not wielding anything which uses phlogiston."));
495 if (o_ptr->xtra4 >= max_flog) {
496 msg_print(_("このアイテムにはこれ以上燃素を補充できません。", "No more phlogiston can be put in this item."));
501 o_ptr->xtra4 += (XTRA16)(max_flog / 2);
502 msg_print(_("照明用アイテムに燃素を補充した。", "You add phlogiston to your light item."));
504 if (o_ptr->xtra4 >= max_flog) {
505 o_ptr->xtra4 = (XTRA16)max_flog;
506 msg_print(_("照明用アイテムは満タンになった。", "Your light item is full."));
509 caster_ptr->update |= (PU_TORCH);
515 * @return ターン消費を要する処理を行ったならばTRUEを返す
517 bool bless_weapon(player_type *caster_ptr)
519 /* Bless only weapons */
520 item_tester_hook = object_is_weapon;
522 concptr q = _("どのアイテムを祝福しますか?", "Bless which weapon? ");
523 concptr s = _("祝福できる武器がありません。", "You have weapon to bless.");
527 o_ptr = choose_object(caster_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
531 GAME_TEXT o_name[MAX_NLEN];
532 describe_flavor(caster_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
533 BIT_FLAGS flgs[TR_FLAG_SIZE];
534 object_flags(caster_ptr, o_ptr, flgs);
536 if (object_is_cursed(o_ptr)) {
537 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) || have_flag(flgs, TR_ADD_L_CURSE) || have_flag(flgs, TR_ADD_H_CURSE)
538 || (o_ptr->curse_flags & TRC_PERMA_CURSE)) {
540 msg_format("%sを覆う黒いオーラは祝福を跳ね返した!", o_name);
542 msg_format("The black aura on %s %s disrupts the blessing!", ((item >= 0) ? "your" : "the"), o_name);
549 msg_format("%s から邪悪なオーラが消えた。", o_name);
551 msg_format("A malignant aura leaves %s %s.", ((item >= 0) ? "your" : "the"), o_name);
554 o_ptr->curse_flags = 0L;
556 o_ptr->ident |= (IDENT_SENSE);
557 o_ptr->feeling = FEEL_NONE;
559 /* Recalculate the bonuses */
560 caster_ptr->update |= (PU_BONUS);
561 caster_ptr->window |= (PW_EQUIP);
565 * Next, we try to bless it. Artifacts have a 1/3 chance of
566 * being blessed, otherwise, the operation simply disenchants
567 * them, godly power negating the magic. Ok, the explanation
568 * is silly, but otherwise priests would always bless every
569 * artifact weapon they find. Ego weapons and normal weapons
570 * can be blessed automatically.
572 if (have_flag(flgs, TR_BLESSED)) {
574 msg_format("%s は既に祝福されている。", o_name);
576 msg_format("%s %s %s blessed already.", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "were" : "was"));
582 if (!(object_is_artifact(o_ptr) || object_is_ego(o_ptr)) || one_in_(3)) {
584 msg_format("%sは輝いた!", o_name);
586 msg_format("%s %s shine%s!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
589 add_flag(o_ptr->art_flags, TR_BLESSED);
590 o_ptr->discount = 99;
592 bool dis_happened = FALSE;
593 msg_print(_("その武器は祝福を嫌っている!", "The weapon resists your blessing!"));
595 /* Disenchant tohit */
596 if (o_ptr->to_h > 0) {
601 if ((o_ptr->to_h > 5) && (randint0(100) < 33))
604 /* Disenchant todam */
605 if (o_ptr->to_d > 0) {
610 if ((o_ptr->to_d > 5) && (randint0(100) < 33))
613 /* Disenchant toac */
614 if (o_ptr->to_a > 0) {
619 if ((o_ptr->to_a > 5) && (randint0(100) < 33))
623 msg_print(_("周囲が凡庸な雰囲気で満ちた...", "There is a static feeling in the air..."));
626 msg_format("%s は劣化した!", o_name);
628 msg_format("%s %s %s disenchanted!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "were" : "was"));
633 caster_ptr->update |= (PU_BONUS);
634 caster_ptr->window |= (PW_EQUIP | PW_PLAYER);
635 calc_android_exp(caster_ptr);
643 * @return ターン消費を要する処理を行ったならばTRUEを返す
645 bool pulish_shield(player_type *caster_ptr)
647 concptr q = _("どの盾を磨きますか?", "Pulish which weapon? ");
648 concptr s = _("磨く盾がありません。", "You have weapon to pulish.");
652 o_ptr = choose_object(caster_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), TV_SHIELD);
656 GAME_TEXT o_name[MAX_NLEN];
657 describe_flavor(caster_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
658 BIT_FLAGS flgs[TR_FLAG_SIZE];
659 object_flags(caster_ptr, o_ptr, flgs);
661 bool is_pulish_successful = o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr);
662 is_pulish_successful &= !object_is_cursed(o_ptr);
663 is_pulish_successful &= (o_ptr->sval != SV_MIRROR_SHIELD);
664 if (is_pulish_successful) {
666 msg_format("%sは輝いた!", o_name);
668 msg_format("%s %s shine%s!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
670 o_ptr->name2 = EGO_REFLECTION;
671 enchant(caster_ptr, o_ptr, randint0(3) + 4, ENCH_TOAC);
673 o_ptr->discount = 99;
674 chg_virtue(caster_ptr, V_ENCHANT, 2);
682 msg_print(_("失敗した。", "Failed."));
683 chg_virtue(caster_ptr, V_ENCHANT, -2);
684 calc_android_exp(caster_ptr);
690 * Break the curse of an item
691 * @param o_ptr 呪い装備情報の参照ポインタ
694 static void break_curse(object_type *o_ptr)
696 BIT_FLAGS is_curse_broken
697 = object_is_cursed(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25);
698 if (!is_curse_broken) {
702 msg_print(_("かけられていた呪いが打ち破られた!", "The curse is broken!"));
704 o_ptr->curse_flags = 0L;
705 o_ptr->ident |= (IDENT_SENSE);
706 o_ptr->feeling = FEEL_NONE;
711 * Enchants a plus onto an item. -RAK-
712 * @param caster_ptr プレーヤーへの参照ポインタ
713 * @param o_ptr 強化するアイテムの参照ポインタ
715 * @param eflag 強化オプション(命中/ダメージ/AC)
716 * @return 強化に成功した場合TRUEを返す
719 * Revamped! Now takes item pointer, number of times to try enchanting,
720 * and a flag of what to try enchanting. Artifacts resist enchantment
721 * some of the time, and successful enchantment to at least +0 might
722 * break a curse on the item. -CFT-
724 * Note that an item can technically be enchanted all the way to +15 if
725 * you wait a very, very, long time. Going from +9 to +10 only works
726 * about 5% of the time, and from +10 to +11 only about 1% of the time.
728 * Note that this function can now be used on "piles" of items, and
729 * the larger the pile, the lower the chance of success.
732 bool enchant(player_type *caster_ptr, object_type *o_ptr, int n, int eflag)
734 /* Large piles resist enchantment */
735 int prob = o_ptr->number * 100;
737 /* Missiles are easy to enchant */
738 if ((o_ptr->tval == TV_BOLT) || (o_ptr->tval == TV_ARROW) || (o_ptr->tval == TV_SHOT)) {
745 bool a = object_is_artifact(o_ptr);
746 bool force = (eflag & ENCH_FORCE);
747 for (int i = 0; i < n; i++) {
748 /* Hack -- Roll for pile resistance */
749 if (!force && randint0(prob) >= 100)
753 if (eflag & ENCH_TOHIT) {
756 else if (o_ptr->to_h > 15)
759 chance = enchant_table[o_ptr->to_h];
761 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50)))) {
765 /* only when you get it above -1 -CFT */
766 if (o_ptr->to_h >= 0)
771 /* Enchant to damage */
772 if (eflag & ENCH_TODAM) {
775 else if (o_ptr->to_d > 15)
778 chance = enchant_table[o_ptr->to_d];
780 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50)))) {
784 /* only when you get it above -1 -CFT */
785 if (o_ptr->to_d >= 0)
790 /* Enchant to armor class */
791 if (!(eflag & ENCH_TOAC)) {
797 else if (o_ptr->to_a > 15)
800 chance = enchant_table[o_ptr->to_a];
802 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50)))) {
806 /* only when you get it above -1 -CFT */
807 if (o_ptr->to_a >= 0)
815 caster_ptr->update |= (PU_BONUS | PU_COMBINE | PU_REORDER);
816 caster_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
818 calc_android_exp(caster_ptr);
825 * @brief 装備修正強化処理のメインルーチン /
826 * Enchant an item (in the inventory or on the floor)
827 * @param caster_ptr プレーヤーへの参照ポインタ
828 * @param num_hit 命中修正量
829 * @param num_dam ダメージ修正量
830 * @param num_ac AC修正量
831 * @return 強化に成功した場合TRUEを返す
833 * Note that "num_ac" requires armour, else weapon
834 * Returns TRUE if attempted, FALSE if cancelled
836 bool enchant_spell(player_type *caster_ptr, HIT_PROB num_hit, HIT_POINT num_dam, ARMOUR_CLASS num_ac)
838 /* Assume enchant weapon */
839 item_tester_hook = object_allow_enchant_weapon;
841 /* Enchant armor if requested */
843 item_tester_hook = object_is_armour;
845 concptr q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
846 concptr s = _("強化できるアイテムがない。", "You have nothing to enchant.");
850 o_ptr = choose_object(caster_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
854 GAME_TEXT o_name[MAX_NLEN];
855 describe_flavor(caster_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
857 msg_format("%s は明るく輝いた!", o_name);
859 msg_format("%s %s glow%s brightly!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
863 bool is_enchant_successful = FALSE;
864 if (enchant(caster_ptr, o_ptr, num_hit, ENCH_TOHIT))
865 is_enchant_successful = TRUE;
866 if (enchant(caster_ptr, o_ptr, num_dam, ENCH_TODAM))
867 is_enchant_successful = TRUE;
868 if (enchant(caster_ptr, o_ptr, num_ac, ENCH_TOAC))
869 is_enchant_successful = TRUE;
871 if (!is_enchant_successful) {
874 msg_print(_("強化に失敗した。", "The enchantment failed."));
876 chg_virtue(caster_ptr, V_ENCHANT, -1);
878 chg_virtue(caster_ptr, V_ENCHANT, 1);
880 calc_android_exp(caster_ptr);
882 /* Something happened */
887 * @brief 武器へのエゴ付加処理 /
888 * Brand the current weapon
889 * @param caster_ptr プレーヤーへの参照ポインタ
890 * @param brand_type エゴ化ID(e_info.txtとは連動していない)
893 void brand_weapon(player_type *caster_ptr, int brand_type)
895 /* Assume enchant weapon */
896 item_tester_hook = object_allow_enchant_melee_weapon;
898 concptr q = _("どの武器を強化しますか? ", "Enchant which weapon? ");
899 concptr s = _("強化できる武器がない。", "You have nothing to enchant.");
903 o_ptr = choose_object(caster_ptr, &item, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT), 0);
907 bool is_special_item = o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) && !object_is_cursed(o_ptr)
908 && !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_POISON_NEEDLE)) && !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE))
909 && !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE));
910 if (!is_special_item) {
914 msg_print(_("属性付加に失敗した。", "The branding failed."));
915 chg_virtue(caster_ptr, V_ENCHANT, -2);
916 calc_android_exp(caster_ptr);
920 /* Let's get the name before it is changed... */
921 GAME_TEXT o_name[MAX_NLEN];
922 describe_flavor(caster_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
925 switch (brand_type) {
927 if (o_ptr->tval == TV_SWORD) {
928 act = _("は鋭さを増した!", "becomes very sharp!");
930 o_ptr->name2 = EGO_SHARPNESS;
931 o_ptr->pval = (PARAMETER_VALUE)m_bonus(5, caster_ptr->current_floor_ptr->dun_level) + 1;
933 if ((o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2))
936 act = _("は破壊力を増した!", "seems very powerful.");
937 o_ptr->name2 = EGO_EARTHQUAKES;
938 o_ptr->pval = (PARAMETER_VALUE)m_bonus(3, caster_ptr->current_floor_ptr->dun_level);
943 act = _("は人間の血を求めている!", "seems to be looking for humans!");
944 o_ptr->name2 = EGO_KILL_HUMAN;
947 act = _("は電撃に覆われた!", "covered with lightning!");
948 o_ptr->name2 = EGO_BRAND_ELEC;
951 act = _("は酸に覆われた!", "coated with acid!");
952 o_ptr->name2 = EGO_BRAND_ACID;
955 act = _("は邪悪なる怪物を求めている!", "seems to be looking for evil monsters!");
956 o_ptr->name2 = EGO_KILL_EVIL;
959 act = _("は異世界の住人の肉体を求めている!", "seems to be looking for demons!");
960 o_ptr->name2 = EGO_KILL_DEMON;
963 act = _("は屍を求めている!", "seems to be looking for undead!");
964 o_ptr->name2 = EGO_KILL_UNDEAD;
967 act = _("は動物の血を求めている!", "seems to be looking for animals!");
968 o_ptr->name2 = EGO_KILL_ANIMAL;
971 act = _("はドラゴンの血を求めている!", "seems to be looking for dragons!");
972 o_ptr->name2 = EGO_KILL_DRAGON;
975 act = _("はトロルの血を求めている!", "seems to be looking for troll!s");
976 o_ptr->name2 = EGO_KILL_TROLL;
979 act = _("はオークの血を求めている!", "seems to be looking for orcs!");
980 o_ptr->name2 = EGO_KILL_ORC;
983 act = _("は巨人の血を求めている!", "seems to be looking for giants!");
984 o_ptr->name2 = EGO_KILL_GIANT;
987 act = _("は非常に不安定になったようだ。", "seems very unstable now.");
988 o_ptr->name2 = EGO_TRUMP;
989 o_ptr->pval = randint1(2);
992 act = _("は血を求めている!", "thirsts for blood!");
993 o_ptr->name2 = EGO_VAMPIRIC;
996 act = _("は毒に覆われた。", "is coated with poison.");
997 o_ptr->name2 = EGO_BRAND_POIS;
1000 act = _("は純ログルスに飲み込まれた。", "is engulfed in raw Logrus!");
1001 o_ptr->name2 = EGO_CHAOTIC;
1004 act = _("は炎のシールドに覆われた!", "is covered in a fiery shield!");
1005 o_ptr->name2 = EGO_BRAND_FIRE;
1008 act = _("は深く冷たいブルーに輝いた!", "glows deep, icy blue!");
1009 o_ptr->name2 = EGO_BRAND_COLD;
1013 msg_format(_("あなたの%s%s", "Your %s %s"), o_name, act);
1014 enchant(caster_ptr, o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
1016 o_ptr->discount = 99;
1017 chg_virtue(caster_ptr, V_ENCHANT, 2);
1018 calc_android_exp(caster_ptr);
1021 bool create_ration(player_type *creature_ptr)
1026 object_prep(creature_ptr, q_ptr, lookup_kind(TV_FOOD, SV_FOOD_RATION));
1027 (void)drop_near(creature_ptr, q_ptr, -1, creature_ptr->y, creature_ptr->x);
1028 msg_print(_("食事を料理して作った。", "You cook some food."));