4 #include "spells-object.h"
5 #include "object-hook.h"
6 #include "player-status.h"
12 OBJECT_TYPE_VALUE tval;
13 OBJECT_SUBTYPE_VALUE sval;
19 * Scatter some "amusing" objects near the player
22 #define AMS_NOTHING 0x00 /* No restriction */
23 #define AMS_NO_UNIQUE 0x01 /* Don't make the amusing object of uniques */
24 #define AMS_FIXED_ART 0x02 /* Make a fixed artifact based on the amusing object */
25 #define AMS_MULTIPLE 0x04 /* Drop 1-3 objects for one type */
26 #define AMS_PILE 0x08 /* Drop 1-99 pile objects for one type */
28 static amuse_type amuse_info[] =
30 { TV_BOTTLE, SV_ANY, 5, AMS_NOTHING },
31 { TV_JUNK, SV_ANY, 3, AMS_MULTIPLE },
32 { TV_SPIKE, SV_ANY, 10, AMS_PILE },
33 { TV_STATUE, SV_ANY, 15, AMS_NOTHING },
34 { TV_CORPSE, SV_ANY, 15, AMS_NO_UNIQUE },
35 { TV_SKELETON, SV_ANY, 10, AMS_NO_UNIQUE },
36 { TV_FIGURINE, SV_ANY, 10, AMS_NO_UNIQUE },
37 { TV_PARCHMENT, SV_ANY, 1, AMS_NOTHING },
38 { TV_POLEARM, SV_TSURIZAO, 3, AMS_NOTHING }, //Fishing Pole of Taikobo
39 { TV_SWORD, SV_BROKEN_DAGGER, 3, AMS_FIXED_ART }, //Broken Dagger of Magician
40 { TV_SWORD, SV_BROKEN_DAGGER, 10, AMS_NOTHING },
41 { TV_SWORD, SV_BROKEN_SWORD, 5, AMS_NOTHING },
42 { TV_SCROLL, SV_SCROLL_AMUSEMENT, 10, AMS_NOTHING },
48 * @brief「弾/矢の製造」処理 / do_cmd_cast calls this function if the player's class is 'archer'.
49 * Hook to determine if an object is contertible in an arrow/bolt
50 * @return 製造を実際に行ったらTRUE、キャンセルしたらFALSEを返す
52 bool create_ammo(void)
61 GAME_TEXT o_name[MAX_NLEN];
66 sprintf(com, _("[S]弾, [A]矢, [B]クロスボウの矢 :", "Create [S]hots, Create [A]rrow or Create [B]olt ?"));
67 else if (p_ptr->lev >= 10)
68 sprintf(com, _("[S]弾, [A]矢:", "Create [S]hots or Create [A]rrow ?"));
70 sprintf(com, _("[S]弾:", "Create [S]hots ?"));
74 msg_print(_("混乱してる!", "You are too confused!"));
80 msg_print(_("目が見えない!", "You are blind!"));
86 if (!get_com(com, &ch, TRUE))
90 if (ch == 'S' || ch == 's')
95 if ((ch == 'A' || ch == 'a') && (p_ptr->lev >= 10))
100 if ((ch == 'B' || ch == 'b') && (p_ptr->lev >= 20))
107 /**********Create shots*********/
114 if (!get_rep_dir(&dir, FALSE)) return FALSE;
115 y = p_ptr->y + ddy[dir];
116 x = p_ptr->x + ddx[dir];
117 g_ptr = &grid_array[y][x];
119 if (!have_flag(f_info[get_feat_mimic(g_ptr)].flags, FF_CAN_DIG))
121 msg_print(_("そこには岩石がない。", "You need pile of rubble."));
124 else if (!cave_have_flag_grid(g_ptr, FF_CAN_DIG) || !cave_have_flag_grid(g_ptr, FF_HURT_ROCK))
126 msg_print(_("硬すぎて崩せなかった。", "You failed to make ammo."));
133 /* Hack -- Give the player some small firestones */
134 object_prep(q_ptr, lookup_kind(TV_SHOT, (OBJECT_SUBTYPE_VALUE)m_bonus(1, p_ptr->lev) + 1));
135 q_ptr->number = (byte)rand_range(15, 30);
138 apply_magic(q_ptr, p_ptr->lev, AM_NO_FIXED_ART);
139 q_ptr->discount = 99;
141 slot = inven_carry(q_ptr);
143 object_desc(o_name, q_ptr, 0);
144 msg_format(_("%sを作った。", "You make some ammo."), o_name);
146 /* Auto-inscription */
147 if (slot >= 0) autopick_alter_item(slot, FALSE);
149 /* Destroy the wall */
150 cave_alter_feat(y, x, FF_HURT_ROCK);
152 p_ptr->update |= (PU_FLOW);
155 /**********Create arrows*********/
162 item_tester_hook = item_tester_hook_convertible;
164 q = _("どのアイテムから作りますか? ", "Convert which item? ");
165 s = _("材料を持っていない。", "You have no item to convert.");
166 q_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
167 if (!q_ptr) return FALSE;
171 /* Hack -- Give the player some small firestones */
172 object_prep(q_ptr, lookup_kind(TV_ARROW, (OBJECT_SUBTYPE_VALUE)m_bonus(1, p_ptr->lev) + 1));
173 q_ptr->number = (byte)rand_range(5, 10);
176 apply_magic(q_ptr, p_ptr->lev, AM_NO_FIXED_ART);
178 q_ptr->discount = 99;
180 object_desc(o_name, q_ptr, 0);
181 msg_format(_("%sを作った。", "You make some ammo."), o_name);
185 inven_item_increase(item, -1);
186 inven_item_describe(item);
187 inven_item_optimize(item);
191 floor_item_increase(0 - item, -1);
192 floor_item_describe(0 - item);
193 floor_item_optimize(0 - item);
196 slot = inven_carry(q_ptr);
198 /* Auto-inscription */
199 if (slot >= 0) autopick_alter_item(slot, FALSE);
201 /**********Create bolts*********/
208 item_tester_hook = item_tester_hook_convertible;
210 q = _("どのアイテムから作りますか? ", "Convert which item? ");
211 s = _("材料を持っていない。", "You have no item to convert.");
213 q_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
214 if (!q_ptr) return FALSE;
218 /* Hack -- Give the player some small firestones */
219 object_prep(q_ptr, lookup_kind(TV_BOLT, (OBJECT_SUBTYPE_VALUE)m_bonus(1, p_ptr->lev) + 1));
220 q_ptr->number = (byte)rand_range(4, 8);
223 apply_magic(q_ptr, p_ptr->lev, AM_NO_FIXED_ART);
225 q_ptr->discount = 99;
227 object_desc(o_name, q_ptr, 0);
228 msg_format(_("%sを作った。", "You make some ammo."), o_name);
232 inven_item_increase(item, -1);
233 inven_item_describe(item);
234 inven_item_optimize(item);
238 floor_item_increase(0 - item, -1);
239 floor_item_describe(0 - item);
240 floor_item_optimize(0 - item);
243 slot = inven_carry(q_ptr);
245 /* Auto-inscription */
246 if (slot >= 0) autopick_alter_item(slot, FALSE);
252 * @brief 魔道具術師の魔力取り込み処理
253 * @return 取り込みを実行したらTRUE、キャンセルしたらFALSEを返す
255 bool import_magic_device(void)
258 PARAMETER_VALUE pval;
262 GAME_TEXT o_name[MAX_NLEN];
264 /* Only accept legal items */
265 item_tester_hook = item_tester_hook_recharge;
267 q = _("どのアイテムの魔力を取り込みますか? ", "Gain power of which item? ");
268 s = _("魔力を取り込めるアイテムがない。", "You have nothing to gain power.");
270 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
271 if (!o_ptr) return (FALSE);
273 if (o_ptr->tval == TV_STAFF && o_ptr->sval == SV_STAFF_NOTHING)
275 msg_print(_("この杖には発動の為の能力は何も備わっていないようだ。", "This staff doesn't have any magical ability."));
279 if (!object_is_known(o_ptr))
281 msg_print(_("鑑定されていないと取り込めない。", "You need to identify before absorbing."));
287 msg_print(_("充填中のアイテムは取り込めない。", "This item is still charging."));
292 if (o_ptr->tval == TV_ROD)
294 else if (o_ptr->tval == TV_WAND)
297 if (o_ptr->tval == TV_ROD)
299 p_ptr->magic_num2[o_ptr->sval + ext] += (MAGIC_NUM2)o_ptr->number;
300 if (p_ptr->magic_num2[o_ptr->sval + ext] > 99) p_ptr->magic_num2[o_ptr->sval + ext] = 99;
305 for (num = o_ptr->number; num; num--)
308 if (o_ptr->tval == TV_WAND) gain_num = (pval + num - 1) / num;
309 if (p_ptr->magic_num2[o_ptr->sval + ext])
312 gain_num = (gain_num / 3 + randint0(gain_num / 3)) / 256;
313 if (gain_num < 1) gain_num = 1;
315 p_ptr->magic_num2[o_ptr->sval + ext] += (MAGIC_NUM2)gain_num;
316 if (p_ptr->magic_num2[o_ptr->sval + ext] > 99) p_ptr->magic_num2[o_ptr->sval + ext] = 99;
317 p_ptr->magic_num1[o_ptr->sval + ext] += pval * 0x10000;
318 if (p_ptr->magic_num1[o_ptr->sval + ext] > 99 * 0x10000) p_ptr->magic_num1[o_ptr->sval + ext] = 99 * 0x10000;
319 if (p_ptr->magic_num1[o_ptr->sval + ext] > p_ptr->magic_num2[o_ptr->sval + ext] * 0x10000) p_ptr->magic_num1[o_ptr->sval + ext] = p_ptr->magic_num2[o_ptr->sval + ext] * 0x10000;
320 if (o_ptr->tval == TV_WAND) pval -= (pval + num - 1) / num;
324 object_desc(o_name, o_ptr, 0);
325 msg_format(_("%sの魔力を取り込んだ。", "You absorb magic of %s."), o_name);
327 /* Eliminate the item (from the pack) */
330 inven_item_increase(item, -999);
331 inven_item_describe(item);
332 inven_item_optimize(item);
335 /* Eliminate the item (from the floor) */
338 floor_item_increase(0 - item, -999);
339 floor_item_describe(0 - item);
340 floor_item_optimize(0 - item);
342 take_turn(p_ptr, 100);
348 * @param y1 配置したいフロアのY座標
349 * @param x1 配置したいフロアのX座標
351 * @param known TRUEならばオブジェクトが必ず*鑑定*済になる
354 void amusement(POSITION y1, POSITION x1, int num, bool known)
357 object_type object_type_body;
360 for (n = 0; amuse_info[n].tval != 0; n++)
362 t += amuse_info[n].prob;
369 KIND_OBJECT_IDX k_idx;
370 ARTIFACT_IDX a_idx = 0;
372 bool insta_art, fixed_art;
376 r -= amuse_info[i].prob;
379 i_ptr = &object_type_body;
381 k_idx = lookup_kind(amuse_info[i].tval, amuse_info[i].sval);
383 /* Paranoia - reroll if nothing */
384 if (!k_idx) continue;
386 /* Search an artifact index if need */
387 insta_art = (k_info[k_idx].gen_flags & TRG_INSTA_ART);
388 fixed_art = (amuse_info[i].flag & AMS_FIXED_ART);
390 if (insta_art || fixed_art)
392 for (a_idx = 1; a_idx < max_a_idx; a_idx++)
394 if (insta_art && !(a_info[a_idx].gen_flags & TRG_INSTA_ART)) continue;
395 if (a_info[a_idx].tval != k_info[k_idx].tval) continue;
396 if (a_info[a_idx].sval != k_info[k_idx].sval) continue;
397 if (a_info[a_idx].cur_num > 0) continue;
401 if (a_idx >= max_a_idx) continue;
404 /* Make an object (if possible) */
405 object_prep(i_ptr, k_idx);
406 if (a_idx) i_ptr->name1 = a_idx;
407 apply_magic(i_ptr, 1, AM_NO_FIXED_ART);
409 if (amuse_info[i].flag & AMS_NO_UNIQUE)
411 if (r_info[i_ptr->pval].flags1 & RF1_UNIQUE) continue;
414 if (amuse_info[i].flag & AMS_MULTIPLE) i_ptr->number = randint1(3);
415 if (amuse_info[i].flag & AMS_PILE) i_ptr->number = randint1(99);
423 /* Paranoia - reroll if nothing */
424 if (!(i_ptr->k_idx)) continue;
426 (void)drop_near(i_ptr, -1, y1, x1);
436 * Scatter some "great" objects near the player
437 * @param y1 配置したいフロアのY座標
438 * @param x1 配置したいフロアのX座標
440 * @param great TRUEならば必ず高級品以上を落とす
441 * @param special TRUEならば必ず特別品を落とす
442 * @param known TRUEならばオブジェクトが必ず*鑑定*済になる
445 void acquirement(POSITION y1, POSITION x1, int num, bool great, bool special, bool known)
448 object_type object_type_body;
449 BIT_FLAGS mode = AM_GOOD | (great || special ? AM_GREAT : 0L) | (special ? AM_SPECIAL : 0L);
454 i_ptr = &object_type_body;
457 /* Make a good (or great) object (if possible) */
458 if (!make_object(i_ptr, mode)) continue;
466 (void)drop_near(i_ptr, -1, y1, x1);
470 void acquire_chaos_weapon(player_type *creature_ptr)
473 object_type *q_ptr = &forge;
474 OBJECT_TYPE_VALUE dummy = TV_SWORD;
475 OBJECT_SUBTYPE_VALUE dummy2;
476 switch (randint1(creature_ptr->lev))
482 dummy2 = SV_MAIN_GAUCHE;
491 dummy2 = SV_SMALL_SWORD;
494 dummy2 = SV_BASILLARD;
496 case 11: case 12: case 13:
497 dummy2 = SV_SHORT_SWORD;
506 dummy2 = SV_WAKIZASHI;
515 dummy2 = SV_BROAD_SWORD;
518 dummy2 = SV_LONG_SWORD;
521 dummy2 = SV_SCIMITAR;
530 dummy2 = SV_BASTARD_SWORD;
533 dummy2 = SV_GREAT_SCIMITAR;
536 dummy2 = SV_CLAYMORE;
542 dummy2 = SV_TWO_HANDED_SWORD;
545 dummy2 = SV_FLAMBERGE;
548 dummy2 = SV_NO_DACHI;
551 dummy2 = SV_EXECUTIONERS_SWORD;
554 dummy2 = SV_ZWEIHANDER;
557 dummy2 = SV_HAYABUSA;
560 dummy2 = SV_BLADE_OF_CHAOS;
563 object_prep(q_ptr, lookup_kind(dummy, dummy2));
564 q_ptr->to_h = 3 + randint1(dun_level) % 10;
565 q_ptr->to_d = 3 + randint1(dun_level) % 10;
566 one_resistance(q_ptr);
567 q_ptr->name2 = EGO_CHAOTIC;
568 (void)drop_near(q_ptr, -1, creature_ptr->y, creature_ptr->x);
574 * Curse the players armor
575 * @return 実際に呪縛されたらTRUEを返す
577 bool curse_armor(void)
582 GAME_TEXT o_name[MAX_NLEN];
584 /* Curse the body armor */
585 o_ptr = &inventory[INVEN_BODY];
587 /* Nothing to curse */
588 if (!o_ptr->k_idx) return (FALSE);
590 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
592 /* Attempt a saving throw for artifacts */
593 if (object_is_artifact(o_ptr) && (randint0(100) < 50))
597 msg_format("%sが%sを包み込もうとしたが、%sはそれを跳ね返した!",
598 "恐怖の暗黒オーラ", "防具", o_name);
600 msg_format("A %s tries to %s, but your %s resists the effects!",
601 "terrible black aura", "surround your armor", o_name);
606 /* not artifact or failed save... */
609 msg_format(_("恐怖の暗黒オーラがあなたの%sを包み込んだ!", "A terrible black aura blasts your %s!"), o_name);
610 chg_virtue(V_ENCHANT, -5);
612 /* Blast the armor */
614 o_ptr->name2 = EGO_BLASTED;
615 o_ptr->to_a = 0 - randint1(5) - randint1(5);
622 for (i = 0; i < TR_FLAG_SIZE; i++)
623 o_ptr->art_flags[i] = 0;
626 o_ptr->curse_flags = TRC_CURSED;
629 o_ptr->ident |= (IDENT_BROKEN);
630 p_ptr->update |= (PU_BONUS | PU_MANA);
631 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
639 * Curse the players weapon
640 * @param force 無条件に呪縛を行うならばTRUE
641 * @param o_ptr 呪縛する武器のアイテム情報参照ポインタ
642 * @return 実際に呪縛されたらTRUEを返す
644 bool curse_weapon_object(bool force, object_type *o_ptr)
647 GAME_TEXT o_name[MAX_NLEN];
649 /* Nothing to curse */
650 if (!o_ptr->k_idx) return (FALSE);
651 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
653 /* Attempt a saving throw */
654 if (object_is_artifact(o_ptr) && (randint0(100) < 50) && !force)
658 msg_format("%sが%sを包み込もうとしたが、%sはそれを跳ね返した!",
659 "恐怖の暗黒オーラ", "武器", o_name);
661 msg_format("A %s tries to %s, but your %s resists the effects!",
662 "terrible black aura", "surround your weapon", o_name);
666 /* not artifact or failed save... */
669 if (!force) msg_format(_("恐怖の暗黒オーラがあなたの%sを包み込んだ!", "A terrible black aura blasts your %s!"), o_name);
670 chg_virtue(V_ENCHANT, -5);
672 /* Shatter the weapon */
674 o_ptr->name2 = EGO_SHATTERED;
675 o_ptr->to_h = 0 - randint1(5) - randint1(5);
676 o_ptr->to_d = 0 - randint1(5) - randint1(5);
682 for (i = 0; i < TR_FLAG_SIZE; i++)
683 o_ptr->art_flags[i] = 0;
686 o_ptr->curse_flags = TRC_CURSED;
689 o_ptr->ident |= (IDENT_BROKEN);
690 p_ptr->update |= (PU_BONUS | PU_MANA);
691 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
698 * @brief 武器呪縛処理のメインルーチン /
699 * Curse the players weapon
700 * @param force 無条件に呪縛を行うならばTRUE
701 * @param slot 呪縛する武器の装備スロット
702 * @return 実際に呪縛されたらTRUEを返す
704 bool curse_weapon(bool force, int slot)
706 /* Curse the weapon */
707 return curse_weapon_object(force, &inventory[slot]);
713 * @return ターン消費を要する処理を行ったならばTRUEを返す
719 GAME_TEXT o_name[MAX_NLEN];
722 /* Select a piece of armour */
723 item_tester_hook = object_is_armour;
725 q = _("どの防具に錆止めをしますか?", "Rustproof which piece of armour? ");
726 s = _("錆止めできるものがありません。", "You have nothing to rustproof.");
728 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
729 if (!o_ptr) return FALSE;
731 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
733 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
735 if ((o_ptr->to_a < 0) && !object_is_cursed(o_ptr))
738 msg_format("%sは新品同様になった!", o_name);
740 msg_format("%s %s look%s as good as new!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
747 msg_format("%sは腐食しなくなった。", o_name);
749 msg_format("%s %s %s now protected against corrosion.", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "are" : "is"));
757 * @brief ボルトのエゴ化処理(火炎エゴのみ) /
761 bool brand_bolts(void)
765 /* Use the first acceptable bolts */
766 for (i = 0; i < INVEN_PACK; i++)
768 object_type *o_ptr = &inventory[i];
771 if (o_ptr->tval != TV_BOLT) continue;
773 /* Skip artifacts and ego-items */
774 if (object_is_artifact(o_ptr) || object_is_ego(o_ptr))
777 /* Skip cursed/broken items */
778 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) continue;
781 if (randint0(100) < 75) continue;
783 msg_print(_("クロスボウの矢が炎のオーラに包まれた!", "Your bolts are covered in a fiery aura!"));
786 o_ptr->name2 = EGO_FLAME;
787 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
791 if (flush_failure) flush();
794 msg_print(_("炎で強化するのに失敗した。", "The fiery enchantment failed."));
800 bool perilous_secrets(player_type *creature_ptr)
802 if (!ident_spell(FALSE)) return FALSE;
804 if (mp_ptr->spell_book)
806 /* Sufficient mana */
807 if (20 <= p_ptr->csp)
813 /* Over-exert the player */
816 int oops = 20 - p_ptr->csp;
822 msg_print(_("石を制御できない!", "You are too weak to control the stone!"));
823 /* Hack -- Bypass free action */
824 (void)set_paralyzed(p_ptr->paralyzed + randint1(5 * oops + 1));
827 (void)set_confused(p_ptr->confused + randint1(5 * oops + 1));
829 p_ptr->redraw |= (PR_MANA);
831 take_hit(DAMAGE_LOSELIFE, damroll(1, 12), _("危険な秘密", "perilous secrets"), -1);
833 if (one_in_(5)) (void)set_confused(p_ptr->confused + randint1(10));
835 /* Exercise a little care... */
836 if (one_in_(20)) take_hit(DAMAGE_LOSELIFE, damroll(4, 10), _("危険な秘密", "perilous secrets"), -1);