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);
231 void acquire_chaos_weapon(player_type *creature_ptr)
234 object_type *q_ptr = &forge;
235 tval_type dummy = TV_SWORD;
236 OBJECT_SUBTYPE_VALUE dummy2;
237 switch (randint1(creature_ptr->lev)) {
244 dummy2 = SV_MAIN_GAUCHE;
255 dummy2 = SV_SMALL_SWORD;
259 dummy2 = SV_BASILLARD;
264 dummy2 = SV_SHORT_SWORD;
275 dummy2 = SV_WAKIZASHI;
284 dummy2 = SV_BROAD_SWORD;
288 dummy2 = SV_LONG_SWORD;
292 dummy2 = SV_SCIMITAR;
302 dummy2 = SV_BASTARD_SWORD;
305 dummy2 = SV_GREAT_SCIMITAR;
308 dummy2 = SV_CLAYMORE;
314 dummy2 = SV_TWO_HANDED_SWORD;
317 dummy2 = SV_FLAMBERGE;
320 dummy2 = SV_NO_DACHI;
323 dummy2 = SV_EXECUTIONERS_SWORD;
326 dummy2 = SV_ZWEIHANDER;
329 dummy2 = SV_HAYABUSA;
332 dummy2 = SV_BLADE_OF_CHAOS;
335 object_prep(creature_ptr, q_ptr, lookup_kind(dummy, dummy2));
336 q_ptr->to_h = 3 + randint1(creature_ptr->current_floor_ptr->dun_level) % 10;
337 q_ptr->to_d = 3 + randint1(creature_ptr->current_floor_ptr->dun_level) % 10;
338 one_resistance(q_ptr);
339 q_ptr->name2 = EGO_CHAOTIC;
340 (void)drop_near(creature_ptr, q_ptr, -1, creature_ptr->y, creature_ptr->x);
344 * todo 元のreturnは間違っているが、修正後の↓文がどれくらい正しいかは要チェック
346 * Curse the players armor
347 * @return 何も持っていない場合を除き、常にTRUEを返す
349 bool curse_armor(player_type *owner_ptr)
351 /* Curse the body armor */
353 o_ptr = &owner_ptr->inventory_list[INVEN_BODY];
358 GAME_TEXT o_name[MAX_NLEN];
359 describe_flavor(owner_ptr, o_name, o_ptr, OD_OMIT_PREFIX);
361 /* Attempt a saving throw for artifacts */
362 if (object_is_artifact(o_ptr) && (randint0(100) < 50)) {
365 msg_format("%sが%sを包み込もうとしたが、%sはそれを跳ね返した!", "恐怖の暗黒オーラ", "防具", o_name);
367 msg_format("A %s tries to %s, but your %s resists the effects!", "terrible black aura", "surround your armor", o_name);
372 /* not artifact or failed save... */
373 msg_format(_("恐怖の暗黒オーラがあなたの%sを包み込んだ!", "A terrible black aura blasts your %s!"), o_name);
374 chg_virtue(owner_ptr, V_ENCHANT, -5);
376 /* Blast the armor */
378 o_ptr->name2 = EGO_BLASTED;
379 o_ptr->to_a = 0 - randint1(5) - randint1(5);
386 for (int i = 0; i < TR_FLAG_SIZE; i++)
387 o_ptr->art_flags[i] = 0;
390 o_ptr->curse_flags = TRC_CURSED;
393 o_ptr->ident |= (IDENT_BROKEN);
394 owner_ptr->update |= (PU_BONUS | PU_MANA);
395 owner_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
400 * todo 元のreturnは間違っているが、修正後の↓文がどれくらい正しいかは要チェック
402 * Curse the players weapon
403 * @param owner_ptr 所持者の参照ポインタ
404 * @param force 無条件に呪縛を行うならばTRUE
405 * @param o_ptr 呪縛する武器のアイテム情報参照ポインタ
406 * @return 何も持っていない場合を除き、常にTRUEを返す
408 bool curse_weapon_object(player_type *owner_ptr, bool force, object_type *o_ptr)
413 GAME_TEXT o_name[MAX_NLEN];
414 describe_flavor(owner_ptr, o_name, o_ptr, OD_OMIT_PREFIX);
416 /* Attempt a saving throw */
417 if (object_is_artifact(o_ptr) && (randint0(100) < 50) && !force) {
419 msg_format("%sが%sを包み込もうとしたが、%sはそれを跳ね返した!", "恐怖の暗黒オーラ", "武器", o_name);
421 msg_format("A %s tries to %s, but your %s resists the effects!", "terrible black aura", "surround your weapon", o_name);
426 /* not artifact or failed save... */
428 msg_format(_("恐怖の暗黒オーラがあなたの%sを包み込んだ!", "A terrible black aura blasts your %s!"), o_name);
429 chg_virtue(owner_ptr, V_ENCHANT, -5);
431 /* Shatter the weapon */
433 o_ptr->name2 = EGO_SHATTERED;
434 o_ptr->to_h = 0 - randint1(5) - randint1(5);
435 o_ptr->to_d = 0 - randint1(5) - randint1(5);
441 for (int i = 0; i < TR_FLAG_SIZE; i++)
442 o_ptr->art_flags[i] = 0;
445 o_ptr->curse_flags = TRC_CURSED;
448 o_ptr->ident |= (IDENT_BROKEN);
449 owner_ptr->update |= (PU_BONUS | PU_MANA);
450 owner_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
456 * @param caster_ptr 錆止め実行者の参照ポインタ
457 * @return ターン消費を要する処理を行ったならばTRUEを返す
459 bool rustproof(player_type *caster_ptr)
461 /* Select a piece of armour */
462 item_tester_hook = object_is_armour;
464 concptr q = _("どの防具に錆止めをしますか?", "Rustproof which piece of armour? ");
465 concptr s = _("錆止めできるものがありません。", "You have nothing to rustproof.");
469 o_ptr = choose_object(caster_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
473 GAME_TEXT o_name[MAX_NLEN];
474 describe_flavor(caster_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
476 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
478 if ((o_ptr->to_a < 0) && !object_is_cursed(o_ptr)) {
480 msg_format("%sは新品同様になった!", o_name);
482 msg_format("%s %s look%s as good as new!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
489 msg_format("%sは腐食しなくなった。", o_name);
491 msg_format("%s %s %s now protected against corrosion.", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "are" : "is"));
494 calc_android_exp(caster_ptr);
499 * @brief ボルトのエゴ化処理(火炎エゴのみ) /
501 * @param caster_ptr プレーヤーへの参照ポインタ
504 void brand_bolts(player_type *caster_ptr)
506 /* Use the first acceptable bolts */
507 for (int i = 0; i < INVEN_PACK; i++) {
508 object_type *o_ptr = &caster_ptr->inventory_list[i];
511 if (o_ptr->tval != TV_BOLT)
514 /* Skip artifacts and ego-items */
515 if (object_is_artifact(o_ptr) || object_is_ego(o_ptr))
518 /* Skip cursed/broken items */
519 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr))
523 if (randint0(100) < 75)
526 msg_print(_("クロスボウの矢が炎のオーラに包まれた!", "Your bolts are covered in a fiery aura!"));
529 o_ptr->name2 = EGO_FLAME;
530 enchant(caster_ptr, o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
536 msg_print(_("炎で強化するのに失敗した。", "The fiery enchantment failed."));
539 bool perilous_secrets(player_type *user_ptr)
541 if (!ident_spell(user_ptr, FALSE, 0))
544 if (mp_ptr->spell_book) {
545 /* Sufficient mana */
546 if (20 <= user_ptr->csp) {
551 /* Over-exert the player */
553 int oops = 20 - user_ptr->csp;
557 user_ptr->csp_frac = 0;
559 msg_print(_("石を制御できない!", "You are too weak to control the stone!"));
560 /* Hack -- Bypass free action */
561 (void)set_paralyzed(user_ptr, user_ptr->paralyzed + randint1(5 * oops + 1));
564 (void)set_confused(user_ptr, user_ptr->confused + randint1(5 * oops + 1));
567 user_ptr->redraw |= (PR_MANA);
570 take_hit(user_ptr, DAMAGE_LOSELIFE, damroll(1, 12), _("危険な秘密", "perilous secrets"), -1);
573 (void)set_confused(user_ptr, user_ptr->confused + randint1(10));
575 /* Exercise a little care... */
577 take_hit(user_ptr, DAMAGE_LOSELIFE, damroll(4, 10), _("危険な秘密", "perilous secrets"), -1);
582 * @brief 寿命つき光源の燃素追加処理 /
583 * Charge a lite (torch or latern)
586 void phlogiston(player_type *caster_ptr)
588 GAME_TURN max_flog = 0;
589 object_type *o_ptr = &caster_ptr->inventory_list[INVEN_LITE];
592 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_LANTERN)) {
593 max_flog = FUEL_LAMP;
597 else if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH)) {
598 max_flog = FUEL_TORCH;
601 /* No torch to refill */
603 msg_print(_("燃素を消費するアイテムを装備していません。", "You are not wielding anything which uses phlogiston."));
607 if (o_ptr->xtra4 >= max_flog) {
608 msg_print(_("このアイテムにはこれ以上燃素を補充できません。", "No more phlogiston can be put in this item."));
613 o_ptr->xtra4 += (XTRA16)(max_flog / 2);
614 msg_print(_("照明用アイテムに燃素を補充した。", "You add phlogiston to your light item."));
616 if (o_ptr->xtra4 >= max_flog) {
617 o_ptr->xtra4 = (XTRA16)max_flog;
618 msg_print(_("照明用アイテムは満タンになった。", "Your light item is full."));
621 caster_ptr->update |= (PU_TORCH);
627 * @return ターン消費を要する処理を行ったならばTRUEを返す
629 bool bless_weapon(player_type *caster_ptr)
631 /* Bless only weapons */
632 item_tester_hook = object_is_weapon;
634 concptr q = _("どのアイテムを祝福しますか?", "Bless which weapon? ");
635 concptr s = _("祝福できる武器がありません。", "You have weapon to bless.");
639 o_ptr = choose_object(caster_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
643 GAME_TEXT o_name[MAX_NLEN];
644 describe_flavor(caster_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
645 BIT_FLAGS flgs[TR_FLAG_SIZE];
646 object_flags(caster_ptr, o_ptr, flgs);
648 if (object_is_cursed(o_ptr)) {
649 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)
650 || (o_ptr->curse_flags & TRC_PERMA_CURSE)) {
652 msg_format("%sを覆う黒いオーラは祝福を跳ね返した!", o_name);
654 msg_format("The black aura on %s %s disrupts the blessing!", ((item >= 0) ? "your" : "the"), o_name);
661 msg_format("%s から邪悪なオーラが消えた。", o_name);
663 msg_format("A malignant aura leaves %s %s.", ((item >= 0) ? "your" : "the"), o_name);
666 o_ptr->curse_flags = 0L;
668 o_ptr->ident |= (IDENT_SENSE);
669 o_ptr->feeling = FEEL_NONE;
671 /* Recalculate the bonuses */
672 caster_ptr->update |= (PU_BONUS);
673 caster_ptr->window |= (PW_EQUIP);
677 * Next, we try to bless it. Artifacts have a 1/3 chance of
678 * being blessed, otherwise, the operation simply disenchants
679 * them, godly power negating the magic. Ok, the explanation
680 * is silly, but otherwise priests would always bless every
681 * artifact weapon they find. Ego weapons and normal weapons
682 * can be blessed automatically.
684 if (have_flag(flgs, TR_BLESSED)) {
686 msg_format("%s は既に祝福されている。", o_name);
688 msg_format("%s %s %s blessed already.", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "were" : "was"));
694 if (!(object_is_artifact(o_ptr) || object_is_ego(o_ptr)) || one_in_(3)) {
696 msg_format("%sは輝いた!", o_name);
698 msg_format("%s %s shine%s!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
701 add_flag(o_ptr->art_flags, TR_BLESSED);
702 o_ptr->discount = 99;
704 bool dis_happened = FALSE;
705 msg_print(_("その武器は祝福を嫌っている!", "The weapon resists your blessing!"));
707 /* Disenchant tohit */
708 if (o_ptr->to_h > 0) {
713 if ((o_ptr->to_h > 5) && (randint0(100) < 33))
716 /* Disenchant todam */
717 if (o_ptr->to_d > 0) {
722 if ((o_ptr->to_d > 5) && (randint0(100) < 33))
725 /* Disenchant toac */
726 if (o_ptr->to_a > 0) {
731 if ((o_ptr->to_a > 5) && (randint0(100) < 33))
735 msg_print(_("周囲が凡庸な雰囲気で満ちた...", "There is a static feeling in the air..."));
738 msg_format("%s は劣化した!", o_name);
740 msg_format("%s %s %s disenchanted!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "were" : "was"));
745 caster_ptr->update |= (PU_BONUS);
746 caster_ptr->window |= (PW_EQUIP | PW_PLAYER);
747 calc_android_exp(caster_ptr);
755 * @return ターン消費を要する処理を行ったならばTRUEを返す
757 bool pulish_shield(player_type *caster_ptr)
759 concptr q = _("どの盾を磨きますか?", "Pulish which weapon? ");
760 concptr s = _("磨く盾がありません。", "You have weapon to pulish.");
764 o_ptr = choose_object(caster_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), TV_SHIELD);
768 GAME_TEXT o_name[MAX_NLEN];
769 describe_flavor(caster_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
770 BIT_FLAGS flgs[TR_FLAG_SIZE];
771 object_flags(caster_ptr, o_ptr, flgs);
773 bool is_pulish_successful = o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr);
774 is_pulish_successful &= !object_is_cursed(o_ptr);
775 is_pulish_successful &= (o_ptr->sval != SV_MIRROR_SHIELD);
776 if (is_pulish_successful) {
778 msg_format("%sは輝いた!", o_name);
780 msg_format("%s %s shine%s!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
782 o_ptr->name2 = EGO_REFLECTION;
783 enchant(caster_ptr, o_ptr, randint0(3) + 4, ENCH_TOAC);
785 o_ptr->discount = 99;
786 chg_virtue(caster_ptr, V_ENCHANT, 2);
794 msg_print(_("失敗した。", "Failed."));
795 chg_virtue(caster_ptr, V_ENCHANT, -2);
796 calc_android_exp(caster_ptr);
802 * Break the curse of an item
803 * @param o_ptr 呪い装備情報の参照ポインタ
806 static void break_curse(object_type *o_ptr)
808 BIT_FLAGS is_curse_broken
809 = object_is_cursed(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25);
810 if (!is_curse_broken) {
814 msg_print(_("かけられていた呪いが打ち破られた!", "The curse is broken!"));
816 o_ptr->curse_flags = 0L;
817 o_ptr->ident |= (IDENT_SENSE);
818 o_ptr->feeling = FEEL_NONE;
823 * Enchants a plus onto an item. -RAK-
824 * @param caster_ptr プレーヤーへの参照ポインタ
825 * @param o_ptr 強化するアイテムの参照ポインタ
827 * @param eflag 強化オプション(命中/ダメージ/AC)
828 * @return 強化に成功した場合TRUEを返す
831 * Revamped! Now takes item pointer, number of times to try enchanting,
832 * and a flag of what to try enchanting. Artifacts resist enchantment
833 * some of the time, and successful enchantment to at least +0 might
834 * break a curse on the item. -CFT-
836 * Note that an item can technically be enchanted all the way to +15 if
837 * you wait a very, very, long time. Going from +9 to +10 only works
838 * about 5% of the time, and from +10 to +11 only about 1% of the time.
840 * Note that this function can now be used on "piles" of items, and
841 * the larger the pile, the lower the chance of success.
844 bool enchant(player_type *caster_ptr, object_type *o_ptr, int n, int eflag)
846 /* Large piles resist enchantment */
847 int prob = o_ptr->number * 100;
849 /* Missiles are easy to enchant */
850 if ((o_ptr->tval == TV_BOLT) || (o_ptr->tval == TV_ARROW) || (o_ptr->tval == TV_SHOT)) {
857 bool a = object_is_artifact(o_ptr);
858 bool force = (eflag & ENCH_FORCE);
859 for (int i = 0; i < n; i++) {
860 /* Hack -- Roll for pile resistance */
861 if (!force && randint0(prob) >= 100)
865 if (eflag & ENCH_TOHIT) {
868 else if (o_ptr->to_h > 15)
871 chance = enchant_table[o_ptr->to_h];
873 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50)))) {
877 /* only when you get it above -1 -CFT */
878 if (o_ptr->to_h >= 0)
883 /* Enchant to damage */
884 if (eflag & ENCH_TODAM) {
887 else if (o_ptr->to_d > 15)
890 chance = enchant_table[o_ptr->to_d];
892 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50)))) {
896 /* only when you get it above -1 -CFT */
897 if (o_ptr->to_d >= 0)
902 /* Enchant to armor class */
903 if (!(eflag & ENCH_TOAC)) {
909 else if (o_ptr->to_a > 15)
912 chance = enchant_table[o_ptr->to_a];
914 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50)))) {
918 /* only when you get it above -1 -CFT */
919 if (o_ptr->to_a >= 0)
927 caster_ptr->update |= (PU_BONUS | PU_COMBINE | PU_REORDER);
928 caster_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
930 calc_android_exp(caster_ptr);
937 * @brief 装備修正強化処理のメインルーチン /
938 * Enchant an item (in the inventory or on the floor)
939 * @param caster_ptr プレーヤーへの参照ポインタ
940 * @param num_hit 命中修正量
941 * @param num_dam ダメージ修正量
942 * @param num_ac AC修正量
943 * @return 強化に成功した場合TRUEを返す
945 * Note that "num_ac" requires armour, else weapon
946 * Returns TRUE if attempted, FALSE if cancelled
948 bool enchant_spell(player_type *caster_ptr, HIT_PROB num_hit, HIT_POINT num_dam, ARMOUR_CLASS num_ac)
950 /* Assume enchant weapon */
951 item_tester_hook = object_allow_enchant_weapon;
953 /* Enchant armor if requested */
955 item_tester_hook = object_is_armour;
957 concptr q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
958 concptr s = _("強化できるアイテムがない。", "You have nothing to enchant.");
962 o_ptr = choose_object(caster_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
966 GAME_TEXT o_name[MAX_NLEN];
967 describe_flavor(caster_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
969 msg_format("%s は明るく輝いた!", o_name);
971 msg_format("%s %s glow%s brightly!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
975 bool is_enchant_successful = FALSE;
976 if (enchant(caster_ptr, o_ptr, num_hit, ENCH_TOHIT))
977 is_enchant_successful = TRUE;
978 if (enchant(caster_ptr, o_ptr, num_dam, ENCH_TODAM))
979 is_enchant_successful = TRUE;
980 if (enchant(caster_ptr, o_ptr, num_ac, ENCH_TOAC))
981 is_enchant_successful = TRUE;
983 if (!is_enchant_successful) {
986 msg_print(_("強化に失敗した。", "The enchantment failed."));
988 chg_virtue(caster_ptr, V_ENCHANT, -1);
990 chg_virtue(caster_ptr, V_ENCHANT, 1);
992 calc_android_exp(caster_ptr);
994 /* Something happened */
999 * @brief 武器へのエゴ付加処理 /
1000 * Brand the current weapon
1001 * @param caster_ptr プレーヤーへの参照ポインタ
1002 * @param brand_type エゴ化ID(e_info.txtとは連動していない)
1005 void brand_weapon(player_type *caster_ptr, int brand_type)
1007 /* Assume enchant weapon */
1008 item_tester_hook = object_allow_enchant_melee_weapon;
1010 concptr q = _("どの武器を強化しますか? ", "Enchant which weapon? ");
1011 concptr s = _("強化できる武器がない。", "You have nothing to enchant.");
1015 o_ptr = choose_object(caster_ptr, &item, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT), 0);
1019 bool is_special_item = o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) && !object_is_cursed(o_ptr)
1020 && !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_POISON_NEEDLE)) && !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE))
1021 && !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE));
1022 if (!is_special_item) {
1026 msg_print(_("属性付加に失敗した。", "The branding failed."));
1027 chg_virtue(caster_ptr, V_ENCHANT, -2);
1028 calc_android_exp(caster_ptr);
1032 /* Let's get the name before it is changed... */
1033 GAME_TEXT o_name[MAX_NLEN];
1034 describe_flavor(caster_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1037 switch (brand_type) {
1039 if (o_ptr->tval == TV_SWORD) {
1040 act = _("は鋭さを増した!", "becomes very sharp!");
1042 o_ptr->name2 = EGO_SHARPNESS;
1043 o_ptr->pval = (PARAMETER_VALUE)m_bonus(5, caster_ptr->current_floor_ptr->dun_level) + 1;
1045 if ((o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2))
1048 act = _("は破壊力を増した!", "seems very powerful.");
1049 o_ptr->name2 = EGO_EARTHQUAKES;
1050 o_ptr->pval = (PARAMETER_VALUE)m_bonus(3, caster_ptr->current_floor_ptr->dun_level);
1055 act = _("は人間の血を求めている!", "seems to be looking for humans!");
1056 o_ptr->name2 = EGO_KILL_HUMAN;
1059 act = _("は電撃に覆われた!", "covered with lightning!");
1060 o_ptr->name2 = EGO_BRAND_ELEC;
1063 act = _("は酸に覆われた!", "coated with acid!");
1064 o_ptr->name2 = EGO_BRAND_ACID;
1067 act = _("は邪悪なる怪物を求めている!", "seems to be looking for evil monsters!");
1068 o_ptr->name2 = EGO_KILL_EVIL;
1071 act = _("は異世界の住人の肉体を求めている!", "seems to be looking for demons!");
1072 o_ptr->name2 = EGO_KILL_DEMON;
1075 act = _("は屍を求めている!", "seems to be looking for undead!");
1076 o_ptr->name2 = EGO_KILL_UNDEAD;
1079 act = _("は動物の血を求めている!", "seems to be looking for animals!");
1080 o_ptr->name2 = EGO_KILL_ANIMAL;
1083 act = _("はドラゴンの血を求めている!", "seems to be looking for dragons!");
1084 o_ptr->name2 = EGO_KILL_DRAGON;
1087 act = _("はトロルの血を求めている!", "seems to be looking for troll!s");
1088 o_ptr->name2 = EGO_KILL_TROLL;
1091 act = _("はオークの血を求めている!", "seems to be looking for orcs!");
1092 o_ptr->name2 = EGO_KILL_ORC;
1095 act = _("は巨人の血を求めている!", "seems to be looking for giants!");
1096 o_ptr->name2 = EGO_KILL_GIANT;
1099 act = _("は非常に不安定になったようだ。", "seems very unstable now.");
1100 o_ptr->name2 = EGO_TRUMP;
1101 o_ptr->pval = randint1(2);
1104 act = _("は血を求めている!", "thirsts for blood!");
1105 o_ptr->name2 = EGO_VAMPIRIC;
1108 act = _("は毒に覆われた。", "is coated with poison.");
1109 o_ptr->name2 = EGO_BRAND_POIS;
1112 act = _("は純ログルスに飲み込まれた。", "is engulfed in raw Logrus!");
1113 o_ptr->name2 = EGO_CHAOTIC;
1116 act = _("は炎のシールドに覆われた!", "is covered in a fiery shield!");
1117 o_ptr->name2 = EGO_BRAND_FIRE;
1120 act = _("は深く冷たいブルーに輝いた!", "glows deep, icy blue!");
1121 o_ptr->name2 = EGO_BRAND_COLD;
1125 msg_format(_("あなたの%s%s", "Your %s %s"), o_name, act);
1126 enchant(caster_ptr, o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
1128 o_ptr->discount = 99;
1129 chg_virtue(caster_ptr, V_ENCHANT, 2);
1130 calc_android_exp(caster_ptr);
1133 bool create_ration(player_type *creature_ptr)
1138 object_prep(creature_ptr, q_ptr, lookup_kind(TV_FOOD, SV_FOOD_RATION));
1139 (void)drop_near(creature_ptr, q_ptr, -1, creature_ptr->y, creature_ptr->x);
1140 msg_print(_("食事を料理して作った。", "You cook some food."));