3 * @brief 魔法効果の実装/ Spell code (part 3)
7 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
8 * This software may be copied and distributed for educational, research,
9 * and not for profit purposes provided that this copyright and statement
10 * are included in all such copies. Other copyrights may also apply.
16 /*! テレポート先探索の試行数 / Maximum number of tries for teleporting */
19 /*! 能力値現象の基本確率(1 / HURT_CHANCE) / 1/x chance of reducing stats (for elemental attacks) */
20 #define HURT_CHANCE 16
23 * @brief 指定されたマスがモンスターのテレポート可能先かどうかを判定する。
24 * @param m_idx モンスターID
28 * @return テレポート先として妥当ならばtrue
30 static bool cave_monster_teleportable_bold(int m_idx, int y, int x, u32b mode)
32 monster_type *m_ptr = &m_list[m_idx];
33 cave_type *c_ptr = &cave[y][x];
34 feature_type *f_ptr = &f_info[c_ptr->feat];
36 /* Require "teleportable" space */
37 if (!have_flag(f_ptr->flags, FF_TELEPORTABLE)) return FALSE;
39 if (c_ptr->m_idx && (c_ptr->m_idx != m_idx)) return FALSE;
40 if (player_bold(y, x)) return FALSE;
42 /* Hack -- no teleport onto glyph of warding */
43 if (is_glyph_grid(c_ptr)) return FALSE;
44 if (is_explosive_rune_grid(c_ptr)) return FALSE;
46 if (!(mode & TELEPORT_PASSIVE))
48 if (!monster_can_cross_terrain(c_ptr->feat, &r_info[m_ptr->r_idx], 0)) return FALSE;
56 * @brief モンスターのテレポートアウェイ処理 /
57 * Teleport a monster, normally up to "dis" grids away.
58 * @param m_idx モンスターID
61 * @return テレポートが実際に行われたらtrue
63 * Attempt to move the monster at least "dis/2" grids away.
64 * But allow variation to prevent infinite loops.
66 bool teleport_away(idx m_idx, int dis, u32b mode)
68 int oy, ox, d, i, min;
70 position ny = 0, nx = 0;
74 monster_type *m_ptr = &m_list[m_idx];
77 if (!m_ptr->r_idx) return (FALSE);
79 /* Save the old location */
83 /* Minimum distance */
86 if ((mode & TELEPORT_DEC_VALOUR) &&
87 (((p_ptr->chp * 10) / p_ptr->mhp) > 5) &&
88 (4+randint1(5) < ((p_ptr->chp * 10) / p_ptr->mhp)))
90 chg_virtue(V_VALOUR, -1);
98 /* Verify max distance */
99 if (dis > 200) dis = 200;
101 /* Try several locations */
102 for (i = 0; i < 500; i++)
104 /* Pick a (possibly illegal) location */
107 ny = rand_spread(oy, dis);
108 nx = rand_spread(ox, dis);
109 d = distance(oy, ox, ny, nx);
110 if ((d >= min) && (d <= dis)) break;
113 /* Ignore illegal locations */
114 if (!in_bounds(ny, nx)) continue;
116 if (!cave_monster_teleportable_bold(m_idx, ny, nx, mode)) continue;
118 /* No teleporting into vaults and such */
119 if (!(p_ptr->inside_quest || p_ptr->inside_arena))
120 if (cave[ny][nx].info & CAVE_ICKY) continue;
122 /* This grid looks good */
129 /* Increase the maximum distance */
132 /* Decrease the minimum distance */
135 /* Stop after MAX_TRIES tries */
136 if (tries > MAX_TRIES) return (FALSE);
140 sound(SOUND_TPOTHER);
142 /* Update the old location */
143 cave[oy][ox].m_idx = 0;
145 /* Update the new location */
146 cave[ny][nx].m_idx = m_idx;
148 /* Move the monster */
152 /* Forget the counter target */
155 /* Update the monster (new location) */
156 update_mon(m_idx, TRUE);
158 /* Redraw the old grid */
161 /* Redraw the new grid */
164 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
165 p_ptr->update |= (PU_MON_LITE);
172 * @brief モンスターを指定された座標付近にテレポートする /
173 * Teleport monster next to a grid near the given location
174 * @param m_idx モンスターID
177 * @param power テレポート成功確率
181 void teleport_monster_to(int m_idx, int ty, int tx, int power, u32b mode)
183 int ny, nx, oy, ox, d, i, min;
187 monster_type *m_ptr = &m_list[m_idx];
190 if (!m_ptr->r_idx) return;
193 if (randint1(100) > power) return;
199 /* Save the old location */
203 /* Minimum distance */
206 /* Look until done */
207 while (look && --attempts)
209 /* Verify max distance */
210 if (dis > 200) dis = 200;
212 /* Try several locations */
213 for (i = 0; i < 500; i++)
215 /* Pick a (possibly illegal) location */
218 ny = rand_spread(ty, dis);
219 nx = rand_spread(tx, dis);
220 d = distance(ty, tx, ny, nx);
221 if ((d >= min) && (d <= dis)) break;
224 /* Ignore illegal locations */
225 if (!in_bounds(ny, nx)) continue;
227 if (!cave_monster_teleportable_bold(m_idx, ny, nx, mode)) continue;
229 /* No teleporting into vaults and such */
230 /* if (cave[ny][nx].info & (CAVE_ICKY)) continue; */
232 /* This grid looks good */
239 /* Increase the maximum distance */
242 /* Decrease the minimum distance */
246 if (attempts < 1) return;
249 sound(SOUND_TPOTHER);
251 /* Update the old location */
252 cave[oy][ox].m_idx = 0;
254 /* Update the new location */
255 cave[ny][nx].m_idx = m_idx;
257 /* Move the monster */
261 /* Update the monster (new location) */
262 update_mon(m_idx, TRUE);
264 /* Redraw the old grid */
267 /* Redraw the new grid */
270 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
271 p_ptr->update |= (PU_MON_LITE);
275 * @brief 指定されたマスにプレイヤーがテレポート可能かどうかを判定する。
279 * @return テレポート先として妥当ならばtrue
281 bool cave_player_teleportable_bold(int y, int x, u32b mode)
283 cave_type *c_ptr = &cave[y][x];
284 feature_type *f_ptr = &f_info[c_ptr->feat];
286 /* Require "teleportable" space */
287 if (!have_flag(f_ptr->flags, FF_TELEPORTABLE)) return FALSE;
289 /* No magical teleporting into vaults and such */
290 if (!(mode & TELEPORT_NONMAGICAL) && (c_ptr->info & CAVE_ICKY)) return FALSE;
292 if (c_ptr->m_idx && (c_ptr->m_idx != p_ptr->riding)) return FALSE;
294 /* don't teleport on a trap. */
295 if (have_flag(f_ptr->flags, FF_HIT_TRAP)) return FALSE;
297 if (!(mode & TELEPORT_PASSIVE))
299 if (!player_can_enter(c_ptr->feat, 0)) return FALSE;
301 if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP))
303 if (!p_ptr->levitation && !p_ptr->can_swim) return FALSE;
306 if (have_flag(f_ptr->flags, FF_LAVA) && !p_ptr->immune_fire && !IS_INVULN())
308 /* Always forbid deep lava */
309 if (have_flag(f_ptr->flags, FF_DEEP)) return FALSE;
311 /* Forbid shallow lava when the player don't have levitation */
312 if (!p_ptr->levitation) return FALSE;
322 #define MAX_TELEPORT_DISTANCE 200
325 * @brief プレイヤーのテレポート先選定と移動処理 /
326 * Teleport the player to a location up to "dis" grids away.
329 * @return 実際にテレポート処理が行われたらtrue
332 * If no such spaces are readily available, the distance may increase.
333 * Try very hard to move the player at least a quarter that distance.
335 * There was a nasty tendency for a long time; which was causing the
336 * player to "bounce" between two or three different spots because
337 * these are the only spots that are "far enough" way to satisfy the
340 * But this tendency is now removed; in the new algorithm, a list of
341 * candidates is selected first, which includes at least 50% of all
342 * floor grids within the distance, and any single grid in this list
343 * of candidates has equal possibility to be choosen as a destination.
347 bool teleport_player_aux(int dis, u32b mode)
349 int candidates_at[MAX_TELEPORT_DISTANCE + 1];
350 int total_candidates, cur_candidates;
351 position y = 0, x = 0;
354 int left = MAX(1, p_ptr->x - dis);
355 int right = MIN(cur_wid - 2, p_ptr->x + dis);
356 int top = MAX(1, p_ptr->y - dis);
357 int bottom = MIN(cur_hgt - 2, p_ptr->y + dis);
359 if (p_ptr->wild_mode) return FALSE;
361 if (p_ptr->anti_tele && !(mode & TELEPORT_NONMAGICAL))
363 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
367 /* Initialize counters */
368 total_candidates = 0;
369 for (i = 0; i <= MAX_TELEPORT_DISTANCE; i++)
370 candidates_at[i] = 0;
372 /* Limit the distance */
373 if (dis > MAX_TELEPORT_DISTANCE) dis = MAX_TELEPORT_DISTANCE;
375 /* Search valid locations */
376 for (y = top; y <= bottom; y++)
378 for (x = left; x <= right; x++)
382 /* Skip illegal locations */
383 if (!cave_player_teleportable_bold(y, x, mode)) continue;
385 /* Calculate distance */
386 d = distance(p_ptr->y, p_ptr->x, y, x);
388 /* Skip too far locations */
389 if (d > dis) continue;
391 /* Count the total number of candidates */
394 /* Count the number of candidates in this circumference */
399 /* No valid location! */
400 if (0 == total_candidates) return FALSE;
402 /* Fix the minimum distance */
403 for (cur_candidates = 0, min = dis; min >= 0; min--)
405 cur_candidates += candidates_at[min];
407 /* 50% of all candidates will have an equal chance to be choosen. */
408 if (cur_candidates && (cur_candidates >= total_candidates / 2)) break;
411 /* Pick up a single location randomly */
412 pick = randint1(cur_candidates);
414 /* Search again the choosen location */
415 for (y = top; y <= bottom; y++)
417 for (x = left; x <= right; x++)
421 /* Skip illegal locations */
422 if (!cave_player_teleportable_bold(y, x, mode)) continue;
424 /* Calculate distance */
425 d = distance(p_ptr->y, p_ptr->x, y, x);
427 /* Skip too far locations */
428 if (d > dis) continue;
430 /* Skip too close locations */
431 if (d < min) continue;
433 /* This grid was picked up? */
442 if (player_bold(y, x)) return FALSE;
445 sound(SOUND_TELEPORT);
448 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
449 msg_format("『こっちだぁ、%s』", p_ptr->name);
452 /* Move the player */
453 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
459 * @brief プレイヤーのテレポート処理メインルーチン
464 void teleport_player(int dis, u32b mode)
468 /* Save the old location */
472 if (!teleport_player_aux(dis, mode)) return;
474 /* Monsters with teleport ability may follow the player */
475 for (xx = -1; xx < 2; xx++)
477 for (yy = -1; yy < 2; yy++)
479 int tmp_m_idx = cave[oy+yy][ox+xx].m_idx;
481 /* A monster except your mount may follow */
482 if (tmp_m_idx && (p_ptr->riding != tmp_m_idx))
484 monster_type *m_ptr = &m_list[tmp_m_idx];
485 monster_race *r_ptr = &r_info[m_ptr->r_idx];
488 * The latter limitation is to avoid
489 * totally unkillable suckers...
491 if ((r_ptr->a_ability_flags2 & RF6_TPORT) &&
492 !(r_ptr->flagsr & RFR_RES_TELE))
494 if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, p_ptr->y, p_ptr->x, r_ptr->level, 0L);
503 * @brief プレイヤーのテレポートアウェイ処理 /
504 * @param m_idx アウェイを試みたプレイヤーID
508 void teleport_player_away(int m_idx, int dis)
512 /* Save the old location */
516 if (!teleport_player_aux(dis, TELEPORT_PASSIVE)) return;
518 /* Monsters with teleport ability may follow the player */
519 for (xx = -1; xx < 2; xx++)
521 for (yy = -1; yy < 2; yy++)
523 int tmp_m_idx = cave[oy+yy][ox+xx].m_idx;
525 /* A monster except your mount or caster may follow */
526 if (tmp_m_idx && (p_ptr->riding != tmp_m_idx) && (m_idx != tmp_m_idx))
528 monster_type *m_ptr = &m_list[tmp_m_idx];
529 monster_race *r_ptr = &r_info[m_ptr->r_idx];
532 * The latter limitation is to avoid
533 * totally unkillable suckers...
535 if ((r_ptr->a_ability_flags2 & RF6_TPORT) &&
536 !(r_ptr->flagsr & RFR_RES_TELE))
538 if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, p_ptr->y, p_ptr->x, r_ptr->level, 0L);
547 * @brief プレイヤーを指定位置近辺にテレポートさせる
548 * Teleport player to a grid near the given location
551 * @param mode オプションフラグ
555 * This function is slightly obsessive about correctness.
556 * This function allows teleporting into vaults (!)
559 void teleport_player_to(int ny, int nx, u32b mode)
561 int y, x, dis = 0, ctr = 0;
563 if (p_ptr->anti_tele && !(mode & TELEPORT_NONMAGICAL))
565 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
569 /* Find a usable location */
572 /* Pick a nearby legal location */
575 y = rand_spread(ny, dis);
576 x = rand_spread(nx, dis);
577 if (in_bounds(y, x)) break;
580 /* Accept any grid when wizard mode */
581 if (p_ptr->wizard && !(mode & TELEPORT_PASSIVE) && (!cave[y][x].m_idx || (cave[y][x].m_idx == p_ptr->riding))) break;
583 /* Accept teleportable floor grids */
584 if (cave_player_teleportable_bold(y, x, mode)) break;
586 /* Occasionally advance the distance */
587 if (++ctr > (4 * dis * dis + 4 * dis + 1))
595 sound(SOUND_TELEPORT);
597 /* Move the player */
598 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
602 void teleport_away_followable(int m_idx)
604 monster_type *m_ptr = &m_list[m_idx];
605 int oldfy = m_ptr->fy;
606 int oldfx = m_ptr->fx;
607 bool old_ml = m_ptr->ml;
608 int old_cdis = m_ptr->cdis;
610 teleport_away(m_idx, MAX_SIGHT * 2 + 5, 0L);
612 if (old_ml && (old_cdis <= MAX_SIGHT) && !world_monster && !p_ptr->inside_battle && los(p_ptr->y, p_ptr->x, oldfy, oldfx))
616 if ((p_ptr->muta1 & MUT1_VTELEPORT) || (p_ptr->pclass == CLASS_IMITATOR)) follow = TRUE;
619 u32b flgs[TR_FLAG_SIZE];
623 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
625 o_ptr = &inventory[i];
626 if (o_ptr->k_idx && !object_is_cursed(o_ptr))
628 object_flags(o_ptr, flgs);
629 if (have_flag(flgs, TR_TELEPORT))
640 if (get_check_strict(_("ついていきますか?", "Do you follow it? "), CHECK_OKAY_CANCEL))
644 teleport_player(200, TELEPORT_PASSIVE);
645 msg_print(_("失敗!", "Failed!"));
647 else teleport_player_to(m_ptr->fy, m_ptr->fx, 0L);
648 p_ptr->energy_need += ENERGY_NEED();
656 * @brief プレイヤー及びモンスターをレベルテレポートさせる /
657 * Teleport the player one level up or down (random when legal)
658 * @param m_idx テレポートの対象となるモンスターID(0ならばプレイヤー) / If m_idx <= 0, target is player.
661 void teleport_level(int m_idx)
667 if (m_idx <= 0) /* To player */
669 strcpy(m_name, _("あなた", "you"));
671 else /* To monster */
673 monster_type *m_ptr = &m_list[m_idx];
675 /* Get the monster name (or "it") */
676 monster_desc(m_name, m_ptr, 0);
678 see_m = is_seen(m_ptr);
681 /* No effect in some case */
682 if (TELE_LEVEL_IS_INEFF(m_idx))
684 if (see_m) msg_print(_("効果がなかった。", "There is no effect."));
688 if ((m_idx <= 0) && p_ptr->anti_tele) /* To player */
690 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
694 /* Choose up or down */
695 if (randint0(100) < 50) go_up = TRUE;
698 if ((m_idx <= 0) && p_ptr->wizard)
700 if (get_check("Force to go up? ")) go_up = TRUE;
701 else if (get_check("Force to go down? ")) go_up = FALSE;
705 if ((ironman_downward && (m_idx <= 0)) || (dun_level <= d_info[dungeon_type].mindepth))
708 if (see_m) msg_format("%^sは床を突き破って沈んでいく。", m_name);
710 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
712 if (m_idx <= 0) /* To player */
716 dungeon_type = ironman_downward ? DUNGEON_ANGBAND : p_ptr->recall_dungeon;
717 p_ptr->oldpy = p_ptr->y;
718 p_ptr->oldpx = p_ptr->x;
721 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
723 if (autosave_l) do_cmd_save_game(TRUE);
727 dun_level = d_info[dungeon_type].mindepth;
728 prepare_change_floor_mode(CFM_RAND_PLACE);
732 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
736 p_ptr->leaving = TRUE;
741 else if (quest_number(dun_level) || (dun_level >= d_info[dungeon_type].maxdepth))
744 if (see_m) msg_format("%^sは天井を突き破って宙へ浮いていく。", m_name);
746 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
750 if (m_idx <= 0) /* To player */
752 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
754 if (autosave_l) do_cmd_save_game(TRUE);
756 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
761 p_ptr->inside_quest = 0;
762 p_ptr->leaving = TRUE;
768 if (see_m) msg_format("%^sは天井を突き破って宙へ浮いていく。", m_name);
770 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
774 if (m_idx <= 0) /* To player */
776 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
778 if (autosave_l) do_cmd_save_game(TRUE);
780 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
783 p_ptr->leaving = TRUE;
789 if (see_m) msg_format("%^sは床を突き破って沈んでいく。", m_name);
791 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
794 if (m_idx <= 0) /* To player */
796 /* Never reach this code on the surface */
797 /* if (!dun_level) dungeon_type = p_ptr->recall_dungeon; */
799 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
801 if (autosave_l) do_cmd_save_game(TRUE);
803 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
806 p_ptr->leaving = TRUE;
810 /* Monster level teleportation is simple deleting now */
813 monster_type *m_ptr = &m_list[m_idx];
815 /* Check for quest completion */
816 check_quest_completion(m_ptr);
818 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
822 monster_desc(m2_name, m_ptr, MD_INDEF_VISIBLE);
823 do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_TELE_LEVEL, m2_name);
826 delete_monster_idx(m_idx);
830 sound(SOUND_TPLEVEL);
835 * @brief これまでに入ったダンジョンの一覧を表示する
836 * @param note ダンジョンに施す処理記述
841 int choose_dungeon(cptr note, int y, int x)
847 /* Hack -- No need to choose dungeon in some case */
848 if (lite_town || vanilla_town || ironman_downward)
850 if (max_dlv[DUNGEON_ANGBAND]) return DUNGEON_ANGBAND;
853 msg_format(_("まだ%sに入ったことはない。", "You haven't entered %s yet."), d_name + d_info[DUNGEON_ANGBAND].name);
859 /* Allocate the "dun" array */
860 C_MAKE(dun, max_d_idx, s16b);
863 for(i = 1; i < max_d_idx; i++)
868 if (!d_info[i].maxdepth) continue;
869 if (!max_dlv[i]) continue;
870 if (d_info[i].final_guardian)
872 if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
874 else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
876 sprintf(buf,_(" %c) %c%-12s : 最大 %d 階", " %c) %c%-16s : Max level %d"),
877 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
878 prt(buf, y + num, x);
884 prt(_(" 選べるダンジョンがない。", " No dungeon is available."), y, x);
887 prt(format(_("どのダンジョン%sしますか:", "Which dungeon do you %s?: "), note), 0, 0);
891 if ((i == ESCAPE) || !num)
893 /* Free the "dun" array */
894 C_KILL(dun, max_d_idx, s16b);
899 if (i >= 'a' && i <('a'+num))
901 select_dungeon = dun[i-'a'];
908 /* Free the "dun" array */
909 C_KILL(dun, max_d_idx, s16b);
911 return select_dungeon;
916 * @brief プレイヤーの帰還発動及び中止処理 /
917 * Recall the player to town or dungeon
918 * @param turns 発動までのターン数
921 bool recall_player(int turns)
924 * TODO: Recall the player to the last
925 * visited town when in the wilderness
929 if (p_ptr->inside_arena || ironman_downward)
931 msg_print(_("何も起こらなかった。", "Nothing happens."));
935 if (dun_level && (max_dlv[dungeon_type] > dun_level) && !p_ptr->inside_quest && !p_ptr->word_recall)
937 if (get_check(_("ここは最深到達階より浅い階です。この階に戻って来ますか? ", "Reset recall depth? ")))
939 max_dlv[dungeon_type] = dun_level;
941 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, _("帰還のときに", "when recall from dungeon"));
945 if (!p_ptr->word_recall)
950 select_dungeon = choose_dungeon(_("に帰還", "recall"), 2, 14);
951 if (!select_dungeon) return FALSE;
952 p_ptr->recall_dungeon = select_dungeon;
954 p_ptr->word_recall = turns;
955 msg_print(_("回りの大気が張りつめてきた...", "The air about you becomes charged..."));
956 p_ptr->redraw |= (PR_STATUS);
960 p_ptr->word_recall = 0;
961 msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
962 p_ptr->redraw |= (PR_STATUS);
971 bool word_of_recall(void)
973 return(recall_player(randint0(21) + 15));
978 * @return リセット処理が実際に行われたらTRUEを返す
980 bool reset_recall(void)
982 int select_dungeon, dummy = 0;
986 select_dungeon = choose_dungeon(_("をセット", "reset"), 2, 14);
989 if (ironman_downward)
991 msg_print(_("何も起こらなかった。", "Nothing happens."));
995 if (!select_dungeon) return FALSE;
997 sprintf(ppp, _("何階にセットしますか (%d-%d):", "Reset to which level (%d-%d): "), d_info[select_dungeon].mindepth, max_dlv[select_dungeon]);
1000 sprintf(tmp_val, "%d", MAX(dun_level, 1));
1002 /* Ask for a level */
1003 if (get_string(ppp, tmp_val, 10))
1005 /* Extract request */
1006 dummy = atoi(tmp_val);
1009 if (dummy < 1) dummy = 1;
1012 if (dummy > max_dlv[select_dungeon]) dummy = max_dlv[select_dungeon];
1013 if (dummy < d_info[select_dungeon].mindepth) dummy = d_info[select_dungeon].mindepth;
1015 max_dlv[select_dungeon] = dummy;
1017 if (record_maxdepth)
1018 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, _("フロア・リセットで", "using a scroll of reset recall"));
1019 /* Accept request */
1021 msg_format("%sの帰還レベルを %d 階にセット。", d_name+d_info[select_dungeon].name, dummy, dummy * 50);
1023 msg_format("Recall depth set to level %d (%d').", dummy, dummy * 50);
1036 * @brief プレイヤーの装備劣化処理 /
1037 * Apply disenchantment to the player's stuff
1038 * @param mode 最下位ビットが1ならば劣化処理が若干低減される
1039 * @return 劣化処理に関するメッセージが発せられた場合はTRUEを返す /
1040 * Return "TRUE" if the player notices anything
1042 bool apply_disenchant(int mode)
1046 char o_name[MAX_NLEN];
1047 int to_h, to_d, to_a, pval;
1049 /* Pick a random slot */
1050 switch (randint1(8))
1052 case 1: t = INVEN_RARM; break;
1053 case 2: t = INVEN_LARM; break;
1054 case 3: t = INVEN_BOW; break;
1055 case 4: t = INVEN_BODY; break;
1056 case 5: t = INVEN_OUTER; break;
1057 case 6: t = INVEN_HEAD; break;
1058 case 7: t = INVEN_HANDS; break;
1059 case 8: t = INVEN_FEET; break;
1063 o_ptr = &inventory[t];
1065 /* No item, nothing happens */
1066 if (!o_ptr->k_idx) return (FALSE);
1068 /* Disenchant equipments only -- No disenchant on monster ball */
1069 if (!object_is_weapon_armour_ammo(o_ptr))
1072 /* Nothing to disenchant */
1073 if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0) && (o_ptr->pval <= 1))
1075 /* Nothing to notice */
1080 /* Describe the object */
1081 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1084 /* Artifacts have 71% chance to resist */
1085 if (object_is_artifact(o_ptr) && (randint0(100) < 71))
1089 msg_format("%s(%c)は劣化を跳ね返した!",o_name, index_to_label(t) );
1091 msg_format("Your %s (%c) resist%s disenchantment!",
1092 o_name, index_to_label(t),
1093 ((o_ptr->number != 1) ? "" : "s"));
1102 /* Memorize old value */
1108 /* Disenchant tohit */
1109 if (o_ptr->to_h > 0) o_ptr->to_h--;
1110 if ((o_ptr->to_h > 5) && (randint0(100) < 20)) o_ptr->to_h--;
1112 /* Disenchant todam */
1113 if (o_ptr->to_d > 0) o_ptr->to_d--;
1114 if ((o_ptr->to_d > 5) && (randint0(100) < 20)) o_ptr->to_d--;
1116 /* Disenchant toac */
1117 if (o_ptr->to_a > 0) o_ptr->to_a--;
1118 if ((o_ptr->to_a > 5) && (randint0(100) < 20)) o_ptr->to_a--;
1120 /* Disenchant pval (occasionally) */
1121 /* Unless called from wild_magic() */
1122 if ((o_ptr->pval > 1) && one_in_(13) && !(mode & 0x01)) o_ptr->pval--;
1124 if ((to_h != o_ptr->to_h) || (to_d != o_ptr->to_d) ||
1125 (to_a != o_ptr->to_a) || (pval != o_ptr->pval))
1129 msg_format("%s(%c)は劣化してしまった!",
1130 o_name, index_to_label(t) );
1132 msg_format("Your %s (%c) %s disenchanted!",
1133 o_name, index_to_label(t),
1134 ((o_ptr->number != 1) ? "were" : "was"));
1137 chg_virtue(V_HARMONY, 1);
1138 chg_virtue(V_ENCHANT, -2);
1140 /* Recalculate bonuses */
1141 p_ptr->update |= (PU_BONUS);
1144 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
1154 * @brief プレイヤーの突然変異処理
1157 void mutate_player(void)
1159 base_status max1, cur1, max2, cur2;
1162 /* Pick a pair of stats */
1164 for (jj = ii; jj == ii; jj = randint0(6)) /* loop */;
1166 max1 = p_ptr->stat_max[ii];
1167 cur1 = p_ptr->stat_cur[ii];
1168 max2 = p_ptr->stat_max[jj];
1169 cur2 = p_ptr->stat_cur[jj];
1171 p_ptr->stat_max[ii] = max2;
1172 p_ptr->stat_cur[ii] = cur2;
1173 p_ptr->stat_max[jj] = max1;
1174 p_ptr->stat_cur[jj] = cur1;
1178 if(p_ptr->stat_max[i] > p_ptr->stat_max_max[i]) p_ptr->stat_max[i] = p_ptr->stat_max_max[i];
1179 if(p_ptr->stat_cur[i] > p_ptr->stat_max_max[i]) p_ptr->stat_cur[i] = p_ptr->stat_max_max[i];
1182 p_ptr->update |= (PU_BONUS);
1187 * @brief プレイヤーの因果混乱処理 / Apply Nexus
1188 * @param m_ptr 因果混乱をプレイヤーに与えたモンスターの情報参照ポインタ
1191 void apply_nexus(monster_type *m_ptr)
1193 switch (randint1(7))
1195 case 1: case 2: case 3:
1197 teleport_player(200, TELEPORT_PASSIVE);
1203 teleport_player_to(m_ptr->fy, m_ptr->fx, TELEPORT_PASSIVE);
1209 if (randint0(100) < p_ptr->skill_sav)
1211 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
1215 /* Teleport Level */
1222 if (randint0(100) < p_ptr->skill_sav)
1224 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
1228 msg_print(_("体がねじれ始めた...", "Your body starts to scramble..."));
1237 * @brief 寿命つき光源の燃素追加処理 /
1238 * Charge a lite (torch or latern)
1241 void phlogiston(void)
1244 object_type * o_ptr = &inventory[INVEN_LITE];
1247 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_LANTERN))
1249 max_flog = FUEL_LAMP;
1253 else if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
1255 max_flog = FUEL_TORCH;
1258 /* No torch to refill */
1261 msg_print(_("燃素を消費するアイテムを装備していません。", "You are not wielding anything which uses phlogiston."));
1265 if (o_ptr->xtra4 >= max_flog)
1267 msg_print(_("このアイテムにはこれ以上燃素を補充できません。", "No more phlogiston can be put in this item."));
1272 o_ptr->xtra4 += (max_flog / 2);
1275 msg_print(_("照明用アイテムに燃素を補充した。", "You add phlogiston to your light item."));
1278 if (o_ptr->xtra4 >= max_flog)
1280 o_ptr->xtra4 = max_flog;
1281 msg_print(_("照明用アイテムは満タンになった。", "Your light item is full."));
1284 /* Recalculate torch */
1285 p_ptr->update |= (PU_TORCH);
1290 * @brief 武器へのエゴ付加処理 /
1291 * Brand the current weapon
1292 * @param brand_type エゴ化ID(e_info.txtとは連動していない)
1295 void brand_weapon(int brand_type)
1302 /* Assume enchant weapon */
1303 item_tester_hook = object_allow_enchant_melee_weapon;
1304 item_tester_no_ryoute = TRUE;
1307 q = _("どの武器を強化しますか? ", "Enchant which weapon? ");
1308 s = _("強化できる武器がない。", "You have nothing to enchant.");
1310 if (!get_item(&item, q, s, (USE_EQUIP))) return;
1312 /* Get the item (in the pack) */
1315 o_ptr = &inventory[item];
1318 /* Get the item (on the floor) */
1321 o_ptr = &o_list[0 - item];
1325 /* you can never modify artifacts / ego-items */
1326 /* you can never modify cursed items */
1327 /* TY: You _can_ modify broken items (if you're silly enough) */
1328 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
1329 !object_is_cursed(o_ptr) &&
1330 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) &&
1331 !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) &&
1332 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)))
1336 /* Let's get the name before it is changed... */
1337 char o_name[MAX_NLEN];
1338 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1343 if (o_ptr->tval == TV_SWORD)
1345 act = _("は鋭さを増した!", "becomes very sharp!");
1347 o_ptr->name2 = EGO_SHARPNESS;
1348 o_ptr->pval = m_bonus(5, dun_level) + 1;
1350 if ((o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2))
1355 act = _("は破壊力を増した!", "seems very powerful.");
1356 o_ptr->name2 = EGO_EARTHQUAKES;
1357 o_ptr->pval = m_bonus(3, dun_level);
1361 act = _("は人間の血を求めている!", "seems to be looking for humans!");
1362 o_ptr->name2 = EGO_KILL_HUMAN;
1365 act = _("は電撃に覆われた!", "covered with lightning!");
1366 o_ptr->name2 = EGO_BRAND_ELEC;
1369 act = _("は酸に覆われた!", "coated with acid!");
1370 o_ptr->name2 = EGO_BRAND_ACID;
1373 act = _("は邪悪なる怪物を求めている!", "seems to be looking for evil monsters!");
1374 o_ptr->name2 = EGO_KILL_EVIL;
1377 act = _("は異世界の住人の肉体を求めている!", "seems to be looking for demons!");
1378 o_ptr->name2 = EGO_KILL_DEMON;
1381 act = _("は屍を求めている!", "seems to be looking for undead!");
1382 o_ptr->name2 = EGO_KILL_UNDEAD;
1385 act = _("は動物の血を求めている!", "seems to be looking for animals!");
1386 o_ptr->name2 = EGO_KILL_ANIMAL;
1389 act = _("はドラゴンの血を求めている!", "seems to be looking for dragons!");
1390 o_ptr->name2 = EGO_KILL_DRAGON;
1393 act = _("はトロルの血を求めている!", "seems to be looking for troll!s");
1394 o_ptr->name2 = EGO_KILL_TROLL;
1397 act = _("はオークの血を求めている!", "seems to be looking for orcs!");
1398 o_ptr->name2 = EGO_KILL_ORC;
1401 act = _("は巨人の血を求めている!", "seems to be looking for giants!");
1402 o_ptr->name2 = EGO_KILL_GIANT;
1405 act = _("は非常に不安定になったようだ。", "seems very unstable now.");
1406 o_ptr->name2 = EGO_TRUMP;
1407 o_ptr->pval = randint1(2);
1410 act = _("は血を求めている!", "thirsts for blood!");
1411 o_ptr->name2 = EGO_VAMPIRIC;
1414 act = _("は毒に覆われた。", "is coated with poison.");
1415 o_ptr->name2 = EGO_BRAND_POIS;
1418 act = _("は純ログルスに飲み込まれた。", "is engulfed in raw Logrus!");
1419 o_ptr->name2 = EGO_CHAOTIC;
1422 act = _("は炎のシールドに覆われた!", "is covered in a fiery shield!");
1423 o_ptr->name2 = EGO_BRAND_FIRE;
1426 act = _("は深く冷たいブルーに輝いた!", "glows deep, icy blue!");
1427 o_ptr->name2 = EGO_BRAND_COLD;
1431 msg_format(_("あなたの%s%s", "Your %s %s"), o_name, act);
1432 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
1434 o_ptr->discount = 99;
1435 chg_virtue(V_ENCHANT, 2);
1439 if (flush_failure) flush();
1441 msg_print(_("属性付加に失敗した。", "The Branding failed."));
1442 chg_virtue(V_ENCHANT, -2);
1449 * @brief 虚無招来によるフロア中の全壁除去処理 /
1450 * Vanish all walls in this floor
1451 * @return 実際に処理が反映された場合TRUE
1453 static bool vanish_dungeon(void)
1457 feature_type *f_ptr;
1458 monster_type *m_ptr;
1461 /* Prevent vasishing of quest levels and town */
1462 if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1467 /* Scan all normal grids */
1468 for (y = 1; y < cur_hgt - 1; y++)
1470 for (x = 1; x < cur_wid - 1; x++)
1472 c_ptr = &cave[y][x];
1474 /* Seeing true feature code (ignore mimic) */
1475 f_ptr = &f_info[c_ptr->feat];
1477 /* Lose room and vault */
1478 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1480 m_ptr = &m_list[c_ptr->m_idx];
1483 if (c_ptr->m_idx && MON_CSLEEP(m_ptr))
1485 /* Reset sleep counter */
1486 (void)set_monster_csleep(c_ptr->m_idx, 0);
1488 /* Notice the "waking up" */
1491 /* Acquire the monster name */
1492 monster_desc(m_name, m_ptr, 0);
1494 /* Dump a message */
1495 msg_format(_("%^sが目を覚ました。", "%^s wakes up."), m_name);
1499 /* Process all walls, doors and patterns */
1500 if (have_flag(f_ptr->flags, FF_HURT_DISI)) cave_alter_feat(y, x, FF_HURT_DISI);
1504 /* Special boundary walls -- Top and bottom */
1505 for (x = 0; x < cur_wid; x++)
1507 c_ptr = &cave[0][x];
1508 f_ptr = &f_info[c_ptr->mimic];
1510 /* Lose room and vault */
1511 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1513 /* Set boundary mimic if needed */
1514 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1516 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1518 /* Check for change to boring grid */
1519 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1522 c_ptr = &cave[cur_hgt - 1][x];
1523 f_ptr = &f_info[c_ptr->mimic];
1525 /* Lose room and vault */
1526 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1528 /* Set boundary mimic if needed */
1529 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1531 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1533 /* Check for change to boring grid */
1534 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1538 /* Special boundary walls -- Left and right */
1539 for (y = 1; y < (cur_hgt - 1); y++)
1541 c_ptr = &cave[y][0];
1542 f_ptr = &f_info[c_ptr->mimic];
1544 /* Lose room and vault */
1545 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1547 /* Set boundary mimic if needed */
1548 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1550 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1552 /* Check for change to boring grid */
1553 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1556 c_ptr = &cave[y][cur_wid - 1];
1557 f_ptr = &f_info[c_ptr->mimic];
1559 /* Lose room and vault */
1560 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1562 /* Set boundary mimic if needed */
1563 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1565 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1567 /* Check for change to boring grid */
1568 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1572 /* Mega-Hack -- Forget the view and lite */
1573 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
1576 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
1578 /* Update the monsters */
1579 p_ptr->update |= (PU_MONSTERS);
1582 p_ptr->redraw |= (PR_MAP);
1585 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1594 void call_the_(void)
1598 bool do_call = TRUE;
1600 for (i = 0; i < 9; i++)
1602 c_ptr = &cave[p_ptr->y + ddy_ddd[i]][p_ptr->x + ddx_ddd[i]];
1604 if (!cave_have_flag_grid(c_ptr, FF_PROJECT))
1606 if (!c_ptr->mimic || !have_flag(f_info[c_ptr->mimic].flags, FF_PROJECT) ||
1607 !permanent_wall(&f_info[c_ptr->feat]))
1617 for (i = 1; i < 10; i++)
1619 if (i - 5) fire_ball(GF_ROCKET, i, 175, 2);
1622 for (i = 1; i < 10; i++)
1624 if (i - 5) fire_ball(GF_MANA, i, 175, 3);
1627 for (i = 1; i < 10; i++)
1629 if (i - 5) fire_ball(GF_NUKE, i, 175, 4);
1633 /* Prevent destruction of quest levels and town */
1634 else if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1636 msg_print(_("地面が揺れた。", "The ground trembles."));
1642 msg_format("あなたは%sを壁に近すぎる場所で唱えてしまった!",
1643 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "祈り" : "呪文"));
1644 msg_print("大きな爆発音があった!");
1646 msg_format("You %s the %s too close to a wall!",
1647 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1648 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
1649 msg_print("There is a loud explosion!");
1654 if (!vanish_dungeon()) msg_print(_("ダンジョンは一瞬静まり返った。", "The dungeon silences a moment."));
1658 if (destroy_area(p_ptr->y, p_ptr->x, 15 + p_ptr->lev + randint0(11), FALSE))
1659 msg_print(_("ダンジョンが崩壊した...", "The dungeon collapses..."));
1661 msg_print(_("ダンジョンは大きく揺れた。", "The dungeon trembles."));
1664 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), _("自殺的な虚無招来", "a suicidal Call the Void"), -1);
1670 * @brief アイテム引き寄せ処理 /
1671 * Fetch an item (teleport it right underneath the caster)
1672 * @param dir 魔法の発動方向
1674 * @param require_los 射線の通りを要求するならばTRUE
1677 void fetch(int dir, int wgt, bool require_los)
1682 char o_name[MAX_NLEN];
1684 /* Check to see if an object is already there */
1685 if (cave[p_ptr->y][p_ptr->x].o_idx)
1687 msg_print(_("自分の足の下にある物は取れません。", "You can't fetch when you're already standing on something."));
1692 if (dir == 5 && target_okay())
1697 if (distance(p_ptr->y, p_ptr->x, ty, tx) > MAX_RANGE)
1699 msg_print(_("そんなに遠くにある物は取れません!", "You can't fetch something that far away!"));
1703 c_ptr = &cave[ty][tx];
1705 /* We need an item to fetch */
1708 msg_print(_("そこには何もありません。", "There is no object at this place."));
1712 /* No fetching from vault */
1713 if (c_ptr->info & CAVE_ICKY)
1715 msg_print(_("アイテムがコントロールを外れて落ちた。", "The item slips from your control."));
1719 /* We need to see the item */
1722 if (!player_has_los_bold(ty, tx))
1724 msg_print(_("そこはあなたの視界に入っていません。", "You have no direct line of sight to that location."));
1727 else if (!projectable(p_ptr->y, p_ptr->x, ty, tx))
1729 msg_print(_("そこは壁の向こうです。", "You have no direct line of sight to that location."));
1736 /* Use a direction */
1737 ty = p_ptr->y; /* Where to drop the item */
1744 c_ptr = &cave[ty][tx];
1746 if ((distance(p_ptr->y, p_ptr->x, ty, tx) > MAX_RANGE) ||
1747 !cave_have_flag_bold(ty, tx, FF_PROJECT)) return;
1749 while (!c_ptr->o_idx);
1752 o_ptr = &o_list[c_ptr->o_idx];
1754 if (o_ptr->weight > wgt)
1756 /* Too heavy to 'fetch' */
1757 msg_print(_("そのアイテムは重過ぎます。", "The object is too heavy."));
1762 c_ptr->o_idx = o_ptr->next_o_idx;
1763 cave[p_ptr->y][p_ptr->x].o_idx = i; /* 'move' it */
1764 o_ptr->next_o_idx = 0;
1765 o_ptr->iy = (byte)p_ptr->y;
1766 o_ptr->ix = (byte)p_ptr->x;
1768 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1769 msg_format(_("%^sがあなたの足元に飛んできた。", "%^s flies through the air to your feet."), o_name);
1771 note_spot(p_ptr->y, p_ptr->x);
1772 p_ptr->redraw |= PR_MAP;
1779 void alter_reality(void)
1781 /* Ironman option */
1782 if (p_ptr->inside_arena || ironman_downward)
1784 msg_print(_("何も起こらなかった。", "Nothing happens."));
1788 if (!p_ptr->alter_reality)
1790 int turns = randint0(21) + 15;
1792 p_ptr->alter_reality = turns;
1793 msg_print(_("回りの景色が変わり始めた...", "The view around you begins to change..."));
1795 p_ptr->redraw |= (PR_STATUS);
1799 p_ptr->alter_reality = 0;
1800 msg_print(_("景色が元に戻った...", "The view around you got back..."));
1801 p_ptr->redraw |= (PR_STATUS);
1808 * @brief 守りのルーン設置処理 /
1809 * Leave a "glyph of warding" which prevents monster movement
1810 * @return 実際に設置が行われた場合TRUEを返す
1812 bool warding_glyph(void)
1815 if (!cave_clean_bold(p_ptr->y, p_ptr->x))
1817 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
1821 /* Create a glyph */
1822 cave[p_ptr->y][p_ptr->x].info |= CAVE_OBJECT;
1823 cave[p_ptr->y][p_ptr->x].mimic = feat_glyph;
1826 note_spot(p_ptr->y, p_ptr->x);
1829 lite_spot(p_ptr->y, p_ptr->x);
1836 * @return 実際に設置が行われた場合TRUEを返す
1838 bool place_mirror(void)
1841 if (!cave_clean_bold(p_ptr->y, p_ptr->x))
1843 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
1847 /* Create a mirror */
1848 cave[p_ptr->y][p_ptr->x].info |= CAVE_OBJECT;
1849 cave[p_ptr->y][p_ptr->x].mimic = feat_mirror;
1851 /* Turn on the light */
1852 cave[p_ptr->y][p_ptr->x].info |= CAVE_GLOW;
1855 note_spot(p_ptr->y, p_ptr->x);
1858 lite_spot(p_ptr->y, p_ptr->x);
1860 update_local_illumination(p_ptr->y, p_ptr->x);
1867 * @brief 爆発のルーン設置処理 /
1868 * Leave an "explosive rune" which prevents monster movement
1869 * @return 実際に設置が行われた場合TRUEを返す
1871 bool explosive_rune(void)
1874 if (!cave_clean_bold(p_ptr->y, p_ptr->x))
1876 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
1880 /* Create a glyph */
1881 cave[p_ptr->y][p_ptr->x].info |= CAVE_OBJECT;
1882 cave[p_ptr->y][p_ptr->x].mimic = feat_explosive_rune;
1885 note_spot(p_ptr->y, p_ptr->x);
1888 lite_spot(p_ptr->y, p_ptr->x);
1895 * @brief 全所持アイテム鑑定処理 /
1896 * Identify everything being carried.
1897 * Done by a potion of "self knowledge".
1900 void identify_pack(void)
1904 /* Simply identify and know every item */
1905 for (i = 0; i < INVEN_TOTAL; i++)
1907 object_type *o_ptr = &inventory[i];
1909 /* Skip non-objects */
1910 if (!o_ptr->k_idx) continue;
1913 identify_item(o_ptr);
1915 /* Auto-inscription */
1916 autopick_alter_item(i, FALSE);
1922 * @brief 装備強化処理の失敗率定数(千分率) /
1923 * Used by the "enchant" function (chance of failure)
1924 * (modified for Zangband, we need better stuff there...) -- TY
1927 static int enchant_table[16] =
1929 0, 10, 50, 100, 200,
1930 300, 400, 500, 650, 800,
1931 950, 987, 993, 995, 998,
1938 * Removes curses from items in inventory
1939 * @param all 軽い呪いまでの解除ならば0
1940 * @return 解呪されたアイテムの数
1943 * Note that Items which are "Perma-Cursed" (The One Ring,
1944 * The Crown of Morgoth) can NEVER be uncursed.
1946 * Note that if "all" is FALSE, then Items which are
1947 * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
1948 * will not be uncursed.
1951 static int remove_curse_aux(int all)
1955 /* Attempt to uncurse items being worn */
1956 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1958 object_type *o_ptr = &inventory[i];
1960 /* Skip non-objects */
1961 if (!o_ptr->k_idx) continue;
1963 /* Uncursed already */
1964 if (!object_is_cursed(o_ptr)) continue;
1966 /* Heavily Cursed Items need a special spell */
1967 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
1969 /* Perma-Cursed Items can NEVER be uncursed */
1970 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
1973 o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
1978 o_ptr->curse_flags = 0L;
1980 /* Hack -- Assume felt */
1981 o_ptr->ident |= (IDENT_SENSE);
1984 o_ptr->feeling = FEEL_NONE;
1986 /* Recalculate the bonuses */
1987 p_ptr->update |= (PU_BONUS);
1990 p_ptr->window |= (PW_EQUIP);
1992 /* Count the uncursings */
1996 /* Return "something uncursed" */
2002 * @brief 装備の軽い呪い解呪処理 /
2003 * Remove most curses
2004 * @return 解呪に成功した装備数
2006 int remove_curse(void)
2008 return (remove_curse_aux(FALSE));
2012 * @brief 装備の重い呪い解呪処理 /
2014 * @return 解呪に成功した装備数
2016 int remove_all_curse(void)
2018 return (remove_curse_aux(TRUE));
2023 * @brief アイテムの価値に応じた錬金術処理 /
2024 * Turns an object into gold, gain some of its value in a shop
2025 * @return 処理が実際に行われたらTRUEを返す
2030 item_number old_number;
2034 char o_name[MAX_NLEN];
2035 char out_val[MAX_NLEN+40];
2039 /* Hack -- force destruction */
2040 if (command_arg > 0) force = TRUE;
2043 q = _("どのアイテムを金に変えますか?", "Turn which item to gold? ");
2044 s = _("金に変えられる物がありません。", "You have nothing to turn to gold.");
2046 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
2048 /* Get the item (in the pack) */
2051 o_ptr = &inventory[item];
2054 /* Get the item (on the floor) */
2057 o_ptr = &o_list[0 - item];
2061 /* See how many items */
2062 if (o_ptr->number > 1)
2064 /* Get a quantity */
2065 amt = get_quantity(NULL, o_ptr->number);
2067 /* Allow user abort */
2068 if (amt <= 0) return FALSE;
2072 /* Describe the object */
2073 old_number = o_ptr->number;
2074 o_ptr->number = amt;
2075 object_desc(o_name, o_ptr, 0);
2076 o_ptr->number = old_number;
2078 /* Verify unless quantity given */
2081 if (confirm_destroy || (object_value(o_ptr) > 0))
2083 /* Make a verification */
2084 sprintf(out_val, _("本当に%sを金に変えますか?", "Really turn %s to gold? "), o_name);
2085 if (!get_check(out_val)) return FALSE;
2089 /* Artifacts cannot be destroyed */
2090 if (!can_player_destroy_object(o_ptr))
2093 msg_format(_("%sを金に変えることに失敗した。", "You fail to turn %s to gold!"), o_name);
2099 price = object_value_real(o_ptr);
2104 msg_format(_("%sをニセの金に変えた。", "You turn %s to fool's gold."), o_name);
2110 if (amt > 1) price *= amt;
2112 if (price > 30000) price = 30000;
2113 msg_format(_("%sを$%d の金に変えた。", "You turn %s to %ld coins worth of gold."), o_name, price);
2118 p_ptr->redraw |= (PR_GOLD);
2121 p_ptr->window |= (PW_PLAYER);
2125 /* Eliminate the item (from the pack) */
2128 inven_item_increase(item, -amt);
2129 inven_item_describe(item);
2130 inven_item_optimize(item);
2133 /* Eliminate the item (from the floor) */
2136 floor_item_increase(0 - item, -amt);
2137 floor_item_describe(0 - item);
2138 floor_item_optimize(0 - item);
2146 * @brief 呪いの打ち破り処理 /
2147 * Break the curse of an item
2148 * @param o_ptr 呪い装備情報の参照ポインタ
2151 static void break_curse(object_type *o_ptr)
2153 if (object_is_cursed(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
2155 msg_print(_("かけられていた呪いが打ち破られた!", "The curse is broken!"));
2157 o_ptr->curse_flags = 0L;
2158 o_ptr->ident |= (IDENT_SENSE);
2159 o_ptr->feeling = FEEL_NONE;
2166 * Enchants a plus onto an item. -RAK-
2167 * @param o_ptr 強化するアイテムの参照ポインタ
2169 * @param eflag 強化オプション(命中/ダメージ/AC)
2170 * @return 強化に成功した場合TRUEを返す
2173 * Revamped! Now takes item pointer, number of times to try enchanting,
2174 * and a flag of what to try enchanting. Artifacts resist enchantment
2175 * some of the time, and successful enchantment to at least +0 might
2176 * break a curse on the item. -CFT-
2178 * Note that an item can technically be enchanted all the way to +15 if
2179 * you wait a very, very, long time. Going from +9 to +10 only works
2180 * about 5% of the time, and from +10 to +11 only about 1% of the time.
2182 * Note that this function can now be used on "piles" of items, and
2183 * the larger the pile, the lower the chance of success.
2186 bool enchant(object_type *o_ptr, int n, int eflag)
2188 int i, chance, prob;
2190 bool a = object_is_artifact(o_ptr);
2191 bool force = (eflag & ENCH_FORCE);
2194 /* Large piles resist enchantment */
2195 prob = o_ptr->number * 100;
2197 /* Missiles are easy to enchant */
2198 if ((o_ptr->tval == TV_BOLT) ||
2199 (o_ptr->tval == TV_ARROW) ||
2200 (o_ptr->tval == TV_SHOT))
2206 for (i = 0; i < n; i++)
2208 /* Hack -- Roll for pile resistance */
2209 if (!force && randint0(prob) >= 100) continue;
2211 /* Enchant to hit */
2212 if (eflag & ENCH_TOHIT)
2214 if (o_ptr->to_h < 0) chance = 0;
2215 else if (o_ptr->to_h > 15) chance = 1000;
2216 else chance = enchant_table[o_ptr->to_h];
2218 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2223 /* only when you get it above -1 -CFT */
2224 if (o_ptr->to_h >= 0)
2229 /* Enchant to damage */
2230 if (eflag & ENCH_TODAM)
2232 if (o_ptr->to_d < 0) chance = 0;
2233 else if (o_ptr->to_d > 15) chance = 1000;
2234 else chance = enchant_table[o_ptr->to_d];
2236 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2241 /* only when you get it above -1 -CFT */
2242 if (o_ptr->to_d >= 0)
2247 /* Enchant to armor class */
2248 if (eflag & ENCH_TOAC)
2250 if (o_ptr->to_a < 0) chance = 0;
2251 else if (o_ptr->to_a > 15) chance = 1000;
2252 else chance = enchant_table[o_ptr->to_a];
2254 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2259 /* only when you get it above -1 -CFT */
2260 if (o_ptr->to_a >= 0)
2267 if (!res) return (FALSE);
2269 /* Recalculate bonuses */
2270 p_ptr->update |= (PU_BONUS);
2272 /* Combine / Reorder the pack (later) */
2273 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2276 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2286 * @brief 装備修正強化処理のメインルーチン /
2287 * Enchant an item (in the inventory or on the floor)
2288 * @param num_hit 命中修正量
2289 * @param num_dam ダメージ修正量
2290 * @param num_ac AC修正量
2291 * @return 強化に成功した場合TRUEを返す
2293 * Note that "num_ac" requires armour, else weapon
2294 * Returns TRUE if attempted, FALSE if cancelled
2296 bool enchant_spell(int num_hit, int num_dam, int num_ac)
2301 char o_name[MAX_NLEN];
2305 /* Assume enchant weapon */
2306 item_tester_hook = object_allow_enchant_weapon;
2307 item_tester_no_ryoute = TRUE;
2309 /* Enchant armor if requested */
2310 if (num_ac) item_tester_hook = object_is_armour;
2313 q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
2314 s = _("強化できるアイテムがない。", "You have nothing to enchant.");
2316 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2318 /* Get the item (in the pack) */
2321 o_ptr = &inventory[item];
2324 /* Get the item (on the floor) */
2327 o_ptr = &o_list[0 - item];
2332 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2336 msg_format("%s は明るく輝いた!",
2339 msg_format("%s %s glow%s brightly!",
2340 ((item >= 0) ? "Your" : "The"), o_name,
2341 ((o_ptr->number > 1) ? "" : "s"));
2346 if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
2347 if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
2348 if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
2354 if (flush_failure) flush();
2357 msg_print(_("強化に失敗した。", "The enchantment failed."));
2359 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2362 chg_virtue(V_ENCHANT, 1);
2366 /* Something happened */
2372 * @brief アイテムが並の価値のアイテムかどうか判定する /
2373 * Check if an object is nameless weapon or armour
2374 * @param o_ptr 判定するアイテムの情報参照ポインタ
2375 * @return 並ならばTRUEを返す
2377 static bool item_tester_hook_nameless_weapon_armour(object_type *o_ptr)
2379 /* Require weapon or armour */
2380 if (!object_is_weapon_armour_ammo(o_ptr)) return FALSE;
2382 /* Require nameless object if the object is well known */
2383 if (object_is_known(o_ptr) && !object_is_nameless(o_ptr))
2390 * @brief アーティファクト生成の巻物処理 /
2391 * @return 生成が実際に試みられたらTRUEを返す
2393 bool artifact_scroll(void)
2398 char o_name[MAX_NLEN];
2402 item_tester_no_ryoute = TRUE;
2404 /* Enchant weapon/armour */
2405 item_tester_hook = item_tester_hook_nameless_weapon_armour;
2408 q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
2409 s = _("強化できるアイテムがない。", "You have nothing to enchant.");
2411 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2413 /* Get the item (in the pack) */
2416 o_ptr = &inventory[item];
2419 /* Get the item (on the floor) */
2422 o_ptr = &o_list[0 - item];
2427 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2431 msg_format("%s は眩い光を発した!",o_name);
2433 msg_format("%s %s radiate%s a blinding light!",
2434 ((item >= 0) ? "Your" : "The"), o_name,
2435 ((o_ptr->number > 1) ? "" : "s"));
2438 if (object_is_artifact(o_ptr))
2441 msg_format("%sは既に伝説のアイテムです!", o_name );
2443 msg_format("The %s %s already %s!",
2444 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2445 ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
2451 else if (object_is_ego(o_ptr))
2454 msg_format("%sは既に名のあるアイテムです!", o_name );
2456 msg_format("The %s %s already %s!",
2457 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2458 ((o_ptr->number > 1) ? "ego items" : "an ego item"));
2464 else if (o_ptr->xtra3)
2467 msg_format("%sは既に強化されています!", o_name );
2469 msg_format("The %s %s already %s!",
2470 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2471 ((o_ptr->number > 1) ? "customized items" : "a customized item"));
2477 if (o_ptr->number > 1)
2480 msg_print("複数のアイテムに魔法をかけるだけのエネルギーはありません!");
2481 msg_format("%d 個の%sが壊れた!",(o_ptr->number)-1, o_name);
2483 msg_print("Not enough enough energy to enchant more than one object!");
2484 msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
2489 inven_item_increase(item, 1-(o_ptr->number));
2493 floor_item_increase(0-item, 1-(o_ptr->number));
2496 okay = create_artifact(o_ptr, TRUE);
2503 if (flush_failure) flush();
2506 msg_print(_("強化に失敗した。", "The enchantment failed."));
2508 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2512 if (record_rand_art)
2515 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2516 do_cmd_write_nikki(NIKKI_ART_SCROLL, 0, o_name);
2518 chg_virtue(V_ENCHANT, 1);
2523 /* Something happened */
2530 * Identify an object
2531 * @param o_ptr 鑑定されるアイテムの情報参照ポインタ
2532 * @return 実際に鑑定できたらTRUEを返す
2534 bool identify_item(object_type *o_ptr)
2536 bool old_known = FALSE;
2537 char o_name[MAX_NLEN];
2540 object_desc(o_name, o_ptr, 0);
2542 if (o_ptr->ident & IDENT_KNOWN)
2545 if (!(o_ptr->ident & (IDENT_MENTAL)))
2547 if (object_is_artifact(o_ptr) || one_in_(5))
2548 chg_virtue(V_KNOWLEDGE, 1);
2551 /* Identify it fully */
2552 object_aware(o_ptr);
2553 object_known(o_ptr);
2555 /* Player touches it */
2556 o_ptr->marked |= OM_TOUCHED;
2558 /* Recalculate bonuses */
2559 p_ptr->update |= (PU_BONUS);
2561 /* Combine / Reorder the pack (later) */
2562 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2565 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2567 strcpy(record_o_name, o_name);
2571 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2573 if(record_fix_art && !old_known && object_is_fixed_artifact(o_ptr))
2574 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2575 if(record_rand_art && !old_known && o_ptr->art_name)
2576 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2582 * @brief アイテムが鑑定済みかを判定する /
2583 * @param o_ptr 判定するアイテムの情報参照ポインタ
2584 * @return 実際に鑑定済みならばTRUEを返す
2586 static bool item_tester_hook_identify(object_type *o_ptr)
2588 return (bool)!object_is_known(o_ptr);
2592 * @brief アイテムが鑑定済みの武器防具かを判定する /
2593 * @param o_ptr 判定するアイテムの情報参照ポインタ
2594 * @return 実際に鑑定済みならばTRUEを返す
2596 static bool item_tester_hook_identify_weapon_armour(object_type *o_ptr)
2598 if (object_is_known(o_ptr))
2600 return object_is_weapon_armour_ammo(o_ptr);
2604 * @brief アイテム鑑定のメインルーチン処理 /
2605 * Identify an object in the inventory (or on the floor)
2606 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2607 * @return 実際に鑑定を行ったならばTRUEを返す
2609 * This routine does *not* automatically combine objects.
2610 * Returns TRUE if something was identified, else FALSE.
2612 bool ident_spell(bool only_equip)
2616 char o_name[MAX_NLEN];
2620 item_tester_no_ryoute = TRUE;
2623 item_tester_hook = item_tester_hook_identify_weapon_armour;
2625 item_tester_hook = item_tester_hook_identify;
2629 q = _("どのアイテムを鑑定しますか? ", "Identify which item? ");
2634 item_tester_hook = object_is_weapon_armour_ammo;
2636 item_tester_hook = NULL;
2638 q = _("すべて鑑定済みです。 ", "All items are identified. ");
2642 s = _("鑑定するべきアイテムがない。", "You have nothing to identify.");
2644 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2646 /* Get the item (in the pack) */
2649 o_ptr = &inventory[item];
2652 /* Get the item (on the floor) */
2655 o_ptr = &o_list[0 - item];
2659 old_known = identify_item(o_ptr);
2662 object_desc(o_name, o_ptr, 0);
2665 if (item >= INVEN_RARM)
2667 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(item), o_name, index_to_label(item));
2671 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
2675 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
2678 /* Auto-inscription/destroy */
2679 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2681 /* Something happened */
2687 * @brief アイテム凡庸化のメインルーチン処理 /
2688 * Identify an object in the inventory (or on the floor)
2689 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2690 * @return 実際に凡庸化をを行ったならばTRUEを返す
2693 * Mundanify an object in the inventory (or on the floor)
2694 * This routine does *not* automatically combine objects.
2695 * Returns TRUE if something was mundanified, else FALSE.
2698 bool mundane_spell(bool only_equip)
2704 if (only_equip) item_tester_hook = object_is_weapon_armour_ammo;
2705 item_tester_no_ryoute = TRUE;
2708 q = _("どれを使いますか?", "Use which item? ");
2709 s = _("使えるものがありません。", "You have nothing you can use.");
2711 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2713 /* Get the item (in the pack) */
2716 o_ptr = &inventory[item];
2719 /* Get the item (on the floor) */
2722 o_ptr = &o_list[0 - item];
2726 msg_print(_("まばゆい閃光が走った!", "There is a bright flash of light!"));
2728 byte iy = o_ptr->iy; /* Y-position on map, or zero */
2729 byte ix = o_ptr->ix; /* X-position on map, or zero */
2730 s16b next_o_idx = o_ptr->next_o_idx; /* Next object in stack (if any) */
2731 byte marked = o_ptr->marked; /* Object is marked */
2732 s16b weight = o_ptr->number * o_ptr->weight;
2733 u16b inscription = o_ptr->inscription;
2736 object_prep(o_ptr, o_ptr->k_idx);
2740 o_ptr->next_o_idx = next_o_idx;
2741 o_ptr->marked = marked;
2742 o_ptr->inscription = inscription;
2743 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
2747 /* Something happened */
2752 * @brief アイテムが*鑑定*済みかを判定する /
2753 * @param o_ptr 判定するアイテムの情報参照ポインタ
2754 * @return 実際に鑑定済みならばTRUEを返す
2756 static bool item_tester_hook_identify_fully(object_type *o_ptr)
2758 return (bool)(!object_is_known(o_ptr) || !(o_ptr->ident & IDENT_MENTAL));
2762 * @brief アイテムが*鑑定*済みの武器防具かを判定する /
2763 * @param o_ptr 判定するアイテムの情報参照ポインタ
2764 * @return 実際に鑑定済みならばTRUEを返す
2766 static bool item_tester_hook_identify_fully_weapon_armour(object_type *o_ptr)
2768 if (!item_tester_hook_identify_fully(o_ptr))
2770 return object_is_weapon_armour_ammo(o_ptr);
2774 * @brief アイテム*鑑定*のメインルーチン処理 /
2775 * Identify an object in the inventory (or on the floor)
2776 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2777 * @return 実際に鑑定を行ったならばTRUEを返す
2779 * Fully "identify" an object in the inventory -BEN-
2780 * This routine returns TRUE if an item was identified.
2782 bool identify_fully(bool only_equip)
2786 char o_name[MAX_NLEN];
2790 item_tester_no_ryoute = TRUE;
2792 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
2794 item_tester_hook = item_tester_hook_identify_fully;
2798 q = _("どのアイテムを*鑑定*しますか? ", "*Identify* which item? ");
2803 item_tester_hook = object_is_weapon_armour_ammo;
2805 item_tester_hook = NULL;
2807 q = _("すべて*鑑定*済みです。 ", "All items are *identified*. ");
2811 s = _("*鑑定*するべきアイテムがない。", "You have nothing to *identify*.");
2813 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2815 /* Get the item (in the pack) */
2818 o_ptr = &inventory[item];
2821 /* Get the item (on the floor) */
2824 o_ptr = &o_list[0 - item];
2828 old_known = identify_item(o_ptr);
2830 /* Mark the item as fully known */
2831 o_ptr->ident |= (IDENT_MENTAL);
2837 object_desc(o_name, o_ptr, 0);
2840 if (item >= INVEN_RARM)
2842 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(item), o_name, index_to_label(item));
2846 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
2850 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
2853 /* Describe it fully */
2854 (void)screen_object(o_ptr, 0L);
2856 /* Auto-inscription/destroy */
2857 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2865 * @brief 魔力充填が可能なアイテムかどうか判定する /
2866 * Hook for "get_item()". Determine if something is rechargable.
2867 * @param o_ptr 判定するアイテムの情報参照ポインタ
2868 * @return 魔力充填が可能ならばTRUEを返す
2870 bool item_tester_hook_recharge(object_type *o_ptr)
2872 /* Recharge staffs */
2873 if (o_ptr->tval == TV_STAFF) return (TRUE);
2875 /* Recharge wands */
2876 if (o_ptr->tval == TV_WAND) return (TRUE);
2878 /* Hack -- Recharge rods */
2879 if (o_ptr->tval == TV_ROD) return (TRUE);
2888 * Recharge a wand/staff/rod from the pack or on the floor.
2889 * This function has been rewritten in Oangband and ZAngband.
2890 * @param power 充填パワー
2891 * @return ターン消費を要する処理まで進んだらTRUEを返す
2893 * Sorcery/Arcane -- Recharge --> recharge(plev * 4)
2894 * Chaos -- Arcane Binding --> recharge(90)
2896 * Scroll of recharging --> recharge(130)
2897 * Artifact activation/Thingol --> recharge(130)
2899 * It is harder to recharge high level, and highly charged wands,
2900 * staffs, and rods. The more wands in a stack, the more easily and
2901 * strongly they recharge. Staffs, however, each get fewer charges if
2904 * XXX XXX XXX Beware of "sliding index errors".
2906 bool recharge(int power)
2909 int recharge_strength, recharge_amount;
2918 char o_name[MAX_NLEN];
2920 /* Only accept legal items */
2921 item_tester_hook = item_tester_hook_recharge;
2924 q = _("どのアイテムに魔力を充填しますか? ", "Recharge which item? ");
2925 s = _("魔力を充填すべきアイテムがない。", "You have nothing to recharge.");
2927 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
2929 /* Get the item (in the pack) */
2932 o_ptr = &inventory[item];
2935 /* Get the item (on the floor) */
2938 o_ptr = &o_list[0 - item];
2941 /* Get the object kind. */
2942 k_ptr = &k_info[o_ptr->k_idx];
2944 /* Extract the object "level" */
2945 lev = k_info[o_ptr->k_idx].level;
2948 /* Recharge a rod */
2949 if (o_ptr->tval == TV_ROD)
2951 /* Extract a recharge strength by comparing object level to power. */
2952 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
2956 if (one_in_(recharge_strength))
2958 /* Activate the failure code. */
2965 /* Recharge amount */
2966 recharge_amount = (power * damroll(3, 2));
2968 /* Recharge by that amount */
2969 if (o_ptr->timeout > recharge_amount)
2970 o_ptr->timeout -= recharge_amount;
2977 /* Recharge wand/staff */
2980 /* Extract a recharge strength by comparing object level to power.
2981 * Divide up a stack of wands' charges to calculate charge penalty.
2983 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
2984 recharge_strength = (100 + power - lev -
2985 (8 * o_ptr->pval / o_ptr->number)) / 15;
2987 /* All staffs, unstacked wands. */
2988 else recharge_strength = (100 + power - lev -
2989 (8 * o_ptr->pval)) / 15;
2992 if (recharge_strength < 0) recharge_strength = 0;
2995 if (one_in_(recharge_strength))
2997 /* Activate the failure code. */
3001 /* If the spell didn't backfire, recharge the wand or staff. */
3004 /* Recharge based on the standard number of charges. */
3005 recharge_amount = randint1(1 + k_ptr->pval / 2);
3007 /* Multiple wands in a stack increase recharging somewhat. */
3008 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3011 (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
3012 if (recharge_amount < 1) recharge_amount = 1;
3013 if (recharge_amount > 12) recharge_amount = 12;
3016 /* But each staff in a stack gets fewer additional charges,
3017 * although always at least one.
3019 if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
3021 recharge_amount /= o_ptr->number;
3022 if (recharge_amount < 1) recharge_amount = 1;
3025 /* Recharge the wand or staff. */
3026 o_ptr->pval += recharge_amount;
3029 /* Hack -- we no longer "know" the item */
3030 o_ptr->ident &= ~(IDENT_KNOWN);
3032 /* Hack -- we no longer think the item is empty */
3033 o_ptr->ident &= ~(IDENT_EMPTY);
3038 /* Inflict the penalties for failing a recharge. */
3041 /* Artifacts are never destroyed. */
3042 if (object_is_fixed_artifact(o_ptr))
3044 object_desc(o_name, o_ptr, OD_NAME_ONLY);
3045 msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
3047 /* Artifact rods. */
3048 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
3049 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3051 /* Artifact wands and staffs. */
3052 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
3057 /* Get the object description */
3058 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3060 /*** Determine Seriousness of Failure ***/
3062 /* Mages recharge objects more safely. */
3063 if (p_ptr->pclass == CLASS_MAGE || p_ptr->pclass == CLASS_HIGH_MAGE || p_ptr->pclass == CLASS_SORCERER || p_ptr->pclass == CLASS_MAGIC_EATER || p_ptr->pclass == CLASS_BLUE_MAGE)
3065 /* 10% chance to blow up one rod, otherwise draining. */
3066 if (o_ptr->tval == TV_ROD)
3068 if (one_in_(10)) fail_type = 2;
3071 /* 75% chance to blow up one wand, otherwise draining. */
3072 else if (o_ptr->tval == TV_WAND)
3074 if (!one_in_(3)) fail_type = 2;
3077 /* 50% chance to blow up one staff, otherwise no effect. */
3078 else if (o_ptr->tval == TV_STAFF)
3080 if (one_in_(2)) fail_type = 2;
3085 /* All other classes get no special favors. */
3088 /* 33% chance to blow up one rod, otherwise draining. */
3089 if (o_ptr->tval == TV_ROD)
3091 if (one_in_(3)) fail_type = 2;
3094 /* 20% chance of the entire stack, else destroy one wand. */
3095 else if (o_ptr->tval == TV_WAND)
3097 if (one_in_(5)) fail_type = 3;
3100 /* Blow up one staff. */
3101 else if (o_ptr->tval == TV_STAFF)
3107 /*** Apply draining and destruction. ***/
3109 /* Drain object or stack of objects. */
3112 if (o_ptr->tval == TV_ROD)
3114 msg_print(_("魔力が逆噴射して、ロッドからさらに魔力を吸い取ってしまった!", "The recharge backfires, draining the rod further!"));
3116 if (o_ptr->timeout < 10000)
3117 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3119 else if (o_ptr->tval == TV_WAND)
3121 msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
3124 /* Staffs aren't drained. */
3127 /* Destroy an object or one in a stack of objects. */
3130 if (o_ptr->number > 1)
3131 msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
3133 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
3135 /* Reduce rod stack maximum timeout, drain wands. */
3136 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
3137 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
3139 /* Reduce and describe inventory */
3142 inven_item_increase(item, -1);
3143 inven_item_describe(item);
3144 inven_item_optimize(item);
3147 /* Reduce and describe floor item */
3150 floor_item_increase(0 - item, -1);
3151 floor_item_describe(0 - item);
3152 floor_item_optimize(0 - item);
3156 /* Destroy all members of a stack of objects. */
3159 if (o_ptr->number > 1)
3160 msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
3162 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
3164 /* Reduce and describe inventory */
3167 inven_item_increase(item, -999);
3168 inven_item_describe(item);
3169 inven_item_optimize(item);
3172 /* Reduce and describe floor item */
3175 floor_item_increase(0 - item, -999);
3176 floor_item_describe(0 - item);
3177 floor_item_optimize(0 - item);
3183 /* Combine / Reorder the pack (later) */
3184 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3187 p_ptr->window |= (PW_INVEN);
3189 /* Something was done */
3197 * @return ターン消費を要する処理を行ったならばTRUEを返す
3199 bool bless_weapon(void)
3203 u32b flgs[TR_FLAG_SIZE];
3204 char o_name[MAX_NLEN];
3207 item_tester_no_ryoute = TRUE;
3209 /* Bless only weapons */
3210 item_tester_hook = object_is_weapon;
3213 q = _("どのアイテムを祝福しますか?", "Bless which weapon? ");
3214 s = _("祝福できる武器がありません。", "You have weapon to bless.");
3216 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3219 /* Get the item (in the pack) */
3222 o_ptr = &inventory[item];
3225 /* Get the item (on the floor) */
3228 o_ptr = &o_list[0 - item];
3233 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3235 /* Extract the flags */
3236 object_flags(o_ptr, flgs);
3238 if (object_is_cursed(o_ptr))
3240 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) ||
3241 have_flag(flgs, TR_ADD_L_CURSE) ||
3242 have_flag(flgs, TR_ADD_H_CURSE) ||
3243 (o_ptr->curse_flags & TRC_PERMA_CURSE))
3246 msg_format("%sを覆う黒いオーラは祝福を跳ね返した!",
3249 msg_format("The black aura on %s %s disrupts the blessing!",
3250 ((item >= 0) ? "your" : "the"), o_name);
3257 msg_format("%s から邪悪なオーラが消えた。",
3260 msg_format("A malignant aura leaves %s %s.",
3261 ((item >= 0) ? "your" : "the"), o_name);
3266 o_ptr->curse_flags = 0L;
3268 /* Hack -- Assume felt */
3269 o_ptr->ident |= (IDENT_SENSE);
3272 o_ptr->feeling = FEEL_NONE;
3274 /* Recalculate the bonuses */
3275 p_ptr->update |= (PU_BONUS);
3278 p_ptr->window |= (PW_EQUIP);
3282 * Next, we try to bless it. Artifacts have a 1/3 chance of
3283 * being blessed, otherwise, the operation simply disenchants
3284 * them, godly power negating the magic. Ok, the explanation
3285 * is silly, but otherwise priests would always bless every
3286 * artifact weapon they find. Ego weapons and normal weapons
3287 * can be blessed automatically.
3289 if (have_flag(flgs, TR_BLESSED))
3292 msg_format("%s は既に祝福されている。",
3295 msg_format("%s %s %s blessed already.",
3296 ((item >= 0) ? "Your" : "The"), o_name,
3297 ((o_ptr->number > 1) ? "were" : "was"));
3303 if (!(object_is_artifact(o_ptr) || object_is_ego(o_ptr)) || one_in_(3))
3307 msg_format("%sは輝いた!",
3310 msg_format("%s %s shine%s!",
3311 ((item >= 0) ? "Your" : "The"), o_name,
3312 ((o_ptr->number > 1) ? "" : "s"));
3315 add_flag(o_ptr->art_flags, TR_BLESSED);
3316 o_ptr->discount = 99;
3320 bool dis_happened = FALSE;
3321 msg_print(_("その武器は祝福を嫌っている!", "The weapon resists your blessing!"));
3323 /* Disenchant tohit */
3324 if (o_ptr->to_h > 0)
3327 dis_happened = TRUE;
3330 if ((o_ptr->to_h > 5) && (randint0(100) < 33)) o_ptr->to_h--;
3332 /* Disenchant todam */
3333 if (o_ptr->to_d > 0)
3336 dis_happened = TRUE;
3339 if ((o_ptr->to_d > 5) && (randint0(100) < 33)) o_ptr->to_d--;
3341 /* Disenchant toac */
3342 if (o_ptr->to_a > 0)
3345 dis_happened = TRUE;
3348 if ((o_ptr->to_a > 5) && (randint0(100) < 33)) o_ptr->to_a--;
3352 msg_print(_("周囲が凡庸な雰囲気で満ちた...", "There is a static feeling in the air..."));
3355 msg_format("%s は劣化した!",
3358 msg_format("%s %s %s disenchanted!",
3359 ((item >= 0) ? "Your" : "The"), o_name,
3360 ((o_ptr->number > 1) ? "were" : "was"));
3366 /* Recalculate bonuses */
3367 p_ptr->update |= (PU_BONUS);
3370 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
3381 * @return ターン消費を要する処理を行ったならばTRUEを返す
3383 bool pulish_shield(void)
3387 u32b flgs[TR_FLAG_SIZE];
3388 char o_name[MAX_NLEN];
3391 item_tester_no_ryoute = TRUE;
3392 /* Assume enchant weapon */
3393 item_tester_tval = TV_SHIELD;
3396 q = _("どの盾を磨きますか?", "Pulish which weapon? ");
3397 s = _("磨く盾がありません。", "You have weapon to pulish.");
3399 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3402 /* Get the item (in the pack) */
3405 o_ptr = &inventory[item];
3408 /* Get the item (on the floor) */
3411 o_ptr = &o_list[0 - item];
3416 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3418 /* Extract the flags */
3419 object_flags(o_ptr, flgs);
3421 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
3422 !object_is_cursed(o_ptr) && (o_ptr->sval != SV_MIRROR_SHIELD))
3425 msg_format("%sは輝いた!", o_name);
3427 msg_format("%s %s shine%s!",
3428 ((item >= 0) ? "Your" : "The"), o_name,
3429 ((o_ptr->number > 1) ? "" : "s"));
3431 o_ptr->name2 = EGO_REFLECTION;
3432 enchant(o_ptr, randint0(3) + 4, ENCH_TOAC);
3434 o_ptr->discount = 99;
3435 chg_virtue(V_ENCHANT, 2);
3441 if (flush_failure) flush();
3443 msg_print(_("失敗した。", "Failed."));
3444 chg_virtue(V_ENCHANT, -2);
3454 * Potions "smash open" and cause an area effect when
3455 * @param who 薬破損の主体ID(プレイヤー所持アイテムが壊れた場合0、床上のアイテムの場合モンスターID)
3458 * @param k_idx 破損した薬のアイテムID
3459 * @return 薬を浴びたモンスターが起こるならばTRUEを返す
3462 * (1) they are shattered while in the player's inventory,
3463 * due to cold (etc) attacks;
3464 * (2) they are thrown at a monster, or obstacle;
3465 * (3) they are shattered by a "cold ball" or other such spell
3466 * while lying on the floor.
3469 * who --- who caused the potion to shatter (0=player)
3470 * potions that smash on the floor are assumed to
3471 * be caused by no-one (who = 1), as are those that
3472 * shatter inside the player inventory.
3473 * (Not anymore -- I changed this; TY)
3474 * y, x --- coordinates of the potion (or player if
3475 * the potion was in her inventory);
3476 * o_ptr --- pointer to the potion object.
3479 bool potion_smash_effect(int who, int y, int x, int k_idx)
3486 object_kind *k_ptr = &k_info[k_idx];
3488 switch (k_ptr->sval)
3490 case SV_POTION_SALT_WATER:
3491 case SV_POTION_SLIME_MOLD:
3492 case SV_POTION_LOSE_MEMORIES:
3493 case SV_POTION_DEC_STR:
3494 case SV_POTION_DEC_INT:
3495 case SV_POTION_DEC_WIS:
3496 case SV_POTION_DEC_DEX:
3497 case SV_POTION_DEC_CON:
3498 case SV_POTION_DEC_CHR:
3499 case SV_POTION_WATER: /* perhaps a 'water' attack? */
3500 case SV_POTION_APPLE_JUICE:
3503 case SV_POTION_INFRAVISION:
3504 case SV_POTION_DETECT_INVIS:
3505 case SV_POTION_SLOW_POISON:
3506 case SV_POTION_CURE_POISON:
3507 case SV_POTION_BOLDNESS:
3508 case SV_POTION_RESIST_HEAT:
3509 case SV_POTION_RESIST_COLD:
3510 case SV_POTION_HEROISM:
3511 case SV_POTION_BESERK_STRENGTH:
3512 case SV_POTION_RES_STR:
3513 case SV_POTION_RES_INT:
3514 case SV_POTION_RES_WIS:
3515 case SV_POTION_RES_DEX:
3516 case SV_POTION_RES_CON:
3517 case SV_POTION_RES_CHR:
3518 case SV_POTION_INC_STR:
3519 case SV_POTION_INC_INT:
3520 case SV_POTION_INC_WIS:
3521 case SV_POTION_INC_DEX:
3522 case SV_POTION_INC_CON:
3523 case SV_POTION_INC_CHR:
3524 case SV_POTION_AUGMENTATION:
3525 case SV_POTION_ENLIGHTENMENT:
3526 case SV_POTION_STAR_ENLIGHTENMENT:
3527 case SV_POTION_SELF_KNOWLEDGE:
3528 case SV_POTION_EXPERIENCE:
3529 case SV_POTION_RESISTANCE:
3530 case SV_POTION_INVULNERABILITY:
3531 case SV_POTION_NEW_LIFE:
3532 /* All of the above potions have no effect when shattered */
3534 case SV_POTION_SLOWNESS:
3539 case SV_POTION_POISON:
3544 case SV_POTION_BLINDNESS:
3548 case SV_POTION_CONFUSION: /* Booze */
3552 case SV_POTION_SLEEP:
3556 case SV_POTION_RUINATION:
3557 case SV_POTION_DETONATIONS:
3559 dam = damroll(25, 25);
3562 case SV_POTION_DEATH:
3563 dt = GF_DEATH_RAY; /* !! */
3564 dam = k_ptr->level * 10;
3568 case SV_POTION_SPEED:
3571 case SV_POTION_CURE_LIGHT:
3573 dam = damroll(2, 3);
3575 case SV_POTION_CURE_SERIOUS:
3577 dam = damroll(4, 3);
3579 case SV_POTION_CURE_CRITICAL:
3580 case SV_POTION_CURING:
3582 dam = damroll(6, 3);
3584 case SV_POTION_HEALING:
3586 dam = damroll(10, 10);
3588 case SV_POTION_RESTORE_EXP:
3593 case SV_POTION_LIFE:
3595 dam = damroll(50, 50);
3598 case SV_POTION_STAR_HEALING:
3600 dam = damroll(50, 50);
3603 case SV_POTION_RESTORE_MANA: /* MANA */
3605 dam = damroll(10, 10);
3612 (void)project(who, radius, y, x, dam, dt,
3613 (PROJECT_JUMP | PROJECT_ITEM | PROJECT_KILL), -1);
3615 /* XXX those potions that explode need to become "known" */
3621 * @brief プレイヤーの全既知呪文を表示する /
3622 * Hack -- Display all known spells in a window
3625 * XXX XXX XXX Need to analyze size of the window.
3626 * XXX XXX XXX Need more color coding.
3628 void display_spell_list(void)
3633 const magic_type *s_ptr;
3641 /* They have too many spells to list */
3642 if (p_ptr->pclass == CLASS_SORCERER) return;
3643 if (p_ptr->pclass == CLASS_RED_MAGE) return;
3646 if (p_ptr->pclass == CLASS_SNIPER)
3648 display_snipe_list();
3652 /* mind.c type classes */
3653 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
3654 (p_ptr->pclass == CLASS_BERSERKER) ||
3655 (p_ptr->pclass == CLASS_NINJA) ||
3656 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
3657 (p_ptr->pclass == CLASS_FORCETRAINER))
3660 int plev = p_ptr->lev;
3666 bool use_hp = FALSE;
3671 /* Display a list of spells */
3673 put_str(_("名前", "Name"), y, x + 5);
3674 put_str(_("Lv MP 失率 効果", "Lv Mana Fail Info"), y, x + 35);
3676 switch(p_ptr->pclass)
3678 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
3679 case CLASS_FORCETRAINER: use_mind = MIND_KI;break;
3680 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
3681 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
3682 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
3683 default: use_mind = 0;break;
3686 /* Dump the spells */
3687 for (i = 0; i < MAX_MIND_POWERS; i++)
3689 byte a = TERM_WHITE;
3691 /* Access the available spell */
3692 spell = mind_powers[use_mind].info[i];
3693 if (spell.min_lev > plev) break;
3695 /* Get the failure rate */
3696 chance = spell.fail;
3698 /* Reduce failure rate by "effective" level adjustment */
3699 chance -= 3 * (p_ptr->lev - spell.min_lev);
3701 /* Reduce failure rate by INT/WIS adjustment */
3702 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
3706 /* Not enough mana to cast */
3707 if (spell.mana_cost > p_ptr->csp)
3709 chance += 5 * (spell.mana_cost - p_ptr->csp);
3715 /* Not enough hp to cast */
3716 if (spell.mana_cost > p_ptr->chp)
3723 /* Extract the minimum failure rate */
3724 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
3726 /* Minimum failure rate */
3727 if (chance < minfail) chance = minfail;
3729 /* Stunning makes spells harder */
3730 if (p_ptr->stun > 50) chance += 25;
3731 else if (p_ptr->stun) chance += 15;
3733 /* Always a 5 percent chance of working */
3734 if (chance > 95) chance = 95;
3737 mindcraft_info(comment, use_mind, i);
3739 /* Dump the spell */
3740 sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s",
3742 spell.min_lev, spell.mana_cost, chance, comment);
3744 Term_putstr(x, y + i + 1, -1, a, psi_desc);
3749 /* Cannot read spellbooks */
3750 if (REALM_NONE == p_ptr->realm1) return;
3752 /* Normal spellcaster with books */
3755 for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
3759 /* Reset vertical */
3762 /* Vertical location */
3763 y = (j < 3) ? 0 : (m[j - 3] + 2);
3765 /* Horizontal location */
3769 for (i = 0; i < 32; i++)
3771 byte a = TERM_WHITE;
3773 /* Access the spell */
3774 if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
3776 s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
3780 s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
3783 strcpy(name, do_spell((j < 1) ? p_ptr->realm1 : p_ptr->realm2, i % 32, SPELL_NAME));
3786 if (s_ptr->slevel >= 99)
3789 strcpy(name, _("(判読不能)", "(illegible)"));
3797 ((p_ptr->spell_forgotten1 & (1L << i))) :
3798 ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
3805 else if (!((j < 1) ?
3806 (p_ptr->spell_learned1 & (1L << i)) :
3807 (p_ptr->spell_learned2 & (1L << (i % 32)))))
3814 else if (!((j < 1) ?
3815 (p_ptr->spell_worked1 & (1L << i)) :
3816 (p_ptr->spell_worked2 & (1L << (i % 32)))))
3822 /* Dump the spell --(-- */
3823 sprintf(out_val, "%c/%c) %-20.20s",
3824 I2A(n / 8), I2A(n % 8), name);
3829 /* Dump onto the window */
3830 Term_putstr(x, m[j], -1, a, out_val);
3840 * @brief 呪文の経験値を返す /
3841 * Returns experience of a spell
3843 * @param use_realm 魔法領域
3846 s16b experience_of_spell(int spell, int use_realm)
3848 if (p_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
3849 else if (p_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
3850 else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
3851 else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
3857 * @brief 呪文の消費MPを返す /
3858 * Modify mana consumption rate using spell exp and p_ptr->dec_mana
3859 * @param need_mana 基本消費MP
3864 int mod_need_mana(int need_mana, int spell, int realm)
3866 #define MANA_CONST 2400
3868 #define DEC_MANA_DIV 3
3871 if ((realm > REALM_NONE) && (realm <= MAX_REALM))
3874 * need_mana defaults if spell exp equals SPELL_EXP_EXPERT and !p_ptr->dec_mana.
3875 * MANA_CONST is used to calculate need_mana effected from spell proficiency.
3877 need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(spell, realm)) + (MANA_CONST - 1);
3878 need_mana *= p_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV;
3879 need_mana /= MANA_CONST * MANA_DIV;
3880 if (need_mana < 1) need_mana = 1;
3883 /* Non-realm magic */
3886 if (p_ptr->dec_mana) need_mana = (need_mana + 1) * DEC_MANA_DIV / MANA_DIV;
3898 * @brief 呪文の失敗率修正処理1(呪い、消費魔力減少、呪文簡易化) /
3899 * Modify spell fail rate
3900 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
3901 * @param chance 修正前失敗率
3905 int mod_spell_chance_1(int chance)
3907 chance += p_ptr->to_m_chance;
3909 if (p_ptr->heavy_spell) chance += 20;
3911 if (p_ptr->dec_mana && p_ptr->easy_spell) chance -= 4;
3912 else if (p_ptr->easy_spell) chance -= 3;
3913 else if (p_ptr->dec_mana) chance -= 2;
3920 * @brief 呪文の失敗率修正処理2(消費魔力減少、呪い、負値修正) /
3921 * Modify spell fail rate
3922 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
3923 * @param chance 修正前失敗率
3925 * Modify spell fail rate (as "suffix" process)
3926 * Using p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
3927 * Note: variable "chance" cannot be negative.
3930 int mod_spell_chance_2(int chance)
3932 if (p_ptr->dec_mana) chance--;
3934 if (p_ptr->heavy_spell) chance += 5;
3936 return MAX(chance, 0);
3941 * @brief 呪文の失敗率計算メインルーチン /
3942 * Returns spell chance of failure for spell -RAK-
3944 * @param use_realm 魔法領域ID
3947 s16b spell_chance(int spell, int use_realm)
3949 int chance, minfail;
3950 const magic_type *s_ptr;
3952 int penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
3955 /* Paranoia -- must be literate */
3956 if (!mp_ptr->spell_book) return (100);
3958 if (use_realm == REALM_HISSATSU) return 0;
3960 /* Access the spell */
3961 if (!is_magic(use_realm))
3963 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
3967 s_ptr = &mp_ptr->info[use_realm - 1][spell];
3970 /* Extract the base spell failure rate */
3971 chance = s_ptr->sfail;
3973 /* Reduce failure rate by "effective" level adjustment */
3974 chance -= 3 * (p_ptr->lev - s_ptr->slevel);
3976 /* Reduce failure rate by INT/WIS adjustment */
3977 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
3980 chance += (MAX(r_info[m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 100 - 10, 0));
3982 /* Extract mana consumption rate */
3983 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
3985 /* Not enough mana to cast */
3986 if (need_mana > p_ptr->csp)
3988 chance += 5 * (need_mana - p_ptr->csp);
3991 if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
3993 /* Extract the minimum failure rate */
3994 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
3997 * Non mage/priest characters never get too good
3998 * (added high mage, mindcrafter)
4000 if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
4002 if (minfail < 5) minfail = 5;
4005 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
4006 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
4007 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
4009 chance = mod_spell_chance_1(chance);
4011 /* Goodness or evilness gives a penalty to failure rate */
4015 if ((p_ptr->align > 50) || (p_ptr->align < -50)) chance += penalty;
4017 case REALM_LIFE: case REALM_CRUSADE:
4018 if (p_ptr->align < -20) chance += penalty;
4020 case REALM_DEATH: case REALM_DAEMON: case REALM_HEX:
4021 if (p_ptr->align > 20) chance += penalty;
4025 /* Minimum failure rate */
4026 if (chance < minfail) chance = minfail;
4028 /* Stunning makes spells harder */
4029 if (p_ptr->stun > 50) chance += 25;
4030 else if (p_ptr->stun) chance += 15;
4032 /* Always a 5 percent chance of working */
4033 if (chance > 95) chance = 95;
4035 if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2)
4036 || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4038 s16b exp = experience_of_spell(spell, use_realm);
4039 if (exp >= SPELL_EXP_EXPERT) chance--;
4040 if (exp >= SPELL_EXP_MASTER) chance--;
4043 /* Return the chance */
4044 return mod_spell_chance_2(chance);
4049 * @brief 魔法が利用可能かどうかを返す /
4050 * Determine if a spell is "okay" for the player to cast or study
4051 * The spell must be legible, not forgotten, and also, to cast,
4052 * it must be known, and to study, it must not be known.
4054 * @param learned 使用可能な判定ならばTRUE、学習可能かどうかの判定ならばFALSE
4055 * @param study_pray 祈りの学習判定目的ならばTRUE
4056 * @param use_realm 魔法領域ID
4059 bool spell_okay(int spell, bool learned, bool study_pray, int use_realm)
4061 const magic_type *s_ptr;
4063 /* Access the spell */
4064 if (!is_magic(use_realm))
4066 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4070 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4073 /* Spell is illegal */
4074 if (s_ptr->slevel > p_ptr->lev) return (FALSE);
4076 /* Spell is forgotten */
4077 if ((use_realm == p_ptr->realm2) ?
4078 (p_ptr->spell_forgotten2 & (1L << spell)) :
4079 (p_ptr->spell_forgotten1 & (1L << spell)))
4085 if (p_ptr->pclass == CLASS_SORCERER) return (TRUE);
4086 if (p_ptr->pclass == CLASS_RED_MAGE) return (TRUE);
4088 /* Spell is learned */
4089 if ((use_realm == p_ptr->realm2) ?
4090 (p_ptr->spell_learned2 & (1L << spell)) :
4091 (p_ptr->spell_learned1 & (1L << spell)))
4094 return (!study_pray);
4097 /* Okay to study, not to cast */
4104 * @brief 呪文情報の表示処理 /
4105 * Print a list of spells (for browsing or casting or viewing)
4106 * @param target_spell 呪文ID
4107 * @param spells アクセス開始するスペルの参照ポイント
4109 * @param y 表示メッセージ左上Y座標
4110 * @param x 表示メッセージ左上X座標
4111 * @param use_realm 魔法領域ID
4114 void print_spells(int target_spell, byte *spells, int num, int y, int x, int use_realm)
4116 int i, spell, exp_level, increment = 64;
4117 const magic_type *s_ptr;
4128 if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
4129 msg_print(_("警告! print_spell が領域なしに呼ばれた", "Warning! print_spells called with null realm"));
4131 /* Title the list */
4133 if (use_realm == REALM_HISSATSU)
4134 strcpy(buf,_(" Lv MP", " Lv SP"));
4136 strcpy(buf,_("熟練度 Lv MP 失率 効果", "Profic Lv SP Fail Effect"));
4138 put_str(_("名前", "Name"), y, x + 5);
4139 put_str(buf, y, x + 29);
4141 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
4142 else if (use_realm == p_ptr->realm1) increment = 0;
4143 else if (use_realm == p_ptr->realm2) increment = 32;
4145 /* Dump the spells */
4146 for (i = 0; i < num; i++)
4148 /* Access the spell */
4151 /* Access the spell */
4152 if (!is_magic(use_realm))
4154 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4158 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4161 if (use_realm == REALM_HISSATSU)
4162 need_mana = s_ptr->smana;
4165 s16b exp = experience_of_spell(spell, use_realm);
4167 /* Extract mana consumption rate */
4168 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4170 if ((increment == 64) || (s_ptr->slevel >= 99)) exp_level = EXP_LEVEL_UNSKILLED;
4171 else exp_level = spell_exp_level(exp);
4174 if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE;
4175 else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE;
4176 else if (s_ptr->slevel >= 99) max = TRUE;
4177 else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE;
4179 strncpy(ryakuji, exp_level_str[exp_level], 4);
4184 if (use_menu && target_spell)
4186 if (i == (target_spell-1))
4187 strcpy(out_val, _(" 》 ", " > "));
4189 strcpy(out_val, " ");
4191 else sprintf(out_val, " %c) ", I2A(i));
4192 /* Skip illegible spells */
4193 if (s_ptr->slevel >= 99)
4195 strcat(out_val, format("%-30s", _("(判読不能)", "(illegible)")));
4196 c_prt(TERM_L_DARK, out_val, y + i + 1, x);
4200 /* XXX XXX Could label spells above the players level */
4202 /* Get extra info */
4203 strcpy(info, do_spell(use_realm, spell, SPELL_INFO));
4208 /* Assume spell is known and tried */
4209 line_attr = TERM_WHITE;
4211 /* Analyze the spell */
4212 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4214 if (s_ptr->slevel > p_ptr->max_plv)
4216 comment = _("未知", "unknown");
4217 line_attr = TERM_L_BLUE;
4219 else if (s_ptr->slevel > p_ptr->lev)
4221 comment = _("忘却", "forgotten");
4222 line_attr = TERM_YELLOW;
4225 else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
4227 comment = _("未知", "unknown");
4228 line_attr = TERM_L_BLUE;
4230 else if ((use_realm == p_ptr->realm1) ?
4231 ((p_ptr->spell_forgotten1 & (1L << spell))) :
4232 ((p_ptr->spell_forgotten2 & (1L << spell))))
4234 comment = _("忘却", "forgotten");
4235 line_attr = TERM_YELLOW;
4237 else if (!((use_realm == p_ptr->realm1) ?
4238 (p_ptr->spell_learned1 & (1L << spell)) :
4239 (p_ptr->spell_learned2 & (1L << spell))))
4241 comment = _("未知", "unknown");
4242 line_attr = TERM_L_BLUE;
4244 else if (!((use_realm == p_ptr->realm1) ?
4245 (p_ptr->spell_worked1 & (1L << spell)) :
4246 (p_ptr->spell_worked2 & (1L << spell))))
4248 comment = _("未経験", "untried");
4249 line_attr = TERM_L_GREEN;
4252 /* Dump the spell --(-- */
4253 if (use_realm == REALM_HISSATSU)
4255 strcat(out_val, format("%-25s %2d %4d",
4256 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
4257 s_ptr->slevel, need_mana));
4261 strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%% %s",
4262 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
4263 (max ? '!' : ' '), ryakuji,
4264 s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
4266 c_prt(line_attr, out_val, y + i + 1, x);
4269 /* Clear the bottom line */
4270 prt("", y + i + 1, x);
4275 * @brief アイテムが酸で破損するかどうかを判定する
4276 * @param o_ptr アイテムの情報参照ポインタ
4277 * @return 破損するならばTRUEを返す
4278 * Note that amulets, rods, and high-level spell books are immune
4279 * to "inventory damage" of any kind. Also sling ammo and shovels.
4280 * Does a given class of objects (usually) hate acid?
4281 * Note that acid can either melt or corrode something.
4283 bool hates_acid(object_type *o_ptr)
4285 /* Analyze the type */
4286 switch (o_ptr->tval)
4288 /* Wearable items */
4308 /* Staffs/Scrolls are wood/paper */
4321 /* Junk is useless */
4335 * @brief アイテムが電撃で破損するかどうかを判定する /
4336 * Does a given object (usually) hate electricity?
4337 * @param o_ptr アイテムの情報参照ポインタ
4338 * @return 破損するならばTRUEを返す
4340 bool hates_elec(object_type *o_ptr)
4342 switch (o_ptr->tval)
4356 * @brief アイテムが火炎で破損するかどうかを判定する /
4357 * Does a given object (usually) hate fire?
4358 * @param o_ptr アイテムの情報参照ポインタ
4359 * @return 破損するならばTRUEを返す
4361 * Hafted/Polearm weapons have wooden shafts.
4362 * Arrows/Bows are mostly wooden.
4364 bool hates_fire(object_type *o_ptr)
4366 /* Analyze the type */
4367 switch (o_ptr->tval)
4385 case TV_SORCERY_BOOK:
4386 case TV_NATURE_BOOK:
4390 case TV_ARCANE_BOOK:
4392 case TV_DAEMON_BOOK:
4393 case TV_CRUSADE_BOOK:
4395 case TV_HISSATSU_BOOK:
4407 /* Staffs/Scrolls burn */
4420 * @brief アイテムが冷気で破損するかどうかを判定する /
4421 * Does a given object (usually) hate cold?
4422 * @param o_ptr アイテムの情報参照ポインタ
4423 * @return 破損するならばTRUEを返す
4425 bool hates_cold(object_type *o_ptr)
4427 switch (o_ptr->tval)
4442 * @brief アイテムが酸で破損するかどうかを判定する(メインルーチン) /
4444 * @param o_ptr アイテムの情報参照ポインタ
4445 * @return 破損するならばTRUEを返す
4448 int set_acid_destroy(object_type *o_ptr)
4450 u32b flgs[TR_FLAG_SIZE];
4451 if (!hates_acid(o_ptr)) return (FALSE);
4452 object_flags(o_ptr, flgs);
4453 if (have_flag(flgs, TR_IGNORE_ACID)) return (FALSE);
4459 * @brief アイテムが電撃で破損するかどうかを判定する(メインルーチン) /
4461 * @param o_ptr アイテムの情報参照ポインタ
4462 * @return 破損するならばTRUEを返す
4465 int set_elec_destroy(object_type *o_ptr)
4467 u32b flgs[TR_FLAG_SIZE];
4468 if (!hates_elec(o_ptr)) return (FALSE);
4469 object_flags(o_ptr, flgs);
4470 if (have_flag(flgs, TR_IGNORE_ELEC)) return (FALSE);
4476 * @brief アイテムが火炎で破損するかどうかを判定する(メインルーチン) /
4478 * @param o_ptr アイテムの情報参照ポインタ
4479 * @return 破損するならばTRUEを返す
4482 int set_fire_destroy(object_type *o_ptr)
4484 u32b flgs[TR_FLAG_SIZE];
4485 if (!hates_fire(o_ptr)) return (FALSE);
4486 object_flags(o_ptr, flgs);
4487 if (have_flag(flgs, TR_IGNORE_FIRE)) return (FALSE);
4493 * @brief アイテムが冷気で破損するかどうかを判定する(メインルーチン) /
4495 * @param o_ptr アイテムの情報参照ポインタ
4496 * @return 破損するならばTRUEを返す
4499 int set_cold_destroy(object_type *o_ptr)
4501 u32b flgs[TR_FLAG_SIZE];
4502 if (!hates_cold(o_ptr)) return (FALSE);
4503 object_flags(o_ptr, flgs);
4504 if (have_flag(flgs, TR_IGNORE_COLD)) return (FALSE);
4510 * @brief アイテムが指定確率で破損するかどうかを判定する /
4511 * Destroys a type of item on a given percent chance
4512 * @param typ 破損判定関数ポインタ
4514 * @return 破損したアイテムの数
4516 * Note that missiles are no longer necessarily all destroyed
4517 * Destruction taken from "melee.c" code for "stealing".
4518 * New-style wands and rods handled correctly. -LM-
4519 * Returns number of items destroyed.
4521 int inven_damage(inven_func typ, int perc)
4525 char o_name[MAX_NLEN];
4527 if (CHECK_MULTISHADOW()) return 0;
4529 if (p_ptr->inside_arena) return 0;
4531 /* Count the casualties */
4534 /* Scan through the slots backwards */
4535 for (i = 0; i < INVEN_PACK; i++)
4537 o_ptr = &inventory[i];
4539 /* Skip non-objects */
4540 if (!o_ptr->k_idx) continue;
4542 /* Hack -- for now, skip artifacts */
4543 if (object_is_artifact(o_ptr)) continue;
4545 /* Give this item slot a shot at death */
4548 /* Count the casualties */
4549 for (amt = j = 0; j < o_ptr->number; ++j)
4551 if (randint0(100) < perc) amt++;
4554 /* Some casualities */
4557 /* Get a description */
4558 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
4561 msg_format(_("%s(%c)が%s壊れてしまった!", "%sour %s (%c) %s destroyed!"),
4564 o_name, index_to_label(i),
4565 ((o_ptr->number > 1) ?
4566 ((amt == o_ptr->number) ? "全部" :
4567 (amt > 1 ? "何個か" : "一個")) : "") );
4569 ((o_ptr->number > 1) ?
4570 ((amt == o_ptr->number) ? "All of y" :
4571 (amt > 1 ? "Some of y" : "One of y")) : "Y"),
4572 o_name, index_to_label(i),
4573 ((amt > 1) ? "were" : "was"));
4577 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
4578 msg_print("やりやがったな!");
4581 /* Potions smash open */
4582 if (object_is_potion(o_ptr))
4584 (void)potion_smash_effect(0, p_ptr->y, p_ptr->x, o_ptr->k_idx);
4587 /* Reduce the charges of rods/wands */
4588 reduce_charges(o_ptr, amt);
4590 /* Destroy "amt" items */
4591 inven_item_increase(i, -amt);
4592 inven_item_optimize(i);
4594 /* Count the casualties */
4600 /* Return the casualty count */
4606 * @brief 酸攻撃による装備のAC劣化処理 /
4607 * Acid has hit the player, attempt to affect some armor.
4608 * @return ACが実際に劣化したらTRUEを返す
4610 * Note that the "base armor" of an object never changes.
4611 * If any armor is damaged (or resists), the player takes less damage.
4613 static int minus_ac(void)
4615 object_type *o_ptr = NULL;
4616 u32b flgs[TR_FLAG_SIZE];
4617 char o_name[MAX_NLEN];
4620 /* Pick a (possibly empty) inventory slot */
4621 switch (randint1(7))
4623 case 1: o_ptr = &inventory[INVEN_RARM]; break;
4624 case 2: o_ptr = &inventory[INVEN_LARM]; break;
4625 case 3: o_ptr = &inventory[INVEN_BODY]; break;
4626 case 4: o_ptr = &inventory[INVEN_OUTER]; break;
4627 case 5: o_ptr = &inventory[INVEN_HANDS]; break;
4628 case 6: o_ptr = &inventory[INVEN_HEAD]; break;
4629 case 7: o_ptr = &inventory[INVEN_FEET]; break;
4632 /* Nothing to damage */
4633 if (!o_ptr->k_idx) return (FALSE);
4635 if (!object_is_armour(o_ptr)) return (FALSE);
4637 /* No damage left to be done */
4638 if (o_ptr->ac + o_ptr->to_a <= 0) return (FALSE);
4642 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
4644 /* Extract the flags */
4645 object_flags(o_ptr, flgs);
4647 /* Object resists */
4648 if (have_flag(flgs, TR_IGNORE_ACID))
4650 msg_format(_("しかし%sには効果がなかった!", "Your %s is unaffected!"), o_name);
4655 msg_format(_("%sがダメージを受けた!", "Your %s is damaged!"), o_name);
4657 /* Damage the item */
4660 /* Calculate bonuses */
4661 p_ptr->update |= (PU_BONUS);
4664 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
4668 /* Item was damaged */
4674 * @brief 酸属性によるプレイヤー損害処理 /
4675 * Hurt the player with Acid
4676 * @param dam 基本ダメージ量
4677 * @param kb_str ダメージ原因記述
4678 * @param monspell 原因となったモンスター特殊攻撃ID
4679 * @param aura オーラよるダメージが原因ならばTRUE
4682 int acid_dam(int dam, cptr kb_str, int monspell, bool aura)
4685 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4686 bool double_resist = IS_OPPOSE_ACID();
4688 /* Total Immunity */
4689 if (p_ptr->immune_acid || (dam <= 0))
4691 learn_spell(monspell);
4695 /* Vulnerability (Ouch!) */
4696 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4697 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4699 /* Resist the damage */
4700 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
4701 if (double_resist) dam = (dam + 2) / 3;
4703 if (aura || !CHECK_MULTISHADOW())
4705 if ((!(double_resist || p_ptr->resist_acid)) &&
4706 one_in_(HURT_CHANCE))
4707 (void)do_dec_stat(A_CHR);
4709 /* If any armor gets hit, defend the player */
4710 if (minus_ac()) dam = (dam + 1) / 2;
4714 get_damage = take_hit(aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
4716 /* Inventory damage */
4717 if (!aura && !(double_resist && p_ptr->resist_acid))
4718 inven_damage(set_acid_destroy, inv);
4724 * @brief 電撃属性によるプレイヤー損害処理 /
4725 * Hurt the player with electricity
4726 * @param dam 基本ダメージ量
4727 * @param kb_str ダメージ原因記述
4728 * @param monspell 原因となったモンスター特殊攻撃ID
4729 * @param aura オーラよるダメージが原因ならばTRUE
4732 int elec_dam(int dam, cptr kb_str, int monspell, bool aura)
4735 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4736 bool double_resist = IS_OPPOSE_ELEC();
4738 /* Total immunity */
4739 if (p_ptr->immune_elec || (dam <= 0))
4741 learn_spell(monspell);
4745 /* Vulnerability (Ouch!) */
4746 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4747 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4748 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
4750 /* Resist the damage */
4751 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
4752 if (double_resist) dam = (dam + 2) / 3;
4754 if (aura || !CHECK_MULTISHADOW())
4756 if ((!(double_resist || p_ptr->resist_elec)) &&
4757 one_in_(HURT_CHANCE))
4758 (void)do_dec_stat(A_DEX);
4762 get_damage = take_hit(aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
4764 /* Inventory damage */
4765 if (!aura && !(double_resist && p_ptr->resist_elec))
4766 inven_damage(set_elec_destroy, inv);
4773 * @brief 火炎属性によるプレイヤー損害処理 /
4774 * Hurt the player with Fire
4775 * @param dam 基本ダメージ量
4776 * @param kb_str ダメージ原因記述
4777 * @param monspell 原因となったモンスター特殊攻撃ID
4778 * @param aura オーラよるダメージが原因ならばTRUE
4781 int fire_dam(int dam, cptr kb_str, int monspell, bool aura)
4784 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4785 bool double_resist = IS_OPPOSE_FIRE();
4787 /* Totally immune */
4788 if (p_ptr->immune_fire || (dam <= 0))
4790 learn_spell(monspell);
4794 /* Vulnerability (Ouch!) */
4795 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4796 if (prace_is_(RACE_ENT)) dam += dam / 3;
4797 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4799 /* Resist the damage */
4800 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
4801 if (double_resist) dam = (dam + 2) / 3;
4803 if (aura || !CHECK_MULTISHADOW())
4805 if ((!(double_resist || p_ptr->resist_fire)) &&
4806 one_in_(HURT_CHANCE))
4807 (void)do_dec_stat(A_STR);
4811 get_damage = take_hit(aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
4813 /* Inventory damage */
4814 if (!aura && !(double_resist && p_ptr->resist_fire))
4815 inven_damage(set_fire_destroy, inv);
4822 * @brief 冷気属性によるプレイヤー損害処理 /
4823 * Hurt the player with Cold
4824 * @param dam 基本ダメージ量
4825 * @param kb_str ダメージ原因記述
4826 * @param monspell 原因となったモンスター特殊攻撃ID
4827 * @param aura オーラよるダメージが原因ならばTRUE
4830 int cold_dam(int dam, cptr kb_str, int monspell, bool aura)
4833 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4834 bool double_resist = IS_OPPOSE_COLD();
4836 /* Total immunity */
4837 if (p_ptr->immune_cold || (dam <= 0))
4839 learn_spell(monspell);
4843 /* Vulnerability (Ouch!) */
4844 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4845 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4847 /* Resist the damage */
4848 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
4849 if (double_resist) dam = (dam + 2) / 3;
4851 if (aura || !CHECK_MULTISHADOW())
4853 if ((!(double_resist || p_ptr->resist_cold)) &&
4854 one_in_(HURT_CHANCE))
4855 (void)do_dec_stat(A_STR);
4859 get_damage = take_hit(aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
4861 /* Inventory damage */
4862 if (!aura && !(double_resist && p_ptr->resist_cold))
4863 inven_damage(set_cold_destroy, inv);
4870 * @return ターン消費を要する処理を行ったならばTRUEを返す
4872 bool rustproof(void)
4876 char o_name[MAX_NLEN];
4879 item_tester_no_ryoute = TRUE;
4880 /* Select a piece of armour */
4881 item_tester_hook = object_is_armour;
4884 q = _("どの防具に錆止めをしますか?", "Rustproof which piece of armour? ");
4885 s = _("錆止めできるものがありません。", "You have nothing to rustproof.");
4887 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return FALSE;
4889 /* Get the item (in the pack) */
4892 o_ptr = &inventory[item];
4895 /* Get the item (on the floor) */
4898 o_ptr = &o_list[0 - item];
4903 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
4905 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
4907 if ((o_ptr->to_a < 0) && !object_is_cursed(o_ptr))
4910 msg_format("%sは新品同様になった!",o_name);
4912 msg_format("%s %s look%s as good as new!",
4913 ((item >= 0) ? "Your" : "The"), o_name,
4914 ((o_ptr->number > 1) ? "" : "s"));
4921 msg_format("%sは腐食しなくなった。", o_name);
4923 msg_format("%s %s %s now protected against corrosion.",
4924 ((item >= 0) ? "Your" : "The"), o_name,
4925 ((o_ptr->number > 1) ? "are" : "is"));
4937 * Curse the players armor
4938 * @return 実際に呪縛されたらTRUEを返す
4940 bool curse_armor(void)
4945 char o_name[MAX_NLEN];
4948 /* Curse the body armor */
4949 o_ptr = &inventory[INVEN_BODY];
4951 /* Nothing to curse */
4952 if (!o_ptr->k_idx) return (FALSE);
4956 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
4958 /* Attempt a saving throw for artifacts */
4959 if (object_is_artifact(o_ptr) && (randint0(100) < 50))
4963 msg_format("%sが%sを包み込もうとしたが、%sはそれを跳ね返した!",
4964 "恐怖の暗黒オーラ", "防具", o_name);
4966 msg_format("A %s tries to %s, but your %s resists the effects!",
4967 "terrible black aura", "surround your armor", o_name);
4972 /* not artifact or failed save... */
4976 msg_format(_("恐怖の暗黒オーラがあなたの%sを包み込んだ!", "A terrible black aura blasts your %s!"), o_name);
4977 chg_virtue(V_ENCHANT, -5);
4979 /* Blast the armor */
4981 o_ptr->name2 = EGO_BLASTED;
4982 o_ptr->to_a = 0 - randint1(5) - randint1(5);
4989 for (i = 0; i < TR_FLAG_SIZE; i++)
4990 o_ptr->art_flags[i] = 0;
4993 o_ptr->curse_flags = TRC_CURSED;
4996 o_ptr->ident |= (IDENT_BROKEN);
4998 /* Recalculate bonuses */
4999 p_ptr->update |= (PU_BONUS);
5001 /* Recalculate mana */
5002 p_ptr->update |= (PU_MANA);
5005 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5013 * Curse the players weapon
5014 * @param force 無条件に呪縛を行うならばTRUE
5015 * @param o_ptr 呪縛する武器のアイテム情報参照ポインタ
5016 * @return 実際に呪縛されたらTRUEを返す
5018 bool curse_weapon_object(bool force, object_type *o_ptr)
5021 char o_name[MAX_NLEN];
5023 /* Nothing to curse */
5024 if (!o_ptr->k_idx) return (FALSE);
5027 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
5029 /* Attempt a saving throw */
5030 if (object_is_artifact(o_ptr) && (randint0(100) < 50) && !force)
5034 msg_format("%sが%sを包み込もうとしたが、%sはそれを跳ね返した!",
5035 "恐怖の暗黒オーラ", "武器", o_name);
5037 msg_format("A %s tries to %s, but your %s resists the effects!",
5038 "terrible black aura", "surround your weapon", o_name);
5042 /* not artifact or failed save... */
5046 if (!force) msg_format(_("恐怖の暗黒オーラがあなたの%sを包み込んだ!", "A terrible black aura blasts your %s!"), o_name);
5047 chg_virtue(V_ENCHANT, -5);
5049 /* Shatter the weapon */
5051 o_ptr->name2 = EGO_SHATTERED;
5052 o_ptr->to_h = 0 - randint1(5) - randint1(5);
5053 o_ptr->to_d = 0 - randint1(5) - randint1(5);
5059 for (i = 0; i < TR_FLAG_SIZE; i++)
5060 o_ptr->art_flags[i] = 0;
5063 o_ptr->curse_flags = TRC_CURSED;
5066 o_ptr->ident |= (IDENT_BROKEN);
5068 /* Recalculate bonuses */
5069 p_ptr->update |= (PU_BONUS);
5071 /* Recalculate mana */
5072 p_ptr->update |= (PU_MANA);
5075 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5083 * @brief 武器呪縛処理のメインルーチン /
5084 * Curse the players weapon
5085 * @param force 無条件に呪縛を行うならばTRUE
5086 * @param slot 呪縛する武器の装備スロット
5087 * @return 実際に呪縛されたらTRUEを返す
5089 bool curse_weapon(bool force, int slot)
5091 /* Curse the weapon */
5092 return curse_weapon_object(force, &inventory[slot]);
5097 * @brief ボルトのエゴ化処理(火炎エゴのみ) /
5098 * Enchant some bolts
5101 bool brand_bolts(void)
5105 /* Use the first acceptable bolts */
5106 for (i = 0; i < INVEN_PACK; i++)
5108 object_type *o_ptr = &inventory[i];
5110 /* Skip non-bolts */
5111 if (o_ptr->tval != TV_BOLT) continue;
5113 /* Skip artifacts and ego-items */
5114 if (object_is_artifact(o_ptr) || object_is_ego(o_ptr))
5117 /* Skip cursed/broken items */
5118 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) continue;
5121 if (randint0(100) < 75) continue;
5124 msg_print(_("クロスボウの矢が炎のオーラに包まれた!", "Your bolts are covered in a fiery aura!"));
5127 o_ptr->name2 = EGO_FLAME;
5130 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
5137 if (flush_failure) flush();
5140 msg_print(_("炎で強化するのに失敗した。", "The fiery enchantment failed."));
5148 * @brief 変身処理向けにモンスターの近隣レベル帯モンスターを返す /
5149 * Helper function -- return a "nearby" race for polymorphing
5150 * @param r_idx 基準となるモンスター種族ID
5151 * @return 変更先のモンスター種族ID
5153 * Note that this function is one of the more "dangerous" ones...
5155 static s16b poly_r_idx(int r_idx)
5157 monster_race *r_ptr = &r_info[r_idx];
5159 int i, r, lev1, lev2;
5161 /* Hack -- Uniques/Questors never polymorph */
5162 if ((r_ptr->flags1 & RF1_UNIQUE) ||
5163 (r_ptr->flags1 & RF1_QUESTOR))
5166 /* Allowable range of "levels" for resulting monster */
5167 lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
5168 lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
5170 /* Pick a (possibly new) non-unique race */
5171 for (i = 0; i < 1000; i++)
5173 /* Pick a new race, using a level calculation */
5174 r = get_mon_num((dun_level + r_ptr->level) / 2 + 5);
5176 /* Handle failure */
5182 /* Ignore unique monsters */
5183 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5185 /* Ignore monsters with incompatible levels */
5186 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
5188 /* Use that index */
5200 * @brief 指定座標にいるモンスターを変身させる /
5201 * Helper function -- return a "nearby" race for polymorphing
5204 * @return 実際に変身したらTRUEを返す
5206 bool polymorph_monster(int y, int x)
5208 cave_type *c_ptr = &cave[y][x];
5209 monster_type *m_ptr = &m_list[c_ptr->m_idx];
5210 bool polymorphed = FALSE;
5212 int old_r_idx = m_ptr->r_idx;
5213 bool targeted = (target_who == c_ptr->m_idx) ? TRUE : FALSE;
5214 bool health_tracked = (p_ptr->health_who == c_ptr->m_idx) ? TRUE : FALSE;
5215 monster_type back_m;
5217 if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
5219 if ((p_ptr->riding == c_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return (FALSE);
5221 /* Memorize the monster before polymorphing */
5224 /* Pick a "new" monster race */
5225 new_r_idx = poly_r_idx(old_r_idx);
5227 /* Handle polymorph */
5228 if (new_r_idx != old_r_idx)
5231 bool preserve_hold_objects = back_m.hold_o_idx ? TRUE : FALSE;
5232 s16b this_o_idx, next_o_idx = 0;
5234 /* Get the monsters attitude */
5235 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
5236 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
5237 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
5239 /* Mega-hack -- ignore held objects */
5240 m_ptr->hold_o_idx = 0;
5242 /* "Kill" the "old" monster */
5243 delete_monster_idx(c_ptr->m_idx);
5245 /* Create a new monster (no groups) */
5246 if (place_monster_aux(0, y, x, new_r_idx, mode))
5248 m_list[hack_m_idx_ii].nickname = back_m.nickname;
5249 m_list[hack_m_idx_ii].parent_m_idx = back_m.parent_m_idx;
5250 m_list[hack_m_idx_ii].hold_o_idx = back_m.hold_o_idx;
5257 /* Placing the new monster failed */
5258 if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
5260 m_list[hack_m_idx_ii] = back_m;
5262 /* Re-initialize monster process */
5265 else preserve_hold_objects = FALSE;
5268 /* Mega-hack -- preserve held objects */
5269 if (preserve_hold_objects)
5271 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
5273 /* Acquire object */
5274 object_type *o_ptr = &o_list[this_o_idx];
5276 /* Acquire next object */
5277 next_o_idx = o_ptr->next_o_idx;
5279 /* Held by new monster */
5280 o_ptr->held_m_idx = hack_m_idx_ii;
5283 else if (back_m.hold_o_idx) /* Failed (paranoia) */
5285 /* Delete objects */
5286 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
5288 /* Acquire next object */
5289 next_o_idx = o_list[this_o_idx].next_o_idx;
5291 /* Delete the object */
5292 delete_object_idx(this_o_idx);
5296 if (targeted) target_who = hack_m_idx_ii;
5297 if (health_tracked) health_track(hack_m_idx_ii);
5306 * @param x テレポート先のX座標
5307 * @param y テレポート先のY座標
5308 * @return 目標に指定通りテレポートできたならばTRUEを返す
5310 static bool dimension_door_aux(int x, int y)
5312 int plev = p_ptr->lev;
5314 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5316 if (!cave_player_teleportable_bold(y, x, 0L) ||
5317 (distance(y, x, p_ptr->y, p_ptr->x) > plev / 2 + 10) ||
5318 (!randint0(plev / 10 + 10)))
5320 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5321 teleport_player((plev + 2) * 2, TELEPORT_PASSIVE);
5328 teleport_player_to(y, x, 0L);
5337 * @brief 次元の扉処理のメインルーチン /
5339 * @return ターンを消費した場合TRUEを返す
5341 bool dimension_door(void)
5345 /* Rerutn FALSE if cancelled */
5346 if (!tgt_pt(&x, &y)) return FALSE;
5348 if (dimension_door_aux(x, y)) return TRUE;
5350 msg_print(_("精霊界から物質界に戻る時うまくいかなかった!", "You fail to exit the astral plane correctly!"));
5357 * @brief 鏡抜け処理のメインルーチン /
5358 * Mirror Master's Dimension Door
5359 * @return ターンを消費した場合TRUEを返す
5361 bool mirror_tunnel(void)
5365 /* Rerutn FALSE if cancelled */
5366 if (!tgt_pt(&x, &y)) return FALSE;
5368 if (dimension_door_aux(x, y)) return TRUE;
5370 msg_print(_("鏡の世界をうまく通れなかった!", "You fail to pass the mirror plane correctly!"));
5378 * @return ターンを消費した場合TRUEを返す
5380 bool eat_magic(int power)
5382 object_type * o_ptr;
5385 int recharge_strength = 0;
5391 char o_name[MAX_NLEN];
5393 item_tester_hook = item_tester_hook_recharge;
5396 q = _("どのアイテムから魔力を吸収しますか?", "Drain which item? ");
5397 s = _("魔力を吸収できるアイテムがありません。", "You have nothing to drain.");
5399 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return FALSE;
5403 o_ptr = &inventory[item];
5407 o_ptr = &o_list[0 - item];
5410 k_ptr = &k_info[o_ptr->k_idx];
5411 lev = k_info[o_ptr->k_idx].level;
5413 if (o_ptr->tval == TV_ROD)
5415 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
5418 if (one_in_(recharge_strength))
5420 /* Activate the failure code. */
5425 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
5427 msg_print(_("充填中のロッドから魔力を吸収することはできません。", "You can't absorb energy from a discharged rod."));
5432 o_ptr->timeout += k_ptr->pval;
5438 /* All staffs, wands. */
5439 recharge_strength = (100 + power - lev) / 15;
5442 if (recharge_strength < 0) recharge_strength = 0;
5445 if (one_in_(recharge_strength))
5447 /* Activate the failure code. */
5452 if (o_ptr->pval > 0)
5454 p_ptr->csp += lev / 2;
5457 /* XXX Hack -- unstack if necessary */
5458 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
5463 /* Get local object */
5466 /* Obtain a local object */
5467 object_copy(q_ptr, o_ptr);
5469 /* Modify quantity */
5472 /* Restore the charges */
5475 /* Unstack the used item */
5477 p_ptr->total_weight -= q_ptr->weight;
5478 item = inven_carry(q_ptr);
5481 msg_print(_("杖をまとめなおした。", "You unstack your staff."));
5486 msg_print(_("吸収できる魔力がありません!", "There's no energy there to absorb!"));
5488 if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
5492 /* Inflict the penalties for failing a recharge. */
5495 /* Artifacts are never destroyed. */
5496 if (object_is_fixed_artifact(o_ptr))
5498 object_desc(o_name, o_ptr, OD_NAME_ONLY);
5499 msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
5501 /* Artifact rods. */
5502 if (o_ptr->tval == TV_ROD)
5503 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5505 /* Artifact wands and staffs. */
5506 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
5511 /* Get the object description */
5512 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5514 /*** Determine Seriousness of Failure ***/
5516 /* Mages recharge objects more safely. */
5517 if (p_ptr->pclass == CLASS_MAGE || p_ptr->pclass == CLASS_HIGH_MAGE || p_ptr->pclass == CLASS_SORCERER || p_ptr->pclass == CLASS_MAGIC_EATER || p_ptr->pclass == CLASS_BLUE_MAGE)
5519 /* 10% chance to blow up one rod, otherwise draining. */
5520 if (o_ptr->tval == TV_ROD)
5522 if (one_in_(10)) fail_type = 2;
5525 /* 75% chance to blow up one wand, otherwise draining. */
5526 else if (o_ptr->tval == TV_WAND)
5528 if (!one_in_(3)) fail_type = 2;
5531 /* 50% chance to blow up one staff, otherwise no effect. */
5532 else if (o_ptr->tval == TV_STAFF)
5534 if (one_in_(2)) fail_type = 2;
5539 /* All other classes get no special favors. */
5542 /* 33% chance to blow up one rod, otherwise draining. */
5543 if (o_ptr->tval == TV_ROD)
5545 if (one_in_(3)) fail_type = 2;
5548 /* 20% chance of the entire stack, else destroy one wand. */
5549 else if (o_ptr->tval == TV_WAND)
5551 if (one_in_(5)) fail_type = 3;
5554 /* Blow up one staff. */
5555 else if (o_ptr->tval == TV_STAFF)
5561 /*** Apply draining and destruction. ***/
5563 /* Drain object or stack of objects. */
5566 if (o_ptr->tval == TV_ROD)
5568 msg_format(_("ロッドは破損を免れたが、魔力は全て失なわれた。",
5569 "You save your rod from destruction, but all charges are lost."), o_name);
5570 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5572 else if (o_ptr->tval == TV_WAND)
5574 msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
5577 /* Staffs aren't drained. */
5580 /* Destroy an object or one in a stack of objects. */
5583 if (o_ptr->number > 1)
5585 msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
5586 /* Reduce rod stack maximum timeout, drain wands. */
5587 if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
5588 else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
5592 msg_format(_("乱暴な魔法のために%sが何本か壊れた!", "Wild magic consumes your %s!"), o_name);
5595 /* Reduce and describe inventory */
5598 inven_item_increase(item, -1);
5599 inven_item_describe(item);
5600 inven_item_optimize(item);
5603 /* Reduce and describe floor item */
5606 floor_item_increase(0 - item, -1);
5607 floor_item_describe(0 - item);
5608 floor_item_optimize(0 - item);
5612 /* Destroy all members of a stack of objects. */
5615 if (o_ptr->number > 1)
5616 msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
5618 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
5620 /* Reduce and describe inventory */
5623 inven_item_increase(item, -999);
5624 inven_item_describe(item);
5625 inven_item_optimize(item);
5628 /* Reduce and describe floor item */
5631 floor_item_increase(0 - item, -999);
5632 floor_item_describe(0 - item);
5633 floor_item_optimize(0 - item);
5639 if (p_ptr->csp > p_ptr->msp)
5641 p_ptr->csp = p_ptr->msp;
5644 /* Redraw mana and hp */
5645 p_ptr->redraw |= (PR_MANA);
5647 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
5648 p_ptr->window |= (PW_INVEN);
5655 * @param level 召喚基準レベル
5658 * @param mode 召喚オプション
5659 * @return ターンを消費した場合TRUEを返す
5661 bool summon_kin_player(int level, int y, int x, u32b mode)
5663 bool pet = (bool)(mode & PM_FORCE_PET);
5664 if (!pet) mode |= PM_NO_PET;
5666 switch (p_ptr->mimic_form)
5669 switch (p_ptr->prace)
5673 case RACE_BARBARIAN:
5676 summon_kin_type = 'p';
5686 case RACE_MIND_FLAYER:
5689 summon_kin_type = 'h';
5692 summon_kin_type = 'o';
5694 case RACE_HALF_TROLL:
5695 summon_kin_type = 'T';
5697 case RACE_HALF_OGRE:
5698 summon_kin_type = 'O';
5700 case RACE_HALF_GIANT:
5701 case RACE_HALF_TITAN:
5703 summon_kin_type = 'P';
5706 summon_kin_type = 'y';
5709 summon_kin_type = 'K';
5712 summon_kin_type = 'k';
5715 if (one_in_(13)) summon_kin_type = 'U';
5716 else summon_kin_type = 'u';
5718 case RACE_DRACONIAN:
5719 summon_kin_type = 'd';
5723 summon_kin_type = 'g';
5726 if (one_in_(13)) summon_kin_type = 'L';
5727 else summon_kin_type = 's';
5730 summon_kin_type = 'z';
5733 summon_kin_type = 'V';
5736 summon_kin_type = 'G';
5739 summon_kin_type = 'I';
5742 summon_kin_type = '#';
5745 summon_kin_type = 'A';
5748 summon_kin_type = 'U';
5751 summon_kin_type = 'p';
5756 if (one_in_(13)) summon_kin_type = 'U';
5757 else summon_kin_type = 'u';
5759 case MIMIC_DEMON_LORD:
5760 summon_kin_type = 'U';
5763 summon_kin_type = 'V';
5766 return summon_specific((pet ? -1 : 0), y, x, level, SUMMON_KIN, mode);
5770 * @brief 皆殺し(全方向攻撃)処理
5771 * @param py プレイヤーY座標
5772 * @param px プレイヤーX座標
5779 monster_type *m_ptr;
5782 for (dir = 0; dir < 8; dir++)
5784 y = p_ptr->y + ddy_ddd[dir];
5785 x = p_ptr->x + ddx_ddd[dir];
5786 c_ptr = &cave[y][x];
5788 /* Get the monster */
5789 m_ptr = &m_list[c_ptr->m_idx];
5791 /* Hack -- attack monsters */
5792 if (c_ptr->m_idx && (m_ptr->ml || cave_have_flag_bold(y, x, FF_PROJECT)))