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"
18 #include "player-effects.h"
19 #include "player-class.h"
20 #include "player-inventory.h"
21 #include "objectkind.h"
23 #include "targeting.h"
24 #include "view-mainwindow.h"
29 OBJECT_TYPE_VALUE tval;
30 OBJECT_SUBTYPE_VALUE sval;
37 * @brief 装備強化処理の失敗率定数(千分率) /
38 * Used by the "enchant" function (chance of failure)
39 * (modified for Zangband, we need better stuff there...) -- TY
42 static int enchant_table[16] =
45 300, 400, 500, 650, 800,
46 950, 987, 993, 995, 998,
52 * Scatter some "amusing" objects near the player
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 */
61 static amuse_type amuse_info[] =
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 },
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を返す
85 bool create_ammo(player_type *creature_ptr)
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 ?"));
93 sprintf(com, _("[S]弾:", "Create [S]hots ?"));
95 if (cmd_limit_confused(creature_ptr)) return FALSE;
96 if (cmd_limit_blind(creature_ptr)) return FALSE;
102 if (!get_com(com, &ch, TRUE))
107 if (ch == 'S' || ch == 's')
113 if ((ch == 'A' || ch == 'a') && (creature_ptr->lev >= 10))
119 if ((ch == 'B' || ch == 'b') && (creature_ptr->lev >= 20))
126 GAME_TEXT o_name[MAX_NLEN];
130 /**********Create shots*********/
137 if (!get_rep_dir(&dir, FALSE)) return FALSE;
138 y = creature_ptr->y + ddy[dir];
139 x = creature_ptr->x + ddx[dir];
140 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
142 if (!have_flag(f_info[get_feat_mimic(g_ptr)].flags, FF_CAN_DIG))
144 msg_print(_("そこには岩石がない。", "You need pile of rubble."));
147 else if (!cave_have_flag_grid(g_ptr, FF_CAN_DIG) || !cave_have_flag_grid(g_ptr, FF_HURT_ROCK))
149 msg_print(_("硬すぎて崩せなかった。", "You failed to make ammo."));
156 /* Hack -- Give the player some small firestones */
157 object_prep(q_ptr, lookup_kind(TV_SHOT, (OBJECT_SUBTYPE_VALUE)m_bonus(1, creature_ptr->lev) + 1));
158 q_ptr->number = (byte)rand_range(15, 30);
161 apply_magic(q_ptr, creature_ptr->lev, AM_NO_FIXED_ART);
162 q_ptr->discount = 99;
164 slot = inven_carry(creature_ptr, q_ptr);
166 object_desc(o_name, q_ptr, 0);
167 msg_format(_("%sを作った。", "You make some ammo."), o_name);
169 /* Auto-inscription */
170 if (slot >= 0) autopick_alter_item(slot, FALSE);
172 /* Destroy the wall */
173 cave_alter_feat(y, x, FF_HURT_ROCK);
175 creature_ptr->update |= (PU_FLOW);
178 /**********Create arrows*********/
185 item_tester_hook = item_tester_hook_convertible;
187 q = _("どのアイテムから作りますか? ", "Convert which item? ");
188 s = _("材料を持っていない。", "You have no item to convert.");
189 q_ptr = choose_object(creature_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), 0);
190 if (!q_ptr) return FALSE;
194 /* Hack -- Give the player some small firestones */
195 object_prep(q_ptr, lookup_kind(TV_ARROW, (OBJECT_SUBTYPE_VALUE)m_bonus(1, creature_ptr->lev) + 1));
196 q_ptr->number = (byte)rand_range(5, 10);
199 apply_magic(q_ptr, creature_ptr->lev, AM_NO_FIXED_ART);
201 q_ptr->discount = 99;
203 object_desc(o_name, q_ptr, 0);
204 msg_format(_("%sを作った。", "You make some ammo."), o_name);
207 slot = inven_carry(creature_ptr, q_ptr);
209 /* Auto-inscription */
210 if (slot >= 0) autopick_alter_item(slot, FALSE);
212 /**********Create bolts*********/
219 item_tester_hook = item_tester_hook_convertible;
221 q = _("どのアイテムから作りますか? ", "Convert which item? ");
222 s = _("材料を持っていない。", "You have no item to convert.");
224 q_ptr = choose_object(creature_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), 0);
225 if (!q_ptr) return FALSE;
229 /* Hack -- Give the player some small firestones */
230 object_prep(q_ptr, lookup_kind(TV_BOLT, (OBJECT_SUBTYPE_VALUE)m_bonus(1, creature_ptr->lev) + 1));
231 q_ptr->number = (byte)rand_range(4, 8);
234 apply_magic(q_ptr, creature_ptr->lev, AM_NO_FIXED_ART);
236 q_ptr->discount = 99;
238 object_desc(o_name, q_ptr, 0);
239 msg_format(_("%sを作った。", "You make some ammo."), o_name);
243 slot = inven_carry(creature_ptr, q_ptr);
245 /* Auto-inscription */
246 if (slot >= 0) autopick_alter_item(slot, FALSE);
253 * @brief 魔道具術師の魔力取り込み処理
254 * @param user_ptr アイテムを取り込むクリーチャー
255 * @return 取り込みを実行したらTRUE、キャンセルしたらFALSEを返す
257 bool import_magic_device(player_type *user_ptr)
259 /* Only accept legal items */
260 item_tester_hook = item_tester_hook_recharge;
262 concptr q = _("どのアイテムの魔力を取り込みますか? ", "Gain power of which item? ");
263 concptr s = _("魔力を取り込めるアイテムがない。", "You have nothing to gain power.");
267 o_ptr = choose_object(user_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), 0);
268 if (!o_ptr) return (FALSE);
270 if (o_ptr->tval == TV_STAFF && o_ptr->sval == SV_STAFF_NOTHING)
272 msg_print(_("この杖には発動の為の能力は何も備わっていないようだ。", "This staff doesn't have any magical ability."));
276 if (!object_is_known(o_ptr))
278 msg_print(_("鑑定されていないと取り込めない。", "You need to identify before absorbing."));
284 msg_print(_("充填中のアイテムは取り込めない。", "This item is still charging."));
288 PARAMETER_VALUE pval = o_ptr->pval;
290 if (o_ptr->tval == TV_ROD)
292 else if (o_ptr->tval == TV_WAND)
295 if (o_ptr->tval == TV_ROD)
297 user_ptr->magic_num2[o_ptr->sval + ext] += (MAGIC_NUM2)o_ptr->number;
298 if (user_ptr->magic_num2[o_ptr->sval + ext] > 99) user_ptr->magic_num2[o_ptr->sval + ext] = 99;
303 for (num = o_ptr->number; num; num--)
306 if (o_ptr->tval == TV_WAND) gain_num = (pval + num - 1) / num;
307 if (user_ptr->magic_num2[o_ptr->sval + ext])
310 gain_num = (gain_num / 3 + randint0(gain_num / 3)) / 256;
311 if (gain_num < 1) gain_num = 1;
313 user_ptr->magic_num2[o_ptr->sval + ext] += (MAGIC_NUM2)gain_num;
314 if (user_ptr->magic_num2[o_ptr->sval + ext] > 99) user_ptr->magic_num2[o_ptr->sval + ext] = 99;
315 user_ptr->magic_num1[o_ptr->sval + ext] += pval * 0x10000;
316 if (user_ptr->magic_num1[o_ptr->sval + ext] > 99 * 0x10000) user_ptr->magic_num1[o_ptr->sval + ext] = 99 * 0x10000;
317 if (user_ptr->magic_num1[o_ptr->sval + ext] > user_ptr->magic_num2[o_ptr->sval + ext] * 0x10000) user_ptr->magic_num1[o_ptr->sval + ext] = user_ptr->magic_num2[o_ptr->sval + ext] * 0x10000;
318 if (o_ptr->tval == TV_WAND) pval -= (pval + num - 1) / num;
322 GAME_TEXT o_name[MAX_NLEN];
323 object_desc(o_name, o_ptr, 0);
324 msg_format(_("%sの魔力を取り込んだ。", "You absorb magic of %s."), o_name);
326 vary_item(item, -999);
327 take_turn(user_ptr, 100);
334 * @param y1 配置したいフロアのY座標
335 * @param x1 配置したいフロアのX座標
337 * @param known TRUEならばオブジェクトが必ず*鑑定*済になる
340 void amusement(POSITION y1, POSITION x1, int num, bool known)
343 for (int n = 0; amuse_info[n].tval != 0; n++)
345 t += amuse_info[n].prob;
350 object_type object_type_body;
354 KIND_OBJECT_IDX k_idx;
355 ARTIFACT_IDX a_idx = 0;
357 bool insta_art, fixed_art;
361 r -= amuse_info[i].prob;
364 i_ptr = &object_type_body;
366 k_idx = lookup_kind(amuse_info[i].tval, amuse_info[i].sval);
368 /* Paranoia - reroll if nothing */
369 if (!k_idx) continue;
371 /* Search an artifact index if need */
372 insta_art = (k_info[k_idx].gen_flags & TRG_INSTA_ART);
373 fixed_art = (amuse_info[i].flag & AMS_FIXED_ART);
375 if (insta_art || fixed_art)
377 for (a_idx = 1; a_idx < max_a_idx; a_idx++)
379 if (insta_art && !(a_info[a_idx].gen_flags & TRG_INSTA_ART)) continue;
380 if (a_info[a_idx].tval != k_info[k_idx].tval) continue;
381 if (a_info[a_idx].sval != k_info[k_idx].sval) continue;
382 if (a_info[a_idx].cur_num > 0) continue;
386 if (a_idx >= max_a_idx) continue;
389 /* Make an object (if possible) */
390 object_prep(i_ptr, k_idx);
391 if (a_idx) i_ptr->name1 = a_idx;
392 apply_magic(i_ptr, 1, AM_NO_FIXED_ART);
394 if (amuse_info[i].flag & AMS_NO_UNIQUE)
396 if (r_info[i_ptr->pval].flags1 & RF1_UNIQUE) continue;
399 if (amuse_info[i].flag & AMS_MULTIPLE) i_ptr->number = randint1(3);
400 if (amuse_info[i].flag & AMS_PILE) i_ptr->number = randint1(99);
408 /* Paranoia - reroll if nothing */
409 if (!(i_ptr->k_idx)) continue;
411 (void)drop_near(i_ptr, -1, y1, x1);
420 * Scatter some "great" objects near the player
421 * @param y1 配置したいフロアのY座標
422 * @param x1 配置したいフロアのX座標
424 * @param great TRUEならば必ず高級品以上を落とす
425 * @param special TRUEならば必ず特別品を落とす
426 * @param known TRUEならばオブジェクトが必ず*鑑定*済になる
429 void acquirement(POSITION y1, POSITION x1, int num, bool great, bool special, bool known)
432 object_type object_type_body;
433 BIT_FLAGS mode = AM_GOOD | (great || special ? AM_GREAT : 0L) | (special ? AM_SPECIAL : 0L);
438 i_ptr = &object_type_body;
441 /* Make a good (or great) object (if possible) */
442 if (!make_object(i_ptr, mode)) continue;
450 (void)drop_near(i_ptr, -1, y1, x1);
455 void acquire_chaos_weapon(player_type *creature_ptr)
458 object_type *q_ptr = &forge;
459 OBJECT_TYPE_VALUE dummy = TV_SWORD;
460 OBJECT_SUBTYPE_VALUE dummy2;
461 switch (randint1(creature_ptr->lev))
467 dummy2 = SV_MAIN_GAUCHE;
476 dummy2 = SV_SMALL_SWORD;
479 dummy2 = SV_BASILLARD;
481 case 11: case 12: case 13:
482 dummy2 = SV_SHORT_SWORD;
491 dummy2 = SV_WAKIZASHI;
500 dummy2 = SV_BROAD_SWORD;
503 dummy2 = SV_LONG_SWORD;
506 dummy2 = SV_SCIMITAR;
515 dummy2 = SV_BASTARD_SWORD;
518 dummy2 = SV_GREAT_SCIMITAR;
521 dummy2 = SV_CLAYMORE;
527 dummy2 = SV_TWO_HANDED_SWORD;
530 dummy2 = SV_FLAMBERGE;
533 dummy2 = SV_NO_DACHI;
536 dummy2 = SV_EXECUTIONERS_SWORD;
539 dummy2 = SV_ZWEIHANDER;
542 dummy2 = SV_HAYABUSA;
545 dummy2 = SV_BLADE_OF_CHAOS;
548 object_prep(q_ptr, lookup_kind(dummy, dummy2));
549 q_ptr->to_h = 3 + randint1(creature_ptr->current_floor_ptr->dun_level) % 10;
550 q_ptr->to_d = 3 + randint1(creature_ptr->current_floor_ptr->dun_level) % 10;
551 one_resistance(q_ptr);
552 q_ptr->name2 = EGO_CHAOTIC;
553 (void)drop_near(q_ptr, -1, creature_ptr->y, creature_ptr->x);
558 * todo 元のreturnは間違っているが、修正後の↓文がどれくらい正しいかは要チェック
560 * Curse the players armor
561 * @return 何も持っていない場合を除き、常にTRUEを返す
563 bool curse_armor(player_type *owner_ptr)
565 /* Curse the body armor */
567 o_ptr = &owner_ptr->inventory_list[INVEN_BODY];
569 if (!o_ptr->k_idx) return FALSE;
571 GAME_TEXT o_name[MAX_NLEN];
572 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
574 /* Attempt a saving throw for artifacts */
575 if (object_is_artifact(o_ptr) && (randint0(100) < 50))
579 msg_format("%sが%sを包み込もうとしたが、%sはそれを跳ね返した!",
580 "恐怖の暗黒オーラ", "防具", o_name);
582 msg_format("A %s tries to %s, but your %s resists the effects!",
583 "terrible black aura", "surround your armor", o_name);
588 /* not artifact or failed save... */
589 msg_format(_("恐怖の暗黒オーラがあなたの%sを包み込んだ!", "A terrible black aura blasts your %s!"), o_name);
590 chg_virtue(owner_ptr, V_ENCHANT, -5);
592 /* Blast the armor */
594 o_ptr->name2 = EGO_BLASTED;
595 o_ptr->to_a = 0 - randint1(5) - randint1(5);
602 for (int i = 0; i < TR_FLAG_SIZE; i++)
603 o_ptr->art_flags[i] = 0;
606 o_ptr->curse_flags = TRC_CURSED;
609 o_ptr->ident |= (IDENT_BROKEN);
610 owner_ptr->update |= (PU_BONUS | PU_MANA);
611 owner_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
617 * todo 元のreturnは間違っているが、修正後の↓文がどれくらい正しいかは要チェック
619 * Curse the players weapon
620 * @param owner_ptr 所持者の参照ポインタ
621 * @param force 無条件に呪縛を行うならばTRUE
622 * @param o_ptr 呪縛する武器のアイテム情報参照ポインタ
623 * @return 何も持っていない場合を除き、常にTRUEを返す
625 bool curse_weapon_object(player_type *owner_ptr, bool force, object_type *o_ptr)
627 if (!o_ptr->k_idx) return FALSE;
629 GAME_TEXT o_name[MAX_NLEN];
630 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
632 /* Attempt a saving throw */
633 if (object_is_artifact(o_ptr) && (randint0(100) < 50) && !force)
636 msg_format("%sが%sを包み込もうとしたが、%sはそれを跳ね返した!",
637 "恐怖の暗黒オーラ", "武器", o_name);
639 msg_format("A %s tries to %s, but your %s resists the effects!",
640 "terrible black aura", "surround your weapon", o_name);
645 /* not artifact or failed save... */
646 if (!force) msg_format(_("恐怖の暗黒オーラがあなたの%sを包み込んだ!", "A terrible black aura blasts your %s!"), o_name);
647 chg_virtue(owner_ptr, V_ENCHANT, -5);
649 /* Shatter the weapon */
651 o_ptr->name2 = EGO_SHATTERED;
652 o_ptr->to_h = 0 - randint1(5) - randint1(5);
653 o_ptr->to_d = 0 - randint1(5) - randint1(5);
659 for (int i = 0; i < TR_FLAG_SIZE; i++)
660 o_ptr->art_flags[i] = 0;
663 o_ptr->curse_flags = TRC_CURSED;
666 o_ptr->ident |= (IDENT_BROKEN);
667 owner_ptr->update |= (PU_BONUS | PU_MANA);
668 owner_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
675 * @param caster_ptr 錆止め実行者の参照ポインタ
676 * @return ターン消費を要する処理を行ったならばTRUEを返す
678 bool rustproof(player_type *caster_ptr)
680 /* Select a piece of armour */
681 item_tester_hook = object_is_armour;
683 concptr q = _("どの防具に錆止めをしますか?", "Rustproof which piece of armour? ");
684 concptr s = _("錆止めできるものがありません。", "You have nothing to rustproof.");
688 o_ptr = choose_object(caster_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
689 if (!o_ptr) return FALSE;
691 GAME_TEXT o_name[MAX_NLEN];
692 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
694 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
696 if ((o_ptr->to_a < 0) && !object_is_cursed(o_ptr))
699 msg_format("%sは新品同様になった!", o_name);
701 msg_format("%s %s look%s as good as new!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
708 msg_format("%sは腐食しなくなった。", o_name);
710 msg_format("%s %s %s now protected against corrosion.", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "are" : "is"));
713 calc_android_exp(caster_ptr);
719 * @brief ボルトのエゴ化処理(火炎エゴのみ) /
721 * @param caster_ptr プレーヤーへの参照ポインタ
724 void brand_bolts(player_type *caster_ptr)
726 /* Use the first acceptable bolts */
727 for (int i = 0; i < INVEN_PACK; i++)
729 object_type *o_ptr = &caster_ptr->inventory_list[i];
732 if (o_ptr->tval != TV_BOLT) continue;
734 /* Skip artifacts and ego-items */
735 if (object_is_artifact(o_ptr) || object_is_ego(o_ptr))
738 /* Skip cursed/broken items */
739 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) continue;
742 if (randint0(100) < 75) continue;
744 msg_print(_("クロスボウの矢が炎のオーラに包まれた!", "Your bolts are covered in a fiery aura!"));
747 o_ptr->name2 = EGO_FLAME;
748 enchant(caster_ptr, o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
752 if (flush_failure) flush();
753 msg_print(_("炎で強化するのに失敗した。", "The fiery enchantment failed."));
757 bool perilous_secrets(player_type *user_ptr)
759 if (!ident_spell(user_ptr, FALSE)) return FALSE;
761 if (mp_ptr->spell_book)
763 /* Sufficient mana */
764 if (20 <= user_ptr->csp)
770 /* Over-exert the player */
773 int oops = 20 - user_ptr->csp;
777 user_ptr->csp_frac = 0;
779 msg_print(_("石を制御できない!", "You are too weak to control the stone!"));
780 /* Hack -- Bypass free action */
781 (void)set_paralyzed(user_ptr, user_ptr->paralyzed + randint1(5 * oops + 1));
784 (void)set_confused(user_ptr, user_ptr->confused + randint1(5 * oops + 1));
787 user_ptr->redraw |= (PR_MANA);
790 take_hit(user_ptr, DAMAGE_LOSELIFE, damroll(1, 12), _("危険な秘密", "perilous secrets"), -1);
792 if (one_in_(5)) (void)set_confused(user_ptr, user_ptr->confused + randint1(10));
794 /* Exercise a little care... */
795 if (one_in_(20)) take_hit(user_ptr, DAMAGE_LOSELIFE, damroll(4, 10), _("危険な秘密", "perilous secrets"), -1);
801 * @brief 固定アーティファクト『ブラッディムーン』の特性を変更する。
802 * @details スレイ2d2種、及びone_resistance()による耐性1d2種、pval2種を得る。
803 * @param o_ptr 対象のオブジェクト構造体(ブラッディムーン)のポインタ
806 void get_bloody_moon_flags(object_type *o_ptr)
808 for (int i = 0; i < TR_FLAG_SIZE; i++)
809 o_ptr->art_flags[i] = a_info[ART_BLOOD].flags[i];
811 int dummy = randint1(2) + randint1(2);
812 for (int i = 0; i < dummy; i++)
814 int flag = randint0(26);
815 if (flag >= 20) add_flag(o_ptr->art_flags, TR_KILL_UNDEAD + flag - 20);
816 else if (flag == 19) add_flag(o_ptr->art_flags, TR_KILL_ANIMAL);
817 else if (flag == 18) add_flag(o_ptr->art_flags, TR_SLAY_HUMAN);
818 else add_flag(o_ptr->art_flags, TR_CHAOTIC + flag);
822 for (int i = 0; i < dummy; i++) one_resistance(o_ptr);
824 for (int i = 0; i < 2; i++)
826 int tmp = randint0(11);
827 if (tmp < A_MAX) add_flag(o_ptr->art_flags, TR_STR + tmp);
828 else add_flag(o_ptr->art_flags, TR_STEALTH + tmp - 6);
834 * @brief 寿命つき光源の燃素追加処理 /
835 * Charge a lite (torch or latern)
838 void phlogiston(player_type *caster_ptr)
840 GAME_TURN max_flog = 0;
841 object_type * o_ptr = &caster_ptr->inventory_list[INVEN_LITE];
844 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_LANTERN))
846 max_flog = FUEL_LAMP;
850 else if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
852 max_flog = FUEL_TORCH;
855 /* No torch to refill */
858 msg_print(_("燃素を消費するアイテムを装備していません。", "You are not wielding anything which uses phlogiston."));
862 if (o_ptr->xtra4 >= max_flog)
864 msg_print(_("このアイテムにはこれ以上燃素を補充できません。", "No more phlogiston can be put in this item."));
869 o_ptr->xtra4 += (XTRA16)(max_flog / 2);
870 msg_print(_("照明用アイテムに燃素を補充した。", "You add phlogiston to your light item."));
872 if (o_ptr->xtra4 >= max_flog)
874 o_ptr->xtra4 = (XTRA16)max_flog;
875 msg_print(_("照明用アイテムは満タンになった。", "Your light item is full."));
878 caster_ptr->update |= (PU_TORCH);
885 * @return ターン消費を要する処理を行ったならばTRUEを返す
887 bool bless_weapon(player_type *caster_ptr)
889 /* Bless only weapons */
890 item_tester_hook = object_is_weapon;
892 concptr q = _("どのアイテムを祝福しますか?", "Bless which weapon? ");
893 concptr s = _("祝福できる武器がありません。", "You have weapon to bless.");
897 o_ptr = choose_object(caster_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
898 if (!o_ptr) return FALSE;
900 GAME_TEXT o_name[MAX_NLEN];
901 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
902 BIT_FLAGS flgs[TR_FLAG_SIZE];
903 object_flags(o_ptr, flgs);
905 if (object_is_cursed(o_ptr))
907 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) ||
908 have_flag(flgs, TR_ADD_L_CURSE) ||
909 have_flag(flgs, TR_ADD_H_CURSE) ||
910 (o_ptr->curse_flags & TRC_PERMA_CURSE))
913 msg_format("%sを覆う黒いオーラは祝福を跳ね返した!", o_name);
915 msg_format("The black aura on %s %s disrupts the blessing!", ((item >= 0) ? "your" : "the"), o_name);
922 msg_format("%s から邪悪なオーラが消えた。", o_name);
924 msg_format("A malignant aura leaves %s %s.", ((item >= 0) ? "your" : "the"), o_name);
928 o_ptr->curse_flags = 0L;
930 o_ptr->ident |= (IDENT_SENSE);
931 o_ptr->feeling = FEEL_NONE;
933 /* Recalculate the bonuses */
934 caster_ptr->update |= (PU_BONUS);
935 caster_ptr->window |= (PW_EQUIP);
939 * Next, we try to bless it. Artifacts have a 1/3 chance of
940 * being blessed, otherwise, the operation simply disenchants
941 * them, godly power negating the magic. Ok, the explanation
942 * is silly, but otherwise priests would always bless every
943 * artifact weapon they find. Ego weapons and normal weapons
944 * can be blessed automatically.
946 if (have_flag(flgs, TR_BLESSED))
949 msg_format("%s は既に祝福されている。", o_name);
951 msg_format("%s %s %s blessed already.",
952 ((item >= 0) ? "Your" : "The"), o_name,
953 ((o_ptr->number > 1) ? "were" : "was"));
959 if (!(object_is_artifact(o_ptr) || object_is_ego(o_ptr)) || one_in_(3))
962 msg_format("%sは輝いた!", o_name);
964 msg_format("%s %s shine%s!",
965 ((item >= 0) ? "Your" : "The"), o_name,
966 ((o_ptr->number > 1) ? "" : "s"));
969 add_flag(o_ptr->art_flags, TR_BLESSED);
970 o_ptr->discount = 99;
974 bool dis_happened = FALSE;
975 msg_print(_("その武器は祝福を嫌っている!", "The weapon resists your blessing!"));
977 /* Disenchant tohit */
984 if ((o_ptr->to_h > 5) && (randint0(100) < 33)) o_ptr->to_h--;
986 /* Disenchant todam */
993 if ((o_ptr->to_d > 5) && (randint0(100) < 33)) o_ptr->to_d--;
995 /* Disenchant toac */
1002 if ((o_ptr->to_a > 5) && (randint0(100) < 33)) o_ptr->to_a--;
1006 msg_print(_("周囲が凡庸な雰囲気で満ちた...", "There is a static feeling in the air..."));
1009 msg_format("%s は劣化した!", o_name);
1011 msg_format("%s %s %s disenchanted!", ((item >= 0) ? "Your" : "The"), o_name,
1012 ((o_ptr->number > 1) ? "were" : "was"));
1018 caster_ptr->update |= (PU_BONUS);
1019 caster_ptr->window |= (PW_EQUIP | PW_PLAYER);
1020 calc_android_exp(caster_ptr);
1029 * @return ターン消費を要する処理を行ったならばTRUEを返す
1031 bool pulish_shield(player_type *caster_ptr)
1033 /* Assume enchant weapon */
1034 item_tester_tval = TV_SHIELD;
1036 concptr q = _("どの盾を磨きますか?", "Pulish which weapon? ");
1037 concptr s = _("磨く盾がありません。", "You have weapon to pulish.");
1041 o_ptr = choose_object(caster_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
1042 if (!o_ptr) return FALSE;
1044 GAME_TEXT o_name[MAX_NLEN];
1045 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1046 BIT_FLAGS flgs[TR_FLAG_SIZE];
1047 object_flags(o_ptr, flgs);
1049 bool is_pulish_successful = o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr);
1050 is_pulish_successful &= !object_is_cursed(o_ptr);
1051 is_pulish_successful &= (o_ptr->sval != SV_MIRROR_SHIELD);
1052 if (is_pulish_successful)
1055 msg_format("%sは輝いた!", o_name);
1057 msg_format("%s %s shine%s!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
1059 o_ptr->name2 = EGO_REFLECTION;
1060 enchant(caster_ptr, o_ptr, randint0(3) + 4, ENCH_TOAC);
1062 o_ptr->discount = 99;
1063 chg_virtue(caster_ptr, V_ENCHANT, 2);
1068 if (flush_failure) flush();
1070 msg_print(_("失敗した。", "Failed."));
1071 chg_virtue(caster_ptr, V_ENCHANT, -2);
1072 calc_android_exp(caster_ptr);
1078 * @brief 呪いの打ち破り処理 /
1079 * Break the curse of an item
1080 * @param o_ptr 呪い装備情報の参照ポインタ
1083 static void break_curse(object_type *o_ptr)
1085 BIT_FLAGS is_curse_broken = object_is_cursed(o_ptr) &&
1086 !(o_ptr->curse_flags & TRC_PERMA_CURSE) &&
1087 !(o_ptr->curse_flags & TRC_HEAVY_CURSE) &&
1088 (randint0(100) < 25);
1089 if (!is_curse_broken)
1094 msg_print(_("かけられていた呪いが打ち破られた!", "The curse is broken!"));
1096 o_ptr->curse_flags = 0L;
1097 o_ptr->ident |= (IDENT_SENSE);
1098 o_ptr->feeling = FEEL_NONE;
1104 * Enchants a plus onto an item. -RAK-
1105 * @param caster_ptr プレーヤーへの参照ポインタ
1106 * @param o_ptr 強化するアイテムの参照ポインタ
1108 * @param eflag 強化オプション(命中/ダメージ/AC)
1109 * @return 強化に成功した場合TRUEを返す
1112 * Revamped! Now takes item pointer, number of times to try enchanting,
1113 * and a flag of what to try enchanting. Artifacts resist enchantment
1114 * some of the time, and successful enchantment to at least +0 might
1115 * break a curse on the item. -CFT-
1117 * Note that an item can technically be enchanted all the way to +15 if
1118 * you wait a very, very, long time. Going from +9 to +10 only works
1119 * about 5% of the time, and from +10 to +11 only about 1% of the time.
1121 * Note that this function can now be used on "piles" of items, and
1122 * the larger the pile, the lower the chance of success.
1125 bool enchant(player_type *caster_ptr, object_type *o_ptr, int n, int eflag)
1127 /* Large piles resist enchantment */
1128 int prob = o_ptr->number * 100;
1130 /* Missiles are easy to enchant */
1131 if ((o_ptr->tval == TV_BOLT) ||
1132 (o_ptr->tval == TV_ARROW) ||
1133 (o_ptr->tval == TV_SHOT))
1141 bool a = object_is_artifact(o_ptr);
1142 bool force = (eflag & ENCH_FORCE);
1143 for (int i = 0; i < n; i++)
1145 /* Hack -- Roll for pile resistance */
1146 if (!force && randint0(prob) >= 100) continue;
1148 /* Enchant to hit */
1149 if (eflag & ENCH_TOHIT)
1151 if (o_ptr->to_h < 0) chance = 0;
1152 else if (o_ptr->to_h > 15) chance = 1000;
1153 else chance = enchant_table[o_ptr->to_h];
1155 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
1160 /* only when you get it above -1 -CFT */
1161 if (o_ptr->to_h >= 0)
1166 /* Enchant to damage */
1167 if (eflag & ENCH_TODAM)
1169 if (o_ptr->to_d < 0) chance = 0;
1170 else if (o_ptr->to_d > 15) chance = 1000;
1171 else chance = enchant_table[o_ptr->to_d];
1173 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
1178 /* only when you get it above -1 -CFT */
1179 if (o_ptr->to_d >= 0)
1184 /* Enchant to armor class */
1185 if (!(eflag & ENCH_TOAC))
1190 if (o_ptr->to_a < 0) chance = 0;
1191 else if (o_ptr->to_a > 15) chance = 1000;
1192 else chance = enchant_table[o_ptr->to_a];
1194 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
1199 /* only when you get it above -1 -CFT */
1200 if (o_ptr->to_a >= 0)
1206 if (!res) return (FALSE);
1207 caster_ptr->update |= (PU_BONUS | PU_COMBINE | PU_REORDER);
1208 caster_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
1210 calc_android_exp(caster_ptr);
1218 * @brief 装備修正強化処理のメインルーチン /
1219 * Enchant an item (in the inventory or on the floor)
1220 * @param caster_ptr プレーヤーへの参照ポインタ
1221 * @param num_hit 命中修正量
1222 * @param num_dam ダメージ修正量
1223 * @param num_ac AC修正量
1224 * @return 強化に成功した場合TRUEを返す
1226 * Note that "num_ac" requires armour, else weapon
1227 * Returns TRUE if attempted, FALSE if cancelled
1229 bool enchant_spell(player_type *caster_ptr, HIT_PROB num_hit, HIT_POINT num_dam, ARMOUR_CLASS num_ac)
1231 /* Assume enchant weapon */
1232 item_tester_hook = object_allow_enchant_weapon;
1234 /* Enchant armor if requested */
1235 if (num_ac) item_tester_hook = object_is_armour;
1237 concptr q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
1238 concptr s = _("強化できるアイテムがない。", "You have nothing to enchant.");
1242 o_ptr = choose_object(caster_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
1243 if (!o_ptr) return (FALSE);
1245 GAME_TEXT o_name[MAX_NLEN];
1246 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1248 msg_format("%s は明るく輝いた!", o_name);
1250 msg_format("%s %s glow%s brightly!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
1254 bool is_enchant_successful = FALSE;
1255 if (enchant(caster_ptr, o_ptr, num_hit, ENCH_TOHIT)) is_enchant_successful = TRUE;
1256 if (enchant(caster_ptr, o_ptr, num_dam, ENCH_TODAM)) is_enchant_successful = TRUE;
1257 if (enchant(caster_ptr, o_ptr, num_ac, ENCH_TOAC)) is_enchant_successful = TRUE;
1259 if (!is_enchant_successful)
1261 if (flush_failure) flush();
1262 msg_print(_("強化に失敗した。", "The enchantment failed."));
1263 if (one_in_(3)) chg_virtue(caster_ptr, V_ENCHANT, -1);
1266 chg_virtue(caster_ptr, V_ENCHANT, 1);
1268 calc_android_exp(caster_ptr);
1270 /* Something happened */
1276 * @brief 武器へのエゴ付加処理 /
1277 * Brand the current weapon
1278 * @param caster_ptr プレーヤーへの参照ポインタ
1279 * @param brand_type エゴ化ID(e_info.txtとは連動していない)
1282 void brand_weapon(player_type *caster_ptr, int brand_type)
1284 /* Assume enchant weapon */
1285 item_tester_hook = object_allow_enchant_melee_weapon;
1287 concptr q = _("どの武器を強化しますか? ", "Enchant which weapon? ");
1288 concptr s = _("強化できる武器がない。", "You have nothing to enchant.");
1292 o_ptr = choose_object(caster_ptr, &item, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT), 0);
1295 bool is_special_item = o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
1296 !object_is_cursed(o_ptr) &&
1297 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) &&
1298 !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) &&
1299 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE));
1300 if (!is_special_item)
1302 if (flush_failure) flush();
1304 msg_print(_("属性付加に失敗した。", "The Branding failed."));
1305 chg_virtue(caster_ptr, V_ENCHANT, -2);
1306 calc_android_exp(caster_ptr);
1310 /* Let's get the name before it is changed... */
1311 GAME_TEXT o_name[MAX_NLEN];
1312 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1318 if (o_ptr->tval == TV_SWORD)
1320 act = _("は鋭さを増した!", "becomes very sharp!");
1322 o_ptr->name2 = EGO_SHARPNESS;
1323 o_ptr->pval = (PARAMETER_VALUE)m_bonus(5, caster_ptr->current_floor_ptr->dun_level) + 1;
1325 if ((o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2))
1330 act = _("は破壊力を増した!", "seems very powerful.");
1331 o_ptr->name2 = EGO_EARTHQUAKES;
1332 o_ptr->pval = (PARAMETER_VALUE)m_bonus(3, caster_ptr->current_floor_ptr->dun_level);
1337 act = _("は人間の血を求めている!", "seems to be looking for humans!");
1338 o_ptr->name2 = EGO_KILL_HUMAN;
1341 act = _("は電撃に覆われた!", "covered with lightning!");
1342 o_ptr->name2 = EGO_BRAND_ELEC;
1345 act = _("は酸に覆われた!", "coated with acid!");
1346 o_ptr->name2 = EGO_BRAND_ACID;
1349 act = _("は邪悪なる怪物を求めている!", "seems to be looking for evil monsters!");
1350 o_ptr->name2 = EGO_KILL_EVIL;
1353 act = _("は異世界の住人の肉体を求めている!", "seems to be looking for demons!");
1354 o_ptr->name2 = EGO_KILL_DEMON;
1357 act = _("は屍を求めている!", "seems to be looking for undead!");
1358 o_ptr->name2 = EGO_KILL_UNDEAD;
1361 act = _("は動物の血を求めている!", "seems to be looking for animals!");
1362 o_ptr->name2 = EGO_KILL_ANIMAL;
1365 act = _("はドラゴンの血を求めている!", "seems to be looking for dragons!");
1366 o_ptr->name2 = EGO_KILL_DRAGON;
1369 act = _("はトロルの血を求めている!", "seems to be looking for troll!s");
1370 o_ptr->name2 = EGO_KILL_TROLL;
1373 act = _("はオークの血を求めている!", "seems to be looking for orcs!");
1374 o_ptr->name2 = EGO_KILL_ORC;
1377 act = _("は巨人の血を求めている!", "seems to be looking for giants!");
1378 o_ptr->name2 = EGO_KILL_GIANT;
1381 act = _("は非常に不安定になったようだ。", "seems very unstable now.");
1382 o_ptr->name2 = EGO_TRUMP;
1383 o_ptr->pval = randint1(2);
1386 act = _("は血を求めている!", "thirsts for blood!");
1387 o_ptr->name2 = EGO_VAMPIRIC;
1390 act = _("は毒に覆われた。", "is coated with poison.");
1391 o_ptr->name2 = EGO_BRAND_POIS;
1394 act = _("は純ログルスに飲み込まれた。", "is engulfed in raw Logrus!");
1395 o_ptr->name2 = EGO_CHAOTIC;
1398 act = _("は炎のシールドに覆われた!", "is covered in a fiery shield!");
1399 o_ptr->name2 = EGO_BRAND_FIRE;
1402 act = _("は深く冷たいブルーに輝いた!", "glows deep, icy blue!");
1403 o_ptr->name2 = EGO_BRAND_COLD;
1407 msg_format(_("あなたの%s%s", "Your %s %s"), o_name, act);
1408 enchant(caster_ptr, o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
1410 o_ptr->discount = 99;
1411 chg_virtue(caster_ptr, V_ENCHANT, 2);
1412 calc_android_exp(caster_ptr);